Ms Auswertungen, Dokument anzeigen, Drag and Drop
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
Imports System.ComponentModel
|
||||
Imports System.Data.SqlClient
|
||||
Imports System.IO
|
||||
Imports System.Text.RegularExpressions
|
||||
Imports DevExpress.Export.Xl
|
||||
Imports DevExpress.Utils.CommonDialogs
|
||||
Imports DevExpress.Utils.Drawing
|
||||
@@ -17,6 +18,7 @@ Imports DigitalData.Modules.Logging
|
||||
Imports EnvelopeGenerator.Common
|
||||
Imports EnvelopeGenerator.Common.Constants
|
||||
Imports EnvelopeGenerator.Common.My
|
||||
Imports GdPicture14
|
||||
|
||||
Partial Public Class frmEnvelopeEditor
|
||||
Public Property Envelope As Envelope
|
||||
@@ -31,7 +33,7 @@ Partial Public Class frmEnvelopeEditor
|
||||
Private Const COL_NAME = "Name"
|
||||
Private Const COL_EMAIL = "Email"
|
||||
Private Const COL_CODE = "AccessCode"
|
||||
|
||||
Private Const COL_PHONE = "PhoneNumber"
|
||||
Public Property State As State
|
||||
Private TempFiles As TempFiles
|
||||
|
||||
@@ -51,14 +53,7 @@ Partial Public Class frmEnvelopeEditor
|
||||
End If
|
||||
|
||||
If OpenFileDialog1.ShowDialog() = DialogResult.OK Then
|
||||
Dim oDocument = Await Controller.CreateDocument(OpenFileDialog1.FileName)
|
||||
|
||||
If oDocument IsNot Nothing Then
|
||||
Documents.Add(oDocument)
|
||||
' Update_File_DB(OpenFileDialog1.FileName)
|
||||
Else
|
||||
MsgBox(Resources.Envelope.Document_Could_Not_Be_Saved, MsgBoxStyle.Critical, Text)
|
||||
End If
|
||||
Await AddDocument(OpenFileDialog1.FileName)
|
||||
End If
|
||||
|
||||
Catch ex As Exception
|
||||
@@ -73,15 +68,31 @@ Partial Public Class frmEnvelopeEditor
|
||||
' End If
|
||||
|
||||
End Sub
|
||||
Private Async Function AddDocument(pfilePath As String) As Threading.Tasks.Task(Of Boolean)
|
||||
Dim oDocument = Await Controller.CreateDocument(pfilePath)
|
||||
|
||||
If oDocument IsNot Nothing Then
|
||||
Documents.Add(oDocument)
|
||||
' Update_File_DB(OpenFileDialog1.FileName)
|
||||
ClearBsiItem()
|
||||
Return True
|
||||
Else
|
||||
MsgBox(Resources.Envelope.Document_Could_Not_Be_Saved, MsgBoxStyle.Critical, Text)
|
||||
Return False
|
||||
End If
|
||||
|
||||
End Function
|
||||
Private Sub frmEditor_Load(sender As Object, e As EventArgs) Handles Me.Load
|
||||
Logger = State.LogConfig.GetLogger()
|
||||
Logger.Debug("Loading Configuration..")
|
||||
TempFiles = New TempFiles(State.LogConfig)
|
||||
TempFiles.Create()
|
||||
If Envelope Is Nothing Then
|
||||
Logger.Debug("Loading Controller..")
|
||||
Controller = New EnvelopeEditorController(State)
|
||||
|
||||
' Get additional data
|
||||
Logger.Debug("Loading oDataForm..")
|
||||
Dim oDataForm As New frmEnvelopeMainData() With {
|
||||
.State = State,
|
||||
.Envelope = Controller.Envelope,
|
||||
@@ -116,6 +127,7 @@ Partial Public Class frmEnvelopeEditor
|
||||
End If
|
||||
WriteBytetoPath(oTempFilename, docItem.Byte_Data)
|
||||
docItem.Filepath = oTempFilename
|
||||
GridDocuments.Tag = docItem.Filepath
|
||||
End If
|
||||
If docItem.Thumbnail Is Nothing Then
|
||||
docItem.Thumbnail = Controller.CreateThumbnail(docItem.Filepath)
|
||||
@@ -139,7 +151,7 @@ Partial Public Class frmEnvelopeEditor
|
||||
RepositoryItemComboBox1.Items.AddRange(AllReceiverEmails)
|
||||
|
||||
SetAccessCodeColumnVisible()
|
||||
|
||||
SetPhoneNumberColumnVisible()
|
||||
txtEnvelopeIdLabel2.Caption = String.Format(txtEnvelopeIdLabel2.Tag.ToString, Controller.Envelope.Id)
|
||||
txtCreatorEmailLabel.Caption = String.Format(txtCreatorEmailLabel.Tag.ToString, Controller.Envelope.User.Email)
|
||||
|
||||
@@ -153,6 +165,13 @@ Partial Public Class frmEnvelopeEditor
|
||||
colAccessCode.Visible = False
|
||||
End If
|
||||
End Sub
|
||||
Private Sub SetPhoneNumberColumnVisible()
|
||||
If Envelope.TFA_Enabled = True Then
|
||||
colPhoneNumber.Visible = True
|
||||
Else
|
||||
colPhoneNumber.Visible = False
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub btnDeleteFile_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnDeleteFile.ItemClick
|
||||
If ViewDocuments.GetSelectedRows().Count > 0 Then
|
||||
@@ -166,14 +185,18 @@ Partial Public Class frmEnvelopeEditor
|
||||
If Controller.DeleteDocument(oDocument) Then
|
||||
Documents.Remove(oDocument)
|
||||
GridDocuments.DataSource = Nothing
|
||||
|
||||
ClearBsiItem()
|
||||
End If
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub btnSave_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnSave.ItemClick
|
||||
Try
|
||||
SaveEnvelopeWithOutValidation()
|
||||
If SaveEnvelopeWithOutValidation() = True Then
|
||||
bsitm_info.Caption = "Data saved succeddfully " + Now.ToString
|
||||
Else
|
||||
bsitm_info.Caption = "Exceprion - Error saving Data. Check LOG"
|
||||
End If
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
End Try
|
||||
@@ -439,7 +462,7 @@ Partial Public Class frmEnvelopeEditor
|
||||
oForm.ShowDialog()
|
||||
|
||||
SetAccessCodeColumnVisible()
|
||||
|
||||
SetPhoneNumberColumnVisible()
|
||||
SetFormTitle(Controller.Envelope.Title)
|
||||
End Sub
|
||||
|
||||
@@ -491,10 +514,14 @@ Partial Public Class frmEnvelopeEditor
|
||||
Private Sub DocumentButtons_Enable()
|
||||
If ViewDocuments.RowCount = 0 Then
|
||||
btnNewFile.Enabled = True
|
||||
bbtnitm_ConcatFiles.Enabled = True
|
||||
btnDeleteFile.Enabled = False
|
||||
btnShowFile.Enabled = False
|
||||
Else
|
||||
btnNewFile.Enabled = False
|
||||
bbtnitm_ConcatFiles.Enabled = False
|
||||
btnDeleteFile.Enabled = True
|
||||
btnShowFile.Enabled = True
|
||||
End If
|
||||
End Sub
|
||||
|
||||
@@ -555,25 +582,35 @@ Partial Public Class frmEnvelopeEditor
|
||||
If IsValidEmailAddress(oEmailAdress) = True Then
|
||||
Dim oLastName As String = Controller.GetLastNameByEmailAdress(oEmailAdress)
|
||||
Dim oAccessCode As String = Helpers.GetAccessCode()
|
||||
Dim oPhoneNumber As String = Controller.GetLastPhoneByEmailAdress(oEmailAdress)
|
||||
ViewReceivers.SetRowCellValue(e.RowHandle, ViewReceivers.Columns.Item(COL_EMAIL), oEmailAdress)
|
||||
ViewReceivers.SetRowCellValue(e.RowHandle, ViewReceivers.Columns.Item(COL_NAME), oLastName)
|
||||
ViewReceivers.SetRowCellValue(e.RowHandle, ViewReceivers.Columns.Item(COL_CODE), oAccessCode)
|
||||
CellValueChanged = False
|
||||
ViewReceivers.SetRowCellValue(e.RowHandle, ViewReceivers.Columns.Item(COL_PHONE), oPhoneNumber)
|
||||
Else
|
||||
Dim oMsg = Resources.Envelope.Error_email_Validation
|
||||
oMsg = oMsg.Replace("@Mail", oEmailAdress)
|
||||
MsgBox(oMsg, MsgBoxStyle.Exclamation, Text)
|
||||
ViewReceivers.DeleteRow(ViewReceivers.FocusedRowHandle)
|
||||
End If
|
||||
|
||||
CellValueChanged = False
|
||||
End If
|
||||
End If
|
||||
ElseIf e.Column.FieldName = COL_PHONE And CellValueChanged = False Then
|
||||
CellValueChanged = True
|
||||
Dim oPhoneNumber As String = DirectCast(e.Value.ToString.ToLower, String)
|
||||
oPhoneNumber = Trim(oPhoneNumber)
|
||||
If IsValidMobilePhoneNumber(oPhoneNumber) = True Then
|
||||
ViewReceivers.SetRowCellValue(e.RowHandle, ViewReceivers.Columns.Item(COL_PHONE), oPhoneNumber)
|
||||
Else
|
||||
Dim oMsg = Resources.Envelope.Error_phone_Validation
|
||||
oMsg = oMsg.Replace("@PhoneNr", oPhoneNumber)
|
||||
MsgBox(oMsg, MsgBoxStyle.Exclamation, Text)
|
||||
ViewReceivers.DeleteRow(ViewReceivers.FocusedRowHandle)
|
||||
End If
|
||||
CellValueChanged = False
|
||||
End If
|
||||
End Sub
|
||||
Private Sub email_validation()
|
||||
|
||||
End Sub
|
||||
|
||||
Private Function IsValidEmailAddress(pEmailAddress As String) As Boolean
|
||||
Try
|
||||
If pEmailAddress.Contains("@") Then
|
||||
@@ -587,21 +624,150 @@ Partial Public Class frmEnvelopeEditor
|
||||
Return False
|
||||
End Try
|
||||
End Function
|
||||
Private Function IsValidMobilePhoneNumber(pPhoneNumber As String) As Boolean
|
||||
Try
|
||||
Dim pattern As String = "^\+49\d{10,14}$"
|
||||
Dim regex As New Regex(pattern)
|
||||
Return regex.IsMatch(pPhoneNumber)
|
||||
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Return False
|
||||
End Try
|
||||
End Function
|
||||
Private Sub RibbonControl1_Click(sender As Object, e As EventArgs) Handles RibbonControl1.Click
|
||||
|
||||
End Sub
|
||||
Private Async Sub bbtnitm_ConcatFiles_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles bbtnitm_ConcatFiles.ItemClick
|
||||
ENVELOPE_TEMP_DOCUMENT = String.Empty
|
||||
OpenFileDialog1.Multiselect = True
|
||||
OpenFileDialog1.Title = Resources.Envelope.Dialog_Concat_PDF
|
||||
Dim oSuccess As Boolean = False
|
||||
Dim oHandle = SplashScreenManager.ShowOverlayForm(Me)
|
||||
Try
|
||||
Dim oErr As Boolean = False
|
||||
If OpenFileDialog1.ShowDialog() = DialogResult.OK Then
|
||||
Dim oIDX As Integer = -1
|
||||
For Each oFile As String In OpenFileDialog1.FileNames
|
||||
oIDX += 1
|
||||
Next
|
||||
|
||||
Private Sub BarButtonItem3_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem3.ItemClick
|
||||
frmChooseDocVariant.ShowDialog()
|
||||
End Sub
|
||||
Dim arPDF As GdPicturePDF() = New GdPicturePDF(oIDX) {}
|
||||
oIDX = 0
|
||||
For Each oFile As String In OpenFileDialog1.FileNames
|
||||
arPDF(oIDX) = New GdPicturePDF()
|
||||
If arPDF(oIDX).LoadFromFile(oFile) <> GdPictureStatus.OK Then
|
||||
MsgBox($"PDF Status of file {oFile} is not OK. Please check PDF-conformity!", MsgBoxStyle.Critical)
|
||||
oErr = True
|
||||
Exit For
|
||||
End If
|
||||
oIDX += 1
|
||||
Next
|
||||
If oErr = False Then
|
||||
|
||||
Private Sub BarButtonItem4_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem4.ItemClick
|
||||
Dim dstPDF As GdPicturePDF = arPDF(0).MergeDocuments(arPDF)
|
||||
Dim oStatus As GdPictureStatus = arPDF(0).GetStat()
|
||||
If oStatus = GdPictureStatus.OK Then
|
||||
Dim oTempFolder = MyTempFiles.TempPath
|
||||
If Not Directory.Exists(oTempFolder) Then
|
||||
Directory.CreateDirectory(oTempFolder)
|
||||
End If
|
||||
Dim oTempFilename = String.Concat(oTempFolder, "\", $"MergedDoc.pdf")
|
||||
'wenn es das MergedDocument schon gibt dann löschen
|
||||
If System.IO.File.Exists(oTempFilename) Then
|
||||
System.IO.File.Delete(oTempFilename)
|
||||
End If
|
||||
If dstPDF.SaveToFile(oTempFilename) = GdPictureStatus.OK Then
|
||||
ENVELOPE_TEMP_DOCUMENT = oTempFilename
|
||||
dstPDF.CloseDocument()
|
||||
oSuccess = True
|
||||
Else
|
||||
MsgBox("Unexpected format-error within the final document!", MsgBoxStyle.Critical)
|
||||
oSuccess = False
|
||||
End If
|
||||
Else
|
||||
MessageBox.Show("The MergeDocuments() method has failed with the status: " + oStatus.ToString(), "Example: MergeDocuments")
|
||||
oSuccess = False
|
||||
End If
|
||||
dstPDF.Dispose()
|
||||
oIDX = 0
|
||||
For Each oFile As String In OpenFileDialog1.FileNames
|
||||
arPDF(oIDX).CloseDocument()
|
||||
oIDX += 1
|
||||
Next
|
||||
If oSuccess = True And ENVELOPE_TEMP_DOCUMENT <> String.Empty Then
|
||||
Await AddDocument(ENVELOPE_TEMP_DOCUMENT)
|
||||
|
||||
End If
|
||||
End If
|
||||
|
||||
End If
|
||||
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Finally
|
||||
SplashScreenManager.CloseOverlayForm(oHandle)
|
||||
End Try
|
||||
|
||||
|
||||
'frmChooseDocVariant.ShowDialog()
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub ViewReceivers_CellValueChanging(sender As Object, e As CellValueChangedEventArgs) Handles ViewReceivers.CellValueChanging
|
||||
Private Sub frmEnvelopeEditor_DragEnter(sender As Object, e As DragEventArgs) Handles Me.DragEnter
|
||||
ClearBsiItem()
|
||||
' Prüfen, ob die Daten vom Typ Datei sind
|
||||
If e.Data.GetDataPresent(DataFormats.FileDrop) Then
|
||||
' prüfen ob es schon eine Datei gibt
|
||||
If Documents.Count > 0 Then
|
||||
e.Effect = DragDropEffects.None
|
||||
bsitm_info.Caption = Resources.Envelope.Only_one_file_is_allowed
|
||||
bsitm_info.ItemAppearance.Normal.BackColor = Color.Red
|
||||
bsitm_info.ItemAppearance.Normal.ForeColor = Color.Yellow
|
||||
Else
|
||||
' Effekt auf "Kopieren" setzen, um Drag-and-Drop zu ermöglichen
|
||||
e.Effect = DragDropEffects.Copy
|
||||
End If
|
||||
|
||||
Else
|
||||
e.Effect = DragDropEffects.None
|
||||
End If
|
||||
End Sub
|
||||
Sub ClearBsiItem()
|
||||
bsitm_info.Caption = ""
|
||||
bsitm_info.ItemAppearance.Normal.BackColor = Color.Transparent
|
||||
bsitm_info.ItemAppearance.Normal.ForeColor = Color.Black
|
||||
End Sub
|
||||
Private Async Sub frmEnvelopeEditor_DragDrop(sender As Object, e As DragEventArgs) Handles Me.DragDrop
|
||||
' Den Pfad der Datei(en) erhalten
|
||||
Dim ofiles() As String = CType(e.Data.GetData(DataFormats.FileDrop), String())
|
||||
|
||||
' Beispiel: Ersten Dateipfad anzeigen
|
||||
If ofiles IsNot Nothing AndAlso ofiles.Length > 0 Then
|
||||
If Not ofiles(0).ToString.EndsWith("pdf") Then
|
||||
bsitm_info.Caption = Resources.Envelope.Drop_only_one_file
|
||||
bsitm_info.ItemAppearance.Normal.BackColor = Color.Red
|
||||
bsitm_info.ItemAppearance.Normal.ForeColor = Color.Yellow
|
||||
Else
|
||||
Dim oHandle = SplashScreenManager.ShowOverlayForm(Me)
|
||||
Await AddDocument(ofiles(0))
|
||||
SplashScreenManager.CloseOverlayForm(oHandle)
|
||||
' MessageBox.Show("Dateipfad: " & ofiles(0), "Datei abgelegt", MessageBoxButtons.OK, MessageBoxIcon.Information)
|
||||
End If
|
||||
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub GridDocuments_DoubleClick(sender As Object, e As EventArgs) Handles GridDocuments.DoubleClick
|
||||
showdocument()
|
||||
End Sub
|
||||
|
||||
Private Sub btnShowFile_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnShowFile.ItemClick
|
||||
showDocument
|
||||
End Sub
|
||||
Sub showdocument()
|
||||
If Not IsNothing(Documents) Then
|
||||
Process.Start(Documents.Item(0).Filepath)
|
||||
End If
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
Reference in New Issue
Block a user