08-12-2022

This commit is contained in:
Jonathan Jenne
2022-12-08 16:43:22 +01:00
parent 7b7147eeee
commit 0a25b0925c
43 changed files with 1740 additions and 378 deletions

View File

@@ -17,11 +17,32 @@ Public Class GetJobConfig
.JobTypes = State.JobTypes,
.JobDefinitions = State.JobDefinitions,
.ProfileDefinitions = New GetJobConfigResponse.ProfileDefinitionConfig With {
.ImportProfiles = State.ProfileDefintions.ImportProfiles
.ImportProfiles = State.ProfileDefintions.ImportProfiles.
Select(AddressOf FillJobForProfile).
Select(AddressOf FillStepsForProfile).
ToList()
},
.WindreamObjectTypes = State.ObjectTypes
}
End Function
Private Function FillJobForProfile(pProfile As ImportProfile) As ImportProfile
Dim oJob = State.JobDefinitions.
Where(Function(job) job.Id = pProfile.JobId).
FirstOrDefault()
pProfile.Job = oJob
Return pProfile
End Function
Private Function FillStepsForProfile(pProfile As ImportProfile) As ImportProfile
Dim oSteps = State.ProfileDefintions.ImportProfileSteps.
Where(Function(s) s.ProfileId = pProfile.Id).
ToList()
pProfile.Steps = oSteps
Return pProfile
End Function
End Class
Public Class GetJobConfigResponse

View File

@@ -31,6 +31,8 @@ Public Class UpdateJob
If oResponse Then
Scheduler.Reload()
Else
Logger.Warn("Error while updating Profile, data not reloaded!")
End If
Return New UpdateJobResponse With {.OK = oResponse}
@@ -74,8 +76,6 @@ Public Class UpdateJob
End Function
End Class
Public Class UpdateJobRequest
Public Enum UpdateJobAction
Create
@@ -84,7 +84,7 @@ Public Class UpdateJob
End Enum
Public Action As UpdateJobAction
Public Job As JobRunnerReference.JobDefinition
Public Job As JobDefinition
End Class
Public Class UpdateJobResponse

View File

@@ -0,0 +1,152 @@
Imports DigitalData.Modules.Database
Imports DigitalData.Modules.Logging
Imports ECM.JobRunner.Common
Imports ECM.JobRunner.Windows.Scheduler
Public Class UpdateProfile
Public Class UpdateProfileMethod
Inherits Base.BaseMethod
Private ReadOnly Scheduler As JobScheduler
Public Sub New(pLogConfig As LogConfig, pDatabase As MSSQLServer, pState As State, pScheduler As JobScheduler)
MyBase.New(pLogConfig, pDatabase, pState)
Scheduler = pScheduler
End Sub
Public Function Run(pData As UpdateProfileRequest) As UpdateProfileResponse
Dim oResponse As Boolean = False
Dim oUpdateJob As New UpdateJob.UpdateJobMethod(LogConfig, Database, State, Scheduler)
' Active on the profile sets active on the job as well
pData.ImportProfile.Job.Active = pData.ImportProfile.Active
Dim oJobResponse = oUpdateJob.Run(New UpdateJob.UpdateJobRequest With {
.Job = pData.ImportProfile.Job,
.Action = pData.Action
})
If oJobResponse.OK = False Then
Return New UpdateProfileResponse With {.OK = False}
End If
Select Case pData.Action
Case UpdateProfileRequest.UpdateProfileAction.Update
oResponse = DoUpdateImportProfile(pData)
Case UpdateProfileRequest.UpdateProfileAction.Create
oResponse = DoCreateImportProfile(pData)
Case UpdateProfileRequest.UpdateProfileAction.Delete
oResponse = DoDeleteImportProfile(pData)
End Select
If oResponse Then
Scheduler.Reload()
Else
Logger.Warn("Error while updating Profile, data not reloaded!")
End If
Return New UpdateProfileResponse With {.OK = oResponse}
End Function
Private Function DoUpdateImportProfile(pData As UpdateProfileRequest) As Boolean
Dim oProfile = pData.ImportProfile
Dim oSQL As String = "UPDATE TBECM_JR_FIW_PROFILE
SET JR_JOB_ID = @JR_JOB_ID,
WM_OBJECTTYPE = @WM_OBJECTTYPE,
SOURCE_FOLDER = @SOURCE_FOLDER,
TARGET_FOLDER = @TARGET_FOLDER,
BACKUP_FOLDER = @BACKUP_FOLDER,
SF_DATE_FORMAT = @SF_DATE_FORMAT,
DEL_FILE_SUCCESS = @DEL_FILE_SUCCESS,
INCL_SUBFOLDER = @INCL_SUBFOLDER,
EXCLUDE_REGEX = @EXCLUDE_REGEX,
ACTIVE = @ACTIVE
WHERE GUID = @GUID"
Dim oCommand As New SqlClient.SqlCommand(oSQL)
oCommand.Parameters.Add("JR_JOB_ID", SqlDbType.Int).Value = oProfile.Job.Id
oCommand.Parameters.Add("WM_OBJECTTYPE", SqlDbType.NVarChar, 100).Value = oProfile.ObjectTypeName
oCommand.Parameters.Add("SOURCE_FOLDER", SqlDbType.NVarChar, 500).Value = oProfile.SourceFolder
oCommand.Parameters.Add("TARGET_FOLDER", SqlDbType.NVarChar, 500).Value = oProfile.TargetFolder
oCommand.Parameters.Add("BACKUP_FOLDER", SqlDbType.NVarChar, 500).Value = oProfile.BackupFolder
oCommand.Parameters.Add("EXCLUDE_REGEX", SqlDbType.NVarChar, 5000).Value = oProfile.FileExcludeRegex
oCommand.Parameters.Add("SF_DATE_FORMAT", SqlDbType.NVarChar, 50).Value = oProfile.SubfolderDateFormat
oCommand.Parameters.Add("DEL_FILE_SUCCESS", SqlDbType.Bit).Value = oProfile.DeleteFiles
oCommand.Parameters.Add("INCL_SUBFOLDER", SqlDbType.Bit).Value = oProfile.IncludeSubfolders
oCommand.Parameters.Add("ACTIVE", SqlDbType.Bit).Value = oProfile.Active
oCommand.Parameters.Add("GUID", SqlDbType.Int).Value = oProfile.Id
Return Database.ExecuteNonQuery(oCommand)
End Function
Private Function DoCreateImportProfile(pData As UpdateProfileRequest) As Boolean
Dim oProfile = pData.ImportProfile
Dim oSQL As String = "INSERT INTO TBECM_JR_FIW_PROFILE (
JR_JOB_ID,
WM_OBJECTTYPE,
SOURCE_FOLDER,
TARGET_FOLDER,
BACKUP_FOLDER,
SF_DATE_FORMAT,
DEL_FILE_SUCCESS,
INCL_SUBFOLDER,
EXCLUDE_REGEX,
ACTIVE
) VALUES (
@JR_JOB_ID,
@WM_OBJECTTYPE,
@SOURCE_FOLDER,
@TARGET_FOLDER,
@BACKUP_FOLDER,
@SF_DATE_FORMAT,
@DEL_FILE_SUCCESS,
@INCL_SUBFOLDER,
@EXCLUDE_REGEX,
@ACTIVE
)"
Dim oCommand As New SqlClient.SqlCommand(oSQL)
oCommand.Parameters.Add("JR_JOB_ID", SqlDbType.Int).Value = oProfile.Job.Id
oCommand.Parameters.Add("WM_OBJECTTYPE", SqlDbType.NVarChar, 100).Value = oProfile.ObjectTypeName
oCommand.Parameters.Add("SOURCE_FOLDER", SqlDbType.NVarChar, 500).Value = oProfile.SourceFolder
oCommand.Parameters.Add("TARGET_FOLDER", SqlDbType.NVarChar, 500).Value = oProfile.TargetFolder
oCommand.Parameters.Add("BACKUP_FOLDER", SqlDbType.NVarChar, 500).Value = oProfile.BackupFolder
oCommand.Parameters.Add("EXCLUDE_REGEX", SqlDbType.NVarChar, 5000).Value = oProfile.FileExcludeRegex
oCommand.Parameters.Add("SF_DATE_FORMAT", SqlDbType.NVarChar, 50).Value = oProfile.SubfolderDateFormat
oCommand.Parameters.Add("DEL_FILE_SUCCESS", SqlDbType.Bit).Value = oProfile.DeleteFiles
oCommand.Parameters.Add("INCL_SUBFOLDER", SqlDbType.Bit).Value = oProfile.IncludeSubfolders
oCommand.Parameters.Add("ACTIVE", SqlDbType.Bit).Value = oProfile.Active
oCommand.Parameters.Add("GUID", SqlDbType.Int).Value = oProfile.Id
Return Database.ExecuteNonQuery(oCommand)
End Function
Private Function DoDeleteImportProfile(pData As UpdateProfileRequest) As Boolean
Dim oProfile = pData.ImportProfile
Dim oSQL As String = "DELETE FROM TBECM_JR_FIW_PROFILE WHERE GUID = @GUID"
Dim oCommand As New SqlClient.SqlCommand(oSQL)
oCommand.Parameters.Add("GUID", SqlDbType.Int).Value = oProfile.Id
Return Database.ExecuteNonQuery(oCommand)
End Function
End Class
Public Class UpdateProfileRequest
Public Enum UpdateProfileAction
Create
Update
Delete
End Enum
Public Action As UpdateProfileAction
Public ImportProfile As ImportProfile
End Class
Public Class UpdateProfileResponse
Inherits Base.BaseResponse
End Class
End Class