Common und Service API Send API Mails
This commit is contained in:
@@ -260,6 +260,7 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="Config.vb" />
|
||||
<Compile Include="LogProvider.vb" />
|
||||
<Compile Include="Scheduler_API_SendEnvelopeMails.vb" />
|
||||
<Compile Include="Service.Designer.vb">
|
||||
<DependentUpon>Service.vb</DependentUpon>
|
||||
</Compile>
|
||||
@@ -288,7 +289,7 @@
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
<Compile Include="Scheduler.vb" />
|
||||
<Compile Include="Scheduler_FinishEnvelope.vb" />
|
||||
<Compile Include="TempFiles.vb" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
||||
72
EnvelopeGenerator.Service/Scheduler_API_SendEnvelopeMails.vb
Normal file
72
EnvelopeGenerator.Service/Scheduler_API_SendEnvelopeMails.vb
Normal file
@@ -0,0 +1,72 @@
|
||||
Imports System.Collections.Specialized
|
||||
Imports DigitalData.Modules.Base
|
||||
Imports DigitalData.Modules.Database
|
||||
Imports DigitalData.Modules.Logging
|
||||
Imports EnvelopeGenerator.Common.Jobs
|
||||
Imports EnvelopeGenerator.Common.Jobs.FinalizeDocument
|
||||
Imports Quartz
|
||||
Public Class Scheduler_API_SendEnvelopeMails
|
||||
Inherits BaseClass
|
||||
Private Scheduler As IScheduler
|
||||
Private ReadOnly ConnectionString As String
|
||||
|
||||
Private Const JobName = "SendInvitationMailsAPI"
|
||||
Public Sub New(pLogConfig As LogConfig, pConnectionString As String)
|
||||
MyBase.New(pLogConfig)
|
||||
ConnectionString = pConnectionString
|
||||
Dim oLogProvider = New LogProvider(Logger)
|
||||
Logging.LogProvider.SetCurrentLogProvider(oLogProvider)
|
||||
End Sub
|
||||
|
||||
Public Async Function Start(pInterval As Integer) As Task
|
||||
Try
|
||||
Logger.Debug("Starting Scheduler SendMailsfromAPI..")
|
||||
|
||||
Dim oProperties As New NameValueCollection()
|
||||
|
||||
Scheduler = Await SchedulerBuilder.Create(oProperties).
|
||||
UseDefaultThreadPool(Sub(x) x.MaxConcurrency = 5).
|
||||
BuildScheduler()
|
||||
Dim oJobKey = New JobKey(JobName)
|
||||
Dim oJobData = New JobDataMap() From {
|
||||
{Common.Constants.LOGCONFIG, LogConfig},
|
||||
{Common.Constants.DATABASE, ConnectionString}
|
||||
}
|
||||
|
||||
Logger.Debug("Initialized Job [{0}]", JobName)
|
||||
|
||||
Dim oJob As IJobDetail = JobBuilder.Create(Of SendInvitationMailJob).
|
||||
UsingJobData(oJobData).
|
||||
WithIdentity(oJobKey).
|
||||
Build()
|
||||
|
||||
Dim oTrigger As ITrigger = TriggerBuilder.Create().
|
||||
ForJob(oJobKey).
|
||||
WithIdentity($"{JobName}-trigger").
|
||||
WithSimpleSchedule(Sub(s) s.
|
||||
RepeatForever().
|
||||
WithIntervalInMinutes(pInterval)).
|
||||
StartNow().
|
||||
Build()
|
||||
|
||||
Logger.Debug($"{JobName}-trigger initialized")
|
||||
|
||||
Await Scheduler.ScheduleJob(oJob, oTrigger)
|
||||
|
||||
Logger.Debug($"{JobName}-scheduled")
|
||||
|
||||
Await Scheduler.Start()
|
||||
|
||||
Logger.Info($"{JobName}-started")
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
End Try
|
||||
|
||||
End Function
|
||||
|
||||
Public Async Function [Stop]() As Task
|
||||
Logger.Info("Stopping scheduler SendMailsfromAPI..")
|
||||
Await Scheduler.Shutdown()
|
||||
Logger.Info("Scheduler SendMailsfromAPI stopped!")
|
||||
End Function
|
||||
End Class
|
||||
@@ -6,7 +6,7 @@ Imports EnvelopeGenerator.Common.Jobs
|
||||
Imports EnvelopeGenerator.Common.Jobs.FinalizeDocument
|
||||
Imports Quartz
|
||||
|
||||
Public Class Scheduler
|
||||
Public Class Scheduler_FinishEnvelope
|
||||
Inherits BaseClass
|
||||
|
||||
Private Scheduler As IScheduler
|
||||
@@ -28,7 +28,7 @@ Public Class Scheduler
|
||||
|
||||
Public Async Function Start(pInterval As Integer) As Task
|
||||
Try
|
||||
Logger.Debug("Starting Scheduler..")
|
||||
Logger.Debug("Starting Scheduler Finish Envelope..")
|
||||
|
||||
Dim oProperties As New NameValueCollection()
|
||||
|
||||
@@ -10,7 +10,8 @@ Public Class Service
|
||||
Private Config As Config
|
||||
Private Database As MSSQLServer
|
||||
Private TempFiles As TempFiles
|
||||
Private Scheduler As Scheduler
|
||||
Private Scheduler1 As Scheduler_FinishEnvelope
|
||||
Private Scheduler2 As Scheduler_API_SendEnvelopeMails
|
||||
|
||||
Protected Overrides Async Sub OnStart(ByVal args() As String)
|
||||
Try
|
||||
@@ -53,10 +54,13 @@ Public Class Service
|
||||
|
||||
' === Initialize Queue ===
|
||||
|
||||
Logger.Debug("Inititalize Quartz")
|
||||
Logger.Debug("Inititalizing scheduler(s) ...")
|
||||
|
||||
Scheduler = New Scheduler(LogConfig, Config.ConnectionString, oKey, Config.PDFBurnerParams)
|
||||
Await Scheduler.Start(Config.IntervalInMin)
|
||||
Scheduler1 = New Scheduler_FinishEnvelope(LogConfig, Config.ConnectionString, oKey, Config.PDFBurnerParams)
|
||||
Await Scheduler1.Start(Config.IntervalInMin)
|
||||
|
||||
Scheduler2 = New Scheduler_API_SendEnvelopeMails(LogConfig, Config.ConnectionString)
|
||||
Await Scheduler2.Start(Config.IntervalInMin)
|
||||
|
||||
Logger.Info("Started [{0}] !", ServiceName)
|
||||
|
||||
@@ -67,8 +71,9 @@ Public Class Service
|
||||
|
||||
Protected Overrides Async Sub OnStop()
|
||||
Try
|
||||
Logger.Info("Stopping [{0}] !", ServiceName)
|
||||
Await Scheduler.Stop()
|
||||
Logger.Info("Stopping [{0}] ...", ServiceName)
|
||||
Await Scheduler1.Stop()
|
||||
Await Scheduler2.Stop()
|
||||
TempFiles.CleanUp()
|
||||
Logger.Info("Stopped [{0}] !", ServiceName)
|
||||
Catch ex As Exception
|
||||
|
||||
Reference in New Issue
Block a user