diff --git a/EDMI_ClientSuite/frmFileTest.Designer.vb b/EDMI_ClientSuite/frmFileTest.Designer.vb index dc217c3f..d343ea22 100644 --- a/EDMI_ClientSuite/frmFileTest.Designer.vb +++ b/EDMI_ClientSuite/frmFileTest.Designer.vb @@ -23,7 +23,11 @@ Partial Class frmFileTest Private Sub InitializeComponent() Me.Button1 = New System.Windows.Forms.Button() - Me.ListBox1 = New System.Windows.Forms.ListBox() + Me.listboxLog = New System.Windows.Forms.ListBox() + Me.btnDocByDocId = New System.Windows.Forms.Button() + Me.TextBox1 = New System.Windows.Forms.TextBox() + Me.btnDocByContainerId = New System.Windows.Forms.Button() + Me.TextBox2 = New System.Windows.Forms.TextBox() Me.SuspendLayout() ' 'Button1 @@ -35,27 +39,69 @@ Partial Class frmFileTest Me.Button1.Text = "Upload file" Me.Button1.UseVisualStyleBackColor = True ' - 'ListBox1 + 'listboxLog ' - Me.ListBox1.FormattingEnabled = True - Me.ListBox1.Location = New System.Drawing.Point(12, 45) - Me.ListBox1.Name = "ListBox1" - Me.ListBox1.Size = New System.Drawing.Size(256, 95) - Me.ListBox1.TabIndex = 1 + Me.listboxLog.Dock = System.Windows.Forms.DockStyle.Bottom + Me.listboxLog.FormattingEnabled = True + Me.listboxLog.Location = New System.Drawing.Point(0, 225) + Me.listboxLog.Name = "listboxLog" + Me.listboxLog.Size = New System.Drawing.Size(800, 225) + Me.listboxLog.TabIndex = 1 + ' + 'btnDocByDocId + ' + Me.btnDocByDocId.Location = New System.Drawing.Point(655, 12) + Me.btnDocByDocId.Name = "btnDocByDocId" + Me.btnDocByDocId.Size = New System.Drawing.Size(133, 32) + Me.btnDocByDocId.TabIndex = 2 + Me.btnDocByDocId.Text = "GetDocByDocId" + Me.btnDocByDocId.UseVisualStyleBackColor = True + ' + 'TextBox1 + ' + Me.TextBox1.Location = New System.Drawing.Point(425, 24) + Me.TextBox1.Name = "TextBox1" + Me.TextBox1.Size = New System.Drawing.Size(224, 20) + Me.TextBox1.TabIndex = 3 + ' + 'btnDocByContainerId + ' + Me.btnDocByContainerId.Location = New System.Drawing.Point(655, 50) + Me.btnDocByContainerId.Name = "btnDocByContainerId" + Me.btnDocByContainerId.Size = New System.Drawing.Size(133, 32) + Me.btnDocByContainerId.TabIndex = 4 + Me.btnDocByContainerId.Text = "GetDocByContainerId" + Me.btnDocByContainerId.UseVisualStyleBackColor = True + ' + 'TextBox2 + ' + Me.TextBox2.Location = New System.Drawing.Point(425, 62) + Me.TextBox2.Name = "TextBox2" + Me.TextBox2.Size = New System.Drawing.Size(224, 20) + Me.TextBox2.TabIndex = 3 ' 'frmFileTest ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size(800, 450) - Me.Controls.Add(Me.ListBox1) + Me.Controls.Add(Me.btnDocByContainerId) + Me.Controls.Add(Me.TextBox2) + Me.Controls.Add(Me.TextBox1) + Me.Controls.Add(Me.btnDocByDocId) + Me.Controls.Add(Me.listboxLog) Me.Controls.Add(Me.Button1) Me.Name = "frmFileTest" Me.Text = "frmFileTest" Me.ResumeLayout(False) + Me.PerformLayout() End Sub Friend WithEvents Button1 As Button - Friend WithEvents ListBox1 As ListBox + Friend WithEvents listboxLog As ListBox + Friend WithEvents btnDocByDocId As Button + Friend WithEvents TextBox1 As TextBox + Friend WithEvents btnDocByContainerId As Button + Friend WithEvents TextBox2 As TextBox End Class diff --git a/EDMI_ClientSuite/frmFileTest.vb b/EDMI_ClientSuite/frmFileTest.vb index eaf6b68b..f9f6759a 100644 --- a/EDMI_ClientSuite/frmFileTest.vb +++ b/EDMI_ClientSuite/frmFileTest.vb @@ -17,24 +17,72 @@ Public Class frmFileTest Private Async Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim oDialog = New OpenFileDialog() - Dim oResult = oDialog.ShowDialog() + Dim oDialogResult = oDialog.ShowDialog() - If oResult <> DialogResult.OK Then + If oDialogResult <> DialogResult.OK Then Exit Sub End If Try - Dim oDocObject = Await _fileOp.ImportFileAsync(oDialog.FileName) + Dim oResult = Await _fileOp.ImportFileAsync(oDialog.FileName) - If oDocObject.OK = False Then - MsgBox(oDocObject.ErrorMessage) + If oResult.OK = False Then + MsgBox(oResult.ErrorMessage) Exit Sub End If - ListBox1.Items.Add(oDocObject) + listboxLog.Items.Add($"Document uploaded!") + listboxLog.Items.Add($"DocId: {oResult.Document._DocumentId}") + listboxLog.Items.Add($"ContainerId: {oResult.Document._ContainerId}") + listboxLog.Items.Add($"Filename: {oResult.Document._FileName}") + listboxLog.Items.Add($"----------------------------------------------------------") Catch ex As Exception MsgBox(ex.Message) _Logger.Error(ex) End Try End Sub + + Private Sub btnDocByDocId_Click(sender As Object, e As EventArgs) Handles btnDocByDocId.Click + Try + Dim oDocId As Int64 = Int64.Parse(TextBox1.Text) + Dim oResult = _fileOp.GetDocumentByDocumentId(oDocId) + + If Not oResult.OK Then + MsgBox(oResult.ErrorMessage) + Exit Sub + End If + + Dim oDocObject = oResult.Document + + listboxLog.Items.Add($"Document fetched!") + listboxLog.Items.Add($"DocId: {oDocObject._DocumentId}") + listboxLog.Items.Add($"ContainerId: {oDocObject._ContainerId}") + listboxLog.Items.Add($"Filename: {oDocObject._FileName}") + listboxLog.Items.Add($"----------------------------------------------------------") + Catch ex As Exception + _ErrorHandler.ShowErrorMessage(ex) + End Try + End Sub + + Private Sub btnDocByContainerId_Click(sender As Object, e As EventArgs) Handles btnDocByContainerId.Click + Try + Dim oContainerId As Int64 = Int64.Parse(TextBox2.Text) + Dim oResult = _fileOp.GetDocumentByContainerId(oContainerId) + + If Not oResult.OK Then + MsgBox(oResult.ErrorMessage) + Exit Sub + End If + + Dim oDocObject = oResult.Document + + listboxLog.Items.Add($"Document fetched!") + listboxLog.Items.Add($"DocId: {oDocObject._DocumentId}") + listboxLog.Items.Add($"ContainerId: {oDocObject._ContainerId}") + listboxLog.Items.Add($"Filename: {oDocObject._FileName}") + listboxLog.Items.Add($"----------------------------------------------------------") + Catch ex As Exception + _ErrorHandler.ShowErrorMessage(ex) + End Try + End Sub End Class \ No newline at end of file diff --git a/EDMI_FILE_OPs/Channel.vb b/EDMI_FILE_OPs/Channel.vb index 03a749e5..c18a7311 100644 --- a/EDMI_FILE_OPs/Channel.vb +++ b/EDMI_FILE_OPs/Channel.vb @@ -1,3 +1,22 @@ -Public Class Channel +Imports System.ServiceModel +Public Class Channel + Public Shared Function GetBinding() As NetTcpBinding + Return New NetTcpBinding() With { + .MaxReceivedMessageSize = Constants.MAX_RECEIVED_MESSAGE_SIZE, + .MaxBufferSize = Constants.MAX_BUFFER_SIZE, + .MaxBufferPoolSize = Constants.MAX_BUFFER_POOL_SIZE, + .MaxConnections = Constants.MAX_CONNECTIONS, + .Security = New NetTcpSecurity() With { + .Mode = SecurityMode.Transport, + .Transport = New TcpTransportSecurity() With { + .ClientCredentialType = TcpClientCredentialType.Windows + } + }, + .ReaderQuotas = New Xml.XmlDictionaryReaderQuotas() With { + .MaxArrayLength = Constants.MAX_ARRAY_LENGTH, + .MaxStringContentLength = Constants.MAX_STRING_CONTENT_LENGTH + } + } + End Function End Class diff --git a/EDMI_FILE_OPs/Connected Services/EDMIServiceReference/DigitalData.Services.EDMService.wsdl b/EDMI_FILE_OPs/Connected Services/EDMIServiceReference/DigitalData.Services.EDMService.wsdl index 00043716..73fa3430 100644 --- a/EDMI_FILE_OPs/Connected Services/EDMIServiceReference/DigitalData.Services.EDMService.wsdl +++ b/EDMI_FILE_OPs/Connected Services/EDMIServiceReference/DigitalData.Services.EDMService.wsdl @@ -70,6 +70,18 @@ + + + + + + + + + + + + @@ -117,6 +129,14 @@ + + + + + + + + diff --git a/EDMI_FILE_OPs/Connected Services/EDMIServiceReference/DigitalData.Services.EDMService.xsd b/EDMI_FILE_OPs/Connected Services/EDMIServiceReference/DigitalData.Services.EDMService.xsd index 161f2f9d..2c7e8c11 100644 --- a/EDMI_FILE_OPs/Connected Services/EDMIServiceReference/DigitalData.Services.EDMService.xsd +++ b/EDMI_FILE_OPs/Connected Services/EDMIServiceReference/DigitalData.Services.EDMService.xsd @@ -139,10 +139,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + @@ -152,7 +180,7 @@ - + diff --git a/EDMI_FILE_OPs/Connected Services/EDMIServiceReference/Reference.vb b/EDMI_FILE_OPs/Connected Services/EDMIServiceReference/Reference.vb index 7005bd4b..ac61e4c2 100644 --- a/EDMI_FILE_OPs/Connected Services/EDMIServiceReference/Reference.vb +++ b/EDMI_FILE_OPs/Connected Services/EDMIServiceReference/Reference.vb @@ -363,6 +363,22 @@ Namespace EDMIServiceReference _ Function DeleteFileAsync(ByVal DocObject As EDMIServiceReference.DocumentObject) As System.Threading.Tasks.Task(Of Boolean) + _ + Function GetDocumentByDocumentId(ByVal DocumentId As Long) As EDMIServiceReference.DocumentResult + + _ + Function GetDocumentByDocumentIdAsync(ByVal DocumentId As Long) As System.Threading.Tasks.Task(Of EDMIServiceReference.DocumentResult) + + _ + Function GetDocumentByContainerId(ByVal ContainerId As String) As EDMIServiceReference.DocumentResult + + _ + Function GetDocumentByContainerIdAsync(ByVal ContainerId As String) As System.Threading.Tasks.Task(Of EDMIServiceReference.DocumentResult) + _ Function NewFileIndex(ByVal DocObject As EDMIServiceReference.DocumentObject, ByVal Syskey As String, ByVal LanguageCode As String, ByVal Value As String) As EDMIServiceReference.IndexResult @@ -481,6 +497,22 @@ Namespace EDMIServiceReference Return MyBase.Channel.DeleteFileAsync(DocObject) End Function + Public Function GetDocumentByDocumentId(ByVal DocumentId As Long) As EDMIServiceReference.DocumentResult Implements EDMIServiceReference.IEDMService.GetDocumentByDocumentId + Return MyBase.Channel.GetDocumentByDocumentId(DocumentId) + End Function + + Public Function GetDocumentByDocumentIdAsync(ByVal DocumentId As Long) As System.Threading.Tasks.Task(Of EDMIServiceReference.DocumentResult) Implements EDMIServiceReference.IEDMService.GetDocumentByDocumentIdAsync + Return MyBase.Channel.GetDocumentByDocumentIdAsync(DocumentId) + End Function + + Public Function GetDocumentByContainerId(ByVal ContainerId As String) As EDMIServiceReference.DocumentResult Implements EDMIServiceReference.IEDMService.GetDocumentByContainerId + Return MyBase.Channel.GetDocumentByContainerId(ContainerId) + End Function + + Public Function GetDocumentByContainerIdAsync(ByVal ContainerId As String) As System.Threading.Tasks.Task(Of EDMIServiceReference.DocumentResult) Implements EDMIServiceReference.IEDMService.GetDocumentByContainerIdAsync + Return MyBase.Channel.GetDocumentByContainerIdAsync(ContainerId) + End Function + Public Function NewFileIndex(ByVal DocObject As EDMIServiceReference.DocumentObject, ByVal Syskey As String, ByVal LanguageCode As String, ByVal Value As String) As EDMIServiceReference.IndexResult Implements EDMIServiceReference.IEDMService.NewFileIndex Return MyBase.Channel.NewFileIndex(DocObject, Syskey, LanguageCode, Value) End Function diff --git a/EDMI_FILE_OPs/Connected Services/EDMIServiceReference/service.wsdl b/EDMI_FILE_OPs/Connected Services/EDMIServiceReference/service.wsdl index 8e188766..1d9e9dda 100644 --- a/EDMI_FILE_OPs/Connected Services/EDMIServiceReference/service.wsdl +++ b/EDMI_FILE_OPs/Connected Services/EDMIServiceReference/service.wsdl @@ -129,6 +129,24 @@ + + + + + + + + + + + + + + + + + + diff --git a/EDMI_FILE_OPs/Constants.vb b/EDMI_FILE_OPs/Constants.vb new file mode 100644 index 00000000..06c03b3a --- /dev/null +++ b/EDMI_FILE_OPs/Constants.vb @@ -0,0 +1,8 @@ +Public Class Constants + Public Const MAX_RECEIVED_MESSAGE_SIZE = 2147483647 + Public Const MAX_BUFFER_SIZE = 2147483647 + Public Const MAX_BUFFER_POOL_SIZE = 2147483647 + Public Const MAX_CONNECTIONS = 10000 + Public Const MAX_ARRAY_LENGTH = 2147483647 + Public Const MAX_STRING_CONTENT_LENGTH = 2147483647 +End Class diff --git a/EDMI_FILE_OPs/Document.vb b/EDMI_FILE_OPs/Document.vb index 0728652a..6224a3c5 100644 --- a/EDMI_FILE_OPs/Document.vb +++ b/EDMI_FILE_OPs/Document.vb @@ -8,22 +8,14 @@ Public Class Document Private _logConfig As LogConfig Private _channelFactory As ChannelFactory(Of IEDMServiceChannel) Private _channel As IEDMServiceChannel - Public Sub New(LogConfig As LogConfig, EDMI_ServiceAdress As String) + Public Sub New(LogConfig As LogConfig, ServiceAdress As String) _logger = LogConfig.GetLogger() _logConfig = LogConfig Try - Dim binding As New NetTcpBinding() - binding.Security.Mode = SecurityMode.Transport - binding.Security.Transport.ClientCredentialType = TcpClientCredentialType.Windows - binding.MaxReceivedMessageSize = 2147483647 - binding.MaxBufferSize = 2147483647 - binding.MaxBufferPoolSize = 2147483647 - binding.MaxConnections = 10000 - binding.ReaderQuotas.MaxArrayLength = 2147483647 - binding.ReaderQuotas.MaxStringContentLength = 2147483647 - Dim endpointAddress = New EndpointAddress(EDMI_ServiceAdress) - _channelFactory = New ChannelFactory(Of IEDMServiceChannel)(binding, endpointAddress) + Dim oBinding = Channel.GetBinding() + Dim oAddress = New EndpointAddress(ServiceAdress) + _channelFactory = New ChannelFactory(Of IEDMServiceChannel)(oBinding, oAddress) Connect2NetService() Catch ex As Exception _logger.Error(ex) @@ -110,6 +102,24 @@ Public Class Document End Try End Function + Public Function GetDocumentByDocumentId(DocumentId As Int64) As DocumentResult + Try + Return _channel.GetDocumentByDocumentId(DocumentId) + Catch ex As Exception + _logger.Error(ex) + Throw ex + End Try + End Function + + Public Function GetDocumentByContainerId(ContainerId As String) As DocumentResult + Try + Return _channel.GetDocumentByContainerId(ContainerId) + Catch ex As Exception + _logger.Error(ex) + Throw ex + End Try + End Function + 'Public Async Function New_EDMI_File(oFILENAME As String, oUserName As String) As Task(Of String) ' Try ' Dim oFileGUID As DocumentResult = Await CreateDocument(oFILENAME) diff --git a/EDMI_FILE_OPs/EDMIAPI.vbproj b/EDMI_FILE_OPs/EDMIAPI.vbproj index c115f0d0..5cbfc34f 100644 --- a/EDMI_FILE_OPs/EDMIAPI.vbproj +++ b/EDMI_FILE_OPs/EDMIAPI.vbproj @@ -78,6 +78,7 @@ True Reference.svcmap + diff --git a/SERVICES/DDEDM_NetworkService/EDMService.vb b/SERVICES/DDEDM_NetworkService/EDMService.vb index d2f24d1a..5e5f7157 100644 --- a/SERVICES/DDEDM_NetworkService/EDMService.vb +++ b/SERVICES/DDEDM_NetworkService/EDMService.vb @@ -3,6 +3,7 @@ Imports DigitalData.Modules.Database Imports DigitalData.Modules.Logging Imports DigitalData.Modules.Filesystem Imports System.IO +Imports DigitalData.Services.EDMService Public Class EDMService @@ -236,10 +237,56 @@ Public Class EDMService End Sub #End Region +#Region "Utils" + Public Function GetDocumentByDocumentId(DocumentId As Long) As DocumentResult Implements IEDMService.GetDocumentByDocumentId + Try + Dim oSQL = $"SELECT GUID, CONTAINER_ID, ORIGINAL_FILENAME FROM TBICM_DOCUMENT WHERE GUID = {DocumentId}" + Dim oTable = Database.GetDatatable(oSQL) + + If oTable.Rows.Count = 0 Then + Return New DocumentResult("Document not found") + End If + + Dim oRow As DataRow = oTable.Rows.Item(0) + Dim oDocument As New DocumentObject( + oRow.Item("CONTAINER_ID"), + oRow.Item("GUID"), + oRow.Item("ORIGINAL_FILENAME") + ) + + Return New DocumentResult(oDocument) + Catch ex As Exception + Return New DocumentResult(ex.Message) + End Try + End Function + + Public Function GetDocumentByContainerId(ContainerId As String) As DocumentResult Implements IEDMService.GetDocumentByContainerId + Try + Dim oSQL = $"SELECT GUID, CONTAINER_ID, ORIGINAL_FILENAME FROM TBICM_DOCUMENT WHERE CONTAINER_ID = '{ContainerId}'" + Dim oTable = Database.GetDatatable(oSQL) + + If oTable.Rows.Count = 0 Then + Return New DocumentResult("Document not found") + End If + + Dim oRow As DataRow = oTable.Rows.Item(0) + Dim oDocument As New DocumentObject( + oRow.Item("CONTAINER_ID"), + oRow.Item("GUID"), + oRow.Item("ORIGINAL_FILENAME") + ) + + Return New DocumentResult(oDocument) + Catch ex As Exception + Return New DocumentResult(ex.Message) + End Try + End Function +#End Region + #Region "Index" Public Function NewFileIndex(DocObject As DocumentObject, Syskey As String, LanguageCode As String, Value As String) As IndexResult Implements IEDMService.NewFileIndex Try - Dim oSQL = $"SELECT FNICM_NEW_OBJECT_VALUE({DocObject.DocumentId},'{Syskey}','{LanguageCode}','{Value}','{_username}') FROM RDB$DATABASE;" + Dim oSQL = $"SELECT FNICM_NEW_DOC_VALUE({DocObject.DocumentId},'{Syskey}','{LanguageCode}','{Value}','{_username}') FROM RDB$DATABASE;" Dim oIndexId As Int64 = Database.GetScalarValue(oSQL) Return New IndexResult(oIndexId) diff --git a/SERVICES/DDEDM_NetworkService/IEDMService.vb b/SERVICES/DDEDM_NetworkService/IEDMService.vb index 342ae67f..ac6bf76c 100644 --- a/SERVICES/DDEDM_NetworkService/IEDMService.vb +++ b/SERVICES/DDEDM_NetworkService/IEDMService.vb @@ -40,6 +40,14 @@ Interface IEDMService Function DeleteFile(DocObject As DocumentObject) As Boolean #End Region +#Region "Utils" + + Function GetDocumentByDocumentId(DocumentId As Int64) As DocumentResult + + + Function GetDocumentByContainerId(ContainerId As String) As DocumentResult +#End Region + #Region "Index" Function NewFileIndex(DocObject As DocumentObject, Syskey As String, LanguageCode As String, Value As String) As IndexResult diff --git a/SERVICES/DDEDM_NetworkService/Results/BaseResult.vb b/SERVICES/DDEDM_NetworkService/Results/BaseResult.vb index 175523b5..67ba3f4a 100644 --- a/SERVICES/DDEDM_NetworkService/Results/BaseResult.vb +++ b/SERVICES/DDEDM_NetworkService/Results/BaseResult.vb @@ -10,7 +10,7 @@ Public Class BaseResult Public Property ErrorMessage As String Public Sub New() - Me.OK = OK + OK = True End Sub Public Sub New(ErrorMessage As String) diff --git a/SERVICES/DDEDM_NetworkService/WindowsService.vb b/SERVICES/DDEDM_NetworkService/WindowsService.vb index ddc796e5..c6d15dbf 100644 --- a/SERVICES/DDEDM_NetworkService/WindowsService.vb +++ b/SERVICES/DDEDM_NetworkService/WindowsService.vb @@ -36,8 +36,8 @@ Public Class WindowsService _logger = _logConfig.GetLogger() - _logger.Info("Service {0} is starting", SERVICE_DISPLAY_NAME) - _logger.Info("Connecting to database") + _logger.Info("Service {0} is starting...", SERVICE_DISPLAY_NAME) + _logger.Debug("Connecting to database...") _db = New Firebird( _logConfig, @@ -47,20 +47,20 @@ Public Class WindowsService AppConfig.FirebirdPassword ) - _logger.Info("Successfully connected to database!") + _logger.Info("Database connection established.") EDMService.Database = _db EDMService.LogConfig = _logConfig EDMService.AppConfig = _config - _logger.Info("Starting the WCF Service") + _logger.Debug("Starting WCF ServiceHost...") _serviceHost = New ServiceHost(GetType(EDMService)) _serviceHost.Open() - _logger.Info("Successfully started the WCF Service!") + _logger.Info("WCF ServiceHost started.") - _logger.Info("Service {0} successfully started!", SERVICE_DISPLAY_NAME) + _logger.Info("Service {0} successfully started.", SERVICE_DISPLAY_NAME) Catch ex As Exception _logger.Error(ex, "Failed to start the service host!") End Try