Advertisement
Guest User

Email Job Table

a guest
Mar 19th, 2019
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.58 KB | None | 0 0
  1. Set cnt = CreateObject("ADODB.Connection")
  2. Set rst = CreateObject("ADODB.recordset")
  3.  
  4.  
  5. stADO = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=GHRMS18;Data Source=(local)"
  6. stSQL = "select top 1 runStatus,upload_conflicts+download_conflicts tot_conflict,start_time,end_time,duration," & _
  7. "(select top 1 rh.comments from dbo.MSmerge_history rh where rh.session_id = sessions2.session_id order by rh.session_id desc, rh.timestamp desc" & _
  8. ") as LastMessage from msMerge_Sessions sessions2 order by session_id desc"
  9.  
  10.  
  11. With cnt
  12. .Open stADO
  13. .CommandTimeout = 0
  14. Set rst = .Execute(stSQL)
  15. End With
  16.  
  17.  
  18. Set objMessage = CreateObject("CDO.Message")
  19. While Not rst.EOF
  20. if rst("runStatus")=2 and rst("tot_conflict")>0 then
  21. objMessage.Subject = "Replication Conflict - GHRMS18 LB1 (Table)"
  22. objMessage.Sender = "isdept@ptids.co.id"
  23. objMessage.From = "isdept@ptids.co.id"
  24. objMessage.To = "cazico@genesysindonesia.com;nristin@genesysindonesia.com;ywardojo@ptids.co.id;drachmanto@ptids.co.id"
  25. objMessage.CC = "notification@genesysindonesia.com"
  26. objMessage.TextBody = rst("lastMessage") & vbcr & "Running on : " & rst("start_time") & " - " & rst("end_time")
  27. objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
  28. objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.ids.co.id"
  29. objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 587
  30. objMessage.Configuration.Fields.Update
  31. objMessage.Send
  32. elseif rst("runStatus")=6 then
  33. objMessage.Subject = "Replication Fail - GHRMS18 LB1 (Table)"
  34. objMessage.Sender = "isdept@ptids.co.id"
  35. objMessage.From = "isdept@ptids.co.id"
  36. objMessage.To = "cazico@genesysindonesia.com;nristin@genesysindonesia.com;ywardojo@ptids.co.id;drachmanto@ptids.co.id"
  37. objMessage.CC = "notification@genesysindonesia.com"
  38. objMessage.TextBody = rst("lastMessage") & vbcr & "Running on : " & rst("start_time") & " - " & rst("end_time")
  39. objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
  40. objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.ids.co.id"
  41. objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 587
  42. objMessage.Configuration.Fields.Update
  43. objMessage.Send
  44. else
  45. if rst("runStatus")=1 then
  46. stat = "Start"
  47. elseif rst("runStatus")=2 then
  48. stat = "Success"
  49. elseif rst("runStatus")=3 then
  50. stat = "In Progress"
  51. elseif rst("runStatus")=4 then
  52. stat = "Idle"
  53. elseif rst("runStatus")=5 then
  54. stat = "Retry"
  55. end if
  56. objMessage.Subject = "Replication " & stat & " - GHRMS18 LB1 (Table)"
  57. objMessage.Sender = "isdept@ptids.co.id"
  58. objMessage.From = "isdept@ptids.co.id"
  59. objMessage.To = "notification@genesysindonesia.com;cazico@genesysindonesia.com;nristin@genesysindonesia.com;ywardojo@ptids.co.id;drachmanto@ptids.co.id"
  60. objMessage.TextBody = rst("lastMessage") & vbcr & "Running on : " & rst("start_time") & " - " & rst("end_time")
  61. objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
  62. objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.ids.co.id"
  63. objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 587
  64. objMessage.Configuration.Fields.Update
  65. objMessage.Send
  66. end if
  67. rst.movenext
  68. Wend
  69. set objMessage = Nothing
  70.  
  71.  
  72. rst.Close
  73. cnt.Close
  74. Set rst = Nothing
  75. Set cnt = Nothing
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement