PageRenderTime 37ms CodeModel.GetById 11ms RepoModel.GetById 1ms app.codeStats 0ms

/source/_SiteNote/XmlEditor/SvcHelper.js

#
JavaScript | 1221 lines | 1027 code | 179 blank | 15 comment | 255 complexity | ceb687b84a8211a7b3f5c6fdde220d29 MD5 | raw file
  1. function SvcHelper(xmlEditorPath, debugMode)
  2. {
  3. this.serviceUrl = xmlEditorPath + 'XmlEditor.asmx';
  4. this.debugMode = debugMode;
  5. this.xmlHttp = null;
  6. /**
  7. * @type WSClient
  8. */
  9. this.wsClient = null;
  10. }
  11. SvcHelper.prototype.Initialize = function ()
  12. {
  13. try
  14. {
  15. this.xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
  16. this.wsClient = new WSClient(this.serviceUrl, "POST", "http://tempuri.org/");
  17. this.wsClient.setSoapHeader("SessionIdHeader", {Id: SiteNote.Session.SessionId});
  18. //this.xmlHttp = new XMLHttpRequest();
  19. //alert('FireFox ou IE7');
  20. }
  21. catch(e)
  22. {
  23. try
  24. {
  25. this.xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
  26. //alert('IE6');
  27. }
  28. catch(ex)
  29. {
  30. err(ex);
  31. this.xmlHttp = null;
  32. }
  33. }
  34. return (this.xmlHttp != null);
  35. }
  36. SvcHelper.prototype.InitializeEdition = function (documentUri, schemaUri, bForceInitialization)
  37. {
  38. var post;
  39. var document;
  40. var result;
  41. var response;
  42. var responseDocument;
  43. var status;
  44. result = null;
  45. if(this.xmlHttp == null)
  46. {
  47. if (!this.Initialize())
  48. {
  49. return result;
  50. }
  51. }
  52. post = "documentUri=" + encodeURIComponent(documentUri) + "&schemaUri=" + encodeURIComponent(schemaUri) + "&bForceInitialization=" + bForceInitialization;
  53. //alert('ici');
  54. this.xmlHttp.Open("POST", this.serviceUrl + '/InitializeEdition', false);
  55. //alert(this.serviceUrl + '/InitializeEdition');
  56. this.xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  57. this.xmlHttp.Send(post);
  58. document = this.xmlHttp.responseXML;
  59. if (document.parseError.errorCode != 0 || document.xml == '')
  60. {
  61. if (this.debugMode)
  62. {
  63. err("unable to retrieve document");
  64. err(this.serviceUrl + '/InitializeEdition');
  65. err(post);
  66. err(this.xmlHttp.responseText);
  67. }
  68. }
  69. else
  70. {
  71. response = document.documentElement.firstChild.text;
  72. responseDocument = new ActiveXObject("Msxml2.DOMDocument.6.0");;
  73. responseDocument.loadXML(response);
  74. if (responseDocument.parseError.errorCode != 0 || responseDocument.xml == '')
  75. {
  76. if (this.debugMode)
  77. {
  78. err("unable to retrieve read response");
  79. err(this.serviceUrl + '/InitializeEdition');
  80. err(post);
  81. err(document.xml);
  82. err(response);
  83. }
  84. }
  85. else
  86. {
  87. status = responseDocument.documentElement.firstChild;
  88. if (status.text == 'succeed')
  89. {
  90. result = status.nextSibling;
  91. }
  92. }
  93. }
  94. return result;
  95. }
  96. SvcHelper.prototype.GetXmlDocument = function (documentId)
  97. {
  98. var post;
  99. var document;
  100. var result;
  101. var response;
  102. var responseDocument;
  103. var status;
  104. result = "";
  105. if(this.xmlHttp == null)
  106. {
  107. if (!this.Initialize())
  108. {
  109. return result;
  110. }
  111. }
  112. post = "documentId=" + encodeURIComponent(documentId);
  113. this.xmlHttp.Open("POST", this.serviceUrl + '/GetXmlDocument', false);
  114. this.xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  115. this.xmlHttp.Send(post);
  116. document = this.xmlHttp.responseXML;
  117. if (document.parseError.errorCode != 0 || document.xml == '')
  118. {
  119. if (this.debugMode)
  120. {
  121. err("unable to retrieve document");
  122. err(this.serviceUrl + '/GetXmlDocument');
  123. err(post);
  124. err(this.xmlHttp.responseText);
  125. }
  126. }
  127. else
  128. {
  129. response = document.documentElement.firstChild.text;
  130. responseDocument = new ActiveXObject("Msxml2.DOMDocument.6.0");;
  131. responseDocument.loadXML(response);
  132. if (responseDocument.parseError.errorCode != 0 || responseDocument.xml == '')
  133. {
  134. if (this.debugMode)
  135. {
  136. err("unable to retrieve read response");
  137. err(this.serviceUrl + '/GetXmlDocument');
  138. err(post);
  139. err(document.xml);
  140. err(response);
  141. }
  142. }
  143. else
  144. {
  145. status = responseDocument.documentElement.firstChild;
  146. if (status.text == 'succeed')
  147. {
  148. result = status.nextSibling.text;
  149. }
  150. }
  151. }
  152. return result;
  153. }
  154. SvcHelper.prototype.ReloadDocument = function (documentId)
  155. {
  156. var post;
  157. var document;
  158. var result;
  159. var response;
  160. var responseDocument;
  161. var status;
  162. result = "";
  163. if(this.xmlHttp == null)
  164. {
  165. if (!this.Initialize())
  166. {
  167. return result;
  168. }
  169. }
  170. post = "documentId=" + encodeURIComponent(documentId);
  171. this.xmlHttp.Open("POST", this.serviceUrl + '/ReloadDocument', false);
  172. this.xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  173. this.xmlHttp.Send(post);
  174. document = this.xmlHttp.responseXML;
  175. if (document.parseError.errorCode != 0 || document.xml == '')
  176. {
  177. if (this.debugMode)
  178. {
  179. err("unable to retrieve document");
  180. err(this.serviceUrl + '/GetXmlDocument');
  181. err(post);
  182. err(this.xmlHttp.responseText);
  183. }
  184. }
  185. else
  186. {
  187. response = document.documentElement.firstChild.text;
  188. responseDocument = new ActiveXObject("Msxml2.DOMDocument.6.0");;
  189. responseDocument.loadXML(response);
  190. if (responseDocument.parseError.errorCode != 0 || responseDocument.xml == '')
  191. {
  192. if (this.debugMode)
  193. {
  194. err("unable to retrieve read response");
  195. err(this.serviceUrl + '/GetXmlDocument');
  196. err(post);
  197. err(document.xml);
  198. err(response);
  199. }
  200. }
  201. else
  202. {
  203. status = responseDocument.documentElement.firstChild;
  204. if (status.text == 'succeed')
  205. {
  206. result = status.nextSibling.text;
  207. }
  208. }
  209. }
  210. return result;
  211. }
  212. SvcHelper.prototype.GetXsltDocument = function (uri)
  213. {
  214. var post;
  215. var document;
  216. var result;
  217. var response;
  218. var responseDocument;
  219. var status;
  220. result = "";
  221. if(this.xmlHttp == null)
  222. {
  223. if (!this.Initialize())
  224. {
  225. return result;
  226. }
  227. }
  228. post = "uri=" + encodeURIComponent(uri);
  229. this.xmlHttp.Open("POST", this.serviceUrl + '/GetXsltDocument', false);
  230. this.xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  231. this.xmlHttp.Send(post);
  232. document = this.xmlHttp.responseXML;
  233. if (document.parseError.errorCode != 0 || document.xml == '')
  234. {
  235. if (this.debugMode)
  236. {
  237. err("unable to retrieve document");
  238. err(this.serviceUrl + '/GetXsltDocument');
  239. err(post);
  240. err(this.xmlHttp.responseText);
  241. }
  242. }
  243. else
  244. {
  245. response = document.documentElement.firstChild.text;
  246. responseDocument = new ActiveXObject("Msxml2.DOMDocument.6.0");;
  247. responseDocument.loadXML(response);
  248. if (responseDocument.parseError.errorCode != 0 || responseDocument.xml == '')
  249. {
  250. if (this.debugMode)
  251. {
  252. err("unable to retrieve read response");
  253. err(this.serviceUrl + '/GetXsltDocument');
  254. err(post);
  255. err(document.xml);
  256. err(response);
  257. }
  258. }
  259. else
  260. {
  261. status = responseDocument.documentElement.firstChild;
  262. if (status.text == 'succeed')
  263. {
  264. result = status.nextSibling.text;
  265. }
  266. }
  267. }
  268. return result;
  269. }
  270. SvcHelper.prototype.GetXmlLabel = function (uri)
  271. {
  272. var post;
  273. var document;
  274. var result;
  275. var response;
  276. var responseDocument;
  277. var status;
  278. result = "";
  279. if(this.xmlHttp == null)
  280. {
  281. if (!this.Initialize())
  282. {
  283. return result;
  284. }
  285. }
  286. post = "uri=" + encodeURIComponent(uri);
  287. this.xmlHttp.Open("POST", this.serviceUrl + '/GetXmlLabel', false);
  288. this.xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  289. this.xmlHttp.Send(post);
  290. document = this.xmlHttp.responseXML;
  291. if (document.parseError.errorCode != 0 || document.xml == '')
  292. {
  293. if (this.debugMode)
  294. {
  295. err("unable to retrieve document");
  296. err(this.serviceUrl + '/GetXmlLabel');
  297. err(post);
  298. err(this.xmlHttp.responseText);
  299. }
  300. }
  301. else
  302. {
  303. response = document.documentElement.firstChild.text;
  304. responseDocument = new ActiveXObject("Msxml2.DOMDocument.6.0");;
  305. responseDocument.loadXML(response);
  306. if (responseDocument.parseError.errorCode != 0 || responseDocument.xml == '')
  307. {
  308. if (this.debugMode)
  309. {
  310. err("unable to retrieve read response");
  311. err(this.serviceUrl + '/GetXmlLabel');
  312. err(post);
  313. err(document.xml);
  314. err(response);
  315. }
  316. }
  317. else
  318. {
  319. status = responseDocument.documentElement.firstChild;
  320. if (status.text == 'succeed')
  321. {
  322. result = status.nextSibling.text;
  323. }
  324. }
  325. }
  326. return result;
  327. }
  328. SvcHelper.prototype.SaveText = function (documentId, object_id, text)
  329. {
  330. var post;
  331. var result;
  332. var response;
  333. var responseDocument;
  334. var status;
  335. result = false;
  336. if(this.wsClient == null)
  337. {
  338. if (!this.Initialize())
  339. {
  340. return result;
  341. }
  342. }
  343. response = this.wsClient.invoke("SaveText", {documentId: documentId, objectId: object_id, text: text});
  344. post = this.wsClient.requestBody;
  345. if (this.wsClient.getErrorCode() != 0)
  346. {
  347. if (this.debugMode)
  348. {
  349. err("unable to retrieve document");
  350. err(this.serviceUrl + '/SaveText');
  351. err(post);
  352. err(this.wsClient.getErrorReason());
  353. }
  354. }
  355. else
  356. {
  357. responseDocument = new ActiveXObject("Msxml2.DOMDocument.6.0");;
  358. responseDocument.loadXML(response);
  359. if (responseDocument.parseError.errorCode != 0 || responseDocument.xml == '')
  360. {
  361. if (this.debugMode)
  362. {
  363. err("unable to retrieve read response");
  364. err(this.serviceUrl + '/SaveText');
  365. err(post);
  366. err(response);
  367. }
  368. }
  369. else
  370. {
  371. status = responseDocument.documentElement.firstChild;
  372. if (status.text == 'succeed')
  373. {
  374. result = true;
  375. }
  376. }
  377. }
  378. return result;
  379. }
  380. SvcHelper.prototype.GetActions = function(documentId, objectId)
  381. {
  382. var post;
  383. var document;
  384. var result;
  385. var response;
  386. var responseDocument;
  387. var status;
  388. result = null;
  389. if(this.xmlHttp == null)
  390. {
  391. if (!this.Initialize())
  392. {
  393. return result;
  394. }
  395. }
  396. post = "documentId=" + encodeURIComponent(documentId) + "&objectId=" + objectId;
  397. this.xmlHttp.Open("POST", this.serviceUrl + '/GetActions', false);
  398. this.xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  399. this.xmlHttp.Send(post);
  400. document = this.xmlHttp.responseXML;
  401. if (document.parseError.errorCode != 0 || document.xml == '')
  402. {
  403. if (this.debugMode)
  404. {
  405. err("unable to retrieve document");
  406. err(this.serviceUrl + '/GetActions');
  407. err(post);
  408. err(this.xmlHttp.responseText);
  409. }
  410. }
  411. else
  412. {
  413. response = document.documentElement.firstChild.text;
  414. responseDocument = new ActiveXObject("Msxml2.DOMDocument.6.0");;
  415. responseDocument.loadXML(response);
  416. if (responseDocument.parseError.errorCode != 0 || responseDocument.xml == '')
  417. {
  418. if (this.debugMode)
  419. {
  420. err("unable to retrieve read response");
  421. err(this.serviceUrl + '/GetActions');
  422. err(post);
  423. err(document.xml);
  424. err(response);
  425. }
  426. }
  427. else
  428. {
  429. status = responseDocument.documentElement.firstChild;
  430. if (status.text == 'succeed')
  431. {
  432. result = status.nextSibling;
  433. }
  434. }
  435. }
  436. return result;
  437. }
  438. SvcHelper.prototype.GetEditionActions = function(documentId, objectId)
  439. {
  440. var post;
  441. var document;
  442. var result;
  443. var response;
  444. var responseDocument;
  445. var status;
  446. result = null;
  447. if(this.xmlHttp == null)
  448. {
  449. if (!this.Initialize())
  450. {
  451. return result;
  452. }
  453. }
  454. post = "documentId=" + encodeURIComponent(documentId) + "&objectId=" + objectId;
  455. this.xmlHttp.Open("POST", this.serviceUrl + '/GetEditionActions', false);
  456. this.xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  457. this.xmlHttp.Send(post);
  458. document = this.xmlHttp.responseXML;
  459. if (document.parseError.errorCode != 0 || document.xml == '')
  460. {
  461. if (this.debugMode)
  462. {
  463. err("unable to retrieve document");
  464. err(this.serviceUrl + '/GetEditionActions');
  465. err(post);
  466. err(this.xmlHttp.responseText);
  467. }
  468. }
  469. else
  470. {
  471. response = document.documentElement.firstChild.text;
  472. responseDocument = new ActiveXObject("Msxml2.DOMDocument.6.0");;
  473. responseDocument.loadXML(response);
  474. if (responseDocument.parseError.errorCode != 0 || responseDocument.xml == '')
  475. {
  476. if (this.debugMode)
  477. {
  478. err("unable to retrieve read response");
  479. err(this.serviceUrl + '/GetEditionActions');
  480. err(post);
  481. err(document.xml);
  482. err(response);
  483. }
  484. }
  485. else
  486. {
  487. status = responseDocument.documentElement.firstChild;
  488. if (status.text == 'succeed')
  489. {
  490. result = status.nextSibling;
  491. }
  492. }
  493. }
  494. return result;
  495. }
  496. SvcHelper.prototype.CreateElement = function(documentId, objectId, position, elementName, elementType, schemaType)
  497. {
  498. var post;
  499. var document;
  500. var result;
  501. var response;
  502. var responseDocument;
  503. var status;
  504. result = null;
  505. if(this.wsClient == null)
  506. {
  507. if (!this.Initialize())
  508. {
  509. return result;
  510. }
  511. }
  512. response = this.wsClient.invoke("CreateElement", {documentId: documentId, objectId: objectId, position: position,
  513. elementName: elementName, elementType: elementType, schemaType: schemaType});
  514. post = this.wsClient.requestBody;
  515. if (this.wsClient.getErrorCode() != 0)
  516. {
  517. if (this.debugMode)
  518. {
  519. err("unable to retrieve document");
  520. err(this.serviceUrl + '/CreateElement');
  521. err(post);
  522. err(this.wsClient.getErrorReason());
  523. }
  524. }
  525. else
  526. {
  527. responseDocument = new ActiveXObject("Msxml2.DOMDocument.6.0");
  528. responseDocument.loadXML(response);
  529. if (responseDocument.parseError.errorCode != 0 || responseDocument.xml == '')
  530. {
  531. if (this.debugMode)
  532. {
  533. err("unable to retrieve read response");
  534. err(this.serviceUrl + '/CreateElement');
  535. err(post);
  536. err(response);
  537. }
  538. }
  539. else
  540. {
  541. status = responseDocument.documentElement.firstChild;
  542. if (status.text == 'succeed')
  543. {
  544. result = status.nextSibling.text;
  545. }
  546. }
  547. }
  548. return result;
  549. }
  550. SvcHelper.prototype.DeleteElement = function(documentId, objectId)
  551. {
  552. var post;
  553. var result;
  554. var response;
  555. var responseDocument;
  556. var status;
  557. result = null;
  558. if(this.wsClient == null)
  559. {
  560. if (!this.Initialize())
  561. {
  562. return result;
  563. }
  564. }
  565. response = this.wsClient.invoke("DeleteElement", {documentId: documentId, objectId: objectId});
  566. post = this.wsClient.requestBody;
  567. if (this.wsClient.getErrorCode() != 0)
  568. {
  569. if (this.debugMode)
  570. {
  571. err("unable to retrieve document");
  572. err(this.serviceUrl + '/DeleteElement');
  573. err(post);
  574. err(this.xmlHttp.responseText);
  575. }
  576. }
  577. else
  578. {
  579. responseDocument = new ActiveXObject("Msxml2.DOMDocument.6.0");;
  580. responseDocument.loadXML(response);
  581. if (responseDocument.parseError.errorCode != 0 || responseDocument.xml == '')
  582. {
  583. if (this.debugMode)
  584. {
  585. err("unable to retrieve read response");
  586. err(this.serviceUrl + '/DeleteElement');
  587. err(post);
  588. err(response);
  589. }
  590. }
  591. else
  592. {
  593. status = responseDocument.documentElement.firstChild;
  594. if (status.text == 'succeed')
  595. {
  596. result = status.nextSibling.text;
  597. }
  598. }
  599. }
  600. return result;
  601. }
  602. SvcHelper.prototype.SplitElement = function(documentId, objectId, position)
  603. {
  604. var post;
  605. var result;
  606. var response;
  607. var responseDocument;
  608. var status;
  609. result = null;
  610. if(this.wsClient == null)
  611. {
  612. if (!this.Initialize())
  613. {
  614. return result;
  615. }
  616. }
  617. response = this.wsClient.invoke("SplitElement", {documentId: documentId, objectId: objectId, position: position})
  618. post = this.wsClient.requestBody;
  619. if (this.wsClient.getErrorCode() != 0)
  620. {
  621. if (this.debugMode)
  622. {
  623. err("unable to retrieve document");
  624. err(this.serviceUrl + '/SplitElement');
  625. err(post);
  626. err(this.wsClient.getErrorReason());
  627. }
  628. }
  629. else
  630. {
  631. responseDocument = new ActiveXObject("Msxml2.DOMDocument.6.0");;
  632. responseDocument.loadXML(response);
  633. if (responseDocument.parseError.errorCode != 0 || responseDocument.xml == '')
  634. {
  635. if (this.debugMode)
  636. {
  637. err("unable to retrieve read response");
  638. err(this.serviceUrl + '/SplitElement');
  639. err(post);
  640. err(response);
  641. }
  642. }
  643. else
  644. {
  645. status = responseDocument.documentElement.firstChild;
  646. if (status.text == 'succeed')
  647. {
  648. result = status.nextSibling.text;
  649. }
  650. }
  651. }
  652. return result;
  653. }
  654. SvcHelper.prototype.MergeSiblings = function(documentId, objectId, siblingPosition)
  655. {
  656. var post;
  657. var result;
  658. var response;
  659. var responseDocument;
  660. var status;
  661. result = null;
  662. if(this.wsClient == null)
  663. {
  664. if (!this.Initialize())
  665. {
  666. return result;
  667. }
  668. }
  669. response = this.wsClient.invoke("MergeSiblings", {documentId: documentId, objectId: objectId, siblingPosition: siblingPosition});
  670. post = this.wsClient.requestBody;
  671. if (this.wsClient.getErrorCode() != 0)
  672. {
  673. if (this.debugMode)
  674. {
  675. err("unable to retrieve document");
  676. err(this.serviceUrl + methodName);
  677. err(post);
  678. err(this.wsClient.getErrorReason());
  679. }
  680. }
  681. else
  682. {
  683. responseDocument = new ActiveXObject("Msxml2.DOMDocument.6.0");;
  684. responseDocument.loadXML(response);
  685. if (responseDocument.parseError.errorCode != 0 || responseDocument.xml == '')
  686. {
  687. if (this.debugMode)
  688. {
  689. err("unable to retrieve read response");
  690. err(this.serviceUrl + methodName);
  691. err(post);
  692. err(response);
  693. }
  694. }
  695. else
  696. {
  697. status = responseDocument.documentElement.firstChild;
  698. if (status.text == 'succeed')
  699. {
  700. result = status.nextSibling.text;
  701. }
  702. }
  703. }
  704. return result;
  705. }
  706. SvcHelper.prototype.CopyElement = function(documentId, objectId)
  707. {
  708. var post;
  709. var result;
  710. var response;
  711. var responseDocument;
  712. var status;
  713. result = false;
  714. if(this.wsClient == null)
  715. {
  716. if (!this.Initialize())
  717. {
  718. return result;
  719. }
  720. }
  721. response = this.wsClient.invoke("CopyElement", {documentId: documentId, objectId: objectId});
  722. post = this.wsClient.requestBody;
  723. if (this.wsClient.getErrorCode() != 0)
  724. {
  725. if (this.debugMode)
  726. {
  727. err("unable to retrieve document");
  728. err(this.serviceUrl + '/CopyElement');
  729. err(post);
  730. err(this.wsClient.getErrorReason());
  731. }
  732. }
  733. else
  734. {
  735. responseDocument = new ActiveXObject("Msxml2.DOMDocument.6.0");;
  736. responseDocument.loadXML(response);
  737. if (responseDocument.parseError.errorCode != 0 || responseDocument.xml == '')
  738. {
  739. if (this.debugMode)
  740. {
  741. err("unable to retrieve read response");
  742. err(this.serviceUrl + '/CopyElement');
  743. err(post);
  744. err(response);
  745. }
  746. }
  747. else
  748. {
  749. status = responseDocument.documentElement.firstChild;
  750. if (status.text == 'succeed')
  751. {
  752. result = true;
  753. }
  754. }
  755. }
  756. return result;
  757. }
  758. SvcHelper.prototype.PasteElement = function(documentId, objectId, position)
  759. {
  760. var post;
  761. var document;
  762. var result;
  763. var response;
  764. var responseDocument;
  765. var status;
  766. result = null;
  767. if(this.wsClient == null)
  768. {
  769. if (!this.Initialize())
  770. {
  771. return result;
  772. }
  773. }
  774. response = this.wsClient.invoke("PasteElement", {documentId: documentId, objectId: objectId, position: position});
  775. post = this.wsClient.requestBody;
  776. if (this.wsClient.getErrorCode() != 0)
  777. {
  778. if (this.debugMode)
  779. {
  780. err("unable to retrieve document");
  781. err(this.serviceUrl + '/PasteElement');
  782. err(post);
  783. err(this.wsClient.getErrorReason());
  784. }
  785. }
  786. else
  787. {
  788. responseDocument = new ActiveXObject("Msxml2.DOMDocument.6.0");;
  789. responseDocument.loadXML(response);
  790. if (responseDocument.parseError.errorCode != 0 || responseDocument.xml == '')
  791. {
  792. if (this.debugMode)
  793. {
  794. err("unable to retrieve read response");
  795. err(this.serviceUrl + '/PasteElement');
  796. err(post);
  797. err(response);
  798. }
  799. }
  800. else
  801. {
  802. status = responseDocument.documentElement.firstChild;
  803. if (status.text == 'succeed')
  804. {
  805. result = status.nextSibling.text;
  806. }
  807. }
  808. }
  809. return result;
  810. }
  811. SvcHelper.prototype.PasteXml = function(documentId, objectId, position, xml)
  812. {
  813. var post;
  814. var document;
  815. var result;
  816. var response;
  817. var responseDocument;
  818. var status;
  819. result = null;
  820. if(this.xmlHttp == null)
  821. {
  822. if (!this.Initialize())
  823. {
  824. return result;
  825. }
  826. }
  827. post = "documentId=" + encodeURIComponent(documentId) + "&objectId=" + objectId + "&position=" + position + "&xml=" + encodeURIComponent(xml);
  828. this.xmlHttp.Open("POST", this.serviceUrl + '/PasteXml', false);
  829. this.xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  830. this.xmlHttp.Send(post);
  831. document = this.xmlHttp.responseXML;
  832. if (document.parseError.errorCode != 0 || document.xml == '')
  833. {
  834. if (this.debugMode)
  835. {
  836. err("unable to retrieve document");
  837. err(this.serviceUrl + '/PasteXml');
  838. err(post);
  839. err(this.xmlHttp.responseText);
  840. }
  841. }
  842. else
  843. {
  844. response = document.documentElement.firstChild.text;
  845. responseDocument = new ActiveXObject("Msxml2.DOMDocument.6.0");;
  846. responseDocument.loadXML(response);
  847. if (responseDocument.parseError.errorCode != 0 || responseDocument.xml == '')
  848. {
  849. if (this.debugMode)
  850. {
  851. err("unable to retrieve read response");
  852. err(this.serviceUrl + '/PasteXml');
  853. err(post);
  854. err(document.xml);
  855. err(response);
  856. }
  857. }
  858. else
  859. {
  860. status = responseDocument.documentElement.firstChild;
  861. if (status.text == 'succeed')
  862. {
  863. result = status.nextSibling.text;
  864. }
  865. }
  866. }
  867. return result;
  868. }
  869. SvcHelper.prototype.DuplicateElement = function(documentId, sourceId, objectId, position, nbCopies)
  870. {
  871. var post;
  872. var document;
  873. var result;
  874. var response;
  875. var responseDocument;
  876. var status;
  877. result = null;
  878. if(this.wsClient == null)
  879. {
  880. if (!this.Initialize())
  881. {
  882. return result;
  883. }
  884. }
  885. response = this.wsClient.invoke("DuplicateElement", {documentId: documentId, sourceId: sourceId, objectId: objectId, position: position, nbCopies: nbCopies});
  886. post = this.wsClient.requestBody;
  887. if (this.wsClient.getErrorCode() != 0)
  888. {
  889. if (this.debugMode)
  890. {
  891. err("unable to retrieve document");
  892. err(this.serviceUrl + '/DuplicateElement');
  893. err(post);
  894. err(this.wsClient.getErrorReason());
  895. }
  896. }
  897. else
  898. {
  899. responseDocument = new ActiveXObject("Msxml2.DOMDocument.6.0");;
  900. responseDocument.loadXML(response);
  901. if (responseDocument.parseError.errorCode != 0 || responseDocument.xml == '')
  902. {
  903. if (this.debugMode)
  904. {
  905. err("unable to retrieve read response");
  906. err(this.serviceUrl + '/DuplicateElement');
  907. err(post);
  908. err(response);
  909. }
  910. }
  911. else
  912. {
  913. status = responseDocument.documentElement.firstChild;
  914. if (status.text == 'succeed')
  915. {
  916. result = status.nextSibling.text;
  917. }
  918. }
  919. }
  920. return result;
  921. }
  922. SvcHelper.prototype.GetEnumeration = function(documentId, schemaType)
  923. {
  924. var post;
  925. var document;
  926. var result;
  927. var response;
  928. var responseDocument;
  929. var status;
  930. result = null;
  931. if(this.xmlHttp == null)
  932. {
  933. if (!this.Initialize())
  934. {
  935. return result;
  936. }
  937. }
  938. post = "documentId=" + encodeURIComponent(documentId) + "&schemaType=" + schemaType;
  939. this.xmlHttp.Open("POST", this.serviceUrl + '/GetEnumeration', false);
  940. this.xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  941. this.xmlHttp.Send(post);
  942. document = this.xmlHttp.responseXML;
  943. if (document.parseError.errorCode != 0 || document.xml == '')
  944. {
  945. if (this.debugMode)
  946. {
  947. err("unable to retrieve document");
  948. err(this.serviceUrl + '/GetEnumeration');
  949. err(post);
  950. err(this.xmlHttp.responseText);
  951. }
  952. }
  953. else
  954. {
  955. response = document.documentElement.firstChild.text;
  956. responseDocument = new ActiveXObject("Msxml2.DOMDocument.6.0");;
  957. responseDocument.loadXML(response);
  958. if (responseDocument.parseError.errorCode != 0 || responseDocument.xml == '')
  959. {
  960. if (this.debugMode)
  961. {
  962. err("unable to retrieve read response");
  963. err(this.serviceUrl + '/GetEnumeration');
  964. err(post);
  965. err(document.xml);
  966. err(response);
  967. }
  968. }
  969. else
  970. {
  971. status = responseDocument.documentElement.firstChild;
  972. if (status.text == 'succeed')
  973. {
  974. result = status.nextSibling;
  975. }
  976. }
  977. }
  978. return result;
  979. }
  980. SvcHelper.prototype.ExecuteCall = function(url, post)
  981. {
  982. var document;
  983. var result;
  984. var response;
  985. var responseDocument;
  986. var status;
  987. result = null;
  988. if(this.xmlHttp == null)
  989. {
  990. if (!this.Initialize())
  991. {
  992. return result;
  993. }
  994. }
  995. //alert(url);
  996. //alert(post);
  997. this.xmlHttp.Open("POST", url, false);
  998. this.xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  999. this.xmlHttp.Send(post);
  1000. document = this.xmlHttp.responseXML;
  1001. if (document.parseError.errorCode != 0 || document.xml == '')
  1002. {
  1003. if (this.debugMode)
  1004. {
  1005. err("unable to retrieve document");
  1006. err(url);
  1007. err(post);
  1008. err(this.xmlHttp.responseText);
  1009. }
  1010. }
  1011. else
  1012. {
  1013. response = document.documentElement.firstChild.text;
  1014. //alert(response);
  1015. /*response = response.replace(/<!\[ATADC\[/g, '<![CDATA[');
  1016. response = response.replace(/\]ATADC\]>/g, ']]>');
  1017. */
  1018. responseDocument = new ActiveXObject("Msxml2.DOMDocument.6.0");;
  1019. responseDocument.loadXML(response);
  1020. //alert(response);
  1021. if (responseDocument.parseError.errorCode != 0 || responseDocument.xml == '')
  1022. {
  1023. if (this.debugMode)
  1024. {
  1025. err("unable to retrieve read response");
  1026. err(url);
  1027. err(post);
  1028. err(document.xml);
  1029. err(response);
  1030. }
  1031. }
  1032. else
  1033. {
  1034. status = responseDocument.documentElement.firstChild;
  1035. if (status.text == 'succeed')
  1036. {
  1037. result = status.nextSibling;
  1038. }
  1039. }
  1040. }
  1041. return result;
  1042. }