Passing parameters to XSL
While transforms in XML using XSL, some time it requires to pass runtime parameters to XSL.
You can create the parameters in XSL like this
<xsl:param name="title" />
And you can use the parameters as normal variables
<xsl:value-of select="$title" />
In code you need a class from System.Xml.Xsl namespace to pass the parameters as Arguments.
XsltArgumentList _RuntimeParams = new XsltArgumentList();
_RuntimeParams.AddParam("title","","Using XML - XSL Convertion");
XslTransform Transform = new XslTransform();
Transform.Load(stylesheet);
XPathDocument XmlDoc = new XPathDocument(filename);
XmlTextWriter OutputWriter = new XmlTextWriter(“MyReport.html”,null);
xslt.Transform(XmlDoc, _RuntimeParams, OutputWriter);
For more information look Url :XsltArgumentList in MSDN
Google chart API – Introduction
Google.com introduced a new API for charting purposes. You can get more information about the Google Chart API on this site. It is very simple and powerful charting api. And you can pass the parameters as query strings and the api will return images, so that you can use that in <IMG> tags
If you are developing something in Web, and want to use charts, then Google API is nice choice.
Printing Infopath forms
While working in Infopath forms, there may some situations where you may need to Print the InfoPath form. But the problem of Infopath API is that we can’t specify the printer name for printing. Like this one
InfoApp.XDocuments(0).PrintOut()
The printout method doesn’t have any parameters like Printer name or port etc. As a workaround you can export the Infopath document as Word, and print the document using Word API, where you can specify the printer name. To export the Infopath as Word there is no direct method, but you can do export to “MHT”(MHTML Document), and change the extention to “.doc” and using Word.Application you can open it and Print.
'Creating the Infopath application
Dim InfoApp As New InfoPath.Application()
'Opening the Infopath document.
InfoApp.XDocuments.Open("C:\Sample\template.xml")
'Exporting the document as Word(MHT)
InfoApp.XDocuments(0).View.Export("C:\Sample\Samplex.doc", "MHT")
Let me know if you find any other solutions
Calling Synchronous Methods Asynchronously – I
In .Net you can call a Synchronous method, asynchronously using delegates. Here is the code
Public Class Form1
Public Delegate Sub JobWithDelayDelegate(ByVal Ar As String)
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Public MyJobWithDelayDelegate As New JobWithDelayDelegate(AddressOf JobWithDelay)
MyJobWithDelayDelegate.BeginInvoke("Hello", Nothing, Nothing)
End Sub
Private Sub JobWithDelay(ByVal Arg1 As String)
System.Threading.Thread.Sleep(60000)
MessageBox.Show(Arg1)
End Sub
End Class
The JobWithDelay method, if we call synchronously, the UI will hang, and if it is taking too much time there is no option available to cancel the operation too. But using asynchronous call, the UI will not hang, and if you wish you can put a method, which cancel the call too.
MyJobWithDelayDelegate.EndInvoke(Nothing)
You can get more information on this url : Calling Synchronous Methods Asynchronously on MSDN
Your first Sync application using MS Sync Framework
In my previous post I had given a very small introduction to Sync Framework, in this post I am implementing Sync service for two folders.
Dim SourceSyncProvider as new FileSyncProvider(GetRepId(), SourcePath) Dim TargetSyncProvider as new FileSyncProvider(GetRepId(), TargetPath) Dim SyncOrchestrator = New SyncOrchestrator() SyncOrchestrator.LocalProvider = SourceSyncProvider SyncOrchestrator.RemoteProvider = TargetSyncProvider SyncOrchestrator.Direction = Microsoft.Synchronization.SyncDirectionOrder.Download SyncOrchestrator.Synchronize()
It will Synchronize(Download), all file and folder changes from Target to source. The GetRepId() method returns Guid values for Sync.
With help of FileSyncProvider.DetectChanges method, we can find the changes. To preview the changes the FileSyncProvider.PreviewMode will help, change the value to True, it will not sync the files, and by using ApplyingChange event we can find the changes.