@@ -7,42 +7,55 @@ function RqlConnector(LoginGuid, SessionKey) {
7
7
this . WebService11ProxyUrl = 'rqlconnector/rqlactionwebservice.aspx' ;
8
8
this . WebService11Url = '/CMS/WebService/RqlWebService.svc' ;
9
9
this . RqlConnectionType = '' ;
10
- this . InitializeConnectionType ( ) ;
11
10
}
12
11
13
12
RqlConnector . prototype . SetConnectionType = function ( ConnectionType ) {
14
13
this . RqlConnectionType = ConnectionType ;
15
14
}
16
15
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 ) ;
27
34
}
28
35
}
29
36
}
30
37
31
38
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
- }
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
+ } ) ;
40
51
}
41
52
42
53
RqlConnector . prototype . SendRqlWebService = function ( InnerRQL , IsText , CallbackFunc ) {
43
54
var SOAPMessage = '' ;
44
55
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>' ;
46
59
SOAPMessage += '</s:Envelope>' ;
47
60
48
61
$ . post ( this . WebService11ProxyUrl , { rqlxml : SOAPMessage , webserviceurl : this . WebService11Url } , function ( data ) {
@@ -55,7 +68,6 @@ RqlConnector.prototype.SendRqlWebService = function (InnerRQL, IsText, CallbackF
55
68
data = RetRql ;
56
69
}
57
70
else {
58
-
59
71
data = $ . parseXML ( RetRql ) ;
60
72
}
61
73
@@ -64,49 +76,47 @@ RqlConnector.prototype.SendRqlWebService = function (InnerRQL, IsText, CallbackF
64
76
}
65
77
66
78
RqlConnector . prototype . SendRqlCOM = function ( InnerRQL , IsText , CallbackFunc ) {
67
- var Rql = this . padRQLXML ( InnerRQL , IsText ) ;
79
+ var Rql = this . PadRQLXML ( InnerRQL , IsText ) ;
68
80
$ . post ( this . DCOMProxyUrl , { rqlxml : Rql } , function ( data ) {
69
81
data = $ . trim ( data ) ;
70
82
71
83
if ( IsText ) {
72
84
// do nothing
73
85
}
74
86
else {
75
-
76
87
data = $ . parseXML ( data ) ;
77
88
}
78
89
79
90
CallbackFunc ( data ) ;
80
91
} , 'text' ) ;
81
92
}
82
93
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
+
85
97
if ( IsText ) {
86
- Rql += ' format="1"';
98
+ Rql = '<IODATA loginguid="' + this . LoginGuid + '" sessionkey="' + this . SessionKey + '" format="1"> ';
87
99
}
88
100
89
- Rql += '>' + InnerRQL + '</IODATA>' ;
90
-
91
- if ( this . GetConnectionType ( this . WebService11 ) == this . WebService11 ) {
92
- Rql = '<![CDATA[' + Rql + ']]>' ;
93
- }
101
+ Rql += InnerRQL ;
102
+ Rql += '</IODATA>' ;
94
103
95
104
return Rql ;
96
105
}
97
106
98
- RqlConnector . prototype . TestConnection = function ( Url ) {
99
- var Isvalid = false ;
107
+ RqlConnector . prototype . TestConnection = function ( Url , CallbackFunc ) {
100
108
$ . ajax ( {
101
- async : false ,
109
+ async : true ,
102
110
url : Url ,
103
111
success : function ( ) {
104
- Isvalid = true ;
112
+ if ( CallbackFunc ) {
113
+ CallbackFunc ( true ) ;
114
+ }
105
115
} ,
106
116
error : function ( ) {
107
- Isvalid = false ;
117
+ if ( CallbackFunc ) {
118
+ CallbackFunc ( false ) ;
119
+ }
108
120
}
109
121
} ) ;
110
-
111
- return Isvalid ;
112
122
}
0 commit comments