GoldenRtWeb.js 60 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745
  1. 
  2. /*GoldenRtWeb*/
  3. !function () {
  4. var global = this;
  5. var nameSpaces =
  6. {
  7. xf: 'http://www.Golden.com/RtWeb/Service/',
  8. i: 'http://www.w3.org/2001/XMLSchema-instance',
  9. xsa: 'http://schemas.microsoft.com/2003/10/Serialization/Arrays'
  10. };
  11. var GoldenRtWeb =
  12. {
  13. ResultCode:
  14. {
  15. S_NONE: 'S_NONE', //0
  16. E_AUTHENERR: 'E_AUTHENERR', //-1,
  17. E_SERVICERESULTERR: 'E_SERVICERESULTERR', //-2,
  18. E_ACCDENY: 'E_ACCDENY', //-3,
  19. E_EXCEPTION: 'E_EXCEPTION', //-4,
  20. E_NOTIMPLEMENT: 'E_NOTIMPLEMENT', //-5
  21. E_PARAERR: 'E_PARAERR', //-6,
  22. E_INNERERROR: 'E_INNERERROR', //-7,
  23. E_URISYNTAXERR: 'E_URISYNTAXERR', //-8,
  24. E_NAMEDITEMNOTEXIST: 'E_NAMEDITEMNOTEXIST', //-9,
  25. E_NAMEDUPLICATE: 'E_NAMEDUPLICATE', //-10,
  26. E_USERTOKENNOTEXIST: 'E_USERTOKENNOTEXIST', //-11,
  27. E_USERGUIDNOTEXIST: 'E_USERGUIDNOTEXIST', //-12,
  28. E_UNKNOWN: 'E_UNKNOWN', //-13,
  29. E_NOREFERENTITY: 'E_NOREFERENTITY', //-14,
  30. E_ENTITYCANTUPDATE: 'E_ENTITYCANTUPDATE', //-15,
  31. E_ENTITYCANTCREATE: 'E_ENTITYCANTCREATE', //-16,
  32. E_ENTITYCANTDELETE: 'E_ENTITYCANTDELETE', //-17,
  33. E_COMMTIMEOUT: 'E_COMMTIMEOUT', //-18,
  34. E_COMMFAULT: 'E_COMMFAULT', //-19,
  35. E_INVALOPERR: 'E_INVALOPERR', //-20,
  36. E_XFOUTMEMORY: 'E_XFOUTMEMORY', //-21,
  37. E_NOTCONFIG: 'E_NOTCONFIG', //-22,
  38. E_OUTSERVICE: 'E_OUTSERVICE', //-23,
  39. E_CHECKCODENOTEXIST: 'E_CHECKCODENOTEXIST', //-24,
  40. E_CHECKCODEERROR: 'E_CHECKCODEERROR', //-25,
  41. E_ACCOUTTLOGGED: 'E_ACCOUTTLOGGED',
  42. S_XFFALSE: 'S_XFFALSE', //1,
  43. S_UPDATEOK: 'S_UPDATEOK', //2,
  44. S_SETVALUE: 'S_SETVALUE', //3,
  45. S_CREATETAB: 'S_CREATETAB', //4,
  46. S_UPDATETAB: 'S_UPDATETAB', //5,
  47. S_XFOK: 'S_XFOK', //6,
  48. S_GETVALUE: 'S_GETVALUE', //7,
  49. S_CREATESETROW:'S_CREATESETROW',
  50. S_REFERUPDATETAB: 'S_REFERUPDATETAB',
  51. S_DELETEROW: 'S_DELETEROW',
  52. S_UPDATESETROW: 'S_UPDATESETROW',
  53. isOK: function (code) {
  54. switch (code) {
  55. case this.S_NONE:
  56. case this.S_CREATETAB:
  57. case this.S_UPDATETAB:
  58. case this.S_SETVALUE:
  59. case this.S_UPDATEOK:
  60. case this.S_XFFALSE:
  61. case this.S_XFOK:
  62. case this.S_GETVALUE:
  63. case this.S_CREATESETROW:
  64. case this.S_REFERUPDATETAB:
  65. case this.S_DELETEROW:
  66. case this.S_UPDATESETROW:
  67. return true;
  68. case this.E_ACCDENY:
  69. case this.E_AUTHENERR:
  70. case this.E_COMMFAULT:
  71. case this.E_COMMTIMEOUT:
  72. case this.E_ENTITYCANTCREATE:
  73. case this.E_ENTITYCANTDELETE:
  74. case this.E_ENTITYCANTUPDATE:
  75. case this.E_EXCEPTION:
  76. case this.E_INNERERROR:
  77. case this.E_INVALOPERR:
  78. case this.E_NAMEDITEMNOTEXIST:
  79. case this.E_NAMEDUPLICATE:
  80. case this.E_NOREFERENTITY:
  81. case this.E_NOTCONFIG:
  82. case this.E_NOTIMPLEMENT:
  83. case this.E_PARAERR:
  84. case this.E_SERVICERESULTERR:
  85. case this.E_UNKNOWN:
  86. case this.E_URISYNTAXERR:
  87. case this.E_USERGUIDNOTEXIST:
  88. case this.E_USERTOKENNOTEXIST:
  89. case this.E_XFOUTMEMORY:
  90. case this.E_CHECKCODENOTEXIST:
  91. case this.E_CHECKCODEERROR:
  92. case this.E_ACCOUTTLOGGED:
  93. return false;
  94. default:
  95. return false;
  96. }
  97. },
  98. isErr: function (code) {
  99. return !this.isOK(code);
  100. }
  101. },
  102. DataPromptEnum:
  103. {
  104. IDENTITY_DATAPROMPT: "Identity",
  105. ACCIDENT_DATAPROMPT: "AccIdent",
  106. ENTITYIDENT_DATAPROMPT: "EntityIdent",
  107. CATEGORYIDENT_DATAPROMPT: "CategoryIdent",
  108. PROPTYIDENT_DATAPROMPT: "ProptyIdent",
  109. PROPIDENT_DATAPROMPT: "PropIdent",
  110. METAIDENT_DATAPROMPT: "MetaIdent",
  111. CLIENTIDENTT_DATAPROMPT: "ClientIdent",
  112. NAMED_DATAPROMPT: "Named",
  113. IPV4INTADDRESS_DATAPROMPT: "IPv4IntAddress",
  114. IPV4SHORTPORT_DATAPROMPT: "IPv4ShortPort",
  115. ASSACC_DATAPROMPT: "AssociateAcc",
  116. ASSENTITY_DATAPROMPT: "AssociateEntity",
  117. ASSPROP_DATAPROMPT: "AssociateProperty",
  118. ASSMETA_DATAPROMPT: "AssociateMeta",
  119. ASSENTITYSET_DATAPROMPT: "AssociateEntitySet",
  120. ASSPROPSET_DATAPROMPT: "AssociatePropertySet",
  121. ASSMEATESET_DATAPROMPT: "AssociateMetaSet",
  122. ASSACCSET_DATAPROMPT: "AssociateAccSet",
  123. REFERURI_DATAPROMPT: "ReferURI"
  124. },
  125. getURL: function () {
  126. var strFullPath = window.document.location.href;
  127. var strPath = window.document.location.pathname;
  128. var pos = strFullPath.indexOf(strPath);
  129. var prePath = strFullPath.substring(0, pos);
  130. var postPath = strPath.substring(0, strPath.substr(1).indexOf('/') + 1);
  131. if (postPath == "/htm")
  132. postPath = "";
  133. return (prePath + postPath);
  134. },
  135. getWebURL: function () {
  136. return "http://"+webServiceIP+":"+webServicePort+"/api/";
  137. },
  138. FileTimeToDate: function(fTime) {
  139. var epoch_diff = 116444736000000000;
  140. var rate_diff = 10000;
  141. var ut = (fTime - epoch_diff) / rate_diff;
  142. return new Date(ut);
  143. },
  144. FileTimeToDateString:function (fTime) {
  145. if (isNaN(fTime) || fTime == 0)
  146. return "";
  147. var date = GoldenRtWeb.FileTimeToDate(fTime);
  148. var dstr = date.getFullYear().toString();
  149. dstr += "-";
  150. if (date.getMonth() + 1 < 10)
  151. dstr += "0" + (date.getMonth() + 1).toString();
  152. else
  153. dstr += (date.getMonth() + 1).toString();
  154. dstr += "-";
  155. if (date.getDate() < 10)
  156. dstr += "0" + date.getDate();
  157. else
  158. dstr += date.getDate();
  159. return dstr;
  160. },
  161. FileTimeToTimeString: function (fTime, withoutMS) {
  162. if (isNaN(fTime) || fTime == 0)
  163. return "";
  164. var date = GoldenRtWeb.FileTimeToDate(fTime);
  165. var time;
  166. if (date.getHours() < 10)
  167. time = "0" + date.getHours();
  168. else
  169. time = date.getHours().toString();
  170. time += ":";
  171. if (date.getMinutes() < 10)
  172. time += "0" + date.getMinutes().toString();
  173. else
  174. time += date.getMinutes();
  175. time += ":";
  176. if (date.getSeconds() < 10)
  177. time += "0" + date.getSeconds().toString();
  178. else
  179. time += date.getSeconds();
  180. if (withoutMS !== true) {
  181. time += ".";
  182. if (date.getMilliseconds() < 10)
  183. time += "00" + date.getMilliseconds().toString();
  184. else if (date.getMilliseconds() < 100)
  185. time += "0" + date.getMilliseconds().toString();
  186. else
  187. time += date.getMilliseconds().toString();
  188. }
  189. return time;
  190. },
  191. FileFullTimeToString: function (fTime, withoutMS) {
  192. return GoldenRtWeb.FileTimeToDateString(fTime) + " " + GoldenRtWeb.FileTimeToTimeString(fTime, withoutMS);
  193. },
  194. FileTimeToString: function (fTime, withoutMS) {
  195. return GoldenRtWeb.FileTimeToTimeString(fTime, withoutMS);
  196. },
  197. DateToFileTime:function (date) {
  198. var epoch_diff = 116444736000000000;
  199. var rate_diff = 10000;
  200. var ut = date.getTime();
  201. var ft = ut * rate_diff + epoch_diff;
  202. return ft;
  203. },
  204. getnodeText: function (oNode) {
  205. if (oNode.text)
  206. return oNode.text;
  207. else if (oNode.nodeType == 1)
  208. return oNode.textContent;
  209. else
  210. return null;
  211. },
  212. setNs : function (xml) {
  213. if (typeof xml.selectSingleNode != "undefined") {
  214. var doc = (xml.nodeType != 9 ? xml.ownerDocument : xml);
  215. var ns = "";
  216. for (var prefix in nameSpaces) {
  217. if (nameSpaces.hasOwnProperty(prefix)) {
  218. ns += "xmlns:" + prefix + "='" + nameSpaces[prefix] + "' ";
  219. }
  220. }
  221. doc.setProperty("SelectionLanguage", "XPath");
  222. doc.setProperty("SelectionNamespaces", ns);
  223. }
  224. },
  225. getnodeAttValue : function (oNode, attrName) {
  226. if (typeof oNode.getAttribute != "undefined")
  227. return oNode.getAttribute(attrName);
  228. else if (oNode.nodeType == 1 || oNode.nodeType == "1")
  229. return oNode.attributes[attrName].value;
  230. else
  231. return null;
  232. },
  233. selectSingleNode : function (context, expression) {
  234. var doc = (context.nodeType != 9 ? context.ownerDocument : context);
  235. if (typeof doc.evaluate != "undefined") {
  236. var result = doc.evaluate(expression, context, function (prefix) {return nameSpaces[prefix];}, XPathResult.FIRST_ORDERED_NODE_TYPE, null);
  237. return (result !== null ? result.singleNodeValue : null);
  238. }
  239. else if (typeof context.selectSingleNode != "undefined")
  240. return context.selectSingleNode(expression);
  241. else {
  242. throw 'No XPath engine found';
  243. }
  244. },
  245. selectNodes : function (context, expression) {
  246. var doc = (context.nodeType != 9 ? context.ownerDocument : context);
  247. if (typeof doc.evaluate != "undefined") {
  248. var result = doc.evaluate(expression, context, function (prefix) {return nameSpaces[prefix];}, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  249. var nodes = new Array();
  250. if (result !== null) {
  251. for (var i = 0, len = result.snapshotLength; i < len; i++) {
  252. nodes.push(result.snapshotItem(i));
  253. }
  254. }
  255. return nodes;
  256. }
  257. else if (typeof context.selectNodes != "undefined") {
  258. var result = context.selectNodes(expression);
  259. var nodes = new Array();
  260. for (var i = 0, len = result.length; i < len; i++) {
  261. nodes.push(result[i]);
  262. }
  263. return nodes;
  264. }
  265. else
  266. throw 'No XPath engine found';
  267. }
  268. };
  269. global.GoldenRtWeb = GoldenRtWeb;
  270. }();
  271. /*HashTale*/
  272. !function () {
  273. var Hashtable = function() {
  274. this.hashtable = new Array();
  275. };
  276. Hashtable.prototype.clear = function () {
  277. for (var i in this.hashtable) {
  278. delete this.hashtable[i];
  279. }
  280. delete this.hashtable;
  281. };
  282. Hashtable.prototype.containsKey = function (key) {
  283. var exists = false;
  284. for (var i in this.hashtable) {
  285. if (i == key && this.hashtable[i] != null) {
  286. exists = true;
  287. break;
  288. }
  289. }
  290. return exists;
  291. };
  292. Hashtable.prototype.containsValue = function(value) {
  293. var contains = false;
  294. if (value != null) {
  295. for (var i in this.hashtable) {
  296. if (this.hashtable[i] == value) {
  297. contains = true;
  298. break;
  299. }
  300. }
  301. }
  302. return contains;
  303. };
  304. Hashtable.prototype.get = function(key) {
  305. return this.hashtable[key];
  306. };
  307. Hashtable.prototype.isEmpty = function() {
  308. for (var i in this.hashtable) {
  309. if (this.hashtable[i] != null)
  310. return false;
  311. }
  312. return true;
  313. };
  314. Hashtable.prototype.keys = function() {
  315. var keys = new Array();
  316. for (var i in this.hashtable) {
  317. if (this.hashtable[i] != null)
  318. keys.push(i);
  319. }
  320. return keys;
  321. };
  322. Hashtable.prototype.put = function(key, value) {
  323. if (key == null || value == null) {
  324. throw 'NullPointerException {' + key + '},{' + value + '}';
  325. } else {
  326. this.hashtable[key] = value;
  327. }
  328. };
  329. Hashtable.prototype.remove = function(key) {
  330. var tmp_previous;
  331. if (typeof (this.hashtable[key]) != 'undefined') {
  332. tmp_previous = this.hashtable[key];
  333. delete this.hashtable[key];
  334. }
  335. return tmp_previous;
  336. };
  337. Hashtable.prototype.size = function() {
  338. var size = 0;
  339. for (var i in this.hashtable) {
  340. if (this.hashtable[i] != null)
  341. size++;
  342. }
  343. return size;
  344. };
  345. Hashtable.prototype.toString = function () {
  346. var result = '';
  347. for (var i in this.hashtable) {
  348. if (this.hashtable[i] != null)
  349. result += '{' + i + '},{' + this.hashtable[i] + '}\n';
  350. }
  351. return result;
  352. };
  353. Hashtable.prototype.values = function() {
  354. var values = new Array();
  355. for (var i in this.hashtable) {
  356. if (this.hashtable[i] != null)
  357. values.push(this.hashtable[i]);
  358. }
  359. return values;
  360. };
  361. GoldenRtWeb.HashTable = Hashtable;
  362. } ();
  363. /*DataPrompt*/
  364. !function () {
  365. var DataPrompt = function () {
  366. this.promptEnum = null;
  367. this.accType = null;
  368. };
  369. DataPrompt.prototype.parseXML = function (resultXML) {
  370. var node = GoldenRtWeb.selectSingleNode(resultXML, "xf:promptEnum");
  371. if (node)
  372. this.promptEnum = GoldenRtWeb.getnodeText(node);
  373. else
  374. this.promptEnum = null;
  375. node = GoldenRtWeb.selectSingleNode(resultXML, "xf:AccType");
  376. if (node)
  377. this.accType = GoldenRtWeb.getnodeText(node);
  378. else
  379. this.accType = null;
  380. };
  381. DataPrompt.prototype.toXML = function () {
  382. var xml = [];
  383. xml.push('<DataPrompt>');
  384. if (this.promptEnum != null) {
  385. xml.push('<promptEnum>');
  386. xml.push(this.accType);
  387. xml.push('</promptEnum>');
  388. }
  389. if (this.accType != null) {
  390. xml.push('<AccType>');
  391. xml.push(this.promptEnum);
  392. xml.push('</AccType>');
  393. }
  394. xml.push('</DataPrompt>');
  395. return xml;
  396. };
  397. GoldenRtWeb.DataPrompt = DataPrompt;
  398. } ();
  399. /*Col*/
  400. !function () {
  401. var Col = function () {
  402. this.key = null;
  403. this.type = null;
  404. this.value = null;
  405. this.resultCode = null;
  406. this.errMess = null;
  407. this.isXML = false;
  408. };
  409. Col.prototype.isOK = function () {
  410. return GoldenRtWeb.ResultCode.isOK(this.resultCode);
  411. };
  412. Col.prototype.isErr = function () {
  413. return !this.isOK();
  414. };
  415. Col.prototype.toXML = function () {
  416. var xml = [];
  417. xml.push('<a:anyType ');
  418. if (this.value != null) {
  419. if (this.isXML === true) {
  420. xml.push('i:type="');
  421. xml.push("ColOfXmlElementey10qY8E");
  422. xml.push('"');
  423. }
  424. else if (this.type != null) {
  425. xml.push('i:type="');
  426. xml.push(this.type);
  427. xml.push('"');
  428. }
  429. else {
  430. var valtype = typeof (this.value);
  431. switch (valtype)
  432. {
  433. case "string":
  434. xml.push('i:type="ColOfstring"');
  435. break;
  436. case "boolean":
  437. xml.push('i:type="ColOfboolean"');
  438. break;
  439. case "number":
  440. if (Math.floor(this.value) == this.value)
  441. xml.push('i:type="ColOfint"');
  442. else
  443. xml.push('i:type="ColOffloat"');
  444. break;
  445. case "object":
  446. if (this.value instanceof GoldenRtWeb.Tab)
  447. xml.push('i:type="ColOfTabS6l8apdU"');
  448. else if (this.value instanceof GoldenRtWeb.RtItemDefine)
  449. xml.push('i:type="ColOfRtItemDefineWWCtA6hf"');
  450. break;
  451. }
  452. }
  453. }
  454. else {
  455. xml.push('i:type="NullCol"');
  456. }
  457. xml.push('>');
  458. if (this.key != null) {
  459. xml.push('<Key>');
  460. xml.push(this.key);
  461. xml.push('</Key>');
  462. }
  463. if (this.resultCode != null) {
  464. xml.push("<ResultCode>");
  465. xml.push(this.resultCode);
  466. xml.push("</ResultCode>");
  467. }
  468. if (this.dataPrompt != null) {
  469. xml = xml.concat(this.dataPrompt.toXML());
  470. }
  471. if (this.value != null) {
  472. xml.push('<Value>');
  473. if (this.value instanceof GoldenRtWeb.Tab) {
  474. var tabXML = this.value.toXML();
  475. if (tabXML.length > 2) {
  476. tabXML = tabXML.slice(1, tabXML.length - 1)
  477. xml = xml.concat(tabXML);
  478. }
  479. }
  480. else if (this.value instanceof GoldenRtWeb.RtItemDefine) {
  481. xml = xml.concat(this.value.toXML());
  482. }
  483. else
  484. xml.push(this.value);
  485. xml.push('</Value>');
  486. }
  487. xml.push(' </a:anyType>');
  488. return xml;
  489. };
  490. Col.prototype.parseVal =function(xmlValue)
  491. {
  492. var valType = GoldenRtWeb.getnodeAttValue(xmlValue, "i:type");
  493. if(!valType)
  494. return null;
  495. var val = null;
  496. switch (valType)
  497. {
  498. case "ColOfstring":
  499. val = GoldenRtWeb.getnodeText(xmlValue);
  500. break;
  501. case "ColOfboolean":
  502. strValue = GoldenRtWeb.getnodeText(xmlValue).toLowerCase();
  503. if (strValue == "true")
  504. val = true;
  505. else if (strValue == "false")
  506. val = false;
  507. else if (strValue == "1" || strValue == "-1")
  508. val = true;
  509. else
  510. val = false;
  511. break;
  512. case "ColOfbyte":
  513. case "ColOfshort":
  514. case "ColOfint":
  515. case "ColOfunsignedByte":
  516. case "ColOfunsignedShort":
  517. case "ColOfunsignedInt":
  518. case "ColOflong":
  519. case "ColOfunsignedLong":
  520. val = parseInt(GoldenRtWeb.getnodeText(xmlValue));
  521. break;
  522. case "ColOffloat":
  523. case "ColOfdouble":
  524. case "ColOfdecimal":
  525. val = parseFloat(GoldenRtWeb.getnodeText(xmlValue));
  526. break;
  527. case "ColOfdateTime":
  528. val = Date.parse(GoldenRtWeb.getnodeText(xmlValue));
  529. break;
  530. case "ColOfTabS6l8apdU":
  531. var tab = new GoldenRtWeb.Tab();
  532. tab.parseXML(xmlValue);
  533. val = tab;
  534. break;
  535. case "ColOfXmlElementey10qY8E":
  536. this.value = xmlValue.firstChild;
  537. this.isXML = true;
  538. break;
  539. default:
  540. if(valType.indexOf("VQT") >= 0)
  541. {
  542. var vqt = new GoldenRtWeb.VQT();
  543. vqt.parseXML(xmlValue);
  544. val = vqt;
  545. }
  546. break;
  547. }
  548. return val;
  549. };
  550. Col.prototype.parseXML = function (resultXML) {
  551. if (resultXML == null) {
  552. this.resultCode = null;
  553. this.errMess = null;
  554. this.key = null;
  555. this.dataPrompt = null;
  556. this.type = null;
  557. this.value = null;
  558. return;
  559. }
  560. this.type = GoldenRtWeb.getnodeAttValue(resultXML, "i:type");
  561. var node = GoldenRtWeb.selectSingleNode(resultXML, "xf:ResultCode");
  562. if (node)
  563. this.resultCode = GoldenRtWeb.getnodeText(node);
  564. else
  565. this.resultCode = GoldenRtWeb.ResultCode.S_NONE;
  566. node = GoldenRtWeb.selectSingleNode(resultXML, "xf:Key");
  567. if (node)
  568. this.key = GoldenRtWeb.getnodeText(node);
  569. else
  570. this.key = null;
  571. node = GoldenRtWeb.selectSingleNode(resultXML, "xf:ErrMess");
  572. if (node)
  573. this.errMess = GoldenRtWeb.getnodeText(node);
  574. else
  575. this.errMess = null;
  576. var xmlDataPrompt = GoldenRtWeb.selectSingleNode(resultXML, "DataPrompt");
  577. if (xmlDataPrompt) {
  578. if (this.dataPrompt == null)
  579. this.dataPrompt = new GoldenRtWeb.DataPrompt();
  580. this.dataPrompt.parseXML(xmlDataPrompt);
  581. }
  582. else
  583. this.dataPrompt = null;
  584. var xmlValue = GoldenRtWeb.selectSingleNode(resultXML, "xf:Value");
  585. if (xmlValue) {
  586. switch (this.type) {
  587. case "ColOfstring":
  588. this.value = GoldenRtWeb.getnodeText(xmlValue);
  589. break;
  590. case "ColOfboolean":
  591. strValue = GoldenRtWeb.getnodeText(xmlValue).toLowerCase();
  592. if (strValue == "true")
  593. this.value = true;
  594. else if (strValue == "false")
  595. this.value = false;
  596. else if (strValue == "1" || strValue == "-1")
  597. this.value = true;
  598. else
  599. this.value = false;
  600. break;
  601. case "ColOfXmlElementey10qY8E":
  602. this.value = xmlValue.firstChild;
  603. this.isXML = true;
  604. break;
  605. case "ColOfbyte":
  606. case "ColOfshort":
  607. case "ColOfint":
  608. case "ColOfunsignedByte":
  609. case "ColOfunsignedShort":
  610. case "ColOfunsignedInt":
  611. case "ColOflong":
  612. case "ColOfunsignedLong":
  613. this.value = parseInt(GoldenRtWeb.getnodeText(xmlValue));
  614. break;
  615. case "ColOffloat":
  616. case "ColOfdouble":
  617. case "ColOfdecimal":
  618. this.value = parseFloat(GoldenRtWeb.getnodeText(xmlValue));
  619. break;
  620. case "ColOfdateTime":
  621. this.value = Date.parse(GoldenRtWeb.getnodeText(xmlValue));
  622. break;
  623. case "ColOfTabS6l8apdU":
  624. var tab = new GoldenRtWeb.Tab();
  625. tab.parseXML(xmlValue);
  626. this.value = tab;
  627. break;
  628. case "ColOfanyType":
  629. var valtype = GoldenRtWeb.getnodeAttValue(xmlValue, "i:type");
  630. if(valtype && valtype.indexOf("VQT") >= 0)
  631. {
  632. var vqt = new GoldenRtWeb.VQT();
  633. vqt.parseXML(xmlValue);
  634. this.value = vqt;
  635. }
  636. break;
  637. case "ColOfArrayOfanyTypeuHEDJ7Dj":
  638. this.value = [];
  639. var vals = GoldenRtWeb.selectNodes(xmlValue, "xsa:anyType");
  640. if(vals && vals.length > 0)
  641. {
  642. for (var i = 0; i < vals.length; i++) {
  643. var val = vals[i];
  644. if(val == null)
  645. console.log('null');
  646. this.value.push(this.parseVal(val));
  647. }
  648. }
  649. break;
  650. case "ColOfXmlElementey10qY8E":
  651. this.value = xmlValue.firstChild;
  652. this.isXML = true;
  653. break;
  654. default:
  655. break;
  656. }
  657. }
  658. else
  659. this.value = null;
  660. };
  661. GoldenRtWeb.Col = Col;
  662. } ();
  663. /*Row*/
  664. !function () {
  665. var Row = function () {
  666. this.resultCode = null;
  667. this.errMess = null;
  668. this.Cols = [];
  669. };
  670. Row.prototype.isOK = function () {
  671. return GoldenRtWeb.ResultCode.isOK(this.resultCode);
  672. };
  673. Row.prototype.isErr = function () {
  674. return !this.isOK();
  675. };
  676. Row.prototype.addCol = function (col) {
  677. //if (col.key != null)
  678. // this.Cols[col.key] = col;
  679. //else
  680. this.Cols.push(col);
  681. };
  682. Row.prototype.toXML = function (resultXML) {
  683. var xml = [];
  684. xml.push('<Row>');
  685. if (this.resultCode != null) {
  686. xml.push("<ResultCode>");
  687. xml.push(this.resultCode);
  688. xml.push("</ResultCode>");
  689. }
  690. if (this.Cols) {
  691. xml.push('<Cols xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays">');
  692. for (k in this.Cols)
  693. xml = xml.concat(this.Cols[k].toXML());
  694. xml.push("</Cols>");
  695. }
  696. xml.push('</Row>');
  697. return xml;
  698. };
  699. Row.prototype.parseXML = function (resultXML) {
  700. if (resultXML == null) {
  701. this.resultCode = null;
  702. this.errMess = null;
  703. this.Cols = null;
  704. return;
  705. }
  706. var node = GoldenRtWeb.selectSingleNode(resultXML, "xf:ResultCode");
  707. if (node)
  708. this.resultCode = GoldenRtWeb.getnodeText(node);
  709. else
  710. this.resultCode = GoldenRtWeb.ResultCode.S_NONE;
  711. var node = GoldenRtWeb.selectSingleNode(resultXML, "xf:ErrMess");
  712. if (node)
  713. this.errMess = GoldenRtWeb.getnodeText(node);
  714. else
  715. this.errMess = null;
  716. var Cols = GoldenRtWeb.selectNodes(resultXML, "xf:Cols/xsa:anyType");
  717. if (Cols || Cols.length > 0) {
  718. for (var i = 0; i < Cols.length; i++) {
  719. var xmlCol = Cols[i];
  720. var col = this.findCol(xmlCol);
  721. if (col == null) {
  722. col = new GoldenRtWeb.Col();
  723. col.parseXML(xmlCol);
  724. this.addCol(col);
  725. }
  726. else
  727. col.parseXML(xmlCol);
  728. }
  729. }
  730. else
  731. this.Cols = null;
  732. };
  733. Row.prototype.findCol = function (colXML) {
  734. var node = GoldenRtWeb.selectSingleNode(colXML, "xf:Key");
  735. if (node) {
  736. var key = GoldenRtWeb.getnodeText(node);
  737. if (key) {
  738. var col = this.Cols[key];
  739. if (col)
  740. return col;
  741. }
  742. return this.getColByName(key);
  743. }
  744. else
  745. return null;
  746. };
  747. Row.prototype.getColByName = function (key) {
  748. if (!this.Cols)
  749. return null;
  750. var skey = key.toLowerCase();
  751. for (i in this.Cols) {
  752. var col = this.Cols[i];
  753. if (col && col.key && col.key.toLowerCase() === skey)
  754. return col;
  755. }
  756. return null;
  757. };
  758. GoldenRtWeb.Row = Row;
  759. } ();
  760. /*Identity*/
  761. !function()
  762. {
  763. var Identity = function () {
  764. this.prompt = null;
  765. this.Id = null;
  766. this.propId = null;
  767. this.uri = null;
  768. this.accType = null;
  769. };
  770. Identity.prototype.toXML= function () {
  771. var xml = [];
  772. xml.push('<Identity>');
  773. if (this.prompt != null)
  774. {
  775. xml.push('<Prompt>');
  776. xml.push(this.prompt);
  777. xml.push('</Prompt>');
  778. }
  779. if (this.Id != null)
  780. {
  781. xml.push('<Id>');
  782. xml.push(this.Id);
  783. xml.push('</Id>');
  784. }
  785. if (this.propId != null)
  786. {
  787. xml.push('<PropId>');
  788. xml.push(this.propId);
  789. xml.push('</PropId>');
  790. }
  791. if (this.uri != null)
  792. {
  793. xml.push('<URI>');
  794. xml.push(this.uri);
  795. xml.push('</URI>');
  796. }
  797. if (this.accType != null)
  798. {
  799. xml.push('<AccType>');
  800. xml.push(this.accType);
  801. xml.push('</AccType>');
  802. }
  803. xml.push('</Identity>');
  804. return xml;
  805. };
  806. GoldenRtWeb.Identity = Identity;
  807. } ();
  808. /*Tab*/
  809. !function () {
  810. var Tab = function () {
  811. this.resultCode = null;
  812. this.errMess = null;
  813. this.errSource = null;
  814. this.clientHandle = null;
  815. this.InfoSet = null;
  816. this.URI = null;
  817. this.identity = null;
  818. this.Rows = [];
  819. this.clearRowOnLoad = false;
  820. };
  821. Tab.prototype.isOK = function () {
  822. return GoldenRtWeb.ResultCode.isOK(this.resultCode);
  823. };
  824. Tab.prototype.isErr = function () {
  825. return !this.isOK();
  826. };
  827. Tab.prototype.findRow = function (rowXML) {
  828. return null;
  829. };
  830. Tab.prototype.addRow = function (row) {
  831. row.Tab = this;
  832. this.Rows.push(row);
  833. };
  834. Tab.prototype.toXML = function () {
  835. var xml = [];
  836. xml.push('<Tab>');
  837. if (this.URI != null) {
  838. xml.push('<URI>');
  839. xml.push(this.URI);
  840. xml.push('</URI>');
  841. }
  842. if (this.clientHandle != null) {
  843. xml.push('<ClientHandle>');
  844. xml.push(this.clientHandle);
  845. xml.push('</ClientHandle>');
  846. }
  847. if (this.resultCode != null) {
  848. xml.push("<ResultCode>");
  849. xml.push(this.resultCode);
  850. xml.push("</ResultCode>");
  851. }
  852. if (this.identity != null)
  853. xml = xml.concat(this.identity.toXML());
  854. if (this.Rows != null && this.Rows.length > 0) {
  855. xml.push("<Rows>");
  856. for (k in this.Rows)
  857. xml = xml.concat(this.Rows[k].toXML());
  858. xml.push("</Rows>");
  859. }
  860. xml.push('</Tab>');
  861. return xml;
  862. };
  863. Tab.prototype.parseXML = function (resultXML) {
  864. if (resultXML == null) {
  865. this.resultCode = null;
  866. this.errMess = null;
  867. this.errorSource = null;
  868. this.costMsec = 0;
  869. this.cursorPos = 0;
  870. this.totalCount = 0;
  871. this.clientHandle = null;
  872. this.Rows = [];
  873. return;
  874. }
  875. var node = GoldenRtWeb.selectSingleNode(resultXML, "xf:ResultCode");
  876. if (node)
  877. this.resultCode = GoldenRtWeb.getnodeText(node);
  878. else
  879. this.resultCode = ResultCode.S_NONE;
  880. node = GoldenRtWeb.selectSingleNode(resultXML, "xf:ErrMess");
  881. if (node)
  882. this.errMess = GoldenRtWeb.getnodeText(node);
  883. else
  884. this.errMess = null;
  885. node = GoldenRtWeb.selectSingleNode(resultXML, "xf:ErrorSource");
  886. if (node)
  887. this.errorSource = GoldenRtWeb.getnodeText(node);
  888. else
  889. this.errorSource = null;
  890. node = GoldenRtWeb.selectSingleNode(resultXML, "xf:CostMsec");
  891. if (node)
  892. this.costMsec = parseInt(GoldenRtWeb.getnodeText(node));
  893. else
  894. this.costMsec = 0;
  895. node = GoldenRtWeb.selectSingleNode(resultXML, "xf:CursorPos");
  896. if (node)
  897. this.cursorPos = parseInt(GoldenRtWeb.getnodeText(node));
  898. else
  899. this.cursorPos = 0;
  900. node = GoldenRtWeb.selectSingleNode(resultXML, "xf:TotalCount");
  901. if (node)
  902. this.totalCount = parseInt(GoldenRtWeb.getnodeText(node));
  903. else
  904. this.totalCount = 0;
  905. var clienthandle = GoldenRtWeb.selectSingleNode(resultXML, "xf:ClientHandle");
  906. if (clienthandle)
  907. this.clientHandle = GoldenRtWeb.getnodeText(clienthandle);
  908. else
  909. this.clientHandle = null;
  910. var uri = GoldenRtWeb.selectSingleNode(resultXML, "xf:URI");
  911. if (uri)
  912. this.URI = GoldenRtWeb.getnodeText(uri);
  913. else
  914. this.URI = null;
  915. var xmlRows = GoldenRtWeb.selectNodes(resultXML, "xf:Rows/xf:Row");
  916. var bLoadRow = false;
  917. if (this.clearRowOnLoad === true)
  918. this.Rows = [];
  919. else if (this.Rows.length == 1 && xmlRows && xmlRows.length == 1)
  920. bLoadRow = true;
  921. if (xmlRows && xmlRows.length > 0) {
  922. for (var i = 0; i < xmlRows.length; i++) {
  923. var xmlRow = xmlRows[i];
  924. var row;
  925. if (bLoadRow) {
  926. row = this.Rows[0];
  927. row.parseXML(xmlRow);
  928. }
  929. else {
  930. row = this.findRow(xmlRow);
  931. if (row == null) {
  932. row = new GoldenRtWeb.Row();
  933. row.parseXML(xmlRow);
  934. this.addRow(row);
  935. }
  936. }
  937. }
  938. }
  939. };
  940. GoldenRtWeb.Tab = Tab;
  941. } ();
  942. /*InfoSet*/
  943. !function () {
  944. var InfoSet = function () {
  945. this.Tabs = [];
  946. this.resultCode = null;
  947. this.costMsec = 0;
  948. this.cursorPos = 0;
  949. this.totalCount = 0;
  950. this.errMess = null;
  951. this.errSource = null;
  952. };
  953. InfoSet.prototype.isOK = function () {
  954. return GoldenRtWeb.ResultCode.isOK(this.resultCode);
  955. };
  956. InfoSet.prototype.isErr = function () {
  957. return !this.isOK();
  958. };
  959. InfoSet.prototype.addTab = function (tab) {
  960. tab.InfoSet = this;
  961. this.Tabs.push(tab);
  962. };
  963. InfoSet.prototype.toXML = function () {
  964. var xml = [];
  965. xml.push("<InfoSet>");
  966. if (this.resultCode != null) {
  967. xml.push("<ResultCode>");
  968. xml.push(this.resultCode);
  969. xml.push("</ResultCode>");
  970. }
  971. if (this.Tabs != null && this.Tabs.length > 0) {
  972. xml.push("<Tabs>");
  973. for (k in this.Tabs)
  974. xml = xml.concat(this.Tabs[k].toXML());
  975. xml.push("</Tabs>");
  976. }
  977. xml.push("</InfoSet>");
  978. return xml;
  979. };
  980. InfoSet.prototype.parseXML = function (resultXML) {
  981. if (resultXML == null) {
  982. this.resultCode = GoldenRtWeb.ResultCode.E_SERVICERESULTERR;
  983. this.errMess = "服务没有返回有效的XML数据。";
  984. this.errorSource = "GoldenRtWebService";
  985. return;
  986. }
  987. GoldenRtWeb.setNs(resultXML);
  988. var infoset = GoldenRtWeb.selectSingleNode(resultXML, "//xf:InfoSet");
  989. if (infoset) {
  990. var node = GoldenRtWeb.selectSingleNode(resultXML, "xf:ResultCode");
  991. if (node)
  992. this.resultCode = GoldenRtWeb.getnodeText(node);
  993. else
  994. this.resultCode = GoldenRtWeb.ResultCode.S_NONE;
  995. node = GoldenRtWeb.selectSingleNode(resultXML, "xf:ErrMess");
  996. if (node)
  997. this.errMess = GoldenRtWeb.getnodeText(node);
  998. else
  999. this.errMess = null;
  1000. node = GoldenRtWeb.selectSingleNode(resultXML, "xf:ErrorSource");
  1001. if (node)
  1002. this.errorSource = GoldenRtWeb.getnodeText(node);
  1003. else
  1004. this.errorSource = null;
  1005. node = GoldenRtWeb.selectSingleNode(resultXML, "xf:CostMsec");
  1006. if (node)
  1007. this.costMsec = parseInt(GoldenRtWeb.getnodeText(node));
  1008. else
  1009. this.costMsec = 0;
  1010. node = GoldenRtWeb.selectSingleNode(resultXML, "xf:CursorPos");
  1011. if (node)
  1012. this.cursorPos = parseInt(GoldenRtWeb.getnodeText(node));
  1013. else
  1014. this.cursorPos = 0;
  1015. node = GoldenRtWeb.selectSingleNode(resultXML, "xf:TotalCount");
  1016. if (node)
  1017. this.totalCount = parseInt(GoldenRtWeb.getnodeText(node));
  1018. else
  1019. this.totalCount = 0;
  1020. var Tabs = GoldenRtWeb.selectNodes(infoset, "xf:Tabs/xf:Tab");
  1021. if (Tabs && Tabs.length) {
  1022. for (var i = 0; i < Tabs.length; i++) {
  1023. var xmlTab = Tabs[i];
  1024. var tab;
  1025. if (i < this.Tabs.length)
  1026. tab = this.Tabs[i];
  1027. else {
  1028. tab = new GoldenRtWeb.Tab();
  1029. this.addTab(tab);
  1030. }
  1031. tab.parseXML(xmlTab);
  1032. }
  1033. }
  1034. }
  1035. else {
  1036. this.resultCode = GoldenRtWeb.ResultCode.E_SERVICERESULTERR;
  1037. this.errMess = "服务没有返回有效的InfoSet数据。";
  1038. this.errorSource = "GoldenRtWebService";
  1039. }
  1040. };
  1041. GoldenRtWeb.InfoSet = InfoSet;
  1042. } ();
  1043. /*RtItemDefine*/
  1044. !function () {
  1045. var RtItemDefine = function (entityId, propId, metaId) {
  1046. this.entityId = entityId;
  1047. this.propId = propId;
  1048. this.metaId = metaId;
  1049. this.dataMethod = null;
  1050. this.beginTime = null;
  1051. this.endTime = null;
  1052. this.slotTime = 0;
  1053. };
  1054. RtItemDefine.prototype.toXML = function () {
  1055. var xml = [];
  1056. xml.push("<EntityID>");
  1057. xml.push(this.entityId);
  1058. xml.push("</EntityID>");
  1059. xml.push("<PropID>");
  1060. xml.push(this.propId);
  1061. xml.push("</PropID>");
  1062. xml.push("<MetaID>");
  1063. xml.push(this.metaId);
  1064. xml.push("</MetaID>");
  1065. if (this.dataMethod) {
  1066. xml.push("<DataMethod>");
  1067. xml.push(this.dataMethod);
  1068. xml.push("</DataMethod>");
  1069. }
  1070. if (this.beginTime != null) {
  1071. xml.push("<BeginTime>");
  1072. xml.push(this.beginTime);
  1073. xml.push("</BeginTime>");
  1074. }
  1075. if (this.endTime != null) {
  1076. xml.push("<EndTime>");
  1077. xml.push(this.endTime);
  1078. xml.push("</EndTime>");
  1079. }
  1080. if (this.slotTime != null)
  1081. {
  1082. xml.push("<TimeSlot>");
  1083. xml.push(Math.floor(this.slotTime));
  1084. xml.push("</TimeSlot>");
  1085. }
  1086. return xml;
  1087. };
  1088. GoldenRtWeb.RtItemDefine = RtItemDefine;
  1089. } ();
  1090. /*VQT*/
  1091. !function () {
  1092. var VQT = function () {
  1093. this.type = null;
  1094. this.entityId = 0;
  1095. this.propId = 0;
  1096. this.metaId = 0;
  1097. this.qua = 0;
  1098. this.stampTime = 0;
  1099. this.value = null;
  1100. this.errMess = null;
  1101. };
  1102. VQT.prototype.parseXML = function (vqtXML) {
  1103. this.type = GoldenRtWeb.getnodeAttValue(vqtXML, "i:type");
  1104. var node = GoldenRtWeb.selectSingleNode(vqtXML, "xf:EntityId");
  1105. if (node)
  1106. this.entityId = parseInt(GoldenRtWeb.getnodeText(node));
  1107. else
  1108. this.entityId = 0;
  1109. node = GoldenRtWeb.selectSingleNode(vqtXML, "xf:PropId");
  1110. if (node)
  1111. this.propId = parseInt(GoldenRtWeb.getnodeText(node));
  1112. else
  1113. this.propId = 0;
  1114. node = GoldenRtWeb.selectSingleNode(vqtXML, "xf:MetaId");
  1115. if (node)
  1116. this.metaId = parseInt(GoldenRtWeb.getnodeText(node));
  1117. else
  1118. this.metaId = 0;
  1119. node = GoldenRtWeb.selectSingleNode(vqtXML, "xf:Qua");
  1120. if (node)
  1121. this.qua = parseInt(GoldenRtWeb.getnodeText(node));
  1122. else
  1123. this.qua = 0;
  1124. node = GoldenRtWeb.selectSingleNode(vqtXML, "xf:StampTime");
  1125. if (node)
  1126. this.stampTime = parseInt(GoldenRtWeb.getnodeText(node));
  1127. else
  1128. this.stampTime = 0;
  1129. node = GoldenRtWeb.selectSingleNode(vqtXML, "xf:ErrMess");
  1130. if (node)
  1131. this.errMess = GoldenRtWeb.getnodeText(node);
  1132. else
  1133. this.errMess = null;
  1134. var xmlValue = GoldenRtWeb.selectSingleNode(vqtXML, "xf:Value");
  1135. if (xmlValue) {
  1136. strValue = GoldenRtWeb.getnodeText(xmlValue);
  1137. if (strValue) {
  1138. switch (this.type) {
  1139. case "VQTOfstring":
  1140. this.value = strValue;
  1141. break;
  1142. case "VQTOfboolean":
  1143. strValue = strValue.toLowerCase();
  1144. if (strValue == "true")
  1145. this.value = true;
  1146. else if (strValue == "false")
  1147. this.value = false;
  1148. else if (strValue == "1" || strValue == "-1")
  1149. this.value = true;
  1150. else
  1151. this.value = false;
  1152. break;
  1153. case "VQTOfbyte":
  1154. case "VQTOfshort":
  1155. case "VQTOfint":
  1156. case "VQTOfunsignedByte":
  1157. case "VQTOfunsignedShort":
  1158. case "VQTOfunsignedInt":
  1159. case "VQTOflong":
  1160. case "VQTOfunsignedLong":
  1161. this.value = parseInt(strValue);
  1162. break;
  1163. case "VQTOffloat":
  1164. case "VQTOfdouble":
  1165. case "VQTOfdecimal":
  1166. this.value = parseFloat(strValue);
  1167. break;
  1168. case "VQTOfdateTime":
  1169. this.value = Date.parse(strValue);
  1170. break;
  1171. case "VQTOfTabS6l8apdU":
  1172. var tab = new GoldenRtWeb.Tab();
  1173. tab.parseXML(xmlValue);
  1174. this.value = tab;
  1175. break;
  1176. case "VQTOfanyType":
  1177. var vqt = new GoldenRtWeb.VQT();
  1178. vqt.parseXML(xmlValue);
  1179. this.value = vqt;
  1180. break;
  1181. default:
  1182. this.errMess = "无法识别的数据类型:" + this.type;
  1183. break;
  1184. }
  1185. }
  1186. }
  1187. };
  1188. VQT.prototype.getQuaStr = function () {
  1189. var re = "";
  1190. switch(this.qua)
  1191. {
  1192. case 0: //
  1193. re = "正常";
  1194. break;
  1195. case 1:
  1196. re = "无数据";
  1197. break;
  1198. case 2:
  1199. re = "创建";
  1200. break;
  1201. case 3:
  1202. re = "停机";
  1203. break;
  1204. case 4:
  1205. re = "计算停止";
  1206. break;
  1207. case 5:
  1208. re = "坏点";
  1209. break;
  1210. case 6:
  1211. re = "被零除";
  1212. break;
  1213. case 7:
  1214. re = "已被删除";
  1215. break;
  1216. default:
  1217. if (this.qua & 0x0100) // 从0x0100至0x01FF为OPC质量码
  1218. {
  1219. switch (this.qua & 0xFC) {
  1220. case 0x00:
  1221. re = "坏值";
  1222. break;
  1223. case 0x04:
  1224. re = "坏值(组态错误)";
  1225. break;
  1226. case 0x08:
  1227. re = "坏值(没有连接)";
  1228. break;
  1229. case 0x0C:
  1230. re = "坏值(设备故障)";
  1231. break;
  1232. case 0x10:
  1233. re = "坏值(传感器故障)";
  1234. break;
  1235. case 0x14:
  1236. re = "坏值(最后值)";
  1237. break;
  1238. case 0x18:
  1239. re = "坏值(通讯故障)";
  1240. break;
  1241. case 0x1C:
  1242. re = "坏值(退出服务)";
  1243. break;
  1244. case 0x20:
  1245. re = "坏值(不被许可)";
  1246. break;
  1247. case 0x24:
  1248. re = "坏值(超出量程)";
  1249. break;
  1250. case 0x2C:
  1251. re = "坏值(未定义值)";
  1252. break;
  1253. case 0x28:
  1254. re = "坏值(计算错误)";
  1255. break;
  1256. case 0x30:
  1257. re = "坏值(输出开路)";
  1258. break;
  1259. case 0x34:
  1260. re = "坏值(输入开路)";
  1261. break;
  1262. case 0x3C:
  1263. re = "坏值(转换错误)";
  1264. break;
  1265. case 0x40:
  1266. re = "坏值(可疑值)";
  1267. break;
  1268. case 0x44:
  1269. re = "可疑值(最后值)";
  1270. break;
  1271. case 0x48:
  1272. re = "可疑值(输出开路)";
  1273. break;
  1274. case 0x4C:
  1275. re = "可疑值(等待同步)";
  1276. break;
  1277. case 0x50:
  1278. re = "可疑值(传感器校正)";
  1279. break;
  1280. case 0x54:
  1281. re = "可疑值(超出量程)";
  1282. break;
  1283. case 0x58:
  1284. re = "可疑值(子故障)";
  1285. break;
  1286. case 0x5C:
  1287. re = "可疑值(输入开路)";
  1288. break;
  1289. case 0x60:
  1290. re = "可疑值(转换错误)";
  1291. break;
  1292. case 0xC0:
  1293. re = "正常";
  1294. break;
  1295. case 0xC4:
  1296. re = "正常(初始化)";
  1297. break;
  1298. case 0xC4:
  1299. re = "正常(无状态)";
  1300. break;
  1301. case 0xD8:
  1302. re = "正常(当地重载)";
  1303. break;
  1304. }
  1305. }
  1306. else {
  1307. re = "用户自定义";
  1308. }
  1309. break;
  1310. }
  1311. return re;
  1312. };
  1313. VQT.prototype.getStampTimeStr = function (withoutMS) {
  1314. return GoldenRtWeb.FileTimeToString(this.stampTime, withoutMS);
  1315. };
  1316. VQT.prototype.getFullStampTimeStr = function (withoutMS) {
  1317. return GoldenRtWeb.FileFullTimeToString(this.stampTime, withoutMS);
  1318. };
  1319. VQT.prototype.isGood = function () {
  1320. return (this.qua == 0 || ((this.qua & 0x100) && (this.qua & 0xc0) == 0xc0));
  1321. };
  1322. VQT.prototype.isUncertain = function () {
  1323. return false;
  1324. };
  1325. VQT.prototype.isBad = function () {
  1326. return !this.isGood();
  1327. };
  1328. VQT.prototype.isFloat = function () {
  1329. return (this.type == "VQTOffloat" || this.type == "VQTOfdouble" || this.type == "VQTOfdecimal");
  1330. };
  1331. VQT.prototype.isBoolen = function () {
  1332. return this.type == "VQTOfboolean";
  1333. };
  1334. VQT.prototype.isString = function () {
  1335. return this.type == "VQTOfstring";
  1336. };
  1337. VQT.prototype.isInt = function () {
  1338. if (!this.type)
  1339. return false;
  1340. switch (this.type) {
  1341. case 'VQTOfbyte':
  1342. case 'VQTOfint':
  1343. case "VQTOflong":
  1344. case "VQTOfshort":
  1345. case "VQTOfunsignedByte":
  1346. case "VQTOfunsignedInt":
  1347. case "VQTOfunsignedLong":
  1348. case "VQTOfunsignedShort":
  1349. return true;
  1350. }
  1351. return false;
  1352. };
  1353. VQT.prototype.isDate = function () {
  1354. return this.type == "VQTOfdateTime";
  1355. };
  1356. VQT.prototype.GetNumber = function () {
  1357. if(this.isString())
  1358. {
  1359. var hash = 0;
  1360. if (!this.value || !this.value.length) return hash;
  1361. for (i = 0; i < this.value.length; i++) {
  1362. char = this.value.charCodeAt(i);
  1363. hash = ((hash<<5)-hash)+char;
  1364. hash = hash & hash;
  1365. }
  1366. return hash;
  1367. }
  1368. else if(this.isBoolen())
  1369. {
  1370. if(this.value)
  1371. return 1;
  1372. else
  1373. return 0;
  1374. }
  1375. else if(this.isDate())
  1376. {
  1377. return this.value.getTime();
  1378. }
  1379. else
  1380. return this.value;
  1381. };
  1382. GoldenRtWeb.VQT = VQT;
  1383. } ();
  1384. /*RtRefresh*/
  1385. !function () {
  1386. var RtRefresher = function (url, period) {
  1387. this.refreshTimer = null;
  1388. this.subscription = null;
  1389. this.refreshPeriod = period || 1000;
  1390. this.webURL = url;
  1391. this.seed = 1;
  1392. };
  1393. RtRefresher.prototype.clear = function () {
  1394. if (this.refreshTimer != null) {
  1395. window.clearTimeout(this.refreshTimer);
  1396. this.refreshTimer = null;
  1397. }
  1398. if (this.subscription) {
  1399. this.subscription.clear();
  1400. delete this.subscription;
  1401. }
  1402. };
  1403. RtRefresher.prototype.RegistRtPt = function (rtDef, scope, callback, opt) {
  1404. var sub = { rtDef: rtDef, scope: scope, callback: callback, opt: opt };
  1405. if (this.subscription == null)
  1406. this.subscription = new GoldenRtWeb.HashTable();
  1407. this.subscription.put(rtDef, sub);
  1408. delete this.sendXML;
  1409. if (this.refreshTimer != null) {
  1410. window.clearTimeout(this.refreshTimer);
  1411. this.refreshTimer = null;
  1412. }
  1413. var me = this;
  1414. this.refreshTimer = window.setTimeout(function () {
  1415. window.clearTimeout(me.refreshTimer);
  1416. me.refreshTimer = null;
  1417. me.RtRefresh();
  1418. me = null;
  1419. }, 10);
  1420. return rtDef;
  1421. };
  1422. RtRefresher.prototype.UnRegistRtPt = function (key) {
  1423. if (this.subscription != null) {
  1424. if (this.subscription.remove(key))
  1425. this.sendXML = null;
  1426. }
  1427. };
  1428. RtRefresher.prototype.RtRefresh = function () {
  1429. if (!this.subscription.isEmpty()) {
  1430. var hasTable = this.subscription.hashtable;
  1431. if (!this.sendXML) {
  1432. var xml = [];
  1433. for (var key in hasTable) {
  1434. var sub = hasTable[key];
  1435. if (sub.rtDef) {
  1436. xml.push(sub.rtDef);
  1437. }
  1438. }
  1439. this.sendXML = "http://" + webServiceIP + ":" + webServicePort + "/api/Snapshot?tagName=";
  1440. this.sendXML += xml.join(",");
  1441. }
  1442. for (var key in hasTable) {
  1443. var sub = hasTable[key];
  1444. if (sub.callback)
  1445. sub.callback.call(sub.scope, 'getting');
  1446. }
  1447. $.ajax(
  1448. {
  1449. url: this.sendXML,
  1450. type: "GET",
  1451. dataType: 'json',
  1452. cache: false,
  1453. complete: function (xhr, ts) {
  1454. if (xhr.token) {
  1455. xhr.token.rtRefreshed(xhr, ts);
  1456. delete xhr.token;
  1457. }
  1458. }
  1459. }).token = this;
  1460. };
  1461. RtRefresher.prototype.rtRefreshed = function (xhr, ts) {
  1462. if (this.refreshTimer) {
  1463. window.clearTimeout(this.refreshTimer);
  1464. this.refreshTimer = null;
  1465. }
  1466. if (this.subscription.isEmpty())
  1467. return;
  1468. var err = null;
  1469. var hasTable = this.subscription.hashtable;
  1470. if (ts == 'success') {
  1471. if(xhr.responseJSON && xhr.responseJSON.length)
  1472. {
  1473. for (var i in xhr.responseJSON)
  1474. {
  1475. var data = xhr.responseJSON[i];
  1476. var sub = hasTable[data.TagName];
  1477. if (sub && sub.callback) {
  1478. var date = GoldenRtWeb.DateToFileTime(new Date(data.Time));
  1479. var val = parseFloat(data.Value);
  1480. if (data.Value.indexOf('.') > 0)
  1481. val = val.toFixed(2);
  1482. if (isNaN(val))
  1483. val = data.Value;
  1484. var vqt = new GoldenRtWeb.VQT();
  1485. vqt.stampTime = date;
  1486. vqt.value = val;
  1487. vqt.errMess = data.ErrorMsg;
  1488. vqt.qua = data.Quality;
  1489. sub.callback.call(sub.scope, 'success', vqt, sub.opt);
  1490. }
  1491. }
  1492. }
  1493. }
  1494. else
  1495. err = "通讯故障:" + (xhr.statusText ? xhr.statusText : "") + "(" + xhr.status + ")";
  1496. if (err != null) {
  1497. for (var key in hasTable) {
  1498. var sub = hasTable[key];
  1499. if (sub && sub.callback)
  1500. sub.callback.call(sub.scope, 'error', err, sub.opt);
  1501. }
  1502. }
  1503. var me = this;
  1504. this.refreshTimer = window.setTimeout(function () {
  1505. window.clearTimeout(me.refreshTimer);
  1506. me.refreshTimer = null;
  1507. me.RtRefresh();
  1508. me = null;
  1509. }, this.refreshPeriod);
  1510. };
  1511. };
  1512. GoldenRtWeb.RtRefresher = RtRefresher;
  1513. } ();
  1514. /*MD5*/
  1515. !function () {
  1516. var MD5 = {
  1517. safe_add: function(x,y)
  1518. {
  1519. var lsw = (x & 0xFFFF) + (y & 0xFFFF);
  1520. var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
  1521. return (msw << 16) | (lsw & 0xFFFF);
  1522. },
  1523. bit_rol: function(num, cnt){
  1524. return (num << cnt) | (num >>> (32 - cnt));
  1525. },
  1526. md5_cmn: function (q, a, b, x, s, t){
  1527. return this.safe_add(this.bit_rol(this.safe_add(this.safe_add(a, q), this.safe_add(x, t)), s),b);
  1528. },
  1529. md5_ff: function (a, b, c, d, x, s, t){
  1530. return this.md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
  1531. },
  1532. md5_gg: function(a, b, c, d, x, s, t){
  1533. return this.md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
  1534. },
  1535. md5_hh: function (a, b, c, d, x, s, t){
  1536. return this.md5_cmn(b ^ c ^ d, a, b, x, s, t);
  1537. },
  1538. md5_ii: function (a, b, c, d, x, s, t){
  1539. return this.md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
  1540. },
  1541. core_md5: function (x, len){
  1542. x[len >> 5] |= 0x80 << ((len) % 32);
  1543. x[(((len + 64) >>> 9) << 4) + 14] = len;
  1544. var a = 1732584193;
  1545. var b = -271733879;
  1546. var c = -1732584194;
  1547. var d = 271733878;
  1548. for(var i = 0; i < x.length; i += 16){
  1549. var olda = a;
  1550. var oldb = b;
  1551. var oldc = c;
  1552. var oldd = d;
  1553. a = this.md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936);
  1554. d = this.md5_ff(d, a, b, c, x[i+ 1], 12, -389564586);
  1555. c = this.md5_ff(c, d, a, b, x[i+ 2], 17, 606105819);
  1556. b = this.md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330);
  1557. a = this.md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897);
  1558. d = this.md5_ff(d, a, b, c, x[i+ 5], 12, 1200080426);
  1559. c = this.md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341);
  1560. b = this.md5_ff(b, c, d, a, x[i+ 7], 22, -45705983);
  1561. a = this.md5_ff(a, b, c, d, x[i+ 8], 7 , 1770035416);
  1562. d = this.md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417);
  1563. c = this.md5_ff(c, d, a, b, x[i+10], 17, -42063);
  1564. b = this.md5_ff(b, c, d, a, x[i+11], 22, -1990404162);
  1565. a = this.md5_ff(a, b, c, d, x[i+12], 7 , 1804603682);
  1566. d = this.md5_ff(d, a, b, c, x[i+13], 12, -40341101);
  1567. c = this.md5_ff(c, d, a, b, x[i+14], 17, -1502002290);
  1568. b = this.md5_ff(b, c, d, a, x[i+15], 22, 1236535329);
  1569. a = this.md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510);
  1570. d = this.md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632);
  1571. c = this.md5_gg(c, d, a, b, x[i+11], 14, 643717713);
  1572. b = this.md5_gg(b, c, d, a, x[i+ 0], 20, -373897302);
  1573. a = this.md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691);
  1574. d = this.md5_gg(d, a, b, c, x[i+10], 9 , 38016083);
  1575. c = this.md5_gg(c, d, a, b, x[i+15], 14, -660478335);
  1576. b = this.md5_gg(b, c, d, a, x[i+ 4], 20, -405537848);
  1577. a = this.md5_gg(a, b, c, d, x[i+ 9], 5 , 568446438);
  1578. d = this.md5_gg(d, a, b, c, x[i+14], 9 , -1019803690);
  1579. c = this.md5_gg(c, d, a, b, x[i+ 3], 14, -187363961);
  1580. b = this.md5_gg(b, c, d, a, x[i+ 8], 20, 1163531501);
  1581. a = this.md5_gg(a, b, c, d, x[i+13], 5 , -1444681467);
  1582. d = this.md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784);
  1583. c = this.md5_gg(c, d, a, b, x[i+ 7], 14, 1735328473);
  1584. b = this.md5_gg(b, c, d, a, x[i+12], 20, -1926607734);
  1585. a = this.md5_hh(a, b, c, d, x[i+ 5], 4 , -378558);
  1586. d = this.md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463);
  1587. c = this.md5_hh(c, d, a, b, x[i+11], 16, 1839030562);
  1588. b = this.md5_hh(b, c, d, a, x[i+14], 23, -35309556);
  1589. a = this.md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060);
  1590. d = this.md5_hh(d, a, b, c, x[i+ 4], 11, 1272893353);
  1591. c = this.md5_hh(c, d, a, b, x[i+ 7], 16, -155497632);
  1592. b = this.md5_hh(b, c, d, a, x[i+10], 23, -1094730640);
  1593. a = this.md5_hh(a, b, c, d, x[i+13], 4 , 681279174);
  1594. d = this.md5_hh(d, a, b, c, x[i+ 0], 11, -358537222);
  1595. c = this.md5_hh(c, d, a, b, x[i+ 3], 16, -722521979);
  1596. b = this.md5_hh(b, c, d, a, x[i+ 6], 23, 76029189);
  1597. a = this.md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487);
  1598. d = this.md5_hh(d, a, b, c, x[i+12], 11, -421815835);
  1599. c = this.md5_hh(c, d, a, b, x[i+15], 16, 530742520);
  1600. b = this.md5_hh(b, c, d, a, x[i+ 2], 23, -995338651);
  1601. a = this.md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844);
  1602. d = this.md5_ii(d, a, b, c, x[i+ 7], 10, 1126891415);
  1603. c = this.md5_ii(c, d, a, b, x[i+14], 15, -1416354905);
  1604. b = this.md5_ii(b, c, d, a, x[i+ 5], 21, -57434055);
  1605. a = this.md5_ii(a, b, c, d, x[i+12], 6 , 1700485571);
  1606. d = this.md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606);
  1607. c = this.md5_ii(c, d, a, b, x[i+10], 15, -1051523);
  1608. b = this.md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799);
  1609. a = this.md5_ii(a, b, c, d, x[i+ 8], 6 , 1873313359);
  1610. d = this.md5_ii(d, a, b, c, x[i+15], 10, -30611744);
  1611. c = this.md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380);
  1612. b = this.md5_ii(b, c, d, a, x[i+13], 21, 1309151649);
  1613. a = this.md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070);
  1614. d = this.md5_ii(d, a, b, c, x[i+11], 10, -1120210379);
  1615. c = this.md5_ii(c, d, a, b, x[i+ 2], 15, 718787259);
  1616. b = this.md5_ii(b, c, d, a, x[i+ 9], 21, -343485551);
  1617. a = this.safe_add(a, olda);
  1618. b = this.safe_add(b, oldb);
  1619. c = this.safe_add(c, oldc);
  1620. d = this.safe_add(d, oldd);
  1621. }
  1622. return [a, b, c, d];
  1623. },
  1624. str2binl: function(str,chrsz){
  1625. var bin = [];
  1626. var mask = (1 << chrsz) - 1;
  1627. for(var i = 0; i < str.length * chrsz; i += chrsz) {
  1628. bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (i%32);
  1629. }
  1630. return bin;
  1631. },
  1632. binl2str: function (bin,chrsz){
  1633. var str = "";
  1634. var mask = (1 << chrsz) - 1;
  1635. for(var i = 0; i < bin.length * 32; i += chrsz) {
  1636. str += String.fromCharCode((bin[i>>5] >>> (i % 32)) & mask);
  1637. }
  1638. return str;
  1639. },
  1640. binl2hex: function (binarray,hexcase){
  1641. var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
  1642. var str = "";
  1643. for(var i = 0; i < binarray.length * 4; i++) {
  1644. str += hex_tab.charAt((binarray[i>>2] >> ((i%4)*8+4)) & 0xF) + hex_tab.charAt((binarray[i>>2] >> ((i%4)*8 )) & 0xF);
  1645. }
  1646. return str;
  1647. },
  1648. Hex: function(str,hexcase,chrsz)
  1649. {
  1650. hexcase = hexcase || false;
  1651. chrsz = chrsz || 16; //number charset {8(ASCII):16(UNICODE)}
  1652. return this.binl2hex(this.core_md5(this.str2binl(str,chrsz), str.length * chrsz),hexcase);
  1653. },
  1654. Bin: function(str)
  1655. {
  1656. chrsz = chrsz || 16; //number charset {8(ASCII):16(UNICODE)}
  1657. return this.binl2str(this.core_md5(this.str2binl(str,chrsz), str.length * chrsz),chrsz)
  1658. }
  1659. };
  1660. GoldenRtWeb.MD5 = MD5;
  1661. }();