public bool login() { IDictionary <string, string> parameters = new Dictionary <string, string>(); parameters.Add("action", "login"); parameters.Add("remember", "sevenday"); parameters.Add("loginName", user0); parameters.Add("loginPwd", pwd0); loginstatus ret = new loginstatus(); HttpWebResponse response = CreatePostHttpResponse(url_login, parameters, null, null, Encoding.UTF8, cookies); if (response != null) { cookies = response.Cookies; StreamReader sr = new StreamReader(response.GetResponseStream()); String txt = sr.ReadToEnd(); Console.WriteLine(txt); ret = JsonConvert.DeserializeObject <loginstatus>(txt); return(ret.success); } return(false); }
public bool update(sockobj x) { String stm = ""; int state = 4; String hcd = utr[x.rtu]; String Guid = x.serial; String msg = "未知错误!"; if (x.uid != "service") { return(false); } msg = x.message; if (x.success) { if (x.value == "0101") //开机 { state = 2; lock (_lock) { foreach (x1 o in pending) { if (o.GUID == Guid) { stm = o.STM; end.Add(o); pending.Remove(o); break; } } } } else if (x.value == "0100")//关机 { state = 3; lock (_lock) { foreach (x1 o in pendinge) { if (o.GUID == Guid) { stm = o.STM; ok.Add(o); pendinge.Remove(o); break; } } } } } else { lock (_lock) { foreach (x1 o in pending) { if (o.GUID == Guid) { stm = o.STM; msg = x.message + "[重试(" + o.getretry().ToString() + ")]"; //o.getretry(); //outdate.Add(o); //pendinge.Remove(o); break; } } } } IDictionary <string, string> parameters = new Dictionary <string, string>(); parameters.Add("action", "updateIrriPlanState"); parameters.Add("state", state.ToString()); parameters.Add("stm", stm); parameters.Add("hcd", hcd); parameters.Add("acttm", DateTime.Now.ToString()); parameters.Add("msg", msg); parameters.Add("id", "1"); parameters.Add("guid", Guid); loginstatus ret = new loginstatus(); HttpWebResponse response = CreatePostHttpResponse(url_update, parameters, null, null, Encoding.UTF8, cookies); if (response != null) { StreamReader sr = new StreamReader(response.GetResponseStream()); String txt = sr.ReadToEnd(); ret = JsonConvert.DeserializeObject <loginstatus>(txt); return(ret.success); } return(true); }