diff --git a/GUIs.ClipboardWatcher/ProfileSearches.vb b/GUIs.ClipboardWatcher/ProfileSearches.vb index 6cae5c8e..8a700a60 100644 --- a/GUIs.ClipboardWatcher/ProfileSearches.vb +++ b/GUIs.ClipboardWatcher/ProfileSearches.vb @@ -32,7 +32,7 @@ Public Class ProfileSearches _Environment = pEnvironment _ClipboardContents = pClipboardContents Try - If _Environment.Service.IsActive = True Then + If _Environment.Service.Client.IsOnline = True Then Try Dim oSplit() As String = _Environment.Service.Address.Split(":") Dim oAppServerAddress As String = oSplit(0) @@ -90,7 +90,7 @@ Public Class ProfileSearches Private Function DoLoadDocumentSearches(ProfileId As Integer) As List(Of Search) Dim oSQL As String = $"SELECT * FROM TBCW_PROF_DOC_SEARCH WHERE ACTIVE = 1 AND PROFILE_ID = {ProfileId} ORDER BY TAB_INDEX" Dim oSearchesDataTable As DataTable - If _Environment.Service.IsActive = True Then + If _Environment.Service.Client.IsOnline = True Then Dim oTableResult As TableResult = _Client.GetDatatableByName("TBCW_PROF_DOC_SEARCH", $"PROFILE_ID = {ProfileId} AND ACTIVE = 1", "TAB_INDEX") oSearchesDataTable = oTableResult.Table If oSearchesDataTable Is Nothing Then @@ -157,7 +157,7 @@ Public Class ProfileSearches Try Dim oSQL As String = $"SELECT * FROM TBCW_PROF_DATA_SEARCH WHERE ACTIVE = 1 AND PROFILE_ID = {ProfileId} ORDER BY TAB_INDEX" Dim oSearchesDataTable As DataTable - If _Environment.Service.IsActive = True Then + If _Environment.Service.Client.IsOnline = True Then Dim oTableResult As TableResult = _Client.GetDatatableByName("TBCW_PROF_DATA_SEARCH", $"PROFILE_ID = {ProfileId} AND ACTIVE = 1", "TAB_INDEX") oSearchesDataTable = oTableResult.Table If oSearchesDataTable Is Nothing Then diff --git a/GUIs.Common/DocumentResultList/Params.vb b/GUIs.Common/DocumentResultList/Params.vb index 4790a565..330590f3 100644 --- a/GUIs.Common/DocumentResultList/Params.vb +++ b/GUIs.Common/DocumentResultList/Params.vb @@ -12,6 +12,7 @@ Namespace DocumentResultList Public OperationModeOverride As OperationMode = OperationMode.None Public ProfileGuid As Integer Public ShowBackNavigation As Boolean = True + Public ShowFileList As Boolean = True End Class Public Class DocumentResult diff --git a/GUIs.Common/frmDocumentResultList.Designer.vb b/GUIs.Common/frmDocumentResultList.Designer.vb index 0aac8473..0299e677 100644 --- a/GUIs.Common/frmDocumentResultList.Designer.vb +++ b/GUIs.Common/frmDocumentResultList.Designer.vb @@ -107,7 +107,7 @@ Partial Class frmDocumentResultList Me.DockPanelMetadata = New DevExpress.XtraBars.Docking.DockPanel() Me.DockPanel3_Container = New DevExpress.XtraBars.Docking.ControlContainer() Me.CtrlObjectPropertyDialog = New DigitalData.GUIs.Common.ctrlObjectPropertyDialog() - Me.DockPanelDocViewer = New DevExpress.XtraBars.Docking.DockPanel() + Me.DockPanelPreview = New DevExpress.XtraBars.Docking.DockPanel() Me.DockPanel1_Container = New DevExpress.XtraBars.Docking.ControlContainer() Me.SvgImageCollection1 = New DevExpress.Utils.SvgImageCollection(Me.components) CType(Me.SplitContainerControl1, System.ComponentModel.ISupportInitialize).BeginInit() @@ -151,7 +151,7 @@ Partial Class frmDocumentResultList CType(Me.EmptySpaceItem1, System.ComponentModel.ISupportInitialize).BeginInit() Me.DockPanelMetadata.SuspendLayout() Me.DockPanel3_Container.SuspendLayout() - Me.DockPanelDocViewer.SuspendLayout() + Me.DockPanelPreview.SuspendLayout() Me.DockPanel1_Container.SuspendLayout() CType(Me.SvgImageCollection1, System.ComponentModel.ISupportInitialize).BeginInit() Me.SuspendLayout() @@ -701,7 +701,7 @@ Partial Class frmDocumentResultList 'DockManager1 ' Me.DockManager1.Form = Me - Me.DockManager1.RootPanels.AddRange(New DevExpress.XtraBars.Docking.DockPanel() {Me.DockPanelFileList, Me.panelContainerStatus, Me.DockPanelDocViewer}) + Me.DockManager1.RootPanels.AddRange(New DevExpress.XtraBars.Docking.DockPanel() {Me.DockPanelFileList, Me.panelContainerStatus, Me.DockPanelPreview}) Me.DockManager1.TopZIndexControls.AddRange(New String() {"DevExpress.XtraBars.BarDockControl", "DevExpress.XtraBars.StandaloneBarDockControl", "System.Windows.Forms.MenuStrip", "System.Windows.Forms.StatusStrip", "System.Windows.Forms.StatusBar", "DevExpress.XtraBars.Ribbon.RibbonStatusBar", "DevExpress.XtraBars.Ribbon.RibbonControl", "DevExpress.XtraBars.Navigation.OfficeNavigationBar", "DevExpress.XtraBars.Navigation.TileNavPane", "DevExpress.XtraBars.TabFormControl", "DevExpress.XtraBars.FluentDesignSystem.FluentDesignFormControl", "DevExpress.XtraBars.ToolbarForm.ToolbarFormControl"}) ' 'DockPanelFileList @@ -712,7 +712,7 @@ Partial Class frmDocumentResultList resources.ApplyResources(Me.DockPanelFileList, "DockPanelFileList") Me.DockPanelFileList.Name = "DockPanelFileList" Me.DockPanelFileList.Options.ShowCloseButton = False - Me.DockPanelFileList.OriginalSize = New System.Drawing.Size(585, 200) + Me.DockPanelFileList.OriginalSize = New System.Drawing.Size(590, 200) ' 'DockPanel2_Container ' @@ -840,15 +840,15 @@ Partial Class frmDocumentResultList resources.ApplyResources(Me.CtrlObjectPropertyDialog, "CtrlObjectPropertyDialog") Me.CtrlObjectPropertyDialog.Name = "CtrlObjectPropertyDialog" ' - 'DockPanelDocViewer + 'DockPanelPreview ' - Me.DockPanelDocViewer.Controls.Add(Me.DockPanel1_Container) - Me.DockPanelDocViewer.Dock = DevExpress.XtraBars.Docking.DockingStyle.Fill - Me.DockPanelDocViewer.ID = New System.Guid("6e5335e5-ba54-49c1-81b3-f174ea4e59ca") - resources.ApplyResources(Me.DockPanelDocViewer, "DockPanelDocViewer") - Me.DockPanelDocViewer.Name = "DockPanelDocViewer" - Me.DockPanelDocViewer.Options.ShowCloseButton = False - Me.DockPanelDocViewer.OriginalSize = New System.Drawing.Size(329, 200) + Me.DockPanelPreview.Controls.Add(Me.DockPanel1_Container) + Me.DockPanelPreview.Dock = DevExpress.XtraBars.Docking.DockingStyle.Fill + Me.DockPanelPreview.ID = New System.Guid("6e5335e5-ba54-49c1-81b3-f174ea4e59ca") + resources.ApplyResources(Me.DockPanelPreview, "DockPanelPreview") + Me.DockPanelPreview.Name = "DockPanelPreview" + Me.DockPanelPreview.Options.ShowCloseButton = False + Me.DockPanelPreview.OriginalSize = New System.Drawing.Size(324, 200) ' 'DockPanel1_Container ' @@ -865,7 +865,7 @@ Partial Class frmDocumentResultList Me.AllowFormGlass = DevExpress.Utils.DefaultBoolean.[True] resources.ApplyResources(Me, "$this") Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font - Me.Controls.Add(Me.DockPanelDocViewer) + Me.Controls.Add(Me.DockPanelPreview) Me.Controls.Add(Me.panelContainerStatus) Me.Controls.Add(Me.DockPanelFileList) Me.Controls.Add(Me.RibbonStatusBar) @@ -916,7 +916,7 @@ Partial Class frmDocumentResultList CType(Me.EmptySpaceItem1, System.ComponentModel.ISupportInitialize).EndInit() Me.DockPanelMetadata.ResumeLayout(False) Me.DockPanel3_Container.ResumeLayout(False) - Me.DockPanelDocViewer.ResumeLayout(False) + Me.DockPanelPreview.ResumeLayout(False) Me.DockPanel1_Container.ResumeLayout(False) CType(Me.SvgImageCollection1, System.ComponentModel.ISupportInitialize).EndInit() Me.ResumeLayout(False) @@ -974,7 +974,7 @@ Partial Class frmDocumentResultList Friend WithEvents RibbonPageGroup5 As DevExpress.XtraBars.Ribbon.RibbonPageGroup Friend WithEvents RibbonPageGroup6 As DevExpress.XtraBars.Ribbon.RibbonPageGroup Friend WithEvents DockManager1 As DevExpress.XtraBars.Docking.DockManager - Friend WithEvents DockPanelDocViewer As DevExpress.XtraBars.Docking.DockPanel + Friend WithEvents DockPanelPreview As DevExpress.XtraBars.Docking.DockPanel Friend WithEvents DockPanel1_Container As DevExpress.XtraBars.Docking.ControlContainer Friend WithEvents DockPanelMetadata As DevExpress.XtraBars.Docking.DockPanel Friend WithEvents DockPanel3_Container As DevExpress.XtraBars.Docking.ControlContainer diff --git a/GUIs.Common/frmDocumentResultList.resx b/GUIs.Common/frmDocumentResultList.resx index abb7d9a4..94a51eae 100644 --- a/GUIs.Common/frmDocumentResultList.resx +++ b/GUIs.Common/frmDocumentResultList.resx @@ -493,7 +493,7 @@ 0, 0 - 323, 459 + 318, 459 @@ -515,7 +515,7 @@ 3, 26 - 323, 459 + 318, 459 0 @@ -527,30 +527,30 @@ DevExpress.XtraBars.Docking.ControlContainer, DevExpress.XtraBars.v21.2, Version=21.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a - DockPanelDocViewer + DockPanelPreview 0 - - 585, 158 + + 590, 158 - - 329, 489 + + 324, 489 - + Vorschau - - DockPanelDocViewer + + DockPanelPreview - + DevExpress.XtraBars.Docking.DockPanel, DevExpress.XtraBars.v21.2, Version=21.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a - + $this - + 0 @@ -774,7 +774,7 @@ 3, 26 - 578, 460 + 583, 460 0 @@ -795,7 +795,7 @@ 0, 158 - 585, 489 + 590, 489 Ergebnisse @@ -1397,7 +1397,7 @@ 4 - 568, 460 + 573, 460 0 @@ -1568,7 +1568,7 @@ 1 - 578, 460 + 583, 460 2 diff --git a/GUIs.Common/frmDocumentResultList.vb b/GUIs.Common/frmDocumentResultList.vb index 57170603..a47735c9 100644 --- a/GUIs.Common/frmDocumentResultList.vb +++ b/GUIs.Common/frmDocumentResultList.vb @@ -117,7 +117,7 @@ Public Class frmDocumentResultList Private Function GetOperationMode() As OperationMode Dim oOperationMode As OperationMode - If Environment.Service.IsActive AndAlso Environment.Service.Address <> String.Empty Then + If Environment.Service.Client.IsOnline AndAlso Environment.Service.Address <> String.Empty Then oOperationMode = OperationMode.WithAppServer Else oOperationMode = OperationMode.NoAppServer @@ -205,6 +205,8 @@ Public Class frmDocumentResultList panelContainerStatus.Visibility = Docking.DockVisibility.Hidden End If + + ' Hide the complete Navigation Ribbon Group if desired RibbonPageGroup_Navigation.Visible = Params.ShowBackNavigation @@ -217,6 +219,15 @@ Public Class frmDocumentResultList chkGridShowGrouping.Checked = LayoutManager.GetGroupPanelVisible() chkGridShowTitle.Checked = LayoutManager.GetBandTitleVisible() + ' This needs to done be after loading the grid + ' so we can set the row handle and start loading the (only) file + If Params.ShowFileList = False Then + DockPanelFileList.HideImmediately() + GridView1.FocusedRowHandle = 0 + Else + DockPanelFileList.Show() + End If + Catch ex As Exception ErrorHandler.ShowErrorMessage(ex, "Form Load", "Error while loading results") @@ -449,9 +460,9 @@ Public Class frmDocumentResultList #End Region Private Function InitAppServer() As Boolean - Dim oSplit As List(Of String) = Environment.Service.Address.Split(":").ToList() - Dim oAddress As String = oSplit.Item(0) - Dim oPort As Integer = oSplit.Item(1) + Dim oServerAddress = Client.ParseServiceAddress(Environment.Service.Client.ServerAddress) + Dim oAddress As String = oServerAddress.Item1 + Dim oPort As Integer = oServerAddress.Item2 Client = New Client(LogConfig, oAddress, oPort) ControlManager = New AttributeControls(LogConfig, Environment, Client) @@ -1113,4 +1124,8 @@ Public Class frmDocumentResultList GridBuilder.WithFontSizeDelta(Config.Config.GridFontSizeDelta) End Sub + + Private Sub RibbonControl_Click(sender As Object, e As EventArgs) Handles RibbonControl.Click + + End Sub End Class \ No newline at end of file diff --git a/GUIs.Test.EDMIBenchmark/Form1.vb b/GUIs.Test.EDMIBenchmark/Form1.vb index 7b991079..46791903 100644 --- a/GUIs.Test.EDMIBenchmark/Form1.vb +++ b/GUIs.Test.EDMIBenchmark/Form1.vb @@ -13,7 +13,7 @@ Public Class Form1 Try _LogConfig = New LogConfig(LogConfig.PathType.Temp, Nothing, "EDMIBenchmark") _Logger = _LogConfig.GetLogger() - _Client = New Client(_LogConfig, "172.24.12.39", 9000) + _Client = New Client(_LogConfig, "172.24.12.39:9000") _Client.Connect() DocumentViewer1.Init(_LogConfig, "21182889975216572111813147150675976632") diff --git a/GUIs.ZooFlow/Administration/frmSQLDesigner.Designer.vb b/GUIs.ZooFlow/Administration/frmSQLDesigner.Designer.vb index 69c00d9d..ba7e3b71 100644 --- a/GUIs.ZooFlow/Administration/frmSQLDesigner.Designer.vb +++ b/GUIs.ZooFlow/Administration/frmSQLDesigner.Designer.vb @@ -23,7 +23,7 @@ Partial Class frmSQLDesigner _ Private Sub InitializeComponent() Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(frmSQLDesigner)) - Dim DataGridViewCellStyle4 As System.Windows.Forms.DataGridViewCellStyle = New System.Windows.Forms.DataGridViewCellStyle() + Dim DataGridViewCellStyle1 As System.Windows.Forms.DataGridViewCellStyle = New System.Windows.Forms.DataGridViewCellStyle() Me.Label14 = New System.Windows.Forms.Label() Me.cmbConnection = New System.Windows.Forms.ComboBox() Me.Label2 = New System.Windows.Forms.Label() @@ -211,8 +211,8 @@ Partial Class frmSQLDesigner ' Me.dgvPlaceholders.AllowUserToAddRows = False Me.dgvPlaceholders.AllowUserToDeleteRows = False - DataGridViewCellStyle4.BackColor = System.Drawing.Color.Cyan - Me.dgvPlaceholders.AlternatingRowsDefaultCellStyle = DataGridViewCellStyle4 + DataGridViewCellStyle1.BackColor = System.Drawing.Color.Cyan + Me.dgvPlaceholders.AlternatingRowsDefaultCellStyle = DataGridViewCellStyle1 Me.dgvPlaceholders.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize Me.dgvPlaceholders.Columns.AddRange(New System.Windows.Forms.DataGridViewColumn() {Me.colPlaceholder, Me.colReplace}) Me.dgvPlaceholders.Enabled = False @@ -280,7 +280,7 @@ Partial Class frmSQLDesigner Me.RibbonControl1.Pages.AddRange(New DevExpress.XtraBars.Ribbon.RibbonPage() {Me.RibbonPage1}) Me.RibbonControl1.RepositoryItems.AddRange(New DevExpress.XtraEditors.Repository.RepositoryItem() {Me.RepositoryItemComboBox1, Me.RepositoryItemLookUpEdit1, Me.RepositoryItemLookUpEdit2, Me.RepositoryItemLookUpEdit3}) Me.RibbonControl1.ShowApplicationButton = DevExpress.Utils.DefaultBoolean.[False] - Me.RibbonControl1.Size = New System.Drawing.Size(995, 158) + Me.RibbonControl1.Size = New System.Drawing.Size(997, 158) Me.RibbonControl1.StatusBar = Me.RibbonStatusBar1 ' 'BarButtonItem1 @@ -365,10 +365,10 @@ Partial Class frmSQLDesigner 'RibbonStatusBar1 ' Me.RibbonStatusBar1.ItemLinks.Add(Me.bsiInfo) - Me.RibbonStatusBar1.Location = New System.Drawing.Point(0, 564) + Me.RibbonStatusBar1.Location = New System.Drawing.Point(0, 588) Me.RibbonStatusBar1.Name = "RibbonStatusBar1" Me.RibbonStatusBar1.Ribbon = Me.RibbonControl1 - Me.RibbonStatusBar1.Size = New System.Drawing.Size(995, 24) + Me.RibbonStatusBar1.Size = New System.Drawing.Size(997, 24) ' 'RibbonPage2 ' @@ -385,7 +385,7 @@ Partial Class frmSQLDesigner Me.GridControl1.MainView = Me.GridView1 Me.GridControl1.MenuManager = Me.RibbonControl1 Me.GridControl1.Name = "GridControl1" - Me.GridControl1.Size = New System.Drawing.Size(691, 133) + Me.GridControl1.Size = New System.Drawing.Size(693, 157) Me.GridControl1.TabIndex = 124 Me.GridControl1.ViewCollection.AddRange(New DevExpress.XtraGrid.Views.Base.BaseView() {Me.GridView1}) ' @@ -399,7 +399,7 @@ Partial Class frmSQLDesigner Me.Appearance.Options.UseFont = True Me.AutoScaleDimensions = New System.Drawing.SizeF(7.0!, 17.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font - Me.ClientSize = New System.Drawing.Size(995, 588) + Me.ClientSize = New System.Drawing.Size(997, 612) Me.Controls.Add(Me.GridControl1) Me.Controls.Add(Me.lblAttributeAuto) Me.Controls.Add(Me.btnAddAttributeAuto) diff --git a/GUIs.ZooFlow/ApplicationEvents.vb b/GUIs.ZooFlow/ApplicationEvents.vb index 12bfb84b..bcd81a97 100644 --- a/GUIs.ZooFlow/ApplicationEvents.vb +++ b/GUIs.ZooFlow/ApplicationEvents.vb @@ -52,9 +52,7 @@ Namespace My My.Application.Service.Client = New Client(LogConfig, oAppServerAddress, oAppServerPort) If Not IsNothing(My.Application.Service.Client) Then - If My.Application.Service.Client.Connect() Then - My.Application.Service.IsActive = True - End If + My.Application.Service.Client.Connect() End If Catch ex As Exception _Logger.Warn($"Could not initialize the AppServer: {ex.Message}") diff --git a/GUIs.ZooFlow/ClassInit.vb b/GUIs.ZooFlow/ClassInit.vb index c8bbb8c0..add35a2d 100644 --- a/GUIs.ZooFlow/ClassInit.vb +++ b/GUIs.ZooFlow/ClassInit.vb @@ -119,15 +119,13 @@ Public Class ClassInit End If End If - MyApplication.Service.Address = My.SystemConfig.AppServerConfig - Dim oServerData = Client.ParseServiceAddress(My.SystemConfig.AppServerConfig) + ' These Properties need to be set directly on - My.Application.Service.Client = New Client(LogConfig, oServerData.Item1, oServerData.Item2) + My.Application.Service.Address = My.SystemConfig.AppServerConfig + My.Application.Service.Client = New Client(LogConfig, My.SystemConfig.AppServerConfig) If Not IsNothing(My.Application.Service.Client) Then - If My.Application.Service.Client.Connect() Then - MyApplication.Service.IsActive = True - End If + My.Application.Service.Client.Connect() End If Catch ex As Exception Logger.Error(ex) diff --git a/GUIs.ZooFlow/Search/SearchRunner.vb b/GUIs.ZooFlow/Search/SearchRunner.vb index 4a239cb6..19981073 100644 --- a/GUIs.ZooFlow/Search/SearchRunner.vb +++ b/GUIs.ZooFlow/Search/SearchRunner.vb @@ -8,8 +8,6 @@ Public Class SearchRunner Private Const SEARCH_FACT_DATE_DEFAULT As String = "ADDED_WHEN" - Private Environment As Environment - Private Const CREATED_TOMORROW As String = "TOMORROW" Private Const CREATED_TODAY As String = "ECM_CREATED_TODAY" Private Const CREATED_YESTERDAY As String = "ECM_CREATED_YESTERDAY" @@ -49,18 +47,30 @@ Public Class SearchRunner Public Property BaseSearchSQL As String Public Property ExplicitDate As Boolean = False - Public Sub New(pLogConfig As LogConfig, pEnvironment As Environment) + Private Environment As Environment + Private SearchTitle As String + + Public Sub New(pLogConfig As LogConfig, pEnvironment As Environment, pSearchTitle As String) MyBase.New(pLogConfig) Environment = pEnvironment + SearchTitle = pSearchTitle End Sub + Public Async Function Run(pSearchTerm As String) As Threading.Tasks.Task(Of SearchResult) + Return Await Run(pSearchTerm, Nothing, Nothing) + End Function + Public Async Function Run(pSearchTerm As String, pDateFrom As Date, pDateTo As Date) As Threading.Tasks.Task(Of SearchResult) + If pDateFrom.Equals(Date.MinValue) = False Then + ExplicitDate = True + End If + Dim oSearchTerm = pSearchTerm Dim oParams = New DocumentResultList.Params() With { - .WindowGuid = "FlowSearch", + .WindowGuid = SearchTitle, .WindowTitle = GetResultWindowString(oSearchTerm), .OperationModeOverride = Modules.ZooFlow.Constants.OperationMode.ZooFlow, - .ProfileGuid = 354522, + .ProfileGuid = 35452, .ColumnNames = New DocumentResultList.ColumnNames With { .ObjectIdColumn = "DocID" }, @@ -88,9 +98,14 @@ Public Class SearchRunner Dim oDTDocResult = Await My.Database.GetDatatableIDBAsync(BaseSearchSQL) If oDTDocResult.Rows.Count > 0 Then oParams.Results.Add(New DocumentResultList.DocumentResult() With { - .Title = "FlowSearchXYZ", + .Title = SearchTitle, .Datatable = oDTDocResult }) + + If oDTDocResult.Rows.Count = 1 Then + oParams.ShowFileList = False + End If + Dim oForm As New frmDocumentResultList(My.LogConfig, Environment, oParams) ' TODO: Implement, not needed right now diff --git a/GUIs.ZooFlow/Search/frmFlowSearch1.vb b/GUIs.ZooFlow/Search/frmFlowSearch1.vb index c8896a0d..210a1dcc 100644 --- a/GUIs.ZooFlow/Search/frmFlowSearch1.vb +++ b/GUIs.ZooFlow/Search/frmFlowSearch1.vb @@ -117,7 +117,7 @@ Public Class frmFlowSearch1 Private Sub frmFlowSearch1_Load(sender As Object, e As EventArgs) Handles Me.Load Logger = My.LogConfig.GetLogger() - SearchRunner = New SearchRunner(My.LogConfig, My.Application.GetEnvironment) + SearchRunner = New SearchRunner(My.LogConfig, My.Application.GetEnvironment, "FlowSearch") Try If My.Application.User.Language = "de-DE" Then diff --git a/GUIs.ZooFlow/Search/frmFlowSearch2.vb b/GUIs.ZooFlow/Search/frmFlowSearch2.vb index 87614f8a..deb94ce1 100644 --- a/GUIs.ZooFlow/Search/frmFlowSearch2.vb +++ b/GUIs.ZooFlow/Search/frmFlowSearch2.vb @@ -13,7 +13,7 @@ Public Class frmFlowSearch2 End If Next - SearchRunner = New SearchRunner(My.LogConfig, My.Application.GetEnvironment) + SearchRunner = New SearchRunner(My.LogConfig, My.Application.GetEnvironment, "FlowSearch") SearchRunner.BaseSearchSQL = BaseSearchSQL Dim osql = $"EXEC PRIDB_SEARCH_AUTOSUGGEST '{My.Application.User.Language}',{My.Application.User.UserId}" diff --git a/GUIs.ZooFlow/ZooFlow.vbproj b/GUIs.ZooFlow/ZooFlow.vbproj index f0352bd9..aa866084 100644 --- a/GUIs.ZooFlow/ZooFlow.vbproj +++ b/GUIs.ZooFlow/ZooFlow.vbproj @@ -670,6 +670,10 @@ {40384b94-1f94-4249-9a5a-d02e0b346738} GlobalIndexer + + {ef29f400-be45-4283-9d18-ca7acd9accc9} + MessageBoxEx + {6ea0c51f-c2b1-4462-8198-3de0b32b74f8} Base diff --git a/GUIs.ZooFlow/frmFlowForm.vb b/GUIs.ZooFlow/frmFlowForm.vb index 2dfe0801..72c025b2 100644 --- a/GUIs.ZooFlow/frmFlowForm.vb +++ b/GUIs.ZooFlow/frmFlowForm.vb @@ -19,6 +19,7 @@ Imports DigitalData.Modules.Language Imports DevExpress.LookAndFeel Imports System.Threading.Tasks Imports System.Threading +Imports DigitalData.Controls.MessageBoxEx Public Class frmFlowForm #Region "Sidebar DllImport" @@ -488,8 +489,11 @@ Public Class frmFlowForm End Sub Sub ExitZooflow() - Dim oResult As DialogResult = MessageBox.Show("Are you sure you want to close ZooFlow?", "Exit Zooflow", MessageBoxButtons.YesNo, MessageBoxIcon.Question) - If oResult = DialogResult.Yes Then + Dim oMsgBox As New MsgBoxEx("Are you sure you want to close ZooFlow?", "Exit Zooflow", MessageBoxIcon.Question) + oMsgBox.SetButtons("Yes", "No") + oMsgBox.ShowDialog() + + If oMsgBox.Result = MsgBoxEx.DialogBoxResult.Button1 Then Close() Else ESCHitCount = 0 @@ -1153,6 +1157,12 @@ Public Class frmFlowForm .Title = GetResultWindowString(pSearchText), .Datatable = oDTDocResult }) + + ' disable file list if we have only one document + If oDTDocResult.Rows.Count = 1 Then + oParams.ShowFileList = False + End If + Dim oForm As New frmDocumentResultList(My.LogConfig, Environment, oParams) oForm.Show() oForm.BringToFront() @@ -1272,5 +1282,9 @@ Public Class frmFlowForm Dim oForm = New frmFlowSearch2() oForm.Show() End Sub + + Private Sub PictureEditQuicksearch1_EditValueChanged(sender As Object, e As EventArgs) Handles PictureEditQuicksearch1.EditValueChanged + + End Sub End Class diff --git a/GUIs.ZooFlow/frmServiceConfig.vb b/GUIs.ZooFlow/frmServiceConfig.vb index 6125aaa8..0a09f0c3 100644 --- a/GUIs.ZooFlow/frmServiceConfig.vb +++ b/GUIs.ZooFlow/frmServiceConfig.vb @@ -20,7 +20,7 @@ Public Class frmServiceConfig txtServicePort.Text = oAddress.Item2 End If - If My.Application.Service.IsActive Then + If My.Application.Service.Client.IsOnline Then txtStatus.Text = STATUS_CONNECTED End If diff --git a/MessageBoxEx/MsgBoxEx.Designer.vb b/MessageBoxEx/MsgBoxEx.Designer.vb index 46e2116c..25c89387 100644 --- a/MessageBoxEx/MsgBoxEx.Designer.vb +++ b/MessageBoxEx/MsgBoxEx.Designer.vb @@ -75,7 +75,7 @@ Partial Class MsgBoxEx Me.messageLbl.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.messageLbl.Location = New System.Drawing.Point(58, 10) Me.messageLbl.Name = "messageLbl" - Me.messageLbl.Size = New System.Drawing.Size(415, 75) + Me.messageLbl.Size = New System.Drawing.Size(415, 63) Me.messageLbl.TabIndex = 19 Me.messageLbl.Text = "[Message]" ' diff --git a/MessageBoxEx/MsgBoxEx.vb b/MessageBoxEx/MsgBoxEx.vb index 90a4b95d..65457406 100644 --- a/MessageBoxEx/MsgBoxEx.vb +++ b/MessageBoxEx/MsgBoxEx.vb @@ -1,21 +1,22 @@ Public Class MsgBoxEx - Public Sub New(ByVal message As String, ByVal title As String) + Public Sub New(message As String, title As String) Me.New(message, title, MessageBoxIcon.None) End Sub - Public Sub New(ByVal message As String, ByVal title As String, ByVal icon As MessageBoxIcon) + Public Sub New(message As String, title As String, icon As MessageBoxIcon) Me.New(message, title, getMessageBoxIcon(icon)) End Sub - Public Sub New(ByVal message As String, ByVal title As String, ByVal icon As Icon) + Public Sub New(message As String, title As String, icon As Icon) InitializeComponent() - Me.messageLbl.Text = message - Me.Text = title - Me.m_sysIcon = icon - If Me.m_sysIcon Is Nothing Then Me.messageLbl.Location = New System.Drawing.Point(FORM_X_MARGIN, FORM_Y_MARGIN) + messageLbl.Text = message + Text = title + m_sysIcon = icon + If m_sysIcon Is Nothing Then messageLbl.Location = New System.Drawing.Point(FORM_X_MARGIN, FORM_Y_MARGIN) + SetButtons("OK") End Sub - Private Shared Function getMessageBoxIcon(ByVal icon As MessageBoxIcon) As Icon + Private Shared Function getMessageBoxIcon(icon As MessageBoxIcon) As Icon Dim oIcon As Icon = Nothing Select Case icon @@ -39,7 +40,7 @@ Private m_minWidth As Integer Private m_minHeight As Integer - Public Sub SetMinSize(ByVal width As Integer, ByVal height As Integer) + Public Sub SetMinSize(width As Integer, height As Integer) m_minWidth = width m_minHeight = height End Sub @@ -51,18 +52,18 @@ drs(i) = DialogResult.None Next - Me.SetButtons(names, drs) + SetButtons(names, drs) End Sub - Public Sub SetButtons(ByVal names As String(), ByVal results As DialogResult()) - Me.SetButtons(names, results, 1) + Public Sub SetButtons(names As String(), results As DialogResult()) + SetButtons(names, results, 1) End Sub - Public Sub SetButtons(ByVal names As String(), ByVal results As DialogResult(), ByVal def As Integer) + Public Sub SetButtons(names As String(), results As DialogResult(), def As Integer) If names Is Nothing Then Throw New ArgumentNullException("btnText", "Button Text is null") Dim count As Integer = names.Length If count < 1 OrElse count > 3 Then Throw New ArgumentException("Invalid number of buttons. Must be between 1 and 3.") - m_minButtonRowWidth += setButtonParams(btn1, names(0), If(def = 1, 1, 2), results(0)) + m_minButtonRowWidth = setButtonParams(btn1, names(0), If(def = 1, 1, 2), results(0)) If count > 1 Then m_minButtonRowWidth += setButtonParams(btn2, names(1), If(def = 2, 1, 3), results(1)) + BUTTON_SPACE @@ -75,7 +76,7 @@ Private m_minButtonRowWidth As Integer - Private Shared Function setButtonParams(ByVal btn As Button, ByVal text As String, ByVal tab As Integer, ByVal dr As DialogResult) As Integer + Private Shared Function setButtonParams(btn As Button, text As String, tab As Integer, dr As DialogResult) As Integer btn.Text = text btn.Visible = True btn.DialogResult = dr @@ -83,22 +84,22 @@ Return btn.Size.Width End Function - Public Sub SetCheckbox(ByVal text As String) - Me.SetCheckbox(text, False) + Public Sub SetCheckbox(text As String) + SetCheckbox(text, False) End Sub - Public Sub SetCheckbox(ByVal text As String, ByVal chcked As Boolean) - Me.chkBx.Visible = True - Me.chkBx.Text = text - Me.chkBx.Checked = chcked - Me.m_minButtonRowWidth += Me.chkBx.Size.Width + CHECKBOX_SPACE + Public Sub SetCheckbox(text As String, chcked As Boolean) + chkBx.Visible = True + chkBx.Text = text + chkBx.Checked = chcked + m_minButtonRowWidth += chkBx.Size.Width + CHECKBOX_SPACE End Sub - Private Sub DialogBox_Load(ByVal sender As Object, ByVal e As EventArgs) - If Not btn1.Visible Then Me.SetButtons(New String() {"OK"}, New DialogResult() {DialogResult.OK}) + Private Sub DialogBox_Load(sender As Object, e As EventArgs) + If Not btn1.Visible Then SetButtons(New String() {"OK"}, New DialogResult() {DialogResult.OK}) m_minButtonRowWidth += 2 * FORM_X_MARGIN - Me.setDialogSize() - Me.setButtonRowLocations() + setDialogSize() + setButtonRowLocations() End Sub Const FORM_Y_MARGIN As Integer = 10 @@ -108,19 +109,19 @@ Const TEXT_Y_MARGIN As Integer = 30 Private Sub setDialogSize() - Dim requiredWidth As Integer = Me.messageLbl.Location.X + Me.messageLbl.Size.Width + FORM_X_MARGIN + Dim requiredWidth As Integer = messageLbl.Location.X + messageLbl.Size.Width + FORM_X_MARGIN requiredWidth = If(requiredWidth > m_minButtonRowWidth, requiredWidth, m_minButtonRowWidth) - Dim requiredHeight As Integer = Me.messageLbl.Location.Y + Me.messageLbl.Size.Height - Me.btn2.Location.Y + Me.ClientSize.Height + TEXT_Y_MARGIN - Dim minSetWidth As Integer = If(Me.ClientSize.Width > Me.m_minWidth, Me.ClientSize.Width, Me.m_minWidth) - Dim minSetHeight As Integer = If(Me.ClientSize.Height > Me.m_minHeight, Me.ClientSize.Height, Me.m_minHeight) + Dim requiredHeight As Integer = messageLbl.Location.Y + messageLbl.Size.Height - btn2.Location.Y + ClientSize.Height + TEXT_Y_MARGIN + Dim minSetWidth As Integer = If(ClientSize.Width > m_minWidth, ClientSize.Width, m_minWidth) + Dim minSetHeight As Integer = If(ClientSize.Height > m_minHeight, ClientSize.Height, m_minHeight) Dim s As Size = New Size() s.Width = If(requiredWidth > minSetWidth, requiredWidth, minSetWidth) s.Height = If(requiredHeight > minSetHeight, requiredHeight, minSetHeight) - Me.ClientSize = s + ClientSize = s End Sub Private Sub setButtonRowLocations() - Dim formWidth As Integer = Me.ClientRectangle.Width + Dim formWidth As Integer = ClientRectangle.Width Dim x As Integer = formWidth - FORM_X_MARGIN Dim y As Integer = btn1.Location.Y @@ -138,12 +139,12 @@ x -= btn1.Size.Width btn1.Location = New Point(x, y) - If Me.chkBx.Visible Then Me.chkBx.Location = New Point(FORM_X_MARGIN, Me.chkBx.Location.Y) + If chkBx.Visible Then chkBx.Location = New Point(FORM_X_MARGIN, chkBx.Location.Y) End Sub Private m_sysIcon As Icon - Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs) + Protected Overrides Sub OnPaint(e As PaintEventArgs) If m_sysIcon IsNot Nothing Then Dim g As Graphics = e.Graphics g.DrawIconUnstretched(m_sysIcon, New Rectangle(FORM_X_MARGIN, FORM_Y_MARGIN, m_sysIcon.Width, m_sysIcon.Height)) @@ -154,7 +155,7 @@ Public ReadOnly Property CheckboxChecked As Boolean Get - Return Me.chkBx.Checked + Return chkBx.Checked End Get End Property @@ -166,7 +167,7 @@ End Get End Property - Private Sub btn_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btn1.Click, btn2.Click, btn3.Click + Private Sub btn_Click(sender As Object, e As EventArgs) Handles btn1.Click, btn2.Click, btn3.Click If sender.Equals(btn1) Then m_result = DialogBoxResult.Button1 ElseIf sender.Equals(btn2) Then diff --git a/Modules.EDMIAPI/Client.vb b/Modules.EDMIAPI/Client.vb index ac0c3cb0..e93b60d8 100644 --- a/Modules.EDMIAPI/Client.vb +++ b/Modules.EDMIAPI/Client.vb @@ -15,22 +15,24 @@ Public Class Client ' Helper Classes Private ReadOnly LogConfig As LogConfig Private ReadOnly Logger As Logger - Private ReadOnly FileEx As Filesystem.File + Private ReadOnly ChannelManager As Channel ' Runtime Variables - Private ReadOnly ServerAddress As String - Private ReadOnly ServerPort As Integer + Private _ServerAddress As ServerAddressStruct Private _ClientConfig As GlobalStateClientConfiguration - - ' Channel - Private ReadOnly ChannelFactory As ChannelFactory(Of IEDMIServiceChannel) - Private Channel As IEDMIServiceChannel + Private _CachedTables As New List(Of String) + Private _IsOnline As Boolean + Private _Channel As IEDMIServiceChannel ' Update Timer Private WithEvents UpdateTimer As New Timers.Timer ' Public Variables - Public CachedTables As New List(Of String) + Public ReadOnly Property CachedTables + Get + Return _CachedTables + End Get + End Property Public ReadOnly Property ClientConfig As GlobalStateClientConfiguration Get @@ -42,24 +44,27 @@ Public Class Client End Get End Property + Public ReadOnly Property IsOnline As Boolean + Get + Return _IsOnline + End Get + End Property + + Public ReadOnly Property ServerAddress As String + Get + Return $"{_ServerAddress.Host}:{_ServerAddress.Port}" + End Get + End Property + ''' ''' Parse a IPAddress:Port String into its parts ''' - ''' + ''' A Server Address, for example: 192.168.1.50, 192.168.1.50:9000, 192.168.1.50;9000 Public Shared Function ParseServiceAddress(AddressWithOptionalPort As String) As Tuple(Of String, Integer) - Dim oSplit() As String = AddressWithOptionalPort.Split(":"c) - Dim oAppServerAddress As String = oSplit(0) - Dim oAppServerPort As Integer + Dim oConnection As New Connection() + Dim oAddress As ServerAddressStruct = oConnection.ParseServiceAddress(AddressWithOptionalPort) - If oSplit.Length = 2 Then - If Integer.TryParse(oSplit(1), oAppServerPort) Then - oAppServerPort = DEFAULT_SERVICE_PORT - End If - Else - oAppServerPort = DEFAULT_SERVICE_PORT - End If - - Return New Tuple(Of String, Integer)(oAppServerAddress, oAppServerPort) + Return New Tuple(Of String, Integer)(oAddress.Host, oAddress.Port) End Function ''' @@ -70,25 +75,18 @@ Public Class Client Public Sub New(pLogConfig As LogConfig, pServiceAdress As String) LogConfig = pLogConfig Logger = pLogConfig.GetLogger() - FileEx = New Filesystem.File(pLogConfig) - - Dim oServiceAddress As String = pServiceAdress - Dim oAddressArray() As String - - If oServiceAddress.Contains(";") Then - oAddressArray = oServiceAddress.Split(";") - Else - oAddressArray = oServiceAddress.Split(":") - End If UpdateTimer.Interval = 60 * 1000 * UPDATE_INTERVAL_IN_MINUTES UpdateTimer.Start() Try - ServerAddress = oAddressArray(0) - ServerPort = oAddressArray(1) - Logger.Debug("Connecting to Service at: [{0}]", ServerAddress) - ChannelFactory = GetChannelFactory(ServerAddress, ServerPort) + Dim oConnection = New Connection() + _ServerAddress = oConnection.ParseServiceAddress(pServiceAdress) + ChannelManager = New Channel(pLogConfig, _ServerAddress) + AddHandler ChannelManager.Reconnect, AddressOf Reconnect + + Logger.Debug("Ready for connection to Service at: [{0}:{1}]", _ServerAddress.Host, _ServerAddress.Port) + Catch ex As Exception Logger.Error(ex) End Try @@ -97,60 +95,60 @@ Public Class Client ''' ''' Creates a new EDMI Client object ''' - ''' LogConfig object - ''' The IP address to connect to - ''' The Port number to use for the connection - Public Sub New(LogConfig As LogConfig, IPAddress As String, PortNumber As Integer) - Me.LogConfig = LogConfig - Logger = LogConfig.GetLogger() - FileEx = New Filesystem.File(LogConfig) + ''' LogConfig object + ''' The IP address to connect to + ''' The Port number to use for the connection + Public Sub New(pLogConfig As LogConfig, pIPAddress As String, pPortNumber As Integer) + LogConfig = pLogConfig + Logger = pLogConfig.GetLogger() UpdateTimer.Interval = 60 * 1000 * UPDATE_INTERVAL_IN_MINUTES UpdateTimer.Start() Try - Logger.Debug("Connecting to Service at: [{0}]", IPAddress) - ChannelFactory = GetChannelFactory(IPAddress, PortNumber) + Dim oConnection = New Connection() + _ServerAddress = oConnection.ParseServiceAddress(pIPAddress, pPortNumber) + ChannelManager = New Channel(pLogConfig, _ServerAddress) + AddHandler ChannelManager.Reconnect, AddressOf Reconnect + + Logger.Debug("Ready for connection to Service at: [{0}:{1}]", _ServerAddress.Host, _ServerAddress.Port) + Catch ex As Exception Logger.Error(ex) End Try End Sub - Private Function GetChannelFactory(pIPAddress As String, pPortNumber As Integer) As ChannelFactory(Of IEDMIServiceChannel) - Dim oBinding = API.Channel.GetBinding() - Dim oAddress = New EndpointAddress($"net.tcp://{pIPAddress}:{pPortNumber}/DigitalData/Services/Main") - Dim oFactory = New ChannelFactory(Of IEDMIServiceChannel)(oBinding, oAddress) - Return oFactory - End Function - ''' ''' Connect to the service ''' ''' True if connection was successful, false otherwise Public Function Connect() As Boolean Try - Channel = GetChannel() + _Channel = ChannelManager.GetChannel() Logger.Debug("Opening channel..") - Channel.Open() + _Channel.Open() - Dim oResponse = Channel.GetClientConfig() + Dim oResponse = _Channel.GetClientConfig() If oResponse.OK Then _ClientConfig = oResponse.ClientConfig Else Logger.Warn("Client Configuration could not be loaded: [{0}]", oResponse.ErrorMessage) End If - Logger.Info($"Connection to AppService {ServerAddress} successfully established!") + Logger.Info($"Connection to AppService [{ServerAddress}] successfully established!") + + _IsOnline = True Return True Catch ex As Exception + _IsOnline = False + Logger.Error(ex) Return False End Try End Function - ''' ''' Aborts the channel and creates a new connection ''' @@ -158,9 +156,11 @@ Public Class Client Logger.Warn("Connection faulted. Trying to reconnect..") Try - Channel.Abort() - Channel = GetChannel() - Channel.Open() + _Channel.Abort() + _Channel = ChannelManager.GetChannel() + _Channel.Open() + + _IsOnline = True Catch ex As Exception Logger.Error(ex) End Try @@ -168,14 +168,14 @@ Public Class Client Private Async Function UpdateTimer_Elapsed(sender As Object, e As Timers.ElapsedEventArgs) As Task Handles UpdateTimer.Elapsed Try - Dim oTables As String() = Await Channel.GetCachedTablesAsync() - CachedTables = oTables. + Dim oTables As String() = Await _Channel.GetCachedTablesAsync() + _CachedTables = oTables. Select(Function(table) table.ToUpper). ToList() Catch ex As Exception Logger.Warn("Update of CachedTable was not successful!") Logger.Error(ex) - CachedTables = New List(Of String) + _CachedTables = New List(Of String) End Try End Function @@ -190,7 +190,7 @@ Public Class Client ''' The ObjectId of the newly generated filesystem object Public Async Function NewFileAsync(pFilePath As String, pObjectStoreName As String, pObjectKind As String, pIDBDoctypeId As Long, Optional pImportOptions As Options.NewFileOptions = Nothing) As Task(Of Long) Try - Dim oNewFile As New Modules.IDB.NewFile(LogConfig, Channel) + Dim oNewFile As New Modules.IDB.NewFile(LogConfig, _Channel) Return Await oNewFile.RunAsync(pFilePath, pObjectStoreName, pObjectKind, pIDBDoctypeId, pImportOptions) Catch ex As Exception @@ -202,7 +202,7 @@ Public Class Client Public Async Function UpdateFileAsync(pObjectId As Long, pFilePath As String, Optional pImportOptions As Options.UpdateFileOptions = Nothing) As Task(Of Long) Try - Dim oUpdateFile As New Modules.IDB.UpdateFile(LogConfig, Channel) + Dim oUpdateFile As New Modules.IDB.UpdateFile(LogConfig, _Channel) Return Await oUpdateFile.RunAsync(pFilePath, pObjectId, pImportOptions) Catch ex As Exception @@ -214,7 +214,7 @@ Public Class Client Public Async Function SetObjectStateAsync(pObjectId As Long, pState As String, Optional pOptions As Options.SetObjectStateOptions = Nothing) As Task(Of Boolean) Try - Dim oSetObjectState As New Modules.IDB.SetObjectState(LogConfig, Channel) + Dim oSetObjectState As New Modules.IDB.SetObjectState(LogConfig, _Channel) Return Await oSetObjectState.RunAsync(pObjectId, pState, pOptions) Catch ex As Exception @@ -226,7 +226,7 @@ Public Class Client Public Async Function SetAttributeValueAsync(pObjectId As Long, pName As String, pValue As Object, Optional pOptions As Options.SetAttributeValueOptions = Nothing) As Task(Of Boolean) Try - Dim oSetAttributeValue As New Modules.IDB.SetAttributeValue(LogConfig, Channel) + Dim oSetAttributeValue As New Modules.IDB.SetAttributeValue(LogConfig, _Channel) Return Await oSetAttributeValue.RunAsync(pObjectId, pName, pValue, pOptions) Catch ex As Exception @@ -238,7 +238,7 @@ Public Class Client Public Async Function CheckOutFile(pObjectId As Long, pComment As String, Optional pOptions As Options.CheckOutInOptions = Nothing) As Task(Of Long) Try - Dim oCheckOutFile As New Modules.IDB.CheckOutFile(LogConfig, Channel) + Dim oCheckOutFile As New Modules.IDB.CheckOutFile(LogConfig, _Channel) Return Await oCheckOutFile.RunAsync(pObjectId, pComment, pOptions) Catch ex As Exception @@ -250,7 +250,7 @@ Public Class Client Public Async Function CheckOutFile(pObjectId As Long, Optional pOptions As Options.CheckOutInOptions = Nothing) As Task(Of Long) Try - Dim oCheckOutFile As New Modules.IDB.CheckOutFile(LogConfig, Channel) + Dim oCheckOutFile As New Modules.IDB.CheckOutFile(LogConfig, _Channel) Return Await oCheckOutFile.RunAsync(pObjectId, String.Empty, pOptions) Catch ex As Exception @@ -262,7 +262,7 @@ Public Class Client Public Async Function CheckInFile(pObjectId As Long, Optional pOptions As Options.CheckOutInOptions = Nothing) As Task(Of Long) Try - Dim oCheckInFile As New Modules.IDB.CheckInFile(LogConfig, Channel) + Dim oCheckInFile As New Modules.IDB.CheckInFile(LogConfig, _Channel) Return Await oCheckInFile.RunAsync(pObjectId, pOptions) Catch ex As Exception @@ -280,7 +280,7 @@ Public Class Client pIDBDoctypeId As String, Optional pImportOptions As Options.ImportFileOptions = Nothing) As Task(Of ImportFileResponse) Try - Dim oImportFile As New Modules.IDB.ImportFile(LogConfig, Channel) + Dim oImportFile As New Modules.IDB.ImportFile(LogConfig, _Channel) Return Await oImportFile.RunAsync(pFilePath, pAttributeValues, pObjectStoreName, pObjectKind, pIDBDoctypeId, pImportOptions) Catch ex As Exception @@ -290,7 +290,6 @@ Public Class Client End Try End Function - Public Async Function Globix_ImportFileAsync( pFilePath As String, pProfileId As Integer, @@ -300,7 +299,7 @@ Public Class Client pIDBDoctypeId As String, Optional pImportOptions As Options.ImportFileOptions = Nothing) As Task(Of Globix_ImportFileResponse) Try - Dim oImportFile As New Modules.Globix.ImportFile(LogConfig, Channel) + Dim oImportFile As New Modules.Globix.ImportFile(LogConfig, _Channel) Return Await oImportFile.RunAsync(pFilePath, pProfileId, pAttributeValues, pObjectStoreName, pObjectKind, pIDBDoctypeId, pImportOptions) Catch ex As Exception @@ -312,7 +311,7 @@ Public Class Client Public Function Zooflow_GetFileObject(pObjectId As Long, pLoadFileContents As Boolean) As FileObject Try - Dim oGetFileObject As New Modules.Zooflow.GetFileObject(LogConfig, Channel) + Dim oGetFileObject As New Modules.Zooflow.GetFileObject(LogConfig, _Channel) Dim oFileObject = oGetFileObject.Run(pObjectId, pLoadFileContents) Return oFileObject Catch ex As Exception @@ -472,7 +471,7 @@ Public Class Client .Language = pOptions.Language } } - Dim oResponse = Channel.GetAttributeValue(oArgs) + Dim oResponse = _Channel.GetAttributeValue(oArgs) If oResponse.OK = False Then Return New VariableValue() @@ -536,7 +535,7 @@ Public Class Client Dim oAttributes As New List(Of ObjectAttribute) Try - Dim oResult As TableResult = Channel.ReturnDatatable_MSSQL_IDB($"EXEC [PRIDB_GET_VALUE_DT] {pObjectId}, '{pLanguage}'") + Dim oResult As TableResult = _Channel.ReturnDatatable_MSSQL_IDB($"EXEC [PRIDB_GET_VALUE_DT] {pObjectId}, '{pLanguage}'") If oResult.OK = False Then Throw New ApplicationException(oResult.ErrorMessage) @@ -577,7 +576,7 @@ Public Class Client Dim oSql = $"DECLARE @NEW_OBJ_MD_ID BIGINT EXEC PRIDB_NEW_OBJ_DATA({pObjectId}, '{pAttributeName}', '{oUsername}', '{pValue}', '{oLanguage}', 0, @OMD_ID = @NEW_OBJ_MD_ID OUTPUT)" - Dim oResult = Channel.ExecuteNonQuery_MSSQL_IDB(oSql) + Dim oResult = _Channel.ExecuteNonQuery_MSSQL_IDB(oSql) If oResult.OK = False Then Logger.Warn("Error while deleting Term object") @@ -594,7 +593,7 @@ Public Class Client Dim oIdIsForeign As Integer = 1 Dim oDELSQL = $"EXEC PRIDB_DELETE_TERM_OBJECT_METADATA {pObjectId},'{pAttributeName}','{pTerm2Delete}','{oUsername}','{oLanguage}',{oIdIsForeign}" - Dim oResult = Channel.ExecuteNonQuery_MSSQL_IDB(oDELSQL) + Dim oResult = _Channel.ExecuteNonQuery_MSSQL_IDB(oDELSQL) If oResult.OK = False Then Logger.Warn("Error while deleting Term object") @@ -611,7 +610,7 @@ Public Class Client #Region "GetDatatable" Public Function GetDatatableFromIDB(pSQL As String) As GetDatatableResponse Try - Dim oResponse = Channel.ReturnDatatable(New GetDatatableRequest() With { + Dim oResponse = _Channel.ReturnDatatable(New GetDatatableRequest() With { .SqlCommand = pSQL, .NamedDatabase = DatabaseName.IDB }) @@ -624,7 +623,7 @@ Public Class Client Public Function GetDatatableFromECM(pSQL As String) As GetDatatableResponse Try - Dim oResponse = Channel.ReturnDatatable(New GetDatatableRequest() With { + Dim oResponse = _Channel.ReturnDatatable(New GetDatatableRequest() With { .SqlCommand = pSQL, .NamedDatabase = DatabaseName.ECM }) @@ -637,7 +636,7 @@ Public Class Client Public Function GetDatatableFromConnection(pSQL As String, pConnectionId As Integer) As GetDatatableResponse Try - Dim oResponse = Channel.ReturnDatatable(New GetDatatableRequest() With { + Dim oResponse = _Channel.ReturnDatatable(New GetDatatableRequest() With { .SqlCommand = pSQL, .NamedDatabase = DatabaseName.None, .ConnectionId = pConnectionId @@ -651,7 +650,7 @@ Public Class Client Public Async Function GetDatatableFromIDBAsync(pSQL As String) As Task(Of GetDatatableResponse) Try - Dim oResponse = Await Channel.ReturnDatatableAsync(New GetDatatableRequest() With { + Dim oResponse = Await _Channel.ReturnDatatableAsync(New GetDatatableRequest() With { .SqlCommand = pSQL, .NamedDatabase = DatabaseName.IDB }) @@ -664,7 +663,7 @@ Public Class Client Public Async Function GetDatatableFromECMAsync(pSQL As String) As Task(Of GetDatatableResponse) Try - Dim oResponse = Await Channel.ReturnDatatableAsync(New GetDatatableRequest() With { + Dim oResponse = Await _Channel.ReturnDatatableAsync(New GetDatatableRequest() With { .SqlCommand = pSQL, .NamedDatabase = DatabaseName.ECM }) @@ -677,7 +676,7 @@ Public Class Client Public Async Function GetDatatableFromConnectionAsync(pSQL As String, Optional pConnectionId As Integer = 0) As Task(Of GetDatatableResponse) Try - Dim oResponse = Await Channel.ReturnDatatableAsync(New GetDatatableRequest() With { + Dim oResponse = Await _Channel.ReturnDatatableAsync(New GetDatatableRequest() With { .SqlCommand = pSQL, .NamedDatabase = DatabaseName.None, .ConnectionId = pConnectionId @@ -693,7 +692,7 @@ Public Class Client #Region "GetScalarValue" Public Function GetScalarValueFromIDB(pSQL As String) As GetScalarValueResponse Try - Dim oResponse = Channel.ReturnScalarValue(New GetScalarValueRequest() With { + Dim oResponse = _Channel.ReturnScalarValue(New GetScalarValueRequest() With { .SqlCommand = pSQL, .NamedDatabase = DatabaseName.IDB }) @@ -706,7 +705,7 @@ Public Class Client Public Function GetScalarValueFromECM(pSQL As String) As GetScalarValueResponse Try - Dim oResponse = Channel.ReturnScalarValue(New GetScalarValueRequest() With { + Dim oResponse = _Channel.ReturnScalarValue(New GetScalarValueRequest() With { .SqlCommand = pSQL, .NamedDatabase = DatabaseName.ECM }) @@ -719,7 +718,7 @@ Public Class Client Public Function GetScalarValueFromConnection(pSQL As String, pConnectionId As Integer) As GetScalarValueResponse Try - Dim oResponse = Channel.ReturnScalarValue(New GetScalarValueRequest() With { + Dim oResponse = _Channel.ReturnScalarValue(New GetScalarValueRequest() With { .SqlCommand = pSQL, .NamedDatabase = DatabaseName.None, .ConnectionId = pConnectionId @@ -733,7 +732,7 @@ Public Class Client Public Async Function GetScalarValueFromIDBAsync(pSQL As String) As Task(Of GetScalarValueResponse) Try - Dim oResponse = Await Channel.ReturnScalarValueAsync(New GetScalarValueRequest() With { + Dim oResponse = Await _Channel.ReturnScalarValueAsync(New GetScalarValueRequest() With { .SqlCommand = pSQL, .NamedDatabase = DatabaseName.IDB }) @@ -746,7 +745,7 @@ Public Class Client Public Async Function GetScalarValueFromECMAsync(pSQL As String) As Task(Of GetScalarValueResponse) Try - Dim oResponse = Await Channel.ReturnScalarValueAsync(New GetScalarValueRequest() With { + Dim oResponse = Await _Channel.ReturnScalarValueAsync(New GetScalarValueRequest() With { .SqlCommand = pSQL, .NamedDatabase = DatabaseName.ECM }) @@ -759,7 +758,7 @@ Public Class Client Public Async Function GetScalarValueFromConnectionAsync(pSQL As String, pConnectionId As Integer) As Task(Of GetScalarValueResponse) Try - Dim oResponse = Await Channel.ReturnScalarValueAsync(New GetScalarValueRequest() With { + Dim oResponse = Await _Channel.ReturnScalarValueAsync(New GetScalarValueRequest() With { .SqlCommand = pSQL, .NamedDatabase = DatabaseName.None, .ConnectionId = pConnectionId @@ -775,7 +774,7 @@ Public Class Client #Region "ExecuteNonQuery" Public Function ExecuteNonQueryFromIDB(pSQL As String) As ExecuteNonQueryResponse Try - Dim oResponse = Channel.ExecuteNonQuery(New ExecuteNonQueryRequest() With { + Dim oResponse = _Channel.ExecuteNonQuery(New ExecuteNonQueryRequest() With { .SqlCommand = pSQL, .NamedDatabase = DatabaseName.IDB }) @@ -788,7 +787,7 @@ Public Class Client Public Function ExecuteNonQueryFromECM(pSQL As String) As ExecuteNonQueryResponse Try - Dim oResponse = Channel.ExecuteNonQuery(New ExecuteNonQueryRequest() With { + Dim oResponse = _Channel.ExecuteNonQuery(New ExecuteNonQueryRequest() With { .SqlCommand = pSQL, .NamedDatabase = DatabaseName.ECM }) @@ -801,7 +800,7 @@ Public Class Client Public Function ExecuteNonQueryFromConnection(pSQL As String, pConnectionId As Integer) As ExecuteNonQueryResponse Try - Dim oResponse = Channel.ExecuteNonQuery(New ExecuteNonQueryRequest() With { + Dim oResponse = _Channel.ExecuteNonQuery(New ExecuteNonQueryRequest() With { .SqlCommand = pSQL, .NamedDatabase = DatabaseName.None, .ConnectionId = pConnectionId @@ -815,7 +814,7 @@ Public Class Client Public Async Function ExecuteNonQueryFromIDBAsync(pSQL As String) As Task(Of ExecuteNonQueryResponse) Try - Dim oResponse = Await Channel.ExecuteNonQueryAsync(New ExecuteNonQueryRequest() With { + Dim oResponse = Await _Channel.ExecuteNonQueryAsync(New ExecuteNonQueryRequest() With { .SqlCommand = pSQL, .NamedDatabase = DatabaseName.IDB }) @@ -828,7 +827,7 @@ Public Class Client Public Async Function ExecuteNonQueryFromECMAsync(pSQL As String) As Task(Of ExecuteNonQueryResponse) Try - Dim oResponse = Await Channel.ExecuteNonQueryAsync(New ExecuteNonQueryRequest() With { + Dim oResponse = Await _Channel.ExecuteNonQueryAsync(New ExecuteNonQueryRequest() With { .SqlCommand = pSQL, .NamedDatabase = DatabaseName.ECM }) @@ -841,7 +840,7 @@ Public Class Client Public Async Function ExecuteNonQueryFromConnectionAsync(pSQL As String, pConnectionId As Integer) As Task(Of ExecuteNonQueryResponse) Try - Dim oResponse = Await Channel.ExecuteNonQueryAsync(New ExecuteNonQueryRequest() With { + Dim oResponse = Await _Channel.ExecuteNonQueryAsync(New ExecuteNonQueryRequest() With { .SqlCommand = pSQL, .NamedDatabase = DatabaseName.None, .ConnectionId = pConnectionId @@ -857,7 +856,7 @@ Public Class Client Public Function GetDatatableByName(DatatableName As String, Optional FilterExpression As String = "", Optional SortByColumn As String = "") As TableResult Try - Dim oResponse = Channel.ReturnDatatableFromCache(DatatableName, FilterExpression, SortByColumn) + Dim oResponse = _Channel.ReturnDatatableFromCache(DatatableName, FilterExpression, SortByColumn) Return oResponse Catch ex As Exception Logger.Error(ex) @@ -867,7 +866,7 @@ Public Class Client Public Async Function GetDatatableByNameAsync(DatatableName As String, Optional FilterExpression As String = "", Optional SortByColumn As String = "") As Task(Of TableResult) Try - Dim oResponse = Await Channel.ReturnDatatableFromCacheAsync(DatatableName, FilterExpression, SortByColumn) + Dim oResponse = Await _Channel.ReturnDatatableFromCacheAsync(DatatableName, FilterExpression, SortByColumn) Return oResponse Catch ex As Exception Logger.Error(ex) @@ -885,7 +884,7 @@ Public Class Client ''' Public Function GetDocumentInfo(UserId As Long, ObjectId As Long) As DocumentInfo Try - Dim oResponse As DocumentInfoResponse = Channel.GetFileInfoByObjectId(New DocumentInfoRequest With { + Dim oResponse As DocumentInfoResponse = _Channel.GetFileInfoByObjectId(New DocumentInfoRequest With { .ObjectId = ObjectId, .UserId = UserId }) @@ -916,7 +915,7 @@ Public Class Client .ObjectId = ObjectId, .UserId = UserId } - Dim oResponse As DocumentInfoResponse = Await Channel.GetFileInfoByObjectIdAsync(oParams) + Dim oResponse As DocumentInfoResponse = Await _Channel.GetFileInfoByObjectIdAsync(oParams) Return New DocumentInfo With { .AccessRight = oResponse.FileRight, @@ -930,23 +929,7 @@ Public Class Client #Region "Private Functions" - ''' - ''' Creates a channel and adds a Faulted-Handler - ''' - ''' A channel object - Private Function GetChannel() As IEDMIServiceChannel - Try - Logger.Debug("...Creating channel..") - Dim oChannel = ChannelFactory.CreateChannel() - AddHandler oChannel.Faulted, AddressOf Reconnect - - Return oChannel - Catch ex As Exception - Logger.Error(ex) - Throw ex - End Try - End Function Private Function GetUserLanguage(pOverrideLanguage As String) As String Return NotNull(pOverrideLanguage, Threading.Thread.CurrentThread.CurrentUICulture.Name) diff --git a/Modules.EDMIAPI/Client/Channel.vb b/Modules.EDMIAPI/Client/Channel.vb index 962fd57e..8a8f1d41 100644 --- a/Modules.EDMIAPI/Client/Channel.vb +++ b/Modules.EDMIAPI/Client/Channel.vb @@ -1,24 +1,21 @@ Imports System.ServiceModel Imports System.Xml - +Imports DigitalData.Modules.Base +Imports DigitalData.Modules.EDMI.API.EDMIServiceReference +Imports DigitalData.Modules.Logging Public Class Channel - ' Infos about MaxBufferSize and MaxBufferPoolSize - ' https://social.msdn.microsoft.com/Forums/vstudio/en-US/d6e234d3-942f-4e9d-8470-32618d3f3212/maxbufferpoolsize-vs-maxbuffersize?forum=wcf + Inherits BaseClass - Public Const MAX_RECEIVED_MESSAGE_SIZE = 2147483647 ' 1GB - Public Const MAX_BUFFER_SIZE = 104857600 ' 100MB - Public Const MAX_BUFFER_POOL_SIZE = 1048576 ' 1MB + Private ReadOnly ChannelFactory As ChannelFactory(Of IEDMIServiceChannel) - Public Const MAX_CONNECTIONS = 500 - Public Const MAX_ARRAY_LENGTH = 2147483647 - Public Const MAX_STRING_CONTENT_LENGTH = 2147483647 + Public Event Reconnect As EventHandler Public Shared Function GetBinding(Optional AuthenticationMode As TcpClientCredentialType = TcpClientCredentialType.Windows) As NetTcpBinding Return New NetTcpBinding() With { - .MaxReceivedMessageSize = MAX_RECEIVED_MESSAGE_SIZE, - .MaxBufferSize = MAX_BUFFER_SIZE, - .MaxBufferPoolSize = MAX_BUFFER_POOL_SIZE, + .MaxReceivedMessageSize = Constants.ChannelSettings.MAX_RECEIVED_MESSAGE_SIZE, + .MaxBufferSize = Constants.ChannelSettings.MAX_BUFFER_SIZE, + .MaxBufferPoolSize = Constants.ChannelSettings.MAX_BUFFER_POOL_SIZE, .TransferMode = TransferMode.Streamed, .Security = New NetTcpSecurity() With { .Mode = SecurityMode.Transport, @@ -27,11 +24,41 @@ Public Class Channel } }, .ReaderQuotas = New XmlDictionaryReaderQuotas() With { - .MaxArrayLength = MAX_ARRAY_LENGTH, - .MaxStringContentLength = MAX_STRING_CONTENT_LENGTH + .MaxArrayLength = Constants.ChannelSettings.MAX_ARRAY_LENGTH, + .MaxStringContentLength = Constants.ChannelSettings.MAX_STRING_CONTENT_LENGTH } } End Function + + Public Sub New(pLogConfig As LogConfig, pServerAddress As ServerAddressStruct) + MyBase.New(pLogConfig) + ChannelFactory = GetChannelFactory(pServerAddress) + End Sub + + ''' + ''' Creates a channel and adds a Faulted-Handler + ''' + ''' A channel object + Public Function GetChannel() As IEDMIServiceChannel + Try + Logger.Debug("Creating channel.") + Dim oChannel = ChannelFactory.CreateChannel() + + AddHandler oChannel.Faulted, Sub() RaiseEvent Reconnect(Me, Nothing) + + Return oChannel + Catch ex As Exception + Logger.Error(ex) + Throw ex + End Try + End Function + + Private Function GetChannelFactory(pServerAddress As ServerAddressStruct) As ChannelFactory(Of IEDMIServiceChannel) + Dim oBinding = GetBinding() + Dim oAddress = New EndpointAddress($"net.tcp://{pServerAddress.Host}:{pServerAddress.Port}/DigitalData/Services/Main") + Dim oFactory = New ChannelFactory(Of IEDMIServiceChannel)(oBinding, oAddress) + Return oFactory + End Function End Class diff --git a/Modules.EDMIAPI/Client/Connection.vb b/Modules.EDMIAPI/Client/Connection.vb new file mode 100644 index 00000000..09ba6276 --- /dev/null +++ b/Modules.EDMIAPI/Client/Connection.vb @@ -0,0 +1,31 @@ +Imports DigitalData.Modules.Base +Imports DigitalData.Modules.Logging + +Public Class Connection + Public Function ParseServiceAddress(pHost As String, pPort As Integer) As ServerAddressStruct + Dim oAddress As ServerAddressStruct + + oAddress.Host = pHost + oAddress.Port = pPort + + Return oAddress + End Function + + Public Function ParseServiceAddress(pAddress As String) As ServerAddressStruct + Dim oAddressList As List(Of String) + Dim oAddress As ServerAddressStruct + + If pAddress.Contains(";"c) Then + oAddressList = pAddress.Split(";"c).ToList + ElseIf pAddress.Contains(":"c) Then + oAddressList = pAddress.Split(":"c).ToList + Else + oAddressList = New List(Of String) From {pAddress, Constants.DEFAULT_SERVICE_PORT} + End If + + oAddress.Host = oAddressList.First() + oAddress.Port = oAddressList.Item(1) + + Return oAddress + End Function +End Class diff --git a/Modules.EDMIAPI/Client/ServerAddressStruct.vb b/Modules.EDMIAPI/Client/ServerAddressStruct.vb new file mode 100644 index 00000000..a4e9d386 --- /dev/null +++ b/Modules.EDMIAPI/Client/ServerAddressStruct.vb @@ -0,0 +1,4 @@ +Public Structure ServerAddressStruct + Public Host As String + Public Port As Integer +End Structure \ No newline at end of file diff --git a/Modules.EDMIAPI/Constants.vb b/Modules.EDMIAPI/Constants.vb index 348dc85e..14311119 100644 --- a/Modules.EDMIAPI/Constants.vb +++ b/Modules.EDMIAPI/Constants.vb @@ -31,4 +31,19 @@ Public Const VECTOR_STRING = "VECTOR STRING" Public Const VECTOR_INTEGER = "VECTOR INTEGER" End Class + + ''' + ''' Infos about MaxBufferSize and MaxBufferPoolSize + ''' https://social.msdn.microsoft.com/Forums/vstudio/en-US/d6e234d3-942f-4e9d-8470-32618d3f3212/maxbufferpoolsize-vs-maxbuffersize?forum=wcf + ''' + Public Class ChannelSettings + Public Const MAX_RECEIVED_MESSAGE_SIZE = 2147483647 ' 1GB + Public Const MAX_BUFFER_SIZE = 104857600 ' 100MB + Public Const MAX_BUFFER_POOL_SIZE = 1048576 ' 1MB + + Public Const MAX_CONNECTIONS = 500 + Public Const MAX_ARRAY_LENGTH = 2147483647 + Public Const MAX_STRING_CONTENT_LENGTH = 2147483647 + End Class + End Class diff --git a/Modules.EDMIAPI/EDMI.API.vbproj b/Modules.EDMIAPI/EDMI.API.vbproj index 45eebcc2..74b1b138 100644 --- a/Modules.EDMIAPI/EDMI.API.vbproj +++ b/Modules.EDMIAPI/EDMI.API.vbproj @@ -72,10 +72,12 @@ + + @@ -277,6 +279,10 @@ + + {6ea0c51f-c2b1-4462-8198-3de0b32b74f8} + Base + {eaf0ea75-5fa7-485d-89c7-b2d843b03a96} Database