@@ -7,42 +7,55 @@ function RqlConnector(LoginGuid, SessionKey) {
77 this . WebService11ProxyUrl = 'rqlconnector/rqlactionwebservice.aspx' ;
88 this . WebService11Url = '/CMS/WebService/RqlWebService.svc' ;
99 this . RqlConnectionType = '' ;
10- this . InitializeConnectionType ( ) ;
1110}
1211
1312RqlConnector . prototype . SetConnectionType = function ( ConnectionType ) {
1413 this . RqlConnectionType = ConnectionType ;
1514}
1615
17- RqlConnector . prototype . GetConnectionType = function ( ) {
18- return this . RqlConnectionType ;
19- }
20-
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 ) ;
16+ RqlConnector . prototype . GetConnectionType = function ( CallbackFunc ) {
17+ var ThisClass = this ;
18+
19+ if ( this . RqlConnectionType == '' ) {
20+ this . TestConnection ( this . WebService11Url , function ( data ) {
21+ if ( data ) {
22+ ThisClass . SetConnectionType ( ThisClass . WebService11 ) ;
23+ } else {
24+ ThisClass . SetConnectionType ( ThisClass . DCOM ) ;
25+ }
26+
27+ if ( CallbackFunc ) {
28+ CallbackFunc ( ThisClass . RqlConnectionType ) ;
29+ }
30+ } ) ;
31+ } else {
32+ if ( CallbackFunc ) {
33+ CallbackFunc ( ThisClass . RqlConnectionType ) ;
2734 }
2835 }
2936}
3037
3138RqlConnector . 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- }
39+ var ThisClass = this ;
40+
41+ this . GetConnectionType ( function ( data ) {
42+ switch ( data ) {
43+ case ThisClass . DCOM :
44+ ThisClass . SendRqlCOM ( InnerRQL , IsText , CallbackFunc ) ;
45+ break ;
46+ case ThisClass . WebService11 :
47+ ThisClass . SendRqlWebService ( InnerRQL , IsText , CallbackFunc ) ;
48+ break ;
49+ }
50+ } ) ;
4051}
4152
4253RqlConnector . prototype . SendRqlWebService = function ( InnerRQL , IsText , CallbackFunc ) {
4354 var SOAPMessage = '' ;
4455 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>' ;
56+ SOAPMessage += '<s:Body><q1:Execute xmlns:q1="http://tempuri.org/RDCMSXMLServer/message/"><sParamA>' ;
57+ SOAPMessage += '<![CDATA[' + this . PadRQLXML ( InnerRQL , IsText ) + ']]>' ;
58+ SOAPMessage += '</sParamA><sErrorA></sErrorA><sResultInfoA></sResultInfoA></q1:Execute></s:Body>' ;
4659 SOAPMessage += '</s:Envelope>' ;
4760
4861 $ . post ( this . WebService11ProxyUrl , { rqlxml : SOAPMessage , webserviceurl : this . WebService11Url } , function ( data ) {
@@ -55,7 +68,6 @@ RqlConnector.prototype.SendRqlWebService = function (InnerRQL, IsText, CallbackF
5568 data = RetRql ;
5669 }
5770 else {
58-
5971 data = $ . parseXML ( RetRql ) ;
6072 }
6173
@@ -64,49 +76,47 @@ RqlConnector.prototype.SendRqlWebService = function (InnerRQL, IsText, CallbackF
6476}
6577
6678RqlConnector . prototype . SendRqlCOM = function ( InnerRQL , IsText , CallbackFunc ) {
67- var Rql = this . padRQLXML ( InnerRQL , IsText ) ;
79+ var Rql = this . PadRQLXML ( InnerRQL , IsText ) ;
6880 $ . post ( this . DCOMProxyUrl , { rqlxml : Rql } , function ( data ) {
6981 data = $ . trim ( data ) ;
7082
7183 if ( IsText ) {
7284 // do nothing
7385 }
7486 else {
75-
7687 data = $ . parseXML ( data ) ;
7788 }
7889
7990 CallbackFunc ( data ) ;
8091 } , 'text' ) ;
8192}
8293
83- RqlConnector . prototype . padRQLXML = function ( InnerRQL , IsText ) {
84- var Rql = '<IODATA loginguid="' + this . LoginGuid + '" sessionkey="' + this . SessionKey + '"' ;
94+ RqlConnector . prototype . PadRQLXML = function ( InnerRQL , IsText ) {
95+ var Rql = '<IODATA loginguid="' + this . LoginGuid + '" sessionkey="' + this . SessionKey + '">' ;
96+
8597 if ( IsText ) {
86- Rql += ' format="1"';
98+ Rql = '<IODATA loginguid="' + this . LoginGuid + '" sessionkey="' + this . SessionKey + '" format="1"> ';
8799 }
88100
89- Rql += '>' + InnerRQL + '</IODATA>' ;
90-
91- if ( this . GetConnectionType ( this . WebService11 ) == this . WebService11 ) {
92- Rql = '<![CDATA[' + Rql + ']]>' ;
93- }
101+ Rql += InnerRQL ;
102+ Rql += '</IODATA>' ;
94103
95104 return Rql ;
96105}
97106
98- RqlConnector . prototype . TestConnection = function ( Url ) {
99- var Isvalid = false ;
107+ RqlConnector . prototype . TestConnection = function ( Url , CallbackFunc ) {
100108 $ . ajax ( {
101- async : false ,
109+ async : true ,
102110 url : Url ,
103111 success : function ( ) {
104- Isvalid = true ;
112+ if ( CallbackFunc ) {
113+ CallbackFunc ( true ) ;
114+ }
105115 } ,
106116 error : function ( ) {
107- Isvalid = false ;
117+ if ( CallbackFunc ) {
118+ CallbackFunc ( false ) ;
119+ }
108120 }
109121 } ) ;
110-
111- return Isvalid ;
112122}
0 commit comments