class MyService
{
public MyResponse createPO (MyRequest _request)
{
Notes json = FormJsonSerializer::serializeClass(_request);
str logId = MyIntegrationGlobal::logInbound("MyService", "createPO", json);
changeCompany(_request.parmDataAreaId());
{
try{
.
. <code>
. response(True);
}
catch(
response(False)
}
MyIntegrationGlobal::logOutbound(logId, "MyService", "createPO", response.parmSuccess(), response.parmMessage());
return response;
}
}
}
class MyAPIIntegrationGlobal
{
public static str logInbound(str _classname, str _methodname, Notes _param)
{
MyIntegrationLog logTable;
System.DateTime localDateTime = DateTimeUtil::applyTimeZoneOffset(DateTimeUtil::getSystemDateTime(), DateTimeUtil::getUserPreferredTimeZone());
ttsbegin;
logTable.clear();
logTable.ID = localDateTime.ToString('yyyyMMdd_HHmmss');
str logId = logTable.ID;
logTable.DateTimeExecuted = localDateTime;
logTable.DateTimeAnswered = localDateTime;
logTable.Direction = InboundOutbound::Inbound;
logTable.ClassName = strFmt("%1 - %2", _classname, _methodname);
logTable.InputParameter = _param;
logTable.insert();
ttscommit;
return logTable.ID;
}
public static void logOutbound(str _id, str _classname, str _methodname, NoYesId _success, Description1000 _responsemessage)
{
MyIntegrationLog logTableInbound, logTableOutbound;
System.DateTime localDateTime = DateTimeUtil::applyTimeZoneOffset(DateTimeUtil::getSystemDateTime(), DateTimeUtil::getUserPreferredTimeZone());
System.DateTime startExecDateTime = localDateTime;
// look for inbound
str classMethodname= strFmt("%1 - %2*", _classname, _methodname);
select firstonly logTableInbound
where logTableInbound.ID == _id
&& logTableInbound.ClassName like classMethodname
&& logTableInbound.Direction == InboundOutbound::Inbound;
// if found, startExecTime will be override
// if not found, startExecTime will have the current time
if (logTableInbound)
{
startExecDateTime = logTableInbound.DateTimeExecuted;
}
ttsbegin;
logTableOutbound.clear();
logTableOutbound.ID = _id;
logTableOutbound.Direction = InboundOutbound::Outbound;
logTableOutbound.DateTimeExecuted = startExecDateTime;
logTableOutbound.DateTimeAnswered = localDateTime;
logTableOutbound.ClassName = strFmt("%1 - %2", _classname, _methodname);
logTableOutbound.Success = _success;
logTableOutbound.HasError = !logTableOutbound.Success;
logTableOutbound.Response = _responsemessage;
logTableOutbound.insert();
ttscommit;
}
}
class MyService
{
public MyResponse createPO (MyRequest _request)
{
Notes json = FormJsonSerializer::serializeClass(_request);
<insert_to_log including json>;
try{
.
. <code>
. response(True);
}
catch(
response(False)
}
<insert_to_log including response>;
return response;
}
public MyResponse CreateGRN(MyRequest _request)
{
Notes json = FormJsonSerializer::serializeClass(_request);
<insert_to_log including json>;
try{
.
. <code>
. response(True);
}
catch(
response(False)
}
<insert_to_log including response>;
return response;
}
}
André Arnaud de Cal... 291,791 Super User 2024 Season 2
Martin Dráb 230,488 Most Valuable Professional
nmaenpaa 101,156