Added some exception handling
parent
2f4d484702
commit
ab6d1bd5a6
|
@ -11,18 +11,23 @@ namespace OpenGridServices.Manager
|
||||||
|
|
||||||
public bool Connect(string GridServerURL, string username, string password)
|
public bool Connect(string GridServerURL, string username, string password)
|
||||||
{
|
{
|
||||||
this.ServerURL=GridServerURL;
|
try {
|
||||||
Hashtable LoginParamsHT = new Hashtable();
|
this.ServerURL=GridServerURL;
|
||||||
LoginParamsHT["username"]=username;
|
Hashtable LoginParamsHT = new Hashtable();
|
||||||
LoginParamsHT["password"]=password;
|
LoginParamsHT["username"]=username;
|
||||||
ArrayList LoginParams = new ArrayList();
|
LoginParamsHT["password"]=password;
|
||||||
LoginParams.Add(LoginParamsHT);
|
ArrayList LoginParams = new ArrayList();
|
||||||
XmlRpcRequest GridLoginReq = new XmlRpcRequest("manager_login",LoginParams);
|
LoginParams.Add(LoginParamsHT);
|
||||||
XmlRpcResponse GridResp = GridLoginReq.Send(ServerURL,3000);
|
XmlRpcRequest GridLoginReq = new XmlRpcRequest("manager_login",LoginParams);
|
||||||
if(GridResp.IsFault) {
|
XmlRpcResponse GridResp = GridLoginReq.Send(ServerURL,3000);
|
||||||
|
if(GridResp.IsFault) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} catch(Exception e) {
|
||||||
|
Console.WriteLine(e.ToString());
|
||||||
return false;
|
return false;
|
||||||
} else {
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,11 @@ namespace OpenGridServices.Manager
|
||||||
switch(cmd) {
|
switch(cmd) {
|
||||||
case "connect_to_gridserver":
|
case "connect_to_gridserver":
|
||||||
win.SetStatus("Connecting to grid server...");
|
win.SetStatus("Connecting to grid server...");
|
||||||
gridserverConn.Connect(operation.Split(sep)[1],operation.Split(sep)[2],operation.Split(sep)[3]);
|
if(gridserverConn.Connect(operation.Split(sep)[1],operation.Split(sep)[2],operation.Split(sep)[3])) {
|
||||||
|
win.SetStatus("Connected OK");
|
||||||
|
} else {
|
||||||
|
win.SetStatus("Could not connect");
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue