diff --git a/PivotSubscriptions/EventLog.cls b/PivotSubscriptions/EventLog.cls
index ed6b55b..185e028 100644
--- a/PivotSubscriptions/EventLog.cls
+++ b/PivotSubscriptions/EventLog.cls
@@ -2,11 +2,8 @@
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");
+/// Event Type covers: create, update, delete, sendSubscription, and tableError
+Property EventType As %String(VALUELIST = ",create,update,delete,sendSubscription,tableError");
Property StartTime As %TimeStamp [ InitialExpression = {$zdt($h, 3, 1)} ];
@@ -31,7 +28,7 @@ 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
+ClassMethod CreateEvent(pType, pUser, pPivot, pDayOfWeek, pHour, pMinute, pFormat, pEmails, pName, ByRef pEvent) As %Status
{
Set tSC=$$$OK
@@ -48,18 +45,13 @@ ClassMethod LogEvent(pType, pUser, pPivot, pDayOfWeek, pHour, pMinute, pFormat,
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
+Method UpdateStatus(pStatus) As %Status
{
Set tSC=$$$OK
@@ -70,6 +62,22 @@ Method LogUpdate(pStatus) As %Status
Quit tSC
}
+Method UpdateEvent(pDayOfWeek, pHour, pMinute, pFormat, pEmails, pName) As %Status
+{
+ Set tSC=$$$OK
+
+ Set ..DayOfWeek=pDayOfWeek
+ Set ..Hour=pHour
+ Set ..Minute=pMinute
+ Set ..Format=pFormat
+ Set ..Emails=pEmails
+ Set ..Name=pName
+
+ Set tSC=..%Save()
+
+ Quit tSC
+}
+
ClassMethod DayOfWeekDisplay(pDayOfWeek) As %String [ SqlProc ]
{
Set pDayOfWeek=$Replace(pDayOfWeek,0,"Sunday")
diff --git a/PivotSubscriptions/Installer.cls b/PivotSubscriptions/Installer.cls
index b4f2350..65ae448 100644
--- a/PivotSubscriptions/Installer.cls
+++ b/PivotSubscriptions/Installer.cls
@@ -1,53 +1,53 @@
-Class PivotSubscriptions.Installer
-{
-
-ClassMethod RunInstaller(pRootDir)
-{
- Set tSC=$$$OK
-
- If pRootDir'="" {
- Do $system.OBJ.LoadDir(pRootDir_"/PivotSubscriptions","ck",,1)
- Set tSC=..ImportImage(pRootDir_"/Assets/PivotSubscriptions_BookCover.png")
- If $$$ISERR(tSC) Quit
- }
-
- Set tItem=##class(%DeepSee.UserLibrary.Link).%New()
- Set tItem.fullName="Pivot Subscriptions"
- Set tPage="PivotSubscriptions.UI.SubscriptionManager.zen"
- Set tItem.href=$system.CSP.GetPortalApp($namespace,tPage)_tPage
- Set tItem.title="Pivot Subscriptions"
- Set tItem.bookCover="{background: {style:'background:white;',src:'covers/PivotSubscriptions_Cover.png'},header: {text:'$type',style:'display: none;'},title: {text:'$title',style:'display: none;'},image: {style:'display: none;',src:'deepsee/ds2_globe_44.png',imageStyle:'width:64px;height:64px;'},subtitle: {style:'display: none;'},footer: {text:'$owner',style:'display: none;'}}"
- Set tSC=tItem.%Save()
-
- If $$$ISERR(tSC) Quit
-
- Set tSC=##class(PivotSubscriptions.Task).ConfigureTask()
-
- Quit tSC
-}
-
-/// Import Cover, code taken from %DeepSee.UI.Dialog.ImageUpload:%OnSubmit
-ClassMethod ImportImage(pDir) As %Status
-{
- Set tSC=$$$OK
- Set tStream=##class(%Stream.FileBinary).%New()
- Set tSC=tStream.LinkToFile(pDir)
- If $$$ISERR(tSC) Quit
- Set tName="PivotSubscriptions_Cover.png"
-
- If $IsObject(tStream)&&(tName'="") {
- Set tFileName=##class(%File).NormalizeDirectory(tName,##class(%DeepSee.UI.Dialog.ImageUpload).%GetImageDirectory())
- Set tLocalFile=##class(%File).%New(tFileName)
- Set tSC=tLocalFile.Open("WSN")
- If $$$ISERR(tSC) Quit
-
- Set tSC=tLocalFile.CopyFrom(tStream)
- If $$$ISERR(tSC) Quit
-
- Do tLocalFile.Close()
- }
-
- Quit tSC
-}
-
-}
\ No newline at end of file
+Class PivotSubscriptions.Installer
+{
+
+ClassMethod RunInstaller(pRootDir)
+{
+ Set tSC=$$$OK
+
+ If pRootDir'="" {
+ Do $system.OBJ.LoadDir(pRootDir_"/PivotSubscriptions","ck",,1)
+ Set tSC=..ImportImage(pRootDir_"/Assets/PivotSubscriptions_BookCover.png")
+ If $$$ISERR(tSC) Quit
+ }
+
+ Set tItem=##class(%DeepSee.UserLibrary.Link).%New()
+ Set tItem.fullName="Pivot Subscriptions"
+ Set tPage="PivotSubscriptions.UI.SubscriptionManager.zen"
+ Set tItem.href=$system.CSP.GetPortalApp($namespace,tPage)_tPage
+ Set tItem.title="Pivot Subscriptions"
+ Set tItem.bookCover="{background: {style:'background:white;',src:'covers/PivotSubscriptions_Cover.png'},header: {text:'$type',style:'display: none;'},title: {text:'$title',style:'display: none;'},image: {style:'display: none;',src:'deepsee/ds2_globe_44.png',imageStyle:'width:64px;height:64px;'},subtitle: {style:'display: none;'},footer: {text:'$owner',style:'display: none;'}}"
+ Set tSC=tItem.%Save()
+
+ If $$$ISERR(tSC) Quit
+
+ Set tSC=##class(PivotSubscriptions.Task).ConfigureTask()
+
+ Quit tSC
+}
+
+/// Import Cover, code taken from %DeepSee.UI.Dialog.ImageUpload:%OnSubmit
+ClassMethod ImportImage(pDir) As %Status
+{
+ Set tSC=$$$OK
+ Set tStream=##class(%Stream.FileBinary).%New()
+ Set tSC=tStream.LinkToFile(pDir)
+ If $$$ISERR(tSC) Quit
+ Set tName="PivotSubscriptions_Cover.png"
+
+ If $IsObject(tStream)&&(tName'="") {
+ Set tFileName=##class(%File).NormalizeDirectory(tName,##class(%DeepSee.UI.Dialog.ImageUpload).%GetImageDirectory())
+ Set tLocalFile=##class(%File).%New(tFileName)
+ Set tSC=tLocalFile.Open("WSN")
+ If $$$ISERR(tSC) Quit
+
+ Set tSC=tLocalFile.CopyFrom(tStream)
+ If $$$ISERR(tSC) Quit
+
+ Do tLocalFile.Close()
+ }
+
+ Quit tSC
+}
+
+}
diff --git a/PivotSubscriptions/Subscription.cls b/PivotSubscriptions/Subscription.cls
index 8ad03b6..e15cfb4 100644
--- a/PivotSubscriptions/Subscription.cls
+++ b/PivotSubscriptions/Subscription.cls
@@ -23,6 +23,8 @@ Property Name As %String(MAXLEN = 100);
Property CustomFilters As array Of %String(MAXLEN = "");
+Property CustomEmailText As %String(MAXLEN = "");
+
Storage Default
{
@@ -61,6 +63,9 @@ Storage Default
Name
+
+CustomEmailText
+^PivotSubscriptions.SubDSubscriptionDefaultData
diff --git a/PivotSubscriptions/Task.cls b/PivotSubscriptions/Task.cls
index a250c4c..8d017d9 100644
--- a/PivotSubscriptions/Task.cls
+++ b/PivotSubscriptions/Task.cls
@@ -12,7 +12,7 @@ Method OnTask() As %Status
Set tHour=$PIECE($ZTIME($PIECE($HOROLOG,",",2),2),":",1)
Set tMinute=$PIECE($ZTIME($PIECE($HOROLOG,",",2),2),":",2)
- If $G(^PivotSubscriptions.Settings("TestEnv")) {
+ If ##class(PivotSubscriptions.Utils).GetSettings("TestEnv",0) {
// 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
@@ -41,9 +41,6 @@ Method OnTask() As %Status
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)
@@ -54,14 +51,6 @@ ClassMethod SendSubscription(pID, pPivot As %String, pEmails As %String, pFormat
} 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
}
@@ -72,14 +61,17 @@ ClassMethod SendEmail(pID, pPivot As %String, pEmails As %String, pFormat As %St
Set tFilename=""
Set mdx=##class(%DeepSee.Utils).%GetMDXFromPivot(pPivot,.tSC,0)
+ Set tSubscription=##class(PivotSubscriptions.Subscription).%OpenId(pID)
// Iterate through all subscribers and send emails to each individually
- For count=1:1:$l(pEmails,",") {
- Set tEmail=$p(pEmails,",",count)
+ For tCount=1:1:$l(pEmails,",") {
+ Set tEmail=$p(pEmails,",",tCount)
+
+ Set tSC=##class(PivotSubscriptions.EventLog).CreateEvent("sendSubscription",$username,pPivot,tSubscription.DayOfWeek,tSubscription.Hour,tSubscription.Minute,tSubscription.Format,tEmail,pName,.pEvent)
+ If $$$ISERR(tSC) Quit tSC
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)
@@ -101,7 +93,7 @@ ClassMethod SendEmail(pID, pPivot As %String, pEmails As %String, pFormat As %St
Set validAdminEmail=##class(PivotSubscriptions.Utils).CheckConfigurationGlobal("AdminEmail")
If validAdminEmail {
- Set msg.ReplyTo=^PivotSubscriptions.Settings("AdminEmail")
+ Set msg.ReplyTo=##class(PivotSubscriptions.Utils).GetSettings("AdminEmail")
}
// Remove ".pivot" extension for subject
@@ -110,9 +102,8 @@ ClassMethod SendEmail(pID, pPivot As %String, pEmails As %String, pFormat As %St
Set msg.IsHTML=1 // Set IsHTML to 1 if email uses HTML
If tHasResults {
-
// Add attachment
- Do ##class(PivotSubscriptions.Utils).WriteEmail(pName, msg, tableStatus)
+ Do ##class(PivotSubscriptions.Utils).WriteEmail(tSubscription, msg, tableStatus)
// if table is too large, then just attach Excel instead
If ((pFormat = "PDF") && (tableStatus)) {
@@ -120,7 +111,7 @@ ClassMethod SendEmail(pID, pPivot As %String, pEmails As %String, pFormat As %St
} 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)
+ Do ##class(PivotSubscriptions.Utils).TableErrorMessage(tSubscription,tEmail,pName,"TooLarge")
}
}
@@ -132,18 +123,22 @@ ClassMethod SendEmail(pID, pPivot As %String, pEmails As %String, pFormat As %St
}
} Else {
Do ##class(PivotSubscriptions.Utils).WriteEmailHeader(msg)
- Do msg.TextData.WriteLine($G(^PivotSubscriptions.Settings("NoDataMessage"),"No data for requested pivot."))
+ Do msg.TextData.WriteLine(##class(PivotSubscriptions.Utils).GetSettings("NoDataMessage","No data for requested pivot."))
+ Do ##class(PivotSubscriptions.Utils).WriteUnsubscribe(msg)
Do ##class(PivotSubscriptions.Utils).WriteEmailFooter(msg)
+
+ Do ##class(PivotSubscriptions.Utils).TableErrorMessage(tSubscription,tEmail,pName,"NoResults")
}
}
Do msg.To.SetAt(tEmail,1)
// Send email
- If tHasResults||$G(^PivotSubscriptions.Settings("SendNoData"),1) {
+ If tHasResults||##class(PivotSubscriptions.Utils).GetSettings("SendNoData",1) {
Set tSC=server.Send(msg)
+ Set tSC=pEvent.UpdateStatus(tSC)
+ If $$$ISERR(tSC) Quit tSC
}
- // TODO: Log individual send status?
If tHasResults {
// Delete file
diff --git a/PivotSubscriptions/UI/ConfigurationPage.cls b/PivotSubscriptions/UI/ConfigurationPage.cls
index 0720bbe..894ebbc 100644
--- a/PivotSubscriptions/UI/ConfigurationPage.cls
+++ b/PivotSubscriptions/UI/ConfigurationPage.cls
@@ -22,6 +22,9 @@ XData contentPane [ XMLNamespace = "http://www.intersystems.com/zen" ]
+
+
+
@@ -52,23 +55,29 @@ Method %OnGetProductName() As %String [ Internal ]
Method %OnAfterCreatePage() As %Status
{
// 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 ##class(PivotSubscriptions.Utils).GetSettings("AdminEmail")'="" {
+ Set ..%GetComponentById("AdminEmailText").value=##class(PivotSubscriptions.Utils).GetSettings("AdminEmail")
}
- If $G(^PivotSubscriptions.Settings("Http"))'="" {
- Set ..%GetComponentById("HTTPButton").value=^PivotSubscriptions.Settings("Http")
+ If ##class(PivotSubscriptions.Utils).GetSettings("Http")'="" {
+ Set ..%GetComponentById("HTTPButton").value=##class(PivotSubscriptions.Utils).GetSettings("Http")
}
- If $G(^PivotSubscriptions.Settings("Server"))'="" {
- Set ..%GetComponentById("ServerText").value=^PivotSubscriptions.Settings("Server")
+ If ##class(PivotSubscriptions.Utils).GetSettings("Server")'="" {
+ Set ..%GetComponentById("ServerText").value=##class(PivotSubscriptions.Utils).GetSettings("Server")
}
- If $G(^PivotSubscriptions.Settings("Port"))'="" {
- Set ..%GetComponentById("PortText").value=^PivotSubscriptions.Settings("Port")
+ If ##class(PivotSubscriptions.Utils).GetSettings("Port")'="" {
+ Set ..%GetComponentById("PortText").value=##class(PivotSubscriptions.Utils).GetSettings("Port")
}
- If $G(^PivotSubscriptions.Settings("SendNoData"))'="" {
- Set ..%GetComponentById("NoDataEmail").value=^PivotSubscriptions.Settings("SendNoData")
+ If ##class(PivotSubscriptions.Utils).GetSettings("SendNoData")'="" {
+ Set ..%GetComponentById("NoDataEmail").value=##class(PivotSubscriptions.Utils).GetSettings("SendNoData")
}
- If $G(^PivotSubscriptions.Settings("NoDataMessage"))'="" {
- Set ..%GetComponentById("NoDataMessage").value=^PivotSubscriptions.Settings("NoDataMessage")
+ If ##class(PivotSubscriptions.Utils).GetSettings("NoDataMessage")'="" {
+ Set ..%GetComponentById("NoDataMessage").value=##class(PivotSubscriptions.Utils).GetSettings("NoDataMessage")
+ }
+ If $G(^PivotSubscriptions.Settings("CustomFooter"))'="" {
+ Set ..%GetComponentById("CustomFooter").value=^PivotSubscriptions.Settings("CustomFooter")
+ }
+ If $G(^PivotSubscriptions.Settings("CustomFooterMessage"))'="" {
+ Set ..%GetComponentById("CustomFooterMessage").value=^PivotSubscriptions.Settings("CustomFooterMessage")
}
Quit $$$OK
@@ -83,19 +92,21 @@ ClientMethod ButtonClick() [ Language = javascript ]
var port=zen('PortText').getValue();
var nodataemail=zen('NoDataEmail').getValue();
var nodatamessage=zen('NoDataMessage').getValue();
+ var customfooter=zen('CustomFooter').getValue();
+ var customfootermessage=zen('CustomFooterMessage').getValue();
- var status=zenPage.SaveConfiguration(adminemail,http,server,port,nodataemail,nodatamessage);
+ var status=zenPage.SaveConfiguration(adminemail,http,server,port,nodataemail,nodatamessage,customfooter,customfootermessage);
}
catch(ex) {
zenExceptionHandler(ex,arguments);
}
}
-Method SaveConfiguration(pAdminEmail, pHttp, pServer, pPort, pNoDataEmail, pNoDataMessage) As %Status [ ZenMethod ]
+Method SaveConfiguration(pAdminEmail, pHttp, pServer, pPort, pNoDataEmail, pNoDataMessage, pCustomFooter, pCustomFooterMessage) As %Status [ ZenMethod ]
{
Set tSC=$$$OK
- Set tSC = ##class(PivotSubscriptions.Utils).ConfigureSettings(pAdminEmail, pHttp, pServer, pPort, pNoDataEmail, pNoDataMessage)
+ Set tSC = ##class(PivotSubscriptions.Utils).ConfigureSettings(pAdminEmail, pHttp, pServer, pPort, pNoDataEmail, pNoDataMessage, pCustomFooter, pCustomFooterMessage)
Quit tSC
}
diff --git a/PivotSubscriptions/UI/Dialog/EditSubscription.cls b/PivotSubscriptions/UI/Dialog/EditSubscription.cls
index c3db468..7caf634 100644
--- a/PivotSubscriptions/UI/Dialog/EditSubscription.cls
+++ b/PivotSubscriptions/UI/Dialog/EditSubscription.cls
@@ -49,6 +49,9 @@ XData dialogBody [ XMLNamespace = "http://www.intersystems.com/zen" ]
+
+
+
}
@@ -74,6 +77,7 @@ Method %OnAfterCreatePage() As %Status
Set ..%GetComponentById("Format").value=tSubscription.Format
Set ..%GetComponentById("Emails").value=tSubscription.Emails
Set ..%GetComponentById("SubscriptionName").value=tSubscription.Name
+ Set ..%GetComponentById("CustomEmailText").value=tSubscription.CustomEmailText
// Populate CustomFilters
Set tKey=""
@@ -113,7 +117,6 @@ Method %OnAfterCreatePage() As %Status
ClientMethod ondialogFinish(action) As %Boolean [ Language = javascript ]
{
try {
-
var subscriptionid=zen('SubscriptionId').getValue();
var dayofweek=zen('DayOfWeek').getValue();
var hour=zen('Hour').getValue();
@@ -122,8 +125,9 @@ ClientMethod ondialogFinish(action) As %Boolean [ Language = javascript ]
var emails=zen('Emails').getValue();
var name=zen('SubscriptionName').getValue();
var pivot=this.pivotName;
+ var emailtext=zen('CustomEmailText').getValue();
- var status=zenPage.EditSubscription(subscriptionid,pivot,dayofweek,hour,minute,emails,format,name);
+ var status=zenPage.EditSubscription(subscriptionid,pivot,dayofweek,hour,minute,emails,format,name,emailtext);
if (status!=1) {
alert("Error during save, see Event Log for more details.");
@@ -132,6 +136,7 @@ ClientMethod ondialogFinish(action) As %Boolean [ Language = javascript ]
catch(ex) {
zenExceptionHandler(ex,arguments);
}
+
return true;
}
@@ -140,7 +145,7 @@ ClientMethod getDialogValue() [ Language = javascript ]
return '';
}
-Method EditSubscription(pSubscriptionId, pPivot, pDayOfWeek, pHour, pMinute, pEmails, pFormat, pName) As %Status [ ZenMethod ]
+Method EditSubscription(pSubscriptionId, pPivot, pDayOfWeek, pHour, pMinute, pEmails, pFormat, pName, pEmailText) As %Status [ ZenMethod ]
{
Set tSC=$$$OK
@@ -154,14 +159,16 @@ Method EditSubscription(pSubscriptionId, pPivot, pDayOfWeek, pHour, pMinute, pEm
Set tSubscription.Pivot=pPivot
Set tEventType="create"
}
- Set tSC=##class(PivotSubscriptions.EventLog).LogEvent(tEventType,$username,tSubscription.Pivot,pDayOfWeek,pHour,pMinute,pFormat,pEmails,pName,.tEvent)
-
+
+ Set tSC=##class(PivotSubscriptions.EventLog).CreateEvent(tEventType,$username,tSubscription.Pivot,tSubscription.DayOfWeek,tSubscription.Hour,tSubscription.Minute,tSubscription.Format,tSubscription.Emails,tSubscription.Name,.tEvent)
+
Set tSubscription.DayOfWeek=pDayOfWeek
Set tSubscription.Hour=pHour
Set tSubscription.Minute=pMinute
Set tSubscription.Format=pFormat
Set tSubscription.Emails=pEmails
Set tSubscription.Name=pName
+ Set tSubscription.CustomEmailText=pEmailText
// Get Custom Filter info
Set tKey=""
@@ -173,14 +180,38 @@ Method EditSubscription(pSubscriptionId, pPivot, pDayOfWeek, pHour, pMinute, pEm
}
Set tSC=tSubscription.%Save()
-
- Do tEvent.LogUpdate(tSC)
-
+ Do tEvent.UpdateStatus(tSC)
+ If tSC {
+ Do tEvent.UpdateEvent(pDayOfWeek,pHour,pMinute,pFormat,pEmails,pName)
+ }
+
+ Quit tSC
+}
+
+Method ValidateEmails() As %Status [ ZenMethod ]
+{
+ Set tSC=$$$OK
+
+ Set tEmails=..%GetComponentById("Emails")
+ Set tEmails.value=$zstrip(tEmails.value,"*WC")
+ Do {
+ Set tUpdated=0
+ If $e(tEmails.value,1)="," {
+ Set tEmails.value=$e(tEmails.value,2,*)
+ Set tUpdated=1
+ }
+ If $e(tEmails.value,*)="," {
+ Set tEmails.value=$e(tEmails.value,1,*-1)
+ Set tUpdated=1
+ }
+ } While tUpdated
+
Quit tSC
}
ClientMethod populateEmailList() [ Language = javascript ]
{
+ zenPage.ValidateEmails();
var emailList=zen('EmailList');
emailList.resetOptions();
diff --git a/PivotSubscriptions/UI/PivotList.cls b/PivotSubscriptions/UI/PivotList.cls
index e191a6c..b6fffe0 100644
--- a/PivotSubscriptions/UI/PivotList.cls
+++ b/PivotSubscriptions/UI/PivotList.cls
@@ -1,123 +1,123 @@
-Include %DeepSee
-
-Class PivotSubscriptions.UI.PivotList Extends PivotSubscriptions.UI.Template
-{
-
-/// Displayed name of this page.
-Parameter PAGENAME = "Pivot List";
-
-/// 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("Pivot List","PivotSubscriptions")
-}
-
-/// Get the (localized) name of the page.
-Method %OnGetPageName() As %String [ Internal ]
-{
- Quit $$$Text("Pivot List","PivotSubscriptions")
-}
-
-Method ExecuteRS(pRS As %ResultSet, Output pSC As %Status, pInfo As %ZEN.Auxiliary.QueryInfo) As %Boolean
-{
- Quit pRS.%Execute($G(pInfo.filters("POwner")),$G(pInfo.filters("PName")))
-}
-
-ClientMethod launchAddSubscription(pivotName) [ Language = javascript ]
-{
- var url=zenLink('PivotSubscriptions.UI.Dialog.EditSubscription.zen')+'?SUBSCRIPTIONID=0&PIVOTNAME='+encodeURIComponent(pivotName);
- zenPage.launchPopupWindow(url,'Add Subscription','status,scrollbars,resizable,width=700,height=575');
-}
-
-ClassMethod DrawAddSubscriptionLink(pTable As %ZEN.Component.tablePane, pName As %String, pSeed As %String) As %Status [ Internal ]
-{
- &html<#("Add Subscription")#>
-
- Quit $$$OK
-}
-
-Query GetPivots(pOwner As %String = "", pName As %String = "") As %Query(ROWSPEC = "POwner:%String,PName:%String,PSubscription:%String")
-{
-}
-
-ClassMethod GetPivotsExecute(ByRef qHandle As %Binary, pOwner As %String = "", pName As %String = "") As %Status
-{
- Set tSC=$$$OK
-
- Set tSC=##class(%DeepSee.UserPortal.Utils).%GetFolderItemsForUser(.tItems,,,1,1)
-
- If $$$ISERR(tSC) Quit tSC
-
- Set tItem=$O(tItems(""))
- While tItem'="" {
- If $LG(tItems(tItem),2)="Pivot" {
- Set tTemp=tItems(tItem)
- If (pOwner'="")&&($$$UPPER($LG(tTemp,10))'[$$$UPPER(pOwner)) {
- Set tTemp=""
- }
- If (pName'="")&&($$$UPPER($LG(tTemp,1))'[$$$UPPER(pName)) {
- Set tTemp=""
- }
- Set:tTemp'="" tPivots($I(tPivots))=tTemp // Sort by pivot ID
- //Set:tTemp'="" tPivots($LG(tTemp,1))=tTemp // Sort by pivot name
- }
- Set tItem=$O(tItems(tItem))
- }
-
- Merge ^||PivotSubscriptions.getPivotExecute=tPivots
- Set qHandle=""
- Quit $$$OK
-}
-
-ClassMethod GetPivotsFetch(ByRef qHandle As %Binary, ByRef Row As %List, ByRef AtEnd As %Integer = 0) As %Status [ PlaceAfter = GetPivotsExecute ]
-{
- Set qHandle=$O(^||PivotSubscriptions.getPivotExecute(qHandle))
- If qHandle="" {
- Set AtEnd=1
- Quit $$$OK
- }
-
- Set Row=$lb($LG(^||PivotSubscriptions.getPivotExecute(qHandle),10),$LG(^||PivotSubscriptions.getPivotExecute(qHandle),1),"Subscription")
- Set AtEnd=0
-
- Quit $$$OK
-}
-
-ClassMethod GetPivotsClose(ByRef qHandle As %Binary) As %Status [ PlaceAfter = GetPivotsFetch ]
-{
- Set qHandle=""
- Quit $$$OK
-}
-
-}
+Include %DeepSee
+
+Class PivotSubscriptions.UI.PivotList Extends PivotSubscriptions.UI.Template
+{
+
+/// Displayed name of this page.
+Parameter PAGENAME = "Pivot List";
+
+/// 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("Pivot List","PivotSubscriptions")
+}
+
+/// Get the (localized) name of the page.
+Method %OnGetPageName() As %String [ Internal ]
+{
+ Quit $$$Text("Pivot List","PivotSubscriptions")
+}
+
+Method ExecuteRS(pRS As %ResultSet, Output pSC As %Status, pInfo As %ZEN.Auxiliary.QueryInfo) As %Boolean
+{
+ Quit pRS.%Execute($G(pInfo.filters("POwner")),$G(pInfo.filters("PName")))
+}
+
+ClientMethod launchAddSubscription(pivotName) [ Language = javascript ]
+{
+ var url=zenLink('PivotSubscriptions.UI.Dialog.EditSubscription.zen')+'?SUBSCRIPTIONID=0&PIVOTNAME='+encodeURIComponent(pivotName);
+ zenPage.launchPopupWindow(url,'Add Subscription','status,scrollbars,resizable,width=700,height=575');
+}
+
+ClassMethod DrawAddSubscriptionLink(pTable As %ZEN.Component.tablePane, pName As %String, pSeed As %String) As %Status [ Internal ]
+{
+ &html<#("Add Subscription")#>
+
+ Quit $$$OK
+}
+
+Query GetPivots(pOwner As %String = "", pName As %String = "") As %Query(ROWSPEC = "POwner:%String,PName:%String,PSubscription:%String")
+{
+}
+
+ClassMethod GetPivotsExecute(ByRef qHandle As %Binary, pOwner As %String = "", pName As %String = "") As %Status
+{
+ Set tSC=$$$OK
+
+ Set tSC=##class(%DeepSee.UserPortal.Utils).%GetFolderItemsForUser(.tItems,,,1,1)
+
+ If $$$ISERR(tSC) Quit tSC
+
+ Set tItem=$O(tItems(""))
+ While tItem'="" {
+ If $LG(tItems(tItem),2)="Pivot" {
+ Set tTemp=tItems(tItem)
+ If (pOwner'="")&&($$$UPPER($LG(tTemp,10))'[$$$UPPER(pOwner)) {
+ Set tTemp=""
+ }
+ If (pName'="")&&($$$UPPER($LG(tTemp,1))'[$$$UPPER(pName)) {
+ Set tTemp=""
+ }
+ Set:tTemp'="" tPivots($I(tPivots))=tTemp // Sort by pivot ID
+ //Set:tTemp'="" tPivots($LG(tTemp,1))=tTemp // Sort by pivot name
+ }
+ Set tItem=$O(tItems(tItem))
+ }
+
+ Merge ^||PivotSubscriptions.getPivotExecute=tPivots
+ Set qHandle=""
+ Quit $$$OK
+}
+
+ClassMethod GetPivotsFetch(ByRef qHandle As %Binary, ByRef Row As %List, ByRef AtEnd As %Integer = 0) As %Status [ PlaceAfter = GetPivotsExecute ]
+{
+ Set qHandle=$O(^||PivotSubscriptions.getPivotExecute(qHandle))
+ If qHandle="" {
+ Set AtEnd=1
+ Quit $$$OK
+ }
+
+ Set Row=$lb($LG(^||PivotSubscriptions.getPivotExecute(qHandle),10),$LG(^||PivotSubscriptions.getPivotExecute(qHandle),1),"Subscription")
+ Set AtEnd=0
+
+ Quit $$$OK
+}
+
+ClassMethod GetPivotsClose(ByRef qHandle As %Binary) As %Status [ PlaceAfter = GetPivotsFetch ]
+{
+ Set qHandle=""
+ Quit $$$OK
+}
+
+}
diff --git a/PivotSubscriptions/UI/SubscriptionManager.cls b/PivotSubscriptions/UI/SubscriptionManager.cls
index b14e373..84a1ebb 100644
--- a/PivotSubscriptions/UI/SubscriptionManager.cls
+++ b/PivotSubscriptions/UI/SubscriptionManager.cls
@@ -88,7 +88,7 @@ ClientMethod onPopupAction(popupName, action, value) [ Internal, Language = java
ClientMethod editSubscription(pId, pPivot) [ Internal, Language = javascript ]
{
var parms = {
- MODE:"models",
+ MODE:"models",
};
zenLaunchPopupWindow('PivotSubscriptions.UI.Dialog.EditSubscription.cls?SUBSCRIPTIONID='+pId+'&PIVOTNAME='+pPivot,'PivotSubscriptions','status,resizable=yes,width=700,height=575',parms);
@@ -133,7 +133,7 @@ Method Delete(pId As %Integer) As %String [ ZenMethod ]
Set tMsg="Subscription Deleted."
Set tSubscription=##class(PivotSubscriptions.Subscription).%OpenId(pId)
- Set tSC=##class(PivotSubscriptions.EventLog).LogEvent("delete",$username,tSubscription.Pivot,tSubscription.DayOfWeek,tSubscription.Hour,tSubscription.Minute,tSubscription.Format,tSubscription.Emails,tSubscription.Name,.tEvent)
+ Set tSC=##class(PivotSubscriptions.EventLog).CreateEvent("delete",$username,tSubscription.Pivot,tSubscription.DayOfWeek,tSubscription.Hour,tSubscription.Minute,tSubscription.Format,tSubscription.Emails,tSubscription.Name,.tEvent)
If $$$ISERR(tSC) Quit tSC
@@ -141,7 +141,7 @@ Method Delete(pId As %Integer) As %String [ ZenMethod ]
If $$$ISERR(tSC) {
Set tMsg=$System.Status.GetErrorText(tSC)
}
- Set tSC=tEvent.LogUpdate(tSC)
+ Set tSC=tEvent.UpdateStatus(tSC)
Quit tMsg
}
@@ -153,7 +153,7 @@ Method SendNow(pId, pPivot, pEmail As %String) As %String [ ZenMethod ]
If pId'=0 {
Set tSubscription=##class(PivotSubscriptions.Subscription).%OpenId(pId)
- Set tSC=##class(PivotSubscriptions.Task).SendSubscription(pId, pPivot, pEmail, tSubscription.Format,tSubscription.DayOfWeek,tSubscription.Hour,tSubscription.Minute,tSubscription.Name)
+ Set tSC=##class(PivotSubscriptions.Task).SendSubscription(pId,pPivot,pEmail,tSubscription.Format,tSubscription.DayOfWeek,tSubscription.Hour,tSubscription.Minute,tSubscription.Name)
If $$$ISERR(tSC) {
Set tMsg=$System.Status.GetErrorText(tSC)
@@ -165,19 +165,14 @@ Method SendNow(pId, pPivot, pEmail As %String) As %String [ ZenMethod ]
Method GetManagerEmail() As %String [ ZenMethod ]
{
- Set tSC=##class(PivotSubscriptions.Utils).CheckConfigurationGlobal("AdminEmail")
-
- If tSC {
- Quit ^PivotSubscriptions.Settings("AdminEmail")
- }
-
- Quit ""
+ Quit ##class(PivotSubscriptions.Utils).GetSettings("AdminEmail")
}
/// Query to get subscriptions for Subscription Manager display table.
Query GetSubscriptionsForDisplay() As %SQLQuery
{
- SELECT ID,Name,Pivot,Emails FROM PivotSubscriptions.Subscription
+ SELECT ID,Name,Pivot,Emails
+ FROM PivotSubscriptions.Subscription
}
}
diff --git a/PivotSubscriptions/Utils.cls b/PivotSubscriptions/Utils.cls
index 6a501d0..7be848b 100644
--- a/PivotSubscriptions/Utils.cls
+++ b/PivotSubscriptions/Utils.cls
@@ -3,11 +3,11 @@ Class PivotSubscriptions.Utils
ClassMethod GetVersion() As %String
{
- Quit "v1.2.2"
+ Quit "v1.3.0"
}
/// Utility method for saving and updating global variables
-ClassMethod ConfigureSettings(pAdminEmail, pHttp, pServer, pPort, pNoDataEmail, pNoDataMessage)
+ClassMethod ConfigureSettings(pAdminEmail, pHttp, pServer, pPort, pNoDataEmail, pNoDataMessage, pCustomFooter, pCustomFooterMessage)
{
Set ^PivotSubscriptions.Settings("AdminEmail")=pAdminEmail
Set ^PivotSubscriptions.Settings("Http")=pHttp
@@ -15,6 +15,8 @@ ClassMethod ConfigureSettings(pAdminEmail, pHttp, pServer, pPort, pNoDataEmail,
Set ^PivotSubscriptions.Settings("Port")=pPort
Set ^PivotSubscriptions.Settings("SendNoData")=pNoDataEmail
Set ^PivotSubscriptions.Settings("NoDataMessage")=pNoDataMessage
+ Set ^PivotSubscriptions.Settings("CustomFooter")=pCustomFooter
+ Set ^PivotSubscriptions.Settings("CustomFooterMessage")=pCustomFooterMessage
Quit $$$OK
}
@@ -22,7 +24,7 @@ ClassMethod ConfigureSettings(pAdminEmail, pHttp, pServer, pPort, pNoDataEmail,
ClassMethod CheckConfigurationGlobal(pConfigurationOptionName As %String)
{
If ((pConfigurationOptionName'="") && $DATA(^PivotSubscriptions.Settings(pConfigurationOptionName))) {
- If (^PivotSubscriptions.Settings(pConfigurationOptionName)'="") {
+ If ##class(PivotSubscriptions.Utils).GetSettings(pConfigurationOptionName)'="" {
Quit 1
}
}
@@ -30,7 +32,12 @@ ClassMethod CheckConfigurationGlobal(pConfigurationOptionName As %String)
Quit 0
}
-ClassMethod GenerateLink(ByRef link As %String) As %Status
+ClassMethod GetSettings(pSetting As %String, pDefaultValue As %String = "") As %String
+{
+ Quit $G(^PivotSubscriptions.Settings(pSetting),pDefaultValue)
+}
+
+ClassMethod GenerateLink(ByRef pLink As %String) As %Status
{
Set tSC=$$$OK
@@ -38,19 +45,19 @@ ClassMethod GenerateLink(ByRef link As %String) As %Status
If $$$ISERR(tSC) Quit tSC
If ..CheckConfigurationGlobal("Http") {
- Set tWebServerPortUrl=^PivotSubscriptions.Settings("Http")
+ Set tWebServerPortUrl=##class(PivotSubscriptions.Utils).GetSettings("Http")
} Else {
Set tWebServerPortUrl="http://"
}
If ..CheckConfigurationGlobal("Server") {
- Set tWebServerPortUrl=tWebServerPortUrl_^PivotSubscriptions.Settings("Server")
+ Set tWebServerPortUrl=tWebServerPortUrl_##class(PivotSubscriptions.Utils).GetSettings("Server")
} Else {
Set tWebServerPortUrl=tWebServerPortUrl_h
}
If ..CheckConfigurationGlobal("Port") {
- Set tWebServerPortUrl=tWebServerPortUrl_":"_^PivotSubscriptions.Settings("Port")
+ Set tWebServerPortUrl=tWebServerPortUrl_":"_##class(PivotSubscriptions.Utils).GetSettings("Port")
} Else {
If '..CheckConfigurationGlobal("Server") {
Set tWebServerPortUrl=tWebServerPortUrl_":"_p
@@ -60,7 +67,7 @@ ClassMethod GenerateLink(ByRef link As %String) As %Status
Set tNamespace=$System.CSP.GetDefaultApp($Namespace)
Set tApplicationName="/PivotSubscriptions.UI.SubscriptionManager.zen"
- Set link=tWebServerPortUrl_tNamespace_tApplicationName
+ Set pLink=tWebServerPortUrl_tNamespace_tApplicationName
Quit tSC
}
@@ -77,19 +84,19 @@ ClassMethod CheckTable(pName As %String) As %Status
If $$$ISERR(tSC) Quit tSC
Set tTableStatus=0
- Set headerCount=0
+ Set tHeaderCount=0
// iterate through stream to check that table has actual data
While 'tStream.AtEnd {
- Set line = tStream.ReadLine()
+ Set tLine=tStream.ReadLine()
- If $Find(line, "
20) {
+ If (tHeaderCount > 20) {
Set tTableStatus=0
}
Quit
@@ -109,24 +116,37 @@ ClassMethod WriteEmailHeader(pMsg As %Net.MailMessage)
Do pMsg.TextData.WriteLine("
")
}
-/// Write footer for any email, including link generation
-ClassMethod WriteEmailFooter(pMsg As %Net.MailMessage)
+ClassMethod WriteUnsubscribe(pMsg As %Net.MailMessage)
{
- Do ##class(PivotSubscriptions.Utils).GenerateLink(.link)
-
+ Do ##class(PivotSubscriptions.Utils).GenerateLink(.tLink)
+
Do pMsg.TextData.WriteLine("