class DEVUtils
{
}
////
public static void CreateAlert(str message,
str subject,
UserId userId = curUserId(),
NoYes showPopup = NoYes::Yes,
NoYes sendEmail = NoYes::No,
Common record = null,
str dataSourcename = '',
MenuFunction menuFunction = null)
{
EventInbox inbox;
DictTable table;
EventContextInformation eci;
EventInboxData inboxData;
Args args = new Args();
List list;
EventInboxId inboxId = EventInbox::nextEventId();
FormRun formRun;
WorkflowRecordCaptionGenerator recordCaptionGenerator;
UserInfo userInfo;
inboxId = EventInbox::nextEventId();
inbox.initValue();
inbox.ShowPopup = showPopup;
inbox.Subject = subject;
inbox.Message = message;
inbox.SendEmail = sendEmail;
inbox.EmailRecipient = SysUserInfo::find().Email;
inbox.UserId = userId;
inbox.InboxId = inboxId;
inbox.AlertCreatedDateTime = DateTimeUtil::getSystemDateTime();
if (record)
{
table = new DictTable(record.TableId);
eci = new EventContextInformation();
if (!menuFunction)
{
menuFunction = new MenuFunction(table.formRef(),MenuItemType::Display);
if (!menuFunction)
throw error(strFmt("@SYS104114",table.formRef()));
}
//Build the data to drill down to from the notification
args.menuItemName(menuFunction.name());
args.menuItemType(MenuItemType::Display);
args.name(menuFunction.object());
eci.parmPackedArgs(args);
eci.parmAlertBuffer(record);
eci.parmAlertFormDsName(dataSourceName);
//eci.parmDontUseFormRunFromMenuItem(true);
inboxData.InboxId = inboxId;
inboxData.DataType = EventInboxDataType::Context;
inboxData.Data = eci.pack();
inboxData.insert();
inbox.AlertTableId = table.id();
inbox.ParentTableId = table.id();
recordCaptionGenerator = WorkflowRecordCaptionGenerator::construct(record);
inbox.AlertedFor = recordCaptionGenerator.caption();
list = SysDictTable::getUniqueIndexFields(table.id());
if (list)
{
inbox.keyFieldList(list.pack());
inbox.keyFieldData(SysDictTable::mapFieldIds2Values(list,record).pack());
}
inbox.CompanyId = record.company();
}
inbox.insert();
}
//////
public static void POCreateAlert(
//str message,
//str subject,
//UserId userId = curUserId(),
//NoYes showPopup = NoYes::Yes,
//NoYes sendEmail = NoYes::No,
PurchTable _PurchTable,
Common record = null,
str dataSourcename = '',
MenuFunction menuFunction = null)
{
EventInbox inbox;
DictTable table;
EventContextInformation eci;
EventInboxData inboxData;
Args args = new Args();
List list;
EventInboxId inboxId = EventInbox::nextEventId();
FormRun formRun;
WorkflowRecordCaptionGenerator recordCaptionGenerator;
UserInfo userInfo;
UserGroupList groupList;
usergroupinfo usergroupinfo;
;
select Name,generalInfo from UserInfo where UserInfo.id == curUserId();
//while select * from groupList where
//groupList.groupId ==PurchParameters::find().MRKPAlertgroupId
//{
inboxId = EventInbox::nextEventId();
inbox.initValue();
inbox.ShowPopup = NoYes::Yes;
inbox.Subject = "This Alert For Purchase order creation:"+ _purchTable.PurchId;
inbox.Message = "New purchase order" + _purchTable.PurchId +" has been created by: " + UserInfo.name;
inbox.SendEmail = NoYes::No;
inbox.EmailRecipient = SysUserInfo::find().Email;
inbox.UserId = DirPersonUser::worker2UserId(_purchTable.Requester);
inbox.InboxId = inboxId;
inbox.AlertCreatedDateTime = DateTimeUtil::getSystemDateTime();
if (record)
{
table = new DictTable(record.TableId);
eci = new EventContextInformation();
if (!menuFunction)
{
menuFunction = new MenuFunction(table.formRef(),MenuItemType::Display);
if (!menuFunction)
throw error(strFmt("@SYS104114",table.formRef()));
}
//Build the data to drill down to from the notification
args.menuItemName(menuFunction.name());
args.menuItemType(MenuItemType::Display);
args.name(menuFunction.object());
eci.parmPackedArgs(args);
eci.parmAlertBuffer(record);
eci.parmAlertFormDsName(dataSourceName);
//eci.parmDontUseFormRunFromMenuItem(true);
inboxData.InboxId = inboxId;
inboxData.DataType = EventInboxDataType::Context;
inboxData.Data = eci.pack();
inboxData.insert();
inbox.AlertTableId = table.id();
inbox.ParentTableId = table.id();
recordCaptionGenerator = WorkflowRecordCaptionGenerator::construct(record);
inbox.AlertedFor = recordCaptionGenerator.caption();
list = SysDictTable::getUniqueIndexFields(table.id());
if (list)
{
inbox.keyFieldList(list.pack());
inbox.keyFieldData(SysDictTable::mapFieldIds2Values(list,record).pack());
}
inbox.CompanyId = record.company();
}
inbox.insert();
// }
}
////
public static void PRCreateAlert(
//str message,
//str subject,
//UserId userId = curUserId(),
//NoYes showPopup = NoYes::Yes,
//NoYes sendEmail = NoYes::No,
PurchReqTable _PurchReqTable,
Common record = null,
str dataSourcename = '',
MenuFunction menuFunction = null)
{
EventInbox inbox;
DictTable table;
EventContextInformation eci;
EventInboxData inboxData;
Args args = new Args();
List list;
EventInboxId inboxId = EventInbox::nextEventId();
FormRun formRun;
WorkflowRecordCaptionGenerator recordCaptionGenerator;
UserInfo userInfo;
UserGroupList groupList;
usergroupinfo usergroupinfo;
;
select Name,generalInfo from UserInfo where UserInfo.id == curUserId();
while select * from groupList where
groupList.groupId ==PurchParameters::find().MRKPAlertgroupId
{
inboxId = EventInbox::nextEventId();
inbox.initValue();
inbox.ShowPopup = NoYes::Yes;
inbox.Subject = "This Alert For Purchase requisition '"+ _purchReqTable.PurchReqId +"' requisition submitted";
inbox.Message = "The Purchase requisition '"+ _purchReqTable.PurchReqId +"'has been submitted by:"+ userInfo.name ;
inbox.SendEmail = NoYes::No;
inbox.EmailRecipient = SysUserInfo::find().Email;
inbox.UserId = groupList.userId;
inbox.InboxId = inboxId;
inbox.AlertCreatedDateTime = DateTimeUtil::getSystemDateTime();
if (record)
{
table = new DictTable(record.TableId);
eci = new EventContextInformation();
if (!menuFunction)
{
menuFunction = new MenuFunction(table.formRef(),MenuItemType::Display);
if (!menuFunction)
throw error(strFmt("@SYS104114",table.formRef()));
}
//Build the data to drill down to from the notification
args.menuItemName(menuFunction.name());
args.menuItemType(MenuItemType::Display);
args.name(menuFunction.object());
eci.parmPackedArgs(args);
eci.parmAlertBuffer(record);
eci.parmAlertFormDsName(dataSourceName);
//eci.parmDontUseFormRunFromMenuItem(true);
inboxData.InboxId = inboxId;
inboxData.DataType = EventInboxDataType::Context;
inboxData.Data = eci.pack();
inboxData.insert();
inbox.AlertTableId = table.id();
inbox.ParentTableId = table.id();
recordCaptionGenerator = WorkflowRecordCaptionGenerator::construct(record);
inbox.AlertedFor = recordCaptionGenerator.caption();
list = SysDictTable::getUniqueIndexFields(table.id());
if (list)
{
inbox.keyFieldList(list.pack());
inbox.keyFieldData(SysDictTable::mapFieldIds2Values(list,record).pack());
}
inbox.CompanyId = record.company();
}
inbox.insert();
}
}
////
public static void StockChangeAlert(
//str message,
//str subject,
//UserId userId = curUserId(),
//NoYes showPopup = NoYes::Yes,
//NoYes sendEmail = NoYes::No,
SalesTable _SalesTable,
Common record = null,
str dataSourcename = '',
MenuFunction menuFunction = null)
{
EventInbox inbox;
DictTable table;
EventContextInformation eci;
EventInboxData inboxData;
Args args = new Args();
List list;
EventInboxId inboxId = EventInbox::nextEventId();
FormRun formRun;
WorkflowRecordCaptionGenerator recordCaptionGenerator;
UserInfo userInfo;
UserGroupList groupList;
usergroupinfo usergroupinfo;
;
select Name,generalInfo from UserInfo where UserInfo.id == curUserId();
//while select * from groupList where
//groupList.groupId ==PurchParameters::find().MRKPAlertgroupId
//{
inboxId = EventInbox::nextEventId();
inbox.initValue();
inbox.ShowPopup = NoYes::Yes;
inbox.Subject = "This Alert For manual stock change in SRP :"+ _salesTable.SalesId;
inbox.Message = "Stock request pool '" + _salesTable.SalesId +"'stock has been modified by: " + UserInfo.name;
inbox.SendEmail = NoYes::No;
inbox.EmailRecipient = SysUserInfo::find().Email;
inbox.UserId = DirPersonUser::worker2UserId(_salesTable.Requester);
inbox.InboxId = inboxId;
inbox.AlertCreatedDateTime = DateTimeUtil::getSystemDateTime();
if (record)
{
table = new DictTable(record.TableId);
eci = new EventContextInformation();
if (!menuFunction)
{
menuFunction = new MenuFunction(table.formRef(),MenuItemType::Display);
if (!menuFunction)
throw error(strFmt("@SYS104114",table.formRef()));
}
//Build the data to drill down to from the notification
args.menuItemName(menuFunction.name());
args.menuItemType(MenuItemType::Display);
args.name(menuFunction.object());
eci.parmPackedArgs(args);
eci.parmAlertBuffer(record);
eci.parmAlertFormDsName(dataSourceName);
//eci.parmDontUseFormRunFromMenuItem(true);
inboxData.InboxId = inboxId;
inboxData.DataType = EventInboxDataType::Context;
inboxData.Data = eci.pack();
inboxData.insert();
inbox.AlertTableId = table.id();
inbox.ParentTableId = table.id();
recordCaptionGenerator = WorkflowRecordCaptionGenerator::construct(record);
inbox.AlertedFor = recordCaptionGenerator.caption();
list = SysDictTable::getUniqueIndexFields(table.id());
if (list)
{
inbox.keyFieldList(list.pack());
inbox.keyFieldData(SysDictTable::mapFieldIds2Values(list,record).pack());
}
inbox.CompanyId = record.company();
}
inbox.insert();
// }
}
///
///----then method call in PURCH auto Create Class in Create Method-----///
//PurchAutoCreate Class//
void create()
{
MRKPAlertCreate alertCreate;
#OCCRetryCount
try
{
setprefix("@SYS28446");
ttsbegin;
this.setVend();
setprefix(#PreFixField(VendTable,AccountNum));
this.setPurchTable();
this.createPurchTable();
this.createLines();
this.endUpdate();
ttscommit;
if (this.showInfo())
info(strfmt("@SYS82024", purchTable.PurchId),'', SysInfoAction_TableField::newBuffer(purchTable));
//<----------------------------------------------------added by murugan.p------------------------------------------------->
DEVUtils::POCreateAlert(purchTable,purchTable,"PurchTable", new MenuFunction(menuitemDisplayStr(PurchTable), MenuItemType::Display));
//<----------------------------------------------------------end---------------------------------------------------------->
}
catch (Exception::Deadlock)
{
retry;
}
catch (Exception::UpdateConflict)
{
if (appl.ttsLevel() == 0)
{
if (xSession::currentRetryCount() >= #RetryNum)
{
throw Exception::UpdateConflictNotRecovered;
}
else
{
retry;
}
}
else
{
throw Exception::UpdateConflict;
}
}
}
{
}
////
public static void CreateAlert(str message,
str subject,
UserId userId = curUserId(),
NoYes showPopup = NoYes::Yes,
NoYes sendEmail = NoYes::No,
Common record = null,
str dataSourcename = '',
MenuFunction menuFunction = null)
{
EventInbox inbox;
DictTable table;
EventContextInformation eci;
EventInboxData inboxData;
Args args = new Args();
List list;
EventInboxId inboxId = EventInbox::nextEventId();
FormRun formRun;
WorkflowRecordCaptionGenerator recordCaptionGenerator;
UserInfo userInfo;
inboxId = EventInbox::nextEventId();
inbox.initValue();
inbox.ShowPopup = showPopup;
inbox.Subject = subject;
inbox.Message = message;
inbox.SendEmail = sendEmail;
inbox.EmailRecipient = SysUserInfo::find().Email;
inbox.UserId = userId;
inbox.InboxId = inboxId;
inbox.AlertCreatedDateTime = DateTimeUtil::getSystemDateTime();
if (record)
{
table = new DictTable(record.TableId);
eci = new EventContextInformation();
if (!menuFunction)
{
menuFunction = new MenuFunction(table.formRef(),MenuItemType::Display);
if (!menuFunction)
throw error(strFmt("@SYS104114",table.formRef()));
}
//Build the data to drill down to from the notification
args.menuItemName(menuFunction.name());
args.menuItemType(MenuItemType::Display);
args.name(menuFunction.object());
eci.parmPackedArgs(args);
eci.parmAlertBuffer(record);
eci.parmAlertFormDsName(dataSourceName);
//eci.parmDontUseFormRunFromMenuItem(true);
inboxData.InboxId = inboxId;
inboxData.DataType = EventInboxDataType::Context;
inboxData.Data = eci.pack();
inboxData.insert();
inbox.AlertTableId = table.id();
inbox.ParentTableId = table.id();
recordCaptionGenerator = WorkflowRecordCaptionGenerator::construct(record);
inbox.AlertedFor = recordCaptionGenerator.caption();
list = SysDictTable::getUniqueIndexFields(table.id());
if (list)
{
inbox.keyFieldList(list.pack());
inbox.keyFieldData(SysDictTable::mapFieldIds2Values(list,record).pack());
}
inbox.CompanyId = record.company();
}
inbox.insert();
}
//////
public static void POCreateAlert(
//str message,
//str subject,
//UserId userId = curUserId(),
//NoYes showPopup = NoYes::Yes,
//NoYes sendEmail = NoYes::No,
PurchTable _PurchTable,
Common record = null,
str dataSourcename = '',
MenuFunction menuFunction = null)
{
EventInbox inbox;
DictTable table;
EventContextInformation eci;
EventInboxData inboxData;
Args args = new Args();
List list;
EventInboxId inboxId = EventInbox::nextEventId();
FormRun formRun;
WorkflowRecordCaptionGenerator recordCaptionGenerator;
UserInfo userInfo;
UserGroupList groupList;
usergroupinfo usergroupinfo;
;
select Name,generalInfo from UserInfo where UserInfo.id == curUserId();
//while select * from groupList where
//groupList.groupId ==PurchParameters::find().MRKPAlertgroupId
//{
inboxId = EventInbox::nextEventId();
inbox.initValue();
inbox.ShowPopup = NoYes::Yes;
inbox.Subject = "This Alert For Purchase order creation:"+ _purchTable.PurchId;
inbox.Message = "New purchase order" + _purchTable.PurchId +" has been created by: " + UserInfo.name;
inbox.SendEmail = NoYes::No;
inbox.EmailRecipient = SysUserInfo::find().Email;
inbox.UserId = DirPersonUser::worker2UserId(_purchTable.Requester);
inbox.InboxId = inboxId;
inbox.AlertCreatedDateTime = DateTimeUtil::getSystemDateTime();
if (record)
{
table = new DictTable(record.TableId);
eci = new EventContextInformation();
if (!menuFunction)
{
menuFunction = new MenuFunction(table.formRef(),MenuItemType::Display);
if (!menuFunction)
throw error(strFmt("@SYS104114",table.formRef()));
}
//Build the data to drill down to from the notification
args.menuItemName(menuFunction.name());
args.menuItemType(MenuItemType::Display);
args.name(menuFunction.object());
eci.parmPackedArgs(args);
eci.parmAlertBuffer(record);
eci.parmAlertFormDsName(dataSourceName);
//eci.parmDontUseFormRunFromMenuItem(true);
inboxData.InboxId = inboxId;
inboxData.DataType = EventInboxDataType::Context;
inboxData.Data = eci.pack();
inboxData.insert();
inbox.AlertTableId = table.id();
inbox.ParentTableId = table.id();
recordCaptionGenerator = WorkflowRecordCaptionGenerator::construct(record);
inbox.AlertedFor = recordCaptionGenerator.caption();
list = SysDictTable::getUniqueIndexFields(table.id());
if (list)
{
inbox.keyFieldList(list.pack());
inbox.keyFieldData(SysDictTable::mapFieldIds2Values(list,record).pack());
}
inbox.CompanyId = record.company();
}
inbox.insert();
// }
}
////
public static void PRCreateAlert(
//str message,
//str subject,
//UserId userId = curUserId(),
//NoYes showPopup = NoYes::Yes,
//NoYes sendEmail = NoYes::No,
PurchReqTable _PurchReqTable,
Common record = null,
str dataSourcename = '',
MenuFunction menuFunction = null)
{
EventInbox inbox;
DictTable table;
EventContextInformation eci;
EventInboxData inboxData;
Args args = new Args();
List list;
EventInboxId inboxId = EventInbox::nextEventId();
FormRun formRun;
WorkflowRecordCaptionGenerator recordCaptionGenerator;
UserInfo userInfo;
UserGroupList groupList;
usergroupinfo usergroupinfo;
;
select Name,generalInfo from UserInfo where UserInfo.id == curUserId();
while select * from groupList where
groupList.groupId ==PurchParameters::find().MRKPAlertgroupId
{
inboxId = EventInbox::nextEventId();
inbox.initValue();
inbox.ShowPopup = NoYes::Yes;
inbox.Subject = "This Alert For Purchase requisition '"+ _purchReqTable.PurchReqId +"' requisition submitted";
inbox.Message = "The Purchase requisition '"+ _purchReqTable.PurchReqId +"'has been submitted by:"+ userInfo.name ;
inbox.SendEmail = NoYes::No;
inbox.EmailRecipient = SysUserInfo::find().Email;
inbox.UserId = groupList.userId;
inbox.InboxId = inboxId;
inbox.AlertCreatedDateTime = DateTimeUtil::getSystemDateTime();
if (record)
{
table = new DictTable(record.TableId);
eci = new EventContextInformation();
if (!menuFunction)
{
menuFunction = new MenuFunction(table.formRef(),MenuItemType::Display);
if (!menuFunction)
throw error(strFmt("@SYS104114",table.formRef()));
}
//Build the data to drill down to from the notification
args.menuItemName(menuFunction.name());
args.menuItemType(MenuItemType::Display);
args.name(menuFunction.object());
eci.parmPackedArgs(args);
eci.parmAlertBuffer(record);
eci.parmAlertFormDsName(dataSourceName);
//eci.parmDontUseFormRunFromMenuItem(true);
inboxData.InboxId = inboxId;
inboxData.DataType = EventInboxDataType::Context;
inboxData.Data = eci.pack();
inboxData.insert();
inbox.AlertTableId = table.id();
inbox.ParentTableId = table.id();
recordCaptionGenerator = WorkflowRecordCaptionGenerator::construct(record);
inbox.AlertedFor = recordCaptionGenerator.caption();
list = SysDictTable::getUniqueIndexFields(table.id());
if (list)
{
inbox.keyFieldList(list.pack());
inbox.keyFieldData(SysDictTable::mapFieldIds2Values(list,record).pack());
}
inbox.CompanyId = record.company();
}
inbox.insert();
}
}
////
public static void StockChangeAlert(
//str message,
//str subject,
//UserId userId = curUserId(),
//NoYes showPopup = NoYes::Yes,
//NoYes sendEmail = NoYes::No,
SalesTable _SalesTable,
Common record = null,
str dataSourcename = '',
MenuFunction menuFunction = null)
{
EventInbox inbox;
DictTable table;
EventContextInformation eci;
EventInboxData inboxData;
Args args = new Args();
List list;
EventInboxId inboxId = EventInbox::nextEventId();
FormRun formRun;
WorkflowRecordCaptionGenerator recordCaptionGenerator;
UserInfo userInfo;
UserGroupList groupList;
usergroupinfo usergroupinfo;
;
select Name,generalInfo from UserInfo where UserInfo.id == curUserId();
//while select * from groupList where
//groupList.groupId ==PurchParameters::find().MRKPAlertgroupId
//{
inboxId = EventInbox::nextEventId();
inbox.initValue();
inbox.ShowPopup = NoYes::Yes;
inbox.Subject = "This Alert For manual stock change in SRP :"+ _salesTable.SalesId;
inbox.Message = "Stock request pool '" + _salesTable.SalesId +"'stock has been modified by: " + UserInfo.name;
inbox.SendEmail = NoYes::No;
inbox.EmailRecipient = SysUserInfo::find().Email;
inbox.UserId = DirPersonUser::worker2UserId(_salesTable.Requester);
inbox.InboxId = inboxId;
inbox.AlertCreatedDateTime = DateTimeUtil::getSystemDateTime();
if (record)
{
table = new DictTable(record.TableId);
eci = new EventContextInformation();
if (!menuFunction)
{
menuFunction = new MenuFunction(table.formRef(),MenuItemType::Display);
if (!menuFunction)
throw error(strFmt("@SYS104114",table.formRef()));
}
//Build the data to drill down to from the notification
args.menuItemName(menuFunction.name());
args.menuItemType(MenuItemType::Display);
args.name(menuFunction.object());
eci.parmPackedArgs(args);
eci.parmAlertBuffer(record);
eci.parmAlertFormDsName(dataSourceName);
//eci.parmDontUseFormRunFromMenuItem(true);
inboxData.InboxId = inboxId;
inboxData.DataType = EventInboxDataType::Context;
inboxData.Data = eci.pack();
inboxData.insert();
inbox.AlertTableId = table.id();
inbox.ParentTableId = table.id();
recordCaptionGenerator = WorkflowRecordCaptionGenerator::construct(record);
inbox.AlertedFor = recordCaptionGenerator.caption();
list = SysDictTable::getUniqueIndexFields(table.id());
if (list)
{
inbox.keyFieldList(list.pack());
inbox.keyFieldData(SysDictTable::mapFieldIds2Values(list,record).pack());
}
inbox.CompanyId = record.company();
}
inbox.insert();
// }
}
///
///----then method call in PURCH auto Create Class in Create Method-----///
//PurchAutoCreate Class//
void create()
{
MRKPAlertCreate alertCreate;
#OCCRetryCount
try
{
setprefix("@SYS28446");
ttsbegin;
this.setVend();
setprefix(#PreFixField(VendTable,AccountNum));
this.setPurchTable();
this.createPurchTable();
this.createLines();
this.endUpdate();
ttscommit;
if (this.showInfo())
info(strfmt("@SYS82024", purchTable.PurchId),'', SysInfoAction_TableField::newBuffer(purchTable));
//<----------------------------------------------------added by murugan.p------------------------------------------------->
DEVUtils::POCreateAlert(purchTable,purchTable,"PurchTable", new MenuFunction(menuitemDisplayStr(PurchTable), MenuItemType::Display));
//<----------------------------------------------------------end---------------------------------------------------------->
}
catch (Exception::Deadlock)
{
retry;
}
catch (Exception::UpdateConflict)
{
if (appl.ttsLevel() == 0)
{
if (xSession::currentRetryCount() >= #RetryNum)
{
throw Exception::UpdateConflictNotRecovered;
}
else
{
retry;
}
}
else
{
throw Exception::UpdateConflict;
}
}
}
No comments:
Post a Comment