- Implemented debug information

- Started table for Fulfillment Plan
This commit is contained in:
admin
2023-01-28 05:12:55 -08:00
parent 8fc009ca77
commit 031d949a83
37 changed files with 2103 additions and 84 deletions

View File

@ -7,75 +7,88 @@
<client_callable>false</client_callable>
<description/>
<name>ProcessorUtils</name>
<script><![CDATA[var _source;
var _appScope;
<script><![CDATA[let LOG;
var ProcessorUtils = Class.create();
ProcessorUtils.prototype = {
initialize: function(appScope) {
if(!appScope)
new LogUtils().write("Application scope is not received.", {type: "error", funcName: "initialize"});
initialize: function(appScope, details) {
if(!appScope) {
new LogUtils().write("Application scope undefined.", {type: "error", funcName: "initialize"});
}
this.internal_scope = appScope;
_appScope = appScope;
},
wrapScriptInclude: function(scriptPrototype, options = {}){
if(details){
this.details = details;
}
},
wrapPrototype: function(prototype, options = {}){
var {
table = "sys_script_include",
name = scriptPrototype.type,
name = prototype.type,
sys_id = false
} = options;
var sourceRecord = this.getSourceRecord(table, { name, sys_id });
Object.getOwnPropertyNames(scriptPrototype).forEach(function(f) {
if(Object.getOwnPropertyDescriptor(scriptPrototype,f).writable){
if (typeof scriptPrototype[f] === 'function') {
var old = scriptPrototype[f];
var funcName = f.toString();
if(_source){
var sourceTable = _source.getTableName();
var sourceID = _source.getValue("sys_id");
}
scriptPrototype[f] = function() {
functionName = Symbol(funcName);
var returnValue = false;
try{
if(old == undefined) throw new Error("Function: " + funcName + " does not exist");
returnValue = old.apply(this, arguments);
}catch(err){
var message = err.message ? "Message: " +err.message : undefined;
var line = err.lineNumber ? "Line: " + err.lineNumber : undefined;
var options = {
type: "error",
funcName: funcName,
lineNumber: line
};
new LogUtils().write(message, options);
}
return returnValue;
};
}
}
});
},
getSourceRecord: function(table, options){
var { sys_id, name } = options;
if(!LOG){
LOG = new LogUtils();
LOG._callee = [];
}
var log = LOG;
if(sourceRecord){
log.source = {
source_table: sourceRecord.getTableName(),
source_record: sourceRecord.getValue("sys_id")
};
}
prototype.LOG = log;
Object.getOwnPropertyNames(prototype).forEach(function(f) {
if(Object.getOwnPropertyDescriptor(prototype,f).writable){
if (typeof prototype[f] === 'function') {
var func = prototype[f];
var funcName = f.toString();
prototype[f] = function() {
prototype.LOG._callee.unshift({
function: funcName,
script_include: name,
start_time: (new Date()).toISOString()
});
var returnValue = false;
try{
returnValue = func.apply(this, arguments);
}catch(err){
prototype.LOG.error(err.message, funcName);
}
prototype.LOG._callee.shift();
return returnValue;
};
}
}
});
LOG = log;
},
getSourceRecord: function(table, options){
var answer = false;
var { sys_id, name } = options;
var sourceGr = new GlideRecord(table);
if(name) sourceGr.addQuery("name", name);
if(sys_id) sourceGr.addQuery("sys_id", sys_id);
sourceGr.addQuery("sys_scope.scope", _appScope);
sourceGr.addQuery("sys_scope.scope", this.internal_scope);
sourceGr.query();
if(sourceGr.next()){
_source = sourceGr;
answer = sourceGr;
}
return answer;
},
type: 'ProcessorUtils'
type: 'ProcessorUtils'
};]]></script>
<sys_class_name>sys_script_include</sys_class_name>
<sys_created_by>admin</sys_created_by>