Skip to content

Commit

Permalink
Merge pull request #117 from psteiwer/dev
Browse files Browse the repository at this point in the history
Dev v1.8
  • Loading branch information
psteiwer authored Nov 3, 2022
2 parents c04b859 + 68d12e5 commit d108af2
Show file tree
Hide file tree
Showing 10 changed files with 284 additions and 201 deletions.
2 changes: 1 addition & 1 deletion PivotSubscriptions/EventLog.cls
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "");

Expand Down
9 changes: 6 additions & 3 deletions PivotSubscriptions/Installer.cls
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ Class PivotSubscriptions.Installer
XData LocalInstall [ XMLNamespace = INSTALLER ]
{
<Manifest>
<Role
Name="PivotSubscriptionsUnsubscribe"
/>
<Resource
Name="PivotSubscriptionsManager"
/>
<Namespace Name="${NAMESPACE}" Create="no" Ensemble="0">
<Role
Name="PivotSubscriptionsUnsubscribe"
/>
<!--CSPApplication
Url="/api/pivotsubscriptionsunsubscribe"
Directory="${CSPDIR}"
Expand Down
15 changes: 14 additions & 1 deletion PivotSubscriptions/Subscription.cls
Original file line number Diff line number Diff line change
Expand Up @@ -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 ];

Expand Down Expand Up @@ -67,6 +67,19 @@ Method Unsubscribe(pEmail) As %Status
Quit tSC
}

ClassMethod GetScheduleDisplay(pID = "") As %String [ SqlProc ]
{
Set tDisplay=""
Quit:pID="" tDisplay

Set tSubscription=##class(PivotSubscriptions.Subscription).%OpenId(pID)
Quit:'$ISOBJECT(tSubscription) tDisplay

Set tDisplay=##class(PivotSubscriptions.EventLog).DayOfWeekDisplay(tSubscription.DayOfWeek)_"@"_tSubscription.Hour_":"_$REPLACE($JUSTIFY(tSubscription.Minute,2)," ",0)

Quit tDisplay
}

Storage Default
{
<Data name="CustomFilters">
Expand Down
20 changes: 15 additions & 5 deletions PivotSubscriptions/Task.cls
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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)) {
Expand All @@ -135,11 +139,17 @@ 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)
Do msg.TextData.WriteLine(##class(PivotSubscriptions.Utils).GetSettings("NoDataMessage","No data for requested pivot."))
Set tSC=##class(PivotSubscriptions.Utils).WriteAnalyzerLink(msg,tSubscription.Pivot)
If $$$ISERR(tSC) Quit
Do msg.TextData.WriteLine("</br></br>"_##class(PivotSubscriptions.Utils).GetSettings("NoDataMessage","No data for requested pivot."))
Do ##class(PivotSubscriptions.Utils).WriteUnsubscribe(msg,tUnsubscribeList)
Do ##class(PivotSubscriptions.Utils).WriteEmailFooter(msg)

Expand Down
79 changes: 72 additions & 7 deletions PivotSubscriptions/UI/Dialog/EditSubscription.cls
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Parameter DOMAIN = "PivotSubscriptions";

Property pivotName As %ZEN.Datatype.string(ZENURL = "PIVOTNAME");

Property SubscriptionId As %ZEN.Datatype.integer(ZENURL = "SUBSCRIPTIONID");
Property SubscriptionId As %ZEN.Datatype.integer(ZENURL = "SUBSCRIPTIONID") [ InitialExpression = 0 ];

Property SelectedEmail As %String;

Expand All @@ -30,7 +30,15 @@ XData Style
XData dialogBody [ XMLNamespace = "http://www.intersystems.com/zen" ]
{
<pane xmlns="http://www.intersystems.com/zen" title="">
<label id="PivotTable" label="Subscription source: "/>
<dataCombo id="PivotTable" label="Subscription source: " title="Select a pivot table for subscription source" name="PivotTable"
editable="true" unrestricted="true" searchKeyLen="10" dropdownWidth="50.0em" size="40"
queryClass="PivotSubscriptions.UI.Dialog.EditSubscription" queryName="GetPivots"
comboType="timer" disabled="false" hidden="false"
displayColumns="1,2" choiceColumn="2" valueColumn="2"
columnHeaders="Owner,Name"
>
</dataCombo>
<!--label id="PivotTable" label="Subscription source: "/-->
<text id="SubscriptionId" value="0" hidden="true"/>
<label id="Name" label="Subscription name: "/>
<text id="SubscriptionName" size="40"/>
Expand All @@ -41,7 +49,7 @@ XData dialogBody [ XMLNamespace = "http://www.intersystems.com/zen" ]
<select id="Hour" label="Hour" displayList="00,01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23" valueList="0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23" value="12"/>
<select id="Minute" label="Minute" displayList="00,15,30,45" valueList="0,15,30,45" value="0"/>
</hgroup>
<radioSet id="Format" label="Format" displayList="Excel,PDF" valueList="Excel,PDF" value="Excel"/>
<radioSet id="Format" label="Format" displayList="Excel,PDF,CSV" valueList="Excel,PDF,CSV" value="Excel"/>
<textarea id="Emails" label="Email Addresses (Comma separated list)" cols="50" rows="2" onchange="zenPage.populateEmailList();"/>
<spacer height="5px"/>
<hgroup>
Expand Down Expand Up @@ -98,8 +106,11 @@ Method %OnAfterCreatePage() As %Status
}
}

Set tTable=..%GetComponentById("PivotTable")
Set tTable.label="Subscription source: """_$ZCONVERT(..pivotName,"I","HTML")_""""
If ..pivotName'="" {
Set tTable=..%GetComponentById("PivotTable")
Set tTable.value=$ZCONVERT(..pivotName,"I","HTML")
Set tTable.readOnly=1
}

Set tOK=..%GetComponentById("btnOK")
Set tOK.caption="Save"
Expand Down Expand Up @@ -166,11 +177,15 @@ ClientMethod ondialogFinish(action) As %Boolean [ Language = javascript ]
alert($$$Text('Please enter at least 1 email.'));
return false;
}
var pivot=this.pivotName;
var pivotName=zen("PivotTable").getValue()
if (pivotName=="") {
alert($$$Text('Please enter at least 1 email.'));
return false;
}
var emailtext=zen('CustomEmailText').getValue();
var runonce=zen('RunOnce').getValue();

var status=zenPage.EditSubscription(subscriptionid,pivot,dayofweek,hour,minute,emails,format,name,emailtext,runonce);
var status=zenPage.EditSubscription(subscriptionid,pivotName,dayofweek,hour,minute,emails,format,name,emailtext,runonce);

if (status!=1) {
alert("Error during save, see Event Log for more details.");
Expand Down Expand Up @@ -398,4 +413,54 @@ Method GetPivotCube(pPivot) As %String [ ZenMethod ]
Quit tCube
}

Query GetPivots(pSearch As %String = "") As %Query(ROWSPEC = "POwner:%String,PName:%String,PSubscription:%String")
{
}

ClassMethod GetPivotsExecute(ByRef qHandle As %Binary, pSearch 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 (pSearch'="") && (($$$UPPER($LG(tTemp,10))'[$$$UPPER(pSearch))&&($$$UPPER($LG(tTemp,1))'[$$$UPPER(pSearch))) {
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
}

}
8 changes: 7 additions & 1 deletion PivotSubscriptions/UI/EventLogViewer.cls
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ XData contentPane [ XMLNamespace = "http://www.intersystems.com/zen" ]
<column colName="UserName" filterType="text" filterOp="UP["/>
<column colName="Name" filterType="text" filterOp="UP["/>
<column colName="Emails" filterType="text" filterOp="UP["/>
<column colName="Status" filterType="text" filterOp="UP["/>
<column colName="Status" filterType="text" filterOp="UP[" OnDrawCell="FormatStatus"/>
</tablePane>
</vgroup>
</hgroup>
Expand All @@ -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
}

}
128 changes: 0 additions & 128 deletions PivotSubscriptions/UI/PivotList.cls

This file was deleted.

Loading

0 comments on commit d108af2

Please sign in to comment.