diff --git a/VERAGAddIn/frmAvisoFormularAnfügen.Designer.vb b/VERAGAddIn/frmAvisoFormularAnfügen.Designer.vb index 85d0969..5f233f7 100644 --- a/VERAGAddIn/frmAvisoFormularAnfügen.Designer.vb +++ b/VERAGAddIn/frmAvisoFormularAnfügen.Designer.vb @@ -35,10 +35,13 @@ Partial Class frmAvisoFormularAnfuegen Me.MyPanel2 = New VERAG_PROG_ALLGEMEIN.MyPanel(Me.components) Me.lblVMId = New System.Windows.Forms.Label() Me.UsrCntlKundenZollVollmachten1 = New SDL.usrCntlKundenZollVollmachten() + Me.dgvAnhaenge = New VERAG_PROG_ALLGEMEIN.MyDatagridview(Me.components) + Me.columnName = New System.Windows.Forms.DataGridViewTextBoxColumn() Me.MyPanel1.SuspendLayout() CType(Me.pbMail, System.ComponentModel.ISupportInitialize).BeginInit() CType(Me.pbAnhaenge, System.ComponentModel.ISupportInitialize).BeginInit() Me.MyPanel2.SuspendLayout() + CType(Me.dgvAnhaenge, System.ComponentModel.ISupportInitialize).BeginInit() Me.SuspendLayout() ' 'lblKunden @@ -121,16 +124,16 @@ Partial Class frmAvisoFormularAnfuegen Me.MyPanel1.Controls.Add(Me.btnOK) Me.MyPanel1.Controls.Add(Me.btnCancel) Me.MyPanel1.Dock = System.Windows.Forms.DockStyle.Bottom - Me.MyPanel1.Location = New System.Drawing.Point(0, 513) + Me.MyPanel1.Location = New System.Drawing.Point(0, 523) Me.MyPanel1.Name = "MyPanel1" - Me.MyPanel1.Size = New System.Drawing.Size(514, 108) + Me.MyPanel1.Size = New System.Drawing.Size(526, 108) Me.MyPanel1.TabIndex = 36 ' 'pbMail ' Me.pbMail.Enabled = False Me.pbMail.Image = Global.VERAGAddIn.My.Resources.Resources.email_big1 - Me.pbMail.Location = New System.Drawing.Point(98, 12) + Me.pbMail.Location = New System.Drawing.Point(12, 11) Me.pbMail.Name = "pbMail" Me.pbMail.Size = New System.Drawing.Size(55, 50) Me.pbMail.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom @@ -141,12 +144,13 @@ Partial Class frmAvisoFormularAnfuegen ' Me.pbAnhaenge.Enabled = False Me.pbAnhaenge.Image = Global.VERAGAddIn.My.Resources.Resources.pdf - Me.pbAnhaenge.Location = New System.Drawing.Point(12, 12) + Me.pbAnhaenge.Location = New System.Drawing.Point(73, 12) Me.pbAnhaenge.Name = "pbAnhaenge" Me.pbAnhaenge.Size = New System.Drawing.Size(65, 50) Me.pbAnhaenge.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom Me.pbAnhaenge.TabIndex = 32 Me.pbAnhaenge.TabStop = False + Me.pbAnhaenge.Visible = False ' 'MyPanel2 ' @@ -157,7 +161,7 @@ Partial Class frmAvisoFormularAnfuegen Me.MyPanel2.Dock = System.Windows.Forms.DockStyle.Top Me.MyPanel2.Location = New System.Drawing.Point(0, 0) Me.MyPanel2.Name = "MyPanel2" - Me.MyPanel2.Size = New System.Drawing.Size(514, 114) + Me.MyPanel2.Size = New System.Drawing.Size(526, 114) Me.MyPanel2.TabIndex = 37 ' 'lblVMId @@ -177,12 +181,42 @@ Partial Class frmAvisoFormularAnfuegen Me.UsrCntlKundenZollVollmachten1.Size = New System.Drawing.Size(514, 387) Me.UsrCntlKundenZollVollmachten1.TabIndex = 38 ' + 'dgvAnhaenge + ' + Me.dgvAnhaenge.AKTUALISIERUNGS_INTERVALL = -1 + Me.dgvAnhaenge.AllowUserToAddRows = False + Me.dgvAnhaenge.AllowUserToDeleteRows = False + Me.dgvAnhaenge.AllowUserToResizeColumns = False + Me.dgvAnhaenge.AllowUserToResizeRows = False + Me.dgvAnhaenge.Anchor = CType(((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left) _ + Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.dgvAnhaenge.BackgroundColor = System.Drawing.Color.White + Me.dgvAnhaenge.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize + Me.dgvAnhaenge.ColumnHeadersVisible = False + Me.dgvAnhaenge.Columns.AddRange(New System.Windows.Forms.DataGridViewColumn() {Me.columnName}) + Me.dgvAnhaenge.Location = New System.Drawing.Point(0, 481) + Me.dgvAnhaenge.Name = "dgvAnhaenge" + Me.dgvAnhaenge.ReadOnly = True + Me.dgvAnhaenge.RowHeadersVisible = False + Me.dgvAnhaenge.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect + Me.dgvAnhaenge.Size = New System.Drawing.Size(523, 48) + Me.dgvAnhaenge.TabIndex = 39 + Me.dgvAnhaenge.Visible = False + ' + 'columnName + ' + Me.columnName.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill + Me.columnName.HeaderText = "Name" + Me.columnName.Name = "columnName" + Me.columnName.ReadOnly = True + ' 'frmAvisoFormularAnfuegen ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.BackColor = System.Drawing.Color.White - Me.ClientSize = New System.Drawing.Size(514, 621) + Me.ClientSize = New System.Drawing.Size(526, 631) + Me.Controls.Add(Me.dgvAnhaenge) Me.Controls.Add(Me.UsrCntlKundenZollVollmachten1) Me.Controls.Add(Me.MyPanel2) Me.Controls.Add(Me.MyPanel1) @@ -195,6 +229,7 @@ Partial Class frmAvisoFormularAnfuegen CType(Me.pbAnhaenge, System.ComponentModel.ISupportInitialize).EndInit() Me.MyPanel2.ResumeLayout(False) Me.MyPanel2.PerformLayout() + CType(Me.dgvAnhaenge, System.ComponentModel.ISupportInitialize).EndInit() Me.ResumeLayout(False) End Sub @@ -209,4 +244,6 @@ Partial Class frmAvisoFormularAnfuegen Friend WithEvents MyPanel2 As VERAG_PROG_ALLGEMEIN.MyPanel Friend WithEvents lblVMId As Windows.Forms.Label Friend WithEvents UsrCntlKundenZollVollmachten1 As SDL.usrCntlKundenZollVollmachten + Friend WithEvents dgvAnhaenge As VERAG_PROG_ALLGEMEIN.MyDatagridview + Friend WithEvents columnName As Windows.Forms.DataGridViewTextBoxColumn End Class diff --git a/VERAGAddIn/frmAvisoFormularAnfügen.resx b/VERAGAddIn/frmAvisoFormularAnfügen.resx index f7f78d5..6ec366f 100644 --- a/VERAGAddIn/frmAvisoFormularAnfügen.resx +++ b/VERAGAddIn/frmAvisoFormularAnfügen.resx @@ -117,6 +117,9 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + True + diff --git a/VERAGAddIn/frmAvisoFormularAnfügen.vb b/VERAGAddIn/frmAvisoFormularAnfügen.vb index 9164618..15ff663 100644 --- a/VERAGAddIn/frmAvisoFormularAnfügen.vb +++ b/VERAGAddIn/frmAvisoFormularAnfügen.vb @@ -9,14 +9,15 @@ Imports VERAG_PROG_ALLGEMEIN Public Class frmAvisoFormularAnfuegen Public KdNr As Integer = -1 + Public vollmachtId As Integer = -1 Dim vollmachtartId As Integer = -1 - Dim vollmachtId As Integer = -1 Dim SQL As New VERAG_PROG_ALLGEMEIN.SQL Dim KUNDE As VERAG_PROG_ALLGEMEIN.cKunde = Nothing Public SendungsId = -1 Public Bezeichnung = "" - Public PDF_MAIL As Boolean = False + Public PDF_MAIL = "" Public ATT As List(Of String) + Public hasAnhaenge As Boolean = False Sub New() @@ -36,15 +37,12 @@ Public Class frmAvisoFormularAnfuegen Private Sub frmAvisoFormularAnfuegen_Load(sender As Object, e As EventArgs) Handles MyBase.Load KdSearchBox.initKdBox(Me) - - If PDF_MAIL Then + initAttachment() + If hasAnhaenge Then pbAnhaenge.Visible = True - Else - pbAnhaenge.Visible = False End If - End Sub @@ -97,20 +95,46 @@ Public Class frmAvisoFormularAnfuegen Private Sub btnOK_Click(sender As Object, e As EventArgs) Handles btnOK.Click - If Not PDF_MAIL Then - 'Sicherheitsabfrage: Mail besitzt keinen Anhang, soll VM gespeichert werden? + If Not hasAnhaenge Then + + If Not vbYes = MsgBox("Die Email besitzt keinen Anhang! Soll die Email denoch gespeichert werden?", vbYesNoCancel) Then Exit Sub + End If - - UsrCntlKundenZollVollmachten1.btnNeu_Click(sender, e) + vollmachtId = UsrCntlKundenZollVollmachten1.vmId - Dim DS As New VERAG_PROG_ALLGEMEIN.cDATENSERVER("DOKUMENTE", "VOLLMACHTEN", "VMID_" & UsrCntlKundenZollVollmachten1.vollmachtartId, "", "", Bezeichnung, KdNr) - Dim path = DS.uploadDataToDATENSERVER("") - + 'MsgBox("Dokument wurde gespeichert!") + 'Dim DS As New VERAG_PROG_ALLGEMEIN.cDATENSERVER("DOKUMENTE", "VOLLMACHTEN", "VMID_" & UsrCntlKundenZollVollmachten1.vollmachtartId, "", "", Bezeichnung, KdNr) + 'Dim path = DS.uploadDataToDATENSERVER("") Close() + + + End Sub Private Sub btnCancel_Click(sender As Object, e As EventArgs) Handles btnCancel.Click Close() End Sub + + Sub initAttachment() + dgvAnhaenge.Rows.Clear() + If ATT.Count = 0 Then + hasAnhaenge = False + PDF_MAIL = "ONLYMAIL_DATENSERVER" + Else + hasAnhaenge = True + PDF_MAIL = "PDF_DATENSERVER" + For Each a In ATT + Dim display = a + If a.Contains("\") Then + Dim sp = a.Split("\") + display = sp(sp.Count - 1) + End If + dgvAnhaenge.Rows.Add({display}) + Next + End If + dgvAnhaenge.ClearSelection() + End Sub + + End Class \ No newline at end of file diff --git a/VERAGAddIn/rbnVERAG.vb b/VERAGAddIn/rbnVERAG.vb index efd5cba..62a6ea9 100644 --- a/VERAGAddIn/rbnVERAG.vb +++ b/VERAGAddIn/rbnVERAG.vb @@ -77,7 +77,7 @@ Public Class VERAGRibbon Private Sub btnVM_Click(sender As Object, e As RibbonControlEventArgs) Handles btnVM.Click ' ToDo -> Logik für das Einfügen eines PDFs aus einer Mail in eine Vollmacht im Aviso. - If LOGIN_OK Then AVISO_Mail_Functions.addMailToAviso_Vollmachten() + If LOGIN_OK Then AVISO_Mail_Functions.addMailToAviso_Hauptfenster(True) End Sub @@ -85,7 +85,7 @@ End Class Public Class AVISO_Mail_Functions - Shared Sub addMailToAviso_Hauptfenster() + Shared Sub addMailToAviso_Hauptfenster(Optional isFormular As Boolean = False) Try Dim explorer As Outlook.Explorer = Globals.ThisAddIn.Application.ActiveExplorer Dim selection As Outlook.Selection = explorer.Selection @@ -94,7 +94,7 @@ Public Class AVISO_Mail_Functions Dim mailItem As Outlook.MailItem = selectedItem mailItem = DirectCast(mailItem, Outlook.MailItem) - addMailToAviso(mailItem) + addMailToAviso(mailItem, isFormular) End If Catch ex As Exception MsgBox(ex.Message & ex.StackTrace) @@ -143,6 +143,10 @@ Public Class AVISO_Mail_Functions ElseIf pdf_mail = "PDFMAIL" Then saveMail(mailItem, AvisoId, Bezeichnung,, SendungsId, Art) saveAttachment(ATTACHMENTS_LIST, AvisoId, SendungsId, Art, BezAnhang) + ElseIf pdf_mail = "PDF_DATENSERVER" Then + saveAttachmentOnDatenserver(ATTACHMENTS_LIST, AvisoId, Art, BezAnhang) + ElseIf pdf_mail = "ONLYMAIL_DATENSERVER" Then + saveMailOnDatenserver(mailItem, AvisoId, Bezeichnung,, Art) Else 'ONLYMAIL saveMail(mailItem, AvisoId, Bezeichnung,, SendungsId, Art) End If @@ -386,6 +390,32 @@ Public Class AVISO_Mail_Functions Catch ex As Exception MsgBox(System.Reflection.MethodInfo.GetCurrentMethod.Name & ex.Message & ex.StackTrace) End Try + End Sub + + Shared Sub saveAttachmentOnDatenserver(ByRef ATTACHMENTS_LIST As List(Of String), AvisoId As Integer, Art As String, BezeichnungAnh As String) + Try + If AvisoId > 0 Then + If ATTACHMENTS_LIST.Count > 1 Then BezeichnungAnh = "" ' nur wenn 1 Anhang wird die Bezeichnung übernommen. + For Each ATT In ATTACHMENTS_LIST + Dim fi As New IO.FileInfo(ATT) + Dim Bezeichnung = BezeichnungAnh + If Bezeichnung = "" Then Bezeichnung = fi.Name + + Dim DS As New VERAG_PROG_ALLGEMEIN.cDATENSERVER("DOKUMENTE", "VOLLMACHTEN", "VMID_" & AvisoId, "", "", Bezeichnung) + Dim path = DS.uploadDataToDATENSERVER(fi.FullName) + + 'If AVISO.frmSendungAnhangImport.getFileTypeValid(fi.Extension, typ) Then + ' AVISO.frmSendungAnhangImport.saveToDS(AvisoId, Bezeichnung, ATT, Art, typ, ,,, If(SendungsId > 0, SendungsId, Nothing)) + Next + End If + Catch ex As Exception + MsgBox(System.Reflection.MethodInfo.GetCurrentMethod.Name & ex.Message & ex.StackTrace) + End Try + + + + + End Sub @@ -577,20 +607,55 @@ Public Class AVISO_Mail_Functions End Try End Sub + Shared Sub saveMailOnDatenserver(mailItem As Outlook.MailItem, AvisoId As Integer, Optional bezeichnung As String = "", Optional saveAttachments As Boolean = True, Optional Art As String = "") + Try + If AvisoId > 0 Then + + If bezeichnung = "" Then bezeichnung = Left(Regex.Replace(mailItem.Subject, "[\/\\\:\?\*\<\>\|""]", ""), 100).Replace("""", "").Replace(vbTab, " ") & ".msg" + Dim strTmpPath As String = System.IO.Path.GetTempPath() & bezeichnung & If(bezeichnung.EndsWith(".msg"), "", ".msg") + + + mailItem.SaveAs(strTmpPath, Outlook.OlSaveAsType.olMSG) + + + 'If AVISO.frmSendungAnhangImport.saveToDS(AvisoId, bezeichnung, strTmpPath, Art, "MSG",,,, If(SendungsId, SendungsId, Nothing)) Then + ' End If + Dim DS As New VERAG_PROG_ALLGEMEIN.cDATENSERVER("DOKUMENTE", "VOLLMACHTEN", "VMID_" & AvisoId, "", "", bezeichnung) + Dim path = DS.uploadDataToDATENSERVER(strTmpPath) + + + ' Clean up the temporary .MSG file from the user's temporary folder + System.IO.File.Delete(strTmpPath) + End If + Catch ex As Exception + MsgBox(ex.Message & ex.StackTrace) + Finally + If mailItem IsNot Nothing Then + Marshal.ReleaseComObject(mailItem) + End If + End Try + End Sub + Shared Function getAvisoId(ByRef Bezeichnung, ByRef pdf_mail, ByRef SendungsId, ByRef Art, ByRef Att, ByVal isFormular) As Integer If (isFormular = True) Then Dim frmAvisoFormularAnfuegen As New frmAvisoFormularAnfuegen(Bezeichnung) + frmAvisoFormularAnfuegen.ATT = Att If frmAvisoFormularAnfuegen.ShowDialog = DialogResult.OK Then + Dim AvisoId = frmAvisoFormularAnfuegen.vollmachtId SendungsId = frmAvisoFormularAnfuegen.SendungsId Bezeichnung = frmAvisoFormularAnfuegen.Bezeichnung pdf_mail = frmAvisoFormularAnfuegen.PDF_MAIL Att = frmAvisoFormularAnfuegen.ATT - Return 1 - Exit Function + Return AvisoId + End If + + Return -1 + Exit Function + End If Dim frmAvisoAnfügen As New frmAvisoAnfuegen(Bezeichnung) @@ -610,22 +675,4 @@ Public Class AVISO_Mail_Functions End Function - Shared Sub addMailToAviso_Vollmachten() - Try - Dim explorer As Outlook.Explorer = Globals.ThisAddIn.Application.ActiveExplorer - Dim selection As Outlook.Selection = explorer.Selection - If selection.Count > 0 Then - Dim selectedItem = selection(1) - Dim mailItem As Outlook.MailItem = selectedItem - mailItem = DirectCast(mailItem, Outlook.MailItem) - - addMailToAviso(mailItem, True) - End If - Catch ex As Exception - MsgBox(ex.Message & ex.StackTrace) - End Try - End Sub - - - End Class