Skip to content

Commit

Permalink
Merge pull request #58 from psteiwer/dev
Browse files Browse the repository at this point in the history
v1.2.2
  • Loading branch information
psteiwer authored Feb 26, 2020
2 parents ef9facb + d8e4791 commit 5291a4e
Show file tree
Hide file tree
Showing 10 changed files with 1,180 additions and 913 deletions.
247 changes: 146 additions & 101 deletions PivotSubscriptions/EventLog.cls
Original file line number Diff line number Diff line change
@@ -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
{
<Data name="EventLogDefaultData">
<Value name="1">
<Value>%%CLASSNAME</Value>
</Value>
<Value name="2">
<Value>EventType</Value>
</Value>
<Value name="3">
<Value>TimeStamp</Value>
</Value>
<Value name="4">
<Value>UserName</Value>
</Value>
<Value name="5">
<Value>Pivot</Value>
</Value>
<Value name="6">
<Value>SubscriptionId</Value>
</Value>
<Value name="7">
<Value>DayOfWeek</Value>
</Value>
<Value name="8">
<Value>Hour</Value>
</Value>
<Value name="9">
<Value>Minute</Value>
</Value>
<Value name="10">
<Value>Format</Value>
</Value>
<Value name="11">
<Value>Emails</Value>
</Value>
<Value name="12">
<Value>Name</Value>
</Value>
</Data>
<DataLocation>^PivotSubscriptions.EventLogD</DataLocation>
<DefaultData>EventLogDefaultData</DefaultData>
<IdLocation>^PivotSubscriptions.EventLogD</IdLocation>
<IndexLocation>^PivotSubscriptions.EventLogI</IndexLocation>
<StreamLocation>^PivotSubscriptions.EventLogS</StreamLocation>
<Type>%Storage.Persistent</Type>
}

}
/// 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
{
<Data name="EventLogDefaultData">
<Value name="1">
<Value>%%CLASSNAME</Value>
</Value>
<Value name="2">
<Value>EventType</Value>
</Value>
<Value name="3">
<Value>StartTime</Value>
</Value>
<Value name="4">
<Value>UserName</Value>
</Value>
<Value name="5">
<Value>Pivot</Value>
</Value>
<Value name="6">
<Value>SubscriptionId</Value>
</Value>
<Value name="7">
<Value>DayOfWeek</Value>
</Value>
<Value name="8">
<Value>Hour</Value>
</Value>
<Value name="9">
<Value>Minute</Value>
</Value>
<Value name="10">
<Value>Format</Value>
</Value>
<Value name="11">
<Value>Emails</Value>
</Value>
<Value name="12">
<Value>Name</Value>
</Value>
<Value name="13">
<Value>EndTime</Value>
</Value>
<Value name="14">
<Value>Status</Value>
</Value>
</Data>
<DataLocation>^PivotSubscriptions.EventLogD</DataLocation>
<DefaultData>EventLogDefaultData</DefaultData>
<IdLocation>^PivotSubscriptions.EventLogD</IdLocation>
<IndexLocation>^PivotSubscriptions.EventLogI</IndexLocation>
<StreamLocation>^PivotSubscriptions.EventLogS</StreamLocation>
<Type>%Storage.Persistent</Type>
}

}
139 changes: 73 additions & 66 deletions PivotSubscriptions/Subscription.cls
Original file line number Diff line number Diff line change
@@ -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
{
<Data name="SubscriptionDefaultData">
<Value name="1">
<Value>%%CLASSNAME</Value>
</Value>
<Value name="2">
<Value>CreatedBy</Value>
</Value>
<Value name="3">
<Value>Pivot</Value>
</Value>
<Value name="4">
<Value>DayOfWeek</Value>
</Value>
<Value name="5">
<Value>Hour</Value>
</Value>
<Value name="6">
<Value>Minute</Value>
</Value>
<Value name="7">
<Value>Format</Value>
</Value>
<Value name="8">
<Value>Emails</Value>
</Value>
<Value name="9">
<Value>Version</Value>
</Value>
<Value name="10">
<Value>Name</Value>
</Value>
</Data>
<DataLocation>^PivotSubscriptions.SubD</DataLocation>
<DefaultData>SubscriptionDefaultData</DefaultData>
<IdLocation>^PivotSubscriptions.SubD</IdLocation>
<IndexLocation>^PivotSubscriptions.SubI</IndexLocation>
<StreamLocation>^PivotSubscriptions.SubS</StreamLocation>
<Type>%Storage.Persistent</Type>
}

}
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
{
<Data name="CustomFilters">
<Attribute>CustomFilters</Attribute>
<Structure>subnode</Structure>
<Subscript>"CustomFilters"</Subscript>
</Data>
<Data name="SubscriptionDefaultData">
<Value name="1">
<Value>%%CLASSNAME</Value>
</Value>
<Value name="2">
<Value>CreatedBy</Value>
</Value>
<Value name="3">
<Value>Pivot</Value>
</Value>
<Value name="4">
<Value>DayOfWeek</Value>
</Value>
<Value name="5">
<Value>Hour</Value>
</Value>
<Value name="6">
<Value>Minute</Value>
</Value>
<Value name="7">
<Value>Format</Value>
</Value>
<Value name="8">
<Value>Emails</Value>
</Value>
<Value name="9">
<Value>Version</Value>
</Value>
<Value name="10">
<Value>Name</Value>
</Value>
</Data>
<DataLocation>^PivotSubscriptions.SubD</DataLocation>
<DefaultData>SubscriptionDefaultData</DefaultData>
<IdLocation>^PivotSubscriptions.SubD</IdLocation>
<IndexLocation>^PivotSubscriptions.SubI</IndexLocation>
<StreamLocation>^PivotSubscriptions.SubS</StreamLocation>
<Type>%Storage.Persistent</Type>
}

}
Loading

0 comments on commit 5291a4e

Please sign in to comment.