MS Integrating ByteData to DB for SIG Documents
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
Imports System.ComponentModel
|
||||
Imports System.Data.SqlClient
|
||||
Imports System.IO
|
||||
Imports DevExpress.Export.Xl
|
||||
Imports DevExpress.Utils.CommonDialogs
|
||||
Imports DevExpress.Utils.Drawing
|
||||
Imports DevExpress.XtraEditors
|
||||
Imports DevExpress.XtraExport.Helpers
|
||||
@@ -35,7 +37,12 @@ Partial Public Class frmEnvelopeEditor
|
||||
|
||||
Private Async Sub btnNewFile_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnNewFile.ItemClick
|
||||
Dim oHandle = SplashScreenManager.ShowOverlayForm(Me)
|
||||
|
||||
If IsNothing(Envelope) Then
|
||||
SaveEnvelopeWithValidation()
|
||||
If IsNothing(Envelope) Then
|
||||
Exit Sub
|
||||
End If
|
||||
End If
|
||||
Try
|
||||
' prüfen ob es schon eine Datei gibt
|
||||
If Documents.Count > 0 Then
|
||||
@@ -48,6 +55,7 @@ Partial Public Class frmEnvelopeEditor
|
||||
|
||||
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
|
||||
@@ -61,7 +69,83 @@ Partial Public Class frmEnvelopeEditor
|
||||
RibbonPageGroupAddSignature_Enabled()
|
||||
End Try
|
||||
End Sub
|
||||
Sub Update_File_DB(pFilePath As String)
|
||||
Dim SqlCom As SqlCommand
|
||||
Dim imageData As Byte()
|
||||
Dim sFileName As String
|
||||
Dim qry As String
|
||||
|
||||
Try
|
||||
'Read Image Bytes into a byte array
|
||||
'Initialize SQL Server Connection
|
||||
|
||||
'Convert File to bytes Array
|
||||
imageData = ReadFile(pFilePath)
|
||||
sFileName = System.IO.Path.GetFileName(pFilePath)
|
||||
'Set insert query
|
||||
qry = $"UPDATE TBSIG_ENVELOPE SET DOC1 = @ImageData WHERE GUID = {Envelope.Id}"
|
||||
'Initialize SqlCommand object for insert.
|
||||
SqlCom = New SqlCommand(qry, DB_DD_ECM.GetConnection)
|
||||
'We are passing File Name and Image byte data as sql parameters.
|
||||
SqlCom.Parameters.Add(New SqlParameter("@ImageData", DirectCast(imageData, Object)))
|
||||
'Execute the Query
|
||||
SqlCom.ExecuteNonQuery()
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
MessageBox.Show(ex.ToString())
|
||||
|
||||
End Try
|
||||
End Sub
|
||||
'Open file in to a filestream and read data in a byte array.
|
||||
Private Function ReadFile(ByVal sPath As String) As Byte()
|
||||
'Initialize byte array with a null value initially.
|
||||
Dim data As Byte() = Nothing
|
||||
'Use FileInfo object to get file size.
|
||||
Dim fInfo As New FileInfo(sPath)
|
||||
Dim numBytes As Long = fInfo.Length
|
||||
'Open FileStream to read file
|
||||
Dim fStream As New FileStream(sPath, FileMode.Open, FileAccess.Read)
|
||||
'Use BinaryReader to read file stream into byte array.
|
||||
Dim br As New BinaryReader(fStream)
|
||||
'When you use BinaryReader, you need to supply number of bytes to read from file.
|
||||
'In this case we want to read entire file. So supplying total number of bytes.
|
||||
data = br.ReadBytes(CInt(numBytes))
|
||||
Return data
|
||||
End Function
|
||||
Private Sub downLoadFile(ByVal sFileName As String)
|
||||
|
||||
Dim strSql As String
|
||||
|
||||
'For Document
|
||||
Try
|
||||
'Get image data from gridview column.
|
||||
strSql = "Select [DOC1] from [TBSIG_ENVELOPE] WHERE GUID =" & Envelope.Id
|
||||
|
||||
|
||||
'Get image data from DB
|
||||
Dim fileData As Byte() = DirectCast(DB_DD_ECM.GetScalarValue(strSql), Byte())
|
||||
Dim sTempFileName As String = Application.StartupPath & "\" & sFileName
|
||||
If Not fileData Is Nothing Then
|
||||
|
||||
'Read image data into a file stream
|
||||
Using fs As New FileStream(sFileName, FileMode.OpenOrCreate, FileAccess.Write)
|
||||
fs.Write(fileData, 0, fileData.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)
|
||||
End Try
|
||||
|
||||
End Sub
|
||||
Private Sub frmEditor_Load(sender As Object, e As EventArgs) Handles Me.Load
|
||||
Logger = State.LogConfig.GetLogger()
|
||||
Logger.Debug("Loading Configuration..")
|
||||
@@ -471,24 +555,26 @@ Partial Public Class frmEnvelopeEditor
|
||||
SendEnvelopeButton_Enable()
|
||||
RibbonPageGroupAddSignature_Enabled()
|
||||
End Sub
|
||||
|
||||
Dim CellValueChanged As Boolean = False
|
||||
Private Sub ViewReceivers_CellValueChanged(sender As Object, e As Views.Base.CellValueChangedEventArgs) Handles ViewReceivers.CellValueChanged
|
||||
If e.Column.FieldName = COL_EMAIL Then
|
||||
If e.Column.FieldName = COL_EMAIL And CellValueChanged = False Then
|
||||
If e.Value Is Nothing Then
|
||||
' Keine E-Mail-Adresse, also weg damit
|
||||
ViewReceivers.DeleteRow(ViewReceivers.FocusedRowHandle)
|
||||
Else
|
||||
' Doppelte E-Mail-Adresse? TODO
|
||||
'Dim oReceivers = Controller.Envelope.Receivers
|
||||
|
||||
CellValueChanged = True
|
||||
Dim oNameCellValue = ViewReceivers.GetRowCellValue(e.RowHandle, COL_NAME)
|
||||
If oNameCellValue Is Nothing Then
|
||||
Dim oEmailAdress As String = DirectCast(e.Value, String)
|
||||
Dim oEmailAdress As String = DirectCast(e.Value.ToString.ToLower, String)
|
||||
|
||||
Dim oLastName As String = Controller.GetLastNameByEmailAdress(oEmailAdress)
|
||||
Dim oAccessCode As String = Helpers.GetAccessCode()
|
||||
|
||||
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
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
@@ -497,4 +583,6 @@ Partial Public Class frmEnvelopeEditor
|
||||
Private Sub RibbonControl1_Click(sender As Object, e As EventArgs) Handles RibbonControl1.Click
|
||||
|
||||
End Sub
|
||||
|
||||
|
||||
End Class
|
||||
|
||||
Reference in New Issue
Block a user