diff --git a/Controls.DocumentViewer/App.config b/Controls.DocumentViewer/App.config index 181c5758..0927f884 100644 --- a/Controls.DocumentViewer/App.config +++ b/Controls.DocumentViewer/App.config @@ -39,7 +39,7 @@ - + diff --git a/Controls.DocumentViewer/DocumentViewer.Designer.vb b/Controls.DocumentViewer/DocumentViewer.Designer.vb index 5cf2b0c8..43146318 100644 --- a/Controls.DocumentViewer/DocumentViewer.Designer.vb +++ b/Controls.DocumentViewer/DocumentViewer.Designer.vb @@ -24,7 +24,6 @@ Partial Class DocumentViewer Private Sub InitializeComponent() Me.components = New System.ComponentModel.Container() Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(DocumentViewer)) - Me.GdViewer = New GdPicture14.GdViewer() Me.OpenFileDialog = New System.Windows.Forms.OpenFileDialog() Me.BarManager1 = New DevExpress.XtraBars.BarManager(Me.components) Me.ToolbarDocumentViewer = New DevExpress.XtraBars.Bar() @@ -74,82 +73,6 @@ Partial Class DocumentViewer CType(Me.RepositoryItemSearchControl1, System.ComponentModel.ISupportInitialize).BeginInit() Me.SuspendLayout() ' - 'GdViewer - ' - Me.GdViewer.AllowDropFile = False - Me.GdViewer.AnimateGIF = True - Me.GdViewer.AnnotationDropShadow = False - Me.GdViewer.AnnotationEnableMultiSelect = True - Me.GdViewer.AnnotationResizeRotateHandlesColor = System.Drawing.Color.FromArgb(CType(CType(0, Byte), Integer), CType(CType(0, Byte), Integer), CType(CType(128, Byte), Integer)) - Me.GdViewer.AnnotationResizeRotateHandlesScale = 1.0! - Me.GdViewer.AnnotationSelectionLineColor = System.Drawing.Color.FromArgb(CType(CType(255, Byte), Integer), CType(CType(0, Byte), Integer), CType(CType(0, Byte), Integer)) - Me.GdViewer.AutoScrollMargin = New System.Drawing.Size(0, 0) - Me.GdViewer.AutoScrollMinSize = New System.Drawing.Size(0, 0) - Me.GdViewer.BackColor = System.Drawing.SystemColors.AppWorkspace - Me.GdViewer.BackgroundImage = Nothing - Me.GdViewer.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None - Me.GdViewer.ClipAnnotsToPageBounds = True - Me.GdViewer.ClipRegionsToPageBounds = True - Me.GdViewer.ContinuousViewMode = True - Me.GdViewer.DisplayQuality = GdPicture14.DisplayQuality.DisplayQualityAutomatic - Me.GdViewer.DisplayQualityAuto = True - Me.GdViewer.Dock = System.Windows.Forms.DockStyle.Fill - Me.GdViewer.DocumentAlignment = GdPicture14.ViewerDocumentAlignment.DocumentAlignmentMiddleCenter - Me.GdViewer.DocumentPosition = GdPicture14.ViewerDocumentPosition.DocumentPositionMiddleCenter - Me.GdViewer.DrawPageBorders = True - Me.GdViewer.EnableDeferredPainting = True - Me.GdViewer.EnabledProgressBar = True - Me.GdViewer.EnableFuzzySearch = False - Me.GdViewer.EnableICM = False - Me.GdViewer.EnableMenu = True - Me.GdViewer.EnableMouseWheel = True - Me.GdViewer.EnableTextSelection = True - Me.GdViewer.ForceScrollBars = False - Me.GdViewer.ForceTemporaryMode = False - Me.GdViewer.ForeColor = System.Drawing.Color.Black - Me.GdViewer.Gamma = 1.0! - Me.GdViewer.HQAnnotationRendering = True - Me.GdViewer.IgnoreDocumentResolution = False - Me.GdViewer.KeepDocumentPosition = False - Me.GdViewer.Location = New System.Drawing.Point(0, 33) - Me.GdViewer.LockViewer = False - Me.GdViewer.MagnifierHeight = 90 - Me.GdViewer.MagnifierWidth = 160 - Me.GdViewer.MagnifierZoomX = 2.0! - Me.GdViewer.MagnifierZoomY = 2.0! - Me.GdViewer.MouseButtonForMouseMode = GdPicture14.MouseButton.MouseButtonLeft - Me.GdViewer.MouseMode = GdPicture14.ViewerMouseMode.MouseModePan - Me.GdViewer.MouseWheelMode = GdPicture14.ViewerMouseWheelMode.MouseWheelModeVerticalScroll - Me.GdViewer.Name = "GdViewer" - Me.GdViewer.PageBordersColor = System.Drawing.Color.Black - Me.GdViewer.PageBordersPenSize = 1 - Me.GdViewer.PageDisplayMode = GdPicture14.PageDisplayMode.MultiplePagesView - Me.GdViewer.PdfDisplayFormField = True - Me.GdViewer.PdfEnableFileLinks = True - Me.GdViewer.PdfEnableLinks = True - Me.GdViewer.PdfIncreaseTextContrast = False - Me.GdViewer.PdfShowDialogForPassword = True - Me.GdViewer.PdfShowOpenFileDialogForDecryption = True - Me.GdViewer.PdfVerifyDigitalCertificates = False - Me.GdViewer.PreserveViewRotation = True - Me.GdViewer.RectBorderColor = System.Drawing.Color.Black - Me.GdViewer.RectBorderSize = 1 - Me.GdViewer.RectIsEditable = True - Me.GdViewer.RegionsAreEditable = True - Me.GdViewer.RenderGdPictureAnnots = True - Me.GdViewer.ScrollBars = True - Me.GdViewer.ScrollLargeChange = CType(50, Short) - Me.GdViewer.ScrollSmallChange = CType(1, Short) - Me.GdViewer.SilentMode = True - Me.GdViewer.Size = New System.Drawing.Size(1012, 557) - Me.GdViewer.TabIndex = 0 - Me.GdViewer.TabStop = False - Me.GdViewer.ViewRotation = System.Drawing.RotateFlipType.RotateNoneFlipNone - Me.GdViewer.Zoom = 1.0R - Me.GdViewer.ZoomCenterAtMousePosition = False - Me.GdViewer.ZoomMode = GdPicture14.ViewerZoomMode.ZoomMode100 - Me.GdViewer.ZoomStep = 25 - ' 'OpenFileDialog ' Me.OpenFileDialog.FileName = "OpenFileDialog1" @@ -355,15 +278,15 @@ Partial Class DocumentViewer Me.barDockControlTop.Dock = System.Windows.Forms.DockStyle.Top Me.barDockControlTop.Location = New System.Drawing.Point(0, 0) Me.barDockControlTop.Manager = Me.BarManager1 - Me.barDockControlTop.Size = New System.Drawing.Size(1012, 33) + Me.barDockControlTop.Size = New System.Drawing.Size(841, 33) ' 'barDockControlBottom ' Me.barDockControlBottom.CausesValidation = False Me.barDockControlBottom.Dock = System.Windows.Forms.DockStyle.Bottom - Me.barDockControlBottom.Location = New System.Drawing.Point(0, 590) + Me.barDockControlBottom.Location = New System.Drawing.Point(0, 555) Me.barDockControlBottom.Manager = Me.BarManager1 - Me.barDockControlBottom.Size = New System.Drawing.Size(1012, 0) + Me.barDockControlBottom.Size = New System.Drawing.Size(841, 0) ' 'barDockControlLeft ' @@ -371,15 +294,15 @@ Partial Class DocumentViewer Me.barDockControlLeft.Dock = System.Windows.Forms.DockStyle.Left Me.barDockControlLeft.Location = New System.Drawing.Point(0, 33) Me.barDockControlLeft.Manager = Me.BarManager1 - Me.barDockControlLeft.Size = New System.Drawing.Size(0, 557) + Me.barDockControlLeft.Size = New System.Drawing.Size(0, 522) ' 'barDockControlRight ' Me.barDockControlRight.CausesValidation = False Me.barDockControlRight.Dock = System.Windows.Forms.DockStyle.Right - Me.barDockControlRight.Location = New System.Drawing.Point(1012, 33) + Me.barDockControlRight.Location = New System.Drawing.Point(841, 33) Me.barDockControlRight.Manager = Me.BarManager1 - Me.barDockControlRight.Size = New System.Drawing.Size(0, 557) + Me.barDockControlRight.Size = New System.Drawing.Size(0, 522) ' 'BarStaticItem1 ' @@ -446,7 +369,7 @@ Partial Class DocumentViewer Me.lbFileNotLoaded.AutoSizeMode = DevExpress.XtraEditors.LabelAutoSizeMode.None Me.lbFileNotLoaded.Location = New System.Drawing.Point(3, 74) Me.lbFileNotLoaded.Name = "lbFileNotLoaded" - Me.lbFileNotLoaded.Size = New System.Drawing.Size(1006, 72) + Me.lbFileNotLoaded.Size = New System.Drawing.Size(835, 72) Me.lbFileNotLoaded.TabIndex = 0 Me.lbFileNotLoaded.Tag = "" Me.lbFileNotLoaded.Text = "Die Datei konnte nicht geladen werden" @@ -454,28 +377,17 @@ Partial Class DocumentViewer ' 'RichEditControl1 ' - Me.RichEditControl1.Location = New System.Drawing.Point(447, 271) + Me.RichEditControl1.Location = New System.Drawing.Point(571, 238) Me.RichEditControl1.MenuManager = Me.BarManager1 Me.RichEditControl1.Name = "RichEditControl1" Me.RichEditControl1.Size = New System.Drawing.Size(400, 200) Me.RichEditControl1.TabIndex = 5 Me.RichEditControl1.Visible = False ' - 'lblInfo - ' - Me.lblInfo.AutoSize = True - Me.lblInfo.ForeColor = System.Drawing.Color.Red - Me.lblInfo.Location = New System.Drawing.Point(18, 558) - Me.lblInfo.Name = "lblInfo" - Me.lblInfo.Size = New System.Drawing.Size(39, 13) - Me.lblInfo.TabIndex = 10 - Me.lblInfo.Text = "Label1" - ' 'DocumentViewer ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font - Me.Controls.Add(Me.lblInfo) Me.Controls.Add(Me.RichEditControl1) Me.Controls.Add(Me.lbFileNotLoaded) Me.Controls.Add(Me.SpreadsheetControl1) @@ -485,7 +397,7 @@ Partial Class DocumentViewer Me.Controls.Add(Me.barDockControlBottom) Me.Controls.Add(Me.barDockControlTop) Me.Name = "DocumentViewer" - Me.Size = New System.Drawing.Size(1012, 590) + Me.Size = New System.Drawing.Size(841, 555) CType(Me.BarManager1, System.ComponentModel.ISupportInitialize).EndInit() CType(Me.RepositoryItemTextEdit2, System.ComponentModel.ISupportInitialize).EndInit() CType(Me.RepositoryItemTextEdit3, System.ComponentModel.ISupportInitialize).EndInit() diff --git a/Controls.DocumentViewer/DocumentViewer.resx b/Controls.DocumentViewer/DocumentViewer.resx index 52330804..249559ce 100644 --- a/Controls.DocumentViewer/DocumentViewer.resx +++ b/Controls.DocumentViewer/DocumentViewer.resx @@ -123,6 +123,9 @@ 285, 22 + + 25 + diff --git a/Controls.DocumentViewer/DocumentViewer.vb b/Controls.DocumentViewer/DocumentViewer.vb index 431dba5e..d5bf0bc0 100644 --- a/Controls.DocumentViewer/DocumentViewer.vb +++ b/Controls.DocumentViewer/DocumentViewer.vb @@ -55,6 +55,7 @@ Public Class DocumentViewer Private _hide_file_info_from_user As Boolean = False + Private _FileStream As Stream Private _FilePath As String Private _FileInfo As FileInfo @@ -65,6 +66,8 @@ Public Class DocumentViewer Private _TempFiles As New List(Of String) Private Sub DocumentViewer_Load(sender As Object, e As EventArgs) Handles Me.Load + ' Ensure search is initialized once the control (and GdViewer) exists + EnsureSearchInitialized() UpdateMainUi() End Sub 'hallo @@ -109,7 +112,8 @@ Public Class DocumentViewer _licenseKey = pLicenseKey _licenseManager.RegisterKEY(_licenseKey) _Annotations = New Annotations(pLogConfig) - _Search = New Search(pLogConfig, GdViewer) + ' Defer creating Search until GdViewer is ready + EnsureSearchInitialized() _ToolbarSettings = pToolbarSettings Dim oConfigPath = ConfigPath() @@ -121,6 +125,17 @@ Public Class DocumentViewer End Try End Function + ' Create the Search helper only when both the log config and the GdViewer control exist + Private Sub EnsureSearchInitialized() + Try + If _Search Is Nothing AndAlso _logConfig IsNot Nothing AndAlso GdViewer IsNot Nothing Then + _Search = New Search(_logConfig, GdViewer) + End If + Catch ex As Exception + _logger?.Error(ex) + End Try + End Sub + ''' ''' Load a file from a path and display it ''' @@ -141,9 +156,8 @@ Public Class DocumentViewer _FileInfo = New FileInfo(FilePath) _logger.Info("Loading file [{0}] from Filesystem", FilePath) - FileLoaded = DoLoadFile(FilePath) - SetViewerMode(_FileInfo.Extension) + FileLoaded = DoLoadFile(FilePath) UpdateMainUi() End Sub @@ -223,7 +237,17 @@ Public Class DocumentViewer Public Sub CloseDocument() Try - GdViewer.CloseDocument() + ' Null-sicher schließen + If GdViewer IsNot Nothing Then + Try + GdViewer.CloseDocument() + Catch exInner As Exception + _logger?.Warn("Fehler beim Schließen von GdViewer") + _logger?.Error(exInner) + End Try + Else + _logger?.Debug("CloseDocument: GdViewer ist Nothing – nichts zu schließen") + End If _FileInfo = Nothing _FilePath = Nothing @@ -299,25 +323,23 @@ Public Class DocumentViewer GdViewer.Focus() UpdateMainUi() End Sub - Private Sub btnFirstPage_Click(ByVal sender As System.Object, ByVal e As EventArgs) Handles buttonFirstPage.ItemClick + Private Sub BtnFirstPage_Click(ByVal sender As System.Object, ByVal e As EventArgs) Handles buttonFirstPage.ItemClick GdViewer.DisplayFirstPage() End Sub - Private Sub btnPreviousPage_Click(ByVal sender As System.Object, ByVal e As EventArgs) Handles buttonPrevPage.ItemClick - _ViewerMode = ViewerMode.GDPicture + Private Sub BtnPreviousPage_Click(ByVal sender As System.Object, ByVal e As EventArgs) Handles buttonPrevPage.ItemClick GdViewer.DisplayPreviousPage() End Sub - Private Sub btnNextPage_Click(ByVal sender As System.Object, ByVal e As EventArgs) Handles buttonNextPage.ItemClick - _ViewerMode = ViewerMode.GDPicture + Private Sub BtnNextPage_Click(ByVal sender As System.Object, ByVal e As EventArgs) Handles buttonNextPage.ItemClick GdViewer.DisplayNextPage() End Sub - Private Sub btnLastPage_Click(ByVal sender As System.Object, ByVal e As EventArgs) Handles buttonLastPage.ItemClick + Private Sub BtnLastPage_Click(ByVal sender As System.Object, ByVal e As EventArgs) Handles buttonLastPage.ItemClick GdViewer.DisplayLastPage() End Sub - Private Sub tbCurrentPage_Leave(ByVal sender As System.Object, ByVal e As EventArgs) Handles txtCurrentPage.EditValueChanged + Private Sub TbCurrentPage_Leave(ByVal sender As System.Object, ByVal e As EventArgs) Handles txtCurrentPage.EditValueChanged Dim page As Integer = 0 If Integer.TryParse(txtCurrentPage.EditValue, page) Then If page > 0 And page <= GdViewer.PageCount Then @@ -339,12 +361,10 @@ Public Class DocumentViewer End Sub Private Sub btnZoomOut_Click(sender As Object, e As EventArgs) Handles buttonZoomOut.ItemClick - _ViewerMode = ViewerMode.GDPicture GdViewer.ZoomOUT() End Sub Private Sub btnZoomIn_Click(sender As Object, e As EventArgs) Handles buttonZoomIn.ItemClick - _ViewerMode = ViewerMode.GDPicture GdViewer.ZoomIN() End Sub @@ -356,11 +376,11 @@ Public Class DocumentViewer GdViewer.PrintDialog() End Sub - Private Sub btnRotateLeft_Click(sender As Object, e As EventArgs) Handles buttonRotateLeft.ItemClick + Private Sub BtnRotateLeft_Click(sender As Object, e As EventArgs) Handles buttonRotateLeft.ItemClick GdViewer.Rotate(RotateFlipType.Rotate270FlipNone) End Sub - Private Sub btnRotateRight_Click(sender As Object, e As EventArgs) Handles buttonRotateRight.ItemClick + Private Sub BtnRotateRight_Click(sender As Object, e As EventArgs) Handles buttonRotateRight.ItemClick GdViewer.Rotate(RotateFlipType.Rotate90FlipNone) End Sub @@ -385,7 +405,7 @@ Public Class DocumentViewer End If End Sub - Private Sub btnSettings_Click(ByVal sender As Object, ByVal e As EventArgs) Handles buttonSettings.ItemClick + Private Sub BtnSettings_Click(ByVal sender As Object, ByVal e As EventArgs) Handles buttonSettings.ItemClick Using frmSettings As New frmViewerSettings(GdViewer) frmSettings.ShowDialog(Me) End Using @@ -439,14 +459,18 @@ Public Class DocumentViewer End Sub Private Sub SetViewerMode(Extension As String) - Select Case Extension.ToUpper - Case "CSV" - _ViewerMode = ViewerMode.Excel - Case ".EML", ".DOC", ".DOCX", ".ODT", ".RTF", ".TXT" - _ViewerMode = ViewerMode.RichText - Case Else - _ViewerMode = ViewerMode.GDPicture - End Select + If _ViewOverride = "Richtext" Then + _ViewerMode = ViewerMode.Richtext + Else + Select Case Extension.ToUpper + Case "CSV" + _ViewerMode = ViewerMode.Excel + 'Case ".EML", ".DOC", ".DOCX", ".ODT", ".RTF", ".TXT" + ' _ViewerMode = ViewerMode.RichText + Case Else + _ViewerMode = ViewerMode.GDPicture + End Select + End If End Sub Private Sub FreeFile() Try @@ -574,6 +598,12 @@ Public Class DocumentViewer End Function Private Function DoLoadFile(FilePath As String) As Boolean Try + ' Ensure the embedded GdViewer control exists before using it + If Not EnsureViewerReady() Then + _logger?.Warn("GdViewer control is not initialized yet. Delaying load.") + Return False + End If + lblInfo.Visible = False Dim oFileInfo = New FileInfo(FilePath) Dim oExtension As String = oFileInfo.Extension.ToUpper @@ -599,46 +629,54 @@ Public Class DocumentViewer Dim oRange = SpreadsheetControl1.ActiveWorksheet.GetUsedRange() oRange.AutoFitColumns() - SpreadsheetControl1.Visible = True - GdViewer.Visible = False - SpreadsheetControl1.Dock = DockStyle.Fill - Else - Select Case oExtension.ToUpper - Case ".CSV" - Dim oFormat = GetSpreadsheetFormat(oExtension) - SpreadsheetControl1.LoadDocument(FilePath, oFormat) + If ViewOverride = "Richtext" Then + RichEditControl1.LoadDocument(FilePath, GetDocumentFormat(oExtension)) + RichEditControl1.Visible = True + GdViewer.Visible = False + RichEditControl1.Dock = DockStyle.Fill + _ViewOverride = "Richtext" + _ViewerMode = ViewerMode.Richtext + lblInfo.Visible = True + lblInfo.Text = "This docx-file contains a generic error and will be displayed in a reduced viewer. Please try to open the file in WORD" + Else + _ViewOverride = "" + Select Case oExtension.ToUpper + Case ".CSV" + Dim oFormat = GetSpreadsheetFormat(oExtension) + SpreadsheetControl1.LoadDocument(FilePath, oFormat) - Dim oRange = SpreadsheetControl1.ActiveWorksheet.GetUsedRange() + Dim oRange = SpreadsheetControl1.ActiveWorksheet.GetUsedRange() oRange.AutoFitColumns() SpreadsheetControl1.Visible = True GdViewer.Visible = False SpreadsheetControl1.Dock = DockStyle.Fill - Case ".EML", ".DOC", ".DOCX", ".ODT", ".RTF", ".TXT" - RichEditControl1.LoadDocument(FilePath, GetDocumentFormat(oExtension)) - - RichEditControl1.Visible = True - GdViewer.Visible = False - RichEditControl1.Dock = DockStyle.Fill - Case Else + Case ".EML", ".DOC", ".DOCX", ".ODT", ".RTF", ".TXT" + RichEditControl1.LoadDocument(FilePath, GetDocumentFormat(oExtension)) + RichEditControl1.Visible = True + GdViewer.Visible = False + RichEditControl1.Dock = DockStyle.Fill + Case Else GdViewer.ZoomMode = ViewerZoomMode.ZoomModeWidthViewer GdViewer.DocumentAlignment = ViewerDocumentAlignment.DocumentAlignmentTopCenter - If Viewer_ForceTemporaryMode = True Then - GdViewer.ForceTemporaryMode = True - End If + GdViewer.ForceTemporaryMode = True + GdViewer.DocumentAlignment = ViewerDocumentAlignment.DocumentAlignmentTopCenter + If Viewer_ForceTemporaryMode = True Then + GdViewer.ForceTemporaryMode = True + End If - GdViewer.AnnotationDropShadow = True - GdViewer.BackColor = Color.White + GdViewer.AnnotationDropShadow = True + GdViewer.BackColor = Color.White - Dim oGDPState As GdPicture14.GdPictureStatus = GdViewer.DisplayFromFile(FilePath) - If oGDPState <> GdPictureStatus.OK Then - _logger.Warn($"GdPictureStatus is [{oGDPState}]") - If oExtension.ToUpper = ".DOCX" And oGDPState = GdPictureStatus.GenericError Then - DoLoadFile(FilePath, "Richtext") - Else - Dim oFileName = IO.Path.GetFileName(FilePath) - lbFileNotLoaded.Text = String.Format("Datei konnte nicht geladen werden:{0}{1}", vbCrLf, oFileName) + Dim oGDPState As GdPicture14.GdPictureStatus = GdViewer.DisplayFromFile(FilePath) + If oGDPState <> GdPictureStatus.OK Then + _logger.Warn($"GdPictureStatus is [{oGDPState}]") + If oExtension.ToUpper = ".DOCX" And oGDPState = GdPictureStatus.GenericError Then + DoLoadFile(FilePath, "Richtext") + Else + Dim oFileName = IO.Path.GetFileName(FilePath) + lbFileNotLoaded.Text = String.Format("Datei konnte nicht geladen werden:{0}{1}", vbCrLf, oFileName) lbFileNotLoaded.Visible = True End If @@ -649,29 +687,60 @@ Public Class DocumentViewer End If End Select - End If - UpdateMainUi() - - Return True + Return True Catch ex As Exception _logger.Error(ex) Return False End Try End Function + ' Ensures the embedded GdViewer control exists and is added to the visual tree + Private Function EnsureViewerReady() As Boolean + Try + ' If the control field is Nothing (e.g., designer not yet created), try to lazy-create and add it + If GdViewer Is Nothing Then + Private Function EnsureViewerReady() As Boolean + Try + ' If the control field is Nothing (e.g., designer not yet created), try to lazy-create and add it + If GdViewer Is Nothing Then + ' Attempt to find an existing instance by name in Controls collection + Dim existing = Me.Controls.OfType(Of GdPicture14.GdViewer)().FirstOrDefault() + If existing IsNot Nothing Then + ' Assign the designer field via reflection if needed, otherwise use it directly + GdViewer = existing + Else + ' Last resort: create a new viewer and add it + Dim viewer = New GdPicture14.GdViewer() + viewer.Dock = DockStyle.Fill + Me.Controls.Add(viewer) + GdViewer = viewer + End If + End If + + Return GdViewer IsNot Nothing + Catch ex As Exception + _logger?.Error(ex) + Return False + End Try + End Function + Private Sub FitToPage() - _ViewerMode = ViewerMode.GDPicture - GdViewer.ZoomMode = ViewerZoomMode.ZoomModeFitToViewer + If Not GdViewer Is Nothing Then + GdViewer.ZoomMode = ViewerZoomMode.ZoomModeFitToViewer + End If End Sub Private Sub FitToWidth() - _ViewerMode = ViewerMode.GDPicture - GdViewer.ZoomMode = ViewerZoomMode.ZoomModeWidthViewer + If Not GdViewer Is Nothing Then + GdViewer.ZoomMode = ViewerZoomMode.ZoomModeWidthViewer + End If + End Sub Private Function DoLoadFile(Stream As Stream, Extension As String) As Boolean + Try SpreadsheetControl1.Visible = False @@ -691,7 +760,9 @@ Public Class DocumentViewer Case Else GdViewer.ZoomMode = ViewerZoomMode.ZoomModeWidthViewer GdViewer.DocumentAlignment = ViewerDocumentAlignment.DocumentAlignmentTopCenter - GdViewer.ForceTemporaryMode = True + If Viewer_ForceTemporaryMode = True Then + GdViewer.ForceTemporaryMode = True + End If GdViewer.AnnotationDropShadow = True GdViewer.DisplayFromStream(Stream) @@ -838,25 +909,27 @@ Public Class DocumentViewer btnSearch2.Visibility = ToVisibility(False) btnNextHighlight.Visibility = ToVisibility(False) btnPrevHighlight.Visibility = ToVisibility(False) - - - + Case Else + ToolbarDocumentViewer.Visible = False End Select End Sub Private Sub btnSearch2_ItemClick(sender As Object, e As XtraBars.ItemClickEventArgs) Handles btnSearch2.ItemClick - If Not String.IsNullOrEmpty(txtSearch.EditValue) Then + EnsureSearchInitialized() + If _Search IsNot Nothing AndAlso Not String.IsNullOrEmpty(txtSearch.EditValue) Then _Search.SearchAll(txtSearch.EditValue?.ToString) End If End Sub Private Sub btnPrevHighlight_ItemClick(sender As Object, e As XtraBars.ItemClickEventArgs) Handles btnPrevHighlight.ItemClick - _Search.PrevHighlight() + EnsureSearchInitialized() + _Search?.PrevHighlight() End Sub Private Sub btnNextHighlight_ItemClick(sender As Object, e As XtraBars.ItemClickEventArgs) Handles btnNextHighlight.ItemClick - _Search.NextHighlight() + EnsureSearchInitialized() + _Search?.NextHighlight() End Sub Private Sub txtSearch_EditValueChanged(sender As Object, e As EventArgs) Handles txtSearch.EditValueChanged diff --git a/Controls.DocumentViewer/DocumentViewer.vbproj b/Controls.DocumentViewer/DocumentViewer.vbproj index 3b46b062..e0494014 100644 --- a/Controls.DocumentViewer/DocumentViewer.vbproj +++ b/Controls.DocumentViewer/DocumentViewer.vbproj @@ -160,15 +160,9 @@ ..\packages\GdPicture.14.3.3\lib\net462\GdPicture.NET.14.wia.gateway.dll True - - ..\packages\IndexRange.1.0.3\lib\net45\IndexRange.dll - ..\packages\Microsoft.Bcl.AsyncInterfaces.8.0.0\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll - - ..\packages\Microsoft.Bcl.HashCode.6.0.0\lib\net462\Microsoft.Bcl.HashCode.dll - ..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll @@ -179,8 +173,8 @@ ..\packages\NLog.5.0.5\lib\net46\NLog.dll - - ..\packages\OpenMcdf.3.0.0\lib\netstandard2.0\OpenMcdf.dll + + ..\packages\OpenMcdf.2.4.1\lib\net40\OpenMcdf.dll @@ -234,8 +228,8 @@ ..\packages\System.Text.Encodings.Web.8.0.0\lib\net462\System.Text.Encodings.Web.dll - - ..\packages\System.Text.Json.8.0.5\lib\net462\System.Text.Json.dll + + ..\packages\System.Text.Json.8.0.6\lib\net462\System.Text.Json.dll ..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll diff --git a/Controls.DocumentViewer/My Project/AssemblyInfo.vb b/Controls.DocumentViewer/My Project/AssemblyInfo.vb index 549bd01d..3d6979a4 100644 --- a/Controls.DocumentViewer/My Project/AssemblyInfo.vb +++ b/Controls.DocumentViewer/My Project/AssemblyInfo.vb @@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices ' übernehmen, indem Sie "*" eingeben: ' - - + + diff --git a/Controls.DocumentViewer/packages.config b/Controls.DocumentViewer/packages.config index 9ac55089..18dc42d5 100644 --- a/Controls.DocumentViewer/packages.config +++ b/Controls.DocumentViewer/packages.config @@ -5,16 +5,14 @@ - - - + @@ -28,7 +26,7 @@ - + \ No newline at end of file diff --git a/GDPicture_NewPDF_net48.zip b/GDPicture_NewPDF_net48.zip new file mode 100644 index 00000000..d23925f2 Binary files /dev/null and b/GDPicture_NewPDF_net48.zip differ diff --git a/GDPicture_NewPDF_net48/App.config b/GDPicture_NewPDF_net48/App.config new file mode 100644 index 00000000..48a52e0d --- /dev/null +++ b/GDPicture_NewPDF_net48/App.config @@ -0,0 +1,156 @@ + + + + +
+ + +
+ + + + + + + + + 172.24.12.50:E:\DataFiles\Firebird\WISAG\EDMI_MASTER.FDB + + + 172.24.12.50 + + + + + + + sysdba + + + dd + + + + + + Server=SDD-VMP04-SQL17\DD_DEVELOP01;Database=DD_ECM;User Id=sa;Password=dd + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/GDPicture_NewPDF_net48/Form1.Designer.vb b/GDPicture_NewPDF_net48/Form1.Designer.vb new file mode 100644 index 00000000..ade5aebf --- /dev/null +++ b/GDPicture_NewPDF_net48/Form1.Designer.vb @@ -0,0 +1,65 @@ + +Partial Class Form1 + Inherits System.Windows.Forms.Form + + 'Das Formular überschreibt den Löschvorgang, um die Komponentenliste zu bereinigen. + + Protected Overrides Sub Dispose(ByVal disposing As Boolean) + Try + If disposing AndAlso components IsNot Nothing Then + components.Dispose() + End If + Finally + MyBase.Dispose(disposing) + End Try + End Sub + + 'Wird vom Windows Form-Designer benötigt. + Private components As System.ComponentModel.IContainer + + 'Hinweis: Die folgende Prozedur ist für den Windows Form-Designer erforderlich. + 'Das Bearbeiten ist mit dem Windows Form-Designer möglich. + 'Das Bearbeiten mit dem Code-Editor ist nicht möglich. + + Private Sub InitializeComponent() + Me.OpenFileDialog1 = New System.Windows.Forms.OpenFileDialog() + Me.FolderBrowserDialog1 = New System.Windows.Forms.FolderBrowserDialog() + Me.OpenFileDialog2 = New System.Windows.Forms.OpenFileDialog() + Me.Button1 = New System.Windows.Forms.Button() + Me.SuspendLayout() + ' + 'OpenFileDialog1 + ' + Me.OpenFileDialog1.FileName = "OpenFileDialog1" + ' + 'OpenFileDialog2 + ' + Me.OpenFileDialog2.FileName = "OpenFileDialog2" + Me.OpenFileDialog2.Filter = "XML files (*.xml)|*.xml" + ' + 'Button1 + ' + Me.Button1.Location = New System.Drawing.Point(30, 43) + Me.Button1.Name = "Button1" + Me.Button1.Size = New System.Drawing.Size(75, 64) + Me.Button1.TabIndex = 13 + Me.Button1.Text = "Create GDPicture" + Me.Button1.UseVisualStyleBackColor = True + ' + 'Form1 + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.ClientSize = New System.Drawing.Size(344, 152) + Me.Controls.Add(Me.Button1) + Me.Name = "Form1" + Me.Text = "E-Invoice-TEST-Tool" + Me.ResumeLayout(False) + + End Sub + + Friend WithEvents OpenFileDialog1 As OpenFileDialog + Friend WithEvents FolderBrowserDialog1 As FolderBrowserDialog + Friend WithEvents OpenFileDialog2 As OpenFileDialog + Friend WithEvents Button1 As Button +End Class diff --git a/GDPicture_NewPDF_net48/Form1.resx b/GDPicture_NewPDF_net48/Form1.resx new file mode 100644 index 00000000..e47e59bf --- /dev/null +++ b/GDPicture_NewPDF_net48/Form1.resx @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + + 159, 17 + + + 328, 17 + + \ No newline at end of file diff --git a/GDPicture_NewPDF_net48/Form1.vb b/GDPicture_NewPDF_net48/Form1.vb new file mode 100644 index 00000000..434d15dc --- /dev/null +++ b/GDPicture_NewPDF_net48/Form1.vb @@ -0,0 +1,31 @@ +Imports System.IO + +Imports System.Security.Cryptography +Imports GdPicture14 + + +Public Class Form1 + Private _GDPictureLizenz As String + + + Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load + + _GDPictureLizenz = "kG1Qf9PwmqgR8aDmIW2zI_ebj48RzqAJegRxcystEmkbTGQqfkNBdFOXIb6C_A00Ra8zZkrHdfjqzOPXK7kgkF2YDhvrqKfqh4WDug2vOt0qO31IommzkANSuLjZ4zmraoubyEVd25rE3veQ2h_j7tGIoH_LyIHmy24GaXsxdG0yCzIBMdiLbMMMDwcPY-809KeZ83Grv76OVhFvcbBWyYc251vou1N-kGg5_ZlHDgfWoY85gTLRxafjD3KS_i9ARW4BMiy36y8n7UP2jN8kGRnW_04ubpFtfjJqvtsrP_J9D0x7bqV8xtVtT5JI6dpKsVTiMgDCrIcoFSo5gCC1fw9oUopX4TDCkBQttO4-WHBlOeq9dG5Yb0otonVmJKaQA2tP6sMR-lZDs3ql_WI9t91yPWgpssrJUxSHDd27_LMTH_owJIqkF3NOJd9mYQuAv22oNKFYbH8e41pVKb8cT33Y9CgcQ_sy6YDA5PTuIRi67mjKge_nD9rd0IN213Ir9M_EFWqg9e4haWzIdHXQUo0md70kVhPX4UIH_BKJnxEEnFfoFRNMh77bB0N4jkcBEHPl-ghOERv8dOztf4vCnNpzzWvcLD2cqWIm6THy8XGGq9h4hp8aEreRleSMwv9QQAC7mjLwhQ1rBYkpUHlpTjhTLnMwHknl6HH0Z6zzmsgkRKVyfquv94Pd7QbQfZrRka0ss_48pf9p8hAywEn81Q==" + + End Sub + + Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click + Dim LicenseManager = New LicenseManager() + LicenseManager.RegisterKEY(_GDPictureLizenz) + Using gdpicturePDF As New GdPicturePDF + ' Create a new PDF/A-2a compliant document (blank, no pages yet) + Dim status As GdPictureStatus = gdpicturePDF.NewPDF(PdfConformance.PDF_A_2a) + If status = GdPictureStatus.OK Then + MsgBox("Status is OK") + Else + MsgBox($"The NewPDF(PdfConformance.PDF_A_2a) method has failed + with the status: {status.ToString()}", MsgBoxStyle.Critical) + End If + End Using + End Sub +End Class diff --git a/GDPicture_NewPDF_net48/GDPicture_NewPDF_net48.sln b/GDPicture_NewPDF_net48/GDPicture_NewPDF_net48.sln new file mode 100644 index 00000000..507b5eee --- /dev/null +++ b/GDPicture_NewPDF_net48/GDPicture_NewPDF_net48.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.14.36310.24 d17.14 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "GDPicture_NewPDF_net48", "GDPicture_NewPDF_net48.vbproj", "{16156434-E471-43F1-8030-76A0DA17CD5A}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {16156434-E471-43F1-8030-76A0DA17CD5A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {16156434-E471-43F1-8030-76A0DA17CD5A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {16156434-E471-43F1-8030-76A0DA17CD5A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {16156434-E471-43F1-8030-76A0DA17CD5A}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {7FB9D072-A417-47E9-ACA3-99FC76D948C3} + EndGlobalSection +EndGlobal diff --git a/GDPicture_NewPDF_net48/GDPicture_NewPDF_net48.vbproj b/GDPicture_NewPDF_net48/GDPicture_NewPDF_net48.vbproj new file mode 100644 index 00000000..60f96ab6 --- /dev/null +++ b/GDPicture_NewPDF_net48/GDPicture_NewPDF_net48.vbproj @@ -0,0 +1,269 @@ + + + + + Debug + AnyCPU + {16156434-E471-43F1-8030-76A0DA17CD5A} + WinExe + ZUGFeRDTest.My.MyApplication + ZUGFeRDTest + ZUGFeRDTest + 512 + WindowsForms + v4.8 + true + + + + + + AnyCPU + true + full + true + true + bin\Debug\ + ZUGFeRDTest.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + AnyCPU + pdbonly + false + true + true + bin\Release\ + ZUGFeRDTest.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + On + + + Binary + + + Off + + + On + + + + ..\packages\DocumentFormat.OpenXml.3.2.0\lib\net46\DocumentFormat.OpenXml.dll + + + ..\packages\DocumentFormat.OpenXml.Framework.3.2.0\lib\net46\DocumentFormat.OpenXml.Framework.dll + + + ..\packages\GdPicture.14.3.14\lib\net462\GdPicture.NET.14.dll + + + ..\packages\GdPicture.14.3.14\lib\net462\GdPicture.NET.14.barcode.1d.writer.dll + + + ..\packages\GdPicture.14.3.14\lib\net462\GdPicture.NET.14.barcode.2d.writer.dll + + + ..\packages\GdPicture.14.3.14\lib\net462\GdPicture.NET.14.CAD.dll + + + ..\packages\GdPicture.14.3.14\lib\net462\GdPicture.NET.14.CAD.DWG.dll + + + ..\packages\GdPicture.14.3.14\lib\net462\GdPicture.NET.14.Common.dll + + + ..\packages\GdPicture.14.3.14\lib\net462\GdPicture.NET.14.Document.dll + + + ..\packages\GdPicture.14.3.14\lib\net462\GdPicture.NET.14.Email.dll + + + ..\packages\GdPicture.14.3.14\lib\net462\GdPicture.NET.14.HTML.dll + + + ..\packages\GdPicture.14.3.14\lib\net462\GdPicture.NET.14.Imaging.dll + + + ..\packages\GdPicture.14.3.14\lib\net462\GdPicture.NET.14.Imaging.Formats.dll + + + ..\packages\GdPicture.14.3.14\lib\net462\GdPicture.NET.14.Imaging.Formats.Conversion.dll + + + ..\packages\GdPicture.14.3.14\lib\net462\GdPicture.NET.14.Imaging.Rendering.dll + + + ..\packages\GdPicture.14.3.14\lib\net462\GdPicture.NET.14.MSOfficeBinary.dll + + + ..\packages\GdPicture.14.3.14\lib\net462\GdPicture.NET.14.OpenDocument.dll + + + ..\packages\GdPicture.14.3.14\lib\net462\GdPicture.NET.14.OpenXML.dll + + + ..\packages\GdPicture.14.3.14\lib\net462\GdPicture.NET.14.OpenXML.Templating.dll + + + ..\packages\GdPicture.14.3.14\lib\net462\GdPicture.NET.14.PDF.dll + + + ..\packages\GdPicture.14.3.14\lib\net462\GdPicture.NET.14.RTF.dll + + + ..\packages\GdPicture.14.3.14\lib\net462\GdPicture.NET.14.SVG.dll + + + ..\packages\GdPicture.14.3.14\lib\net462\GdPicture.NET.14.wia.gateway.dll + True + + + + ..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll + + + ..\packages\Newtonsoft.Json.Bson.1.0.2\lib\net45\Newtonsoft.Json.Bson.dll + + + ..\packages\OpenMcdf.2.4.1\lib\net40\OpenMcdf.dll + + + ..\packages\protobuf-net.3.2.46\lib\net462\protobuf-net.dll + + + ..\packages\protobuf-net.Core.3.2.46\lib\net462\protobuf-net.Core.dll + + + ..\packages\RtfPipe.2.0.7677.4303\lib\net45\RtfPipe.dll + + + + ..\packages\System.Buffers.4.6.0\lib\net462\System.Buffers.dll + + + ..\packages\System.CodeDom.8.0.0\lib\net462\System.CodeDom.dll + + + ..\packages\System.Collections.Immutable.8.0.0\lib\net462\System.Collections.Immutable.dll + + + + + + + ..\packages\System.IO.Packaging.8.0.1\lib\net462\System.IO.Packaging.dll + + + + ..\packages\System.Memory.4.6.0\lib\net462\System.Memory.dll + + + ..\packages\Microsoft.AspNet.WebApi.Client.6.0.0\lib\net45\System.Net.Http.Formatting.dll + + + + ..\packages\System.Numerics.Vectors.4.6.0\lib\net462\System.Numerics.Vectors.dll + + + ..\packages\System.Runtime.CompilerServices.Unsafe.6.1.0\lib\net462\System.Runtime.CompilerServices.Unsafe.dll + + + + + ..\packages\System.Security.Cryptography.Pkcs.8.0.1\lib\net462\System.Security.Cryptography.Pkcs.dll + + + + ..\packages\System.Text.Encodings.Web.8.0.0\lib\net462\System.Text.Encodings.Web.dll + + + ..\packages\System.Text.Json.8.0.5\lib\net462\System.Text.Json.dll + + + ..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll + + + + + + + + + + + + + + + + + + + + + + + + + + Form + + + Form1.vb + Form + + + + True + Application.myapp + True + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + Form1.vb + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + + + MyApplicationCodeGenerator + Application.Designer.vb + + + SettingsSingleFileGenerator + My + Settings.Designer.vb + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + + \ No newline at end of file diff --git a/GDPicture_NewPDF_net48/My Project/Application.Designer.vb b/GDPicture_NewPDF_net48/My Project/Application.Designer.vb new file mode 100644 index 00000000..f602fad3 --- /dev/null +++ b/GDPicture_NewPDF_net48/My Project/Application.Designer.vb @@ -0,0 +1,44 @@ +'------------------------------------------------------------------------------ +' +' Dieser Code wurde von einem Tool generiert. +' Laufzeitversion:4.0.30319.42000 +' +' Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn +' der Code erneut generiert wird. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My + + 'HINWEIS: Diese Datei wird automatisch generiert und darf nicht direkt bearbeitet werden. Wenn Sie Änderungen vornehmen möchten + ' oder in dieser Datei Buildfehler auftreten, wechseln Sie zum Projekt-Designer. + ' (Wechseln Sie dazu zu den Projekteigenschaften, oder doppelklicken Sie auf den Knoten "Mein Projekt" im + ' Projektmappen-Explorer). Nehmen Sie auf der Registerkarte "Anwendung" entsprechende Änderungen vor. + ' + Partial Friend Class MyApplication + + _ + Public Sub New() + MyBase.New(Global.Microsoft.VisualBasic.ApplicationServices.AuthenticationMode.Windows) + Me.IsSingleInstance = false + Me.EnableVisualStyles = true + Me.SaveMySettingsOnExit = true + Me.ShutDownStyle = Global.Microsoft.VisualBasic.ApplicationServices.ShutdownMode.AfterMainFormCloses + End Sub + + _ + Protected Overrides Sub OnCreateMainForm() + Me.MainForm = Global.ZUGFeRDTest.Form1 + End Sub + + _ + Protected Overrides Function OnInitialize(ByVal commandLineArgs As System.Collections.ObjectModel.ReadOnlyCollection(Of String)) As Boolean + Me.MinimumSplashScreenDisplayTime = 0 + Return MyBase.OnInitialize(commandLineArgs) + End Function + End Class +End Namespace diff --git a/GDPicture_NewPDF_net48/My Project/Application.myapp b/GDPicture_NewPDF_net48/My Project/Application.myapp new file mode 100644 index 00000000..1243847f --- /dev/null +++ b/GDPicture_NewPDF_net48/My Project/Application.myapp @@ -0,0 +1,11 @@ + + + true + Form1 + false + 0 + true + 0 + 0 + true + diff --git a/GDPicture_NewPDF_net48/My Project/AssemblyInfo.vb b/GDPicture_NewPDF_net48/My Project/AssemblyInfo.vb new file mode 100644 index 00000000..bb5dd90b --- /dev/null +++ b/GDPicture_NewPDF_net48/My Project/AssemblyInfo.vb @@ -0,0 +1,35 @@ +Imports System +Imports System.Reflection +Imports System.Runtime.InteropServices + +' Allgemeine Informationen über eine Assembly werden über die folgenden +' Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern, +' die einer Assembly zugeordnet sind. + +' Werte der Assemblyattribute überprüfen + + + + + + + + + + +'Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird. + + +' Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten: +' +' Hauptversion +' Nebenversion +' Buildnummer +' Revision +' +' Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden, +' übernehmen, indem Sie "*" eingeben: +' + + + diff --git a/GDPicture_NewPDF_net48/My Project/Resources.Designer.vb b/GDPicture_NewPDF_net48/My Project/Resources.Designer.vb new file mode 100644 index 00000000..86b9648a --- /dev/null +++ b/GDPicture_NewPDF_net48/My Project/Resources.Designer.vb @@ -0,0 +1,63 @@ +'------------------------------------------------------------------------------ +' +' Dieser Code wurde von einem Tool generiert. +' Laufzeitversion:4.0.30319.42000 +' +' Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn +' der Code erneut generiert wird. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + +Imports System + +Namespace My.Resources + + 'Diese Klasse wurde von der StronglyTypedResourceBuilder automatisch generiert + '-Klasse über ein Tool wie ResGen oder Visual Studio automatisch generiert. + 'Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen + 'mit der /str-Option erneut aus, oder Sie erstellen Ihr VS-Projekt neu. + ''' + ''' Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw. + ''' + _ + Friend Module Resources + + Private resourceMan As Global.System.Resources.ResourceManager + + Private resourceCulture As Global.System.Globalization.CultureInfo + + ''' + ''' Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird. + ''' + _ + Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager + Get + If Object.ReferenceEquals(resourceMan, Nothing) Then + Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("ZUGFeRDTest.Resources", GetType(Resources).Assembly) + resourceMan = temp + End If + Return resourceMan + End Get + End Property + + ''' + ''' Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle + ''' Ressourcenzuordnungen, die diese stark typisierte Ressourcenklasse verwenden. + ''' + _ + Friend Property Culture() As Global.System.Globalization.CultureInfo + Get + Return resourceCulture + End Get + Set + resourceCulture = value + End Set + End Property + End Module +End Namespace diff --git a/GDPicture_NewPDF_net48/My Project/Resources.resx b/GDPicture_NewPDF_net48/My Project/Resources.resx new file mode 100644 index 00000000..af7dbebb --- /dev/null +++ b/GDPicture_NewPDF_net48/My Project/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/GDPicture_NewPDF_net48/My Project/Settings.Designer.vb b/GDPicture_NewPDF_net48/My Project/Settings.Designer.vb new file mode 100644 index 00000000..1cba3fe1 --- /dev/null +++ b/GDPicture_NewPDF_net48/My Project/Settings.Designer.vb @@ -0,0 +1,139 @@ +'------------------------------------------------------------------------------ +' +' Dieser Code wurde von einem Tool generiert. +' Laufzeitversion:4.0.30319.42000 +' +' Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn +' der Code erneut generiert wird. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My + + _ + Partial Friend NotInheritable Class MySettings + Inherits Global.System.Configuration.ApplicationSettingsBase + + Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings()),MySettings) + +#Region "Automatische My.Settings-Speicherfunktion" +#If _MyType = "WindowsForms" Then + Private Shared addedHandler As Boolean + + Private Shared addedHandlerLockObject As New Object + + _ + Private Shared Sub AutoSaveSettings(sender As Global.System.Object, e As Global.System.EventArgs) + If My.Application.SaveMySettingsOnExit Then + My.Settings.Save() + End If + End Sub +#End If +#End Region + + Public Shared ReadOnly Property [Default]() As MySettings + Get + +#If _MyType = "WindowsForms" Then + If Not addedHandler Then + SyncLock addedHandlerLockObject + If Not addedHandler Then + AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings + addedHandler = True + End If + End SyncLock + End If +#End If + Return defaultInstance + End Get + End Property + + _ + Public ReadOnly Property FB_DATABASE() As String + Get + Return CType(Me("FB_DATABASE"),String) + End Get + End Property + + _ + Public ReadOnly Property FB_DATASOURCE() As String + Get + Return CType(Me("FB_DATASOURCE"),String) + End Get + End Property + + _ + Public Property FB_USER() As String + Get + Return CType(Me("FB_USER"),String) + End Get + Set + Me("FB_USER") = value + End Set + End Property + + _ + Public Property FB_PASS() As String + Get + Return CType(Me("FB_PASS"),String) + End Get + Set + Me("FB_PASS") = value + End Set + End Property + + _ + Public Property MD5Cheksum() As String + Get + Return CType(Me("MD5Cheksum"),String) + End Get + Set + Me("MD5Cheksum") = value + End Set + End Property + + _ + Public Property MSSQL_CONNECTIONSTRING() As String + Get + Return CType(Me("MSSQL_CONNECTIONSTRING"),String) + End Get + Set + Me("MSSQL_CONNECTIONSTRING") = value + End Set + End Property + End Class +End Namespace + +Namespace My + + _ + Friend Module MySettingsProperty + + _ + Friend ReadOnly Property Settings() As Global.ZUGFeRDTest.My.MySettings + Get + Return Global.ZUGFeRDTest.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/GDPicture_NewPDF_net48/My Project/Settings.settings b/GDPicture_NewPDF_net48/My Project/Settings.settings new file mode 100644 index 00000000..4e788b7e --- /dev/null +++ b/GDPicture_NewPDF_net48/My Project/Settings.settings @@ -0,0 +1,24 @@ + + + + + + 172.24.12.50:E:\DataFiles\Firebird\WISAG\EDMI_MASTER.FDB + + + 172.24.12.50 + + + sysdba + + + dd + + + + + + Server=SDD-VMP04-SQL17\DD_DEVELOP01;Database=DD_ECM;User Id=sa;Password=dd + + + \ No newline at end of file diff --git a/GDPicture_NewPDF_net48/packages.config b/GDPicture_NewPDF_net48/packages.config new file mode 100644 index 00000000..1b23f530 --- /dev/null +++ b/GDPicture_NewPDF_net48/packages.config @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/GUIs.Test.TestGUI/MyApplication.vb b/GUIs.Test.TestGUI/MyApplication.vb new file mode 100644 index 00000000..68fe6785 --- /dev/null +++ b/GUIs.Test.TestGUI/MyApplication.vb @@ -0,0 +1,49 @@ +Imports DigitalData.Modules.Database +Imports DigitalData.Modules.EDMI.API +Imports DigitalData.Modules.EDMI.API.Modules +Imports DigitalData.Modules.Logging +Imports DigitalData.Modules.ZooFlow + +Namespace My + ''' + ''' Extends the My Namespace + ''' Example: My.LogConfig + ''' + + Module Extension + Property LogConfig As LogConfig +#Region "Database" + Property Database As DatabaseWithFallback + Property DatabaseECM As MSSQLServer + Property DatabaseIDB As MSSQLServer + End Module + +#End Region + Partial Friend Class MyApplication + Public Property Skin As String = "" + Public Property Palette As String = "" + Public Property GlobixDropAreaStyle As String = "PROGRESSIVE" + + Public Property Settings As New State.SettingsState + Public Property User As New State.UserState + Public Property Service As New State.ServiceState + Public Property Modules As New Dictionary(Of String, State.ModuleState) + Public Property ModulesActive As New List(Of String) + + + Public CommandLineFunction As String + Public CommandLineArguments As New Dictionary(Of String, String) + + Public Function GetEnvironment() As Environment + Return New Environment With { + .Database = My.DatabaseECM, + .DatabaseIDB = My.DatabaseIDB, + .Modules = My.Application.Modules, + .Service = My.Application.Service, + .Settings = My.Application.Settings, + .User = My.Application.User + } + End Function + + End Class +End Namespace \ No newline at end of file diff --git a/GUIs.Test.TestGUI/TestGUI.vbproj b/GUIs.Test.TestGUI/TestGUI.vbproj index a03ed34b..2b171b5d 100644 --- a/GUIs.Test.TestGUI/TestGUI.vbproj +++ b/GUIs.Test.TestGUI/TestGUI.vbproj @@ -93,6 +93,10 @@ ..\..\DDModules\Database\bin\Debug\DigitalData.Modules.Database.dll + + False + P:\Projekte DIGITAL DATA\DIGITAL DATA - Entwicklung\DLL_Bibliotheken\Digital Data\DD_Modules\DigitalData.Modules.EDMI.API.dll + ..\..\DDModules\Encryption\bin\Debug\DigitalData.Modules.Encryption.dll @@ -117,6 +121,10 @@ ..\..\DDModules\Windream\bin\Debug\DigitalData.Modules.Windream.dll + + False + ..\..\DDModules\ZooFlow\bin\Debug\DigitalData.Modules.ZooFlow.dll + ..\packages\DocumentFormat.OpenXml.3.2.0\lib\net46\DocumentFormat.OpenXml.dll @@ -406,6 +414,7 @@ Settings.settings True + @@ -487,10 +496,6 @@ {a8c3f298-76ab-4359-ab3c-986e313b4336} EDMIService - - {7deec36e-ea5f-4711-ad1e-fd8894f4ad77} - DDZUGFeRDService - diff --git a/GUIs.Test.TestGUI/frmFilesystem.Designer.vb b/GUIs.Test.TestGUI/frmFilesystem.Designer.vb index 7c530ea3..49790b0a 100644 --- a/GUIs.Test.TestGUI/frmFilesystem.Designer.vb +++ b/GUIs.Test.TestGUI/frmFilesystem.Designer.vb @@ -23,28 +23,141 @@ Partial Class frmFilesystem _ Private Sub InitializeComponent() Me.Button1 = New System.Windows.Forms.Button() + Me.Button2 = New System.Windows.Forms.Button() + Me.GroupBox1 = New System.Windows.Forms.GroupBox() + Me.Button3 = New System.Windows.Forms.Button() + Me.TextBox1 = New System.Windows.Forms.TextBox() + Me.SaveFileDialog1 = New System.Windows.Forms.SaveFileDialog() + Me.txtServiceAddress = New DevExpress.XtraEditors.TextEdit() + Me.Label1 = New System.Windows.Forms.Label() + Me.txtServicePort = New DevExpress.XtraEditors.TextEdit() + Me.Button4 = New System.Windows.Forms.Button() + Me.txtStatus = New System.Windows.Forms.TextBox() + Me.GroupBox1.SuspendLayout() + CType(Me.txtServiceAddress.Properties, System.ComponentModel.ISupportInitialize).BeginInit() + CType(Me.txtServicePort.Properties, System.ComponentModel.ISupportInitialize).BeginInit() Me.SuspendLayout() ' 'Button1 ' - Me.Button1.Location = New System.Drawing.Point(12, 12) + Me.Button1.Location = New System.Drawing.Point(59, 343) Me.Button1.Name = "Button1" - Me.Button1.Size = New System.Drawing.Size(75, 23) + Me.Button1.Size = New System.Drawing.Size(288, 23) Me.Button1.TabIndex = 0 - Me.Button1.Text = "Button1" + Me.Button1.Text = "CreateDateDirectory" Me.Button1.UseVisualStyleBackColor = True ' + 'Button2 + ' + Me.Button2.Location = New System.Drawing.Point(6, 71) + Me.Button2.Name = "Button2" + Me.Button2.Size = New System.Drawing.Size(288, 23) + Me.Button2.TabIndex = 1 + Me.Button2.Text = "Stream simple file" + Me.Button2.UseVisualStyleBackColor = True + ' + 'GroupBox1 + ' + Me.GroupBox1.Controls.Add(Me.Button3) + Me.GroupBox1.Controls.Add(Me.TextBox1) + Me.GroupBox1.Controls.Add(Me.Button2) + Me.GroupBox1.Location = New System.Drawing.Point(36, 153) + Me.GroupBox1.Name = "GroupBox1" + Me.GroupBox1.Size = New System.Drawing.Size(709, 157) + Me.GroupBox1.TabIndex = 2 + Me.GroupBox1.TabStop = False + Me.GroupBox1.Text = "Stream simple file" + ' + 'Button3 + ' + Me.Button3.Location = New System.Drawing.Point(6, 19) + Me.Button3.Name = "Button3" + Me.Button3.Size = New System.Drawing.Size(181, 23) + Me.Button3.TabIndex = 3 + Me.Button3.Text = "1. Choose file" + Me.Button3.UseVisualStyleBackColor = True + ' + 'TextBox1 + ' + Me.TextBox1.Location = New System.Drawing.Point(6, 45) + Me.TextBox1.Name = "TextBox1" + Me.TextBox1.Size = New System.Drawing.Size(669, 20) + Me.TextBox1.TabIndex = 2 + ' + 'txtServiceAddress + ' + Me.txtServiceAddress.Location = New System.Drawing.Point(36, 37) + Me.txtServiceAddress.Name = "txtServiceAddress" + Me.txtServiceAddress.Size = New System.Drawing.Size(485, 20) + Me.txtServiceAddress.TabIndex = 5 + ' + 'Label1 + ' + Me.Label1.AutoSize = True + Me.Label1.Location = New System.Drawing.Point(33, 21) + Me.Label1.Name = "Label1" + Me.Label1.Size = New System.Drawing.Size(81, 13) + Me.Label1.TabIndex = 6 + Me.Label1.Text = "ServiceAdresse" + ' + 'txtServicePort + ' + Me.txtServicePort.EditValue = New Decimal(New Integer() {9000, 0, 0, 0}) + Me.txtServicePort.Location = New System.Drawing.Point(36, 63) + Me.txtServicePort.Name = "txtServicePort" + Me.txtServicePort.Properties.EditValueChangedFiringMode = DevExpress.XtraEditors.Controls.EditValueChangedFiringMode.Buffered + Me.txtServicePort.Properties.MaskSettings.Set("MaskManagerType", GetType(DevExpress.Data.Mask.NumericMaskManager)) + Me.txtServicePort.Size = New System.Drawing.Size(485, 20) + Me.txtServicePort.TabIndex = 7 + ' + 'Button4 + ' + Me.Button4.Location = New System.Drawing.Point(36, 89) + Me.Button4.Name = "Button4" + Me.Button4.Size = New System.Drawing.Size(75, 23) + Me.Button4.TabIndex = 8 + Me.Button4.Text = "Connect" + Me.Button4.UseVisualStyleBackColor = True + ' + 'txtStatus + ' + Me.txtStatus.Location = New System.Drawing.Point(527, 37) + Me.txtStatus.Name = "txtStatus" + Me.txtStatus.Size = New System.Drawing.Size(100, 20) + Me.txtStatus.TabIndex = 9 + ' 'frmFilesystem ' 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.txtStatus) + Me.Controls.Add(Me.Button4) + Me.Controls.Add(Me.txtServicePort) + Me.Controls.Add(Me.Label1) + Me.Controls.Add(Me.txtServiceAddress) + Me.Controls.Add(Me.GroupBox1) Me.Controls.Add(Me.Button1) Me.Name = "frmFilesystem" Me.Text = "frmFilesystem" + Me.GroupBox1.ResumeLayout(False) + Me.GroupBox1.PerformLayout() + CType(Me.txtServiceAddress.Properties, System.ComponentModel.ISupportInitialize).EndInit() + CType(Me.txtServicePort.Properties, System.ComponentModel.ISupportInitialize).EndInit() Me.ResumeLayout(False) + Me.PerformLayout() End Sub Friend WithEvents Button1 As Button + Friend WithEvents Button2 As Button + Friend WithEvents GroupBox1 As GroupBox + Friend WithEvents Button3 As Button + Friend WithEvents TextBox1 As TextBox + Friend WithEvents SaveFileDialog1 As SaveFileDialog + Friend WithEvents txtServiceAddress As DevExpress.XtraEditors.TextEdit + Friend WithEvents Label1 As Label + Friend WithEvents txtServicePort As DevExpress.XtraEditors.TextEdit + Friend WithEvents Button4 As Button + Friend WithEvents txtStatus As TextBox End Class diff --git a/GUIs.Test.TestGUI/frmFilesystem.resx b/GUIs.Test.TestGUI/frmFilesystem.resx index 1af7de15..4008a9ee 100644 --- a/GUIs.Test.TestGUI/frmFilesystem.resx +++ b/GUIs.Test.TestGUI/frmFilesystem.resx @@ -117,4 +117,7 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 17, 17 + \ No newline at end of file diff --git a/GUIs.Test.TestGUI/frmFilesystem.vb b/GUIs.Test.TestGUI/frmFilesystem.vb index ad4cfa91..b352ebbb 100644 --- a/GUIs.Test.TestGUI/frmFilesystem.vb +++ b/GUIs.Test.TestGUI/frmFilesystem.vb @@ -1,8 +1,29 @@ -Imports DigitalData.Modules.Logging +Imports System.Collections.Generic +Imports System.IO +Imports System.Numerics ' Verweis auf System.Numerics assembly hinzufügen! +Imports System.Security.Cryptography +Imports DigitalData.GUIs.Common +Imports DigitalData.Modules.Base.IDB.Constants +Imports DigitalData.Modules.Database +Imports DigitalData.Modules.EDMI.API +Imports DigitalData.Modules.EDMI.API.EDMIServiceReference +Imports DigitalData.Modules.Logging +Imports DigitalData.Modules.ZooFlow.State Public Class frmFilesystem + Private Client As Client + Private Logger As Logger + + Private Const STATUS_CONNECTED = "Connection Established" + Private Const STATUS_CONNECTING = "Trying to create connection..." + Private Const STATUS_FAILED = "Connection Failed!" + + Private ConnectionChanged As Boolean = False + + Public Property ServiceAddress As String = "" + Public Property ServiceOnline As Boolean = False Private LogConfig As LogConfig - Private Filesystem As DigitalData.Modules.Filesystem.File + Private MYDD_Filesystem As DigitalData.Modules.Filesystem.File Private ShortName As String = "E:\some_test_file.txt" Private LongName As String = "E:\some_test_file_with_some_more_data_and_with_some_more_data_and_with_some_more_data_and_with_some_more_data_and_with_some_more_data_and_with_some_more_data_and_with_some_more_data_and_with_some_more_data_and_with_some_more_data_and_with_some_more.txt" @@ -10,7 +31,8 @@ Public Class frmFilesystem Private Sub frmFilesystem_Load(sender As Object, e As EventArgs) Handles MyBase.Load Try LogConfig = New LogConfig(LogConfig.PathType.Temp) - Filesystem = New DigitalData.Modules.Filesystem.File(LogConfig) + Logger = LogConfig.GetLogger() + MYDD_Filesystem = New DigitalData.Modules.Filesystem.File(LogConfig) 'Using oWriter = IO.File.CreateText("E:\some_test_file.txt") @@ -34,6 +56,138 @@ Public Class frmFilesystem End Sub Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click - Dim oDateString = Filesystem.CreateDateDirectory("E:\") + Dim oDateString = MYDD_Filesystem.CreateDateDirectory("E:\") + End Sub + + Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click + If SaveFileDialog1.ShowDialog = DialogResult.OK Then + ' Fallback: einfache Textdatei schreiben + System.IO.File.WriteAllText(SaveFileDialog1.FileName, "Some text data") + End If + End Sub + + Private Async Function Button2_ClickAsync(sender As Object, e As EventArgs) As Task Handles Button2.Click + ' Import a file via EDMI Globix ImportFile API to test Service.EDMIService ImportFileMethod + Try + If Client Is Nothing OrElse ServiceOnline = False Then + MsgBox("Bitte zuerst Verbindung zum EDMI Service herstellen.", MsgBoxStyle.Exclamation, Text) + Return + End If + + Using ofd As New OpenFileDialog() + ofd.Title = "Datei für Import wählen" + ofd.Filter = "Alle Dateien (*.*)|*.*" + If ofd.ShowDialog() <> DialogResult.OK Then + Return + End If + + Dim oFilePath = ofd.FileName + Dim fi As New FileInfo(oFilePath) + Dim fileBytes As Byte() = IO.File.ReadAllBytes(oFilePath) + + ' Basic user context for testing + Dim user As New DigitalData.Modules.ZooFlow.State.UserState() With { + .UserName = Environment.UserName, + .Language = "de-DE", + .LanguageId = 1031 + } + + Dim oObjectStore As String = "SelectedDocType.ObjectStore" + Dim oIDBDoctypeId As Long = 1 + Dim oObjectKind As String = "DOC" + Dim oProfileId As Integer = 1 + Dim oAttributes As List(Of UserAttributeValue) = Nothing + Dim oOptions As New Options.ImportFileOptions + + Logger.Debug("FilePath: [{0}]", oFilePath) + Logger.Debug("ObjectStore: [{0}]", oObjectStore) + Logger.Debug("ObjectKind: [{0}]", oObjectKind) + Logger.Debug("ProfileId: [{0}]", oProfileId) + Logger.Debug("IDB DoctypeId: [{0}]", oIDBDoctypeId) + + Logger.Info("Running Import") + + Dim oResult = Await My.Application.Service.Client.Globix_ImportFileAsync( + oFilePath, oProfileId, oAttributes, oObjectStore, oObjectKind, oIDBDoctypeId, oOptions) + + Logger.Info("Import result: [{0}]", oResult.OK) + Logger.Info("Imported file got ObjectId [{0}]", oResult.ObjectId) + + If oResult.OK Then + MsgBox("Alles OK") + Else + Logger.Warn("Import failed with message: [{0}] and details [{1}]", oResult.ErrorMessage, oResult.ErrorDetails) + Dim oMsg As String, oTitle As String + If My.Application.User.Language = "de-DE" Then + oMsg = $"Die Datei wurde nicht verarbeitet.{vbNewLine}{vbNewLine}Fehler: {oResult.ErrorMessage}" + oTitle = "Achtung" + Else + oMsg = $"Unexpected Error in FileFlow{vbNewLine}{vbNewLine}Fehler: {oResult.ErrorMessage}" + oTitle = "Attention" + End If + + + MsgBox("Fehler") + End If + End Using + Catch ex As Exception + If Logger IsNot Nothing Then Logger.Error(ex) + MsgBox("Fehler beim Datei-Import.", MsgBoxStyle.Critical, Text) + End Try + End Function + + + Public Class SecureStorageHandler + + + + End Class + + Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click + Try + Dim oIPAddress = txtServiceAddress.Text + Dim oPort = Integer.Parse(txtServicePort.Text) + + Client = New Client(LogConfig, oIPAddress, oPort) + + txtStatus.Text = STATUS_CONNECTING + Dim oResult = Client.Connect() + + If oResult = True Then + ServiceAddress = $"{oIPAddress}:{oPort}" + ServiceOnline = True + txtStatus.Text = STATUS_CONNECTED + My.Application.Service.Client = Client + Logger.Debug("Loading client config..") + Dim oClientConfig = My.Application.Service.Client.ClientConfig + Logger.Debug("Establishing ECM connection..") + Dim oECMConnectionString = oClientConfig.ConnectionStringECM + My.DatabaseECM = New MSSQLServer(My.LogConfig, oECMConnectionString) + Logger.Debug("Establishing IDB connection..") + Dim oIDBConnectionString = oClientConfig.ConnectionStringIDB + My.DatabaseIDB = New MSSQLServer(My.LogConfig, oIDBConnectionString) + + Logger.Debug("Establishing Database connection with fallback..") + My.Database = New DatabaseWithFallback(LogConfig, My.Application.Service.Client, My.DatabaseECM, My.DatabaseIDB) + Else + ServiceAddress = "" + ServiceOnline = True + txtStatus.Text = STATUS_FAILED + ' TODO: Make a connection test that is as elaborate as this one :D + 'Select Case oResult + ' Case ClassService.ConnectionTestResult.NotFound + ' lblStatus.Text = "Dienst konnte nicht gefunden werden. Bitte überprüfen sie Addresse und Port." + ' Case ClassService.ConnectionTestResult.EmptyURI + ' lblStatus.Text = "Bitte tragen Sie eine gültige Dienst Adresse ein." + ' Case ClassService.ConnectionTestResult.Authentication + ' lblStatus.Text = "Authentifizierungsfehler. Prüfen Sie, ob sich Ihr Gerät in der korrekten Domäne befindet." + ' Case Else + ' lblStatus.Text = "Unbekannter Fehler." + 'End Select + End If + Catch ex As Exception + If Logger IsNot Nothing Then Logger.Error(ex) + MsgBox("Fehler beim Verbindungsaufbau", MsgBoxStyle.Critical, Text) + End Try End Sub End Class \ No newline at end of file diff --git a/GUIs.Test.ZUGFeRDTest/App.config b/GUIs.Test.ZUGFeRDTest/App.config index 9b511643..1da1135b 100644 --- a/GUIs.Test.ZUGFeRDTest/App.config +++ b/GUIs.Test.ZUGFeRDTest/App.config @@ -2,16 +2,26 @@ +
+
- + + + + 172.24.12.50:E:\DataFiles\Firebird\WISAG\EDMI_MASTER.FDB + + + 172.24.12.50 + + 172.24.12.50:E:\DataFiles\Firebird\WISAG\EDMI_MASTER.FDB @@ -22,6 +32,20 @@ + + + sysdba + + + dd + + + + + + Server=SDD-VMP04-SQL17\DD_DEVELOP01;Database=DD_ECM;User Id=sa;Password=dd;TrustServerCertificate=true; + + sysdba @@ -147,6 +171,18 @@ + + + + + + + + + + + + diff --git a/GUIs.Test.ZUGFeRDTest/Form1.Designer.vb b/GUIs.Test.ZUGFeRDTest/Form1.Designer.vb index 1eef804d..addd06e6 100644 --- a/GUIs.Test.ZUGFeRDTest/Form1.Designer.vb +++ b/GUIs.Test.ZUGFeRDTest/Form1.Designer.vb @@ -1,4 +1,6 @@ - +Imports System.Windows.Forms + + Partial Class Form1 Inherits System.Windows.Forms.Form @@ -22,227 +24,256 @@ Partial Class Form1 'Das Bearbeiten mit dem Code-Editor ist nicht möglich. Private Sub InitializeComponent() - Me.OpenFileDialog1 = New System.Windows.Forms.OpenFileDialog() - Me.btRunJob = New System.Windows.Forms.Button() - Me.ListBox1 = New System.Windows.Forms.ListBox() - Me.btValidateSerializePDF = New System.Windows.Forms.Button() - Me.btValidateSerializeParseProps = New System.Windows.Forms.Button() - Me.btCreateMD5Checksum = New System.Windows.Forms.Button() - Me.GroupBox1 = New System.Windows.Forms.GroupBox() - Me.ButtonValidateXMLOnly = New System.Windows.Forms.Button() - Me.GroupBox2 = New System.Windows.Forms.GroupBox() - Me.btExtractPDFAttachments = New System.Windows.Forms.Button() - Me.GroupBox3 = New System.Windows.Forms.GroupBox() - Me.txtMD5Checksum = New System.Windows.Forms.TextBox() - Me.txtPropName = New System.Windows.Forms.TextBox() - Me.GroupBox4 = New System.Windows.Forms.GroupBox() - Me.btFindExtractXMLValue = New System.Windows.Forms.Button() - Me.FolderBrowserDialog1 = New System.Windows.Forms.FolderBrowserDialog() - Me.GroupBox5 = New System.Windows.Forms.GroupBox() - Me.btWriteBinary = New System.Windows.Forms.Button() - Me.OpenFileDialog2 = New System.Windows.Forms.OpenFileDialog() - Me.Button1 = New System.Windows.Forms.Button() - Me.GroupBox1.SuspendLayout() - Me.GroupBox2.SuspendLayout() - Me.GroupBox3.SuspendLayout() - Me.GroupBox4.SuspendLayout() - Me.GroupBox5.SuspendLayout() - Me.SuspendLayout() - ' - 'OpenFileDialog1 - ' - Me.OpenFileDialog1.FileName = "OpenFileDialog1" - ' - 'btRunJob - ' - Me.btRunJob.Location = New System.Drawing.Point(6, 19) - Me.btRunJob.Name = "btRunJob" - Me.btRunJob.Size = New System.Drawing.Size(221, 23) - Me.btRunJob.TabIndex = 0 - Me.btRunJob.Text = "Run Job" - Me.btRunJob.UseVisualStyleBackColor = True - ' - 'ListBox1 - ' - Me.ListBox1.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _ - Or System.Windows.Forms.AnchorStyles.Left) _ - Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) - Me.ListBox1.FormattingEnabled = True - Me.ListBox1.Location = New System.Drawing.Point(378, 8) - Me.ListBox1.Name = "ListBox1" - Me.ListBox1.Size = New System.Drawing.Size(532, 602) - Me.ListBox1.TabIndex = 1 - ' - 'btValidateSerializePDF - ' - Me.btValidateSerializePDF.Location = New System.Drawing.Point(6, 19) - Me.btValidateSerializePDF.Name = "btValidateSerializePDF" - Me.btValidateSerializePDF.Size = New System.Drawing.Size(246, 23) - Me.btValidateSerializePDF.TabIndex = 2 - Me.btValidateSerializePDF.Text = "Validate and Serialize PDF" - Me.btValidateSerializePDF.UseVisualStyleBackColor = True - ' - 'btValidateSerializeParseProps - ' - Me.btValidateSerializeParseProps.Location = New System.Drawing.Point(6, 48) - Me.btValidateSerializeParseProps.Name = "btValidateSerializeParseProps" - Me.btValidateSerializeParseProps.Size = New System.Drawing.Size(246, 23) - Me.btValidateSerializeParseProps.TabIndex = 3 - Me.btValidateSerializeParseProps.Text = "Validate and Serialize PDF and Parse Props" - Me.btValidateSerializeParseProps.UseVisualStyleBackColor = True - ' - 'btCreateMD5Checksum - ' - Me.btCreateMD5Checksum.Location = New System.Drawing.Point(6, 19) - Me.btCreateMD5Checksum.Name = "btCreateMD5Checksum" - Me.btCreateMD5Checksum.Size = New System.Drawing.Size(221, 23) - Me.btCreateMD5Checksum.TabIndex = 4 - Me.btCreateMD5Checksum.Text = "Create MD5 Checksum for PDF" - Me.btCreateMD5Checksum.UseVisualStyleBackColor = True - ' - 'GroupBox1 - ' - Me.GroupBox1.Controls.Add(Me.ButtonValidateXMLOnly) - Me.GroupBox1.Controls.Add(Me.btRunJob) - Me.GroupBox1.Location = New System.Drawing.Point(12, 12) - Me.GroupBox1.Name = "GroupBox1" - Me.GroupBox1.Size = New System.Drawing.Size(252, 92) - Me.GroupBox1.TabIndex = 7 - Me.GroupBox1.TabStop = False - Me.GroupBox1.Text = "Run Job like in eInvoice Service" - ' - 'ButtonValidateXMLOnly - ' - Me.ButtonValidateXMLOnly.Location = New System.Drawing.Point(6, 48) - Me.ButtonValidateXMLOnly.Name = "ButtonValidateXMLOnly" - Me.ButtonValidateXMLOnly.Size = New System.Drawing.Size(221, 23) - Me.ButtonValidateXMLOnly.TabIndex = 4 - Me.ButtonValidateXMLOnly.Text = "XML Job (Sichtbeleg)" - Me.ButtonValidateXMLOnly.UseVisualStyleBackColor = True - ' - 'GroupBox2 - ' - Me.GroupBox2.Controls.Add(Me.btValidateSerializePDF) - Me.GroupBox2.Controls.Add(Me.btExtractPDFAttachments) - Me.GroupBox2.Controls.Add(Me.btValidateSerializeParseProps) - Me.GroupBox2.Location = New System.Drawing.Point(12, 110) - Me.GroupBox2.Name = "GroupBox2" - Me.GroupBox2.Size = New System.Drawing.Size(360, 155) - Me.GroupBox2.TabIndex = 8 - Me.GroupBox2.TabStop = False - Me.GroupBox2.Text = "Run Functions on a single file (needs Breakpoint)" - ' - 'btExtractPDFAttachments - ' - Me.btExtractPDFAttachments.Location = New System.Drawing.Point(6, 77) - Me.btExtractPDFAttachments.Name = "btExtractPDFAttachments" - Me.btExtractPDFAttachments.Size = New System.Drawing.Size(246, 23) - Me.btExtractPDFAttachments.TabIndex = 3 - Me.btExtractPDFAttachments.Text = "Extract PDF Attachments" - Me.btExtractPDFAttachments.UseVisualStyleBackColor = True - ' - 'GroupBox3 - ' - Me.GroupBox3.Controls.Add(Me.btCreateMD5Checksum) - Me.GroupBox3.Controls.Add(Me.txtMD5Checksum) - Me.GroupBox3.Location = New System.Drawing.Point(12, 271) - Me.GroupBox3.Name = "GroupBox3" - Me.GroupBox3.Size = New System.Drawing.Size(360, 85) - Me.GroupBox3.TabIndex = 9 - Me.GroupBox3.TabStop = False - Me.GroupBox3.Text = "Open PDF and calculate Checksum" - ' - 'txtMD5Checksum - ' - Me.txtMD5Checksum.DataBindings.Add(New System.Windows.Forms.Binding("Text", Global.ZUGFeRDTest.My.MySettings.Default, "MD5Cheksum", True, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged)) - Me.txtMD5Checksum.Location = New System.Drawing.Point(6, 49) - Me.txtMD5Checksum.Name = "txtMD5Checksum" - Me.txtMD5Checksum.Size = New System.Drawing.Size(348, 20) - Me.txtMD5Checksum.TabIndex = 5 - Me.txtMD5Checksum.Text = Global.ZUGFeRDTest.My.MySettings.Default.MD5Cheksum - ' - 'txtPropName - ' - Me.txtPropName.Location = New System.Drawing.Point(6, 48) - Me.txtPropName.Name = "txtPropName" - Me.txtPropName.Size = New System.Drawing.Size(348, 20) - Me.txtPropName.TabIndex = 10 - ' - 'GroupBox4 - ' - Me.GroupBox4.Controls.Add(Me.btFindExtractXMLValue) - Me.GroupBox4.Controls.Add(Me.txtPropName) - Me.GroupBox4.Location = New System.Drawing.Point(12, 362) - Me.GroupBox4.Name = "GroupBox4" - Me.GroupBox4.Size = New System.Drawing.Size(360, 122) - Me.GroupBox4.TabIndex = 11 - Me.GroupBox4.TabStop = False - Me.GroupBox4.Text = "GroupBox4" - ' - 'btFindExtractXMLValue - ' - Me.btFindExtractXMLValue.Location = New System.Drawing.Point(6, 19) - Me.btFindExtractXMLValue.Name = "btFindExtractXMLValue" - Me.btFindExtractXMLValue.Size = New System.Drawing.Size(221, 23) - Me.btFindExtractXMLValue.TabIndex = 11 - Me.btFindExtractXMLValue.Text = "Find and Extract XML Path Value" - Me.btFindExtractXMLValue.UseVisualStyleBackColor = True - ' - 'GroupBox5 - ' - Me.GroupBox5.Controls.Add(Me.btWriteBinary) - Me.GroupBox5.Location = New System.Drawing.Point(12, 490) - Me.GroupBox5.Name = "GroupBox5" - Me.GroupBox5.Size = New System.Drawing.Size(360, 122) - Me.GroupBox5.TabIndex = 12 - Me.GroupBox5.TabStop = False - Me.GroupBox5.Text = "GroupBox5" - ' - 'btWriteBinary - ' - Me.btWriteBinary.Location = New System.Drawing.Point(6, 19) - Me.btWriteBinary.Name = "btWriteBinary" - Me.btWriteBinary.Size = New System.Drawing.Size(221, 23) - Me.btWriteBinary.TabIndex = 11 - Me.btWriteBinary.Text = "Write Binary to PDF" - Me.btWriteBinary.UseVisualStyleBackColor = True - ' - 'OpenFileDialog2 - ' - Me.OpenFileDialog2.FileName = "OpenFileDialog2" - Me.OpenFileDialog2.Filter = "XML files (*.xml)|*.xml" - ' - 'Button1 - ' - Me.Button1.Location = New System.Drawing.Point(270, 31) - Me.Button1.Name = "Button1" - Me.Button1.Size = New System.Drawing.Size(75, 23) - Me.Button1.TabIndex = 4 - Me.Button1.Text = "LogFolder" - Me.Button1.UseVisualStyleBackColor = True - ' - 'Form1 - ' - Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) - Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font - Me.ClientSize = New System.Drawing.Size(916, 633) - Me.Controls.Add(Me.Button1) - Me.Controls.Add(Me.GroupBox5) - Me.Controls.Add(Me.GroupBox4) - Me.Controls.Add(Me.GroupBox3) - Me.Controls.Add(Me.GroupBox2) - Me.Controls.Add(Me.GroupBox1) - Me.Controls.Add(Me.ListBox1) - Me.Name = "Form1" - Me.Text = "E-Invoice-TEST-Tool" - Me.GroupBox1.ResumeLayout(False) - Me.GroupBox2.ResumeLayout(False) - Me.GroupBox3.ResumeLayout(False) - Me.GroupBox3.PerformLayout() - Me.GroupBox4.ResumeLayout(False) - Me.GroupBox4.PerformLayout() - Me.GroupBox5.ResumeLayout(False) - Me.ResumeLayout(False) + OpenFileDialog1 = New OpenFileDialog() + btRunJob = New Button() + ListBox1 = New ListBox() + btValidateSerializePDF = New Button() + btValidateSerializeParseProps = New Button() + btCreateMD5Checksum = New Button() + GroupBox1 = New GroupBox() + ButtonValidateXMLOnly = New Button() + GroupBox2 = New GroupBox() + btExtractPDFAttachments = New Button() + GroupBox3 = New GroupBox() + txtMD5Checksum = New TextBox() + txtPropName = New TextBox() + GroupBox4 = New GroupBox() + btFindExtractXMLValue = New Button() + FolderBrowserDialog1 = New FolderBrowserDialog() + GroupBox5 = New GroupBox() + btWriteBinary = New Button() + OpenFileDialog2 = New OpenFileDialog() + Button1 = New Button() + Button2 = New Button() + GroupBox1.SuspendLayout() + GroupBox2.SuspendLayout() + GroupBox3.SuspendLayout() + GroupBox4.SuspendLayout() + GroupBox5.SuspendLayout() + SuspendLayout() + ' + ' OpenFileDialog1 + ' + OpenFileDialog1.FileName = "OpenFileDialog1" + ' + ' btRunJob + ' + btRunJob.Location = New System.Drawing.Point(8, 29) + btRunJob.Margin = New Padding(4, 5, 4, 5) + btRunJob.Name = "btRunJob" + btRunJob.Size = New System.Drawing.Size(295, 35) + btRunJob.TabIndex = 0 + btRunJob.Text = "Run Job" + btRunJob.UseVisualStyleBackColor = True + ' + ' ListBox1 + ' + ListBox1.Anchor = AnchorStyles.Top Or AnchorStyles.Bottom Or AnchorStyles.Left Or AnchorStyles.Right + ListBox1.FormattingEnabled = True + ListBox1.Location = New System.Drawing.Point(504, 12) + ListBox1.Margin = New Padding(4, 5, 4, 5) + ListBox1.Name = "ListBox1" + ListBox1.Size = New System.Drawing.Size(362, 664) + ListBox1.TabIndex = 1 + ' + ' btValidateSerializePDF + ' + btValidateSerializePDF.Location = New System.Drawing.Point(8, 29) + btValidateSerializePDF.Margin = New Padding(4, 5, 4, 5) + btValidateSerializePDF.Name = "btValidateSerializePDF" + btValidateSerializePDF.Size = New System.Drawing.Size(328, 35) + btValidateSerializePDF.TabIndex = 2 + btValidateSerializePDF.Text = "Validate and Serialize PDF" + btValidateSerializePDF.UseVisualStyleBackColor = True + ' + ' btValidateSerializeParseProps + ' + btValidateSerializeParseProps.Location = New System.Drawing.Point(8, 74) + btValidateSerializeParseProps.Margin = New Padding(4, 5, 4, 5) + btValidateSerializeParseProps.Name = "btValidateSerializeParseProps" + btValidateSerializeParseProps.Size = New System.Drawing.Size(328, 35) + btValidateSerializeParseProps.TabIndex = 3 + btValidateSerializeParseProps.Text = "Validate and Serialize PDF and Parse Props" + btValidateSerializeParseProps.UseVisualStyleBackColor = True + ' + ' btCreateMD5Checksum + ' + btCreateMD5Checksum.Location = New System.Drawing.Point(8, 29) + btCreateMD5Checksum.Margin = New Padding(4, 5, 4, 5) + btCreateMD5Checksum.Name = "btCreateMD5Checksum" + btCreateMD5Checksum.Size = New System.Drawing.Size(295, 35) + btCreateMD5Checksum.TabIndex = 4 + btCreateMD5Checksum.Text = "Create MD5 Checksum for PDF" + btCreateMD5Checksum.UseVisualStyleBackColor = True + ' + ' GroupBox1 + ' + GroupBox1.Controls.Add(ButtonValidateXMLOnly) + GroupBox1.Controls.Add(btRunJob) + GroupBox1.Location = New System.Drawing.Point(16, 18) + GroupBox1.Margin = New Padding(4, 5, 4, 5) + GroupBox1.Name = "GroupBox1" + GroupBox1.Padding = New Padding(4, 5, 4, 5) + GroupBox1.Size = New System.Drawing.Size(319, 116) + GroupBox1.TabIndex = 7 + GroupBox1.TabStop = False + GroupBox1.Text = "Run Job like in eInvoice Service" + ' + ' ButtonValidateXMLOnly + ' + ButtonValidateXMLOnly.Location = New System.Drawing.Point(8, 74) + ButtonValidateXMLOnly.Margin = New Padding(4, 5, 4, 5) + ButtonValidateXMLOnly.Name = "ButtonValidateXMLOnly" + ButtonValidateXMLOnly.Size = New System.Drawing.Size(295, 35) + ButtonValidateXMLOnly.TabIndex = 4 + ButtonValidateXMLOnly.Text = "Run XML Job (spez. Configuration)" + ButtonValidateXMLOnly.UseVisualStyleBackColor = True + ' + ' GroupBox2 + ' + GroupBox2.Controls.Add(btValidateSerializePDF) + GroupBox2.Controls.Add(btExtractPDFAttachments) + GroupBox2.Controls.Add(btValidateSerializeParseProps) + GroupBox2.Location = New System.Drawing.Point(16, 144) + GroupBox2.Margin = New Padding(4, 5, 4, 5) + GroupBox2.Name = "GroupBox2" + GroupBox2.Padding = New Padding(4, 5, 4, 5) + GroupBox2.Size = New System.Drawing.Size(480, 167) + GroupBox2.TabIndex = 8 + GroupBox2.TabStop = False + GroupBox2.Text = "Run Functions on a single file (needs Breakpoint)" + ' + ' btExtractPDFAttachments + ' + btExtractPDFAttachments.Location = New System.Drawing.Point(8, 118) + btExtractPDFAttachments.Margin = New Padding(4, 5, 4, 5) + btExtractPDFAttachments.Name = "btExtractPDFAttachments" + btExtractPDFAttachments.Size = New System.Drawing.Size(328, 35) + btExtractPDFAttachments.TabIndex = 3 + btExtractPDFAttachments.Text = "Extract PDF Attachments" + btExtractPDFAttachments.UseVisualStyleBackColor = True + ' + ' GroupBox3 + ' + GroupBox3.Controls.Add(btCreateMD5Checksum) + GroupBox3.Controls.Add(txtMD5Checksum) + GroupBox3.Location = New System.Drawing.Point(16, 321) + GroupBox3.Margin = New Padding(4, 5, 4, 5) + GroupBox3.Name = "GroupBox3" + GroupBox3.Padding = New Padding(4, 5, 4, 5) + GroupBox3.Size = New System.Drawing.Size(480, 131) + GroupBox3.TabIndex = 9 + GroupBox3.TabStop = False + GroupBox3.Text = "Open PDF and calculate Checksum" + ' + ' txtMD5Checksum + ' + txtMD5Checksum.Location = New System.Drawing.Point(8, 75) + txtMD5Checksum.Margin = New Padding(4, 5, 4, 5) + txtMD5Checksum.Name = "txtMD5Checksum" + txtMD5Checksum.Size = New System.Drawing.Size(463, 27) + txtMD5Checksum.TabIndex = 5 + ' + ' txtPropName + ' + txtPropName.Location = New System.Drawing.Point(8, 74) + txtPropName.Margin = New Padding(4, 5, 4, 5) + txtPropName.Name = "txtPropName" + txtPropName.Size = New System.Drawing.Size(463, 27) + txtPropName.TabIndex = 10 + ' + ' GroupBox4 + ' + GroupBox4.Controls.Add(btFindExtractXMLValue) + GroupBox4.Controls.Add(txtPropName) + GroupBox4.Location = New System.Drawing.Point(16, 462) + GroupBox4.Margin = New Padding(4, 5, 4, 5) + GroupBox4.Name = "GroupBox4" + GroupBox4.Padding = New Padding(4, 5, 4, 5) + GroupBox4.Size = New System.Drawing.Size(480, 117) + GroupBox4.TabIndex = 11 + GroupBox4.TabStop = False + GroupBox4.Text = "GroupBox4" + ' + ' btFindExtractXMLValue + ' + btFindExtractXMLValue.Location = New System.Drawing.Point(8, 29) + btFindExtractXMLValue.Margin = New Padding(4, 5, 4, 5) + btFindExtractXMLValue.Name = "btFindExtractXMLValue" + btFindExtractXMLValue.Size = New System.Drawing.Size(295, 35) + btFindExtractXMLValue.TabIndex = 11 + btFindExtractXMLValue.Text = "Find and Extract XML Path Value" + btFindExtractXMLValue.UseVisualStyleBackColor = True + ' + ' GroupBox5 + ' + GroupBox5.Controls.Add(btWriteBinary) + GroupBox5.Location = New System.Drawing.Point(13, 589) + GroupBox5.Margin = New Padding(4, 5, 4, 5) + GroupBox5.Name = "GroupBox5" + GroupBox5.Padding = New Padding(4, 5, 4, 5) + GroupBox5.Size = New System.Drawing.Size(480, 87) + GroupBox5.TabIndex = 12 + GroupBox5.TabStop = False + GroupBox5.Text = "GroupBox5" + ' + ' btWriteBinary + ' + btWriteBinary.Location = New System.Drawing.Point(8, 29) + btWriteBinary.Margin = New Padding(4, 5, 4, 5) + btWriteBinary.Name = "btWriteBinary" + btWriteBinary.Size = New System.Drawing.Size(295, 35) + btWriteBinary.TabIndex = 11 + btWriteBinary.Text = "Write Binary to PDF" + btWriteBinary.UseVisualStyleBackColor = True + ' + ' OpenFileDialog2 + ' + OpenFileDialog2.FileName = "OpenFileDialog2" + OpenFileDialog2.Filter = "XML files (*.xml)|*.xml" + ' + ' Button1 + ' + Button1.Location = New System.Drawing.Point(361, 47) + Button1.Name = "Button1" + Button1.Size = New System.Drawing.Size(94, 29) + Button1.TabIndex = 5 + Button1.Text = "Log Folder" + Button1.UseVisualStyleBackColor = True + ' + ' Button2 + ' + Button2.Location = New System.Drawing.Point(361, 82) + Button2.Name = "Button2" + Button2.Size = New System.Drawing.Size(94, 29) + Button2.TabIndex = 13 + Button2.Text = "AppFolder" + Button2.UseVisualStyleBackColor = True + ' + ' Form1 + ' + AutoScaleDimensions = New System.Drawing.SizeF(8.0F, 20.0F) + AutoScaleMode = AutoScaleMode.Font + ClientSize = New System.Drawing.Size(879, 690) + Controls.Add(Button2) + Controls.Add(Button1) + Controls.Add(GroupBox5) + Controls.Add(GroupBox4) + Controls.Add(GroupBox3) + Controls.Add(GroupBox2) + Controls.Add(GroupBox1) + Controls.Add(ListBox1) + Margin = New Padding(4, 5, 4, 5) + Name = "Form1" + Text = "E-Invoice-TEST-Tool" + GroupBox1.ResumeLayout(False) + GroupBox2.ResumeLayout(False) + GroupBox3.ResumeLayout(False) + GroupBox3.PerformLayout() + GroupBox4.ResumeLayout(False) + GroupBox4.PerformLayout() + GroupBox5.ResumeLayout(False) + ResumeLayout(False) End Sub @@ -265,5 +296,4 @@ Partial Class Form1 Friend WithEvents btWriteBinary As Button Friend WithEvents ButtonValidateXMLOnly As Button Friend WithEvents OpenFileDialog2 As OpenFileDialog - Friend WithEvents Button1 As Button End Class diff --git a/GUIs.Test.ZUGFeRDTest/Form1.resx b/GUIs.Test.ZUGFeRDTest/Form1.resx index e47e59bf..6ab56a3c 100644 --- a/GUIs.Test.ZUGFeRDTest/Form1.resx +++ b/GUIs.Test.ZUGFeRDTest/Form1.resx @@ -1,17 +1,17 @@  - @@ -126,4 +126,7 @@ 328, 17 + + 25 + \ No newline at end of file diff --git a/GUIs.Test.ZUGFeRDTest/Form1.vb b/GUIs.Test.ZUGFeRDTest/Form1.vb index 950ee575..7800d254 100644 --- a/GUIs.Test.ZUGFeRDTest/Form1.vb +++ b/GUIs.Test.ZUGFeRDTest/Form1.vb @@ -1,6 +1,8 @@ -Imports System.IO +Imports System.Data +Imports System.IO Imports System.Reflection Imports System.Security.Cryptography +Imports System.Windows.Forms Imports DigitalData.Modules.Config Imports DigitalData.Modules.Database Imports DigitalData.Modules.Interfaces @@ -21,11 +23,16 @@ Public Class Form1 Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load - _logConfig = New LogConfig(LogConfig.PathType.CustomPath, Application.StartupPath & "\Log", Nothing, My.Application.Info.CompanyName, My.Application.Info.ProductName) With { + Dim oLogPath = Path.Combine(Application.StartupPath, "Log") + _logConfig = New LogConfig(LogConfig.PathType.CustomPath, oLogPath, Nothing, My.Application.Info.CompanyName, My.Application.Info.ProductName) With { .Debug = True } _logger = _logConfig.GetLogger() - _mssql = New MSSQLServer(_logConfig, My.Settings.MSSQL_CONNECTIONSTRING) + Dim oCS = My.Settings.MSSQL_CONNECTIONSTRING + If Not oCS.Contains("TrustServerCertificate") Then + oCS += ";TrustServerCertificate=true" + End If + _mssql = New MSSQLServer(_logConfig, oCS) _GDPictureVersion = "11.2024" _GDPictureLizenz = ConfigDbFunct.GetProductLicense("GDPICTURE", _GDPictureVersion, _logConfig, My.Settings.MSSQL_CONNECTIONSTRING) @@ -92,14 +99,14 @@ Public Class Form1 Dim oEN16931_ID = oRow.Item("EN16931_ID") Args.PropertyMapList.Add(New XmlItemProperty() With { - .XMLPath = xmlPath, - .Description = description, - .TableName = tableName, - .TableColumn = tableColumn, - .IsRequired = isRequired, - .IsGrouped = isGrouped, - .GroupScope = groupScope, - .Specification = specification, + .xmlPath = xmlPath, + .description = description, + .tableName = tableName, + .tableColumn = tableColumn, + .isRequired = isRequired, + .isGrouped = isGrouped, + .groupScope = groupScope, + .specification = specification, .ItemType = oItemType, .EN16931_ID = oEN16931_ID }) @@ -152,9 +159,41 @@ Public Class Form1 If oResult = DialogResult.OK Then Try - Dim oDoc = _zugferd.ValidateZUGFeRDFileWithGDPicture(OpenFileDialog1.FileName) + Dim oDoc = _zugferd.ValidateZUGFeRDFileWithGDPicture(OpenFileDialog1.FileName, True) + Dim oZFResult = _zugferd.ValidateZUGFeRDDocument(oDoc) Dim oZUGFERD = _zugferd.SerializeZUGFeRDDocument(oDoc) - Console.WriteLine() + WriteLog("Specification: " & oZFResult.Specification) + 'WriteLog("XML-Schema: " & oResult.UsedXMLSchema) + WriteLog("Embedded File Name: " & oZFResult.DataFileName) + + Dim oSpecification = oZFResult.Specification + + If oSpecification = ZUGFeRDInterface.ZUGFERD_SPEC_10 Then + oSpecification = ZUGFeRDInterface.ZUGFERD_SPEC_DEFAULT + End If + + Dim oPropertyMap = oArgs.PropertyMapList. + Where(Function(kv) kv.Specification = oSpecification). + ToDictionary(Function(kv) kv.XMLPath, Function(kv) kv) + + Dim oResult2 = _zugferd.PropertyValues.CheckPropertyValues(oZFResult.SchemaObject, oPropertyMap, "test") + + WriteLog("Valid Properties: [{0}]", oResult2.ValidProperties.Count) + For Each Prop In oResult2.ValidProperties + If Prop.Value.Length > 250 Then + WriteLog("Property: [{0}] = [{1}]", Prop.Description, Prop.Value.Substring(0, 250)) + Else + WriteLog("Property: [{0}] = [{1}]", Prop.Description, Prop.Value) + End If + Next + + WriteLog("--------------------------------") + WriteLog("Missing Properties: [{0}]", oResult2.MissingProperties.Count) + For Each Prop In oResult2.MissingProperties + WriteLog("Missing Property: [{0}]", Prop.ToString) ''Prop.Description + Next + + WriteLog("--------------------------------") Catch ex As DigitalData.Modules.Interfaces.Exceptions.ZUGFeRDExecption Dim oErrorCode = GetRejectionCodeNumber(ex.ErrorCode) Dim oMessage = oErrorCode + " - (" + ex.ErrorCode.ToString() + ") - " + ex.Message @@ -162,6 +201,7 @@ Public Class Form1 Catch ex As Exception MsgBox(ex.Message) End Try + MsgBox("Finished - check log") End If End Sub @@ -220,7 +260,7 @@ Public Class Form1 Try If oDialogResult = DialogResult.OK Then - Dim oDoc = _zugferd.ValidateZUGFeRDFileWithGDPicture(OpenFileDialog1.FileName) + Dim oDoc = _zugferd.ValidateZUGFeRDFileWithGDPicture(OpenFileDialog1.FileName, True) Dim oResult = _zugferd.ValidateZUGFeRDDocument(oDoc) oResult = _zugferd.SerializeZUGFeRDDocument(oDoc) @@ -375,6 +415,10 @@ Public Class Form1 End Function Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click - Process.Start(_logConfig.LogDirectory) + Process.Start("explorer.exe", _logConfig.LogDirectory) + End Sub + + Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click + Process.Start("explorer.exe", System.Windows.Forms.Application.UserAppDataPath()) End Sub End Class diff --git a/GUIs.Test.ZUGFeRDTest/My Project/Application.Designer.vb b/GUIs.Test.ZUGFeRDTest/My Project/Application.Designer.vb index 7a03956b..f602fad3 100644 --- a/GUIs.Test.ZUGFeRDTest/My Project/Application.Designer.vb +++ b/GUIs.Test.ZUGFeRDTest/My Project/Application.Designer.vb @@ -34,5 +34,11 @@ Namespace My Protected Overrides Sub OnCreateMainForm() Me.MainForm = Global.ZUGFeRDTest.Form1 End Sub + + _ + Protected Overrides Function OnInitialize(ByVal commandLineArgs As System.Collections.ObjectModel.ReadOnlyCollection(Of String)) As Boolean + Me.MinimumSplashScreenDisplayTime = 0 + Return MyBase.OnInitialize(commandLineArgs) + End Function End Class End Namespace diff --git a/GUIs.Test.ZUGFeRDTest/My Project/AssemblyInfo.vb b/GUIs.Test.ZUGFeRDTest/My Project/AssemblyInfo.vb index bb5dd90b..c545a7ad 100644 --- a/GUIs.Test.ZUGFeRDTest/My Project/AssemblyInfo.vb +++ b/GUIs.Test.ZUGFeRDTest/My Project/AssemblyInfo.vb @@ -1,35 +1,9 @@ Imports System Imports System.Reflection Imports System.Runtime.InteropServices - -' Allgemeine Informationen über eine Assembly werden über die folgenden -' Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern, -' die einer Assembly zugeordnet sind. - -' Werte der Assemblyattribute überprüfen - - - - - - 'Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird. - -' Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten: -' -' Hauptversion -' Nebenversion -' Buildnummer -' Revision -' -' Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden, -' übernehmen, indem Sie "*" eingeben: -' - - - diff --git a/GUIs.Test.ZUGFeRDTest/My Project/Settings.Designer.vb b/GUIs.Test.ZUGFeRDTest/My Project/Settings.Designer.vb index 0b05ad5c..1cba3fe1 100644 --- a/GUIs.Test.ZUGFeRDTest/My Project/Settings.Designer.vb +++ b/GUIs.Test.ZUGFeRDTest/My Project/Settings.Designer.vb @@ -15,7 +15,7 @@ Option Explicit On Namespace My _ Partial Friend NotInheritable Class MySettings Inherits Global.System.Configuration.ApplicationSettingsBase diff --git a/GUIs.Test.ZUGFeRDTest/My Project/Settings.settings b/GUIs.Test.ZUGFeRDTest/My Project/Settings.settings index 4e788b7e..b128f7c1 100644 --- a/GUIs.Test.ZUGFeRDTest/My Project/Settings.settings +++ b/GUIs.Test.ZUGFeRDTest/My Project/Settings.settings @@ -1,5 +1,5 @@  - + @@ -18,7 +18,7 @@ - Server=SDD-VMP04-SQL17\DD_DEVELOP01;Database=DD_ECM;User Id=sa;Password=dd + Server=SDD-VMP04-SQL17\DD_DEVELOP01;Database=DD_ECM;User Id=sa;Password=dd;TrustServerCertificate=true; \ No newline at end of file diff --git a/GUIs.Test.ZUGFeRDTest/Program.cs b/GUIs.Test.ZUGFeRDTest/Program.cs new file mode 100644 index 00000000..3e953e10 --- /dev/null +++ b/GUIs.Test.ZUGFeRDTest/Program.cs @@ -0,0 +1,21 @@ +using CoreWCF.Configuration; +using CoreWCF.Description; + +var builder = WebApplication.CreateBuilder(args); + +// Add CoreWCF services +builder.Services.AddServiceModelServices(); +builder.Services.AddServiceModelMetadata(); +builder.Services.AddSingleton(); + +var app = builder.Build(); + +app.UseServiceModel(builder => +{ + // TODO add here service endpoints and behaviors +}); + +var serviceMetadataBehavior = app.Services.GetRequiredService(); +serviceMetadataBehavior.HttpGetEnabled = true; + +app.Run(); diff --git a/GUIs.Test.ZUGFeRDTest/ZUGFeRDTest.vbproj b/GUIs.Test.ZUGFeRDTest/ZUGFeRDTest.vbproj index 40d5966c..f541b57f 100644 --- a/GUIs.Test.ZUGFeRDTest/ZUGFeRDTest.vbproj +++ b/GUIs.Test.ZUGFeRDTest/ZUGFeRDTest.vbproj @@ -1,54 +1,27 @@ - - - + + - Debug - AnyCPU - {16156434-E471-43F1-8030-76A0DA17CD5A} + ZUGFeRDTest + net8.0-windows WinExe ZUGFeRDTest.My.MyApplication - ZUGFeRDTest - ZUGFeRDTest - 512 WindowsForms - v4.6.2 - true - - - - - - AnyCPU - true - full - true - true - bin\Debug\ - ZUGFeRDTest.xml - 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 - - - AnyCPU - pdbonly - false - true - true - bin\Release\ - ZUGFeRDTest.xml - 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 - - - On - - - Binary - - - Off - - - On + true + ZUGFeRDTest + Digital Data GmbH + Provides baseclasses, methods and constants for DD Products + 2.0 + 2.0 + $(AssemblyName) + $(AssemblyName) + + + + + + + ..\packages\BouncyCastle.Cryptography.2.5.0\lib\net461\BouncyCastle.Cryptography.dll @@ -224,67 +197,20 @@ + - - - - - - - - - - - - - - - Form - - - Form1.vb - Form - - - - True - Application.myapp - True - - - True - True - Resources.resx - - - True - Settings.settings - True - - - - - Form1.vb - - - VbMyResourcesResXFileCodeGenerator - Resources.Designer.vb - My.Resources - Designer - - - - - MyApplicationCodeGenerator - Application.Designer.vb - - + + SettingsSingleFileGenerator + + + SettingsSingleFileGenerator + + + SettingsSingleFileGenerator + + SettingsSingleFileGenerator - My - Settings.Designer.vb - - diff --git a/GUIs.Test.ZUGFeRDTest/packages.config b/GUIs.Test.ZUGFeRDTest/packages.config index e93f4cb0..29c65262 100644 --- a/GUIs.Test.ZUGFeRDTest/packages.config +++ b/GUIs.Test.ZUGFeRDTest/packages.config @@ -27,5 +27,5 @@ - + \ No newline at end of file diff --git a/Service.EDMIService/EDMIService.vbproj b/Service.EDMIService/EDMIService.vbproj index 5edf3300..1c749f52 100644 --- a/Service.EDMIService/EDMIService.vbproj +++ b/Service.EDMIService/EDMIService.vbproj @@ -226,6 +226,7 @@ + Component diff --git a/Service.EDMIService/Methods/IDB/GetFileObject/GetFileObjectMethod.vb b/Service.EDMIService/Methods/IDB/GetFileObject/GetFileObjectMethod.vb index 9b735d52..613c68c2 100644 --- a/Service.EDMIService/Methods/IDB/GetFileObject/GetFileObjectMethod.vb +++ b/Service.EDMIService/Methods/IDB/GetFileObject/GetFileObjectMethod.vb @@ -2,6 +2,7 @@ Imports DigitalData.Modules.Logging Imports DigitalData.Modules.Language Imports System.IO +Imports DigitalData.Services.EDMIService.Security Namespace Methods.IDB.GetFileObject Public Class GetFileObjectMethod @@ -69,6 +70,29 @@ Namespace Methods.IDB.GetFileObject End Function Private Function LoadFileContents(pFilePath As String) As Byte() + Try + Dim password = Environment.GetEnvironmentVariable("DD_FILE_ENCRYPTION_PASSWORD") + If String.IsNullOrWhiteSpace(password) Then + Logger.Warn("No encryption password set (DD_FILE_ENCRYPTION_PASSWORD). Attempting legacy plain read for file [{0}]", pFilePath) + Return ReadPlain(pFilePath) + End If + + Try + ' Try decrypt first (preferred path) + Logger.Debug("Attempting AES decrypt for file [{0}]", pFilePath) + Return SecureFileHandler.DecryptFileToBytes(pFilePath, password) + Catch exDec As Exception + Logger.Warn("Decrypt failed for file [{0}]. Falling back to plain read. Reason: {1}", pFilePath, exDec.Message) + Logger.Error(exDec) + Return ReadPlain(pFilePath) + End Try + + Catch ex As Exception + Logger.Error(ex) + Return Nothing + End Try + End Function + Private Function LoadFileContents_Old(pFilePath As String) As Byte() Try Using oFileStream As New FileStream(pFilePath, FileMode.Open, FileAccess.Read) Using oMemoryStream As New MemoryStream() @@ -85,6 +109,15 @@ Namespace Methods.IDB.GetFileObject End Try End Function + + Private Function ReadPlain(pFilePath As String) As Byte() + Using oFileStream As New FileStream(pFilePath, FileMode.Open, FileAccess.Read, FileShare.Read) + Using oMemoryStream As New MemoryStream() + oFileStream.CopyTo(oMemoryStream) + Return oMemoryStream.ToArray() + End Using + End Using + End Function End Class End Namespace \ No newline at end of file diff --git a/Service.EDMIService/Methods/IDB/NewFile/NewFileMethod.vb b/Service.EDMIService/Methods/IDB/NewFile/NewFileMethod.vb index 98fe1a49..9c38046a 100644 --- a/Service.EDMIService/Methods/IDB/NewFile/NewFileMethod.vb +++ b/Service.EDMIService/Methods/IDB/NewFile/NewFileMethod.vb @@ -3,6 +3,7 @@ Imports DigitalData.Modules.Base.IDB.Constants Imports DigitalData.Modules.Database Imports DigitalData.Modules.Database.MSSQLServer.TransactionMode Imports DigitalData.Modules.Logging +Imports DigitalData.Services.EDMIService.Security Namespace Methods.IDB.NewFile Public Class NewFileMethod @@ -22,6 +23,197 @@ Namespace Methods.IDB.NewFile Logger.Debug("Running [NewFileMethod].") Dim oFilePath As String = Nothing + Try + If pData.File Is Nothing Then + Throw New ArgumentNullException(NameOf(pData.File)) + End If + + If pData.KindType Is Nothing Then + Throw New ArgumentNullException(NameOf(pData.KindType)) + End If + + If pData.StoreName Is Nothing Then + Throw New ArgumentNullException(NameOf(pData.StoreName)) + End If + + If pData.User Is Nothing Then + Throw New ArgumentNullException(NameOf(pData.User)) + End If + + If IsNothing(pData.IDBDoctypeId) Then + Throw New ArgumentNullException(NameOf(pData.IDBDoctypeId)) + End If + + Logger.Debug("Checking if checksum already exists..") + Dim oExistingObjectId = Helpers.TestFileChecksumExists(pData.File.FileChecksum) + If oExistingObjectId > 0 Then + Return New NewFileResponse(oExistingObjectId) + End If + + Logger.Debug("Creating New ObjectId..") + Dim oObjectId = Helpers.NewObjectIdWithTransaction(pData.KindType, pData.User.UserName, Connection, Transaction) + If oObjectId = 0 Then + LogAndThrow("Could not create new ObjectId!") + End If + Logger.Debug("New ObjectId [{0}] created!", oObjectId) + + ' Find ObjectStore by Title + Logger.Debug("Checking for DataStore [{0}].", pData.StoreName) + Dim oStore = GlobalState.ObjectStores. + Where(Function(store) store.Title = pData.StoreName). + SingleOrDefault() + + If oStore Is Nothing Then + LogAndThrow($"DataStore [{pData.StoreName}] does not exist. Exiting.") + End If + Logger.Debug("Using DataStore [{0}].", pData.StoreName) + + ' Get Store base and final path + Logger.Debug("Store BasePath is [{0}]", oStore.Path) + Dim oFinalPath = Helpers.GetFileObjectPath(oStore, pData.File.FileImportedAt) + + ' Ensure target directory exists + Try + If Not IO.Directory.Exists(oFinalPath) Then + IO.Directory.CreateDirectory(oFinalPath) + End If + Catch exDir As Exception + LogAndThrow(exDir, $"Target directory [{oFinalPath}] could not be created.") + End Try + + ' Get filename + Dim oKeepFileName As Boolean = False + If oStore.IsArchive Then + Logger.Debug("Object Store is an archive: [{0}]", oStore.IsArchive) + oKeepFileName = True + End If + + Dim oFileName As String = GetFileObjectFileName(oObjectId, pData.File.FileName, oKeepFileName) + Logger.Debug("Filename is [{0}]", oFileName) + + oFilePath = IO.Path.Combine(oFinalPath, oFileName) + Dim oFileObjectInfo As IO.FileInfo = New IO.FileInfo(oFilePath) + + Dim oFileObjectName As String = oFileObjectInfo.Name + Logger.Debug("File Information for [{0}]:", oFileObjectName) + + Dim oFileObjectSize As Long = pData.File.FileContents.Length ' original (plaintext) size + Logger.Debug("Original Size: [{0}]", oFileObjectSize) + + Dim oOriginalExtension As String = pData.File.FileInfoRaw.Extension.Substring(1) + Logger.Debug("Original Extension: [{0}]", oOriginalExtension) + + Logger.Debug("Checksum: [{0}]", pData.File.FileChecksum) + + ' Retrieve encryption password (environment variable) + Dim encryptionPassword As String = Environment.GetEnvironmentVariable("DD_FILE_ENCRYPTION_PASSWORD") + If String.IsNullOrWhiteSpace(encryptionPassword) Then + LogAndThrow("Encryption password not configured (env DD_FILE_ENCRYPTION_PASSWORD).") + End If + + ' Perform encryption with strict failure handling + Try + Logger.Info("Encrypting and saving file to path [{0}]", oFilePath) + SecureFileHandler.EncryptFileFromBytes(pData.File.FileContents, oFilePath, encryptionPassword) + Catch exEnc As Exception + LogAndThrow(exEnc, $"Could not encrypt/write file [{oFilePath}] to disk!") + End Try + + ' Post-encryption validation: file must exist and contain at least header bytes + Try + Dim fi As New IO.FileInfo(oFilePath) + If Not fi.Exists Then + LogAndThrow($"Encrypted file was not created at [{oFilePath}].") + End If + ' Minimum file size:1 (version) +4 (iterations) +32 (salt) =37 bytes + If fi.Length < 37 Then + LogAndThrow($"Encrypted file at [{oFilePath}] is invalid or truncated (size {fi.Length}).") + End If + Logger.Debug("Encrypted physical file size: [{0}]", fi.Length) + Catch exVal As Exception + ' LogAndThrow above will throw; any other IO errors should also abort here + LogAndThrow(exVal, "Encrypted file validation failed.") + End Try + + '--------------------------------------------------------------------------- + + Logger.Info("Creating IDB FileObject for ObjectId [{0}].", oObjectId) + ' Insert into DB (store original plaintext size for consistency) + Dim oSQL As String = $"EXEC PRIDB_NEW_IDBFO + '{oFinalPath}', + '{oFileObjectName}', + '{oOriginalExtension}', + {oFileObjectSize}, + '{pData.File.FileChecksum}' , + '{pData.User.UserName}', + '{oObjectId}', + {oStore.Id}, + {pData.IDBDoctypeId}" + + Dim oResult As Boolean = DatabaseIDB.ExecuteNonQueryWithConnectionObject(oSQL, Connection, ExternalTransaction, Transaction) + + If oResult = False Then + LogAndThrow("IDB FileObject could not be created!") + End If + + '--------------------------------------------------------------------------- + + Dim oSystemAttributes As New Dictionary(Of String, Object) From { + {Attributes.ATTRIBUTE_ORIGIN_FILENAME, pData.File.FileName}, + {Attributes.ATTRIBUTE_ORIGIN_CREATED, pData.File.FileCreatedAt}, + {Attributes.ATTRIBUTE_ORIGIN_CHANGED, pData.File.FileChangedAt} + } + + For Each oAttribute As KeyValuePair(Of String, Object) In oSystemAttributes + Try + ' Dont write empty attributes + If oAttribute.Value Is Nothing Then + Continue For + End If + + Dim oSuccess = Helpers.SetAttributeValueWithTransaction(Connection, Transaction, oObjectId, oAttribute.Key, oAttribute.Value, pData.User.Language, pData.User.UserName) + If oSuccess Then + Logger.Debug("System Attribute [{0}] written with value [{1}]", oAttribute.Key, oAttribute.Value) + Else + Logger.Warn("System attribute value could not be written") + End If + Catch ex As Exception + LogAndThrow(ex, $"System attribute [{oAttribute.Key}] could not be written!") + End Try + Next + + '--------------------------------------------------------------------------- + + ' Finally, commit the transaction + Transaction?.Commit() + + Return New NewFileResponse(oObjectId) + + Catch ex As Exception + Logger.Warn("Error occurred while creating file!") + Logger.Error(ex) + + Logger.Info("Cleaning up files.") + If Not IsNothing(oFilePath) AndAlso IO.File.Exists(oFilePath) Then + Try + IO.File.Delete(oFilePath) + Catch exInner As Exception + Logger.Warn("Error while cleaning up files.") + Logger.Error(exInner) + End Try + End If + + Logger.Info("Rolling back transaction.") + Transaction?.Rollback() + + Return New NewFileResponse(ex) + + End Try + End Function + Public Function Run_Old(pData As NewFileRequest) As NewFileResponse + Logger.Debug("Running [NewFileMethod Old].") + Dim oFilePath As String = Nothing + Try If pData.File Is Nothing Then Throw New ArgumentNullException(NameOf(pData.File)) @@ -181,7 +373,6 @@ Namespace Methods.IDB.NewFile End Try End Function - Private Function GetFileObjectFileName(IDB_OBJ_ID As Long, pFilename As String, pKeepFilename As Boolean) As String ' TODO: save actual extensions If pKeepFilename Then diff --git a/Service.EDMIService/Security/SecureFileHandler.vb b/Service.EDMIService/Security/SecureFileHandler.vb new file mode 100644 index 00000000..cc4f470f --- /dev/null +++ b/Service.EDMIService/Security/SecureFileHandler.vb @@ -0,0 +1,146 @@ +Imports System.IO +Imports System.Security.Cryptography + +Namespace Security + ''' + ''' Provides secure AES file encryption and decryption using PBKDF2 (Rfc2898DeriveBytes) for key derivation. + ''' File format: + ''' [1 byte Version][4 bytes IterationCount (Int32, big-endian)][32 bytes Salt][Encrypted Payload] + ''' + Public NotInheritable Class SecureFileHandler + Private Sub New() + End Sub + + Private Const CURRENT_VERSION As Byte = 1 + Private Const SALT_LENGTH As Integer = 32 + Private Const KEY_SIZE_BYTES As Integer = 32 ' AES-256 + Private Const IV_SIZE_BYTES As Integer = 16 ' AES Block size (128 bit) + Private Const DEFAULT_ITERATIONS As Integer = 100000 + Private Const BUFFER_SIZE As Integer = 81920 '80KB streaming buffer + + ''' + ''' Encrypts the provided byte array and writes an encrypted file to the target path using streaming. + ''' + Public Shared Sub EncryptFileFromBytes(sourceData() As Byte, targetFilePath As String, password As String, Optional iterations As Integer = DEFAULT_ITERATIONS) + If sourceData Is Nothing Then Throw New ArgumentNullException(NameOf(sourceData)) + If String.IsNullOrWhiteSpace(password) Then Throw New ArgumentNullException(NameOf(password)) + Using fsOut = New FileStream(targetFilePath, FileMode.Create, FileAccess.Write, FileShare.None) + Dim salt = GenerateRandomBytes(SALT_LENGTH) + + ' Write header: Version, Iterations, Salt + fsOut.WriteByte(CURRENT_VERSION) + WriteInt32BigEndian(fsOut, iterations) + fsOut.Write(salt, 0, salt.Length) + + Using keyDerivation = New Rfc2898DeriveBytes(password, salt, iterations) + Dim key = keyDerivation.GetBytes(KEY_SIZE_BYTES) + Dim iv = keyDerivation.GetBytes(IV_SIZE_BYTES) + + Dim aesAlg As System.Security.Cryptography.Aes = System.Security.Cryptography.Aes.Create() + Try + aesAlg.KeySize = KEY_SIZE_BYTES * 8 + aesAlg.BlockSize = IV_SIZE_BYTES * 8 + aesAlg.Mode = CipherMode.CBC + aesAlg.Padding = PaddingMode.PKCS7 + aesAlg.Key = key + aesAlg.IV = iv + + Using crypto = aesAlg.CreateEncryptor() + Using cs = New CryptoStream(fsOut, crypto, CryptoStreamMode.Write) + Using msIn = New MemoryStream(sourceData, writable:=False) + Dim buffer(BUFFER_SIZE - 1) As Byte + Dim read As Integer + Do + read = msIn.Read(buffer, 0, buffer.Length) + If read <= 0 Then Exit Do + cs.Write(buffer, 0, read) + Loop + End Using + cs.FlushFinalBlock() + End Using + End Using + Finally + aesAlg.Dispose() + End Try + End Using + End Using + End Sub + + ''' + ''' Decrypts the encrypted file and returns the plaintext bytes. + ''' + Public Shared Function DecryptFileToBytes(encryptedFilePath As String, password As String) As Byte() + If String.IsNullOrWhiteSpace(encryptedFilePath) Then Throw New ArgumentNullException(NameOf(encryptedFilePath)) + If String.IsNullOrWhiteSpace(password) Then Throw New ArgumentNullException(NameOf(password)) + Using fsIn = New FileStream(encryptedFilePath, FileMode.Open, FileAccess.Read, FileShare.Read) + Dim version = CByte(fsIn.ReadByte()) + If version <> CURRENT_VERSION Then Throw New InvalidDataException("Unsupported file version.") + Dim iterations = ReadInt32BigEndian(fsIn) + Dim salt = New Byte(SALT_LENGTH - 1) {} + ReadExact(fsIn, salt, 0, salt.Length) + + Using keyDerivation = New Rfc2898DeriveBytes(password, salt, iterations) + Dim key = keyDerivation.GetBytes(KEY_SIZE_BYTES) + Dim iv = keyDerivation.GetBytes(IV_SIZE_BYTES) + + Dim aesAlg As System.Security.Cryptography.Aes = System.Security.Cryptography.Aes.Create() + Try + aesAlg.KeySize = KEY_SIZE_BYTES * 8 + aesAlg.BlockSize = IV_SIZE_BYTES * 8 + aesAlg.Mode = CipherMode.CBC + aesAlg.Padding = PaddingMode.PKCS7 + aesAlg.Key = key + aesAlg.IV = iv + + Using crypto = aesAlg.CreateDecryptor() + Using cs = New CryptoStream(fsIn, crypto, CryptoStreamMode.Read) + Using msOut = New MemoryStream() + Dim buffer(BUFFER_SIZE - 1) As Byte + Dim read As Integer + Do + read = cs.Read(buffer, 0, buffer.Length) + If read <= 0 Then Exit Do + msOut.Write(buffer, 0, read) + Loop + Return msOut.ToArray() + End Using + End Using + End Using + Finally + aesAlg.Dispose() + End Try + End Using + End Using + End Function + + Private Shared Function GenerateRandomBytes(length As Integer) As Byte() + Dim data = New Byte(length - 1) {} + Using rng = RandomNumberGenerator.Create() + rng.GetBytes(data) + End Using + Return data + End Function + + Private Shared Sub WriteInt32BigEndian(stream As Stream, value As Integer) + Dim bytes = BitConverter.GetBytes(value) + If BitConverter.IsLittleEndian Then Array.Reverse(bytes) + stream.Write(bytes, 0, bytes.Length) + End Sub + + Private Shared Function ReadInt32BigEndian(stream As Stream) As Integer + Dim bytes = New Byte(3) {} + ReadExact(stream, bytes, 0, 4) + If BitConverter.IsLittleEndian Then Array.Reverse(bytes) + Return BitConverter.ToInt32(bytes, 0) + End Function + + Private Shared Sub ReadExact(stream As Stream, buffer As Byte(), offset As Integer, count As Integer) + Dim totalRead As Integer = 0 + While totalRead < count + Dim read = stream.Read(buffer, offset + totalRead, count - totalRead) + If read <= 0 Then Throw New EndOfStreamException("Unexpected end of stream.") + totalRead += read + End While + End Sub + End Class +End Namespace