/// <summary> /// Detects whether the Snip2Code web service is alive or not /// </summary> /// <returns></returns> public bool PingS2CServer(string pingUrl) { bool res = false; using (S2cWebClient client = new S2cWebClient(10000, this.m_requestFormat)) { try { string retStr = client.DownloadString(pingUrl); S2CResObj <object> boolResp = S2CSerializer.DeserializeObj(retStr, this.m_requestFormat); if ((boolResp != null) && (boolResp.Status == ErrorCodes.OK)) { if (!bool.TryParse(boolResp.Data.ToString(), out res)) { res = false; } } } catch (Exception e) { //log.DebugFormat("Cannot connect due to {0}; response is {1}", e, (response == null ? "null" : response.StatusCode.ToString())); log.DebugFormat("Cannot connect due to {0}", e); } } log.Debug("CheckConnections result=" + res); return(res); }
/// <summary> /// Perform a logout operation on the server for the current user /// </summary> /// <returns></returns> public bool Logout() { string logoutUrl = string.Format("{0}{1}", BaseWS.Server, LOGOUT_URL); string response = SendGetRequest(logoutUrl, true); if (string.IsNullOrEmpty(response)) { return(false); } S2CResObj <object> resp = S2CSerializer.DeserializeObj(response, m_requestFormat); if ((resp != null) && (resp.Status == ErrorCodes.OK)) { ResetLoginStatus(); return(true); } return(false); }