12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745 |
-
- /*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('<DataPrompt>');
- if (this.promptEnum != null) {
- xml.push('<promptEnum>');
- xml.push(this.accType);
- xml.push('</promptEnum>');
- }
- if (this.accType != null) {
- xml.push('<AccType>');
- xml.push(this.promptEnum);
- xml.push('</AccType>');
- }
- xml.push('</DataPrompt>');
- 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('<a:anyType ');
- if (this.value != null) {
- if (this.isXML === true) {
- xml.push('i:type="');
- xml.push("ColOfXmlElementey10qY8E");
- xml.push('"');
- }
- else if (this.type != null) {
- xml.push('i:type="');
- xml.push(this.type);
- xml.push('"');
- }
- else {
- var valtype = typeof (this.value);
- switch (valtype)
- {
- case "string":
- xml.push('i:type="ColOfstring"');
- break;
- case "boolean":
- xml.push('i:type="ColOfboolean"');
- break;
- case "number":
- if (Math.floor(this.value) == this.value)
- xml.push('i:type="ColOfint"');
- else
- xml.push('i:type="ColOffloat"');
- break;
- case "object":
- if (this.value instanceof GoldenRtWeb.Tab)
- xml.push('i:type="ColOfTabS6l8apdU"');
- else if (this.value instanceof GoldenRtWeb.RtItemDefine)
- xml.push('i:type="ColOfRtItemDefineWWCtA6hf"');
- break;
- }
- }
- }
- else {
- xml.push('i:type="NullCol"');
- }
- xml.push('>');
- if (this.key != null) {
- xml.push('<Key>');
- xml.push(this.key);
- xml.push('</Key>');
- }
- if (this.resultCode != null) {
- xml.push("<ResultCode>");
- xml.push(this.resultCode);
- xml.push("</ResultCode>");
- }
- if (this.dataPrompt != null) {
- xml = xml.concat(this.dataPrompt.toXML());
- }
- if (this.value != null) {
- xml.push('<Value>');
- 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('</Value>');
- }
- xml.push(' </a:anyType>');
- 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('<Row>');
- if (this.resultCode != null) {
- xml.push("<ResultCode>");
- xml.push(this.resultCode);
- xml.push("</ResultCode>");
- }
- if (this.Cols) {
- xml.push('<Cols xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays">');
- for (k in this.Cols)
- xml = xml.concat(this.Cols[k].toXML());
- xml.push("</Cols>");
- }
- xml.push('</Row>');
- 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('<Identity>');
- if (this.prompt != null)
- {
- xml.push('<Prompt>');
- xml.push(this.prompt);
- xml.push('</Prompt>');
- }
- if (this.Id != null)
- {
- xml.push('<Id>');
- xml.push(this.Id);
- xml.push('</Id>');
- }
- if (this.propId != null)
- {
- xml.push('<PropId>');
- xml.push(this.propId);
- xml.push('</PropId>');
- }
- if (this.uri != null)
- {
- xml.push('<URI>');
- xml.push(this.uri);
- xml.push('</URI>');
- }
- if (this.accType != null)
- {
- xml.push('<AccType>');
- xml.push(this.accType);
- xml.push('</AccType>');
- }
- xml.push('</Identity>');
- 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('<Tab>');
- if (this.URI != null) {
- xml.push('<URI>');
- xml.push(this.URI);
- xml.push('</URI>');
- }
- if (this.clientHandle != null) {
- xml.push('<ClientHandle>');
- xml.push(this.clientHandle);
- xml.push('</ClientHandle>');
- }
- if (this.resultCode != null) {
- xml.push("<ResultCode>");
- xml.push(this.resultCode);
- xml.push("</ResultCode>");
- }
- if (this.identity != null)
- xml = xml.concat(this.identity.toXML());
- if (this.Rows != null && this.Rows.length > 0) {
- xml.push("<Rows>");
- for (k in this.Rows)
- xml = xml.concat(this.Rows[k].toXML());
- xml.push("</Rows>");
- }
- xml.push('</Tab>');
- 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("<InfoSet>");
- if (this.resultCode != null) {
- xml.push("<ResultCode>");
- xml.push(this.resultCode);
- xml.push("</ResultCode>");
- }
- if (this.Tabs != null && this.Tabs.length > 0) {
- xml.push("<Tabs>");
- for (k in this.Tabs)
- xml = xml.concat(this.Tabs[k].toXML());
- xml.push("</Tabs>");
- }
- xml.push("</InfoSet>");
- 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("<EntityID>");
- xml.push(this.entityId);
- xml.push("</EntityID>");
- xml.push("<PropID>");
- xml.push(this.propId);
- xml.push("</PropID>");
- xml.push("<MetaID>");
- xml.push(this.metaId);
- xml.push("</MetaID>");
- if (this.dataMethod) {
- xml.push("<DataMethod>");
- xml.push(this.dataMethod);
- xml.push("</DataMethod>");
- }
- if (this.beginTime != null) {
- xml.push("<BeginTime>");
- xml.push(this.beginTime);
- xml.push("</BeginTime>");
- }
- if (this.endTime != null) {
- xml.push("<EndTime>");
- xml.push(this.endTime);
- xml.push("</EndTime>");
- }
- if (this.slotTime != null)
- {
- xml.push("<TimeSlot>");
- xml.push(Math.floor(this.slotTime));
- xml.push("</TimeSlot>");
- }
- 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;
- }();
|