From 0544a10288d97d24f5a1510e882e6d353a488d1b Mon Sep 17 00:00:00 2001 From: psteiwer Date: Mon, 31 Jan 2022 16:44:58 -0500 Subject: [PATCH 01/11] Display Status in readable format Fixes #113 --- PivotSubscriptions/UI/EventLogViewer.cls | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/PivotSubscriptions/UI/EventLogViewer.cls b/PivotSubscriptions/UI/EventLogViewer.cls index 23528c0..4cc5d6b 100644 --- a/PivotSubscriptions/UI/EventLogViewer.cls +++ b/PivotSubscriptions/UI/EventLogViewer.cls @@ -32,7 +32,7 @@ XData contentPane [ XMLNamespace = "http://www.intersystems.com/zen" ] - + @@ -57,4 +57,10 @@ Method %OnGetPageName() As %String [ Internal ] Quit $$$Text("Event Log Viewer","PivotSubscriptions") } +Method FormatStatus(pTable As %ZEN.Component.tablePane, pName As %String, pSeed As %String) As %Status +{ + Write $System.Status.GetErrorText(%query(pName)) + Quit $$$OK +} + } From 9e112b672db11784b21d21184007c010fcdab3b9 Mon Sep 17 00:00:00 2001 From: psteiwer Date: Wed, 11 May 2022 10:52:26 -0400 Subject: [PATCH 02/11] Add CSV file type option --- PivotSubscriptions/EventLog.cls | 2 +- PivotSubscriptions/Subscription.cls | 2 +- PivotSubscriptions/Task.cls | 16 ++- .../UI/Dialog/EditSubscription.cls | 2 +- PivotSubscriptions/Utils.cls | 111 +++++++++++------- 5 files changed, 86 insertions(+), 47 deletions(-) diff --git a/PivotSubscriptions/EventLog.cls b/PivotSubscriptions/EventLog.cls index 7887903..e39612f 100644 --- a/PivotSubscriptions/EventLog.cls +++ b/PivotSubscriptions/EventLog.cls @@ -19,7 +19,7 @@ Property Hour As %Integer(MAXVAL = 23, MINVAL = 0); Property Minute As %Integer(MAXVAL = 59, MINVAL = 0); -Property Format As %String(VALUELIST = ",Excel,PDF"); +Property Format As %String(VALUELIST = ",Excel,PDF,CSV"); Property Emails As %String(MAXLEN = ""); diff --git a/PivotSubscriptions/Subscription.cls b/PivotSubscriptions/Subscription.cls index 3f83e86..684f19c 100644 --- a/PivotSubscriptions/Subscription.cls +++ b/PivotSubscriptions/Subscription.cls @@ -13,7 +13,7 @@ Property Hour As %Integer(MAXVAL = 23, MINVAL = 0) [ Required ]; Property Minute As %Integer(VALUELIST = ",0,15,30,45") [ Required ]; -Property Format As %String(VALUELIST = ",Excel,PDF"); +Property Format As %String(VALUELIST = ",Excel,PDF,CSV"); Property Emails As %String(MAXLEN = "") [ Required ]; diff --git a/PivotSubscriptions/Task.cls b/PivotSubscriptions/Task.cls index 61ac584..79ebd99 100644 --- a/PivotSubscriptions/Task.cls +++ b/PivotSubscriptions/Task.cls @@ -88,15 +88,19 @@ ClassMethod SendEmail(pID, pSendNow As %Boolean = 0, pPivot As %String, pEmails Set tSC=##class(PivotSubscriptions.Utils).ExecuteForSubscription(mdx,tCustomFilter,.tHasResults) If $$$ISERR(tSC) Quit + Set tFormat="Excel" If tHasResults { // Only generate file if requested pivot has results - Set tSC=##class(PivotSubscriptions.Utils).GenerateFileForSubscription("Excel",mdx,tCustomFilter,pName,pPivot,.tFilename) + If pFormat="CSV" { + Set tFormat="CSV" + } + Set tSC=##class(PivotSubscriptions.Utils).GenerateFileForSubscription(tFormat,mdx,tCustomFilter,pName,pPivot,.tFilename) If $$$ISERR(tSC) Quit } // Generate email // check whether the table generated is too wide/truncated AND whether the table has data - Set tableStatus=##class(PivotSubscriptions.Utils).CheckTable(pName) + Set tableStatus=##class(PivotSubscriptions.Utils).CheckTable(pName,tFilename) Set server=##class(%Net.SMTP).%New() Set server.smtpserver=##class(%SYS.Task.Config).GetData("MailServer") @@ -120,7 +124,7 @@ ClassMethod SendEmail(pID, pSendNow As %Boolean = 0, pPivot As %String, pEmails If tHasResults { // Add attachment - Do ##class(PivotSubscriptions.Utils).WriteEmail(tSubscription,msg,tableStatus,tUnsubscribeList) + Do ##class(PivotSubscriptions.Utils).WriteEmail(tSubscription,msg,tableStatus,tUnsubscribeList,.tFilename) // if table is too large, then just attach Excel instead If ((pFormat = "PDF") && (tableStatus)) { @@ -135,7 +139,11 @@ ClassMethod SendEmail(pID, pSendNow As %Boolean = 0, pPivot As %String, pEmails } } - Set tSC=msg.AttachFile("",tFilename) + If $L(tFilename,"\") { + Set tSC=msg.AttachFile($P(tFilename,"\",1,*-1),$P(tFilename,"\",*)) + } Else { + Set tSC=msg.AttachFile("",tFilename) + } If $$$ISERR(tSC) Quit } Else { Do ##class(PivotSubscriptions.Utils).WriteEmailHeader(msg) diff --git a/PivotSubscriptions/UI/Dialog/EditSubscription.cls b/PivotSubscriptions/UI/Dialog/EditSubscription.cls index 25aec26..ed27cf7 100644 --- a/PivotSubscriptions/UI/Dialog/EditSubscription.cls +++ b/PivotSubscriptions/UI/Dialog/EditSubscription.cls @@ -41,7 +41,7 @@ XData dialogBody [ XMLNamespace = "http://www.intersystems.com/zen" ] - +