14-08-2023
This commit is contained in:
@@ -24,6 +24,8 @@
|
|||||||
Public Property SQLQueryFetch As String = ""
|
Public Property SQLQueryFetch As String = ""
|
||||||
|
|
||||||
Public Property OutputDirectory As String = ""
|
Public Property OutputDirectory As String = ""
|
||||||
|
Public Property AddDateSubDirectory As Boolean = False
|
||||||
|
|
||||||
Public Property TimerIntervalMin As Integer = 0
|
Public Property TimerIntervalMin As Integer = 0
|
||||||
|
|
||||||
Public Property Debug As Boolean = False
|
Public Property Debug As Boolean = False
|
||||||
|
|||||||
@@ -64,6 +64,24 @@ Public MustInherit Class BaseModule
|
|||||||
Return StringEx.ConvertTextToSlug(oName) & oExtension
|
Return StringEx.ConvertTextToSlug(oName) & oExtension
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
|
Friend Function GetFinalFileName(pFileName As String, pId As String) As String
|
||||||
|
Dim oExtension = Path.GetExtension(pFileName)
|
||||||
|
Return pId & oExtension
|
||||||
|
End Function
|
||||||
|
|
||||||
|
Friend Function GetFinalFilePath(pFileName As String) As String
|
||||||
|
If Config.AddDateSubDirectory Then
|
||||||
|
Dim oSubPath = FileEx.CreateDateDirectory(Config.OutputDirectory)
|
||||||
|
If oSubPath Is Nothing Then
|
||||||
|
Throw New ApplicationException("Output sub path could not be created!")
|
||||||
|
End If
|
||||||
|
Logger.Debug("Subdirectory [{0}] created.", oSubPath)
|
||||||
|
Return Path.Combine(oSubPath, pFileName)
|
||||||
|
Else
|
||||||
|
Return Path.Combine(Config.OutputDirectory, pFileName)
|
||||||
|
End If
|
||||||
|
End Function
|
||||||
|
|
||||||
Friend Function CopyFileToOutputPath(pFileContents As Byte(), pFilePath As String) As Boolean
|
Friend Function CopyFileToOutputPath(pFileContents As Byte(), pFilePath As String) As Boolean
|
||||||
Try
|
Try
|
||||||
Using oStream As New MemoryStream(pFileContents)
|
Using oStream As New MemoryStream(pFileContents)
|
||||||
|
|||||||
@@ -10,8 +10,6 @@ Namespace Sharepoint
|
|||||||
Inherits BaseModule
|
Inherits BaseModule
|
||||||
Implements ISync
|
Implements ISync
|
||||||
|
|
||||||
Private Const STRING1_PLACEHOLDER = "[String1]"
|
|
||||||
|
|
||||||
Public Overrides Property Name As String = "Sharepoint Sync"
|
Public Overrides Property Name As String = "Sharepoint Sync"
|
||||||
Public Overrides Property IsLoggedIn As Boolean
|
Public Overrides Property IsLoggedIn As Boolean
|
||||||
|
|
||||||
@@ -45,23 +43,14 @@ Namespace Sharepoint
|
|||||||
Logger.Info("ExtDocId: [{0}]", oDocument.Id)
|
Logger.Info("ExtDocId: [{0}]", oDocument.Id)
|
||||||
|
|
||||||
Dim oFileName = ConvertFilenameToSlug(oDocument.Name)
|
Dim oFileName = ConvertFilenameToSlug(oDocument.Name)
|
||||||
Dim oSubPath = FileEx.CreateDateDirectory(Config.OutputDirectory)
|
Dim oTempFileName = GetFinalFileName(oDocument.Name, oDocument.Id)
|
||||||
If oSubPath Is Nothing Then
|
Dim oFilePath = GetFinalFilePath(oTempFileName)
|
||||||
Throw New ApplicationException("Output sub path could not be created!")
|
|
||||||
End If
|
|
||||||
Dim oFilePath = Path.Combine(oSubPath, oFileName)
|
|
||||||
Logger.Debug("Subdirectory [{0}] created.", oSubPath)
|
|
||||||
|
|
||||||
If CopyFileToOutputPath(oDocument.Data, oFilePath) = False Then
|
If CopyFileToOutputPath(oDocument.Data, oFilePath) = False Then
|
||||||
Throw New ApplicationException("File could not be created in output path!")
|
Throw New ApplicationException("File could not be created in output path!")
|
||||||
End If
|
End If
|
||||||
|
|
||||||
Dim oSQL = String.Format(Config.SQLQueryExport, oDocument.Id, oFileName)
|
Dim oSQL = String.Format(Config.SQLQueryExport, oDocument.Id, oFileName)
|
||||||
|
|
||||||
If oSQL.Contains(STRING1_PLACEHOLDER) Then
|
|
||||||
oSQL.Replace(STRING1_PLACEHOLDER, oDocument.Path)
|
|
||||||
End If
|
|
||||||
|
|
||||||
Await Database.ExecuteNonQueryAsync(oSQL)
|
Await Database.ExecuteNonQueryAsync(oSQL)
|
||||||
|
|
||||||
Catch ex As Exception
|
Catch ex As Exception
|
||||||
@@ -70,8 +59,6 @@ Namespace Sharepoint
|
|||||||
End Try
|
End Try
|
||||||
Next
|
Next
|
||||||
|
|
||||||
'TODO
|
|
||||||
|
|
||||||
AddInfoEntry("Finished Sync.")
|
AddInfoEntry("Finished Sync.")
|
||||||
Catch ex As Exception
|
Catch ex As Exception
|
||||||
Logger.Error(ex)
|
Logger.Error(ex)
|
||||||
|
|||||||
@@ -53,14 +53,10 @@ Namespace slt
|
|||||||
AddInfoEntry("Document: [{0}]", oDocument.Name)
|
AddInfoEntry("Document: [{0}]", oDocument.Name)
|
||||||
Logger.Info("ExtDocId: [{0}]", oDocument.ExtDocId)
|
Logger.Info("ExtDocId: [{0}]", oDocument.ExtDocId)
|
||||||
|
|
||||||
Dim oDocumentName = GetFilenameWithExtension(oDocument.Name, oDocument.DocMimeType)
|
Dim oDocumentName = GetFilenameWithExtension(oDocument.ExtDocId, oDocument.DocMimeType)
|
||||||
Dim oFileName = ConvertFilenameToSlug(oDocumentName)
|
Dim oFileName = ConvertFilenameToSlug(oDocumentName)
|
||||||
Dim oSubPath = FileEx.CreateDateDirectory(Config.OutputDirectory)
|
Dim oTempFileName = GetFinalFileName(oFileName, oDocument.ExtDocId)
|
||||||
If oSubPath Is Nothing Then
|
Dim oFilePath = GetFinalFilePath(oFileName)
|
||||||
Throw New ApplicationException("Output sub path could not be created!")
|
|
||||||
End If
|
|
||||||
Dim oFilePath = Path.Combine(oSubPath, oFileName)
|
|
||||||
Logger.Debug("Subdirectory [{0}] created.", oSubPath)
|
|
||||||
|
|
||||||
If CopyFileToOutputPath(oDocument.Data, oFilePath) = False Then
|
If CopyFileToOutputPath(oDocument.Data, oFilePath) = False Then
|
||||||
Throw New ApplicationException("File could not be created in output path!")
|
Throw New ApplicationException("File could not be created in output path!")
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ Partial Public Class frmMain
|
|||||||
|
|
||||||
AddInfoEntry("Application started.")
|
AddInfoEntry("Application started.")
|
||||||
AddInfoEntry("Version: {0}", Application.ProductVersion)
|
AddInfoEntry("Version: {0}", Application.ProductVersion)
|
||||||
AddInfoEntry("Timer Interval: {0} min", ConfigManager.Config.TimerIntervalMin.ToString)
|
|
||||||
AddDivider()
|
AddDivider()
|
||||||
|
|
||||||
Database = New MSSQLServer(LogConfig, ConfigManager.Config.ConnectionString)
|
Database = New MSSQLServer(LogConfig, ConfigManager.Config.ConnectionString)
|
||||||
@@ -52,8 +51,11 @@ Partial Public Class frmMain
|
|||||||
End If
|
End If
|
||||||
|
|
||||||
If ConfigManager.Config.TimerIntervalMin > 0 Then
|
If ConfigManager.Config.TimerIntervalMin > 0 Then
|
||||||
|
AddInfoEntry("Timer Interval: {0} min", ConfigManager.Config.TimerIntervalMin.ToString)
|
||||||
SyncTimer.Interval = ConfigManager.Config.TimerIntervalMin * 60 * 1_000
|
SyncTimer.Interval = ConfigManager.Config.TimerIntervalMin * 60 * 1_000
|
||||||
StartTimer()
|
StartTimer()
|
||||||
|
Else
|
||||||
|
AddInfoEntry("Timer Interval: Off", ConfigManager.Config.TimerIntervalMin.ToString)
|
||||||
End If
|
End If
|
||||||
|
|
||||||
Catch ex As Exception
|
Catch ex As Exception
|
||||||
|
|||||||
Reference in New Issue
Block a user