我有一个在系统中连续运行的计时器。我希望该计时器将剩余的邮件发送给用户。每个邮件将有不同的间隔。
Public Function CreateDummyDatatable() As DataTable
tempCompoTable = New DataTable()
Dim col As DataColumn = New DataColumn("CReportID")
col.DataType = Type.GetType("System.String")
tempCompoTable.Columns.Add(col)
Dim col1 As DataColumn = New DataColumn("iIntervalMinute")
col1.DataType = Type.GetType("System.Int32")
tempCompoTable.Columns.Add(col1)
Dim col2 As DataColumn = New DataColumn("dbActiob")
col2.DataType = Type.GetType("System.DateTime")
tempCompoTable.Columns.Add(col2)
tempCompoTable.Rows.Add("Report-A", 3, DateTime.Now) ''sends remainder in every 3 minutes
tempCompoTable.Rows.Add("Report-b", 2, DateTime.Now.AddMinutes(-5)) '' sends remainder in every 2 minutes
tempCompoTable.Rows.Add("Report-c", 5, DateTime.Now.AddMinutes(-3)) '' send remainder in every 5 minute
Return tempCompoTable
End Function
我具有如下检查和发送电子邮件的功能。但是找不到能够正确检查是否发送电子邮件以及仅在剩余时间过去后才发送剩余邮件的逻辑
Public Sub RunSchedular(ByVal timerinterval As Integer)
If tempCompoTable IsNot Nothing AndAlso tempCompoTable.Rows.Count > 0 Then
For Each dvRow As DataRowView In tempCompoTable.DefaultView
Dim CReportID As String = dvRow("CReportID").ToString()
Dim iRemindInterval As Integer = dvRow("iIntervalMinute")
Dim dtDocReceivedTime As DateTime=DateTime.Parse(dvRow("dbActiob"))
Dim rTotalPendingHours As Double = DateTime.Now.Subtract(dtDocReceivedTime ).TotalMinutes
Dim iCompletedReaminderCount As Integer = rTotalPendingHours \ iRemindInterval
Dim iminutesafterlastremainder As Integer = rTotalPendingHours Mod iRemindInterval
Dim dtCalculatedlastremainder As DateTime = dtDoccumentReceivedTime.AddHours(iCompletedReaminderCount * iRemindInterval)
'Help Required to Find Logic here
' If remainder time is alapsed and no mail was sent after time elapsed
' sentremainder(CReportID)
' End If
Next
End If
End Sub