11function RqlConnector ( LoginGuid , SessionKey ) {
2- this . LoginGuid = LoginGuid ;
3- this . SessionKey = SessionKey ;
4- this . DCOM = 'DCOM' ;
5- this . DCOMProxyUrl = 'rqlconnector/rqlaction.asp' ;
6- this . WebService11 = 'WebService11' ;
7- this . WebService11ProxyUrl = 'rqlconnector/rqlactionwebservice.aspx' ;
8- this . WebService11Url = '/CMS/WebService/RqlWebService.svc' ;
9- this . RqlConnectionType = '' ;
10- this . InitializeConnectionType ( ) ;
2+ this . LoginGuid = LoginGuid ;
3+ this . SessionKey = SessionKey ;
4+ this . DCOM = 'DCOM' ;
5+ this . DCOMProxyUrl = 'rqlconnector/rqlaction.asp' ;
6+ this . WebService11 = 'WebService11' ;
7+ this . WebService11ProxyUrl = 'rqlconnector/rqlactionwebservice.aspx' ;
8+ this . WebService11Url = '/CMS/WebService/RqlWebService.svc' ;
9+ this . RqlConnectionType = '' ;
10+ this . InitializeConnectionType ( ) ;
1111}
1212
13- RqlConnector . prototype . SetConnectionType = function ( ConnectionType )
14- {
15- this . RqlConnectionType = ConnectionType ;
13+ RqlConnector . prototype . SetConnectionType = function ( ConnectionType ) {
14+ this . RqlConnectionType = ConnectionType ;
1615}
1716
18- RqlConnector . prototype . GetConnectionType = function ( )
19- {
20- return this . RqlConnectionType ;
17+ RqlConnector . prototype . GetConnectionType = function ( ) {
18+ return this . RqlConnectionType ;
2119}
2220
23- RqlConnector . prototype . InitializeConnectionType = function ( )
24- {
25- if ( this . GetConnectionType ( ) == '' )
26- {
27- if ( this . TestConnection ( this . WebService11Url ) )
28- {
29- this . SetConnectionType ( this . WebService11 ) ;
30- } else {
31- this . SetConnectionType ( this . DCOM ) ;
32- }
33- }
21+ RqlConnector . prototype . InitializeConnectionType = function ( ) {
22+ if ( this . GetConnectionType ( ) == '' ) {
23+ if ( this . TestConnection ( this . WebService11Url ) ) {
24+ this . SetConnectionType ( this . WebService11 ) ;
25+ } else {
26+ this . SetConnectionType ( this . DCOM ) ;
27+ }
28+ }
3429}
3530
36- RqlConnector . prototype . SendRql = function ( InnerRQL , IsText , CallbackFunc )
37- {
38- switch ( this . GetConnectionType ( ) )
39- {
40- case this . DCOM :
41- this . SendRqlCOM ( InnerRQL , IsText , CallbackFunc ) ;
42- break ;
43- case this . WebService11 :
44- this . SendRqlWebService ( InnerRQL , IsText , CallbackFunc ) ;
45- break ;
46- }
31+ RqlConnector . prototype . SendRql = function ( InnerRQL , IsText , CallbackFunc ) {
32+ switch ( this . GetConnectionType ( ) ) {
33+ case this . DCOM :
34+ this . SendRqlCOM ( InnerRQL , IsText , CallbackFunc ) ;
35+ break ;
36+ case this . WebService11 :
37+ this . SendRqlWebService ( InnerRQL , IsText , CallbackFunc ) ;
38+ break ;
39+ }
4740}
4841
49- RqlConnector . prototype . SendRqlWebService = function ( InnerRQL , IsText , CallbackFunc )
50- {
51- var SOAPMessage = '' ;
52- SOAPMessage += '<s:Envelope xmlns:s ="http://schemas.xmlsoap. org/soap/envelope/" >' ;
53- SOAPMessage += '<s:Body><q1:Execute xmlns:q1="http://tempuri.org/RDCMSXMLServer/message/"><sParamA>' + this . padRQLXML ( InnerRQL , IsText ) + '</sParamA><sErrorA></sErrorA><sResultInfoA></sResultInfoA></q1:Execute></s:Body >' ;
54- SOAPMessage += '</s:Envelope>' ;
55-
56- $ . post ( this . WebService11ProxyUrl , { rqlxml : SOAPMessage , webserviceurl : this . WebService11Url } ,
57- function ( data ) {
58- var RetRql = $ ( data ) . find ( 'Result' ) . text ( ) ;
59-
60- if ( IsText )
61- {
62- data = RetRql ;
63- }
64- else
65- {
66- data = $ . parseXML ( $ . trim ( RetRql ) ) ;
67- }
68-
69- CallbackFunc ( data ) ;
70- } ) ;
42+ RqlConnector . prototype . SendRqlWebService = function ( InnerRQL , IsText , CallbackFunc ) {
43+ var SOAPMessage = '' ;
44+ SOAPMessage + = '<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> ' ;
45+ SOAPMessage += '<s:Body><q1:Execute xmlns:q1 ="http://tempuri. org/RDCMSXMLServer/message/"><sParamA>' + this . padRQLXML ( InnerRQL , IsText ) + '</sParamA><sErrorA></sErrorA><sResultInfoA></sResultInfoA></q1:Execute></s:Body >';
46+ SOAPMessage += '</s:Envelope >' ;
47+
48+ $ . post ( this . WebService11ProxyUrl , { rqlxml : SOAPMessage , webserviceurl : this . WebService11Url } , function ( data ) {
49+ data = $ . trim ( data ) ;
50+
51+ var RetRql = $ ( $ . parseXML ( data ) ) . find ( 'Result' ) . text ( ) ;
52+ RetRql = $ . tr ( RetRql ) ;
53+
54+ if ( IsText ) {
55+ data = RetRql ;
56+ }
57+ else {
58+
59+ data = $ . parseXML ( RetRql ) ;
60+ }
61+
62+ CallbackFunc ( data ) ;
63+ } , 'text' ) ;
7164}
7265
73- RqlConnector . prototype . SendRqlCOM = function ( InnerRQL , IsText , CallbackFunc )
74- {
75- var Rql = this . padRQLXML ( InnerRQL , IsText ) ;
76- $ . post ( this . DCOMProxyUrl , { rqlxml : Rql } ,
77- function ( data ) {
78- data = $ ( '<div/>' ) . append ( data ) ;
79- CallbackFunc ( data ) ;
80- } ) ;
66+ RqlConnector . prototype . SendRqlCOM = function ( InnerRQL , IsText , CallbackFunc ) {
67+ var Rql = this . padRQLXML ( InnerRQL , IsText ) ;
68+ $ . post ( this . DCOMProxyUrl , { rqlxml : Rql } , function ( data ) {
69+ data = $ . trim ( data ) ;
70+
71+ if ( IsText ) {
72+ // do nothing
73+ }
74+ else {
75+
76+ data = $ . parseXML ( data ) ;
77+ }
78+
79+ CallbackFunc ( data ) ;
80+ } , 'text' ) ;
8181}
8282
83- RqlConnector . prototype . padRQLXML = function ( InnerRQL , IsText )
84- {
85- var Rql = '<IODATA loginguid="' + this . LoginGuid + '" sessionkey="' + this . SessionKey + '"' ;
86- if ( IsText )
87- {
88- Rql += ' format="1"' ;
89- }
90-
91- Rql += '>' + InnerRQL + '</IODATA>' ;
92-
93- if ( this . GetConnectionType ( this . WebService11 ) == this . WebService11 )
94- {
95- Rql = '<![CDATA[' + Rql + ']]>' ;
96- }
97-
98- return Rql ;
83+ RqlConnector . prototype . padRQLXML = function ( InnerRQL , IsText ) {
84+ var Rql = '<IODATA loginguid="' + this . LoginGuid + '" sessionkey="' + this . SessionKey + '"' ;
85+ if ( IsText ) {
86+ Rql += ' format="1"' ;
87+ }
88+
89+ Rql += '>' + InnerRQL + '</IODATA>' ;
90+
91+ if ( this . GetConnectionType ( this . WebService11 ) == this . WebService11 ) {
92+ Rql = '<![CDATA[' + Rql + ']]>' ;
93+ }
94+
95+ return Rql ;
9996}
10097
101- RqlConnector . prototype . TestConnection = function ( Url )
102- {
103- var Isvalid = false ;
98+ RqlConnector . prototype . TestConnection = function ( Url ) {
99+ var Isvalid = false ;
104100 $ . ajax ( {
105101 async : false ,
106102 url : Url ,
107- success : function ( ) {
108- Isvalid = true ;
103+ success : function ( ) {
104+ Isvalid = true ;
109105 } ,
110- error : function ( ) {
111- Isvalid = false ;
112- }
106+ error : function ( ) {
107+ Isvalid = false ;
108+ }
113109 } ) ;
114-
115- return Isvalid ;
110+
111+ return Isvalid ;
116112}
0 commit comments