diff --git a/Examples/Mvc.CS/Controllers/DocumentViewerController.Stream.cs b/Examples/Mvc.CS/Controllers/DocumentViewerController.Stream.cs index aba87b8..8ef4f40 100644 --- a/Examples/Mvc.CS/Controllers/DocumentViewerController.Stream.cs +++ b/Examples/Mvc.CS/Controllers/DocumentViewerController.Stream.cs @@ -34,6 +34,7 @@ public ActionResult Stream() // So it can be any string value that your IDocumentHandler implementation understands. documentViewer.Document = "~/App_Data/ExampleFiles/Default.docx"; + //--------------------------------------------- // Here is an example (commented out) for loading a document from database. // See below for DbDocumentHandler class which implements IDocumentHandler interface. @@ -41,7 +42,14 @@ public ActionResult Stream() /* documentViewer.DocumentHandlerType = typeof(DbDocumentHandler); documentViewer.Document = "176"; // a file path or identifier + + // When you need to pass custom parameters along with the input file to your handler implementation, + // use documentViewer.DocumentHandlerParameters property to set your parameters. + // These will be passed to the methods of your handler implementation: + documentViewer.DocumentHandlerParameters.Set("connectionString", "SOME CONNECTION STRING"); */ + //--------------------------------------------- + //--------------------------------------------- //When you don't have a file on disk and implementing IDocumentHandler interface is not convenient, @@ -65,6 +73,8 @@ public ActionResult Stream() byteArray ); */ + //--------------------------------------------- + return View(documentViewer); } @@ -84,7 +94,7 @@ public class CustomDocumentHandler : IDocumentHandler // the input file that was requested to be loaded in DocumentViewer // // Return a DocumentInfo instance initialized with required information from this method. - public DocumentInfo GetInfo(string inputFile) + public DocumentInfo GetInfo(string inputFile, DocumentHandlerParameters handlerParameters) { var physicalPath = HttpContext.Current.Server.MapPath(inputFile); var fileInfo = new FileInfo(physicalPath); @@ -123,7 +133,7 @@ public DocumentInfo GetInfo(string inputFile) // for you to locate and open a corresponding stream. // // Return a StreamResult instance initialized with a readable System.IO.Stream object. - public StreamResult OpenRead(string inputFile, InputOptions inputOptions) + public StreamResult OpenRead(string inputFile, InputOptions inputOptions, DocumentHandlerParameters handlerParameters) { var physicalPath = HttpContext.Current.Server.MapPath(inputFile); var stream = File.OpenRead(physicalPath); @@ -148,12 +158,16 @@ public class DbDocumentHandler : IDocumentHandler // the input file that was requested to be loaded in DocumentViewer // // Return a DocumentInfo instance initialized with required information from this method. - public DocumentInfo GetInfo(string inputFile) + public DocumentInfo GetInfo(string inputFile, DocumentHandlerParameters handlerParameters) { var fileId = inputFile; string fileName; - using (var connection = new SqlConnection("CONNECTION STRING")) + // Get your parameters that were set in documentViewer.DocumentHandlerParameters property + // The type for the generic Get method should be the same as the set value's type. + var connectionString = handlerParameters.Get("connectionString"); + + using (var connection = new SqlConnection(connectionString)) { connection.Open(); @@ -203,12 +217,16 @@ public DocumentInfo GetInfo(string inputFile) // for you to locate and open a corresponding stream. // // Return a StreamResult instance initialized with a readable System.IO.Stream object. - public StreamResult OpenRead(string inputFile, InputOptions inputOptions) + public StreamResult OpenRead(string inputFile, InputOptions inputOptions, DocumentHandlerParameters handlerParameters) { var fileId = inputFile; byte[] fileBytes; - using (var connection = new SqlConnection("CONNECTION STRING")) + // Get your parameters that were set in documentViewer.DocumentHandlerParameters property + // The type for the generic Get method should be the same as the set value's type. + var connectionString = handlerParameters.Get("connectionString"); + + using (var connection = new SqlConnection(connectionString)) { connection.Open(); diff --git a/Examples/Mvc.CS/Mvc.CS.csproj b/Examples/Mvc.CS/Mvc.CS.csproj index ef3a47b..2aac339 100644 --- a/Examples/Mvc.CS/Mvc.CS.csproj +++ b/Examples/Mvc.CS/Mvc.CS.csproj @@ -53,7 +53,7 @@ ..\packages\GleamTech.Core.2.3.3\lib\net40\GleamTech.Core.dll - ..\packages\DocumentUltimate.3.12.0\lib\net40\GleamTech.DocumentUltimate.dll + ..\packages\DocumentUltimate.3.13.0\lib\net40\GleamTech.DocumentUltimate.dll diff --git a/Examples/Mvc.CS/packages.config b/Examples/Mvc.CS/packages.config index 39d7a2d..e8ed06f 100644 --- a/Examples/Mvc.CS/packages.config +++ b/Examples/Mvc.CS/packages.config @@ -5,5 +5,5 @@ - + diff --git a/Examples/Mvc.VB/Controllers/DocumentViewerController.Stream.vb b/Examples/Mvc.VB/Controllers/DocumentViewerController.Stream.vb index 6033924..8d1e833 100644 --- a/Examples/Mvc.VB/Controllers/DocumentViewerController.Stream.vb +++ b/Examples/Mvc.VB/Controllers/DocumentViewerController.Stream.vb @@ -31,6 +31,7 @@ Namespace Controllers ' So it can be any string value that your IDocumentHandler implementation understands. documentViewer.Document = "~/App_Data/ExampleFiles/Default.docx" + ' --------------------------------------------- ' Here is an example (commented out) for loading a document from database. ' See below for DbDocumentHandler class which implements IDocumentHandler interface. @@ -38,6 +39,12 @@ Namespace Controllers 'documentViewer.DocumentHandlerType = typeof(DbDocumentHandler); 'documentViewer.Document = "176"; ' a file path or identifier + ' When you need to pass custom parameters along with the input file to your handler implementation, + ' use documentViewer.DocumentHandlerParameters property to set your parameters. + ' These will be passed to the methods of your handler implementation: + 'documentViewer.DocumentHandlerParameters.Set("connectionString", "SOME CONNECTION STRING") + ' --------------------------------------------- + ' --------------------------------------------- ' When you don't have a file on disk and implementing IDocumentHandler interface is not convenient, @@ -57,7 +64,7 @@ Namespace Controllers ' New DocumentInfo(uniqueId, fileName), ' byteArray ') - + ' --------------------------------------------- Return View(documentViewer) End Function @@ -80,7 +87,7 @@ Namespace Controllers ' the input file that was requested to be loaded in DocumentViewer ' ' Return a DocumentInfo instance initialized with required information from this method. - Public Function GetInfo(inputFile As String) As DocumentInfo Implements IDocumentHandler.GetInfo + Public Function GetInfo(inputFile As String, handlerParameters As DocumentHandlerParameters) As DocumentInfo Implements IDocumentHandler.GetInfo Dim physicalPath = HttpContext.Current.Server.MapPath(inputFile) Dim fileInfo As New FileInfo(physicalPath) @@ -120,7 +127,7 @@ Namespace Controllers ' for you to locate and open a corresponding stream. ' ' Return a StreamResult instance initialized with a readable System.IO.Stream object. - Public Function OpenRead(inputFile As String, inputOptions As InputOptions) As StreamResult Implements IDocumentHandler.OpenRead + Public Function OpenRead(inputFile As String, inputOptions As InputOptions, handlerParameters As DocumentHandlerParameters) As StreamResult Implements IDocumentHandler.OpenRead Dim physicalPath = HttpContext.Current.Server.MapPath(inputFile) Dim stream = File.OpenRead(physicalPath) @@ -148,11 +155,15 @@ Namespace Controllers ' the input file that was requested to be loaded in DocumentViewer ' ' Return a DocumentInfo instance initialized with required information from this method. - Public Function GetInfo(inputFile As String) As DocumentInfo Implements IDocumentHandler.GetInfo + Public Function GetInfo(inputFile As String, handlerParameters As DocumentHandlerParameters) As DocumentInfo Implements IDocumentHandler.GetInfo Dim fileId = inputFile Dim fileName As String - Using connection As New SqlConnection("CONNECTION STRING") + ' Get your parameters that were set in documentViewer.DocumentHandlerParameters property + ' The type for the generic Get method should be the same as the set value's type. + Dim connectionString = handlerParameters.Get(Of String)("connectionString") + + Using connection As New SqlConnection(connectionString) connection.Open() Dim sql = "SELECT FileName FROM FileTable WHERE FileId=" + fileId @@ -199,11 +210,15 @@ Namespace Controllers ' for you to locate and open a corresponding stream. ' ' Return a StreamResult instance initialized with a readable System.IO.Stream object. - Public Function OpenRead(inputFile As String, inputOptions As InputOptions) As StreamResult Implements IDocumentHandler.OpenRead + Public Function OpenRead(inputFile As String, inputOptions As InputOptions, handlerParameters As DocumentHandlerParameters) As StreamResult Implements IDocumentHandler.OpenRead Dim fileId = inputFile Dim fileBytes As Byte() - Using connection As New SqlConnection("CONNECTION STRING") + ' Get your parameters that were set in documentViewer.DocumentHandlerParameters property + ' The type for the generic Get method should be the same as the set value's type. + Dim connectionString = handlerParameters.Get(Of String)("connectionString") + + Using connection As New SqlConnection(connectionString) connection.Open() Dim sql = "SELECT FileBytes FROM FileTable WHERE FileId=" + fileId @@ -225,4 +240,5 @@ Namespace Controllers Return New StreamResult(stream) End Function End Class + End Namespace diff --git a/Examples/Mvc.VB/Mvc.VB.vbproj b/Examples/Mvc.VB/Mvc.VB.vbproj index 603f109..bdffeb6 100644 --- a/Examples/Mvc.VB/Mvc.VB.vbproj +++ b/Examples/Mvc.VB/Mvc.VB.vbproj @@ -57,7 +57,7 @@ ..\packages\GleamTech.Core.2.3.3\lib\net40\GleamTech.Core.dll - ..\packages\DocumentUltimate.3.12.0\lib\net40\GleamTech.DocumentUltimate.dll + ..\packages\DocumentUltimate.3.13.0\lib\net40\GleamTech.DocumentUltimate.dll diff --git a/Examples/Mvc.VB/packages.config b/Examples/Mvc.VB/packages.config index 39d7a2d..e8ed06f 100644 --- a/Examples/Mvc.VB/packages.config +++ b/Examples/Mvc.VB/packages.config @@ -5,5 +5,5 @@ - + diff --git a/Examples/WebForms.CS/DocumentViewer/Stream.aspx.cs b/Examples/WebForms.CS/DocumentViewer/Stream.aspx.cs index b0c189f..ce65913 100644 --- a/Examples/WebForms.CS/DocumentViewer/Stream.aspx.cs +++ b/Examples/WebForms.CS/DocumentViewer/Stream.aspx.cs @@ -26,6 +26,7 @@ protected void Page_Load(object sender, EventArgs e) // So it can be any string value that your IDocumentHandler implementation understands. documentViewer.Document = "~/App_Data/ExampleFiles/Default.docx"; + //--------------------------------------------- // Here is an example (commented out) for loading a document from database. // See below for DbDocumentHandler class which implements IDocumentHandler interface. @@ -33,7 +34,14 @@ protected void Page_Load(object sender, EventArgs e) /* documentViewer.DocumentHandlerType = typeof(DbDocumentHandler); documentViewer.Document = "176"; // a file path or identifier + + // When you need to pass custom parameters along with the input file to your handler implementation, + // use documentViewer.DocumentHandlerParameters property to set your parameters. + // These will be passed to the methods of your handler implementation: + documentViewer.DocumentHandlerParameters.Set("connectionString", "SOME CONNECTION STRING"); */ + //--------------------------------------------- + //--------------------------------------------- //When you don't have a file on disk and implementing IDocumentHandler interface is not convenient, @@ -57,6 +65,7 @@ protected void Page_Load(object sender, EventArgs e) byteArray ); */ + //--------------------------------------------- } } @@ -74,7 +83,7 @@ public class CustomDocumentHandler : IDocumentHandler // the input file that was requested to be loaded in DocumentViewer // // Return a DocumentInfo instance initialized with required information from this method. - public DocumentInfo GetInfo(string inputFile) + public DocumentInfo GetInfo(string inputFile, DocumentHandlerParameters handlerParameters) { var physicalPath = HttpContext.Current.Server.MapPath(inputFile); var fileInfo = new FileInfo(physicalPath); @@ -113,7 +122,7 @@ public DocumentInfo GetInfo(string inputFile) // for you to locate and open a corresponding stream. // // Return a StreamResult instance initialized with a readable System.IO.Stream object. - public StreamResult OpenRead(string inputFile, InputOptions inputOptions) + public StreamResult OpenRead(string inputFile, InputOptions inputOptions, DocumentHandlerParameters handlerParameters) { var physicalPath = HttpContext.Current.Server.MapPath(inputFile); var stream = File.OpenRead(physicalPath); @@ -138,12 +147,16 @@ public class DbDocumentHandler : IDocumentHandler // the input file that was requested to be loaded in DocumentViewer // // Return a DocumentInfo instance initialized with required information from this method. - public DocumentInfo GetInfo(string inputFile) + public DocumentInfo GetInfo(string inputFile, DocumentHandlerParameters handlerParameters) { var fileId = inputFile; string fileName; - using (var connection = new SqlConnection("CONNECTION STRING")) + // Get your parameters that were set in documentViewer.DocumentHandlerParameters property + // The type for the generic Get method should be the same as the set value's type. + var connectionString = handlerParameters.Get("connectionString"); + + using (var connection = new SqlConnection(connectionString)) { connection.Open(); @@ -193,12 +206,16 @@ public DocumentInfo GetInfo(string inputFile) // for you to locate and open a corresponding stream. // // Return a StreamResult instance initialized with a readable System.IO.Stream object. - public StreamResult OpenRead(string inputFile, InputOptions inputOptions) + public StreamResult OpenRead(string inputFile, InputOptions inputOptions, DocumentHandlerParameters handlerParameters) { var fileId = inputFile; byte[] fileBytes; - using (var connection = new SqlConnection("CONNECTION STRING")) + // Get your parameters that were set in documentViewer.DocumentHandlerParameters property + // The type for the generic Get method should be the same as the set value's type. + var connectionString = handlerParameters.Get("connectionString"); + + using (var connection = new SqlConnection(connectionString)) { connection.Open(); diff --git a/Examples/WebForms.CS/WebForms.CS.csproj b/Examples/WebForms.CS/WebForms.CS.csproj index 7cc5395..3ec3916 100644 --- a/Examples/WebForms.CS/WebForms.CS.csproj +++ b/Examples/WebForms.CS/WebForms.CS.csproj @@ -51,7 +51,7 @@ ..\packages\GleamTech.Core.2.3.3\lib\net40\GleamTech.Core.dll - ..\packages\DocumentUltimate.3.12.0\lib\net40\GleamTech.DocumentUltimate.dll + ..\packages\DocumentUltimate.3.13.0\lib\net40\GleamTech.DocumentUltimate.dll diff --git a/Examples/WebForms.CS/packages.config b/Examples/WebForms.CS/packages.config index 7dacf29..e3ca76c 100644 --- a/Examples/WebForms.CS/packages.config +++ b/Examples/WebForms.CS/packages.config @@ -1,5 +1,5 @@ - + diff --git a/Examples/WebForms.VB/DocumentViewer/Stream.aspx.vb b/Examples/WebForms.VB/DocumentViewer/Stream.aspx.vb index 2e9622b..47da462 100644 --- a/Examples/WebForms.VB/DocumentViewer/Stream.aspx.vb +++ b/Examples/WebForms.VB/DocumentViewer/Stream.aspx.vb @@ -31,6 +31,12 @@ Namespace DocumentViewer 'documentViewer.DocumentHandlerType = typeof(DbDocumentHandler); 'documentViewer.Document = "176"; ' a file path or identifier + ' When you need to pass custom parameters along with the input file to your handler implementation, + ' use documentViewer.DocumentHandlerParameters property to set your parameters. + ' These will be passed to the methods of your handler implementation: + 'documentViewer.DocumentHandlerParameters.Set("connectionString", "SOME CONNECTION STRING") + ' --------------------------------------------- + ' --------------------------------------------- ' When you don't have a file on disk and implementing IDocumentHandler interface is not convenient, @@ -50,6 +56,7 @@ Namespace DocumentViewer ' New DocumentInfo(uniqueId, fileName), ' byteArray ') + ' --------------------------------------------- End Sub End Class @@ -70,7 +77,7 @@ Namespace DocumentViewer ' the input file that was requested to be loaded in DocumentViewer ' ' Return a DocumentInfo instance initialized with required information from this method. - Public Function GetInfo(inputFile As String) As DocumentInfo Implements IDocumentHandler.GetInfo + Public Function GetInfo(inputFile As String, handlerParameters As DocumentHandlerParameters) As DocumentInfo Implements IDocumentHandler.GetInfo Dim physicalPath = HttpContext.Current.Server.MapPath(inputFile) Dim fileInfo As New FileInfo(physicalPath) @@ -110,7 +117,7 @@ Namespace DocumentViewer ' for you to locate and open a corresponding stream. ' ' Return a StreamResult instance initialized with a readable System.IO.Stream object. - Public Function OpenRead(inputFile As String, inputOptions As InputOptions) As StreamResult Implements IDocumentHandler.OpenRead + Public Function OpenRead(inputFile As String, inputOptions As InputOptions, handlerParameters As DocumentHandlerParameters) As StreamResult Implements IDocumentHandler.OpenRead Dim physicalPath = HttpContext.Current.Server.MapPath(inputFile) Dim stream = File.OpenRead(physicalPath) @@ -138,11 +145,15 @@ Namespace DocumentViewer ' the input file that was requested to be loaded in DocumentViewer ' ' Return a DocumentInfo instance initialized with required information from this method. - Public Function GetInfo(inputFile As String) As DocumentInfo Implements IDocumentHandler.GetInfo + Public Function GetInfo(inputFile As String, handlerParameters As DocumentHandlerParameters) As DocumentInfo Implements IDocumentHandler.GetInfo Dim fileId = inputFile Dim fileName As String - Using connection As New SqlConnection("CONNECTION STRING") + ' Get your parameters that were set in documentViewer.DocumentHandlerParameters property + ' The type for the generic Get method should be the same as the set value's type. + Dim connectionString = handlerParameters.Get(Of String)("connectionString") + + Using connection As New SqlConnection(connectionString) connection.Open() Dim sql = "SELECT FileName FROM FileTable WHERE FileId=" + fileId @@ -189,11 +200,15 @@ Namespace DocumentViewer ' for you to locate and open a corresponding stream. ' ' Return a StreamResult instance initialized with a readable System.IO.Stream object. - Public Function OpenRead(inputFile As String, inputOptions As InputOptions) As StreamResult Implements IDocumentHandler.OpenRead + Public Function OpenRead(inputFile As String, inputOptions As InputOptions, handlerParameters As DocumentHandlerParameters) As StreamResult Implements IDocumentHandler.OpenRead Dim fileId = inputFile Dim fileBytes As Byte() - Using connection As New SqlConnection("CONNECTION STRING") + ' Get your parameters that were set in documentViewer.DocumentHandlerParameters property + ' The type for the generic Get method should be the same as the set value's type. + Dim connectionString = handlerParameters.Get(Of String)("connectionString") + + Using connection As New SqlConnection(connectionString) connection.Open() Dim sql = "SELECT FileBytes FROM FileTable WHERE FileId=" + fileId diff --git a/Examples/WebForms.VB/WebForms.VB.vbproj b/Examples/WebForms.VB/WebForms.VB.vbproj index 8de1f5e..cae7d20 100644 --- a/Examples/WebForms.VB/WebForms.VB.vbproj +++ b/Examples/WebForms.VB/WebForms.VB.vbproj @@ -65,7 +65,7 @@ ..\packages\GleamTech.Core.2.3.3\lib\net40\GleamTech.Core.dll - ..\packages\DocumentUltimate.3.12.0\lib\net40\GleamTech.DocumentUltimate.dll + ..\packages\DocumentUltimate.3.13.0\lib\net40\GleamTech.DocumentUltimate.dll diff --git a/Examples/WebForms.VB/packages.config b/Examples/WebForms.VB/packages.config index 7dacf29..e3ca76c 100644 --- a/Examples/WebForms.VB/packages.config +++ b/Examples/WebForms.VB/packages.config @@ -1,5 +1,5 @@ - +