/*GoldenRtWeb*/ !function () { var global = this; var nameSpaces = { xf: 'http://www.Golden.com/RtWeb/Service/', i: 'http://www.w3.org/2001/XMLSchema-instance', xsa: 'http://schemas.microsoft.com/2003/10/Serialization/Arrays' }; var GoldenRtWeb = { ResultCode: { S_NONE: 'S_NONE', //0 E_AUTHENERR: 'E_AUTHENERR', //-1, E_SERVICERESULTERR: 'E_SERVICERESULTERR', //-2, E_ACCDENY: 'E_ACCDENY', //-3, E_EXCEPTION: 'E_EXCEPTION', //-4, E_NOTIMPLEMENT: 'E_NOTIMPLEMENT', //-5 E_PARAERR: 'E_PARAERR', //-6, E_INNERERROR: 'E_INNERERROR', //-7, E_URISYNTAXERR: 'E_URISYNTAXERR', //-8, E_NAMEDITEMNOTEXIST: 'E_NAMEDITEMNOTEXIST', //-9, E_NAMEDUPLICATE: 'E_NAMEDUPLICATE', //-10, E_USERTOKENNOTEXIST: 'E_USERTOKENNOTEXIST', //-11, E_USERGUIDNOTEXIST: 'E_USERGUIDNOTEXIST', //-12, E_UNKNOWN: 'E_UNKNOWN', //-13, E_NOREFERENTITY: 'E_NOREFERENTITY', //-14, E_ENTITYCANTUPDATE: 'E_ENTITYCANTUPDATE', //-15, E_ENTITYCANTCREATE: 'E_ENTITYCANTCREATE', //-16, E_ENTITYCANTDELETE: 'E_ENTITYCANTDELETE', //-17, E_COMMTIMEOUT: 'E_COMMTIMEOUT', //-18, E_COMMFAULT: 'E_COMMFAULT', //-19, E_INVALOPERR: 'E_INVALOPERR', //-20, E_XFOUTMEMORY: 'E_XFOUTMEMORY', //-21, E_NOTCONFIG: 'E_NOTCONFIG', //-22, E_OUTSERVICE: 'E_OUTSERVICE', //-23, E_CHECKCODENOTEXIST: 'E_CHECKCODENOTEXIST', //-24, E_CHECKCODEERROR: 'E_CHECKCODEERROR', //-25, E_ACCOUTTLOGGED: 'E_ACCOUTTLOGGED', S_XFFALSE: 'S_XFFALSE', //1, S_UPDATEOK: 'S_UPDATEOK', //2, S_SETVALUE: 'S_SETVALUE', //3, S_CREATETAB: 'S_CREATETAB', //4, S_UPDATETAB: 'S_UPDATETAB', //5, S_XFOK: 'S_XFOK', //6, S_GETVALUE: 'S_GETVALUE', //7, S_CREATESETROW:'S_CREATESETROW', S_REFERUPDATETAB: 'S_REFERUPDATETAB', S_DELETEROW: 'S_DELETEROW', S_UPDATESETROW: 'S_UPDATESETROW', isOK: function (code) { switch (code) { case this.S_NONE: case this.S_CREATETAB: case this.S_UPDATETAB: case this.S_SETVALUE: case this.S_UPDATEOK: case this.S_XFFALSE: case this.S_XFOK: case this.S_GETVALUE: case this.S_CREATESETROW: case this.S_REFERUPDATETAB: case this.S_DELETEROW: case this.S_UPDATESETROW: return true; case this.E_ACCDENY: case this.E_AUTHENERR: case this.E_COMMFAULT: case this.E_COMMTIMEOUT: case this.E_ENTITYCANTCREATE: case this.E_ENTITYCANTDELETE: case this.E_ENTITYCANTUPDATE: case this.E_EXCEPTION: case this.E_INNERERROR: case this.E_INVALOPERR: case this.E_NAMEDITEMNOTEXIST: case this.E_NAMEDUPLICATE: case this.E_NOREFERENTITY: case this.E_NOTCONFIG: case this.E_NOTIMPLEMENT: case this.E_PARAERR: case this.E_SERVICERESULTERR: case this.E_UNKNOWN: case this.E_URISYNTAXERR: case this.E_USERGUIDNOTEXIST: case this.E_USERTOKENNOTEXIST: case this.E_XFOUTMEMORY: case this.E_CHECKCODENOTEXIST: case this.E_CHECKCODEERROR: case this.E_ACCOUTTLOGGED: return false; default: return false; } }, isErr: function (code) { return !this.isOK(code); } }, DataPromptEnum: { IDENTITY_DATAPROMPT: "Identity", ACCIDENT_DATAPROMPT: "AccIdent", ENTITYIDENT_DATAPROMPT: "EntityIdent", CATEGORYIDENT_DATAPROMPT: "CategoryIdent", PROPTYIDENT_DATAPROMPT: "ProptyIdent", PROPIDENT_DATAPROMPT: "PropIdent", METAIDENT_DATAPROMPT: "MetaIdent", CLIENTIDENTT_DATAPROMPT: "ClientIdent", NAMED_DATAPROMPT: "Named", IPV4INTADDRESS_DATAPROMPT: "IPv4IntAddress", IPV4SHORTPORT_DATAPROMPT: "IPv4ShortPort", ASSACC_DATAPROMPT: "AssociateAcc", ASSENTITY_DATAPROMPT: "AssociateEntity", ASSPROP_DATAPROMPT: "AssociateProperty", ASSMETA_DATAPROMPT: "AssociateMeta", ASSENTITYSET_DATAPROMPT: "AssociateEntitySet", ASSPROPSET_DATAPROMPT: "AssociatePropertySet", ASSMEATESET_DATAPROMPT: "AssociateMetaSet", ASSACCSET_DATAPROMPT: "AssociateAccSet", REFERURI_DATAPROMPT: "ReferURI" }, getURL: function () { var strFullPath = window.document.location.href; var strPath = window.document.location.pathname; var pos = strFullPath.indexOf(strPath); var prePath = strFullPath.substring(0, pos); var postPath = strPath.substring(0, strPath.substr(1).indexOf('/') + 1); if (postPath == "/htm") postPath = ""; return (prePath + postPath); }, getWebURL: function () { return "http://"+webServiceIP+":"+webServicePort+"/api/"; }, FileTimeToDate: function(fTime) { var epoch_diff = 116444736000000000; var rate_diff = 10000; var ut = (fTime - epoch_diff) / rate_diff; return new Date(ut); }, FileTimeToDateString:function (fTime) { if (isNaN(fTime) || fTime == 0) return ""; var date = GoldenRtWeb.FileTimeToDate(fTime); var dstr = date.getFullYear().toString(); dstr += "-"; if (date.getMonth() + 1 < 10) dstr += "0" + (date.getMonth() + 1).toString(); else dstr += (date.getMonth() + 1).toString(); dstr += "-"; if (date.getDate() < 10) dstr += "0" + date.getDate(); else dstr += date.getDate(); return dstr; }, FileTimeToTimeString: function (fTime, withoutMS) { if (isNaN(fTime) || fTime == 0) return ""; var date = GoldenRtWeb.FileTimeToDate(fTime); var time; if (date.getHours() < 10) time = "0" + date.getHours(); else time = date.getHours().toString(); time += ":"; if (date.getMinutes() < 10) time += "0" + date.getMinutes().toString(); else time += date.getMinutes(); time += ":"; if (date.getSeconds() < 10) time += "0" + date.getSeconds().toString(); else time += date.getSeconds(); if (withoutMS !== true) { time += "."; if (date.getMilliseconds() < 10) time += "00" + date.getMilliseconds().toString(); else if (date.getMilliseconds() < 100) time += "0" + date.getMilliseconds().toString(); else time += date.getMilliseconds().toString(); } return time; }, FileFullTimeToString: function (fTime, withoutMS) { return GoldenRtWeb.FileTimeToDateString(fTime) + " " + GoldenRtWeb.FileTimeToTimeString(fTime, withoutMS); }, FileTimeToString: function (fTime, withoutMS) { return GoldenRtWeb.FileTimeToTimeString(fTime, withoutMS); }, DateToFileTime:function (date) { var epoch_diff = 116444736000000000; var rate_diff = 10000; var ut = date.getTime(); var ft = ut * rate_diff + epoch_diff; return ft; }, getnodeText: function (oNode) { if (oNode.text) return oNode.text; else if (oNode.nodeType == 1) return oNode.textContent; else return null; }, setNs : function (xml) { if (typeof xml.selectSingleNode != "undefined") { var doc = (xml.nodeType != 9 ? xml.ownerDocument : xml); var ns = ""; for (var prefix in nameSpaces) { if (nameSpaces.hasOwnProperty(prefix)) { ns += "xmlns:" + prefix + "='" + nameSpaces[prefix] + "' "; } } doc.setProperty("SelectionLanguage", "XPath"); doc.setProperty("SelectionNamespaces", ns); } }, getnodeAttValue : function (oNode, attrName) { if (typeof oNode.getAttribute != "undefined") return oNode.getAttribute(attrName); else if (oNode.nodeType == 1 || oNode.nodeType == "1") return oNode.attributes[attrName].value; else return null; }, selectSingleNode : function (context, expression) { var doc = (context.nodeType != 9 ? context.ownerDocument : context); if (typeof doc.evaluate != "undefined") { var result = doc.evaluate(expression, context, function (prefix) {return nameSpaces[prefix];}, XPathResult.FIRST_ORDERED_NODE_TYPE, null); return (result !== null ? result.singleNodeValue : null); } else if (typeof context.selectSingleNode != "undefined") return context.selectSingleNode(expression); else { throw 'No XPath engine found'; } }, selectNodes : function (context, expression) { var doc = (context.nodeType != 9 ? context.ownerDocument : context); if (typeof doc.evaluate != "undefined") { var result = doc.evaluate(expression, context, function (prefix) {return nameSpaces[prefix];}, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); var nodes = new Array(); if (result !== null) { for (var i = 0, len = result.snapshotLength; i < len; i++) { nodes.push(result.snapshotItem(i)); } } return nodes; } else if (typeof context.selectNodes != "undefined") { var result = context.selectNodes(expression); var nodes = new Array(); for (var i = 0, len = result.length; i < len; i++) { nodes.push(result[i]); } return nodes; } else throw 'No XPath engine found'; } }; global.GoldenRtWeb = GoldenRtWeb; }(); /*HashTale*/ !function () { var Hashtable = function() { this.hashtable = new Array(); }; Hashtable.prototype.clear = function () { for (var i in this.hashtable) { delete this.hashtable[i]; } delete this.hashtable; }; Hashtable.prototype.containsKey = function (key) { var exists = false; for (var i in this.hashtable) { if (i == key && this.hashtable[i] != null) { exists = true; break; } } return exists; }; Hashtable.prototype.containsValue = function(value) { var contains = false; if (value != null) { for (var i in this.hashtable) { if (this.hashtable[i] == value) { contains = true; break; } } } return contains; }; Hashtable.prototype.get = function(key) { return this.hashtable[key]; }; Hashtable.prototype.isEmpty = function() { for (var i in this.hashtable) { if (this.hashtable[i] != null) return false; } return true; }; Hashtable.prototype.keys = function() { var keys = new Array(); for (var i in this.hashtable) { if (this.hashtable[i] != null) keys.push(i); } return keys; }; Hashtable.prototype.put = function(key, value) { if (key == null || value == null) { throw 'NullPointerException {' + key + '},{' + value + '}'; } else { this.hashtable[key] = value; } }; Hashtable.prototype.remove = function(key) { var tmp_previous; if (typeof (this.hashtable[key]) != 'undefined') { tmp_previous = this.hashtable[key]; delete this.hashtable[key]; } return tmp_previous; }; Hashtable.prototype.size = function() { var size = 0; for (var i in this.hashtable) { if (this.hashtable[i] != null) size++; } return size; }; Hashtable.prototype.toString = function () { var result = ''; for (var i in this.hashtable) { if (this.hashtable[i] != null) result += '{' + i + '},{' + this.hashtable[i] + '}\n'; } return result; }; Hashtable.prototype.values = function() { var values = new Array(); for (var i in this.hashtable) { if (this.hashtable[i] != null) values.push(this.hashtable[i]); } return values; }; GoldenRtWeb.HashTable = Hashtable; } (); /*DataPrompt*/ !function () { var DataPrompt = function () { this.promptEnum = null; this.accType = null; }; DataPrompt.prototype.parseXML = function (resultXML) { var node = GoldenRtWeb.selectSingleNode(resultXML, "xf:promptEnum"); if (node) this.promptEnum = GoldenRtWeb.getnodeText(node); else this.promptEnum = null; node = GoldenRtWeb.selectSingleNode(resultXML, "xf:AccType"); if (node) this.accType = GoldenRtWeb.getnodeText(node); else this.accType = null; }; DataPrompt.prototype.toXML = function () { var xml = []; xml.push(''); if (this.promptEnum != null) { xml.push(''); xml.push(this.accType); xml.push(''); } if (this.accType != null) { xml.push(''); xml.push(this.promptEnum); xml.push(''); } xml.push(''); return xml; }; GoldenRtWeb.DataPrompt = DataPrompt; } (); /*Col*/ !function () { var Col = function () { this.key = null; this.type = null; this.value = null; this.resultCode = null; this.errMess = null; this.isXML = false; }; Col.prototype.isOK = function () { return GoldenRtWeb.ResultCode.isOK(this.resultCode); }; Col.prototype.isErr = function () { return !this.isOK(); }; Col.prototype.toXML = function () { var xml = []; xml.push(''); if (this.key != null) { xml.push(''); xml.push(this.key); xml.push(''); } if (this.resultCode != null) { xml.push(""); xml.push(this.resultCode); xml.push(""); } if (this.dataPrompt != null) { xml = xml.concat(this.dataPrompt.toXML()); } if (this.value != null) { xml.push(''); if (this.value instanceof GoldenRtWeb.Tab) { var tabXML = this.value.toXML(); if (tabXML.length > 2) { tabXML = tabXML.slice(1, tabXML.length - 1) xml = xml.concat(tabXML); } } else if (this.value instanceof GoldenRtWeb.RtItemDefine) { xml = xml.concat(this.value.toXML()); } else xml.push(this.value); xml.push(''); } xml.push(' '); return xml; }; Col.prototype.parseVal =function(xmlValue) { var valType = GoldenRtWeb.getnodeAttValue(xmlValue, "i:type"); if(!valType) return null; var val = null; switch (valType) { case "ColOfstring": val = GoldenRtWeb.getnodeText(xmlValue); break; case "ColOfboolean": strValue = GoldenRtWeb.getnodeText(xmlValue).toLowerCase(); if (strValue == "true") val = true; else if (strValue == "false") val = false; else if (strValue == "1" || strValue == "-1") val = true; else val = false; break; case "ColOfbyte": case "ColOfshort": case "ColOfint": case "ColOfunsignedByte": case "ColOfunsignedShort": case "ColOfunsignedInt": case "ColOflong": case "ColOfunsignedLong": val = parseInt(GoldenRtWeb.getnodeText(xmlValue)); break; case "ColOffloat": case "ColOfdouble": case "ColOfdecimal": val = parseFloat(GoldenRtWeb.getnodeText(xmlValue)); break; case "ColOfdateTime": val = Date.parse(GoldenRtWeb.getnodeText(xmlValue)); break; case "ColOfTabS6l8apdU": var tab = new GoldenRtWeb.Tab(); tab.parseXML(xmlValue); val = tab; break; case "ColOfXmlElementey10qY8E": this.value = xmlValue.firstChild; this.isXML = true; break; default: if(valType.indexOf("VQT") >= 0) { var vqt = new GoldenRtWeb.VQT(); vqt.parseXML(xmlValue); val = vqt; } break; } return val; }; Col.prototype.parseXML = function (resultXML) { if (resultXML == null) { this.resultCode = null; this.errMess = null; this.key = null; this.dataPrompt = null; this.type = null; this.value = null; return; } this.type = GoldenRtWeb.getnodeAttValue(resultXML, "i:type"); var node = GoldenRtWeb.selectSingleNode(resultXML, "xf:ResultCode"); if (node) this.resultCode = GoldenRtWeb.getnodeText(node); else this.resultCode = GoldenRtWeb.ResultCode.S_NONE; node = GoldenRtWeb.selectSingleNode(resultXML, "xf:Key"); if (node) this.key = GoldenRtWeb.getnodeText(node); else this.key = null; node = GoldenRtWeb.selectSingleNode(resultXML, "xf:ErrMess"); if (node) this.errMess = GoldenRtWeb.getnodeText(node); else this.errMess = null; var xmlDataPrompt = GoldenRtWeb.selectSingleNode(resultXML, "DataPrompt"); if (xmlDataPrompt) { if (this.dataPrompt == null) this.dataPrompt = new GoldenRtWeb.DataPrompt(); this.dataPrompt.parseXML(xmlDataPrompt); } else this.dataPrompt = null; var xmlValue = GoldenRtWeb.selectSingleNode(resultXML, "xf:Value"); if (xmlValue) { switch (this.type) { case "ColOfstring": this.value = GoldenRtWeb.getnodeText(xmlValue); break; case "ColOfboolean": strValue = GoldenRtWeb.getnodeText(xmlValue).toLowerCase(); if (strValue == "true") this.value = true; else if (strValue == "false") this.value = false; else if (strValue == "1" || strValue == "-1") this.value = true; else this.value = false; break; case "ColOfXmlElementey10qY8E": this.value = xmlValue.firstChild; this.isXML = true; break; case "ColOfbyte": case "ColOfshort": case "ColOfint": case "ColOfunsignedByte": case "ColOfunsignedShort": case "ColOfunsignedInt": case "ColOflong": case "ColOfunsignedLong": this.value = parseInt(GoldenRtWeb.getnodeText(xmlValue)); break; case "ColOffloat": case "ColOfdouble": case "ColOfdecimal": this.value = parseFloat(GoldenRtWeb.getnodeText(xmlValue)); break; case "ColOfdateTime": this.value = Date.parse(GoldenRtWeb.getnodeText(xmlValue)); break; case "ColOfTabS6l8apdU": var tab = new GoldenRtWeb.Tab(); tab.parseXML(xmlValue); this.value = tab; break; case "ColOfanyType": var valtype = GoldenRtWeb.getnodeAttValue(xmlValue, "i:type"); if(valtype && valtype.indexOf("VQT") >= 0) { var vqt = new GoldenRtWeb.VQT(); vqt.parseXML(xmlValue); this.value = vqt; } break; case "ColOfArrayOfanyTypeuHEDJ7Dj": this.value = []; var vals = GoldenRtWeb.selectNodes(xmlValue, "xsa:anyType"); if(vals && vals.length > 0) { for (var i = 0; i < vals.length; i++) { var val = vals[i]; if(val == null) console.log('null'); this.value.push(this.parseVal(val)); } } break; case "ColOfXmlElementey10qY8E": this.value = xmlValue.firstChild; this.isXML = true; break; default: break; } } else this.value = null; }; GoldenRtWeb.Col = Col; } (); /*Row*/ !function () { var Row = function () { this.resultCode = null; this.errMess = null; this.Cols = []; }; Row.prototype.isOK = function () { return GoldenRtWeb.ResultCode.isOK(this.resultCode); }; Row.prototype.isErr = function () { return !this.isOK(); }; Row.prototype.addCol = function (col) { //if (col.key != null) // this.Cols[col.key] = col; //else this.Cols.push(col); }; Row.prototype.toXML = function (resultXML) { var xml = []; xml.push(''); if (this.resultCode != null) { xml.push(""); xml.push(this.resultCode); xml.push(""); } if (this.Cols) { xml.push(''); for (k in this.Cols) xml = xml.concat(this.Cols[k].toXML()); xml.push(""); } xml.push(''); return xml; }; Row.prototype.parseXML = function (resultXML) { if (resultXML == null) { this.resultCode = null; this.errMess = null; this.Cols = null; return; } var node = GoldenRtWeb.selectSingleNode(resultXML, "xf:ResultCode"); if (node) this.resultCode = GoldenRtWeb.getnodeText(node); else this.resultCode = GoldenRtWeb.ResultCode.S_NONE; var node = GoldenRtWeb.selectSingleNode(resultXML, "xf:ErrMess"); if (node) this.errMess = GoldenRtWeb.getnodeText(node); else this.errMess = null; var Cols = GoldenRtWeb.selectNodes(resultXML, "xf:Cols/xsa:anyType"); if (Cols || Cols.length > 0) { for (var i = 0; i < Cols.length; i++) { var xmlCol = Cols[i]; var col = this.findCol(xmlCol); if (col == null) { col = new GoldenRtWeb.Col(); col.parseXML(xmlCol); this.addCol(col); } else col.parseXML(xmlCol); } } else this.Cols = null; }; Row.prototype.findCol = function (colXML) { var node = GoldenRtWeb.selectSingleNode(colXML, "xf:Key"); if (node) { var key = GoldenRtWeb.getnodeText(node); if (key) { var col = this.Cols[key]; if (col) return col; } return this.getColByName(key); } else return null; }; Row.prototype.getColByName = function (key) { if (!this.Cols) return null; var skey = key.toLowerCase(); for (i in this.Cols) { var col = this.Cols[i]; if (col && col.key && col.key.toLowerCase() === skey) return col; } return null; }; GoldenRtWeb.Row = Row; } (); /*Identity*/ !function() { var Identity = function () { this.prompt = null; this.Id = null; this.propId = null; this.uri = null; this.accType = null; }; Identity.prototype.toXML= function () { var xml = []; xml.push(''); if (this.prompt != null) { xml.push(''); xml.push(this.prompt); xml.push(''); } if (this.Id != null) { xml.push(''); xml.push(this.Id); xml.push(''); } if (this.propId != null) { xml.push(''); xml.push(this.propId); xml.push(''); } if (this.uri != null) { xml.push(''); xml.push(this.uri); xml.push(''); } if (this.accType != null) { xml.push(''); xml.push(this.accType); xml.push(''); } xml.push(''); return xml; }; GoldenRtWeb.Identity = Identity; } (); /*Tab*/ !function () { var Tab = function () { this.resultCode = null; this.errMess = null; this.errSource = null; this.clientHandle = null; this.InfoSet = null; this.URI = null; this.identity = null; this.Rows = []; this.clearRowOnLoad = false; }; Tab.prototype.isOK = function () { return GoldenRtWeb.ResultCode.isOK(this.resultCode); }; Tab.prototype.isErr = function () { return !this.isOK(); }; Tab.prototype.findRow = function (rowXML) { return null; }; Tab.prototype.addRow = function (row) { row.Tab = this; this.Rows.push(row); }; Tab.prototype.toXML = function () { var xml = []; xml.push(''); if (this.URI != null) { xml.push(''); xml.push(this.URI); xml.push(''); } if (this.clientHandle != null) { xml.push(''); xml.push(this.clientHandle); xml.push(''); } if (this.resultCode != null) { xml.push(""); xml.push(this.resultCode); xml.push(""); } if (this.identity != null) xml = xml.concat(this.identity.toXML()); if (this.Rows != null && this.Rows.length > 0) { xml.push(""); for (k in this.Rows) xml = xml.concat(this.Rows[k].toXML()); xml.push(""); } xml.push(''); return xml; }; Tab.prototype.parseXML = function (resultXML) { if (resultXML == null) { this.resultCode = null; this.errMess = null; this.errorSource = null; this.costMsec = 0; this.cursorPos = 0; this.totalCount = 0; this.clientHandle = null; this.Rows = []; return; } var node = GoldenRtWeb.selectSingleNode(resultXML, "xf:ResultCode"); if (node) this.resultCode = GoldenRtWeb.getnodeText(node); else this.resultCode = ResultCode.S_NONE; node = GoldenRtWeb.selectSingleNode(resultXML, "xf:ErrMess"); if (node) this.errMess = GoldenRtWeb.getnodeText(node); else this.errMess = null; node = GoldenRtWeb.selectSingleNode(resultXML, "xf:ErrorSource"); if (node) this.errorSource = GoldenRtWeb.getnodeText(node); else this.errorSource = null; node = GoldenRtWeb.selectSingleNode(resultXML, "xf:CostMsec"); if (node) this.costMsec = parseInt(GoldenRtWeb.getnodeText(node)); else this.costMsec = 0; node = GoldenRtWeb.selectSingleNode(resultXML, "xf:CursorPos"); if (node) this.cursorPos = parseInt(GoldenRtWeb.getnodeText(node)); else this.cursorPos = 0; node = GoldenRtWeb.selectSingleNode(resultXML, "xf:TotalCount"); if (node) this.totalCount = parseInt(GoldenRtWeb.getnodeText(node)); else this.totalCount = 0; var clienthandle = GoldenRtWeb.selectSingleNode(resultXML, "xf:ClientHandle"); if (clienthandle) this.clientHandle = GoldenRtWeb.getnodeText(clienthandle); else this.clientHandle = null; var uri = GoldenRtWeb.selectSingleNode(resultXML, "xf:URI"); if (uri) this.URI = GoldenRtWeb.getnodeText(uri); else this.URI = null; var xmlRows = GoldenRtWeb.selectNodes(resultXML, "xf:Rows/xf:Row"); var bLoadRow = false; if (this.clearRowOnLoad === true) this.Rows = []; else if (this.Rows.length == 1 && xmlRows && xmlRows.length == 1) bLoadRow = true; if (xmlRows && xmlRows.length > 0) { for (var i = 0; i < xmlRows.length; i++) { var xmlRow = xmlRows[i]; var row; if (bLoadRow) { row = this.Rows[0]; row.parseXML(xmlRow); } else { row = this.findRow(xmlRow); if (row == null) { row = new GoldenRtWeb.Row(); row.parseXML(xmlRow); this.addRow(row); } } } } }; GoldenRtWeb.Tab = Tab; } (); /*InfoSet*/ !function () { var InfoSet = function () { this.Tabs = []; this.resultCode = null; this.costMsec = 0; this.cursorPos = 0; this.totalCount = 0; this.errMess = null; this.errSource = null; }; InfoSet.prototype.isOK = function () { return GoldenRtWeb.ResultCode.isOK(this.resultCode); }; InfoSet.prototype.isErr = function () { return !this.isOK(); }; InfoSet.prototype.addTab = function (tab) { tab.InfoSet = this; this.Tabs.push(tab); }; InfoSet.prototype.toXML = function () { var xml = []; xml.push(""); if (this.resultCode != null) { xml.push(""); xml.push(this.resultCode); xml.push(""); } if (this.Tabs != null && this.Tabs.length > 0) { xml.push(""); for (k in this.Tabs) xml = xml.concat(this.Tabs[k].toXML()); xml.push(""); } xml.push(""); return xml; }; InfoSet.prototype.parseXML = function (resultXML) { if (resultXML == null) { this.resultCode = GoldenRtWeb.ResultCode.E_SERVICERESULTERR; this.errMess = "服务没有返回有效的XML数据。"; this.errorSource = "GoldenRtWebService"; return; } GoldenRtWeb.setNs(resultXML); var infoset = GoldenRtWeb.selectSingleNode(resultXML, "//xf:InfoSet"); if (infoset) { var node = GoldenRtWeb.selectSingleNode(resultXML, "xf:ResultCode"); if (node) this.resultCode = GoldenRtWeb.getnodeText(node); else this.resultCode = GoldenRtWeb.ResultCode.S_NONE; node = GoldenRtWeb.selectSingleNode(resultXML, "xf:ErrMess"); if (node) this.errMess = GoldenRtWeb.getnodeText(node); else this.errMess = null; node = GoldenRtWeb.selectSingleNode(resultXML, "xf:ErrorSource"); if (node) this.errorSource = GoldenRtWeb.getnodeText(node); else this.errorSource = null; node = GoldenRtWeb.selectSingleNode(resultXML, "xf:CostMsec"); if (node) this.costMsec = parseInt(GoldenRtWeb.getnodeText(node)); else this.costMsec = 0; node = GoldenRtWeb.selectSingleNode(resultXML, "xf:CursorPos"); if (node) this.cursorPos = parseInt(GoldenRtWeb.getnodeText(node)); else this.cursorPos = 0; node = GoldenRtWeb.selectSingleNode(resultXML, "xf:TotalCount"); if (node) this.totalCount = parseInt(GoldenRtWeb.getnodeText(node)); else this.totalCount = 0; var Tabs = GoldenRtWeb.selectNodes(infoset, "xf:Tabs/xf:Tab"); if (Tabs && Tabs.length) { for (var i = 0; i < Tabs.length; i++) { var xmlTab = Tabs[i]; var tab; if (i < this.Tabs.length) tab = this.Tabs[i]; else { tab = new GoldenRtWeb.Tab(); this.addTab(tab); } tab.parseXML(xmlTab); } } } else { this.resultCode = GoldenRtWeb.ResultCode.E_SERVICERESULTERR; this.errMess = "服务没有返回有效的InfoSet数据。"; this.errorSource = "GoldenRtWebService"; } }; GoldenRtWeb.InfoSet = InfoSet; } (); /*RtItemDefine*/ !function () { var RtItemDefine = function (entityId, propId, metaId) { this.entityId = entityId; this.propId = propId; this.metaId = metaId; this.dataMethod = null; this.beginTime = null; this.endTime = null; this.slotTime = 0; }; RtItemDefine.prototype.toXML = function () { var xml = []; xml.push(""); xml.push(this.entityId); xml.push(""); xml.push(""); xml.push(this.propId); xml.push(""); xml.push(""); xml.push(this.metaId); xml.push(""); if (this.dataMethod) { xml.push(""); xml.push(this.dataMethod); xml.push(""); } if (this.beginTime != null) { xml.push(""); xml.push(this.beginTime); xml.push(""); } if (this.endTime != null) { xml.push(""); xml.push(this.endTime); xml.push(""); } if (this.slotTime != null) { xml.push(""); xml.push(Math.floor(this.slotTime)); xml.push(""); } return xml; }; GoldenRtWeb.RtItemDefine = RtItemDefine; } (); /*VQT*/ !function () { var VQT = function () { this.type = null; this.entityId = 0; this.propId = 0; this.metaId = 0; this.qua = 0; this.stampTime = 0; this.value = null; this.errMess = null; }; VQT.prototype.parseXML = function (vqtXML) { this.type = GoldenRtWeb.getnodeAttValue(vqtXML, "i:type"); var node = GoldenRtWeb.selectSingleNode(vqtXML, "xf:EntityId"); if (node) this.entityId = parseInt(GoldenRtWeb.getnodeText(node)); else this.entityId = 0; node = GoldenRtWeb.selectSingleNode(vqtXML, "xf:PropId"); if (node) this.propId = parseInt(GoldenRtWeb.getnodeText(node)); else this.propId = 0; node = GoldenRtWeb.selectSingleNode(vqtXML, "xf:MetaId"); if (node) this.metaId = parseInt(GoldenRtWeb.getnodeText(node)); else this.metaId = 0; node = GoldenRtWeb.selectSingleNode(vqtXML, "xf:Qua"); if (node) this.qua = parseInt(GoldenRtWeb.getnodeText(node)); else this.qua = 0; node = GoldenRtWeb.selectSingleNode(vqtXML, "xf:StampTime"); if (node) this.stampTime = parseInt(GoldenRtWeb.getnodeText(node)); else this.stampTime = 0; node = GoldenRtWeb.selectSingleNode(vqtXML, "xf:ErrMess"); if (node) this.errMess = GoldenRtWeb.getnodeText(node); else this.errMess = null; var xmlValue = GoldenRtWeb.selectSingleNode(vqtXML, "xf:Value"); if (xmlValue) { strValue = GoldenRtWeb.getnodeText(xmlValue); if (strValue) { switch (this.type) { case "VQTOfstring": this.value = strValue; break; case "VQTOfboolean": strValue = strValue.toLowerCase(); if (strValue == "true") this.value = true; else if (strValue == "false") this.value = false; else if (strValue == "1" || strValue == "-1") this.value = true; else this.value = false; break; case "VQTOfbyte": case "VQTOfshort": case "VQTOfint": case "VQTOfunsignedByte": case "VQTOfunsignedShort": case "VQTOfunsignedInt": case "VQTOflong": case "VQTOfunsignedLong": this.value = parseInt(strValue); break; case "VQTOffloat": case "VQTOfdouble": case "VQTOfdecimal": this.value = parseFloat(strValue); break; case "VQTOfdateTime": this.value = Date.parse(strValue); break; case "VQTOfTabS6l8apdU": var tab = new GoldenRtWeb.Tab(); tab.parseXML(xmlValue); this.value = tab; break; case "VQTOfanyType": var vqt = new GoldenRtWeb.VQT(); vqt.parseXML(xmlValue); this.value = vqt; break; default: this.errMess = "无法识别的数据类型:" + this.type; break; } } } }; VQT.prototype.getQuaStr = function () { var re = ""; switch(this.qua) { case 0: // re = "正常"; break; case 1: re = "无数据"; break; case 2: re = "创建"; break; case 3: re = "停机"; break; case 4: re = "计算停止"; break; case 5: re = "坏点"; break; case 6: re = "被零除"; break; case 7: re = "已被删除"; break; default: if (this.qua & 0x0100) // 从0x0100至0x01FF为OPC质量码 { switch (this.qua & 0xFC) { case 0x00: re = "坏值"; break; case 0x04: re = "坏值(组态错误)"; break; case 0x08: re = "坏值(没有连接)"; break; case 0x0C: re = "坏值(设备故障)"; break; case 0x10: re = "坏值(传感器故障)"; break; case 0x14: re = "坏值(最后值)"; break; case 0x18: re = "坏值(通讯故障)"; break; case 0x1C: re = "坏值(退出服务)"; break; case 0x20: re = "坏值(不被许可)"; break; case 0x24: re = "坏值(超出量程)"; break; case 0x2C: re = "坏值(未定义值)"; break; case 0x28: re = "坏值(计算错误)"; break; case 0x30: re = "坏值(输出开路)"; break; case 0x34: re = "坏值(输入开路)"; break; case 0x3C: re = "坏值(转换错误)"; break; case 0x40: re = "坏值(可疑值)"; break; case 0x44: re = "可疑值(最后值)"; break; case 0x48: re = "可疑值(输出开路)"; break; case 0x4C: re = "可疑值(等待同步)"; break; case 0x50: re = "可疑值(传感器校正)"; break; case 0x54: re = "可疑值(超出量程)"; break; case 0x58: re = "可疑值(子故障)"; break; case 0x5C: re = "可疑值(输入开路)"; break; case 0x60: re = "可疑值(转换错误)"; break; case 0xC0: re = "正常"; break; case 0xC4: re = "正常(初始化)"; break; case 0xC4: re = "正常(无状态)"; break; case 0xD8: re = "正常(当地重载)"; break; } } else { re = "用户自定义"; } break; } return re; }; VQT.prototype.getStampTimeStr = function (withoutMS) { return GoldenRtWeb.FileTimeToString(this.stampTime, withoutMS); }; VQT.prototype.getFullStampTimeStr = function (withoutMS) { return GoldenRtWeb.FileFullTimeToString(this.stampTime, withoutMS); }; VQT.prototype.isGood = function () { return (this.qua == 0 || ((this.qua & 0x100) && (this.qua & 0xc0) == 0xc0)); }; VQT.prototype.isUncertain = function () { return false; }; VQT.prototype.isBad = function () { return !this.isGood(); }; VQT.prototype.isFloat = function () { return (this.type == "VQTOffloat" || this.type == "VQTOfdouble" || this.type == "VQTOfdecimal"); }; VQT.prototype.isBoolen = function () { return this.type == "VQTOfboolean"; }; VQT.prototype.isString = function () { return this.type == "VQTOfstring"; }; VQT.prototype.isInt = function () { if (!this.type) return false; switch (this.type) { case 'VQTOfbyte': case 'VQTOfint': case "VQTOflong": case "VQTOfshort": case "VQTOfunsignedByte": case "VQTOfunsignedInt": case "VQTOfunsignedLong": case "VQTOfunsignedShort": return true; } return false; }; VQT.prototype.isDate = function () { return this.type == "VQTOfdateTime"; }; VQT.prototype.GetNumber = function () { if(this.isString()) { var hash = 0; if (!this.value || !this.value.length) return hash; for (i = 0; i < this.value.length; i++) { char = this.value.charCodeAt(i); hash = ((hash<<5)-hash)+char; hash = hash & hash; } return hash; } else if(this.isBoolen()) { if(this.value) return 1; else return 0; } else if(this.isDate()) { return this.value.getTime(); } else return this.value; }; GoldenRtWeb.VQT = VQT; } (); /*RtRefresh*/ !function () { var RtRefresher = function (url, period) { this.refreshTimer = null; this.subscription = null; this.refreshPeriod = period || 1000; this.webURL = url; this.seed = 1; }; RtRefresher.prototype.clear = function () { if (this.refreshTimer != null) { window.clearTimeout(this.refreshTimer); this.refreshTimer = null; } if (this.subscription) { this.subscription.clear(); delete this.subscription; } }; RtRefresher.prototype.RegistRtPt = function (rtDef, scope, callback, opt) { var sub = { rtDef: rtDef, scope: scope, callback: callback, opt: opt }; if (this.subscription == null) this.subscription = new GoldenRtWeb.HashTable(); this.subscription.put(rtDef, sub); delete this.sendXML; if (this.refreshTimer != null) { window.clearTimeout(this.refreshTimer); this.refreshTimer = null; } var me = this; this.refreshTimer = window.setTimeout(function () { window.clearTimeout(me.refreshTimer); me.refreshTimer = null; me.RtRefresh(); me = null; }, 10); return rtDef; }; RtRefresher.prototype.UnRegistRtPt = function (key) { if (this.subscription != null) { if (this.subscription.remove(key)) this.sendXML = null; } }; RtRefresher.prototype.RtRefresh = function () { if (!this.subscription.isEmpty()) { var hasTable = this.subscription.hashtable; if (!this.sendXML) { var xml = []; for (var key in hasTable) { var sub = hasTable[key]; if (sub.rtDef) { xml.push(sub.rtDef); } } this.sendXML = "http://" + webServiceIP + ":" + webServicePort + "/api/Snapshot?tagName="; this.sendXML += xml.join(","); } for (var key in hasTable) { var sub = hasTable[key]; if (sub.callback) sub.callback.call(sub.scope, 'getting'); } $.ajax( { url: this.sendXML, type: "GET", dataType: 'json', cache: false, complete: function (xhr, ts) { if (xhr.token) { xhr.token.rtRefreshed(xhr, ts); delete xhr.token; } } }).token = this; }; RtRefresher.prototype.rtRefreshed = function (xhr, ts) { if (this.refreshTimer) { window.clearTimeout(this.refreshTimer); this.refreshTimer = null; } if (this.subscription.isEmpty()) return; var err = null; var hasTable = this.subscription.hashtable; if (ts == 'success') { if(xhr.responseJSON && xhr.responseJSON.length) { for (var i in xhr.responseJSON) { var data = xhr.responseJSON[i]; var sub = hasTable[data.TagName]; if (sub && sub.callback) { var date = GoldenRtWeb.DateToFileTime(new Date(data.Time)); var val = parseFloat(data.Value); if (data.Value.indexOf('.') > 0) val = val.toFixed(2); if (isNaN(val)) val = data.Value; var vqt = new GoldenRtWeb.VQT(); vqt.stampTime = date; vqt.value = val; vqt.errMess = data.ErrorMsg; vqt.qua = data.Quality; sub.callback.call(sub.scope, 'success', vqt, sub.opt); } } } } else err = "通讯故障:" + (xhr.statusText ? xhr.statusText : "") + "(" + xhr.status + ")"; if (err != null) { for (var key in hasTable) { var sub = hasTable[key]; if (sub && sub.callback) sub.callback.call(sub.scope, 'error', err, sub.opt); } } var me = this; this.refreshTimer = window.setTimeout(function () { window.clearTimeout(me.refreshTimer); me.refreshTimer = null; me.RtRefresh(); me = null; }, this.refreshPeriod); }; }; GoldenRtWeb.RtRefresher = RtRefresher; } (); /*MD5*/ !function () { var MD5 = { safe_add: function(x,y) { var lsw = (x & 0xFFFF) + (y & 0xFFFF); var msw = (x >> 16) + (y >> 16) + (lsw >> 16); return (msw << 16) | (lsw & 0xFFFF); }, bit_rol: function(num, cnt){ return (num << cnt) | (num >>> (32 - cnt)); }, md5_cmn: function (q, a, b, x, s, t){ return this.safe_add(this.bit_rol(this.safe_add(this.safe_add(a, q), this.safe_add(x, t)), s),b); }, md5_ff: function (a, b, c, d, x, s, t){ return this.md5_cmn((b & c) | ((~b) & d), a, b, x, s, t); }, md5_gg: function(a, b, c, d, x, s, t){ return this.md5_cmn((b & d) | (c & (~d)), a, b, x, s, t); }, md5_hh: function (a, b, c, d, x, s, t){ return this.md5_cmn(b ^ c ^ d, a, b, x, s, t); }, md5_ii: function (a, b, c, d, x, s, t){ return this.md5_cmn(c ^ (b | (~d)), a, b, x, s, t); }, core_md5: function (x, len){ x[len >> 5] |= 0x80 << ((len) % 32); x[(((len + 64) >>> 9) << 4) + 14] = len; var a = 1732584193; var b = -271733879; var c = -1732584194; var d = 271733878; for(var i = 0; i < x.length; i += 16){ var olda = a; var oldb = b; var oldc = c; var oldd = d; a = this.md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936); d = this.md5_ff(d, a, b, c, x[i+ 1], 12, -389564586); c = this.md5_ff(c, d, a, b, x[i+ 2], 17, 606105819); b = this.md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330); a = this.md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897); d = this.md5_ff(d, a, b, c, x[i+ 5], 12, 1200080426); c = this.md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341); b = this.md5_ff(b, c, d, a, x[i+ 7], 22, -45705983); a = this.md5_ff(a, b, c, d, x[i+ 8], 7 , 1770035416); d = this.md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417); c = this.md5_ff(c, d, a, b, x[i+10], 17, -42063); b = this.md5_ff(b, c, d, a, x[i+11], 22, -1990404162); a = this.md5_ff(a, b, c, d, x[i+12], 7 , 1804603682); d = this.md5_ff(d, a, b, c, x[i+13], 12, -40341101); c = this.md5_ff(c, d, a, b, x[i+14], 17, -1502002290); b = this.md5_ff(b, c, d, a, x[i+15], 22, 1236535329); a = this.md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510); d = this.md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632); c = this.md5_gg(c, d, a, b, x[i+11], 14, 643717713); b = this.md5_gg(b, c, d, a, x[i+ 0], 20, -373897302); a = this.md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691); d = this.md5_gg(d, a, b, c, x[i+10], 9 , 38016083); c = this.md5_gg(c, d, a, b, x[i+15], 14, -660478335); b = this.md5_gg(b, c, d, a, x[i+ 4], 20, -405537848); a = this.md5_gg(a, b, c, d, x[i+ 9], 5 , 568446438); d = this.md5_gg(d, a, b, c, x[i+14], 9 , -1019803690); c = this.md5_gg(c, d, a, b, x[i+ 3], 14, -187363961); b = this.md5_gg(b, c, d, a, x[i+ 8], 20, 1163531501); a = this.md5_gg(a, b, c, d, x[i+13], 5 , -1444681467); d = this.md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784); c = this.md5_gg(c, d, a, b, x[i+ 7], 14, 1735328473); b = this.md5_gg(b, c, d, a, x[i+12], 20, -1926607734); a = this.md5_hh(a, b, c, d, x[i+ 5], 4 , -378558); d = this.md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463); c = this.md5_hh(c, d, a, b, x[i+11], 16, 1839030562); b = this.md5_hh(b, c, d, a, x[i+14], 23, -35309556); a = this.md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060); d = this.md5_hh(d, a, b, c, x[i+ 4], 11, 1272893353); c = this.md5_hh(c, d, a, b, x[i+ 7], 16, -155497632); b = this.md5_hh(b, c, d, a, x[i+10], 23, -1094730640); a = this.md5_hh(a, b, c, d, x[i+13], 4 , 681279174); d = this.md5_hh(d, a, b, c, x[i+ 0], 11, -358537222); c = this.md5_hh(c, d, a, b, x[i+ 3], 16, -722521979); b = this.md5_hh(b, c, d, a, x[i+ 6], 23, 76029189); a = this.md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487); d = this.md5_hh(d, a, b, c, x[i+12], 11, -421815835); c = this.md5_hh(c, d, a, b, x[i+15], 16, 530742520); b = this.md5_hh(b, c, d, a, x[i+ 2], 23, -995338651); a = this.md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844); d = this.md5_ii(d, a, b, c, x[i+ 7], 10, 1126891415); c = this.md5_ii(c, d, a, b, x[i+14], 15, -1416354905); b = this.md5_ii(b, c, d, a, x[i+ 5], 21, -57434055); a = this.md5_ii(a, b, c, d, x[i+12], 6 , 1700485571); d = this.md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606); c = this.md5_ii(c, d, a, b, x[i+10], 15, -1051523); b = this.md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799); a = this.md5_ii(a, b, c, d, x[i+ 8], 6 , 1873313359); d = this.md5_ii(d, a, b, c, x[i+15], 10, -30611744); c = this.md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380); b = this.md5_ii(b, c, d, a, x[i+13], 21, 1309151649); a = this.md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070); d = this.md5_ii(d, a, b, c, x[i+11], 10, -1120210379); c = this.md5_ii(c, d, a, b, x[i+ 2], 15, 718787259); b = this.md5_ii(b, c, d, a, x[i+ 9], 21, -343485551); a = this.safe_add(a, olda); b = this.safe_add(b, oldb); c = this.safe_add(c, oldc); d = this.safe_add(d, oldd); } return [a, b, c, d]; }, str2binl: function(str,chrsz){ var bin = []; var mask = (1 << chrsz) - 1; for(var i = 0; i < str.length * chrsz; i += chrsz) { bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (i%32); } return bin; }, binl2str: function (bin,chrsz){ var str = ""; var mask = (1 << chrsz) - 1; for(var i = 0; i < bin.length * 32; i += chrsz) { str += String.fromCharCode((bin[i>>5] >>> (i % 32)) & mask); } return str; }, binl2hex: function (binarray,hexcase){ var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef"; var str = ""; for(var i = 0; i < binarray.length * 4; i++) { str += hex_tab.charAt((binarray[i>>2] >> ((i%4)*8+4)) & 0xF) + hex_tab.charAt((binarray[i>>2] >> ((i%4)*8 )) & 0xF); } return str; }, Hex: function(str,hexcase,chrsz) { hexcase = hexcase || false; chrsz = chrsz || 16; //number charset {8(ASCII):16(UNICODE)} return this.binl2hex(this.core_md5(this.str2binl(str,chrsz), str.length * chrsz),hexcase); }, Bin: function(str) { chrsz = chrsz || 16; //number charset {8(ASCII):16(UNICODE)} return this.binl2str(this.core_md5(this.str2binl(str,chrsz), str.length * chrsz),chrsz) } }; GoldenRtWeb.MD5 = MD5; }();