1. Rename "form.XSN" to "form.ZIP"
2. Extract template.XML and view1.XSL
3. Run the code to convert template.XML to template.HTML
4. Verify that template.HTML looks ok
4. Loop thru other xml docs in your sharepoint library created from that infopath template and convert them all to htmls.
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Xml;
using System.Xml.Xsl;
using System.Web ;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string path;
path = @"R:\\XSN\\EmployeeOrientationForm\\";
XslCompiledTransform xslt = new XslCompiledTransform();
xslt.Load(path+"view1.xsl");
// Execute the transform and output the results to a file.
xslt.Transform(path+"template.xml", path+"template.html");
}
};
}
http://msdn.microsoft.com/en-us/library/system.xml.xsl.xslcompiledtransform.aspx
http://code.cmsstores.com/infopath-form-to-html-using-c/
http://vamsheewithyou.blogspot.com/2010/12/infopath-form-to-html-using-csharp.html
Free Microsoft Office Documents Recovery
Thank you for visiting my blog. It is all started with Microsoft Word/Excel document recovery method that I implemented at work. My coworkers were so impressed that they “forced” me to create a webpage and post steps required for that method. Later I realized that not many people are reading this blog and I decided to keep it for myself and post here some code and ideas that I could reuse for the future. If you find my posts useful drop a comment for me.
Tuesday, January 31, 2012
Convert InfoPath form to a WebPage
Thursday, January 19, 2012
Sending Emails with RAISEERROR
I was going over sql server store procedures and decided to improve error handling with
try-catch code. Everything worked fine except that the RAISEERROR didn't send any emails to an operator.
The solution was simple all I had to do is to add "with log" option.
begin try
...
end try
begin catchraiseerror ('mydb.dbo.myproc failed!',16,1) WITH log
end catch
Friday, January 6, 2012
Email warning when mailbox size is over limit on Exchange 2010 with PowerShell Script
I had to write a PowerShell script for Exchange 2010 that sends an email to a user when his mailbox size exceeded 1Gb. Here is the script:
If ((Get-PSSnapin | where {$_.Name -match "Exchange.Management"}) -eq $null)
{
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010
}
$toArray=Get-MailboxServer | Get-Mailbox | foreach-object {$email = $_.primarysmtpaddress; $_ | Get-MailboxStatistics | Where {$_.TotalItemSize.Value.ToMB() -gt 1024 } | select @{ expression={$email}}}
$from="from@from.com"
Foreach ($to in $toArray)
{
$s=[string]$to
[int]$Start = $s.IndexOf("=")
[int]$End = $s.IndexOf("}")
[string]$ss=$s.Substring($Start+1,$End-$start-1)
$messageParameters = @{
smtpServer = “smtp server”
From = [string]$from
To = $ss
Subject = "Warning!"
Body = “Your mailbox is over 1Gb in size. Please delete old email messages to reduce size of your mailbox”
}
Send-MailMessage @messageParameters -BodyAsHtml
}
Creating Scheduled Tasks for Exchange 2010 PowerShell Scripts:
http://www.mikepfeiffer.net/2010/02/creating-scheduled-tasks-for-exchange-2010-powershell-scripts/
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -command ". 'C:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExchange.ps1'; Connect-ExchangeServer -auto; c:\Scripts\MoveMailboxes.ps1"
Monday, November 14, 2011
Corrupted InfoPath forms get published to SharePoint
MS Access 2010 /pwd command line switch is missing
To automate a report from encrypted database I used a free uility AutoHotkey.
Here is the source script, that I compiled to mydb.exe and then deleted
-----------------------------------------------------------------------------------------------------------------
run "C:\Program Files\Microsoft Office\OFFICE14\MSACCESS.EXE" c:\projects\mydb.mdb /cmd "auto"
WinWait, Password Required, , 3
sendinput {p}
sendinput {a}
sendinput {s}
sendinput {s}
sendinput {w}
sendinput {r}
sendinput {d}
sendinput {Enter}
return
-----------------------------------------------------------------------------------------------------------------
Then I used mydb.exe to run as a scheduled job.
Monday, October 31, 2011
Microsoft Windows Updates Report for SOX Audit
Our system center server failed to provide a report that would satisfy the auditor.
He wanted to see the latest updates for every single computer : servers and desktops.
To solve this problem I used a PowerShell script to retrieve system event log and filter the output for event code 19 which is:” Installation Successful: Windows successfully installed the following update:...”
get-content f:\WindowsUpdates\pc.txt | f:\WindowsUpdates\reportevent.ps1 –debug
where
Report-Events.ps1 was taken from here http://jdhitsolutions.com/resources/scripts/Report-Events.txt
and modified query string to filter out all other events:
$query="Select ComputerName,Message,TimeWritten,Type,SourceName,EventCode,Logfile from win32_NTLogEvent WHERE (EventCode=19) and Logfile='System' "
And list computers thet were down or failed to obtain the updates:
$err+=" *** No matching events found for $computername ****
"
To populate pc.txt I copied the script from
http://blogs.technet.com/b/heyscriptingguy/archive/2006/11/09/how-can-i-use-windows-powershell-to-get-a-list-of-all-my-computers.aspx
$strCategory = "computer"
$objDomain = New-Object System.DirectoryServices.DirectoryEntry
$objSearcher = New-Object System.DirectoryServices.DirectorySearcher
$objSearcher.SearchRoot = $objDomain
$objSearcher.Filter = ("(objectCategory=$strCategory)")
$colProplist = "name"
foreach ($i in $colPropList){$objSearcher.PropertiesToLoad.Add($i)}
$colResults = $objSearcher.FindAll()
foreach ($objResult in $colResults)
{$objComputer = $objResult.Properties; $objComputer.name}
Wednesday, September 21, 2011
Html5 links
Html5 Links: Dive into Html5 - a great overview of what Html5 has to offer.
http://diveintohtml5.org/IE9
Test Drive - cool applications made by the IE team.
http://ie.microsoft.com/testdrive/
Chrome Experiments - like IE9 Test drive but from the chrome team
http://www.chromeexperiments.com/ Apple Html5 - for Safari
http://www.apple.com/html5
/ Dynamic Pages via Media Queries - a list apart has good articles on web in general
http://www.alistapart.com/articles/responsive-web-design/ Html5 demos - Demos for individual features http://html5demos.com/
Internet Explorer links:• beautyoftheweb: http://www.beautyoftheweb.com/•
Internet Explorer Test Drive: http://ie.microsoft.com/testdrive/•
Pin Site Radio:
http://ie.microsoft.com/testdrive/Browser/Radio/Default.html
• Internet Explorer Developer Center:
http://msdn.microsoft.com/en-us/ie
• IEBlog: http://blogs.msdn.com/b/ie/