/// <summary> /// 获取设备信息 /// </summary> /// <param name="IsOnline"></param> private void GetDeviceInfo(bool IsOnline) { XmlHelper xml = new XmlHelper(); string ip = ""; //首先获取本机IP if (IsOnline) { ip = NetworkHelper.GetIpAddress(); //ip = "192.168.0.140";//制动泵 //ip = "192.168.0.129";//踏板 //ip = "192.168.0.173";//前桥 //ip = "192.168.0.174";//后桥 xml.UpdateInnerText("/Root/Local/LocalIp", ip); deviceModel = deviceDAL.GetModel("", "", ip); } else { if (BaseVariable.IsRunFirst) { this.btnLogin.Enabled = false; return; } ip = xml.SelectValue("/Root/Local/LocalIp"); deviceModel = lDeviceDAL.GetModel(string.Format("DeviceIP='{0}'", ip)); } if (deviceModel == null) { this.btnLogin.Enabled = false; MessageBox.Show("获取设备信息失败,请联系管理人员", "系统提示"); return; } BaseVariable.DeviceEntity = deviceModel;//当前设备信息 this.lblDevice.Text = "设备:" + deviceModel.DeviceID; }
/// <summary> /// 获取设备信息 /// </summary> private void Select() { try { string method = context.Request.Params["method"].ToString(); if (method == "model") { string TID = context.Request.Params["TID"].ToString(); string DeviceID = context.Request.Params["DeviceID"].ToString(); string DeviceIP = context.Request.Params["DeviceIP"].ToString(); string sql = " 1=1 "; if (!string.IsNullOrEmpty(TID)) { sql += string.Format(" AND TID = {0}", TID); } if (!string.IsNullOrEmpty(DeviceID)) { sql += string.Format(" AND DeviceID = '{0}'", DeviceID); } if (!string.IsNullOrEmpty(DeviceIP)) { sql += string.Format(" AND DeviceIP = '{0}'", DeviceIP); } DeviceInfoMDL model = DataDAL.GetModel(sql); if (model != null) { ReturnData.Code = "1"; ReturnData.Msg = "OK"; ReturnData.Data = model; } } else { DataSet set = DataDAL.GetList(""); ReturnData.Code = "0"; ReturnData.Msg = "NOK"; if (set != null && set.Tables.Count > 0) { DataTable table = set.Tables[0]; if (table != null && table.Rows.Count > 0) { object obj = TableHelper.TableToObj(table); ReturnData.Code = "1"; ReturnData.Msg = "OK"; ReturnData.Data = obj; } } } } catch (Exception ex) { CLog.WriteErrLog(ex.Message); ReturnData.Code = "0"; ReturnData.Msg = "NOK"; } }