diff --git a/PivotSubscriptions/EventLog.cls b/PivotSubscriptions/EventLog.cls index a8b694b..ed6b55b 100644 --- a/PivotSubscriptions/EventLog.cls +++ b/PivotSubscriptions/EventLog.cls @@ -1,101 +1,146 @@ -/// Event Log is a log for every action performed by Pivot Subscriptions, covering five event types: creation, update, deletion, sent email subscriptions by Task, and immediately sent emails. -Class PivotSubscriptions.EventLog Extends %Persistent -{ - -/// Event Type covers: creation, update, deletion and sent email subscriptions -/* - * Only possible values are creation, update, deletion, send, and tableError - */ -Property EventType As %String (VALUELIST=",creation,update,deletion,send,tableError"); - -Property TimeStamp As %TimeStamp [ InitialExpression = {$zdt($h, 3, 1)} ]; - -Property UserName As %String(MAXLEN = 128) [ InitialExpression = {$username} ]; - -Property Pivot As %String(MAXLEN = 512); - -Property DayOfWeek As %String; - -Property Hour As %Integer(MINVAL=0, MAXVAL=23); - -Property Minute As %Integer (MINVAL=0, MAXVAL=59); - -Property Format As %String(VALUELIST = ",Excel,PDF"); - -Property Emails As %String; - -Property Name As %String; - -/// Takes in info about an Alert Task and logs the information to the TaskLog -ClassMethod LogEvent(pEvent, pUser, pPivot, pDayOfWeek, pHour, pMinute, pFormat, pEmails, pName) As %Status -{ - Set tSC=$$$OK - - Set tEventLog=##class(PivotSubscriptions.EventLog).%New() - Set tEventLog.EventType=pEvent - Set tEventLog.TimeStamp=$zdt($h, 3, 1) - Set tEventLog.UserName=pUser - Set tEventLog.Pivot=pPivot - Set tEventLog.Name=pName - - Set tEventLog.DayOfWeek=pDayOfWeek - Set tEventLog.Hour=pHour - Set tEventLog.Minute=pMinute - - Set tEventLog.Format=pFormat - Set tEventLog.Emails=pEmails - - Set tSC=tEventLog.%Save() - - Quit tSC -} - -Storage Default -{ - - -%%CLASSNAME - - -EventType - - -TimeStamp - - -UserName - - -Pivot - - -SubscriptionId - - -DayOfWeek - - -Hour - - -Minute - - -Format - - -Emails - - -Name - - -^PivotSubscriptions.EventLogD -EventLogDefaultData -^PivotSubscriptions.EventLogD -^PivotSubscriptions.EventLogI -^PivotSubscriptions.EventLogS -%Storage.Persistent -} - -} \ No newline at end of file +/// Event Log is a log for every action performed by Pivot Subscriptions, covering five event types: creation, update, deletion, sent email subscriptions by Task, and immediately sent emails. +Class PivotSubscriptions.EventLog Extends %Persistent +{ + +/* + * Only possible values are creation, update, deletion, send, and tableError + */ +/// Event Type covers: creation, update, deletion and sent email subscriptions +Property EventType As %String(VALUELIST = ",create,update,delete,sendSubscription,sendError,tableError"); + +Property StartTime As %TimeStamp [ InitialExpression = {$zdt($h, 3, 1)} ]; + +Property EndTime As %TimeStamp; + +Property UserName As %String(MAXLEN = 128) [ InitialExpression = {$username} ]; + +Property Pivot As %String(MAXLEN = 512); + +Property DayOfWeek As %String; + +Property Hour As %Integer(MAXVAL = 23, MINVAL = 0); + +Property Minute As %Integer(MAXVAL = 59, MINVAL = 0); + +Property Format As %String(VALUELIST = ",Excel,PDF"); + +Property Emails As %String(MAXLEN = ""); + +Property Name As %String(MAXLEN = 100); + +Property Status As %Status; + +/// Takes in info about an Alert Task and logs the information to the TaskLog +ClassMethod LogEvent(pType, pUser, pPivot, pDayOfWeek, pHour, pMinute, pFormat, pEmails, pName, ByRef pEvent) As %Status +{ + Set tSC=$$$OK + + Set tEventLog=##class(PivotSubscriptions.EventLog).%New() + Set tEventLog.EventType=pType + Set tEventLog.UserName=pUser + Set tEventLog.Pivot=pPivot + Set tEventLog.Name=pName + + Set tEventLog.DayOfWeek=pDayOfWeek + Set tEventLog.Hour=pHour + Set tEventLog.Minute=pMinute + + Set tEventLog.Format=pFormat + Set tEventLog.Emails=pEmails + + If pType="tableError" { + Set tEventLog.Status=$$$OK + Set tEventLog.EndTime=$zdt($h,3,1) + } + + Set tSC=tEventLog.%Save() + Set pEvent=tEventLog + + Quit tSC +} + +Method LogUpdate(pStatus) As %Status +{ + Set tSC=$$$OK + + Set ..EndTime=$zdt($h,3,1) + Set ..Status=pStatus + Set tSC=..%Save() + + Quit tSC +} + +ClassMethod DayOfWeekDisplay(pDayOfWeek) As %String [ SqlProc ] +{ + Set pDayOfWeek=$Replace(pDayOfWeek,0,"Sunday") + Set pDayOfWeek=$Replace(pDayOfWeek,1,"Monday") + Set pDayOfWeek=$Replace(pDayOfWeek,2,"Tuesday") + Set pDayOfWeek=$Replace(pDayOfWeek,3,"Wednesday") + Set pDayOfWeek=$Replace(pDayOfWeek,4,"Thursday") + Set pDayOfWeek=$Replace(pDayOfWeek,5,"Friday") + Set pDayOfWeek=$Replace(pDayOfWeek,6,"Saturday") + Quit pDayOfWeek +} + +Query GetEvents() As %SQLQuery +{ + SELECT StartTime,EndTime,EventType,Name,Pivot,UserName,PivotSubscriptions.EventLog_DayOfWeekDisplay(DayOfWeek) As DayOfWeek,Format,"Hour","Minute",Emails,Status + FROM PivotSubscriptions.EventLog + ORDER BY ID DESC +} + +Storage Default +{ + + +%%CLASSNAME + + +EventType + + +StartTime + + +UserName + + +Pivot + + +SubscriptionId + + +DayOfWeek + + +Hour + + +Minute + + +Format + + +Emails + + +Name + + +EndTime + + +Status + + +^PivotSubscriptions.EventLogD +EventLogDefaultData +^PivotSubscriptions.EventLogD +^PivotSubscriptions.EventLogI +^PivotSubscriptions.EventLogS +%Storage.Persistent +} + +} diff --git a/PivotSubscriptions/Subscription.cls b/PivotSubscriptions/Subscription.cls index 477e391..8ad03b6 100644 --- a/PivotSubscriptions/Subscription.cls +++ b/PivotSubscriptions/Subscription.cls @@ -1,66 +1,73 @@ -Class PivotSubscriptions.Subscription Extends %Persistent -{ - -Parameter DEFAULTGLOBAL = "^PivotSubscriptions.Sub"; - -Property CreatedBy As %String; - -Property Pivot As %String(MAXLEN=""); - -Property DayOfWeek As %String; - -Property Hour As %Integer(MINVAL=0, MAXVAL=23); - -Property Minute As %Integer(VALUELIST=",0,15,30,45"); - -Property Format As %String(VALUELIST = ",Excel,PDF"); - -Property Emails As %String(MAXLEN=""); - -Property Version As %String [ InitialExpression = {##class(PivotSubscriptions.Utility).GetVersion()} ]; - -Property Name As %String(MAXLEN=100); - -Storage Default -{ - - -%%CLASSNAME - - -CreatedBy - - -Pivot - - -DayOfWeek - - -Hour - - -Minute - - -Format - - -Emails - - -Version - - -Name - - -^PivotSubscriptions.SubD -SubscriptionDefaultData -^PivotSubscriptions.SubD -^PivotSubscriptions.SubI -^PivotSubscriptions.SubS -%Storage.Persistent -} - -} +Class PivotSubscriptions.Subscription Extends %Persistent +{ + +Parameter DEFAULTGLOBAL = "^PivotSubscriptions.Sub"; + +Property CreatedBy As %String; + +Property Pivot As %String(MAXLEN = ""); + +Property DayOfWeek As %String; + +Property Hour As %Integer(MAXVAL = 23, MINVAL = 0); + +Property Minute As %Integer(VALUELIST = ",0,15,30,45"); + +Property Format As %String(VALUELIST = ",Excel,PDF"); + +Property Emails As %String(MAXLEN = ""); + +Property Version As %String [ InitialExpression = {##class(PivotSubscriptions.Utils).GetVersion()} ]; + +Property Name As %String(MAXLEN = 100); + +Property CustomFilters As array Of %String(MAXLEN = ""); + +Storage Default +{ + +CustomFilters +subnode +"CustomFilters" + + + +%%CLASSNAME + + +CreatedBy + + +Pivot + + +DayOfWeek + + +Hour + + +Minute + + +Format + + +Emails + + +Version + + +Name + + +^PivotSubscriptions.SubD +SubscriptionDefaultData +^PivotSubscriptions.SubD +^PivotSubscriptions.SubI +^PivotSubscriptions.SubS +%Storage.Persistent +} + +} diff --git a/PivotSubscriptions/Task.cls b/PivotSubscriptions/Task.cls index ebcb7a9..2fab7d6 100644 --- a/PivotSubscriptions/Task.cls +++ b/PivotSubscriptions/Task.cls @@ -1,202 +1,197 @@ -Class PivotSubscriptions.Task Extends %SYS.Task.Definition -{ - -Parameter TaskName = "Pivot Subscriptions Task"; - -Method OnTask() As %Status -{ - Set tSC=$$$OK - - // Construct current day and time for query - Set tDayOfWeek=$ZDATE($HOROLOG,10) - Set tHour=$PIECE($ZTIME($PIECE($HOROLOG,",",2),2),":",1) - Set tMinute=$PIECE($ZTIME($PIECE($HOROLOG,",",2),2),":",2) - - If $G(^PivotSubscriptions.Settings("TestEnv")) { - // Ignore minute for testing purposes - // This will allow the task to be run on demand and send emails immediately - // Leaving DayOfWeek and Hour so the scheduled task does not spam emails - Set tRS=##class(%SQL.Statement).%ExecDirect(,"SELECT Emails,Name,Pivot,Format,DayOfWeek,""Hour"",""Minute"" FROM PivotSubscriptions.Subscription WHERE DayOfWeek[? AND ""Hour""=?",tDayOfWeek,tHour) - } Else { - Set tRS=##class(%SQL.Statement).%ExecDirect(,"SELECT Emails,Name,Pivot,Format,DayOfWeek,""Hour"",""Minute"" FROM PivotSubscriptions.Subscription WHERE DayOfWeek[? AND ""Hour""=? AND ""Minute""=?",tDayOfWeek,tHour,tMinute) - } - - // Loop through Subscription results and send emails. - While tRS.%Next() { - Set tEmails=tRS.%Get("Emails") - Set tPivot=tRS.%Get("Pivot") - Set tFormat=tRS.%Get("Format") - Set tDayOfWeek=tRS.%Get("DayOfWeek") - Set tHour=tRS.%Get("Hour") - Set tMinute=tRS.%Get("Minute") - Set tName=tRS.%Get("Name") - - Set tSC = ##class(PivotSubscriptions.Task).SendSubscription(tPivot,tEmails,tFormat,tDayOfWeek,tHour,tMinute,tName) - } - - Quit tSC -} - -ClassMethod SendSubscription(pPivot As %String, pEmails As %String, pFormat As %String,pDayOfWeek,pHour,pMinute,pName) As %Status -{ - Set tSC=$$$OK - - Set tSC=##class(PivotSubscriptions.EventLog).LogEvent("send", $username, pPivot, pDayOfWeek, pHour, pMinute, pFormat, pEmails, pName) - If $$$ISERR(tSC) Quit tSC - - If pName="" { - Set pName=$E(pPivot,1,*-6) - } - - Set tSC=##class(PivotSubscriptions.Task).SendEmail(pPivot,pEmails,pFormat,pName) - If $$$ISERR(tSC) Quit tSC - - If '(##class(PivotSubscriptions.Utility).CheckTable(pName)) { - Set tSC=##class(PivotSubscriptions.EventLog).LogEvent("tableError", $username, pPivot, pDayOfWeek, pHour, pMinute, pFormat, pEmails, pName) - If $$$ISERR(tSC) Quit tSC - } - - Quit tSC -} +Class PivotSubscriptions.Task Extends %SYS.Task.Definition +{ -ClassMethod SendEmail(pPivot As %String, pEmails As %String, pFormat As %String, pName As %String) As %Status -{ - Set tSC=$$$OK - Set tFilename="" - - Set mdx=##class(%DeepSee.Utils).%GetMDXFromPivot(pPivot,.tSC,0) - - // Execute MDX to see if there are results - Set tHasResults=0 - Set tRS=##class(%DeepSee.ResultSet).%New() - Do tRS.%PrepareMDX(mdx) - Do tRS.%Execute() - If tRS.%Query.queryType="DRILLTHROUGH" { - If tRS.listingRows>0 { - Set tHasResults=1 - } - } Else { - If tRS.%GetGrandTotal()'=0 { - Set tHasResults=1 - } - } - - // Only generate file if requested pivot has results - If tHasResults { - Set pParms("TITLE")=pName - Set pParms("SUBTITLE")=$E(pPivot,1,*-6)_". Report generated on "_$zd($h,6) - Set pParms("MDX")=mdx - - Set tFilename=$replace($zstrip(pName,"*PC'W",,"/")_" - "_$zd($h,6),"/","-")_".xls" - Set tSC=##class(%DeepSee.Utils).%ExportExcelToFile(tFilename,.pParms) - } - If $$$ISERR(tSC) Quit tSC - - // Generate email - If tSC { - // check whether the table generated is too wide/truncated AND whether the table has data - Set tableStatus=##class(PivotSubscriptions.Utility).CheckTable(pName) - - Set server=##class(%Net.SMTP).%New() - Set server.smtpserver=##class(%SYS.Task.Config).GetData("MailServer") - Set msg=##class(%Net.MailMessage).%New() - Set msg.From="PivotSubscriptions" - - Set validAdminEmail=##class(PivotSubscriptions.Utility).CheckConfigurationGlobal("AdminEmail") - - If validAdminEmail { - Set msg.ReplyTo=^PivotSubscriptions.Settings("AdminEmail") - } - - // Remove ".pivot" extension for subject - Set msg.Subject=pName - Set msg.IsBinary=0 - Set msg.IsHTML=1 // Set IsHTML to 1 if email uses HTML - - If tHasResults { - - // Add attachment - Do ##class(PivotSubscriptions.Utility).WriteEmail(pName, msg, tableStatus) - - // if table is too large, then just attach Excel instead - If ((pFormat = "PDF") && (tableStatus)) { - Set tFilename = $EXTRACT(tFilename,1,$LENGTH(tFilename)-3) _ "pdf" - Do ##class(%DeepSee.Utils).%ExportPDFToFile(tFilename,.pParms) - } ElseIf 'tableStatus { - // Check if both configuration settings for admin email is valid before sending error message - If validAdminEmail { - Do ##class(PivotSubscriptions.Utility).SendErrorMessage(pPivot,^PivotSubscriptions.Settings("AdminEmail"),pName) - } - } - - Set status=msg.AttachFile("",tFilename) - - If $$$ISERR(status) { - Do $System.Status.DisplayError(status) - Quit $$$ERROR() - } - } Else { - Do ##class(PivotSubscriptions.Utility).WriteEmailHeader(msg) - Do msg.TextData.WriteLine("No data for requested pivot.") - Do ##class(PivotSubscriptions.Utility).WriteEmailFooter(msg) - } - - // iterate through all subscribers and send emails to each individually - For count=1:1:$l(pEmails,",") { - Set tEmail=$p(pEmails,",",count) - Do msg.To.SetAt(tEmail,1) - - // Send email - Set tSC=server.Send(msg) - } - - If tHasResults { - // Delete file - Do ##class(%File).Delete(tFilename) - } - } - - Quit tSC -} - -/// This method is called each time a new subscription is created. It will create or update the task as needed -ClassMethod ConfigureTask() As %Status -{ - Set tSC=$$$OK - //Does task exist? If so, update. Else, create - Set tFullName=..#TaskName_" - "_$NAMESPACE - Set tTaskID=##class(%SYS.Task).FindId(tFullName) - If tTaskID="" { - // Task is not present, need to create one - Set tTask=##class(%SYS.Task).%New() - Set tTask.Name=tFullName - Set tTask.NameSpace=$NAMESPACE - } Else { - // Task has already been defined - Quit tSC - } - - Set tTask.TaskClass="PivotSubscriptions.Task" - Set tTask.RunAsUser="_SYSTEM" - Set tTask.Description="Executes PivotSubscriptions Task" - - // Set schedule according to passed in parameters - Set tTask.TimePeriod=0 - Set tTask.TimePeriodEvery=1 - Set tTask.TimePeriodDay="" - - // Build runs at most once every day - Set tTask.DailyFrequency=1 - Set tTask.DailyFrequencyTime=0 - Set tTask.DailyIncrement=15 - Set tTask.DailyStartTime=0 - Set tTask.DailyEndTime=0 - - // The task should be operational at the next available build time - Set tSC=tTask.StartDateSet(+$h) - - Set tSC=tTask.%Save() - Quit tSC -} - -} +Parameter TaskName = "Pivot Subscriptions Task"; + +Method OnTask() As %Status +{ + Set tSC=$$$OK + + // Construct current day and time for query + Set tDayOfWeek=$ZDATE($HOROLOG,10) + Set tHour=$PIECE($ZTIME($PIECE($HOROLOG,",",2),2),":",1) + Set tMinute=$PIECE($ZTIME($PIECE($HOROLOG,",",2),2),":",2) + + If $G(^PivotSubscriptions.Settings("TestEnv")) { + // Ignore minute for testing purposes + // This will allow the task to be run on demand and send emails immediately + // Leaving DayOfWeek and Hour so the scheduled task does not spam emails + Set tRS=##class(%SQL.Statement).%ExecDirect(,"SELECT ID,Emails,Name,Pivot,Format,DayOfWeek,""Hour"",""Minute"" FROM PivotSubscriptions.Subscription WHERE DayOfWeek[? AND ""Hour""=?",tDayOfWeek,tHour) + } Else { + Set tRS=##class(%SQL.Statement).%ExecDirect(,"SELECT ID,Emails,Name,Pivot,Format,DayOfWeek,""Hour"",""Minute"" FROM PivotSubscriptions.Subscription WHERE DayOfWeek[? AND ""Hour""=? AND ""Minute""=?",tDayOfWeek,tHour,tMinute) + } + + // Loop through Subscription results and send emails. + While tRS.%Next() { + Set tID=tRS.%Get("ID") + Set tEmails=tRS.%Get("Emails") + Set tPivot=tRS.%Get("Pivot") + Set tFormat=tRS.%Get("Format") + Set tDayOfWeek=tRS.%Get("DayOfWeek") + Set tHour=tRS.%Get("Hour") + Set tMinute=tRS.%Get("Minute") + Set tName=tRS.%Get("Name") + + Set tSC = ##class(PivotSubscriptions.Task).SendSubscription(tID,tPivot,tEmails,tFormat,tDayOfWeek,tHour,tMinute,tName) + } + + Quit tSC +} + +ClassMethod SendSubscription(pID, pPivot As %String, pEmails As %String, pFormat As %String, pDayOfWeek, pHour, pMinute, pName) As %Status +{ + Set tSC=$$$OK + + Set tSC=##class(PivotSubscriptions.EventLog).LogEvent("sendSubscription", $username, pPivot, pDayOfWeek, pHour, pMinute, pFormat, pEmails, pName, .pEvent) + If $$$ISERR(tSC) Quit tSC + + If pName="" { + Set pName=$E(pPivot,1,*-6) + } + + Try { + Set tSC=##class(PivotSubscriptions.Task).SendEmail(pID,pPivot,pEmails,pFormat,pName) + } Catch ex { + Set tSC=ex.AsStatus() + } + // Update send event with status and end time + Set tSC=pEvent.LogUpdate(tSC) + If $$$ISERR(tSC) Quit tSC + + If '(##class(PivotSubscriptions.Utils).CheckTable(pName)) { + Set tSC=##class(PivotSubscriptions.EventLog).LogEvent("tableError", $username, pPivot, pDayOfWeek, pHour, pMinute, pFormat, pEmails, pName) + If $$$ISERR(tSC) Quit tSC + } + + Quit tSC +} + +ClassMethod SendEmail(pID, pPivot As %String, pEmails As %String, pFormat As %String, pName As %String) As %Status +{ + Set tSC=$$$OK + Set tFilename="" + + Set mdx=##class(%DeepSee.Utils).%GetMDXFromPivot(pPivot,.tSC,0) + + // Iterate through all subscribers and send emails to each individually + For count=1:1:$l(pEmails,",") { + Set tEmail=$p(pEmails,",",count) + + Set tHasResults=0 + + Set tSubscription=##class(PivotSubscriptions.Subscription).%OpenId(pID) + Set tCustomFilter=tSubscription.CustomFilters.GetAt(tEmail) + Set tSC=##class(PivotSubscriptions.Utils).ExecuteForSubscription(mdx,tCustomFilter,.tHasResults) + + If tHasResults { + // Only generate file if requested pivot has results + Set tSC=##class(PivotSubscriptions.Utils).GenerateFileForSubscription("Excel",mdx,tCustomFilter,pName,pPivot,.tFilename) + } + + // Generate email + If tSC { + // check whether the table generated is too wide/truncated AND whether the table has data + Set tableStatus=##class(PivotSubscriptions.Utils).CheckTable(pName) + + Set server=##class(%Net.SMTP).%New() + Set server.smtpserver=##class(%SYS.Task.Config).GetData("MailServer") + Set msg=##class(%Net.MailMessage).%New() + Set msg.From="PivotSubscriptions" + + Set validAdminEmail=##class(PivotSubscriptions.Utils).CheckConfigurationGlobal("AdminEmail") + + If validAdminEmail { + Set msg.ReplyTo=^PivotSubscriptions.Settings("AdminEmail") + } + + // Remove ".pivot" extension for subject + Set msg.Subject=pName + Set msg.IsBinary=0 + Set msg.IsHTML=1 // Set IsHTML to 1 if email uses HTML + + If tHasResults { + + // Add attachment + Do ##class(PivotSubscriptions.Utils).WriteEmail(pName, msg, tableStatus) + + // if table is too large, then just attach Excel instead + If ((pFormat = "PDF") && (tableStatus)) { + Set tSC=##class(PivotSubscriptions.Utils).GenerateFileForSubscription("PDF",mdx,tCustomFilter,pName,pPivot,.tFilename) + } ElseIf 'tableStatus { + // Check if both configuration settings for admin email is valid before sending error message + If validAdminEmail { + Do ##class(PivotSubscriptions.Utils).SendErrorMessage(pPivot,^PivotSubscriptions.Settings("AdminEmail"),pName) + } + } + + Set status=msg.AttachFile("",tFilename) + + If $$$ISERR(status) { + Do $System.Status.DisplayError(status) + Quit $$$ERROR() + } + } Else { + Do ##class(PivotSubscriptions.Utils).WriteEmailHeader(msg) + Do msg.TextData.WriteLine($G(^PivotSubscriptions.Settings("NoDataMessage"),"No data for requested pivot.")) + Do ##class(PivotSubscriptions.Utils).WriteEmailFooter(msg) + } + } + + Do msg.To.SetAt(tEmail,1) + + // Send email + If $G(^PivotSubscriptions.Settings("SendNoData"),1) { + Set tSC=server.Send(msg) + } + // TODO: Log individual send status? + + If tHasResults { + // Delete file + Do ##class(%File).Delete(tFilename) + } + } + + Quit tSC +} + +/// This method is called each time a new subscription is created. It will create or update the task as needed +ClassMethod ConfigureTask() As %Status +{ + Set tSC=$$$OK + //Does task exist? If so, update. Else, create + Set tFullName=..#TaskName_" - "_$NAMESPACE + Set tTaskID=##class(%SYS.Task).FindId(tFullName) + If tTaskID="" { + // Task is not present, need to create one + Set tTask=##class(%SYS.Task).%New() + Set tTask.Name=tFullName + Set tTask.NameSpace=$NAMESPACE + } Else { + // Task has already been defined + Quit tSC + } + + Set tTask.TaskClass="PivotSubscriptions.Task" + Set tTask.RunAsUser="_SYSTEM" + Set tTask.Description="Executes PivotSubscriptions Task" + + // Set schedule according to passed in parameters + Set tTask.TimePeriod=0 + Set tTask.TimePeriodEvery=1 + Set tTask.TimePeriodDay="" + + // Build runs at most once every day + Set tTask.DailyFrequency=1 + Set tTask.DailyFrequencyTime=0 + Set tTask.DailyIncrement=15 + Set tTask.DailyStartTime=0 + Set tTask.DailyEndTime=0 + + // The task should be operational at the next available build time + Set tSC=tTask.StartDateSet(+$h) + + Set tSC=tTask.%Save() + Quit tSC +} + +} diff --git a/PivotSubscriptions/UI/ConfigurationPage.cls b/PivotSubscriptions/UI/ConfigurationPage.cls index 38b0ffb..0720bbe 100644 --- a/PivotSubscriptions/UI/ConfigurationPage.cls +++ b/PivotSubscriptions/UI/ConfigurationPage.cls @@ -1,114 +1,103 @@ -Include %DeepSee - -/// Configuration page that lets users of Pivot Subscriptions to set the default admin's email for table errors and instant emails (sendNow feature), as well as set the generated link to match the application's namespace, webserver/port, and application name. -Class PivotSubscriptions.UI.ConfigurationPage Extends PivotSubscriptions.UI.Template -{ - -/// Displayed name of this page. -Parameter PAGENAME = "Configuration Page"; - -/// This XML block defines the contents of this pane. -XData contentPane [ XMLNamespace = "http://www.intersystems.com/zen" ] -{ - -
- - - - -
-
-} - -/// Get the (localized) title string for the page. -Method %OnGetTitle() As %String [ Internal ] -{ - Quit $$$Text("Configuration Page","PivotSubscriptions") -} - -/// Get the (localized) name of the page. -Method %OnGetPageName() As %String [ Internal ] -{ - Quit $$$Text("Configuration Page","PivotSubscriptions") -} - -/// Get the product name for the page. -Method %OnGetProductName() As %String [ Internal ] -{ - Quit "DeepSee" -} - -Method %OnAfterCreatePage() As %Status -{ - Set ..%GetComponentById("AdminEmailLabel").value=$$$TextJS("Send error email notification to:") - Set ..%GetComponentById("HTTPLabel").value=$$$TextJS("HTTP or HTTPS?") - Set ..%GetComponentById("ServerLabel").value=$$$TextJS("Server") - Set ..%GetComponentById("PortLabel").value=$$$TextJS("Port Number") - - // check if each global is instantiated and set only if they aren't empty or nonexsistent - If $G(^PivotSubscriptions.Settings("AdminEmail"))'="" { - Set ..%GetComponentById("AdminEmailText").value=^PivotSubscriptions.Settings("AdminEmail") - } - If $G(^PivotSubscriptions.Settings("Http"))'="" { - Set ..%GetComponentById("HTTPButton").value=^PivotSubscriptions.Settings("Http") - } - If $G(^PivotSubscriptions.Settings("Server"))'="" { - Set ..%GetComponentById("ServerText").value=^PivotSubscriptions.Settings("Server") - } - If $G(^PivotSubscriptions.Settings("Port"))'="" { - Set ..%GetComponentById("PortText").value=^PivotSubscriptions.Settings("Port") - } - - Quit $$$OK -} - -ClientMethod ButtonClick() [ Language = javascript ] -{ - try { - var adminemail=zen('AdminEmailText').getValue(); - var http=zen('HTTPButton').getValue(); - var server=zen('ServerText').getValue(); - var port=zen('PortText').getValue(); - - var status=zenPage.SaveConfiguration(adminemail,http,server,port); - } - catch(ex) { - zenExceptionHandler(ex,arguments); - } -} - -Method SaveConfiguration(pAdminEmail, pHttp, pServer, pPort) As %Status [ ZenMethod ] -{ - Set tSC=$$$OK - - Set tSC = ##class(PivotSubscriptions.Utility).ConfigureSettings(pAdminEmail, pHttp, pServer, pPort) - - Quit tSC -} - -} \ No newline at end of file +Include %DeepSee + +/// Configuration page that lets users of Pivot Subscriptions to set the default admin's email for table errors and instant emails (sendNow feature), as well as set the generated link to match the application's namespace, webserver/port, and application name. +Class PivotSubscriptions.UI.ConfigurationPage Extends PivotSubscriptions.UI.Template +{ + +/// Displayed name of this page. +Parameter PAGENAME = "Configuration Page"; + +/// This XML block defines the contents of this pane. +XData contentPane [ XMLNamespace = "http://www.intersystems.com/zen" ] +{ + +
+ + + +