Add Language Module, use RemoveInvalidCharacters to Remove Emojis from Filenames
This commit is contained in:
parent
79202e379e
commit
917d8b71a0
@ -53,7 +53,7 @@ Public Class ClassFileDrop
|
|||||||
Loop
|
Loop
|
||||||
stmInput.Close()
|
stmInput.Close()
|
||||||
'Sonderzeichen entfernen
|
'Sonderzeichen entfernen
|
||||||
Dim Tempfilename = ClassFilehandle.InvalidCharacters(stbFileName.ToString)
|
Dim Tempfilename = DigitalData.Modules.Language.Utils.RemoveInvalidCharacters(stbFileName.ToString)
|
||||||
Dim anhaenge = e.Data.GetDataPresent("FileContents")
|
Dim anhaenge = e.Data.GetDataPresent("FileContents")
|
||||||
'Dim path As String = "C:\VBProjekte\Dateien"
|
'Dim path As String = "C:\VBProjekte\Dateien"
|
||||||
'// put the zip file into the temp directory
|
'// put the zip file into the temp directory
|
||||||
@ -93,61 +93,68 @@ Public Class ClassFileDrop
|
|||||||
End If
|
End If
|
||||||
End If
|
End If
|
||||||
If e.Data.GetDataPresent("FileGroupDescriptor") Then
|
If e.Data.GetDataPresent("FileGroupDescriptor") Then
|
||||||
Dim oApp As Outlook.Application
|
Dim oApp As Outlook.Application
|
||||||
|
Try
|
||||||
|
oApp = New Outlook.Application()
|
||||||
|
Catch ex As Exception
|
||||||
|
LOGGER.Error(ex)
|
||||||
|
MsgBox("Unexpected error in Initialisieren von Outlook-API:" & vbNewLine & ex.Message & vbNewLine & vbNewLine & "Evtl ist Outlook nicht in der dafür vorgesehenen For")
|
||||||
|
Return False
|
||||||
|
End Try
|
||||||
|
|
||||||
|
LOGGER.Info(" Drop of msg")
|
||||||
|
'supports a drop of a Outlook message
|
||||||
|
Dim myobj As Outlook.MailItem
|
||||||
|
For i As Integer = 1 To oApp.ActiveExplorer.Selection.Count
|
||||||
|
myobj = oApp.ActiveExplorer.Selection.Item(i)
|
||||||
|
Dim subj As String = myobj.Subject
|
||||||
|
If subj = "" Then
|
||||||
|
subj = "NO_SUBJECT"
|
||||||
|
End If
|
||||||
|
If subj.Contains("\") Then
|
||||||
|
subj = subj.Replace("\", "-")
|
||||||
|
End If
|
||||||
|
If subj.Contains("/") Then
|
||||||
|
subj = subj.Replace("/", "-")
|
||||||
|
End If
|
||||||
|
|
||||||
|
'Sonderzeichen entfernen
|
||||||
|
subj = DigitalData.Modules.Language.Utils.RemoveInvalidCharacters(subj)
|
||||||
|
'hardcode a destination path for testing
|
||||||
|
Dim oFilename As String = IO.Path.Combine(Path.GetTempPath, subj + ".msg")
|
||||||
|
|
||||||
|
oFilename = oFilename.Replace("?", "")
|
||||||
|
oFilename = oFilename.Replace("!", "")
|
||||||
|
oFilename = oFilename.Replace("%", "")
|
||||||
|
oFilename = oFilename.Replace("$", "")
|
||||||
|
LOGGER.Info("Drop of msg - File:" & oFilename)
|
||||||
Try
|
Try
|
||||||
oApp = New Outlook.Application()
|
myobj.SaveAs(oFilename)
|
||||||
Catch ex As Exception
|
Catch ex As Exception
|
||||||
LOGGER.Error(ex)
|
LOGGER.Error(ex)
|
||||||
MsgBox("Unexpected error in Initialisieren von Outlook-API:" & vbNewLine & ex.Message & vbNewLine & vbNewLine & "Evtl ist Outlook nicht in der dafür vorgesehenen For")
|
MsgBox("Die Email konnte aufgrund einer Sicherheitseinstellung im Outlook nicht abgelegt werden! " &
|
||||||
Return False
|
|
||||||
End Try
|
|
||||||
|
|
||||||
LOGGER.Info(" Drop of msg")
|
|
||||||
'supports a drop of a Outlook message
|
|
||||||
Dim myobj As Outlook.MailItem
|
|
||||||
For i As Integer = 1 To oApp.ActiveExplorer.Selection.Count
|
|
||||||
myobj = oApp.ActiveExplorer.Selection.Item(i)
|
|
||||||
Dim subj As String = myobj.Subject
|
|
||||||
If subj = "" Then
|
|
||||||
subj = "NO_SUBJECT"
|
|
||||||
End If
|
|
||||||
If subj.Contains("\") Then
|
|
||||||
subj = subj.Replace("\", "-")
|
|
||||||
End If
|
|
||||||
If subj.Contains("/") Then
|
|
||||||
subj = subj.Replace("/", "-")
|
|
||||||
End If
|
|
||||||
'Sonderzeichen entfernen
|
|
||||||
subj = ClassFilehandle.InvalidCharacters(subj)
|
|
||||||
'hardcode a destination path for testing
|
|
||||||
Dim oFilename As String = IO.Path.Combine(Path.GetTempPath, subj + ".msg")
|
|
||||||
oFilename = oFilename.Replace("?", "")
|
|
||||||
oFilename = oFilename.Replace("!", "")
|
|
||||||
oFilename = oFilename.Replace("%", "")
|
|
||||||
oFilename = oFilename.Replace("$", "")
|
|
||||||
LOGGER.Info("Drop of msg - File:" & oFilename)
|
|
||||||
Try
|
|
||||||
myobj.SaveAs(oFilename)
|
|
||||||
Catch ex As Exception
|
|
||||||
LOGGER.Error(ex)
|
|
||||||
MsgBox("Die Email konnte aufgrund einer Sicherheitseinstellung im Outlook nicht abgelegt werden! " &
|
|
||||||
"Bitte wenden Sie sich an Ihren Administrator, " &
|
"Bitte wenden Sie sich an Ihren Administrator, " &
|
||||||
"um den programmatischen Zugriff auf Outlook zuzulassen. " &
|
"um den programmatischen Zugriff auf Outlook zuzulassen. " &
|
||||||
"Weitere Informationen finden Sie im Log.", MsgBoxStyle.Critical, "Global Indexer")
|
"Weitere Informationen finden Sie im Log.", MsgBoxStyle.Critical, "Global Indexer")
|
||||||
End Try
|
End Try
|
||||||
|
|
||||||
ReDim Preserve files_dropped(i)
|
ReDim Preserve files_dropped(i)
|
||||||
files_dropped(i) = "|OUTLOOK_MESSAGE|" & oFilename
|
files_dropped(i) = "|OUTLOOK_MESSAGE|" & oFilename
|
||||||
Next
|
Next
|
||||||
Return True
|
|
||||||
|
|
||||||
|
Return True
|
||||||
'Drop eines Outlook Attachments
|
'Drop eines Outlook Attachments
|
||||||
End If
|
End If
|
||||||
|
|
||||||
Catch ex As Exception
|
Catch ex As Exception
|
||||||
MsgBox("Error in Drop-File" & vbNewLine & ex.Message, MsgBoxStyle.Critical)
|
MsgBox("Error in Drop-File" & vbNewLine & ex.Message, MsgBoxStyle.Critical)
|
||||||
Return False
|
Return False
|
||||||
End Try
|
End Try
|
||||||
|
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
|
|
||||||
'Private Sub DragDrop_HandleTobit(e As DragEventArgs)
|
'Private Sub DragDrop_HandleTobit(e As DragEventArgs)
|
||||||
' If e.Data.GetDataPresent("#TobitMsgData") Then
|
' If e.Data.GetDataPresent("#TobitMsgData") Then
|
||||||
' Dim Quellpfad As String = ""
|
' Dim Quellpfad As String = ""
|
||||||
|
|||||||
@ -2,21 +2,9 @@
|
|||||||
Imports System.Text.RegularExpressions
|
Imports System.Text.RegularExpressions
|
||||||
Imports DevExpress.XtraEditors
|
Imports DevExpress.XtraEditors
|
||||||
Imports Independentsoft
|
Imports Independentsoft
|
||||||
|
Imports DigitalData.Modules.Language
|
||||||
|
|
||||||
Public Class ClassFilehandle
|
Public Class ClassFilehandle
|
||||||
''' <summary>
|
|
||||||
''' Diese Funktion entfernt alle Zeichen aus dem übergebenen String
|
|
||||||
''' die in Dateinamen nicht erlaubt sind.
|
|
||||||
''' </summary>
|
|
||||||
''' <param name="Input">Der zu prüfende String</param>
|
|
||||||
''' <returns>String ohne nichterlaubte Zeichen</returns>
|
|
||||||
Public Shared Function InvalidCharacters(Input As String) As String
|
|
||||||
Dim replacement = ""
|
|
||||||
'Return System.Text.RegularExpressions.Regex.Replace(Input, "[\\/:*?""<>|\r\n]", "", System.Text.RegularExpressions.RegexOptions.Singleline)
|
|
||||||
Dim regexSearch = New String(Path.GetInvalidFileNameChars()) & New String(Path.GetInvalidPathChars())
|
|
||||||
Dim r = New Regex(String.Format("[{0}]", Regex.Escape(regexSearch)))
|
|
||||||
Return r.Replace(Input, replacement)
|
|
||||||
End Function
|
|
||||||
Public Shared Function Decide_FileHandle(pFilename As String, pHandletype As String)
|
Public Shared Function Decide_FileHandle(pFilename As String, pHandletype As String)
|
||||||
Try
|
Try
|
||||||
If pFilename.EndsWith(".msg") Then
|
If pFilename.EndsWith(".msg") Then
|
||||||
@ -115,7 +103,7 @@ Public Class ClassFilehandle
|
|||||||
attachment_name = attachment.LongFileName
|
attachment_name = attachment.LongFileName
|
||||||
End If
|
End If
|
||||||
If attachment.EmbeddedMessage IsNot Nothing Then
|
If attachment.EmbeddedMessage IsNot Nothing Then
|
||||||
attachment_name = ClassFilehandle.InvalidCharacters(attachment_name)
|
attachment_name = Utils.RemoveInvalidCharacters(attachment_name)
|
||||||
tempfile = Path.Combine(Path.GetTempPath, attachment_name & ".msg")
|
tempfile = Path.Combine(Path.GetTempPath, attachment_name & ".msg")
|
||||||
tempfile = ClassFilehandle.Versionierung_Datei(tempfile)
|
tempfile = ClassFilehandle.Versionierung_Datei(tempfile)
|
||||||
|
|
||||||
@ -129,7 +117,7 @@ Public Class ClassFilehandle
|
|||||||
End If
|
End If
|
||||||
ElseIf Not attachment_name.Contains("inline") Then
|
ElseIf Not attachment_name.Contains("inline") Then
|
||||||
'Sonderzeichen entfernen
|
'Sonderzeichen entfernen
|
||||||
attachment_name = ClassFilehandle.InvalidCharacters(attachment_name)
|
attachment_name = Utils.RemoveInvalidCharacters(attachment_name)
|
||||||
tempfile = Path.Combine(Path.GetTempPath, attachment_name)
|
tempfile = Path.Combine(Path.GetTempPath, attachment_name)
|
||||||
tempfile = ClassFilehandle.Versionierung_Datei(tempfile)
|
tempfile = ClassFilehandle.Versionierung_Datei(tempfile)
|
||||||
If tempfile <> "" Then
|
If tempfile <> "" Then
|
||||||
|
|||||||
@ -167,6 +167,10 @@
|
|||||||
<HintPath>..\..\DDMonorepo\Modules.Filesystem\bin\Debug\DigitalData.Modules.Filesystem.dll</HintPath>
|
<HintPath>..\..\DDMonorepo\Modules.Filesystem\bin\Debug\DigitalData.Modules.Filesystem.dll</HintPath>
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="DigitalData.Modules.Language, Version=1.1.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
|
<SpecificVersion>False</SpecificVersion>
|
||||||
|
<HintPath>..\..\DDMonorepo\Modules.Language\bin\Debug\DigitalData.Modules.Language.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="DigitalData.Modules.Logging, Version=2.0.0.1, Culture=neutral, processorArchitecture=MSIL">
|
<Reference Include="DigitalData.Modules.Logging, Version=2.0.0.1, Culture=neutral, processorArchitecture=MSIL">
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
<HintPath>..\..\DDMonorepo\Modules.Logging\bin\Debug\DigitalData.Modules.Logging.dll</HintPath>
|
<HintPath>..\..\DDMonorepo\Modules.Logging\bin\Debug\DigitalData.Modules.Logging.dll</HintPath>
|
||||||
|
|||||||
@ -118,6 +118,7 @@
|
|||||||
<File Id="LookupGrid" Name="DigitalData.Controls.LookupGrid.dll" Source="DigitalData.Controls.LookupGrid.dll" KeyPath="no" />
|
<File Id="LookupGrid" Name="DigitalData.Controls.LookupGrid.dll" Source="DigitalData.Controls.LookupGrid.dll" KeyPath="no" />
|
||||||
<File Id="Windream" Name="DigitalData.Modules.Windream.dll" Source="DigitalData.Modules.Windream.dll" KeyPath="no" />
|
<File Id="Windream" Name="DigitalData.Modules.Windream.dll" Source="DigitalData.Modules.Windream.dll" KeyPath="no" />
|
||||||
<File Id="Windows" Name="DigitalData.Modules.Windows.dll" Source="DigitalData.Modules.Windows.dll" KeyPath="no" />
|
<File Id="Windows" Name="DigitalData.Modules.Windows.dll" Source="DigitalData.Modules.Windows.dll" KeyPath="no" />
|
||||||
|
<File Id="Language" Name="DigitalData.Modules.Language.dll" Source="DigitalData.Modules.Language.dll" KeyPath="no" />
|
||||||
</Component>
|
</Component>
|
||||||
|
|
||||||
<Component Id="GDPictureLibs" Guid="9ea5ab43-58ff-4813-9a8b-f854784f0275">
|
<Component Id="GDPictureLibs" Guid="9ea5ab43-58ff-4813-9a8b-f854784f0275">
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user