Correct export of Delivery Unit EON_EMOBILITY_PROVIDER (37 files, replaces incomplete initial export)
This commit is contained in:
@@ -1,8 +1,29 @@
|
||||
{
|
||||
"exposed": true,
|
||||
"authentication": [
|
||||
{
|
||||
"authentication": [{
|
||||
"method": "Basic"
|
||||
}
|
||||
]
|
||||
}],
|
||||
|
||||
"mime_mapping": [{
|
||||
"extension": "jpg",
|
||||
"mimetype": "image/jpeg"
|
||||
}],
|
||||
"force_ssl": false,
|
||||
"enable_etags": true,
|
||||
"prevent_xsrf": false,
|
||||
"cache_control": "no-cache, no-store",
|
||||
"default_file": "index.html",
|
||||
"cors" :
|
||||
{
|
||||
"enabled" : true,
|
||||
"allowMethods": [
|
||||
"GET",
|
||||
"POST",
|
||||
"HEAD",
|
||||
"PUT",
|
||||
"OPTIONS"],
|
||||
"allowOrigin" : ["*"],
|
||||
"allowHeaders" : ["crossdomain","X-Requested-With","Access-Control-Request-Method","Referer","Access-Control-Request-Headers","Accept-Encoding","Sec-Fetch-Mode","Sec-Fetch-Site","authorization","Accept","Origin","Content-Type","Content-Length","content-encoding","Depth","User-Agent","Cache-Control","x-csrf-token","x-sap-cid","Accept-Language","sap-cancel-on-close","sap-contextid-accept","DataServiceVersion","MaxDataServiceVersion","sec-ch-ua","sec-ch-ua-mobile","Prefer"],
|
||||
"exposeHeaders" : ["x-csrf-token","access-control-allow-headers","Access-Control-Allow-Origin","access-control-expose-headers","authorization"]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,264 @@
|
||||
var datetimeLib = $.import("uniorg.libs", "datetime");
|
||||
//var logginglib = $.import("uniorg.libs", "uologging");
|
||||
//var billingEngine = $.import("uniorg.eon.emobility.billing.engine.v1", "BillingEngine");
|
||||
var destLib = $.import("uniorg.destinations", "uodestlib");
|
||||
var slLib = $.import("uniorg.ServiceLayer", "B1SLLogic");
|
||||
|
||||
var serviceName = "eon.emobility.provider.backend.addNewProvider.xsjs";
|
||||
var serviceVersion = '1.0';
|
||||
|
||||
var output = {};
|
||||
var outMessages = [];
|
||||
var outMsg = {};
|
||||
var outStatus = "success";
|
||||
var myDebug = {};
|
||||
|
||||
var companyid = 0;
|
||||
var UserName = '';
|
||||
var UserPass = '';
|
||||
var UserComp = '';
|
||||
|
||||
var SESSIONID = "";
|
||||
var NODEID = "";
|
||||
var slLoggedIn = false;
|
||||
var schemaName = "A19753_EON_P01";
|
||||
|
||||
var debugLevel = 0;
|
||||
switch ($.request.parameters.get("debug")) {
|
||||
case "true":
|
||||
case "yes":
|
||||
case "1":
|
||||
debugLevel = 1;
|
||||
break;
|
||||
case "full":
|
||||
case "2":
|
||||
debugLevel = 2;
|
||||
break;
|
||||
}
|
||||
|
||||
if (debugLevel > 0) {
|
||||
output.requestParams = $.request.parameters;
|
||||
}
|
||||
|
||||
function setOutputMessage() {
|
||||
output.status = outStatus;
|
||||
if (debugLevel > 0) {
|
||||
output.debugInfos = myDebug;
|
||||
}
|
||||
output.messages = outMessages;
|
||||
$.response.contentType = "application/json";
|
||||
$.response.setBody(JSON.stringify(output));
|
||||
//$.response.status = $.net.http.OK;
|
||||
}
|
||||
|
||||
function exceptionHandler(ex) {
|
||||
if (outMsg.method && outMessages.indexOf(outMsg) === -1) {
|
||||
outMsg.status = "canceled";
|
||||
outMessages.push(outMsg);
|
||||
}
|
||||
outMsg = {};
|
||||
outMsg.method = "exceptionHandler";
|
||||
outMsg.status = "error";
|
||||
outMsg.message = ex.toString();
|
||||
if (debugLevel > 0) {
|
||||
outMsg.exceptionInfo = {};
|
||||
outMsg.exceptionInfo.name = ex.name;
|
||||
outMsg.exceptionInfo.message = ex.message;
|
||||
outMsg.exceptionInfo.fileName = ex.fileName;
|
||||
outMsg.exceptionInfo.lineNumber = ex.lineNumber;
|
||||
outMsg.exceptionInfo.columnNumber = ex.columnNumber;
|
||||
outMsg.exceptionInfo.stack = ex.stack;
|
||||
//outMsg.exceptionInfo.source = ex.toSource();
|
||||
}
|
||||
outMessages.push(outMsg);
|
||||
outStatus = "error";
|
||||
output.status = outStatus;
|
||||
if (debugLevel > 0) {
|
||||
output.debugInfos = myDebug;
|
||||
}
|
||||
output.messages = outMessages;
|
||||
|
||||
var errbody = JSON.stringify(output);
|
||||
$.response.contentType = 'application/json';
|
||||
$.response.setBody(errbody);
|
||||
$.response.status = $.net.http.INTERNAL_SERVER_ERROR;
|
||||
try {
|
||||
if (slLoggedIn) {
|
||||
slLib.SLLogout(SESSIONID, NODEID);
|
||||
}
|
||||
} catch (e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function checkAuthorization() {
|
||||
var isAuthorized = true;
|
||||
try {
|
||||
$.session.assertAppPrivilege("uniorg.eon.emobility.provider::MaintainProviderData");
|
||||
} catch (ex) {
|
||||
isAuthorized = false;
|
||||
outMsg = {};
|
||||
outMsg.method = "checkAuthorization";
|
||||
outMsg.status = "error";
|
||||
outStatus = "error";
|
||||
outMsg.message = "Privilege '" + ex.privilege + "' is missing";
|
||||
outMessages.push(outMsg);
|
||||
$.response.status = $.net.http.FORBIDDEN;
|
||||
}
|
||||
return isAuthorized;
|
||||
}
|
||||
|
||||
function checkPayload(inObj) {
|
||||
var isValid = true;
|
||||
try {
|
||||
var provider = JSON.parse(inObj);
|
||||
if (!provider.hasOwnProperty('Code') || !provider.hasOwnProperty('Name') || !provider.hasOwnProperty('U_ACTIVE') ||
|
||||
!provider.hasOwnProperty('U_ACTIVE_FROM') || !provider.hasOwnProperty('U_ACTIVE_TO')) {
|
||||
isValid = false;
|
||||
}
|
||||
} catch (e) {
|
||||
exceptionHandler(e);
|
||||
isValid = false;
|
||||
}
|
||||
if (!isValid) {
|
||||
outMsg = {};
|
||||
outMsg.method = "checkPayload";
|
||||
outMsg.status = "error";
|
||||
outStatus = "error";
|
||||
outMsg.message = "invalid payload content";
|
||||
outMessages.push(outMsg);
|
||||
$.response.status = $.net.http.BAD_REQUEST;
|
||||
}
|
||||
return isValid;
|
||||
}
|
||||
|
||||
function setConnectionParams() {
|
||||
var idValue = schemaName;
|
||||
var idFieldname = 'SYS_NAME';
|
||||
var CompanyConfig = destLib.getCompanyCfg(idValue, idFieldname);
|
||||
UserComp = CompanyConfig.COMPANYNAME;
|
||||
UserName = CompanyConfig.USERNAME;
|
||||
UserPass = destLib.readSecureStore(CompanyConfig.ID);
|
||||
if (debugLevel > 1) {
|
||||
myDebug.connectionParams = CompanyConfig;
|
||||
}
|
||||
myDebug.idValue = idValue;
|
||||
myDebug.idFieldname = idFieldname;
|
||||
if (CompanyConfig.COMPANYNAME === undefined) {
|
||||
outMsg = {};
|
||||
outMsg.method = "getCompany";
|
||||
outStatus = "error";
|
||||
outMsg.status = "error";
|
||||
outMsg.message = "System " + idValue + " is invalid for this endpoint";
|
||||
outMessages.push(outMsg);
|
||||
}
|
||||
|
||||
myDebug.CompanyName = UserComp;
|
||||
}
|
||||
|
||||
function slLogin() {
|
||||
var loginResult = false;
|
||||
var loginInfo = {};
|
||||
loginInfo.UserName = UserName;
|
||||
loginInfo.Password = UserPass;
|
||||
loginInfo.CompanyDB = UserComp;
|
||||
|
||||
// SL LOGIN
|
||||
var response = slLib.SLLogin(JSON.stringify(loginInfo), null, null);
|
||||
|
||||
// B1SESSION and ROUTEID cookies returned by Login
|
||||
for (var j in response.cookies) {
|
||||
if (response.cookies[j].name == "B1SESSION") {
|
||||
SESSIONID = response.cookies[j].value;
|
||||
//output.SessionID = SESSIONID;
|
||||
} else if (response.cookies[j].name == "ROUTEID") {
|
||||
NODEID = response.cookies[j].value;
|
||||
//output.NodeID = NODEID;
|
||||
}
|
||||
}
|
||||
|
||||
var loginResponse;
|
||||
try {
|
||||
loginResponse = JSON.parse(response.body.asString());
|
||||
} catch (e) {
|
||||
loginResponse = response.body.asString();
|
||||
}
|
||||
|
||||
if (debugLevel > 1) {
|
||||
myDebug.loginInfo = loginInfo;
|
||||
}
|
||||
myDebug.loginResponse = loginResponse;
|
||||
if (response.status === 200) {
|
||||
loginResult = true;
|
||||
} else {
|
||||
outMsg = {};
|
||||
outMsg.method = "login";
|
||||
outMsg.status = "error";
|
||||
var slError = myDebug.loginResponse.error;
|
||||
if (slError && slError.hasOwnProperty("code") && slError.message && slError.message.value) {
|
||||
outMsg.message = slError.message.value + " (Code: " + slError.code.toString() + ")";
|
||||
} else {
|
||||
outMsg.message = JSON.stringify(myDebug.loginResponse);
|
||||
}
|
||||
outMsg.response = myDebug.loginResponse;
|
||||
//outMsg.message = loginResponse;
|
||||
outMessages.push(outMsg);
|
||||
outStatus = "error";
|
||||
}
|
||||
return loginResult;
|
||||
}
|
||||
|
||||
function createUDO(provider) {
|
||||
outMsg = {};
|
||||
outMsg.method = "createUDO";
|
||||
outMsg.status = "error";
|
||||
try {
|
||||
var slProviderObj = {
|
||||
Code: provider.Code,
|
||||
Name: provider.Name,
|
||||
U_ACTIVE: provider.U_ACTIVE,
|
||||
U_ACTIVE_FROM: datetimeLib.convertToISODate(provider.U_ACTIVE_FROM),
|
||||
U_ACTIVE_TO: datetimeLib.convertToISODate(provider.U_ACTIVE_TO)
|
||||
};
|
||||
myDebug.slProviderObj = slProviderObj;
|
||||
var responseProvider = slLib.postDynamicEntity('EON_PROVIDER', JSON.stringify(slProviderObj), SESSIONID, NODEID);
|
||||
if (responseProvider.status >= 200 && responseProvider.status < 300) {
|
||||
outMsg.status = "success";
|
||||
} else {
|
||||
if (responseProvider.body) {
|
||||
var responseBodyParsed = JSON.parse(responseProvider.body.asString());
|
||||
var slError = responseBodyParsed.error;
|
||||
if (slError && slError.hasOwnProperty("code") && slError.message && slError.message.value) {
|
||||
outMsg.message = slError.message.value + " (Code: " + slError.code.toString() + ")";
|
||||
} else {
|
||||
outMsg.message = responseProvider.body.asString();
|
||||
}
|
||||
outMsg.response = responseBodyParsed;
|
||||
} else {
|
||||
outMsg.message = JSON.stringify(responseProvider);
|
||||
}
|
||||
outStatus = "error";
|
||||
}
|
||||
outMessages.push(outMsg);
|
||||
} catch (ex) {
|
||||
exceptionHandler(ex);
|
||||
}
|
||||
}
|
||||
|
||||
// main
|
||||
var content = "";
|
||||
if ($.request.body) {
|
||||
content = $.request.body.asString();
|
||||
}
|
||||
if (checkPayload(content) && checkAuthorization()) {
|
||||
setConnectionParams();
|
||||
slLoggedIn = slLogin();
|
||||
if (slLoggedIn) {
|
||||
var inObj = JSON.parse(content);
|
||||
createUDO(inObj);
|
||||
slLib.SLLogout(SESSIONID, NODEID);
|
||||
}
|
||||
}
|
||||
|
||||
$.trace.debug("DEBUG: " + JSON.stringify(myDebug));
|
||||
setOutputMessage();
|
||||
@@ -0,0 +1,308 @@
|
||||
var datetimeLib = $.import("uniorg.libs", "datetime");
|
||||
//var logginglib = $.import("uniorg.libs", "uologging");
|
||||
//var billingEngine = $.import("uniorg.eon.emobility.billing.engine.v1", "BillingEngine");
|
||||
var destLib = $.import("uniorg.destinations", "uodestlib");
|
||||
var slLib = $.import("uniorg.ServiceLayer", "B1SLLogic");
|
||||
|
||||
var serviceName = "eon.emobility.provider.backend.addNextPeriodData.xsjs";
|
||||
var serviceVersion = '1.3';
|
||||
|
||||
var output = {};
|
||||
var outMessages = [];
|
||||
var outMsg = {};
|
||||
var outStatus = "success";
|
||||
var myDebug = {};
|
||||
|
||||
var companyid = 0;
|
||||
var UserName = '';
|
||||
var UserPass = '';
|
||||
var UserComp = '';
|
||||
|
||||
var SESSIONID = "";
|
||||
var NODEID = "";
|
||||
var slLoggedIn = false;
|
||||
var schemaName = "A19753_EON_P01";
|
||||
|
||||
var debugLevel = 0;
|
||||
switch ($.request.parameters.get("debug")) {
|
||||
case "true":
|
||||
case "yes":
|
||||
case "1":
|
||||
debugLevel = 1;
|
||||
break;
|
||||
case "full":
|
||||
case "2":
|
||||
debugLevel = 2;
|
||||
break;
|
||||
}
|
||||
|
||||
if (debugLevel > 0) {
|
||||
output.requestParams = $.request.parameters;
|
||||
}
|
||||
|
||||
function setOutputMessage() {
|
||||
output.status = outStatus;
|
||||
if (debugLevel > 0) {
|
||||
output.debugInfos = myDebug;
|
||||
}
|
||||
output.messages = outMessages;
|
||||
$.response.contentType = "application/json";
|
||||
$.response.setBody(JSON.stringify(output));
|
||||
//$.response.status = $.net.http.OK;
|
||||
}
|
||||
|
||||
function exceptionHandler(ex) {
|
||||
if (outMsg.method && outMessages.indexOf(outMsg) === -1) {
|
||||
outMsg.status = "canceled";
|
||||
outMessages.push(outMsg);
|
||||
}
|
||||
outMsg = {};
|
||||
outMsg.method = "exceptionHandler";
|
||||
outMsg.status = "error";
|
||||
outMsg.message = ex.toString();
|
||||
if (debugLevel > 0) {
|
||||
outMsg.exceptionInfo = {};
|
||||
outMsg.exceptionInfo.name = ex.name;
|
||||
outMsg.exceptionInfo.message = ex.message;
|
||||
outMsg.exceptionInfo.fileName = ex.fileName;
|
||||
outMsg.exceptionInfo.lineNumber = ex.lineNumber;
|
||||
outMsg.exceptionInfo.columnNumber = ex.columnNumber;
|
||||
outMsg.exceptionInfo.stack = ex.stack;
|
||||
//outMsg.exceptionInfo.source = ex.toSource();
|
||||
}
|
||||
outMessages.push(outMsg);
|
||||
outStatus = "error";
|
||||
output.status = outStatus;
|
||||
if (debugLevel > 0) {
|
||||
output.debugInfos = myDebug;
|
||||
}
|
||||
output.messages = outMessages;
|
||||
|
||||
var errbody = JSON.stringify(output);
|
||||
$.response.contentType = 'application/json';
|
||||
$.response.setBody(errbody);
|
||||
$.response.status = $.net.http.INTERNAL_SERVER_ERROR;
|
||||
try {
|
||||
if (slLoggedIn) {
|
||||
slLib.SLLogout(SESSIONID, NODEID);
|
||||
}
|
||||
} catch (e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function checkAuthorization() {
|
||||
var isAuthorized = true;
|
||||
try {
|
||||
$.session.assertAppPrivilege("uniorg.eon.emobility.provider::MaintainProviderData");
|
||||
} catch (ex) {
|
||||
isAuthorized = false;
|
||||
outMsg = {};
|
||||
outMsg.method = "checkAuthorization";
|
||||
outMsg.status = "error";
|
||||
outStatus = "error";
|
||||
outMsg.message = "Privilege '" + ex.privilege + "' is missing";
|
||||
outMessages.push(outMsg);
|
||||
$.response.status = $.net.http.FORBIDDEN;
|
||||
}
|
||||
return isAuthorized;
|
||||
}
|
||||
|
||||
function checkPayload(inObj) {
|
||||
var isValid = true;
|
||||
var errorList = [];
|
||||
try {
|
||||
var provider = JSON.parse(inObj);
|
||||
if (!provider.hasOwnProperty('Code')) {
|
||||
isValid = false;
|
||||
}
|
||||
if (Array.isArray(provider.NextPeriod)) {
|
||||
provider.NextPeriod.forEach(function(npl) {
|
||||
if (!npl.hasOwnProperty('U_CODE') || !npl.hasOwnProperty('U_FROM') || !npl.hasOwnProperty('U_TO') || !npl.hasOwnProperty('U_TYP') || !npl.hasOwnProperty('U_OPERATOR') || !npl.hasOwnProperty('U_SUBOPERATOR')) {
|
||||
isValid = false;
|
||||
} else {
|
||||
var errorDetails = {
|
||||
U_CODE: npl.U_CODE,
|
||||
U_FROM: npl.U_FROM,
|
||||
U_TO: npl.U_TO,
|
||||
U_TYP: npl.U_TYP,
|
||||
U_OPERATOR: npl.U_OPERATOR,
|
||||
U_SUBOPERATOR: npl.U_SUBOPERATOR,
|
||||
Status: 'error'
|
||||
};
|
||||
if (errorDetails.StatusText) {
|
||||
errorList.push(errorDetails);
|
||||
isValid = false;
|
||||
} else if (debugLevel > 0) {
|
||||
errorDetails.Status = "success";
|
||||
errorList.push(errorDetails);
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
isValid = false;
|
||||
}
|
||||
} catch (e) {
|
||||
exceptionHandler(e);
|
||||
isValid = false;
|
||||
}
|
||||
if (!isValid) {
|
||||
outMsg = {};
|
||||
outMsg.method = "checkPayload";
|
||||
outMsg.status = "error";
|
||||
outStatus = "error";
|
||||
if (errorList.length > 0) {
|
||||
outMsg.message = "invalid payload content";
|
||||
output.results = errorList;
|
||||
} else {
|
||||
outMsg.message = "invalid payload structure";
|
||||
}
|
||||
outMessages.push(outMsg);
|
||||
$.response.status = $.net.http.BAD_REQUEST;
|
||||
}
|
||||
return isValid;
|
||||
}
|
||||
|
||||
function setConnectionParams() {
|
||||
var idValue = schemaName;
|
||||
var idFieldname = 'SYS_NAME';
|
||||
var CompanyConfig = destLib.getCompanyCfg(idValue, idFieldname);
|
||||
UserComp = CompanyConfig.COMPANYNAME;
|
||||
UserName = CompanyConfig.USERNAME;
|
||||
UserPass = destLib.readSecureStore(CompanyConfig.ID);
|
||||
if (debugLevel > 1) {
|
||||
myDebug.connectionParams = CompanyConfig;
|
||||
}
|
||||
myDebug.idValue = idValue;
|
||||
myDebug.idFieldname = idFieldname;
|
||||
if (CompanyConfig.COMPANYNAME === undefined) {
|
||||
outMsg = {};
|
||||
outMsg.method = "getCompany";
|
||||
outStatus = "error";
|
||||
outMsg.status = "error";
|
||||
outMsg.message = "System " + idValue + " is invalid for this endpoint";
|
||||
outMessages.push(outMsg);
|
||||
}
|
||||
|
||||
myDebug.CompanyName = UserComp;
|
||||
}
|
||||
|
||||
function slLogin() {
|
||||
var loginResult = false;
|
||||
var loginInfo = {};
|
||||
loginInfo.UserName = UserName;
|
||||
loginInfo.Password = UserPass;
|
||||
loginInfo.CompanyDB = UserComp;
|
||||
|
||||
// SL LOGIN
|
||||
var response = slLib.SLLogin(JSON.stringify(loginInfo), null, null);
|
||||
|
||||
// B1SESSION and ROUTEID cookies returned by Login
|
||||
for (var j in response.cookies) {
|
||||
if (response.cookies[j].name == "B1SESSION") {
|
||||
SESSIONID = response.cookies[j].value;
|
||||
//output.SessionID = SESSIONID;
|
||||
} else if (response.cookies[j].name == "ROUTEID") {
|
||||
NODEID = response.cookies[j].value;
|
||||
//output.NodeID = NODEID;
|
||||
}
|
||||
}
|
||||
|
||||
var loginResponse;
|
||||
try {
|
||||
loginResponse = JSON.parse(response.body.asString());
|
||||
} catch (e) {
|
||||
loginResponse = response.body.asString();
|
||||
}
|
||||
|
||||
if (debugLevel > 1) {
|
||||
myDebug.loginInfo = loginInfo;
|
||||
}
|
||||
myDebug.loginResponse = loginResponse;
|
||||
if (response.status === 200) {
|
||||
loginResult = true;
|
||||
} else {
|
||||
outMsg = {};
|
||||
outMsg.method = "login";
|
||||
outMsg.status = "error";
|
||||
var slError = myDebug.loginResponse.error;
|
||||
if (slError && slError.hasOwnProperty("code") && slError.message && slError.message.value) {
|
||||
outMsg.message = slError.message.value + " (Code: " + slError.code.toString() + ")";
|
||||
} else {
|
||||
outMsg.message = JSON.stringify(myDebug.loginResponse);
|
||||
}
|
||||
outMsg.response = myDebug.loginResponse;
|
||||
//outMsg.message = loginResponse;
|
||||
outMessages.push(outMsg);
|
||||
outStatus = "error";
|
||||
}
|
||||
return loginResult;
|
||||
}
|
||||
|
||||
function updateUDO(provider) {
|
||||
outMsg = {};
|
||||
outMsg.method = "updateUDO";
|
||||
outMsg.status = "failure";
|
||||
try {
|
||||
var slProviderObj = {
|
||||
EON_PROVIDER_LINESCollection: provider.NextPeriod.map(function(npl) {return {
|
||||
Code: npl.Code,
|
||||
U_CODE: npl.U_CODE,
|
||||
U_FROM: datetimeLib.convertToISODate(npl.U_FROM),
|
||||
U_TO: datetimeLib.convertToISODate(npl.U_TO),
|
||||
U_OPERATOR: npl.U_OPERATOR,
|
||||
U_SUBOPERATOR: npl.U_SUBOPERATOR,
|
||||
U_TYP: npl.U_TYP,
|
||||
U_CURRENCY: npl.U_CURRENCY,
|
||||
U_VALUE: npl.NewValue,
|
||||
U_BLOCK_FROM: npl.U_BLOCK_FROM,
|
||||
U_BLOCK_TO: npl.U_BLOCK_TO,
|
||||
U_BLOCKMAX: npl.U_BLOCKMAX,
|
||||
U_RELEASED: 'Y',
|
||||
U_RELEASE_DATE: datetimeLib.convertToISODate(new Date()),
|
||||
U_RELEASE_USER: $.session.getUsername(),
|
||||
U_CHANGE_DATE: datetimeLib.convertToISODate(new Date()),
|
||||
U_CHANGE_USER: $.session.getUsername()
|
||||
};})
|
||||
};
|
||||
myDebug.slProviderObj = slProviderObj;
|
||||
var responseProvider = slLib.patchDynamicEntity('EON_PROVIDER', provider.Code, JSON.stringify(slProviderObj), SESSIONID, NODEID, false);
|
||||
if (responseProvider.status >= 200 && responseProvider.status < 300) {
|
||||
outMsg.status = "success";
|
||||
} else {
|
||||
if (responseProvider.body) {
|
||||
var responseBodyParsed = JSON.parse(responseProvider.body.asString());
|
||||
var slError = responseBodyParsed.error;
|
||||
if (slError && slError.hasOwnProperty("code") && slError.message && slError.message.value) {
|
||||
outMsg.message = slError.message.value + " (Code: " + slError.code.toString() + ")";
|
||||
} else {
|
||||
outMsg.message = responseProvider.body.asString();
|
||||
}
|
||||
outMsg.response = responseBodyParsed;
|
||||
} else {
|
||||
outMsg.message = JSON.stringify(responseProvider);
|
||||
}
|
||||
outStatus = "error";
|
||||
}
|
||||
outMessages.push(outMsg);
|
||||
} catch (ex) {
|
||||
exceptionHandler(ex);
|
||||
}
|
||||
}
|
||||
|
||||
// main
|
||||
var content = "";
|
||||
if ($.request.body) {
|
||||
content = $.request.body.asString();
|
||||
}
|
||||
if (checkPayload(content) && checkAuthorization()) {
|
||||
setConnectionParams();
|
||||
slLoggedIn = slLogin();
|
||||
if (slLoggedIn) {
|
||||
updateUDO(JSON.parse(content));
|
||||
slLib.SLLogout(SESSIONID, NODEID);
|
||||
}
|
||||
}
|
||||
|
||||
$.trace.debug("DEBUG: " + JSON.stringify(myDebug));
|
||||
setOutputMessage();
|
||||
@@ -0,0 +1,269 @@
|
||||
var datetimeLib = $.import("uniorg.libs", "datetime");
|
||||
//var logginglib = $.import("uniorg.libs", "uologging");
|
||||
//var billingEngine = $.import("uniorg.eon.emobility.billing.engine.v1", "BillingEngine");
|
||||
var destLib = $.import("uniorg.destinations", "uodestlib");
|
||||
var slLib = $.import("uniorg.ServiceLayer", "B1SLLogic");
|
||||
|
||||
var serviceName = "eon.emobility.provider.backend.deleteSubOperator.xsjs";
|
||||
var serviceVersion = '1.0';
|
||||
|
||||
var output = {};
|
||||
var outMessages = [];
|
||||
var outMsg = {};
|
||||
var outStatus = "success";
|
||||
var myDebug = {};
|
||||
|
||||
var companyid = 0;
|
||||
var UserName = '';
|
||||
var UserPass = '';
|
||||
var UserComp = '';
|
||||
|
||||
var SESSIONID = "";
|
||||
var NODEID = "";
|
||||
var slLoggedIn = false;
|
||||
var schemaName = "A19753_EON_P01";
|
||||
|
||||
var debugLevel = 0;
|
||||
switch ($.request.parameters.get("debug")) {
|
||||
case "true":
|
||||
case "yes":
|
||||
case "1":
|
||||
debugLevel = 1;
|
||||
break;
|
||||
case "full":
|
||||
case "2":
|
||||
debugLevel = 2;
|
||||
break;
|
||||
}
|
||||
|
||||
if (debugLevel > 0) {
|
||||
output.requestParams = $.request.parameters;
|
||||
}
|
||||
|
||||
function setOutputMessage() {
|
||||
output.status = outStatus;
|
||||
if (debugLevel > 0) {
|
||||
output.debugInfos = myDebug;
|
||||
}
|
||||
output.messages = outMessages;
|
||||
$.response.contentType = "application/json";
|
||||
$.response.setBody(JSON.stringify(output));
|
||||
//$.response.status = $.net.http.OK;
|
||||
}
|
||||
|
||||
function exceptionHandler(ex) {
|
||||
if (outMsg.method && outMessages.indexOf(outMsg) === -1) {
|
||||
outMsg.status = "canceled";
|
||||
outMessages.push(outMsg);
|
||||
}
|
||||
outMsg = {};
|
||||
outMsg.method = "exceptionHandler";
|
||||
outMsg.status = "error";
|
||||
outMsg.message = ex.toString();
|
||||
if (debugLevel > 0) {
|
||||
outMsg.exceptionInfo = {};
|
||||
outMsg.exceptionInfo.name = ex.name;
|
||||
outMsg.exceptionInfo.message = ex.message;
|
||||
outMsg.exceptionInfo.fileName = ex.fileName;
|
||||
outMsg.exceptionInfo.lineNumber = ex.lineNumber;
|
||||
outMsg.exceptionInfo.columnNumber = ex.columnNumber;
|
||||
outMsg.exceptionInfo.stack = ex.stack;
|
||||
//outMsg.exceptionInfo.source = ex.toSource();
|
||||
}
|
||||
outMessages.push(outMsg);
|
||||
outStatus = "error";
|
||||
output.status = outStatus;
|
||||
if (debugLevel > 0) {
|
||||
output.debugInfos = myDebug;
|
||||
}
|
||||
output.messages = outMessages;
|
||||
|
||||
var errbody = JSON.stringify(output);
|
||||
$.response.contentType = 'application/json';
|
||||
$.response.setBody(errbody);
|
||||
$.response.status = $.net.http.INTERNAL_SERVER_ERROR;
|
||||
try {
|
||||
if (slLoggedIn) {
|
||||
slLib.SLLogout(SESSIONID, NODEID);
|
||||
}
|
||||
} catch (e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function checkAuthorization() {
|
||||
var isAuthorized = true;
|
||||
try {
|
||||
$.session.assertAppPrivilege("uniorg.eon.emobility.provider::MaintainProviderData");
|
||||
} catch (ex) {
|
||||
isAuthorized = false;
|
||||
outMsg = {};
|
||||
outMsg.method = "checkAuthorization";
|
||||
outMsg.status = "error";
|
||||
outStatus = "error";
|
||||
outMsg.message = "Privilege '" + ex.privilege + "' is missing";
|
||||
outMessages.push(outMsg);
|
||||
$.response.status = $.net.http.FORBIDDEN;
|
||||
}
|
||||
return isAuthorized;
|
||||
}
|
||||
|
||||
function checkPayload(inObj) {
|
||||
var isValid = true;
|
||||
var errorList = [];
|
||||
try {
|
||||
var subOperator = JSON.parse(inObj);
|
||||
if (!subOperator.hasOwnProperty('Code')) {
|
||||
isValid = false;
|
||||
}
|
||||
} catch (e) {
|
||||
exceptionHandler(e);
|
||||
isValid = false;
|
||||
}
|
||||
if (!isValid) {
|
||||
outMsg = {};
|
||||
outMsg.method = "checkPayload";
|
||||
outMsg.status = "error";
|
||||
outStatus = "error";
|
||||
if (errorList.length > 0) {
|
||||
outMsg.message = "invalid payload content";
|
||||
output.results = errorList;
|
||||
} else {
|
||||
outMsg.message = "invalid payload structure";
|
||||
}
|
||||
outMessages.push(outMsg);
|
||||
$.response.status = $.net.http.BAD_REQUEST;
|
||||
}
|
||||
return isValid;
|
||||
}
|
||||
|
||||
function setConnectionParams() {
|
||||
var idValue = schemaName;
|
||||
var idFieldname = 'SYS_NAME';
|
||||
var CompanyConfig = destLib.getCompanyCfg(idValue, idFieldname);
|
||||
UserComp = CompanyConfig.COMPANYNAME;
|
||||
UserName = CompanyConfig.USERNAME;
|
||||
UserPass = destLib.readSecureStore(CompanyConfig.ID);
|
||||
if (debugLevel > 1) {
|
||||
myDebug.connectionParams = CompanyConfig;
|
||||
}
|
||||
myDebug.idValue = idValue;
|
||||
myDebug.idFieldname = idFieldname;
|
||||
if (CompanyConfig.COMPANYNAME === undefined) {
|
||||
outMsg = {};
|
||||
outMsg.method = "getCompany";
|
||||
outStatus = "error";
|
||||
outMsg.status = "error";
|
||||
outMsg.message = "System " + idValue + " is invalid for this endpoint";
|
||||
outMessages.push(outMsg);
|
||||
}
|
||||
|
||||
myDebug.CompanyName = UserComp;
|
||||
}
|
||||
|
||||
function slLogin() {
|
||||
var loginResult = false;
|
||||
var loginInfo = {};
|
||||
loginInfo.UserName = UserName;
|
||||
loginInfo.Password = UserPass;
|
||||
loginInfo.CompanyDB = UserComp;
|
||||
|
||||
// SL LOGIN
|
||||
var response = slLib.SLLogin(JSON.stringify(loginInfo), null, null);
|
||||
|
||||
// B1SESSION and ROUTEID cookies returned by Login
|
||||
for (var j in response.cookies) {
|
||||
if (response.cookies[j].name == "B1SESSION") {
|
||||
SESSIONID = response.cookies[j].value;
|
||||
//output.SessionID = SESSIONID;
|
||||
} else if (response.cookies[j].name == "ROUTEID") {
|
||||
NODEID = response.cookies[j].value;
|
||||
//output.NodeID = NODEID;
|
||||
}
|
||||
}
|
||||
|
||||
var loginResponse;
|
||||
try {
|
||||
loginResponse = JSON.parse(response.body.asString());
|
||||
} catch (e) {
|
||||
loginResponse = response.body.asString();
|
||||
}
|
||||
|
||||
if (debugLevel > 1) {
|
||||
myDebug.loginInfo = loginInfo;
|
||||
}
|
||||
myDebug.loginResponse = loginResponse;
|
||||
if (response.status === 200) {
|
||||
loginResult = true;
|
||||
} else {
|
||||
outMsg = {};
|
||||
outMsg.method = "login";
|
||||
outMsg.status = "error";
|
||||
var slError = myDebug.loginResponse.error;
|
||||
if (slError && slError.hasOwnProperty("code") && slError.message && slError.message.value) {
|
||||
outMsg.message = slError.message.value + " (Code: " + slError.code.toString() + ")";
|
||||
} else {
|
||||
outMsg.message = JSON.stringify(myDebug.loginResponse);
|
||||
}
|
||||
outMsg.response = myDebug.loginResponse;
|
||||
//outMsg.message = loginResponse;
|
||||
outMessages.push(outMsg);
|
||||
outStatus = "error";
|
||||
}
|
||||
return loginResult;
|
||||
}
|
||||
|
||||
function deleteUDO(Code) {
|
||||
outMsg = {};
|
||||
outMsg.method = "deleteUDO";
|
||||
outMsg.code = Code;
|
||||
outMsg.status = "error";
|
||||
var result = {};
|
||||
try {
|
||||
var responseDelete = slLib.deleteDynamicEntity('EON_SUBOPERATOR', Code, SESSIONID, NODEID);
|
||||
outMsg.statuscode = responseDelete.status;
|
||||
if (responseDelete.status >= 200 && responseDelete.status < 300) {
|
||||
outMsg.status = "success";
|
||||
} else {
|
||||
if (responseDelete.body) {
|
||||
var responseBodyParsed = JSON.parse(responseDelete.body.asString());
|
||||
var slError = responseBodyParsed.error;
|
||||
if (slError && slError.hasOwnProperty("code") && slError.message && slError.message.value) {
|
||||
outMsg.message = slError.message.value + " (Code: " + slError.code.toString() + ")";
|
||||
} else {
|
||||
outMsg.message = responseDelete.body.asString();
|
||||
}
|
||||
outMsg.response = responseBodyParsed;
|
||||
} else {
|
||||
outMsg.message = JSON.stringify(responseDelete);
|
||||
}
|
||||
outStatus = "error";
|
||||
}
|
||||
if (debugLevel > 0 || outMsg.status !== "success") {
|
||||
outMessages.push(outMsg);
|
||||
}
|
||||
} catch (ex) {
|
||||
exceptionHandler(ex);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// main
|
||||
var content = "";
|
||||
if ($.request.body) {
|
||||
content = $.request.body.asString();
|
||||
}
|
||||
if (checkPayload(content) && checkAuthorization()) {
|
||||
setConnectionParams();
|
||||
slLoggedIn = slLogin();
|
||||
if (slLoggedIn) {
|
||||
var inObj = JSON.parse(content);
|
||||
if (outStatus !== "error") {
|
||||
deleteUDO(inObj.Code);
|
||||
}
|
||||
slLib.SLLogout(SESSIONID, NODEID);
|
||||
}
|
||||
}
|
||||
|
||||
$.trace.debug("DEBUG: " + JSON.stringify(myDebug));
|
||||
setOutputMessage();
|
||||
@@ -0,0 +1,971 @@
|
||||
//var datetimelib = $.import("uniorg.libs", "datetime");
|
||||
//var logginglib = $.import("uniorg.libs", "uologging");
|
||||
//var billingEngine = $.import("uniorg.eon.emobility.billing.engine.v1", "BillingEngine");
|
||||
|
||||
var serviceName = "eon.emobility.provider.backend.getProviderData.xsjs";
|
||||
var serviceVersion = '1.3';
|
||||
|
||||
var output = {};
|
||||
var outMessages = [];
|
||||
var outMsg = {};
|
||||
var outStatus = "success";
|
||||
var myDebug = {};
|
||||
|
||||
var debugLevel = 0;
|
||||
switch ($.request.parameters.get("debug")) {
|
||||
case "true":
|
||||
case "yes":
|
||||
case "1":
|
||||
debugLevel = 1;
|
||||
break;
|
||||
case "full":
|
||||
case "2":
|
||||
debugLevel = 2;
|
||||
break;
|
||||
}
|
||||
|
||||
if (debugLevel > 0) {
|
||||
output.requestParams = $.request.parameters;
|
||||
}
|
||||
|
||||
function setOutputMessage() {
|
||||
output.status = outStatus;
|
||||
if (debugLevel > 0) {
|
||||
output.debugInfos = myDebug;
|
||||
}
|
||||
output.messages = outMessages;
|
||||
$.response.contentType = "application/json";
|
||||
$.response.setBody(JSON.stringify(output));
|
||||
//$.response.status = $.net.http.OK;
|
||||
}
|
||||
|
||||
function exceptionHandler(ex) {
|
||||
outMsg = {};
|
||||
outMsg.method = "exceptionHandler";
|
||||
outMsg.status = "error";
|
||||
outMsg.message = ex.toString();
|
||||
if (debugLevel > 0) {
|
||||
outMsg.exceptionInfo = {};
|
||||
outMsg.exceptionInfo.name = ex.name;
|
||||
outMsg.exceptionInfo.message = ex.message;
|
||||
outMsg.exceptionInfo.fileName = ex.fileName;
|
||||
outMsg.exceptionInfo.lineNumber = ex.lineNumber;
|
||||
outMsg.exceptionInfo.columnNumber = ex.columnNumber;
|
||||
outMsg.exceptionInfo.stack = ex.stack;
|
||||
//outMsg.exceptionInfo.source = ex.toSource();
|
||||
}
|
||||
outMessages.push(outMsg);
|
||||
outStatus = "error";
|
||||
output.status = outStatus;
|
||||
if (debugLevel > 0) {
|
||||
output.debugInfos = myDebug;
|
||||
}
|
||||
output.messages = outMessages;
|
||||
|
||||
var errbody = JSON.stringify(output);
|
||||
$.response.contentType = 'application/json';
|
||||
$.response.setBody(errbody);
|
||||
$.response.status = $.net.http.INTERNAL_SERVER_ERROR;
|
||||
}
|
||||
|
||||
function checkAuthorization() {
|
||||
var isAuthorized = true;
|
||||
try {
|
||||
$.session.assertAppPrivilege("uniorg.eon.emobility.provider::ViewProviderData");
|
||||
} catch (ex) {
|
||||
isAuthorized = false;
|
||||
outMsg = {};
|
||||
outMsg.method = "checkAuthorization";
|
||||
outMsg.status = "error";
|
||||
outStatus = "error";
|
||||
outMsg.message = "Privilege '" + ex.privilege + "' is missing";
|
||||
outMessages.push(outMsg);
|
||||
$.response.status = $.net.http.FORBIDDEN;
|
||||
}
|
||||
// temporary test
|
||||
/*var random_boolean = Math.random() < 0.5;
|
||||
if (random_boolean) {
|
||||
isAuthorized = false;
|
||||
outMsg = {};
|
||||
outMsg.method = "checkAuthorization";
|
||||
outMsg.status = "error";
|
||||
outStatus = "error";
|
||||
outMsg.message = "Random test exception";
|
||||
outMessages.push(outMsg);
|
||||
$.response.status = $.net.http.UNAUTHORIZED;
|
||||
}*/
|
||||
//
|
||||
return isAuthorized;
|
||||
}
|
||||
|
||||
function checkParams() {
|
||||
var isValid = true;
|
||||
var missingParams = [];
|
||||
try {
|
||||
/*if (!$.request.parameters.get("billingrunid")) {
|
||||
missingParams.push("billingrunid");
|
||||
isValid = false;
|
||||
}
|
||||
if (!$.request.parameters.get("phase")) {
|
||||
missingParams.push("phase");
|
||||
isValid = false;
|
||||
}*/
|
||||
} catch (e) {
|
||||
exceptionHandler(e);
|
||||
isValid = false;
|
||||
}
|
||||
if (!isValid) {
|
||||
outMsg = {};
|
||||
outMsg.method = "checkParams";
|
||||
outMsg.status = "error";
|
||||
outStatus = "error";
|
||||
outMsg.message = "missing mandatory parameters: " + missingParams.join();
|
||||
outMessages.push(outMsg);
|
||||
$.response.status = $.net.http.BAD_REQUEST;
|
||||
}
|
||||
return isValid;
|
||||
}
|
||||
|
||||
function setScheduled(billingRunId) {
|
||||
outMsg = {};
|
||||
outMsg.method = "schedule";
|
||||
outMsg.status = "failure";
|
||||
try {
|
||||
var conn = $.hdb.getConnection();
|
||||
var query =
|
||||
'update BRL set BRL."STATUS"=\'scheduled\' from \
|
||||
"A19753_EON_P01"."UO_BILLINGRUN_LINE" BRL INNER JOIN "A19753_EON_P01"."UO_BILLINGRUN_HEAD" BRH ON BRH."ID"=BRL."BILLING_RUN_ID" \
|
||||
where BRL."STATUS" = \'phase1\' and BRH."RUN_ID" = ?';
|
||||
myDebug.updateStatement = query;
|
||||
var rc = conn.executeUpdate(query, billingRunId);
|
||||
outMsg.rowsAffected = rc;
|
||||
if (rc > 0) {
|
||||
outMsg.status = "success";
|
||||
} else {
|
||||
outStatus = "error";
|
||||
outMsg.message = "No Billing Lines for Billing Run ID " + billingRunId + " were found";
|
||||
$.response.status = $.net.http.NOT_FOUND;
|
||||
}
|
||||
conn.commit();
|
||||
conn.close();
|
||||
|
||||
outMessages.push(outMsg);
|
||||
} catch (ex) {
|
||||
exceptionHandler(ex);
|
||||
}
|
||||
}
|
||||
|
||||
function setPhase(billingRunId, phase) {
|
||||
outMsg = {};
|
||||
outMsg.method = "update";
|
||||
outMsg.status = "failure";
|
||||
try {
|
||||
var conn = $.hdb.getConnection();
|
||||
var query =
|
||||
'UPDATE "A19753_EON_P01"."UO_BILLINGRUN_HEAD" SET "PHASE" = ?, "UPDATE_TS" = CURRENT_TIMESTAMP, "USER_EXECUTE" = ? WHERE "RUN_ID" = ?';
|
||||
myDebug.updateStatement = query;
|
||||
var rc = conn.executeUpdate(query, phase, $.session.getUsername(), billingRunId);
|
||||
outMsg.rowsAffected = rc;
|
||||
if (rc > 0) {
|
||||
outMsg.status = "success";
|
||||
} else {
|
||||
outStatus = "error";
|
||||
outMsg.message = "Billing Run ID " + billingRunId + " was not found";
|
||||
$.response.status = $.net.http.NOT_FOUND;
|
||||
}
|
||||
conn.commit();
|
||||
conn.close();
|
||||
|
||||
outMessages.push(outMsg);
|
||||
if (outMsg.status = "success" && phase === 'INVOICED') {
|
||||
setScheduled(billingRunId);
|
||||
}
|
||||
} catch (ex) {
|
||||
exceptionHandler(ex);
|
||||
}
|
||||
}
|
||||
|
||||
function getData() {
|
||||
outMsg = {};
|
||||
outMsg.method = "get";
|
||||
outMsg.status = "success";
|
||||
var rsMsg = {};
|
||||
rsMsg.ReadOnly = !$.session.hasAppPrivilege("uniorg.eon.emobility.provider::MaintainProviderData");
|
||||
try {
|
||||
|
||||
var conn = $.db.getConnection();
|
||||
var pstmt;
|
||||
var query = 'SELECT * FROM "A19753_EON_P01"."V_EON_PROVIDER" ORDER BY "Code"';
|
||||
pstmt = conn.prepareStatement(query);
|
||||
var rs = pstmt.executeQuery();
|
||||
var rsmd = rs.getMetaData();
|
||||
var colCount = rsmd.getColumnCount();
|
||||
var rc = 0;
|
||||
var providerRows = [];
|
||||
while (rs.next()) {
|
||||
var row = {};
|
||||
rc++;
|
||||
for (var c = 1; c <= colCount; c++) {
|
||||
var colName = rsmd.getColumnLabel(c);
|
||||
var colType = rsmd.getColumnTypeName(c);
|
||||
switch (colType) {
|
||||
case 'TINYINT':
|
||||
case 'SMALLINT':
|
||||
case 'INT':
|
||||
case 'INTEGER':
|
||||
case 'BIGINT':
|
||||
row[colName] = rs.getInteger(c);
|
||||
break;
|
||||
case 'DECIMAL':
|
||||
row[colName] = rs.getDecimal(c);
|
||||
break;
|
||||
case 'REAL':
|
||||
case 'DOUBLE':
|
||||
case 'FLOAT':
|
||||
row[colName] = rs.getDouble(c);
|
||||
break;
|
||||
case 'NVARCHAR':
|
||||
case 'NCHAR':
|
||||
case 'SHORTTEXT':
|
||||
row[colName] = rs.getNString(c);
|
||||
break;
|
||||
case 'VARCHAR':
|
||||
case 'CHAR':
|
||||
row[colName] = rs.getString(c);
|
||||
break;
|
||||
case 'BINARY':
|
||||
case 'VARBINARY':
|
||||
row[colName] = rs.getBString(c);
|
||||
break;
|
||||
case 'DATE':
|
||||
row[colName] = rs.getDate(c);
|
||||
break;
|
||||
case 'TIME':
|
||||
row[colName] = rs.getTime(c);
|
||||
break;
|
||||
case 'TIMESTAMP':
|
||||
row[colName] = rs.getTimestamp(c);
|
||||
break;
|
||||
case 'CLOB':
|
||||
row[colName] = rs.getClob(c);
|
||||
break;
|
||||
case 'NCLOB':
|
||||
case 'TEXT':
|
||||
row[colName] = rs.getNClob(c);
|
||||
break;
|
||||
case 'BLOB':
|
||||
row[colName] = rs.getBlob(c);
|
||||
break;
|
||||
case 'SECONDDATE':
|
||||
row[colName] = rs.getSeconddate(c);
|
||||
break;
|
||||
}
|
||||
//row[colName] = colType;
|
||||
}
|
||||
providerRows.push(row);
|
||||
}
|
||||
|
||||
query = 'SELECT * FROM "A19753_EON_P01"."V_EON_PROVIDER_LINES" ORDER BY "Code", U_CODE DESC, U_FROM DESC, U_TYP, U_OPERATOR';
|
||||
pstmt = conn.prepareStatement(query);
|
||||
rs = pstmt.executeQuery();
|
||||
rsmd = rs.getMetaData();
|
||||
colCount = rsmd.getColumnCount();
|
||||
rc = 0;
|
||||
var lineRows = [];
|
||||
while (rs.next()) {
|
||||
row = {};
|
||||
rc++;
|
||||
for (c = 1; c <= colCount; c++) {
|
||||
colName = rsmd.getColumnLabel(c);
|
||||
colType = rsmd.getColumnTypeName(c);
|
||||
switch (colType) {
|
||||
case 'TINYINT':
|
||||
case 'SMALLINT':
|
||||
case 'INT':
|
||||
case 'INTEGER':
|
||||
case 'BIGINT':
|
||||
row[colName] = rs.getInteger(c);
|
||||
break;
|
||||
case 'DECIMAL':
|
||||
row[colName] = rs.getDecimal(c);
|
||||
break;
|
||||
case 'REAL':
|
||||
case 'DOUBLE':
|
||||
case 'FLOAT':
|
||||
row[colName] = rs.getDouble(c);
|
||||
break;
|
||||
case 'NVARCHAR':
|
||||
case 'NCHAR':
|
||||
case 'SHORTTEXT':
|
||||
row[colName] = rs.getNString(c);
|
||||
break;
|
||||
case 'VARCHAR':
|
||||
case 'CHAR':
|
||||
row[colName] = rs.getString(c);
|
||||
break;
|
||||
case 'BINARY':
|
||||
case 'VARBINARY':
|
||||
row[colName] = rs.getBString(c);
|
||||
break;
|
||||
case 'DATE':
|
||||
row[colName] = rs.getDate(c);
|
||||
break;
|
||||
case 'TIME':
|
||||
row[colName] = rs.getTime(c);
|
||||
break;
|
||||
case 'TIMESTAMP':
|
||||
row[colName] = rs.getTimestamp(c);
|
||||
break;
|
||||
case 'CLOB':
|
||||
row[colName] = rs.getClob(c);
|
||||
break;
|
||||
case 'NCLOB':
|
||||
case 'TEXT':
|
||||
row[colName] = rs.getNClob(c);
|
||||
break;
|
||||
case 'BLOB':
|
||||
row[colName] = rs.getBlob(c);
|
||||
break;
|
||||
case 'SECONDDATE':
|
||||
row[colName] = rs.getSeconddate(c);
|
||||
break;
|
||||
}
|
||||
//row[colName] = colType;
|
||||
}
|
||||
row.editable = false;
|
||||
row.new = false;
|
||||
row.pendingChanges = false;
|
||||
row.highlight = 'None';
|
||||
row.highlightText = '';
|
||||
row.guid = $.util.createUuid();
|
||||
lineRows.push(row);
|
||||
}
|
||||
|
||||
query = 'SELECT * FROM "A19753_EON_P01"."V_EON_PROVIDER_PERIODS" ORDER BY "Code", U_FROM DESC';
|
||||
pstmt = conn.prepareStatement(query);
|
||||
rs = pstmt.executeQuery();
|
||||
rsmd = rs.getMetaData();
|
||||
colCount = rsmd.getColumnCount();
|
||||
rc = 0;
|
||||
var periodRows = [];
|
||||
while (rs.next()) {
|
||||
row = {};
|
||||
rc++;
|
||||
for (c = 1; c <= colCount; c++) {
|
||||
colName = rsmd.getColumnLabel(c);
|
||||
colType = rsmd.getColumnTypeName(c);
|
||||
switch (colType) {
|
||||
case 'TINYINT':
|
||||
case 'SMALLINT':
|
||||
case 'INT':
|
||||
case 'INTEGER':
|
||||
case 'BIGINT':
|
||||
row[colName] = rs.getInteger(c);
|
||||
break;
|
||||
case 'DECIMAL':
|
||||
row[colName] = rs.getDecimal(c);
|
||||
break;
|
||||
case 'REAL':
|
||||
case 'DOUBLE':
|
||||
case 'FLOAT':
|
||||
row[colName] = rs.getDouble(c);
|
||||
break;
|
||||
case 'NVARCHAR':
|
||||
case 'NCHAR':
|
||||
case 'SHORTTEXT':
|
||||
row[colName] = rs.getNString(c);
|
||||
break;
|
||||
case 'VARCHAR':
|
||||
case 'CHAR':
|
||||
row[colName] = rs.getString(c);
|
||||
break;
|
||||
case 'BINARY':
|
||||
case 'VARBINARY':
|
||||
row[colName] = rs.getBString(c);
|
||||
break;
|
||||
case 'DATE':
|
||||
row[colName] = rs.getDate(c);
|
||||
break;
|
||||
case 'TIME':
|
||||
row[colName] = rs.getTime(c);
|
||||
break;
|
||||
case 'TIMESTAMP':
|
||||
row[colName] = rs.getTimestamp(c);
|
||||
break;
|
||||
case 'CLOB':
|
||||
row[colName] = rs.getClob(c);
|
||||
break;
|
||||
case 'NCLOB':
|
||||
case 'TEXT':
|
||||
row[colName] = rs.getNClob(c);
|
||||
break;
|
||||
case 'BLOB':
|
||||
row[colName] = rs.getBlob(c);
|
||||
break;
|
||||
case 'SECONDDATE':
|
||||
row[colName] = rs.getSeconddate(c);
|
||||
break;
|
||||
}
|
||||
//row[colName] = colType;
|
||||
}
|
||||
periodRows.push(row);
|
||||
}
|
||||
query = 'SELECT * FROM "A19753_EON_P01"."V_EON_PROVIDER_NEXT_PERIOD" ORDER BY "Code", U_CODE DESC, U_FROM DESC, U_TYP, U_OPERATOR, U_SUBOPERATOR';
|
||||
pstmt = conn.prepareStatement(query);
|
||||
rs = pstmt.executeQuery();
|
||||
rsmd = rs.getMetaData();
|
||||
colCount = rsmd.getColumnCount();
|
||||
rc = 0;
|
||||
var nextPeriodRows = [];
|
||||
while (rs.next()) {
|
||||
row = {};
|
||||
rc++;
|
||||
for (c = 1; c <= colCount; c++) {
|
||||
colName = rsmd.getColumnLabel(c);
|
||||
colType = rsmd.getColumnTypeName(c);
|
||||
switch (colType) {
|
||||
case 'TINYINT':
|
||||
case 'SMALLINT':
|
||||
case 'INT':
|
||||
case 'INTEGER':
|
||||
case 'BIGINT':
|
||||
row[colName] = rs.getInteger(c);
|
||||
break;
|
||||
case 'DECIMAL':
|
||||
row[colName] = rs.getDecimal(c);
|
||||
break;
|
||||
case 'REAL':
|
||||
case 'DOUBLE':
|
||||
case 'FLOAT':
|
||||
row[colName] = rs.getDouble(c);
|
||||
break;
|
||||
case 'NVARCHAR':
|
||||
case 'NCHAR':
|
||||
case 'SHORTTEXT':
|
||||
row[colName] = rs.getNString(c);
|
||||
break;
|
||||
case 'VARCHAR':
|
||||
case 'CHAR':
|
||||
row[colName] = rs.getString(c);
|
||||
break;
|
||||
case 'BINARY':
|
||||
case 'VARBINARY':
|
||||
row[colName] = rs.getBString(c);
|
||||
break;
|
||||
case 'DATE':
|
||||
row[colName] = rs.getDate(c);
|
||||
break;
|
||||
case 'TIME':
|
||||
row[colName] = rs.getTime(c);
|
||||
break;
|
||||
case 'TIMESTAMP':
|
||||
row[colName] = rs.getTimestamp(c);
|
||||
break;
|
||||
case 'CLOB':
|
||||
row[colName] = rs.getClob(c);
|
||||
break;
|
||||
case 'NCLOB':
|
||||
case 'TEXT':
|
||||
row[colName] = rs.getNClob(c);
|
||||
break;
|
||||
case 'BLOB':
|
||||
row[colName] = rs.getBlob(c);
|
||||
break;
|
||||
case 'SECONDDATE':
|
||||
row[colName] = rs.getSeconddate(c);
|
||||
break;
|
||||
}
|
||||
//row[colName] = colType;
|
||||
}
|
||||
row.editable = false;
|
||||
row.guid = $.util.createUuid();
|
||||
row.highlight = 'None';
|
||||
row.highlightText = '';
|
||||
nextPeriodRows.push(row);
|
||||
}
|
||||
|
||||
var provider = providerRows.map(function(p) {
|
||||
var prov = {};
|
||||
// copy all properties of provider head object
|
||||
Object.keys(p).forEach(function(k) {
|
||||
prov[k] = p[k];
|
||||
});
|
||||
prov.editable = false;
|
||||
prov.new = false;
|
||||
prov.pendingChanges = false;
|
||||
prov.allowNewPeriod = $.session.hasAppPrivilege("uniorg.eon.emobility.provider::MaintainProviderData");
|
||||
prov.Lines = lineRows.filter(function(lr) {
|
||||
return lr.Code === p.Code;
|
||||
});
|
||||
prov.Periods = periodRows.filter(function(pr) {
|
||||
return pr.Code === p.Code;
|
||||
});
|
||||
prov.NextPeriod = nextPeriodRows.filter(function(npr) {
|
||||
return npr.Code === p.Code;
|
||||
});
|
||||
return prov;
|
||||
});
|
||||
rsMsg.Provider = provider;
|
||||
|
||||
|
||||
query = 'SELECT T1."FldValue" AS "U_CODE" FROM "A19753_EON_P01"."CUFD" D1 INNER JOIN "A19753_EON_P01"."UFD1" T1 ON D1."TableID"=T1."TableID" AND D1."FieldID"=T1."FieldID" AND D1."AliasID"=\'CODE\' WHERE D1."TableID" = \'@EON_PROVIDER_LINES\'';
|
||||
pstmt = conn.prepareStatement(query);
|
||||
rs = pstmt.executeQuery();
|
||||
rsmd = rs.getMetaData();
|
||||
colCount = rsmd.getColumnCount();
|
||||
rc = 0;
|
||||
var valuesCode = [];
|
||||
while (rs.next()) {
|
||||
row = {};
|
||||
rc++;
|
||||
for (c = 1; c <= colCount; c++) {
|
||||
colName = rsmd.getColumnLabel(c);
|
||||
colType = rsmd.getColumnTypeName(c);
|
||||
switch (colType) {
|
||||
case 'TINYINT':
|
||||
case 'SMALLINT':
|
||||
case 'INT':
|
||||
case 'INTEGER':
|
||||
case 'BIGINT':
|
||||
row[colName] = rs.getInteger(c);
|
||||
break;
|
||||
case 'DECIMAL':
|
||||
row[colName] = rs.getDecimal(c);
|
||||
break;
|
||||
case 'REAL':
|
||||
case 'DOUBLE':
|
||||
case 'FLOAT':
|
||||
row[colName] = rs.getDouble(c);
|
||||
break;
|
||||
case 'NVARCHAR':
|
||||
case 'NCHAR':
|
||||
case 'SHORTTEXT':
|
||||
row[colName] = rs.getNString(c);
|
||||
break;
|
||||
case 'VARCHAR':
|
||||
case 'CHAR':
|
||||
row[colName] = rs.getString(c);
|
||||
break;
|
||||
case 'BINARY':
|
||||
case 'VARBINARY':
|
||||
row[colName] = rs.getBString(c);
|
||||
break;
|
||||
case 'DATE':
|
||||
row[colName] = rs.getDate(c);
|
||||
break;
|
||||
case 'TIME':
|
||||
row[colName] = rs.getTime(c);
|
||||
break;
|
||||
case 'TIMESTAMP':
|
||||
row[colName] = rs.getTimestamp(c);
|
||||
break;
|
||||
case 'CLOB':
|
||||
row[colName] = rs.getClob(c);
|
||||
break;
|
||||
case 'NCLOB':
|
||||
case 'TEXT':
|
||||
row[colName] = rs.getNClob(c);
|
||||
break;
|
||||
case 'BLOB':
|
||||
row[colName] = rs.getBlob(c);
|
||||
break;
|
||||
case 'SECONDDATE':
|
||||
row[colName] = rs.getSeconddate(c);
|
||||
break;
|
||||
}
|
||||
//row[colName] = colType;
|
||||
}
|
||||
valuesCode.push(row);
|
||||
}
|
||||
|
||||
query = 'SELECT T1."FldValue" AS "U_TYP" FROM "A19753_EON_P01"."CUFD" D1 INNER JOIN "A19753_EON_P01"."UFD1" T1 ON D1."TableID"=T1."TableID" AND D1."FieldID"=T1."FieldID" AND D1."AliasID"=\'TYP\' WHERE D1."TableID" = \'@EON_PROVIDER_LINES\'';
|
||||
pstmt = conn.prepareStatement(query);
|
||||
rs = pstmt.executeQuery();
|
||||
rsmd = rs.getMetaData();
|
||||
colCount = rsmd.getColumnCount();
|
||||
rc = 0;
|
||||
var valuesType = [];
|
||||
while (rs.next()) {
|
||||
row = {};
|
||||
rc++;
|
||||
for (c = 1; c <= colCount; c++) {
|
||||
colName = rsmd.getColumnLabel(c);
|
||||
colType = rsmd.getColumnTypeName(c);
|
||||
switch (colType) {
|
||||
case 'TINYINT':
|
||||
case 'SMALLINT':
|
||||
case 'INT':
|
||||
case 'INTEGER':
|
||||
case 'BIGINT':
|
||||
row[colName] = rs.getInteger(c);
|
||||
break;
|
||||
case 'DECIMAL':
|
||||
row[colName] = rs.getDecimal(c);
|
||||
break;
|
||||
case 'REAL':
|
||||
case 'DOUBLE':
|
||||
case 'FLOAT':
|
||||
row[colName] = rs.getDouble(c);
|
||||
break;
|
||||
case 'NVARCHAR':
|
||||
case 'NCHAR':
|
||||
case 'SHORTTEXT':
|
||||
row[colName] = rs.getNString(c);
|
||||
break;
|
||||
case 'VARCHAR':
|
||||
case 'CHAR':
|
||||
row[colName] = rs.getString(c);
|
||||
break;
|
||||
case 'BINARY':
|
||||
case 'VARBINARY':
|
||||
row[colName] = rs.getBString(c);
|
||||
break;
|
||||
case 'DATE':
|
||||
row[colName] = rs.getDate(c);
|
||||
break;
|
||||
case 'TIME':
|
||||
row[colName] = rs.getTime(c);
|
||||
break;
|
||||
case 'TIMESTAMP':
|
||||
row[colName] = rs.getTimestamp(c);
|
||||
break;
|
||||
case 'CLOB':
|
||||
row[colName] = rs.getClob(c);
|
||||
break;
|
||||
case 'NCLOB':
|
||||
case 'TEXT':
|
||||
row[colName] = rs.getNClob(c);
|
||||
break;
|
||||
case 'BLOB':
|
||||
row[colName] = rs.getBlob(c);
|
||||
break;
|
||||
case 'SECONDDATE':
|
||||
row[colName] = rs.getSeconddate(c);
|
||||
break;
|
||||
}
|
||||
//row[colName] = colType;
|
||||
}
|
||||
valuesType.push(row);
|
||||
}
|
||||
|
||||
query = 'SELECT T1."FldValue" AS "U_OPERATOR" FROM "A19753_EON_P01"."CUFD" D1 INNER JOIN "A19753_EON_P01"."UFD1" T1 ON D1."TableID"=T1."TableID" AND D1."FieldID"=T1."FieldID" AND D1."AliasID"=\'OPERATOR\' WHERE D1."TableID" = \'@EON_PROVIDER_LINES\'';
|
||||
pstmt = conn.prepareStatement(query);
|
||||
rs = pstmt.executeQuery();
|
||||
rsmd = rs.getMetaData();
|
||||
colCount = rsmd.getColumnCount();
|
||||
rc = 0;
|
||||
var valuesOperator = [];
|
||||
while (rs.next()) {
|
||||
row = {};
|
||||
rc++;
|
||||
for (c = 1; c <= colCount; c++) {
|
||||
colName = rsmd.getColumnLabel(c);
|
||||
colType = rsmd.getColumnTypeName(c);
|
||||
switch (colType) {
|
||||
case 'TINYINT':
|
||||
case 'SMALLINT':
|
||||
case 'INT':
|
||||
case 'INTEGER':
|
||||
case 'BIGINT':
|
||||
row[colName] = rs.getInteger(c);
|
||||
break;
|
||||
case 'DECIMAL':
|
||||
row[colName] = rs.getDecimal(c);
|
||||
break;
|
||||
case 'REAL':
|
||||
case 'DOUBLE':
|
||||
case 'FLOAT':
|
||||
row[colName] = rs.getDouble(c);
|
||||
break;
|
||||
case 'NVARCHAR':
|
||||
case 'NCHAR':
|
||||
case 'SHORTTEXT':
|
||||
row[colName] = rs.getNString(c);
|
||||
break;
|
||||
case 'VARCHAR':
|
||||
case 'CHAR':
|
||||
row[colName] = rs.getString(c);
|
||||
break;
|
||||
case 'BINARY':
|
||||
case 'VARBINARY':
|
||||
row[colName] = rs.getBString(c);
|
||||
break;
|
||||
case 'DATE':
|
||||
row[colName] = rs.getDate(c);
|
||||
break;
|
||||
case 'TIME':
|
||||
row[colName] = rs.getTime(c);
|
||||
break;
|
||||
case 'TIMESTAMP':
|
||||
row[colName] = rs.getTimestamp(c);
|
||||
break;
|
||||
case 'CLOB':
|
||||
row[colName] = rs.getClob(c);
|
||||
break;
|
||||
case 'NCLOB':
|
||||
case 'TEXT':
|
||||
row[colName] = rs.getNClob(c);
|
||||
break;
|
||||
case 'BLOB':
|
||||
row[colName] = rs.getBlob(c);
|
||||
break;
|
||||
case 'SECONDDATE':
|
||||
row[colName] = rs.getSeconddate(c);
|
||||
break;
|
||||
}
|
||||
//row[colName] = colType;
|
||||
}
|
||||
valuesOperator.push(row);
|
||||
}
|
||||
|
||||
query = 'select "CurrCode", "CurrName", "ChkName" from "A19753_EON_P01".OCRN ORDER BY "CurrCode"';
|
||||
pstmt = conn.prepareStatement(query);
|
||||
rs = pstmt.executeQuery();
|
||||
rsmd = rs.getMetaData();
|
||||
colCount = rsmd.getColumnCount();
|
||||
rc = 0;
|
||||
var currencies = [];
|
||||
while (rs.next()) {
|
||||
row = {};
|
||||
rc++;
|
||||
for (c = 1; c <= colCount; c++) {
|
||||
colName = rsmd.getColumnLabel(c);
|
||||
colType = rsmd.getColumnTypeName(c);
|
||||
switch (colType) {
|
||||
case 'TINYINT':
|
||||
case 'SMALLINT':
|
||||
case 'INT':
|
||||
case 'INTEGER':
|
||||
case 'BIGINT':
|
||||
row[colName] = rs.getInteger(c);
|
||||
break;
|
||||
case 'DECIMAL':
|
||||
row[colName] = rs.getDecimal(c);
|
||||
break;
|
||||
case 'REAL':
|
||||
case 'DOUBLE':
|
||||
case 'FLOAT':
|
||||
row[colName] = rs.getDouble(c);
|
||||
break;
|
||||
case 'NVARCHAR':
|
||||
case 'NCHAR':
|
||||
case 'SHORTTEXT':
|
||||
row[colName] = rs.getNString(c);
|
||||
break;
|
||||
case 'VARCHAR':
|
||||
case 'CHAR':
|
||||
row[colName] = rs.getString(c);
|
||||
break;
|
||||
case 'BINARY':
|
||||
case 'VARBINARY':
|
||||
row[colName] = rs.getBString(c);
|
||||
break;
|
||||
case 'DATE':
|
||||
row[colName] = rs.getDate(c);
|
||||
break;
|
||||
case 'TIME':
|
||||
row[colName] = rs.getTime(c);
|
||||
break;
|
||||
case 'TIMESTAMP':
|
||||
row[colName] = rs.getTimestamp(c);
|
||||
break;
|
||||
case 'CLOB':
|
||||
row[colName] = rs.getClob(c);
|
||||
break;
|
||||
case 'NCLOB':
|
||||
case 'TEXT':
|
||||
row[colName] = rs.getNClob(c);
|
||||
break;
|
||||
case 'BLOB':
|
||||
row[colName] = rs.getBlob(c);
|
||||
break;
|
||||
case 'SECONDDATE':
|
||||
row[colName] = rs.getSeconddate(c);
|
||||
break;
|
||||
}
|
||||
//row[colName] = colType;
|
||||
}
|
||||
currencies.push(row);
|
||||
}
|
||||
|
||||
rsMsg.ValueHelp = {
|
||||
Code: valuesCode,
|
||||
Type: valuesType,
|
||||
Operator: valuesOperator,
|
||||
Currencies: currencies
|
||||
};
|
||||
|
||||
query = 'SELECT "Code", "Name" FROM "A19753_EON_P01"."@EON_SUBOPERATOR" ORDER BY "Code"';
|
||||
pstmt = conn.prepareStatement(query);
|
||||
rs = pstmt.executeQuery();
|
||||
rsmd = rs.getMetaData();
|
||||
colCount = rsmd.getColumnCount();
|
||||
rc = 0;
|
||||
var subOperators = [];
|
||||
while (rs.next()) {
|
||||
row = {};
|
||||
rc++;
|
||||
for (c = 1; c <= colCount; c++) {
|
||||
colName = rsmd.getColumnLabel(c);
|
||||
colType = rsmd.getColumnTypeName(c);
|
||||
switch (colType) {
|
||||
case 'TINYINT':
|
||||
case 'SMALLINT':
|
||||
case 'INT':
|
||||
case 'INTEGER':
|
||||
case 'BIGINT':
|
||||
row[colName] = rs.getInteger(c);
|
||||
break;
|
||||
case 'DECIMAL':
|
||||
row[colName] = rs.getDecimal(c);
|
||||
break;
|
||||
case 'REAL':
|
||||
case 'DOUBLE':
|
||||
case 'FLOAT':
|
||||
row[colName] = rs.getDouble(c);
|
||||
break;
|
||||
case 'NVARCHAR':
|
||||
case 'NCHAR':
|
||||
case 'SHORTTEXT':
|
||||
row[colName] = rs.getNString(c);
|
||||
break;
|
||||
case 'VARCHAR':
|
||||
case 'CHAR':
|
||||
row[colName] = rs.getString(c);
|
||||
break;
|
||||
case 'BINARY':
|
||||
case 'VARBINARY':
|
||||
row[colName] = rs.getBString(c);
|
||||
break;
|
||||
case 'DATE':
|
||||
row[colName] = rs.getDate(c);
|
||||
break;
|
||||
case 'TIME':
|
||||
row[colName] = rs.getTime(c);
|
||||
break;
|
||||
case 'TIMESTAMP':
|
||||
row[colName] = rs.getTimestamp(c);
|
||||
break;
|
||||
case 'CLOB':
|
||||
row[colName] = rs.getClob(c);
|
||||
break;
|
||||
case 'NCLOB':
|
||||
case 'TEXT':
|
||||
row[colName] = rs.getNClob(c);
|
||||
break;
|
||||
case 'BLOB':
|
||||
row[colName] = rs.getBlob(c);
|
||||
break;
|
||||
case 'SECONDDATE':
|
||||
row[colName] = rs.getSeconddate(c);
|
||||
break;
|
||||
}
|
||||
//row[colName] = colType;
|
||||
}
|
||||
row.pendingChanges = false;
|
||||
row.newEntry = false;
|
||||
subOperators.push(row);
|
||||
}
|
||||
|
||||
query = 'SELECT "Code", "LineId", "U_ORG_ID" FROM "A19753_EON_P01"."@EON_SUBOPERATOR_L" ORDER BY "Code", "U_ORG_ID"';
|
||||
pstmt = conn.prepareStatement(query);
|
||||
rs = pstmt.executeQuery();
|
||||
rsmd = rs.getMetaData();
|
||||
colCount = rsmd.getColumnCount();
|
||||
rc = 0;
|
||||
var organizations = [];
|
||||
while (rs.next()) {
|
||||
row = {};
|
||||
rc++;
|
||||
for (c = 1; c <= colCount; c++) {
|
||||
colName = rsmd.getColumnLabel(c);
|
||||
colType = rsmd.getColumnTypeName(c);
|
||||
switch (colType) {
|
||||
case 'TINYINT':
|
||||
case 'SMALLINT':
|
||||
case 'INT':
|
||||
case 'INTEGER':
|
||||
case 'BIGINT':
|
||||
row[colName] = rs.getInteger(c);
|
||||
break;
|
||||
case 'DECIMAL':
|
||||
row[colName] = rs.getDecimal(c);
|
||||
break;
|
||||
case 'REAL':
|
||||
case 'DOUBLE':
|
||||
case 'FLOAT':
|
||||
row[colName] = rs.getDouble(c);
|
||||
break;
|
||||
case 'NVARCHAR':
|
||||
case 'NCHAR':
|
||||
case 'SHORTTEXT':
|
||||
row[colName] = rs.getNString(c);
|
||||
break;
|
||||
case 'VARCHAR':
|
||||
case 'CHAR':
|
||||
row[colName] = rs.getString(c);
|
||||
break;
|
||||
case 'BINARY':
|
||||
case 'VARBINARY':
|
||||
row[colName] = rs.getBString(c);
|
||||
break;
|
||||
case 'DATE':
|
||||
row[colName] = rs.getDate(c);
|
||||
break;
|
||||
case 'TIME':
|
||||
row[colName] = rs.getTime(c);
|
||||
break;
|
||||
case 'TIMESTAMP':
|
||||
row[colName] = rs.getTimestamp(c);
|
||||
break;
|
||||
case 'CLOB':
|
||||
row[colName] = rs.getClob(c);
|
||||
break;
|
||||
case 'NCLOB':
|
||||
case 'TEXT':
|
||||
row[colName] = rs.getNClob(c);
|
||||
break;
|
||||
case 'BLOB':
|
||||
row[colName] = rs.getBlob(c);
|
||||
break;
|
||||
case 'SECONDDATE':
|
||||
row[colName] = rs.getSeconddate(c);
|
||||
break;
|
||||
}
|
||||
//row[colName] = colType;
|
||||
}
|
||||
row.guid = $.util.createUuid();
|
||||
row.highlight = 'None';
|
||||
row.highlightText = '';
|
||||
organizations.push(row);
|
||||
}
|
||||
|
||||
subOperators.forEach(function(subOp) {
|
||||
subOp.Organizations = organizations.filter(function(org) {return org.Code === subOp.Code;});
|
||||
});
|
||||
|
||||
rsMsg.SubOperators = subOperators;
|
||||
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
conn.close();
|
||||
outMessages.push(outMsg);
|
||||
} catch (ex) {
|
||||
exceptionHandler(ex);
|
||||
}
|
||||
|
||||
output.resultSet = rsMsg;
|
||||
}
|
||||
|
||||
// main
|
||||
var content = "";
|
||||
if ($.request.body) {
|
||||
content = $.request.body.asString();
|
||||
}
|
||||
if (checkParams() && checkAuthorization()) {
|
||||
getData();
|
||||
//setPhase($.request.parameters.get("billingrunid"), $.request.parameters.get("phase"));
|
||||
}
|
||||
|
||||
$.trace.debug("DEBUG: " + JSON.stringify(myDebug));
|
||||
setOutputMessage();
|
||||
@@ -0,0 +1,116 @@
|
||||
//var datetimelib = $.import("uniorg.libs", "datetime");
|
||||
//var logginglib = $.import("uniorg.libs", "uologging");
|
||||
//var billingEngine = $.import("uniorg.eon.emobility.billing.engine.v1", "BillingEngine");
|
||||
|
||||
var serviceName = "eon.emobility.provider.backend.keepAlive.xsjs";
|
||||
var serviceVersion = '1.0';
|
||||
|
||||
var output = {};
|
||||
var outMessages = [];
|
||||
var outMsg = {};
|
||||
var outStatus = "success";
|
||||
var myDebug = {};
|
||||
|
||||
var debugLevel = 0;
|
||||
switch ($.request.parameters.get("debug")) {
|
||||
case "true":
|
||||
case "yes":
|
||||
case "1":
|
||||
debugLevel = 1;
|
||||
break;
|
||||
case "full":
|
||||
case "2":
|
||||
debugLevel = 2;
|
||||
break;
|
||||
}
|
||||
|
||||
if (debugLevel > 0) {
|
||||
output.requestParams = $.request.parameters;
|
||||
}
|
||||
|
||||
function setOutputMessage() {
|
||||
output.status = outStatus;
|
||||
if (debugLevel > 0) {
|
||||
output.debugInfos = myDebug;
|
||||
}
|
||||
output.messages = outMessages;
|
||||
$.response.contentType = "application/json";
|
||||
$.response.setBody(JSON.stringify(output));
|
||||
//$.response.status = $.net.http.OK;
|
||||
}
|
||||
|
||||
function exceptionHandler(ex) {
|
||||
outMsg = {};
|
||||
outMsg.method = "exceptionHandler";
|
||||
outMsg.status = "error";
|
||||
outMsg.message = ex.toString();
|
||||
if (debugLevel > 0) {
|
||||
outMsg.exceptionInfo = {};
|
||||
outMsg.exceptionInfo.name = ex.name;
|
||||
outMsg.exceptionInfo.message = ex.message;
|
||||
outMsg.exceptionInfo.fileName = ex.fileName;
|
||||
outMsg.exceptionInfo.lineNumber = ex.lineNumber;
|
||||
outMsg.exceptionInfo.columnNumber = ex.columnNumber;
|
||||
outMsg.exceptionInfo.stack = ex.stack;
|
||||
//outMsg.exceptionInfo.source = ex.toSource();
|
||||
}
|
||||
outMessages.push(outMsg);
|
||||
outStatus = "error";
|
||||
output.status = outStatus;
|
||||
if (debugLevel > 0) {
|
||||
output.debugInfos = myDebug;
|
||||
}
|
||||
output.messages = outMessages;
|
||||
|
||||
var errbody = JSON.stringify(output);
|
||||
$.response.contentType = 'application/json';
|
||||
$.response.setBody(errbody);
|
||||
$.response.status = $.net.http.INTERNAL_SERVER_ERROR;
|
||||
}
|
||||
|
||||
function checkAuthorization() {
|
||||
var isAuthorized = true;
|
||||
try {
|
||||
$.session.assertAppPrivilege("uniorg.eon.emobility.provider::ViewProviderData");
|
||||
} catch (ex) {
|
||||
isAuthorized = false;
|
||||
outMsg = {};
|
||||
outMsg.method = "checkAuthorization";
|
||||
outMsg.status = "error";
|
||||
outStatus = "error";
|
||||
outMsg.message = "Privilege '" + ex.privilege + "' is missing";
|
||||
outMessages.push(outMsg);
|
||||
$.response.status = $.net.http.FORBIDDEN;
|
||||
}
|
||||
return isAuthorized;
|
||||
}
|
||||
|
||||
function dbRequest() {
|
||||
outMsg = {};
|
||||
outMsg.method = "databaseKeepAliveRequest";
|
||||
outMsg.status = "success";
|
||||
try {
|
||||
|
||||
var conn = $.db.getConnection();
|
||||
var pstmt;
|
||||
var query = "SELECT 'ok' as \"Alive\" FROM DUMMY";
|
||||
pstmt = conn.prepareStatement(query);
|
||||
var rs = pstmt.executeQuery();
|
||||
if (rs.next()) {
|
||||
outMsg.status = 'success';
|
||||
outStatus = 'success';
|
||||
}
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
conn.close();
|
||||
outMessages.push(outMsg);
|
||||
} catch (ex) {
|
||||
exceptionHandler(ex);
|
||||
}
|
||||
}
|
||||
|
||||
// main
|
||||
if (checkAuthorization()) {
|
||||
dbRequest();
|
||||
}
|
||||
setOutputMessage();
|
||||
@@ -0,0 +1,263 @@
|
||||
var datetimeLib = $.import("uniorg.libs", "datetime");
|
||||
//var logginglib = $.import("uniorg.libs", "uologging");
|
||||
//var billingEngine = $.import("uniorg.eon.emobility.billing.engine.v1", "BillingEngine");
|
||||
var destLib = $.import("uniorg.destinations", "uodestlib");
|
||||
var slLib = $.import("uniorg.ServiceLayer", "B1SLLogic");
|
||||
|
||||
var serviceName = "eon.emobility.provider.backend.setProviderData.xsjs";
|
||||
var serviceVersion = '1.0';
|
||||
|
||||
var output = {};
|
||||
var outMessages = [];
|
||||
var outMsg = {};
|
||||
var outStatus = "success";
|
||||
var myDebug = {};
|
||||
|
||||
var companyid = 0;
|
||||
var UserName = '';
|
||||
var UserPass = '';
|
||||
var UserComp = '';
|
||||
|
||||
var SESSIONID = "";
|
||||
var NODEID = "";
|
||||
var slLoggedIn = false;
|
||||
var schemaName = "A19753_EON_P01";
|
||||
|
||||
var debugLevel = 0;
|
||||
switch ($.request.parameters.get("debug")) {
|
||||
case "true":
|
||||
case "yes":
|
||||
case "1":
|
||||
debugLevel = 1;
|
||||
break;
|
||||
case "full":
|
||||
case "2":
|
||||
debugLevel = 2;
|
||||
break;
|
||||
}
|
||||
|
||||
if (debugLevel > 0) {
|
||||
output.requestParams = $.request.parameters;
|
||||
}
|
||||
|
||||
function setOutputMessage() {
|
||||
output.status = outStatus;
|
||||
if (debugLevel > 0) {
|
||||
output.debugInfos = myDebug;
|
||||
}
|
||||
output.messages = outMessages;
|
||||
$.response.contentType = "application/json";
|
||||
$.response.setBody(JSON.stringify(output));
|
||||
//$.response.status = $.net.http.OK;
|
||||
}
|
||||
|
||||
function exceptionHandler(ex) {
|
||||
if (outMsg.method && outMessages.indexOf(outMsg) === -1) {
|
||||
outMsg.status = "canceled";
|
||||
outMessages.push(outMsg);
|
||||
}
|
||||
outMsg = {};
|
||||
outMsg.method = "exceptionHandler";
|
||||
outMsg.status = "error";
|
||||
outMsg.message = ex.toString();
|
||||
if (debugLevel > 0) {
|
||||
outMsg.exceptionInfo = {};
|
||||
outMsg.exceptionInfo.name = ex.name;
|
||||
outMsg.exceptionInfo.message = ex.message;
|
||||
outMsg.exceptionInfo.fileName = ex.fileName;
|
||||
outMsg.exceptionInfo.lineNumber = ex.lineNumber;
|
||||
outMsg.exceptionInfo.columnNumber = ex.columnNumber;
|
||||
outMsg.exceptionInfo.stack = ex.stack;
|
||||
//outMsg.exceptionInfo.source = ex.toSource();
|
||||
}
|
||||
outMessages.push(outMsg);
|
||||
outStatus = "error";
|
||||
output.status = outStatus;
|
||||
if (debugLevel > 0) {
|
||||
output.debugInfos = myDebug;
|
||||
}
|
||||
output.messages = outMessages;
|
||||
|
||||
var errbody = JSON.stringify(output);
|
||||
$.response.contentType = 'application/json';
|
||||
$.response.setBody(errbody);
|
||||
$.response.status = $.net.http.INTERNAL_SERVER_ERROR;
|
||||
try {
|
||||
if (slLoggedIn) {
|
||||
slLib.SLLogout(SESSIONID, NODEID);
|
||||
}
|
||||
} catch (e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function checkAuthorization() {
|
||||
var isAuthorized = true;
|
||||
try {
|
||||
$.session.assertAppPrivilege("uniorg.eon.emobility.provider::MaintainProviderData");
|
||||
} catch (ex) {
|
||||
isAuthorized = false;
|
||||
outMsg = {};
|
||||
outMsg.method = "checkAuthorization";
|
||||
outMsg.status = "error";
|
||||
outStatus = "error";
|
||||
outMsg.message = "Privilege '" + ex.privilege + "' is missing";
|
||||
outMessages.push(outMsg);
|
||||
$.response.status = $.net.http.FORBIDDEN;
|
||||
}
|
||||
return isAuthorized;
|
||||
}
|
||||
|
||||
function checkPayload(inObj) {
|
||||
var isValid = true;
|
||||
try {
|
||||
var provider = JSON.parse(inObj);
|
||||
if (!provider.hasOwnProperty('Code') || !provider.hasOwnProperty('Name') || !provider.hasOwnProperty('U_ACTIVE') ||
|
||||
!provider.hasOwnProperty('U_ACTIVE_FROM') || !provider.hasOwnProperty('U_ACTIVE_TO')) {
|
||||
isValid = false;
|
||||
}
|
||||
} catch (e) {
|
||||
exceptionHandler(e);
|
||||
isValid = false;
|
||||
}
|
||||
if (!isValid) {
|
||||
outMsg = {};
|
||||
outMsg.method = "checkPayload";
|
||||
outMsg.status = "error";
|
||||
outStatus = "error";
|
||||
outMsg.message = "invalid payload content";
|
||||
outMessages.push(outMsg);
|
||||
$.response.status = $.net.http.BAD_REQUEST;
|
||||
}
|
||||
return isValid;
|
||||
}
|
||||
|
||||
function setConnectionParams() {
|
||||
var idValue = schemaName;
|
||||
var idFieldname = 'SYS_NAME';
|
||||
var CompanyConfig = destLib.getCompanyCfg(idValue, idFieldname);
|
||||
UserComp = CompanyConfig.COMPANYNAME;
|
||||
UserName = CompanyConfig.USERNAME;
|
||||
UserPass = destLib.readSecureStore(CompanyConfig.ID);
|
||||
if (debugLevel > 1) {
|
||||
myDebug.connectionParams = CompanyConfig;
|
||||
}
|
||||
myDebug.idValue = idValue;
|
||||
myDebug.idFieldname = idFieldname;
|
||||
if (CompanyConfig.COMPANYNAME === undefined) {
|
||||
outMsg = {};
|
||||
outMsg.method = "getCompany";
|
||||
outStatus = "error";
|
||||
outMsg.status = "error";
|
||||
outMsg.message = "System " + idValue + " is invalid for this endpoint";
|
||||
outMessages.push(outMsg);
|
||||
}
|
||||
|
||||
myDebug.CompanyName = UserComp;
|
||||
}
|
||||
|
||||
function slLogin() {
|
||||
var loginResult = false;
|
||||
var loginInfo = {};
|
||||
loginInfo.UserName = UserName;
|
||||
loginInfo.Password = UserPass;
|
||||
loginInfo.CompanyDB = UserComp;
|
||||
|
||||
// SL LOGIN
|
||||
var response = slLib.SLLogin(JSON.stringify(loginInfo), null, null);
|
||||
|
||||
// B1SESSION and ROUTEID cookies returned by Login
|
||||
for (var j in response.cookies) {
|
||||
if (response.cookies[j].name == "B1SESSION") {
|
||||
SESSIONID = response.cookies[j].value;
|
||||
//output.SessionID = SESSIONID;
|
||||
} else if (response.cookies[j].name == "ROUTEID") {
|
||||
NODEID = response.cookies[j].value;
|
||||
//output.NodeID = NODEID;
|
||||
}
|
||||
}
|
||||
|
||||
var loginResponse;
|
||||
try {
|
||||
loginResponse = JSON.parse(response.body.asString());
|
||||
} catch (e) {
|
||||
loginResponse = response.body.asString();
|
||||
}
|
||||
|
||||
if (debugLevel > 1) {
|
||||
myDebug.loginInfo = loginInfo;
|
||||
}
|
||||
myDebug.loginResponse = loginResponse;
|
||||
if (response.status === 200) {
|
||||
loginResult = true;
|
||||
} else {
|
||||
outMsg = {};
|
||||
outMsg.method = "login";
|
||||
outMsg.status = "error";
|
||||
var slError = myDebug.loginResponse.error;
|
||||
if (slError && slError.hasOwnProperty("code") && slError.message && slError.message.value) {
|
||||
outMsg.message = slError.message.value + " (Code: " + slError.code.toString() + ")";
|
||||
} else {
|
||||
outMsg.message = JSON.stringify(myDebug.loginResponse);
|
||||
}
|
||||
outMsg.response = myDebug.loginResponse;
|
||||
//outMsg.message = loginResponse;
|
||||
outMessages.push(outMsg);
|
||||
outStatus = "error";
|
||||
}
|
||||
return loginResult;
|
||||
}
|
||||
|
||||
function updateUDO(provider) {
|
||||
outMsg = {};
|
||||
outMsg.method = "updateUDO";
|
||||
outMsg.status = "error";
|
||||
try {
|
||||
var slProviderObj = {
|
||||
Name: provider.Name,
|
||||
U_ACTIVE: provider.U_ACTIVE,
|
||||
U_ACTIVE_FROM: datetimeLib.convertToISODate(provider.U_ACTIVE_FROM),
|
||||
U_ACTIVE_TO: datetimeLib.convertToISODate(provider.U_ACTIVE_TO)
|
||||
};
|
||||
myDebug.slProviderObj = slProviderObj;
|
||||
var responseProvider = slLib.patchDynamicEntity('EON_PROVIDER', provider.Code, JSON.stringify(slProviderObj), SESSIONID, NODEID, false);
|
||||
if (responseProvider.status >= 200 && responseProvider.status < 300) {
|
||||
outMsg.status = "success";
|
||||
} else {
|
||||
if (responseProvider.body) {
|
||||
var responseBodyParsed = JSON.parse(responseProvider.body.asString());
|
||||
var slError = responseBodyParsed.error;
|
||||
if (slError && slError.hasOwnProperty("code") && slError.message && slError.message.value) {
|
||||
outMsg.message = slError.message.value + " (Code: " + slError.code.toString() + ")";
|
||||
} else {
|
||||
outMsg.message = responseProvider.body.asString();
|
||||
}
|
||||
outMsg.response = responseBodyParsed;
|
||||
} else {
|
||||
outMsg.message = JSON.stringify(responseProvider);
|
||||
}
|
||||
outStatus = "error";
|
||||
}
|
||||
outMessages.push(outMsg);
|
||||
} catch (ex) {
|
||||
exceptionHandler(ex);
|
||||
}
|
||||
}
|
||||
|
||||
// main
|
||||
var content = "";
|
||||
if ($.request.body) {
|
||||
content = $.request.body.asString();
|
||||
}
|
||||
if (checkPayload(content) && checkAuthorization()) {
|
||||
setConnectionParams();
|
||||
slLoggedIn = slLogin();
|
||||
if (slLoggedIn) {
|
||||
var inObj = JSON.parse(content);
|
||||
updateUDO(inObj);
|
||||
slLib.SLLogout(SESSIONID, NODEID);
|
||||
}
|
||||
}
|
||||
|
||||
$.trace.debug("DEBUG: " + JSON.stringify(myDebug));
|
||||
setOutputMessage();
|
||||
@@ -0,0 +1,493 @@
|
||||
var datetimeLib = $.import("uniorg.libs", "datetime");
|
||||
//var logginglib = $.import("uniorg.libs", "uologging");
|
||||
//var billingEngine = $.import("uniorg.eon.emobility.billing.engine.v1", "BillingEngine");
|
||||
var destLib = $.import("uniorg.destinations", "uodestlib");
|
||||
var slLib = $.import("uniorg.ServiceLayer", "B1SLLogic");
|
||||
|
||||
var serviceName = "eon.emobility.provider.backend.setProviderLinesData.xsjs";
|
||||
var serviceVersion = '1.2';
|
||||
|
||||
var output = {};
|
||||
var outMessages = [];
|
||||
var outMsg = {};
|
||||
var outStatus = "success";
|
||||
var myDebug = {};
|
||||
|
||||
var companyid = 0;
|
||||
var UserName = '';
|
||||
var UserPass = '';
|
||||
var UserComp = '';
|
||||
|
||||
var SESSIONID = "";
|
||||
var NODEID = "";
|
||||
var slLoggedIn = false;
|
||||
var schemaName = "A19753_EON_P01";
|
||||
|
||||
var debugLevel = 0;
|
||||
switch ($.request.parameters.get("debug")) {
|
||||
case "true":
|
||||
case "yes":
|
||||
case "1":
|
||||
debugLevel = 1;
|
||||
break;
|
||||
case "full":
|
||||
case "2":
|
||||
debugLevel = 2;
|
||||
break;
|
||||
}
|
||||
|
||||
if (debugLevel > 0) {
|
||||
output.requestParams = $.request.parameters;
|
||||
}
|
||||
|
||||
function setOutputMessage() {
|
||||
output.status = outStatus;
|
||||
if (debugLevel > 0) {
|
||||
output.debugInfos = myDebug;
|
||||
}
|
||||
output.messages = outMessages;
|
||||
$.response.contentType = "application/json";
|
||||
$.response.setBody(JSON.stringify(output));
|
||||
//$.response.status = $.net.http.OK;
|
||||
}
|
||||
|
||||
function exceptionHandler(ex) {
|
||||
if (outMsg.method && outMessages.indexOf(outMsg) === -1) {
|
||||
outMsg.status = "canceled";
|
||||
outMessages.push(outMsg);
|
||||
}
|
||||
outMsg = {};
|
||||
outMsg.method = "exceptionHandler";
|
||||
outMsg.status = "error";
|
||||
outMsg.message = ex.toString();
|
||||
if (debugLevel > 0) {
|
||||
outMsg.exceptionInfo = {};
|
||||
outMsg.exceptionInfo.name = ex.name;
|
||||
outMsg.exceptionInfo.message = ex.message;
|
||||
outMsg.exceptionInfo.fileName = ex.fileName;
|
||||
outMsg.exceptionInfo.lineNumber = ex.lineNumber;
|
||||
outMsg.exceptionInfo.columnNumber = ex.columnNumber;
|
||||
outMsg.exceptionInfo.stack = ex.stack;
|
||||
//outMsg.exceptionInfo.source = ex.toSource();
|
||||
}
|
||||
outMessages.push(outMsg);
|
||||
outStatus = "error";
|
||||
output.status = outStatus;
|
||||
if (debugLevel > 0) {
|
||||
output.debugInfos = myDebug;
|
||||
}
|
||||
output.messages = outMessages;
|
||||
|
||||
var errbody = JSON.stringify(output);
|
||||
$.response.contentType = 'application/json';
|
||||
$.response.setBody(errbody);
|
||||
$.response.status = $.net.http.INTERNAL_SERVER_ERROR;
|
||||
try {
|
||||
if (slLoggedIn) {
|
||||
slLib.SLLogout(SESSIONID, NODEID);
|
||||
}
|
||||
} catch (e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function checkAuthorization() {
|
||||
var isAuthorized = true;
|
||||
try {
|
||||
$.session.assertAppPrivilege("uniorg.eon.emobility.provider::MaintainProviderData");
|
||||
} catch (ex) {
|
||||
isAuthorized = false;
|
||||
outMsg = {};
|
||||
outMsg.method = "checkAuthorization";
|
||||
outMsg.status = "error";
|
||||
outStatus = "error";
|
||||
outMsg.message = "Privilege '" + ex.privilege + "' is missing";
|
||||
outMessages.push(outMsg);
|
||||
$.response.status = $.net.http.FORBIDDEN;
|
||||
}
|
||||
return isAuthorized;
|
||||
}
|
||||
|
||||
function checkPayload(inObj) {
|
||||
var isValid = true;
|
||||
var errorList = [];
|
||||
try {
|
||||
var provider = JSON.parse(inObj);
|
||||
if (!provider.hasOwnProperty('Code')) {
|
||||
isValid = false;
|
||||
}
|
||||
if (Array.isArray(provider.Lines)) {
|
||||
provider.Lines.forEach(function(l) {
|
||||
if (!l.hasOwnProperty('U_CODE') || !l.hasOwnProperty('U_FROM') || !l.hasOwnProperty('U_TO') ||
|
||||
!l.hasOwnProperty('U_TYP') || !l.hasOwnProperty('U_OPERATOR') || !l.hasOwnProperty('U_SUBOPERATOR') || !l.hasOwnProperty('U_RELEASED')) {
|
||||
isValid = false;
|
||||
} else {
|
||||
var errorDetails = {
|
||||
U_CODE: l.U_CODE,
|
||||
U_FROM: l.U_FROM,
|
||||
U_TO: l.U_TO,
|
||||
U_TYP: l.U_TYP,
|
||||
U_OPERATOR: l.U_OPERATOR,
|
||||
U_SUBOPERATOR: l.U_SUBOPERATOR,
|
||||
U_RELEASED: l.U_RELEASED,
|
||||
Status: 'error'
|
||||
};
|
||||
/*if (debugLevel > 0) {
|
||||
errorDetails.Price = npl.Price;
|
||||
errorDetails.Currency = npl.Currency;
|
||||
}
|
||||
if (typeof npl.MaterialNo !== 'string' || !npl.MaterialNo) {
|
||||
errorDetails.StatusText = "MaterialNo is not valid";
|
||||
} else {
|
||||
if (!npl.MaterialNo.length > 0) {
|
||||
errorDetails.StatusText = "MaterialNo is empty";
|
||||
}
|
||||
if (npl.MaterialNo.length > 18) {
|
||||
errorDetails.StatusText = "MaterialNo too long";
|
||||
}
|
||||
}
|
||||
if (typeof npl.PriceList !== 'string' || !npl.PriceList) {
|
||||
errorDetails.StatusText = "PriceList is not valid";
|
||||
} else {
|
||||
if (!npl.PriceList.length > 0) {
|
||||
errorDetails.StatusText = "PriceList is empty";
|
||||
}
|
||||
if (npl.PriceList.length > 32) {
|
||||
errorDetails.StatusText = "PriceList too long";
|
||||
}
|
||||
}
|
||||
try {
|
||||
var parsedDate = npl.DateFrom.startsWith('/Date(') ? new Date(parseInt(npl.DateFrom.substr(6))) : new Date(npl.DateFrom);
|
||||
if (debugLevel > 0) {
|
||||
errorDetails.ParsedDate = parsedDate;
|
||||
}
|
||||
if (!parsedDate instanceof Date || isNaN(parsedDate.valueOf())) {
|
||||
errorDetails.StatusText = "DateFrom is not a valid date";
|
||||
} else if (!(parsedDate.getTime() >= new Date('2000-01-01').getTime() && parsedDate.getTime() <= new Date('9999-12-31').getTime())) {
|
||||
errorDetails.StatusText = "DateFrom is outside of valid range";
|
||||
}
|
||||
} catch (e) {
|
||||
errorDetails.StatusText = "DateFrom is not a valid date";
|
||||
}
|
||||
if (typeof npl.Price !== 'number' || isNaN(npl.Price)) {
|
||||
errorDetails.StatusText = "Price is not valid";
|
||||
} else {
|
||||
var priceParts = npl.Price.toString().split('.');
|
||||
var priceExp = npl.Price.toString().split('e');
|
||||
if (debugLevel > 0) {
|
||||
errorDetails.PriceDecimalParts = priceParts;
|
||||
}
|
||||
if (npl.Price < 0) {
|
||||
errorDetails.StatusText = "Price must be a positive value";
|
||||
} else if (priceExp.length > 1 && !isNaN(priceExp[1]) && parseInt(priceExp[1]) + priceParts[0].length > 17) {
|
||||
errorDetails.StatusText = "Price decimal precision too high";
|
||||
} else if ((priceParts.length > 1 && priceParts[0].length + priceParts[1].length > 17) || priceParts[0].length > 17) {
|
||||
errorDetails.StatusText = "Price decimal precision too high";
|
||||
} else if (priceParts.length > 1 && priceParts[1].length > 6) {
|
||||
errorDetails.StatusText = "Price decimal scale too high";
|
||||
}
|
||||
}
|
||||
if (typeof npl.Currency !== 'string' || !npl.Currency) {
|
||||
errorDetails.StatusText = "Currency is not valid";
|
||||
} else {
|
||||
if (!npl.Currency.length > 0) {
|
||||
errorDetails.StatusText = "Currency is empty";
|
||||
}
|
||||
if (npl.Currency.length > 3) {
|
||||
errorDetails.StatusText = "Currency too long";
|
||||
}
|
||||
}*/
|
||||
if (errorDetails.StatusText) {
|
||||
errorList.push(errorDetails);
|
||||
isValid = false;
|
||||
} else if (debugLevel > 0) {
|
||||
errorDetails.Status = "success";
|
||||
errorList.push(errorDetails);
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
isValid = false;
|
||||
}
|
||||
} catch (e) {
|
||||
exceptionHandler(e);
|
||||
isValid = false;
|
||||
}
|
||||
if (!isValid) {
|
||||
outMsg = {};
|
||||
outMsg.method = "checkPayload";
|
||||
outMsg.status = "error";
|
||||
outStatus = "error";
|
||||
if (errorList.length > 0) {
|
||||
outMsg.message = "invalid payload content";
|
||||
output.results = errorList;
|
||||
} else {
|
||||
outMsg.message = "invalid payload structure";
|
||||
}
|
||||
outMessages.push(outMsg);
|
||||
$.response.status = $.net.http.BAD_REQUEST;
|
||||
}
|
||||
return isValid;
|
||||
}
|
||||
|
||||
function setConnectionParams() {
|
||||
var idValue = schemaName;
|
||||
var idFieldname = 'SYS_NAME';
|
||||
var CompanyConfig = destLib.getCompanyCfg(idValue, idFieldname);
|
||||
UserComp = CompanyConfig.COMPANYNAME;
|
||||
UserName = CompanyConfig.USERNAME;
|
||||
UserPass = destLib.readSecureStore(CompanyConfig.ID);
|
||||
if (debugLevel > 1) {
|
||||
myDebug.connectionParams = CompanyConfig;
|
||||
}
|
||||
myDebug.idValue = idValue;
|
||||
myDebug.idFieldname = idFieldname;
|
||||
if (CompanyConfig.COMPANYNAME === undefined) {
|
||||
outMsg = {};
|
||||
outMsg.method = "getCompany";
|
||||
outStatus = "error";
|
||||
outMsg.status = "error";
|
||||
outMsg.message = "System " + idValue + " is invalid for this endpoint";
|
||||
outMessages.push(outMsg);
|
||||
}
|
||||
|
||||
myDebug.CompanyName = UserComp;
|
||||
}
|
||||
|
||||
function slLogin() {
|
||||
var loginResult = false;
|
||||
var loginInfo = {};
|
||||
loginInfo.UserName = UserName;
|
||||
loginInfo.Password = UserPass;
|
||||
loginInfo.CompanyDB = UserComp;
|
||||
|
||||
// SL LOGIN
|
||||
var response = slLib.SLLogin(JSON.stringify(loginInfo), null, null);
|
||||
|
||||
// B1SESSION and ROUTEID cookies returned by Login
|
||||
for (var j in response.cookies) {
|
||||
if (response.cookies[j].name == "B1SESSION") {
|
||||
SESSIONID = response.cookies[j].value;
|
||||
//output.SessionID = SESSIONID;
|
||||
} else if (response.cookies[j].name == "ROUTEID") {
|
||||
NODEID = response.cookies[j].value;
|
||||
//output.NodeID = NODEID;
|
||||
}
|
||||
}
|
||||
|
||||
var loginResponse;
|
||||
try {
|
||||
loginResponse = JSON.parse(response.body.asString());
|
||||
} catch (e) {
|
||||
loginResponse = response.body.asString();
|
||||
}
|
||||
|
||||
if (debugLevel > 1) {
|
||||
myDebug.loginInfo = loginInfo;
|
||||
}
|
||||
myDebug.loginResponse = loginResponse;
|
||||
if (response.status === 200) {
|
||||
loginResult = true;
|
||||
} else {
|
||||
outMsg = {};
|
||||
outMsg.method = "login";
|
||||
outMsg.status = "error";
|
||||
var slError = myDebug.loginResponse.error;
|
||||
if (slError && slError.hasOwnProperty("code") && slError.message && slError.message.value) {
|
||||
outMsg.message = slError.message.value + " (Code: " + slError.code.toString() + ")";
|
||||
} else {
|
||||
outMsg.message = JSON.stringify(myDebug.loginResponse);
|
||||
}
|
||||
outMsg.response = myDebug.loginResponse;
|
||||
//outMsg.message = loginResponse;
|
||||
outMessages.push(outMsg);
|
||||
outStatus = "error";
|
||||
}
|
||||
return loginResult;
|
||||
}
|
||||
|
||||
function updateUDO(provider, oldUDO) {
|
||||
outMsg = {};
|
||||
outMsg.method = "updateUDO";
|
||||
outMsg.status = "error";
|
||||
try {
|
||||
var slProviderObj = {
|
||||
U_ACTIVE: provider.U_ACTIVE,
|
||||
U_ACTIVE_FROM: datetimeLib.convertToISODate(provider.U_ACTIVE_FROM),
|
||||
U_ACTIVE_TO: datetimeLib.convertToISODate(provider.U_ACTIVE_TO),
|
||||
EON_PROVIDER_LINESCollection: oldUDO.EON_PROVIDER_LINESCollection.map(function(ol) {
|
||||
var line = {
|
||||
Code: ol.Code,
|
||||
LineId: ol.LineId,
|
||||
Object: ol.Object
|
||||
};
|
||||
var changedLine = false;
|
||||
var nl = provider.Lines.find(function(l) {
|
||||
return l.Code === ol.Code && l.LineId === ol.LineId;
|
||||
});
|
||||
if (typeof nl !== "undefined") {
|
||||
if (nl.U_RELEASED !== ol.U_RELEASED) {
|
||||
//changedLine = true;
|
||||
line.U_RELEASED = nl.U_RELEASED;
|
||||
if (nl.U_RELEASED === 'Y') {
|
||||
line.U_RELEASE_DATE = datetimeLib.convertToISODate(new Date());
|
||||
line.U_RELEASE_USER = $.session.getUsername();
|
||||
}
|
||||
}
|
||||
if (datetimeLib.convertToISODate(nl.U_TO) !== ol.U_TO) {
|
||||
changedLine = true;
|
||||
line.U_TO = datetimeLib.convertToISODate(nl.U_TO);
|
||||
}
|
||||
if (nl.U_SUBOPERATOR !== ol.U_SUBOPERATOR) {
|
||||
changedLine = true;
|
||||
line.U_SUBOPERATOR = nl.U_SUBOPERATOR;
|
||||
}
|
||||
if (nl.U_VALUE !== ol.U_VALUE) {
|
||||
changedLine = true;
|
||||
line.U_VALUE = nl.U_VALUE;
|
||||
}
|
||||
if (nl.U_CURRENCY !== ol.U_CURRENCY) {
|
||||
changedLine = true;
|
||||
line.U_CURRENCY = nl.U_CURRENCY;
|
||||
}
|
||||
if (ol.U_CODE === 'MINUTES_BLOCK') {
|
||||
if (nl.U_BLOCK_FROM !== ol.U_BLOCK_FROM.substring(0,5)) {
|
||||
changedLine = true;
|
||||
line.U_BLOCK_FROM = nl.U_BLOCK_FROM;
|
||||
}
|
||||
if (nl.U_BLOCK_TO !== ol.U_BLOCK_TO.substring(0,5)) {
|
||||
changedLine = true;
|
||||
line.U_BLOCK_TO = nl.U_BLOCK_TO;
|
||||
}
|
||||
if (nl.U_BLOCKMAX !== ol.U_BLOCKMAX) {
|
||||
changedLine = true;
|
||||
line.U_BLOCKMAX = nl.U_BLOCKMAX;
|
||||
}
|
||||
}
|
||||
if (changedLine) {
|
||||
line.U_CHANGE_DATE = datetimeLib.convertToISODate(new Date());
|
||||
line.U_CHANGE_USER = $.session.getUsername();
|
||||
}
|
||||
}
|
||||
return line;
|
||||
/*{
|
||||
Code: l.Code,
|
||||
LineId: l.LineId,
|
||||
U_CODE: l.U_CODE,
|
||||
U_FROM: datetimeLib.convertToISODate(l.U_FROM),
|
||||
U_TO: datetimeLib.convertToISODate(l.U_TO),
|
||||
U_OPERATOR: l.U_OPERATOR,
|
||||
U_TYP: l.U_TYP,
|
||||
U_VALUE: l.U_VALUE,
|
||||
U_BLOCK_FROM: l.U_BLOCK_FROM,
|
||||
U_BLOCK_TO: l.U_BLOCK_TO,
|
||||
U_BLOCKMAX: l.U_BLOCKMAX,
|
||||
U_RELEASED: l.U_RELEASED,
|
||||
U_RELEASE_DATE: l.U_RELEASED === 'Y' ? datetimeLib.convertToISODate(new Date()) : l.U_RELEASE_DATE,
|
||||
U_RELEASE_USER: l.U_RELEASED === 'Y' ? $.session.getUsername() : l.U_RELEASED,
|
||||
U_CHANGE_DATE: datetimeLib.convertToISODate(new Date())
|
||||
};*/
|
||||
}).concat(provider.Lines.filter(function(l) {
|
||||
return l.new === true;
|
||||
}).map(function(nl) {return {
|
||||
U_CODE: nl.U_CODE,
|
||||
U_FROM: datetimeLib.convertToISODate(nl.U_FROM),
|
||||
U_TO: datetimeLib.convertToISODate(nl.U_TO),
|
||||
U_OPERATOR: nl.U_OPERATOR,
|
||||
U_SUBOPERATOR: nl.U_SUBOPERATOR,
|
||||
U_TYP: nl.U_TYP,
|
||||
U_CURRENCY: nl.U_CURRENCY,
|
||||
U_VALUE: nl.U_VALUE,
|
||||
U_BLOCK_FROM: nl.U_BLOCK_FROM,
|
||||
U_BLOCK_TO: nl.U_BLOCK_TO,
|
||||
U_BLOCKMAX: nl.U_BLOCKMAX,
|
||||
U_RELEASED: nl.U_RELEASED,
|
||||
U_RELEASE_DATE: nl.U_RELEASED === 'Y' ? datetimeLib.convertToISODate(new Date()) : nl.U_RELEASE_DATE,
|
||||
U_RELEASE_USER: nl.U_RELEASED === 'Y' ? $.session.getUsername() : nl.U_RELEASE_USER,
|
||||
U_CHANGE_DATE: datetimeLib.convertToISODate(new Date()),
|
||||
U_CHANGE_USER: $.session.getUsername()
|
||||
};}))
|
||||
};
|
||||
myDebug.slProviderObj = slProviderObj;
|
||||
var responseProvider = slLib.patchDynamicEntity('EON_PROVIDER', provider.Code, JSON.stringify(slProviderObj), SESSIONID, NODEID, true);
|
||||
if (responseProvider.status >= 200 && responseProvider.status < 300) {
|
||||
outMsg.status = "success";
|
||||
} else {
|
||||
if (responseProvider.body) {
|
||||
var responseBodyParsed = JSON.parse(responseProvider.body.asString());
|
||||
var slError = responseBodyParsed.error;
|
||||
if (slError && slError.hasOwnProperty("code") && slError.message && slError.message.value) {
|
||||
outMsg.message = slError.message.value + " (Code: " + slError.code.toString() + ")";
|
||||
} else {
|
||||
outMsg.message = responseProvider.body.asString();
|
||||
}
|
||||
outMsg.response = responseBodyParsed;
|
||||
} else {
|
||||
outMsg.message = JSON.stringify(responseProvider);
|
||||
}
|
||||
outStatus = "error";
|
||||
}
|
||||
outMessages.push(outMsg);
|
||||
} catch (ex) {
|
||||
exceptionHandler(ex);
|
||||
}
|
||||
}
|
||||
|
||||
function getUDO(Code) {
|
||||
outMsg = {};
|
||||
outMsg.method = "getUDO";
|
||||
outMsg.code = Code;
|
||||
outMsg.status = "error";
|
||||
var result = {};
|
||||
try {
|
||||
var responseGet = slLib.getDynamicEntity('EON_PROVIDER', Code, SESSIONID, NODEID);
|
||||
outMsg.statuscode = responseGet.status;
|
||||
if (responseGet.status >= 200 && responseGet.status < 300) {
|
||||
var bodyGet = JSON.parse(responseGet.body.asString());
|
||||
outMsg.status = "success";
|
||||
result = bodyGet;
|
||||
outMsg.response = bodyGet;
|
||||
} else {
|
||||
if (responseGet.body) {
|
||||
var responseBodyParsed = JSON.parse(responseGet.body.asString());
|
||||
var slError = responseBodyParsed.error;
|
||||
if (slError && slError.hasOwnProperty("code") && slError.message && slError.message.value) {
|
||||
outMsg.message = slError.message.value + " (Code: " + slError.code.toString() + ")";
|
||||
} else {
|
||||
outMsg.message = responseGet.body.asString();
|
||||
}
|
||||
outMsg.response = responseBodyParsed;
|
||||
} else {
|
||||
outMsg.message = JSON.stringify(responseGet);
|
||||
}
|
||||
outStatus = "error";
|
||||
}
|
||||
if (debugLevel > 0 || outMsg.status !== "success") {
|
||||
outMessages.push(outMsg);
|
||||
}
|
||||
} catch (ex) {
|
||||
exceptionHandler(ex);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// main
|
||||
var content = "";
|
||||
if ($.request.body) {
|
||||
content = $.request.body.asString();
|
||||
}
|
||||
if (checkPayload(content) && checkAuthorization()) {
|
||||
setConnectionParams();
|
||||
slLoggedIn = slLogin();
|
||||
if (slLoggedIn) {
|
||||
var inObj = JSON.parse(content);
|
||||
var oldUDO = getUDO(inObj.Code);
|
||||
if (outStatus !== "error" && oldUDO.Code) {
|
||||
updateUDO(inObj, oldUDO);
|
||||
}
|
||||
slLib.SLLogout(SESSIONID, NODEID);
|
||||
}
|
||||
}
|
||||
|
||||
$.trace.debug("DEBUG: " + JSON.stringify(myDebug));
|
||||
setOutputMessage();
|
||||
@@ -0,0 +1,333 @@
|
||||
var datetimeLib = $.import("uniorg.libs", "datetime");
|
||||
//var logginglib = $.import("uniorg.libs", "uologging");
|
||||
//var billingEngine = $.import("uniorg.eon.emobility.billing.engine.v1", "BillingEngine");
|
||||
var destLib = $.import("uniorg.destinations", "uodestlib");
|
||||
var slLib = $.import("uniorg.ServiceLayer", "B1SLLogic");
|
||||
|
||||
var serviceName = "eon.emobility.provider.backend.setSubOperatorData.xsjs";
|
||||
var serviceVersion = '1.0';
|
||||
|
||||
var output = {};
|
||||
var outMessages = [];
|
||||
var outMsg = {};
|
||||
var outStatus = "success";
|
||||
var myDebug = {};
|
||||
|
||||
var companyid = 0;
|
||||
var UserName = '';
|
||||
var UserPass = '';
|
||||
var UserComp = '';
|
||||
|
||||
var SESSIONID = "";
|
||||
var NODEID = "";
|
||||
var slLoggedIn = false;
|
||||
var schemaName = "A19753_EON_P01";
|
||||
|
||||
var debugLevel = 0;
|
||||
switch ($.request.parameters.get("debug")) {
|
||||
case "true":
|
||||
case "yes":
|
||||
case "1":
|
||||
debugLevel = 1;
|
||||
break;
|
||||
case "full":
|
||||
case "2":
|
||||
debugLevel = 2;
|
||||
break;
|
||||
}
|
||||
|
||||
if (debugLevel > 0) {
|
||||
output.requestParams = $.request.parameters;
|
||||
}
|
||||
|
||||
function setOutputMessage() {
|
||||
output.status = outStatus;
|
||||
if (debugLevel > 0) {
|
||||
output.debugInfos = myDebug;
|
||||
}
|
||||
output.messages = outMessages;
|
||||
$.response.contentType = "application/json";
|
||||
$.response.setBody(JSON.stringify(output));
|
||||
//$.response.status = $.net.http.OK;
|
||||
}
|
||||
|
||||
function exceptionHandler(ex) {
|
||||
if (outMsg.method && outMessages.indexOf(outMsg) === -1) {
|
||||
outMsg.status = "canceled";
|
||||
outMessages.push(outMsg);
|
||||
}
|
||||
outMsg = {};
|
||||
outMsg.method = "exceptionHandler";
|
||||
outMsg.status = "error";
|
||||
outMsg.message = ex.toString();
|
||||
if (debugLevel > 0) {
|
||||
outMsg.exceptionInfo = {};
|
||||
outMsg.exceptionInfo.name = ex.name;
|
||||
outMsg.exceptionInfo.message = ex.message;
|
||||
outMsg.exceptionInfo.fileName = ex.fileName;
|
||||
outMsg.exceptionInfo.lineNumber = ex.lineNumber;
|
||||
outMsg.exceptionInfo.columnNumber = ex.columnNumber;
|
||||
outMsg.exceptionInfo.stack = ex.stack;
|
||||
//outMsg.exceptionInfo.source = ex.toSource();
|
||||
}
|
||||
outMessages.push(outMsg);
|
||||
outStatus = "error";
|
||||
output.status = outStatus;
|
||||
if (debugLevel > 0) {
|
||||
output.debugInfos = myDebug;
|
||||
}
|
||||
output.messages = outMessages;
|
||||
|
||||
var errbody = JSON.stringify(output);
|
||||
$.response.contentType = 'application/json';
|
||||
$.response.setBody(errbody);
|
||||
$.response.status = $.net.http.INTERNAL_SERVER_ERROR;
|
||||
try {
|
||||
if (slLoggedIn) {
|
||||
slLib.SLLogout(SESSIONID, NODEID);
|
||||
}
|
||||
} catch (e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function checkAuthorization() {
|
||||
var isAuthorized = true;
|
||||
try {
|
||||
$.session.assertAppPrivilege("uniorg.eon.emobility.provider::MaintainProviderData");
|
||||
} catch (ex) {
|
||||
isAuthorized = false;
|
||||
outMsg = {};
|
||||
outMsg.method = "checkAuthorization";
|
||||
outMsg.status = "error";
|
||||
outStatus = "error";
|
||||
outMsg.message = "Privilege '" + ex.privilege + "' is missing";
|
||||
outMessages.push(outMsg);
|
||||
$.response.status = $.net.http.FORBIDDEN;
|
||||
}
|
||||
return isAuthorized;
|
||||
}
|
||||
|
||||
function checkPayload(inObj) {
|
||||
var isValid = true;
|
||||
var errorList = [];
|
||||
try {
|
||||
var subOperator = JSON.parse(inObj);
|
||||
if (!subOperator.hasOwnProperty('Code')) {
|
||||
isValid = false;
|
||||
}
|
||||
if (Array.isArray(subOperator.Organizations)) {
|
||||
subOperator.Organizations.forEach(function(org) {
|
||||
if (!org.hasOwnProperty('U_ORG_ID')) {
|
||||
isValid = false;
|
||||
} else {
|
||||
var errorDetails = {
|
||||
U_ORG_ID: org.U_ORG_ID,
|
||||
Status: 'error'
|
||||
};
|
||||
if (errorDetails.StatusText) {
|
||||
errorList.push(errorDetails);
|
||||
isValid = false;
|
||||
} else if (debugLevel > 0) {
|
||||
errorDetails.Status = "success";
|
||||
errorList.push(errorDetails);
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
isValid = false;
|
||||
}
|
||||
} catch (e) {
|
||||
exceptionHandler(e);
|
||||
isValid = false;
|
||||
}
|
||||
if (!isValid) {
|
||||
outMsg = {};
|
||||
outMsg.method = "checkPayload";
|
||||
outMsg.status = "error";
|
||||
outStatus = "error";
|
||||
if (errorList.length > 0) {
|
||||
outMsg.message = "invalid payload content";
|
||||
output.results = errorList;
|
||||
} else {
|
||||
outMsg.message = "invalid payload structure";
|
||||
}
|
||||
outMessages.push(outMsg);
|
||||
$.response.status = $.net.http.BAD_REQUEST;
|
||||
}
|
||||
return isValid;
|
||||
}
|
||||
|
||||
function setConnectionParams() {
|
||||
var idValue = schemaName;
|
||||
var idFieldname = 'SYS_NAME';
|
||||
var CompanyConfig = destLib.getCompanyCfg(idValue, idFieldname);
|
||||
UserComp = CompanyConfig.COMPANYNAME;
|
||||
UserName = CompanyConfig.USERNAME;
|
||||
UserPass = destLib.readSecureStore(CompanyConfig.ID);
|
||||
if (debugLevel > 1) {
|
||||
myDebug.connectionParams = CompanyConfig;
|
||||
}
|
||||
myDebug.idValue = idValue;
|
||||
myDebug.idFieldname = idFieldname;
|
||||
if (CompanyConfig.COMPANYNAME === undefined) {
|
||||
outMsg = {};
|
||||
outMsg.method = "getCompany";
|
||||
outStatus = "error";
|
||||
outMsg.status = "error";
|
||||
outMsg.message = "System " + idValue + " is invalid for this endpoint";
|
||||
outMessages.push(outMsg);
|
||||
}
|
||||
|
||||
myDebug.CompanyName = UserComp;
|
||||
}
|
||||
|
||||
function slLogin() {
|
||||
var loginResult = false;
|
||||
var loginInfo = {};
|
||||
loginInfo.UserName = UserName;
|
||||
loginInfo.Password = UserPass;
|
||||
loginInfo.CompanyDB = UserComp;
|
||||
|
||||
// SL LOGIN
|
||||
var response = slLib.SLLogin(JSON.stringify(loginInfo), null, null);
|
||||
|
||||
// B1SESSION and ROUTEID cookies returned by Login
|
||||
for (var j in response.cookies) {
|
||||
if (response.cookies[j].name == "B1SESSION") {
|
||||
SESSIONID = response.cookies[j].value;
|
||||
//output.SessionID = SESSIONID;
|
||||
} else if (response.cookies[j].name == "ROUTEID") {
|
||||
NODEID = response.cookies[j].value;
|
||||
//output.NodeID = NODEID;
|
||||
}
|
||||
}
|
||||
|
||||
var loginResponse;
|
||||
try {
|
||||
loginResponse = JSON.parse(response.body.asString());
|
||||
} catch (e) {
|
||||
loginResponse = response.body.asString();
|
||||
}
|
||||
|
||||
if (debugLevel > 1) {
|
||||
myDebug.loginInfo = loginInfo;
|
||||
}
|
||||
myDebug.loginResponse = loginResponse;
|
||||
if (response.status === 200) {
|
||||
loginResult = true;
|
||||
} else {
|
||||
outMsg = {};
|
||||
outMsg.method = "login";
|
||||
outMsg.status = "error";
|
||||
var slError = myDebug.loginResponse.error;
|
||||
if (slError && slError.hasOwnProperty("code") && slError.message && slError.message.value) {
|
||||
outMsg.message = slError.message.value + " (Code: " + slError.code.toString() + ")";
|
||||
} else {
|
||||
outMsg.message = JSON.stringify(myDebug.loginResponse);
|
||||
}
|
||||
outMsg.response = myDebug.loginResponse;
|
||||
//outMsg.message = loginResponse;
|
||||
outMessages.push(outMsg);
|
||||
outStatus = "error";
|
||||
}
|
||||
return loginResult;
|
||||
}
|
||||
|
||||
function updateUDO(subOperator) {
|
||||
outMsg = {};
|
||||
outMsg.method = "updateUDO";
|
||||
outMsg.status = "error";
|
||||
try {
|
||||
var slSubOperatorObj = {
|
||||
Code: subOperator.Code,
|
||||
Name: subOperator.Name,
|
||||
EON_SUBOPERATOR_LCollection: subOperator.Organizations.map(function(org) {return {
|
||||
Code: subOperator.Code,
|
||||
LineId: org.LineId,
|
||||
Object: 'EON_SUBOPERATOR',
|
||||
U_ORG_ID: org.U_ORG_ID
|
||||
};})
|
||||
};
|
||||
myDebug.slSubOperatorObj = slSubOperatorObj;
|
||||
var responseSubOperator = subOperator.newEntry ? slLib.postDynamicEntity('EON_SUBOPERATOR', JSON.stringify(slSubOperatorObj), SESSIONID, NODEID) : slLib.patchDynamicEntity('EON_SUBOPERATOR', subOperator.Code, JSON.stringify(slSubOperatorObj), SESSIONID, NODEID, true);
|
||||
if (responseSubOperator.status >= 200 && responseSubOperator.status < 300) {
|
||||
outMsg.status = "success";
|
||||
} else {
|
||||
if (responseSubOperator.body) {
|
||||
var responseBodyParsed = JSON.parse(responseSubOperator.body.asString());
|
||||
var slError = responseBodyParsed.error;
|
||||
if (slError && slError.hasOwnProperty("code") && slError.message && slError.message.value) {
|
||||
outMsg.message = slError.message.value + " (Code: " + slError.code.toString() + ")";
|
||||
} else {
|
||||
outMsg.message = responseSubOperator.body.asString();
|
||||
}
|
||||
outMsg.response = responseBodyParsed;
|
||||
} else {
|
||||
outMsg.message = JSON.stringify(responseSubOperator);
|
||||
}
|
||||
outStatus = "error";
|
||||
}
|
||||
outMessages.push(outMsg);
|
||||
} catch (ex) {
|
||||
exceptionHandler(ex);
|
||||
}
|
||||
}
|
||||
|
||||
function getUDO(Code) {
|
||||
outMsg = {};
|
||||
outMsg.method = "getUDO";
|
||||
outMsg.code = Code;
|
||||
outMsg.status = "error";
|
||||
var result = {};
|
||||
try {
|
||||
var responseGet = slLib.getDynamicEntity('EON_SUBOPERATOR', Code, SESSIONID, NODEID);
|
||||
outMsg.statuscode = responseGet.status;
|
||||
if (responseGet.status >= 200 && responseGet.status < 300) {
|
||||
var bodyGet = JSON.parse(responseGet.body.asString());
|
||||
outMsg.status = "success";
|
||||
result = bodyGet;
|
||||
outMsg.response = bodyGet;
|
||||
} else {
|
||||
if (responseGet.body) {
|
||||
var responseBodyParsed = JSON.parse(responseGet.body.asString());
|
||||
var slError = responseBodyParsed.error;
|
||||
if (slError && slError.hasOwnProperty("code") && slError.message && slError.message.value) {
|
||||
outMsg.message = slError.message.value + " (Code: " + slError.code.toString() + ")";
|
||||
} else {
|
||||
outMsg.message = responseGet.body.asString();
|
||||
}
|
||||
outMsg.response = responseBodyParsed;
|
||||
} else {
|
||||
outMsg.message = JSON.stringify(responseGet);
|
||||
}
|
||||
outStatus = "error";
|
||||
}
|
||||
if (debugLevel > 0 || outMsg.status !== "success") {
|
||||
outMessages.push(outMsg);
|
||||
}
|
||||
} catch (ex) {
|
||||
exceptionHandler(ex);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// main
|
||||
var content = "";
|
||||
if ($.request.body) {
|
||||
content = $.request.body.asString();
|
||||
}
|
||||
if (checkPayload(content) && checkAuthorization()) {
|
||||
setConnectionParams();
|
||||
slLoggedIn = slLogin();
|
||||
if (slLoggedIn) {
|
||||
var inObj = JSON.parse(content);
|
||||
if (outStatus !== "error") {
|
||||
updateUDO(inObj);
|
||||
}
|
||||
slLib.SLLogout(SESSIONID, NODEID);
|
||||
}
|
||||
}
|
||||
|
||||
$.trace.debug("DEBUG: " + JSON.stringify(myDebug));
|
||||
setOutputMessage();
|
||||
Reference in New Issue
Block a user