ms
This commit is contained in:
parent
338cec6859
commit
5ffe390f45
@ -115,7 +115,7 @@ Public Class DocumentViewer
|
|||||||
Dim oFileInfo = New IO.FileInfo(FilePath)
|
Dim oFileInfo = New IO.FileInfo(FilePath)
|
||||||
Dim oExtension As String = oFileInfo.Extension
|
Dim oExtension As String = oFileInfo.Extension
|
||||||
|
|
||||||
Select Case oExtension
|
Select Case oExtension.ToLower
|
||||||
Case ".msg"
|
Case ".msg"
|
||||||
Dim oMsg As New Independentsoft.Msg.Message(FilePath)
|
Dim oMsg As New Independentsoft.Msg.Message(FilePath)
|
||||||
' TODO: Improve Encoding, maybe convert based on encoding
|
' TODO: Improve Encoding, maybe convert based on encoding
|
||||||
|
|||||||
@ -172,7 +172,7 @@
|
|||||||
<Project>{44982f9b-6116-44e2-85d0-f39650b1ef99}</Project>
|
<Project>{44982f9b-6116-44e2-85d0-f39650b1ef99}</Project>
|
||||||
<Name>Config</Name>
|
<Name>Config</Name>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
<ProjectReference Include="..\Filesystem\Filesystem.vbproj">
|
<ProjectReference Include="..\Modules.Filesystem\Filesystem.vbproj">
|
||||||
<Project>{991d0231-4623-496d-8bd0-9ca906029cbc}</Project>
|
<Project>{991d0231-4623-496d-8bd0-9ca906029cbc}</Project>
|
||||||
<Name>Filesystem</Name>
|
<Name>Filesystem</Name>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
|
|||||||
@ -73,11 +73,11 @@ Public Class ImportZUGFeRDFiles
|
|||||||
_logger.Warn("Got no results for MessageId {0}", MessageId)
|
_logger.Warn("Got no results for MessageId {0}", MessageId)
|
||||||
Return Nothing
|
Return Nothing
|
||||||
ElseIf oDatatable.Rows.Count > 1 Then
|
ElseIf oDatatable.Rows.Count > 1 Then
|
||||||
_logger.Warn("Got too many results for MessageId {0}. Using first row.", MessageId)
|
_logger.Warn("Got too many results for MessageId {0}. Using last row.", MessageId)
|
||||||
End If
|
End If
|
||||||
|
|
||||||
_logger.Debug("Got Email Data for FileId {0}", MessageId)
|
_logger.Debug("Got Email Data for FileId {0}", MessageId)
|
||||||
oRow = oDatatable.Rows.Item(0)
|
oRow = oDatatable.Rows.Item(oDatatable.Rows.Count - 1)
|
||||||
|
|
||||||
Return New EmailData() With {
|
Return New EmailData() With {
|
||||||
.From = oRow.Item("EMAIL_FROM"),
|
.From = oRow.Item("EMAIL_FROM"),
|
||||||
@ -204,8 +204,8 @@ Public Class ImportZUGFeRDFiles
|
|||||||
_logger.Error(ex)
|
_logger.Error(ex)
|
||||||
End Try
|
End Try
|
||||||
End Sub
|
End Sub
|
||||||
Private Sub AddToEmailQueueMSSQL(MessageId As String, BodyText As String, EmailData As EmailData, SourceProcedure As String)
|
Private Sub AddToEmailQueueMSSQL(MessageId As String, BodyText As String, pEmailData As EmailData, SourceProcedure As String)
|
||||||
If EmailData Is Nothing Then
|
If pEmailData Is Nothing Then
|
||||||
_logger.Warn("EmailData is empty. Email will not be sent!")
|
_logger.Warn("EmailData is empty. Email will not be sent!")
|
||||||
Exit Sub
|
Exit Sub
|
||||||
End If
|
End If
|
||||||
@ -219,8 +219,14 @@ Public Class ImportZUGFeRDFiles
|
|||||||
Dim oCreatedWho = "ZUGFeRD Service"
|
Dim oCreatedWho = "ZUGFeRD Service"
|
||||||
Dim oFinalBodyText = String.Format(EMAIL_WRAPPING_TEXT, BodyText)
|
Dim oFinalBodyText = String.Format(EMAIL_WRAPPING_TEXT, BodyText)
|
||||||
|
|
||||||
Dim oEmailAddress = EmailData.From
|
Dim oEmailAddress = pEmailData.From
|
||||||
Dim oAttachment = EmailData.Attachment
|
Dim oAttachment = pEmailData.Attachment
|
||||||
|
If oAttachment <> String.Empty Then
|
||||||
|
_logger.Debug($"Attachment_String [{oAttachment}]!")
|
||||||
|
If IO.File.Exists(oAttachment) = False Then
|
||||||
|
_logger.Info($"Attachment.File [{oAttachment}] is not existing!!!")
|
||||||
|
End If
|
||||||
|
End If
|
||||||
|
|
||||||
If IsNothing(oEmailAddress) OrElse String.IsNullOrWhiteSpace(oEmailAddress) Then
|
If IsNothing(oEmailAddress) OrElse String.IsNullOrWhiteSpace(oEmailAddress) Then
|
||||||
_logger.Warn("Could not find email-address for MessageId {0}", MessageId)
|
_logger.Warn("Could not find email-address for MessageId {0}", MessageId)
|
||||||
@ -251,7 +257,8 @@ Public Class ImportZUGFeRDFiles
|
|||||||
,[EMAIL_SUBJ]
|
,[EMAIL_SUBJ]
|
||||||
,[EMAIL_BODY]
|
,[EMAIL_BODY]
|
||||||
,[COMMENT]
|
,[COMMENT]
|
||||||
,[ADDED_WHO])
|
,[ADDED_WHO]
|
||||||
|
,EMAIL_ATTMT1)
|
||||||
VALUES
|
VALUES
|
||||||
(77
|
(77
|
||||||
,{oAccountId}
|
,{oAccountId}
|
||||||
@ -262,7 +269,8 @@ Public Class ImportZUGFeRDFiles
|
|||||||
,'{oSubject}'
|
,'{oSubject}'
|
||||||
,'{oFinalBodyText}'
|
,'{oFinalBodyText}'
|
||||||
,'{SourceProcedure}'
|
,'{SourceProcedure}'
|
||||||
,'{oCreatedWho}')"
|
,'{oCreatedWho}'
|
||||||
|
,'{oAttachment}')"
|
||||||
_mssql.ExecuteNonQuery(oInsert)
|
_mssql.ExecuteNonQuery(oInsert)
|
||||||
Else
|
Else
|
||||||
'If oDTResult.Rows.Count = 0 Then
|
'If oDTResult.Rows.Count = 0 Then
|
||||||
@ -423,7 +431,7 @@ Public Class ImportZUGFeRDFiles
|
|||||||
End Try
|
End Try
|
||||||
If oRejected = False Then
|
If oRejected = False Then
|
||||||
HISTORY_ID = oMD5DT.Rows(0).Item("GUID")
|
HISTORY_ID = oMD5DT.Rows(0).Item("GUID")
|
||||||
Throw New MD5HashException()
|
Throw New MD5HashException($"There is already an identical invoice! - HistoryID [{HISTORY_ID}]")
|
||||||
Else
|
Else
|
||||||
_logger.Info("ZuGFeRDFile already has been worked, but formerly obviously was rejected!")
|
_logger.Info("ZuGFeRDFile already has been worked, but formerly obviously was rejected!")
|
||||||
End If
|
End If
|
||||||
|
|||||||
@ -39,8 +39,8 @@ Public Class Exceptions
|
|||||||
Public Class MD5HashException
|
Public Class MD5HashException
|
||||||
Inherits ApplicationException
|
Inherits ApplicationException
|
||||||
|
|
||||||
Public Sub New()
|
Public Sub New(pInfo As String)
|
||||||
MyBase.New("There is already an identical invoice")
|
MyBase.New(pInfo)
|
||||||
End Sub
|
End Sub
|
||||||
End Class
|
End Class
|
||||||
End Class
|
End Class
|
||||||
|
|||||||
@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
|
|||||||
' übernehmen, indem Sie "*" eingeben:
|
' übernehmen, indem Sie "*" eingeben:
|
||||||
' <Assembly: AssemblyVersion("1.0.*")>
|
' <Assembly: AssemblyVersion("1.0.*")>
|
||||||
|
|
||||||
<Assembly: AssemblyVersion("0.0.0.4")>
|
<Assembly: AssemblyVersion("1.0.0.2")>
|
||||||
<Assembly: AssemblyFileVersion("1.0.0.0")>
|
<Assembly: AssemblyFileVersion("1.0.0.0")>
|
||||||
|
|||||||
@ -203,17 +203,18 @@ Public Class Windream
|
|||||||
End Try
|
End Try
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
Public Function GetFileByPath(Path As String) As WMObject
|
Public Function GetFileByPath(pPath As String) As WMObject
|
||||||
If TestSessionLoggedIn() = False Then
|
If TestSessionLoggedIn() = False Then
|
||||||
Return Nothing
|
Return Nothing
|
||||||
End If
|
End If
|
||||||
Path = GetNormalizedPath(Path)
|
pPath = GetNormalizedPath(pPath)
|
||||||
Dim oWMObject As WMObject
|
|
||||||
|
|
||||||
|
Dim oWMObject As WMObject
|
||||||
Try
|
Try
|
||||||
oWMObject = Session.GetWMObjectByPath(WMEntityDocument, Path)
|
oWMObject = Session.GetWMObjectByPath(WMEntityDocument, pPath)
|
||||||
Return oWMObject
|
Return oWMObject
|
||||||
Catch ex As Exception
|
Catch ex As Exception
|
||||||
|
_logger.Error(ex)
|
||||||
Return Nothing
|
Return Nothing
|
||||||
End Try
|
End Try
|
||||||
End Function
|
End Function
|
||||||
@ -725,22 +726,29 @@ Public Class Windream
|
|||||||
|
|
||||||
Public Function GetNormalizedPath(Path As String) As String
|
Public Function GetNormalizedPath(Path As String) As String
|
||||||
Dim oNormalizedPath = GetCleanedPath(Path)
|
Dim oNormalizedPath = GetCleanedPath(Path)
|
||||||
|
Try
|
||||||
|
|
||||||
If UsesDriveLetter Then
|
If UsesDriveLetter Then
|
||||||
' Remove Driveletter eg. W:\
|
' Remove Driveletter eg. W:\
|
||||||
If oNormalizedPath.StartsWith($"{ClientDriveLetter}:\") Then
|
If oNormalizedPath.StartsWith($"{ClientDriveLetter}:\") Then
|
||||||
oNormalizedPath = oNormalizedPath.Substring(ClientDriveLetter + 2)
|
oNormalizedPath = oNormalizedPath.Substring(ClientDriveLetter + 2)
|
||||||
|
End If
|
||||||
|
Else
|
||||||
|
If oNormalizedPath.ToLower.StartsWith(ClientBasePath.ToLower) Then
|
||||||
|
' Remove Windream Base Path eg. \\windream\objects\
|
||||||
|
oNormalizedPath = oNormalizedPath.Substring(ClientBasePath.Length - 1)
|
||||||
|
End If
|
||||||
End If
|
End If
|
||||||
Else
|
|
||||||
If oNormalizedPath.ToLower.StartsWith(ClientBasePath.ToLower) Then
|
|
||||||
' Remove Windream Base Path eg. \\windream\objects\
|
|
||||||
oNormalizedPath = oNormalizedPath.Substring(ClientBasePath.Length)
|
|
||||||
End If
|
|
||||||
End If
|
|
||||||
|
|
||||||
oNormalizedPath = oNormalizedPath.Replace("\\", "\")
|
oNormalizedPath = oNormalizedPath.Replace("\\", "\")
|
||||||
|
_logger.Debug($"oNormalizedPath: [{oNormalizedPath}]")
|
||||||
|
Return oNormalizedPath
|
||||||
|
Catch ex As Exception
|
||||||
|
_logger.Warn($"Unexpected error in GetNormalizedPath - oNormalizedPath [{oNormalizedPath}] - Error: [{ex.Message}]")
|
||||||
|
Return ""
|
||||||
|
End Try
|
||||||
|
|
||||||
|
|
||||||
Return oNormalizedPath
|
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
''' <summary>
|
''' <summary>
|
||||||
@ -993,6 +1001,7 @@ Public Class Windream
|
|||||||
|
|
||||||
Public Function RemoveFile(Path As String) As Boolean
|
Public Function RemoveFile(Path As String) As Boolean
|
||||||
If TestSessionLoggedIn() = False Then
|
If TestSessionLoggedIn() = False Then
|
||||||
|
_logger.Warn("TestSession = False!")
|
||||||
Return Nothing
|
Return Nothing
|
||||||
End If
|
End If
|
||||||
|
|
||||||
@ -1000,11 +1009,12 @@ Public Class Windream
|
|||||||
Dim oWMObject As WMObject = GetFileByPath(Path)
|
Dim oWMObject As WMObject = GetFileByPath(Path)
|
||||||
|
|
||||||
If oWMObject Is Nothing Then
|
If oWMObject Is Nothing Then
|
||||||
|
_logger.Warn("Error RemoveFile (oWMObject is nothing)")
|
||||||
Return False
|
Return False
|
||||||
End If
|
End If
|
||||||
|
_logger.Info($"Deleting WMObject [{Path}]")
|
||||||
oWMObject.Delete()
|
oWMObject.Delete()
|
||||||
_logger.Warn($"file {Path} has been deleted!")
|
_logger.Info($"[RemoveFile] - File [{Path}] has been deleted!")
|
||||||
Return True
|
Return True
|
||||||
Catch ex As Exception
|
Catch ex As Exception
|
||||||
_logger.Error(ex)
|
_logger.Error(ex)
|
||||||
@ -1215,11 +1225,11 @@ Public Class Windream
|
|||||||
|
|
||||||
Dim oWMObject As WMObject = GetFileByPath(WMPath)
|
Dim oWMObject As WMObject = GetFileByPath(WMPath)
|
||||||
|
|
||||||
_logger.Debug("Working on file: " & oWMObject.aName)
|
_logger.Debug("(Export_WMFile)Working on file: " & oWMObject.aName)
|
||||||
|
|
||||||
|
|
||||||
Dim ExportFileIO = New WMOTOOLLib.WMFileIO ' CreateObject("WMOTOOLLib.WMFileIO") ' New WMOTOOLLib.WMFileIO
|
Dim ExportFileIO = New WMOTOOLLib.WMFileIO ' CreateObject("WMOTOOLLib.WMFileIO") ' New WMOTOOLLib.WMFileIO
|
||||||
_logger.Debug("ExportFileIO created...")
|
_logger.Debug("(Export_WMFile)ExportFileIO created...")
|
||||||
' Stream Interface bereitstellen
|
' Stream Interface bereitstellen
|
||||||
oWMObject.LockFor(WMObjectEditModeFileSystem)
|
oWMObject.LockFor(WMObjectEditModeFileSystem)
|
||||||
Try
|
Try
|
||||||
@ -1263,39 +1273,69 @@ Public Class Windream
|
|||||||
End Function
|
End Function
|
||||||
Public Function Export_WMFile_DocID(WMPath As String, Exportpath As String, DocId As Integer)
|
Public Function Export_WMFile_DocID(WMPath As String, Exportpath As String, DocId As Integer)
|
||||||
Try
|
Try
|
||||||
|
|
||||||
|
|
||||||
If Not Exportpath.EndsWith("\") Then
|
If Not Exportpath.EndsWith("\") Then
|
||||||
Exportpath &= "\"
|
Exportpath &= "\"
|
||||||
End If
|
End If
|
||||||
|
Dim Extension = WMPath.Substring(WMPath.LastIndexOf("."))
|
||||||
|
Dim oTempFilename As String = Exportpath & DocId & Extension
|
||||||
|
_logger.Info($"(Export_WMFile_DocID)Working on file [{WMPath}] ")
|
||||||
|
|
||||||
|
If IO.File.Exists(oTempFilename) Then
|
||||||
|
_logger.Info($"(Export_WMFile_DocID) DocID [{DocId}] already existing!! No action necessary!")
|
||||||
|
Return True
|
||||||
|
End If
|
||||||
|
|
||||||
|
Dim oWMObject As WMObject
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Dim oWMObject As WMObject = GetFileByPath(WMPath)
|
|
||||||
Try
|
Try
|
||||||
_logger.Info("Working on file: " & oWMObject.aName)
|
oWMObject = GetFileByPath(WMPath)
|
||||||
|
|
||||||
Catch ex As Exception
|
Catch ex As Exception
|
||||||
_logger.Error(ex)
|
_logger.Error(ex)
|
||||||
_logger.Warn("No object created: " & WMPath)
|
_logger.Warn("No object created: " & WMPath)
|
||||||
Return False
|
Return False
|
||||||
End Try
|
End Try
|
||||||
Dim ExportFileIO = New WMOTOOLLib.WMFileIO ' CreateObject("WMOTOOLLib.WMFileIO") ' New WMOTOOLLib.WMFileIO
|
Dim ExportFileIO = New WMOTOOLLib.WMFileIO ' CreateObject("WMOTOOLLib.WMFileIO") ' New WMOTOOLLib.WMFileIO
|
||||||
_logger.Debug("ExportFileIO created...")
|
_logger.Debug("(Export_WMFile_DocID)ExportFileIO created...")
|
||||||
Dim oWMStream = oWMObject.OpenStream("BinaryObject", 1)
|
Dim oWMStream = oWMObject.OpenStream("BinaryObject", 1)
|
||||||
'### VERSIONIERUNG ###
|
'### VERSIONIERUNG ###
|
||||||
Dim version As Integer = 2
|
Dim version As Integer = 2
|
||||||
Dim Extension = oWMObject.aName.Substring(oWMObject.aName.LastIndexOf("."))
|
|
||||||
Dim tempFilename As String = Exportpath & DocId & Extension
|
_logger.Debug($"Checking (FileExists) on [{oTempFilename}]... ")
|
||||||
'Überprüfen ob File existiert
|
'Überprüfen ob File existiert
|
||||||
Do While IO.File.Exists(tempFilename) = True
|
Do While IO.File.Exists(oTempFilename) = True
|
||||||
tempFilename = Exportpath & DocId & "_" & version & Extension
|
oTempFilename = Exportpath & DocId & "_" & version & Extension
|
||||||
version = version + 1
|
version = version + 1
|
||||||
Loop
|
Loop
|
||||||
_logger.Debug("Exportfilename is: " & tempFilename)
|
_logger.Debug($"(Export_WMFile_DocID)Exportfilename is [{oTempFilename}] ")
|
||||||
' den Dateiinhalt der neuen Datei zuweisen
|
' den Dateiinhalt der neuen Datei zuweisen
|
||||||
ExportFileIO.aWMStream = oWMStream
|
ExportFileIO.aWMStream = oWMStream
|
||||||
ExportFileIO.bstrOriginalFileName = tempFilename
|
ExportFileIO.bstrOriginalFileName = oTempFilename
|
||||||
'Das eigentliche kopieren
|
'Das eigentliche kopieren
|
||||||
ExportFileIO.ExportOriginal(True)
|
ExportFileIO.ExportOriginal(True)
|
||||||
|
|
||||||
|
Dim oCounter = 0
|
||||||
|
Dim oError As Boolean = False
|
||||||
|
Do While IO.File.Exists(oTempFilename) = False
|
||||||
|
oCounter += 1
|
||||||
|
If oCounter = 30000 Then
|
||||||
|
_logger.Warn($"WMStream took too long...Check the file [{WMPath}]")
|
||||||
|
oError = True
|
||||||
|
Exit Do
|
||||||
|
End If
|
||||||
|
Loop
|
||||||
|
If oError = True Then
|
||||||
|
Return False
|
||||||
|
End If
|
||||||
|
|
||||||
|
|
||||||
'close the windream file stream
|
'close the windream file stream
|
||||||
oWMStream.Close()
|
oWMStream.Close()
|
||||||
_logger.Info($"WMFile DocID {DocId} has been exported to {tempFilename} ")
|
_logger.Info($"WMFile DocID [{DocId}] has been exported to [{oTempFilename}]")
|
||||||
Return True
|
Return True
|
||||||
Catch ex As Exception
|
Catch ex As Exception
|
||||||
_logger.Error(ex)
|
_logger.Error(ex)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user