Imports System.ComponentModel Imports System.IdentityModel.Metadata Imports System.IO Imports System.Text Imports DevExpress.LookAndFeel Imports DevExpress.Utils.Extensions Imports DevExpress.XtraCharts Imports DevExpress.XtraGrid Imports DevExpress.XtraGrid.Views.Grid Imports DevExpress.XtraPrinting Imports DevExpress.XtraSplashScreen Imports DigitalData.GUIs.Common Imports DigitalData.Modules.Base Imports DigitalData.Modules.Logging Imports EnvelopeGenerator.CommonServices Imports EnvelopeGenerator.CommonServices.My Imports EnvelopeGenerator.Domain.Entities Public Class frmMain Private ReadOnly LogConfig As LogConfig Private ReadOnly Logger As Logger Private TempFiles As TempFiles Private GridBuilder As GridBuilder Private RefreshHelper As RefreshHelper Private State As State Private Controller As EnvelopeListController Private myFileData As Byte() Private myResFileData As Byte() Private FormLoad As Boolean = True Public Sub New(pState As State) ' Dieser Aufruf ist für den Designer erforderlich. InitializeComponent() ' Fügen Sie Initialisierungen nach dem InitializeComponent()-Aufruf hinzu. State = pState LogConfig = pState.LogConfig Logger = LogConfig.GetLogger() End Sub Private Sub frmMain_Load(sender As Object, e As EventArgs) Handles MyBase.Load Text = $"{State.DbConfig.ExternalProgramName} - {Resources.Envelope.Envelope_Overview}" TempFiles = New TempFiles(LogConfig) TempFiles.Create() MyTempFiles = TempFiles RefreshHelper = New RefreshHelper(ViewEnvelopes, "Id") Controller = New EnvelopeListController(State) Try Me.LookAndFeel.UseDefaultLookAndFeel = False LookAndFeel.SetSkinStyle(SkinStyle.Office2019White, SkinSvgPalette.DefaultSkin) Catch ex As Exception End Try If MYUSER.IsAdmin Then XtraTabControlMain.TabPages(2).PageVisible = True XtraTabControlMain.TabPages(3).PageVisible = True Else XtraTabControlMain.TabPages(2).PageVisible = False XtraTabControlMain.TabPages(3).PageVisible = False End If LoadEnvelopeData() Dim oXMLPath = Get_DocGrid_Layout_Filename(ViewEnvelopes.Name) If File.Exists(oXMLPath) Then ViewEnvelopes.RestoreLayoutFromXml(oXMLPath) End If End Sub Private Sub LoadEnvelopeData() Try RefreshHelper.SaveViewInfo() If XtraTabControlMain.SelectedTabPageIndex = 0 Then LoadEnvelopes() ElseIf XtraTabControlMain.SelectedTabPageIndex = 1 Then LoadCompletedEnvelopes() End If RefreshHelper.LoadViewInfo() 'LoadCharts() txtRefreshLabel.Caption = String.Format(txtRefreshLabel.Tag, Now) Catch ex As Exception Logger.Error(ex) End Try End Sub Private Sub LoadEnvelopes() Try GridBuilder = New GridBuilder(ViewEnvelopes) GridBuilder.SetReadOnlyOptions(ViewEnvelopes) GridBuilder.SetReadOnlyOptions(ViewHistory) GridBuilder.SetDefaults(ViewHistory) GridEnvelopes.DataSource = Controller.ListEnvelopes() If ViewEnvelopes.RowCount = 0 Then RibbonPageGroupFunctions.Enabled = False btnDeleteEnvelope.Visibility = DevExpress.XtraBars.BarItemVisibility.Never btnEditEnvelope.Enabled = False Else RibbonPageGroupFunctions.Enabled = True btnDeleteEnvelope.Visibility = DevExpress.XtraBars.BarItemVisibility.Always btnEditEnvelope.Enabled = True End If Catch ex As Exception Logger.Error(ex) End Try End Sub Private Sub LoadCompletedEnvelopes() Try GridBuilder = New GridBuilder(ViewCompleted) GridBuilder.SetReadOnlyOptions(ViewCompleted) GridBuilder.SetReadOnlyOptions(ViewHistoryCompleted) GridBuilder.SetDefaults(ViewHistoryCompleted) GridCompleted.DataSource = Controller.ListCompleted() Catch ex As Exception Logger.Error(ex) End Try End Sub Private Sub LoadCharts() Dim oChartControl As ChartControl = Controller.GetPieChart() Me.SplitContainerControl1.Panel2.AddControl(oChartControl) End Sub Private Sub btnCreateEnvelope_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnCreateEnvelope.ItemClick Dim oHandle = SplashScreenManager.ShowOverlayForm(Me) Try Dim oForm As New frmEnvelopeEditor() With {.State = State} oForm.ShowDialog() LoadEnvelopeData() Catch ex As Exception Logger.Error(ex) Finally SplashScreenManager.CloseOverlayForm(oHandle) End Try End Sub Private Sub btnEditEnvelope_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnEditEnvelope.ItemClick Dim oSelectedRows = ViewEnvelopes.GetSelectedRows() If oSelectedRows.Count > 0 Then LoadEnvelope(oSelectedRows.First) End If End Sub Private Sub LoadEnvelope(pRowHandle As Integer) Dim oHandle = SplashScreenManager.ShowOverlayForm(Me) Try Dim oEnvelope As Envelope = DirectCast(ViewEnvelopes.GetRow(pRowHandle), Envelope) If oEnvelope.IsAlreadySent Then Exit Sub End If Dim oForm As New frmEnvelopeEditor() With {.State = State, .Envelope = oEnvelope} oForm.ShowDialog() LoadEnvelopeData() Catch ex As Exception Logger.Error(ex) Finally SplashScreenManager.CloseOverlayForm(oHandle) End Try End Sub Private Sub DeleteEnvelope(pRowHandle As Integer, pReason As String) Dim oEnvelope As Envelope = ViewEnvelopes.GetRow(pRowHandle) 'If MsgBox(Resources.Envelope.Do_you_really_want_to_delete_this_envelope, MsgBoxStyle.Question Or MsgBoxStyle.YesNo, Text) = MsgBoxResult.No Then ' Exit Sub 'End If If Controller.DeleteEnvelope(oEnvelope, pReason) Then LoadEnvelopeData() Else MsgBox(Resources.Envelope.The_envelope_could_not_be_deleted, MsgBoxStyle.Critical, Text) End If End Sub Private Sub ViewEnvelopes_DoubleClick(sender As Object, e As EventArgs) Handles ViewEnvelopes.DoubleClick Dim oSelectedRows = ViewEnvelopes.GetSelectedRows() If oSelectedRows.Count > 0 Then LoadEnvelope(oSelectedRows.First) End If End Sub Private Sub btnDeleteEnvelope_ItemClick_1(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnDeleteEnvelope.ItemClick Try Dim oSelectedRows = ViewEnvelopes.GetSelectedRows() Dim oEnvelope As Envelope = DirectCast(ViewEnvelopes.GetRow(oSelectedRows.First), Envelope) If oSelectedRows.Count > 0 Then CurrentEnvelopID = oEnvelope.Id CurrentEnvelopetitle = oEnvelope.Title Dim ofrmAbort As New frmRueckruf frmRueckruf.ShowDialog() If frmRueckruf.Continue_Reject = True Then DeleteEnvelope(oSelectedRows.First, frmRueckruf.Reject_reason) End If End If Catch ex As Exception MsgBox(ex.Message, MsgBoxStyle.Critical) End Try End Sub Private Sub frmMain_FormClosing(sender As Object, e As FormClosingEventArgs) Handles MyBase.FormClosing ' Cleanup Methods TempFiles.CleanUp() End Sub Private Sub XtraTabControl1_SelectedPageChanged(sender As Object, e As DevExpress.XtraTab.TabPageChangedEventArgs) Handles XtraTabControlMain.SelectedPageChanged Dim oHandle = SplashScreenManager.ShowOverlayForm(Me) Try RibbonPageGroupFunctions.Enabled = True RibbonPageEnvelopeActions.Enabled = True Select Case XtraTabControlMain.SelectedTabPageIndex Case 1 RibbonPageGroupReceiver.Visible = False btnEditEnvelope.Enabled = False btnDeleteEnvelope.Enabled = False btnContactReceiver.Enabled = False btnShowDocument.Enabled = False bbtnitm_ResendInvitation.Enabled = False bbtnitmInfoMail.Enabled = False bbtnitmEB.Enabled = True bbtnitm2Faktor.Enabled = False LoadEnvelopeData() Dim oXMLPath = Get_DocGrid_Layout_Filename(ViewCompleted.Name) If File.Exists(oXMLPath) Then ViewCompleted.RestoreLayoutFromXml(oXMLPath) End If Case 0 RibbonPageGroupReceiver.Visible = True btnEditEnvelope.Enabled = True btnDeleteEnvelope.Enabled = True btnContactReceiver.Enabled = True btnShowDocument.Enabled = True bbtnitm_ResendInvitation.Enabled = True bbtnitmInfoMail.Enabled = True bbtnitm2Faktor.Enabled = True bbtnitmEB.Enabled = False LoadEnvelopeData() txtEnvelopeIdLabel.Caption = "No Envelope selected" Case 2 RibbonPageGroupFunctions.Enabled = False RibbonPageEnvelopeActions.Enabled = False End Select Catch ex As Exception Logger.Error(ex) Finally SplashScreenManager.CloseOverlayForm(oHandle) End Try End Sub Private Sub BarButtonItem1_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem1.ItemClick LoadEnvelopeData() End Sub Private Sub ViewEnvelopes_FocusedRowChanged(sender As Object, e As DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs) Handles ViewEnvelopes.FocusedRowChanged If ViewEnvelopes.FocusedRowHandle < 0 Then Exit Sub End If Dim oEnvelope As Envelope = ViewEnvelopes.GetRow(ViewEnvelopes.FocusedRowHandle) txtEnvelopeIdLabel.Caption = String.Format(txtEnvelopeIdLabel.Tag, oEnvelope.Id) If oEnvelope.IsAlreadySent Then btnEditEnvelope.Enabled = False Else btnEditEnvelope.Enabled = True End If End Sub Private Sub bbtnitmEB_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles bbtnitmEB.ItemClick Try If IsNothing(ViewEnvelopes.FocusedRowHandle) Then bsitmInfo.Caption = "No row selected" Exit Sub End If bsitmInfo.Caption = "" Me.Cursor = Cursors.WaitCursor Dim oEnvelope As Envelope = ViewCompleted.GetRow(ViewCompleted.FocusedRowHandle) GetResRepFileStreamByte(oEnvelope.Id) Dim oTempFolder = TempFiles._TempPath If Not Directory.Exists(oTempFolder) Then Directory.CreateDirectory(oTempFolder) End If Dim oFilename = "ViewEnvResReport" Dim oVersion As Integer = 0 Dim oTempFilename = String.Concat(oTempFolder, "\", $"{oFilename}_{oEnvelope.Id}.pdf") Do While File.Exists(oTempFilename) oVersion += 1 oTempFilename = String.Concat(oTempFolder, "\", $"{oFilename}_{oEnvelope.Id}_", oVersion.ToString, ".pdf") Loop downloadResFile(oTempFilename) Catch ex As Exception MsgBox(ex.Message, MsgBoxStyle.Exclamation) End Try Me.Cursor = Cursors.Default End Sub Private Sub ViewEnvelopes_CustomDrawCell(sender As Object, e As DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs) Handles ViewEnvelopes.CustomDrawCell If e.RowHandle < 0 Or XtraTabControlMain.SelectedTabPageIndex = 1 Then Exit Sub End If Dim oEnvelope As Envelope = ViewEnvelopes.GetRow(e.RowHandle) If oEnvelope.Status = Domain.Constants.EnvelopeStatus.EnvelopePartlySigned Then e.Appearance.BackColor = ColorTranslator.FromHtml(Domain.Constants.GREEN_300) End If If oEnvelope.Status = Domain.Constants.EnvelopeStatus.EnvelopeQueued Or oEnvelope.Status = Domain.Constants.EnvelopeStatus.EnvelopeSent Then e.Appearance.BackColor = ColorTranslator.FromHtml(Domain.Constants.ORANGE_300) End If End Sub Private Sub ViewReceivers_CustomDrawCell(sender As Object, e As DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs) Handles ViewReceivers.CustomDrawCell If e.RowHandle < 0 Then Exit Sub End If Dim oView As GridView = DirectCast(sender, GridView) Dim oReceiver As Receiver = oView.GetRow(e.RowHandle) If (oReceiver Is Nothing) Then Exit Sub End If If oReceiver.Status = Domain.Constants.ReceiverStatus.Signed Then e.Appearance.BackColor = ColorTranslator.FromHtml(Domain.Constants.GREEN_300) Else e.Appearance.BackColor = ColorTranslator.FromHtml(Domain.Constants.RED_300) End If End Sub Private Sub ViewCompleted_CustomDrawCell(sender As Object, e As Views.Base.RowCellCustomDrawEventArgs) Handles ViewCompleted.CustomDrawCell If e.RowHandle < 0 Then Exit Sub End If Dim oEnvelope As Envelope = ViewCompleted.GetRow(e.RowHandle) If oEnvelope.Status = Domain.Constants.EnvelopeStatus.EnvelopeCompletelySigned Then e.Appearance.BackColor = ColorTranslator.FromHtml(Domain.Constants.GREEN_300) End If If oEnvelope.Status = Domain.Constants.EnvelopeStatus.EnvelopeDeleted Or oEnvelope.Status = Domain.Constants.EnvelopeStatus.EnvelopeWithdrawn Or oEnvelope.Status = Domain.Constants.EnvelopeStatus.EnvelopeRejected Then e.Appearance.BackColor = ColorTranslator.FromHtml(Domain.Constants.RED_300) End If End Sub Private Sub ViewReceiversCompleted_CustomDrawCell(sender As Object, e As Views.Base.RowCellCustomDrawEventArgs) Handles ViewReceiversCompleted.CustomDrawCell If e.RowHandle < 0 Then Exit Sub End If Dim oView As GridView = DirectCast(sender, GridView) Dim oReceiver As Receiver = oView.GetRow(e.RowHandle) If (oReceiver Is Nothing) Then Exit Sub End If If oReceiver.Status = Domain.Constants.ReceiverStatus.Signed Then e.Appearance.BackColor = ColorTranslator.FromHtml(Domain.Constants.GREEN_300) Else e.Appearance.BackColor = ColorTranslator.FromHtml(Domain.Constants.RED_300) End If End Sub Private Sub RefreshTimer_Tick(sender As Object, e As EventArgs) Handles RefreshTimer.Tick Try If Application.OpenForms.OfType(Of frmEnvelopeEditor).Any = False Then LoadEnvelopeData() End If Catch ex As Exception Logger.Error(ex) End Try End Sub Private Sub btnContactReceiver_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnContactReceiver.ItemClick If ViewEnvelopes.FocusedRowHandle < 0 Then Exit Sub End If Dim oEnvelope As Envelope = ViewEnvelopes.GetRow(ViewEnvelopes.FocusedRowHandle) Dim oView As GridView = GridEnvelopes.FocusedView If oView.Name = ViewReceivers.Name Then Dim oReceiver As Receiver = oView.GetRow(oView.FocusedRowHandle) Dim oEnvelopeTitle As String = Net.WebUtility.UrlEncode(oEnvelope.Title) Process.Start($"mailto:{oReceiver.EmailAddress}?subject={oEnvelopeTitle}") Else MsgBox(Resources.Envelope.Please_select_a_recipient_from_the_Recipients_tab, MsgBoxStyle.Information, Text) End If End Sub Private Sub btnShowDocument_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnShowDocument.ItemClick Try If ViewEnvelopes.FocusedRowHandle < 0 Then Exit Sub End If Me.Cursor = Cursors.WaitCursor Dim oEnvelope As Envelope = ViewEnvelopes.GetRow(ViewEnvelopes.FocusedRowHandle) Dim oDocument = oEnvelope.Documents.FirstOrDefault() If oDocument Is Nothing Then MsgBox(Resources.Envelope.The_envelope_does_not_contain_any_documents, MsgBoxStyle.Exclamation, Text) Me.Cursor = Cursors.Default Exit Sub Else If Not IsNothing(oDocument.ByteData) Then Dim oTempFolder = TempFiles._TempPath Dim oTempFilename = String.Concat(oTempFolder, "\", $"ViewEnvDoc_{oEnvelope.Id}.pdf") If File.Exists(oTempFilename) Then Try File.OpenWrite(oTempFilename) Catch ex As Exception MsgBox("File might already be open?", MsgBoxStyle.Exclamation) Me.Cursor = Cursors.Default Exit Sub End Try File.Delete(oTempFilename) End If downloadFile(oTempFilename, oDocument.ByteData) End If End If Catch ex As Exception MsgBox(Resources.Envelope.Document_could_not_be_opened, MsgBoxStyle.Critical, Text) Logger.Error(ex) End Try Me.Cursor = Cursors.Default End Sub Private Sub GetResRepFileStreamByte(ByVal pEnvID As Long) Dim strSql As String 'For Document Try 'Get image data from gridview column. strSql = "Select [DOC_RESULT] from [TBSIG_ENVELOPE] WHERE GUID = " & pEnvID Dim obyteDB = DB_DD_ECM.GetScalarValue(strSql) If Not IsDBNull(obyteDB) Then 'Get image data from DB Dim fileData As Byte() = DirectCast(DB_DD_ECM.GetScalarValue(strSql), Byte()) If Not fileData Is Nothing Then myResFileData = fileData Else bsitmInfo.Caption = "FileStream 1 is nothing - check data!" myResFileData = Nothing End If Else myResFileData = Nothing bsitmInfo.Caption = "FileStream 2 is nothing - check data!" End If Catch ex As Exception MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Error in GetResRepFileStreamByte") myResFileData = Nothing End Try End Sub Private Sub downloadFile(ByVal sFileName As String, pByte As Byte()) 'For Document Try If Not pByte Is Nothing Then 'Read image data into a file stream Using fs As New FileStream(sFileName, FileMode.OpenOrCreate, FileAccess.Write) fs.Write(pByte, 0, pByte.Length) 'Set image variable value using memory stream. fs.Flush() fs.Close() End Using 'Open File Process.Start(sFileName) End If Catch ex As Exception MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Error in downloadFile") End Try End Sub Private Sub downloadResFile(ByVal sFileName As String) Try If Not myResFileData Is Nothing Then Logger.Debug("working myResFileData in downloadResFile") 'Read image data into a file stream Using fs As New FileStream(sFileName, FileMode.OpenOrCreate, FileAccess.Write) fs.Write(myResFileData, 0, myResFileData.Length) 'Set image variable value using memory stream. fs.Flush() fs.Close() End Using Logger.Debug($"Trying to open {sFileName}...") 'Open File Process.Start(sFileName) Else MsgBox("Could not get DocData from Database!", MsgBoxStyle.Exclamation, "Error in downloadResFile") End If Catch ex As Exception MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Error in downloadResFile") End Try End Sub Private Sub ViewCompleted_FocusedRowChanged(sender As Object, e As Views.Base.FocusedRowChangedEventArgs) Handles ViewCompleted.FocusedRowChanged If ViewCompleted.FocusedRowHandle < 0 Then Exit Sub End If Dim oEnvelope As Envelope = ViewCompleted.GetRow(ViewCompleted.FocusedRowHandle) If oEnvelope.Status = Domain.Constants.EnvelopeStatus.EnvelopeArchived Then bbtnitmEB.Enabled = True Else bbtnitmEB.Enabled = False End If txtEnvelopeIdLabel.Caption = String.Format(txtEnvelopeIdLabel.Tag, oEnvelope.Id) End Sub Private Sub btnOpenLogDirectory_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnOpenLogDirectory.ItemClick Try Process.Start(LogConfig.LogDirectory) Catch ex As Exception Logger.Error(ex) End Try End Sub Private Sub BarCheckItem1_CheckedChanged(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarCheckItem1.CheckedChanged If BarCheckItem1.Checked = True Then If CurrLogConfig.Debug = False Then CurrLogConfig.Debug = True bsitmInfo.Caption = "DEBUG-Log is active" bsitmInfo.Visibility = DevExpress.XtraBars.BarItemVisibility.Always End If Else CurrLogConfig.Debug = False bsitmInfo.Visibility = DevExpress.XtraBars.BarItemVisibility.Never End If End Sub Private Sub frmMain_Shown(sender As Object, e As EventArgs) Handles MyBase.Shown If CurrLogConfig.Debug Then BarCheckItem1.Checked = True Else BarCheckItem1.Checked = False End If bbtnitmEB.Enabled = False RefreshTimer.Start() If USER_GHOST_MODE_ACTIVE Or MYUSER.GhostModeActive Then frmGhostMode.ShowDialog() If USER_GHOST_MODE_USRNAME <> "" Then MyUserModel = New UserModel(MyState) MyState.UserId = MyUserModel.SelectUserId(USER_GHOST_MODE_USRNAME) Dim oUser = MyUserModel.SelectUser() If oUser IsNot Nothing Then MyUserModel.CheckUserLogin(oUser) BarStaticItemGhost.Caption = $"GhostMode active: {USER_GHOST_MODE_USRNAME} - End signFLOW to quit ghost-mode" Me.Text = $"GhostMode active: {USER_GHOST_MODE_USRNAME} - End signFLOW to quit ghost - mode" BarStaticItemGhost.Visibility = DevExpress.XtraBars.BarItemVisibility.Always LoadEnvelopeData() End If MYUSER = oUser End If End If FormLoad = False End Sub Private Sub bbtnitmInfoMail_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles bbtnitmInfoMail.ItemClick If ViewEnvelopes.FocusedRowHandle < 0 Then Exit Sub End If Try Dim oEnvelope As Envelope = ViewEnvelopes.GetRow(ViewEnvelopes.FocusedRowHandle) Dim oView As GridView = GridEnvelopes.FocusedView If oView.Name = ViewReceivers.Name Then Dim oReceiver As Receiver = oView.GetRow(oView.FocusedRowHandle) Dim mailto As String = "mailto:support-flow@digitaldata.works" Dim subject As String = Uri.EscapeDataString("signFLOW - Envelope issue - ID: " & oEnvelope.Id) Dim body As String = Uri.EscapeDataString($"Dear Digital Data Team," & vbCrLf & "There is an error or misbehavin with following envelope and Receiver:" & vbCrLf & $"Envelope-ID:{oEnvelope.Id}" & vbCrLf & $"Receiver: {oReceiver.EmailAddress}" & vbCrLf & "Issue/Description: Please describe the issue in Your own words...") Dim mailtoUri As String = $"{mailto}?subject={subject}&body={body}" Dim psi As New ProcessStartInfo(mailtoUri) psi.UseShellExecute = True Try Process.Start(psi) Catch ex As Exception MessageBox.Show("Error in creating mailto-Object: " & ex.Message) End Try Else MsgBox(Resources.Envelope.Please_select_a_recipient_from_the_Recipients_tab, MsgBoxStyle.Information, Text) End If Catch ex As Exception MsgBox(ex.Message, MsgBoxStyle.Critical, Text) End Try End Sub Private Sub BarButtonItem2_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles bbtnitm_ResendInvitation.ItemClick Dim oHandle = SplashScreenManager.ShowOverlayForm(Me) Try Dim oView As GridView = GridEnvelopes.FocusedView Dim selReceiver As Receiver If oView.Name = ViewReceivers.Name Then selReceiver = oView.GetRow(oView.FocusedRowHandle) Else MsgBox(Resources.Envelope.Please_select_a_recipient_from_the_Recipients_tab, MsgBoxStyle.Information, Text) End If If ViewEnvelopes.FocusedRowHandle < 0 Or IsNothing(selReceiver) Then Exit Sub End If Dim oEnvelope As Envelope = ViewEnvelopes.GetRow(ViewEnvelopes.FocusedRowHandle) Dim oController = New EnvelopeEditorController(State, oEnvelope) Dim Documents As New BindingList(Of EnvelopeDocument) Dim Receivers As New BindingList(Of Receiver) Receivers = New BindingList(Of Receiver)(oController.Envelope.Receivers) For Each oReceiver As Receiver In Receivers If oReceiver.EmailAddress = selReceiver.EmailAddress Then If oController.ActionService.ResendReceiver(oEnvelope, oReceiver) = True Then Dim oMsg = Resources.Envelope.Invitation_successfully_resend.Replace("@Mail", oReceiver.EmailAddress) MsgBox(oMsg, MsgBoxStyle.Information, Text) End If End If Next Catch ex As Exception Logger.Error(ex) Finally End Try SplashScreenManager.CloseOverlayForm(oHandle) End Sub Private Sub ViewEnvelopes_Click(sender As Object, e As EventArgs) Handles ViewEnvelopes.Click If ViewEnvelopes.FocusedRowHandle < 0 Then Exit Sub End If Dim oEnvelope As Envelope = ViewEnvelopes.GetRow(ViewEnvelopes.FocusedRowHandle) txtEnvelopeIdLabel.Caption = String.Format(txtEnvelopeIdLabel.Tag, oEnvelope.Id) End Sub Private Sub btnEnvelopes_thismonth_Click(sender As Object, e As EventArgs) Handles btnEnvelopes_thismonth.Click If SQL_REP_ENV_USER_TM <> String.Empty Then Result_Execute(SQL_REP_ENV_USER_TM) Else GridControlData.DataSource = Nothing GridViewData.Columns.Clear() End If End Sub Private Sub btnEnvelopes_lastmonth_Click(sender As Object, e As EventArgs) Handles btnEnvelopes_lastmonth.Click If SQL_REP_ENV_USER_LM <> String.Empty Then Result_Execute(SQL_REP_ENV_USER_LM) Else GridControlData.DataSource = Nothing End If End Sub Private Sub btnEnvelopes_thisYear_Click(sender As Object, e As EventArgs) Handles btnEnvelopes_thisYear.Click If SQL_REP_ENV_USER_Y <> String.Empty Then Result_Execute(SQL_REP_ENV_USER_Y) Else GridControlData.DataSource = Nothing End If End Sub Private Sub btnEnvelopes_All_Click(sender As Object, e As EventArgs) Handles btnEnvelopes_All.Click If SQL_REP_ENV_USER_ALL <> String.Empty Then Result_Execute(SQL_REP_ENV_USER_ALL) Else GridControlData.DataSource = Nothing End If End Sub Private Sub Result_Execute(mySQL As String) Try Dim oDT As DataTable = DB_DD_ECM.GetDatatable(mySQL) If Not IsNothing(oDT) Then If GridViewData.Columns.Count > 0 Then GridViewData.Columns.Clear() End If GridControlData.DataSource = oDT Else GridControlData.DataSource = Nothing End If Catch ex As Exception End Try End Sub Private Sub LabelControl1_Click(sender As Object, e As EventArgs) End Sub Private Sub BarButtonItem3_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem3.ItemClick XtraSaveFileDialog1.FileName = "Overview.xlsx" XtraSaveFileDialog1.DefaultExt = ".xlsx" If XtraSaveFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then Dim oOptions As New XlsxExportOptions() With { .ExportMode = XlsxExportMode.SingleFile } If XtraTabControlMain.SelectedTabPageIndex = 0 Then GridEnvelopes.ExportToXlsx(XtraSaveFileDialog1.FileName, oOptions) ElseIf XtraTabControlMain.SelectedTabPageIndex = 1 Then GridCompleted.ExportToXlsx(XtraSaveFileDialog1.FileName, oOptions) ElseIf XtraTabControlMain.SelectedTabPageIndex = 2 Then GridControlData.ExportToXlsx(XtraSaveFileDialog1.FileName, oOptions) End If End If End Sub Private Sub BarButtonItem4_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem4.ItemClick Try Dim saveFileDialog1 As New SaveFileDialog() If File.Exists(LogConfig.LogFile) Then saveFileDialog1.Filter = "log file|*.log" saveFileDialog1.FileName = Path.GetFileName(LogConfig.LogFile) If saveFileDialog1.ShowDialog() = DialogResult.OK Then If File.Exists(saveFileDialog1.FileName) Then File.Delete(saveFileDialog1.FileName) End If File.Copy(LogConfig.LogFile, saveFileDialog1.FileName) End If End If If LogConfig.Debug = True Then Dim oDebuglogFilename_only = Path.GetFileNameWithoutExtension(LogConfig.LogFile) + "-Debug.log" Dim oDebuglogFilename = LogConfig.LogDirectory + "\" + oDebuglogFilename_only If File.Exists(oDebuglogFilename) Then saveFileDialog1.Filter = "log file|*.log" saveFileDialog1.FileName = oDebuglogFilename_only If saveFileDialog1.ShowDialog() = DialogResult.OK Then If File.Exists(saveFileDialog1.FileName) Then File.Delete(saveFileDialog1.FileName) End If File.Copy(oDebuglogFilename, saveFileDialog1.FileName) End If End If End If Dim oErrorlogFilename_only = Path.GetFileNameWithoutExtension(LogConfig.LogFile) + "-Error.log" Dim oErrorlogFilename = LogConfig.LogDirectory + "\" + oErrorlogFilename_only If File.Exists(oErrorlogFilename) Then saveFileDialog1.Filter = "log file|*.log" saveFileDialog1.FileName = oErrorlogFilename_only If saveFileDialog1.ShowDialog() = DialogResult.OK Then If File.Exists(saveFileDialog1.FileName) Then File.Delete(saveFileDialog1.FileName) End If File.Copy(oErrorlogFilename, saveFileDialog1.FileName) End If End If Dim oMSG = "The export of the log files was successful. Please make the log files available in a ticket or send them to Your admin-team" MsgBox(oMSG, MsgBoxStyle.Information, Me.Text) Catch ex As Exception MsgBox(ex.Message, MsgBoxStyle.Critical, "Error saving log file") End Try End Sub Public Shared Sub Save_Logfiles() End Sub Private Sub btnEvvallUs_thismonth_Click(sender As Object, e As EventArgs) Handles btnEvvallUs_thismonth.Click If SQL_REP_ENV_ALL_USER_MONTH <> String.Empty Then Result_Execute(SQL_REP_ENV_ALL_USER_MONTH) Else GridControlData.DataSource = Nothing End If End Sub Private Sub btnEvvallUs_lastmonth_Click(sender As Object, e As EventArgs) Handles btnEvvallUs_lastmonth.Click If SQL_REP_ENV_ALL_USER_LAST_MONTH <> String.Empty Then Result_Execute(SQL_REP_ENV_ALL_USER_LAST_MONTH) Else GridControlData.DataSource = Nothing End If End Sub Private Sub bbtnitm2Faktor_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles bbtnitm2Faktor.ItemClick If ViewEnvelopes.FocusedRowHandle < 0 Then Exit Sub End If Dim oEnvelope As Envelope = ViewEnvelopes.GetRow(ViewEnvelopes.FocusedRowHandle) Dim oView As GridView = GridEnvelopes.FocusedView If oView.Name = ViewReceivers.Name Then Dim oReceiver As Receiver = oView.GetRow(oView.FocusedRowHandle) Dim oEnvelopeTitle As String = Net.WebUtility.UrlEncode(oEnvelope.Title) Dim oDT As DataTable = DB_DD_ECM.GetDatatable($"SELECT * FROM TBSIG_RECEIVER WHERE EMAIL_ADDRESS = '{oReceiver.EmailAddress}'") If Not IsNothing(oDT) Then If oDT.Rows.Count = 1 Then Dim oTFA_REG_DL = oDT.Rows(0).Item("TFA_REG_DEADLINE") Dim oTOTP = oDT.Rows(0).Item("TOTP_SECRET_KEY") If Not IsDBNull(oTOTP) And Not IsDBNull(oTFA_REG_DL) Then Dim oForm As New frm2Factor_Properties(oReceiver.EmailAddress, oTOTP.ToString, oTFA_REG_DL, DB_DD_ECM) oForm.ShowDialog() End If End If End If Else MsgBox(Resources.Envelope.Please_select_a_recipient_from_the_Recipients_tab, MsgBoxStyle.Information, Text) End If End Sub Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click If txtEnvID.Text = String.Empty Then Exit Sub End If Dim EnvelopeModel As EnvelopeModel Dim oState = GetState() EnvelopeModel = New EnvelopeModel(oState) Dim oEnvelope = EnvelopeModel.GetById(txtEnvID.Text) Dim oMailToCreator = oEnvelope.FinalEmailToCreator Dim oMailToReceivers = oEnvelope.FinalEmailToReceivers If oMailToCreator <> Domain.Constants.FinalEmailType.No Then MsgBox("Finale email an Creator könnten/würden gesendet werden!") Else MsgBox("Finale email an Creator könnte/würde nicht erzeugt werden!" & vbNewLine & $"No SendFinalEmailToCreator - oMailToCreator [{oMailToCreator}] <> [{Domain.Constants.FinalEmailType.No}]") End If If oMailToReceivers <> Domain.Constants.FinalEmailType.No Then MsgBox("Finale email an Unterzeichner könnten/würden gesendet werden!") Else MsgBox("Finale email an Unterzeichner könnte/würde nicht erzeugt werden!" & vbNewLine & $"No SendFinalEmailToReceivers - oMailToReceivers [{oMailToReceivers}] <> [{Domain.Constants.FinalEmailType.No}]") End If End Sub Private Function GetState() As State Return New State With { .LogConfig = LogConfig, .UserId = 0, .Database = DB_DD_ECM, .Config = Nothing, .DbConfig = Nothing } End Function Private Sub BarButtonItem2_ItemClick_1(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem2.ItemClick Dim oHandle = SplashScreenManager.ShowOverlayForm(Me) Try Dim oView As GridView = GridEnvelopes.FocusedView Dim selReceiver As Receiver If oView.Name = ViewReceivers.Name Then selReceiver = oView.GetRow(oView.FocusedRowHandle) Else MsgBox(Resources.Envelope.Please_select_a_recipient_from_the_Recipients_tab, MsgBoxStyle.Information, Text) End If If ViewEnvelopes.FocusedRowHandle < 0 Or IsNothing(selReceiver) Then Exit Sub End If Dim oEnvelope As Envelope = ViewEnvelopes.GetRow(ViewEnvelopes.FocusedRowHandle) If oEnvelope.UseAccessCode = True Then Dim oController = New EnvelopeEditorController(State, oEnvelope) Dim Documents As New BindingList(Of EnvelopeDocument) Dim Receivers As New BindingList(Of Receiver) Receivers = New BindingList(Of Receiver)(oController.Envelope.Receivers) For Each oReceiver As Receiver In Receivers If oReceiver.EmailAddress = selReceiver.EmailAddress Then If oController.ActionService.ManuallySendAccessCode(oEnvelope, oReceiver) = True Then Dim oMsg = Resources.Envelope.AccessCode_successfully_send.Replace("@Mail", oReceiver.EmailAddress) MsgBox(oMsg, MsgBoxStyle.Information, Text) End If End If Next Else MsgBox("Envelope is defined without AccessCode so far!", MsgBoxStyle.Information) End If Catch ex As Exception Logger.Error(ex) Finally End Try SplashScreenManager.CloseOverlayForm(oHandle) End Sub Private Sub ViewCompleted_Layout(sender As Object, e As EventArgs) Handles ViewCompleted.Layout If FormLoad = True Then Exit Sub End If Dim oXMLPath = Get_DocGrid_Layout_Filename(ViewCompleted.Name) ViewCompleted.SaveLayoutToXml(oXMLPath) bsitmInfo.Caption = "Grid Layout Envelopes Completed Saved" End Sub Private Sub ViewEnvelopes_Layout(sender As Object, e As EventArgs) Handles ViewEnvelopes.Layout If FormLoad = True Then Exit Sub End If Dim oXMLPath = Get_DocGrid_Layout_Filename(ViewEnvelopes.Name) ViewEnvelopes.SaveLayoutToXml(oXMLPath) bsitmInfo.Caption = "Grid Layout Envelopes Saved" End Sub Private Function Get_DocGrid_Layout_Filename(pGridViewName As String) Dim EntityRegex As New RegularExpressions.Regex("\s+\(\d+\)") Dim Filename As String = String.Format("{0}_UserLayout.xml", pGridViewName) Dim oGridlayoutFullFilename = System.IO.Path.Combine(Application.UserAppDataPath(), Filename) Return oGridlayoutFullFilename End Function End Class