private RemoteResult GetRemoteResult(string guid, string deviceCode) { RemoteResult res = null; for (int i = 0; i < 5; i++) { //if (_relist.ContainsKey(guid) && _relist.TryRemove(guid, out res)) if (_relist.TryRemove(guid, out res)) { break; } else { Thread.Sleep(1000); } } if (res == null) { if (_offdevlist.Contains(deviceCode)) { string ss = "下线"; //res = new RemoteResult("", "", deviceCode + "下线", null, null); } } return(res); }
private RemoteResult GetRemoteResult1(string guid, string deviceCode) { RemoteResult res = null; for (int i = 0; i < 5; i++) { //if (_relist.ContainsKey(guid) && _relist.TryRemove(guid, out res)) if (_relist.TryRemove(guid, out res)) { break; } else { Thread.Sleep(1000); } } return(res); }
private RemoteResult GetRemoteResult(string guid) { var sql = string.Format("select cmd_datas from T_CommondResult where cmd_guid='{0}'", guid); Thread.Sleep(1000); RemoteResult res = null; for (int i = 0; i < 5; i++) { var obj = DbHelperSQL.GetSingle(sql); if (obj != null) { res = new RemoteResult(); res.Datas = (byte[])obj; res.tag = guid; break; } else { Thread.Sleep(500); } //var obj = DbHelperSQL.Query(sql); //if (obj != null&&obj.Tables[0].Rows.Count>0) //{ // res = new RemoteResult(); // res.Datas = (byte[])obj.Tables[0].Rows[0][0]; // res.tag = guid; // break; //} //else //{ // Thread.Sleep(500); //} } return(res); }
public string SendCommandAndGetResult(byte[] datas, CommandConst name, int returnLength, string devicecode, out RemoteResult res) { res = null; string msg = string.Empty; if (string.IsNullOrEmpty(devicecode)) { return("设备号不可为空"); } var guid = Guid.NewGuid().ToString(); msg = SendCommand(datas, name, returnLength, devicecode, guid); if (string.IsNullOrEmpty(msg)) { res = GetRemoteResult(guid, devicecode); } //重试一次 //if (res == null) //{ // if (ClientReAttach()) // { // msg = SendCommand(datas, name, returnLength, devicecode, guid); // if (string.IsNullOrEmpty(msg)) // { // res = GetRemoteResult(guid, devicecode); // } // } //} return(msg); }
public string SendCommandAndGetResult(byte[] datas, CommandConst name, int returnLength, string devicecode, out RemoteResult res) { res = null; string msg = string.Empty; if (string.IsNullOrEmpty(devicecode)) { return("设备号不可为空"); } string testguid = string.Empty; var cint = (int)name; var testguidkey = "TestGuid" + cint.ToString(); var testguidcfg = ConfigurationManager.AppSettings[testguidkey]; if (testguidcfg != null) { testguid = testguidcfg.ToString(); } string guid = null; if (string.IsNullOrEmpty(testguid)) { guid = Guid.NewGuid().ToString(); msg = SendCommand(datas, name, returnLength, devicecode, guid); } else { guid = testguid; } if (string.IsNullOrEmpty(msg)) { res = GetRemoteResult(guid); } if (res != null) { res.deviceCode = devicecode; res.name = name; res.senderUser = commandClient.Sender; } else { msg = "获取信息失败"; } return(msg); }