/// <summary> /// 通过单个分机号获取正在等待的分机信息 /// </summary> /// <returns></returns> public static void GetChannelsinfo(out List <Channelsinfo> infoes) { infoes = new List <Channelsinfo>(); string sql = "SELECT uuid,ExtensionNO,application,application_data from ipvt_channelsinfotable"; MySqlDataReader reader = null; try { reader = CustomMySqlHelper.ExecuteDataReader(sql); while (reader.Read()) { Channelsinfo model = new Channelsinfo(); model.Uuid = EvaluationHelper.ObjectToString(reader["uuid"]); model.ExtNo = EvaluationHelper.ObjectToString(reader["ExtensionNO"]); model.ApplicationInfo = EvaluationHelper.ObjectToString(reader["application"]); model.ApplicationDate = EvaluationHelper.ObjectToString(reader["application_data"]); infoes.Add(model); } } catch (Exception ex) { LogHelper.MainLog(ex.Message); } finally { if (reader != null) { reader.Close(); } } }
/// <summary> /// 获取SDK配置信息 /// </summary> /// <param name="models"></param> public static void GetSdkModels(out List <SdkSetupModel> models) { models = new List <SdkSetupModel>(); string sql = "select SdkID,SdkIP,SdkPort from ipvt_sdkinfotable"; MySqlDataReader reader = null; try { reader = CustomMySqlHelper.ExecuteDataReader(sql); if (reader != null) { while (reader.Read()) { models.Add(new SdkSetupModel() { Id = EvaluationHelper.ObjectToInt(reader["SdkID"]), Ip = EvaluationHelper.ObjectToString(reader["SdkIP"]), Port = EvaluationHelper.ObjectToString(reader["SdkPort"]) }); } } } catch (Exception ex) { LogHelper.MainLog(ex.ToString()); } finally { if (reader != null) { reader.Close(); } } }
/// <summary> /// 通过单个分机号获取正在等待的分机信息 /// </summary> /// <param name="exten">分机号</param> /// <returns></returns> public static Channelsinfo GetChannelsinfo(string exten) { string sql = "SELECT uuid,ExtensionNO,application,application_data from ipvt_channelsinfotable where ExtensionNO=?extenNo"; var ps = new MySqlParameter[1]; ps[0] = new MySqlParameter("?extenNo", exten); MySqlDataReader reader = null; try { reader = CustomMySqlHelper.ExecuteDataReader(sql, ps); while (reader.Read()) { Channelsinfo model = new Channelsinfo(); model.Uuid = EvaluationHelper.ObjectToString(reader["uuid"]); model.ExtNo = EvaluationHelper.ObjectToString(reader["ExtensionNO"]); model.ApplicationInfo = EvaluationHelper.ObjectToString(reader["application"]); model.ApplicationDate = EvaluationHelper.ObjectToString(reader["application_data"]); return(model); } } catch (Exception ex) { LogHelper.MainLog(ex.Message); } finally { if (reader != null) { reader.Close(); } } return(null); }
/// <summary> /// 获取输入/输出端口报警设置原型 /// </summary> /// <param name="models"></param> public static void GetPortAlarmModels(out List <CommonModel> models) { models = new List <CommonModel>(); string sql = "select AlarmTypeID,AlarmType from ipvt_alarmtypetable"; MySqlDataReader reader = null; try { reader = CustomMySqlHelper.ExecuteDataReader(sql); while (reader.Read()) { CommonModel model = new CommonModel(); model.Id = EvaluationHelper.ObjectToInt(reader["AlarmTypeID"]); model.Content = EvaluationHelper.ObjectToString(reader["AlarmType"]); models.Add(model); } } catch (Exception ex) { LogHelper.MainLog("error in GetPortAlarmModels()" + ex.Message); } finally { if (reader != null) { reader.Close(); //读取完关闭reader对象 } } }
/// <summary> /// 获取报警信息 /// </summary> /// <param name="id"></param> /// <returns></returns> public static string GetAlarmType(int id) { if (id > 0) { string sql = "select AlarmType from ipvt_alarmtypetable where AlarmTypeID=?id"; var result = CustomMySqlHelper.ExecuteScalar(sql, new MySqlParameter("?id", id)); return(EvaluationHelper.ObjectToString(result)); } return(null); }
/// <summary> /// 获取 /// </summary> /// <returns></returns> public static VideoLinkageModel GetVideoLinkageModel(int did, int pnum) { VideoLinkageModel model = null; if (did > 0 && pnum >= 0)//一代设备的面板号有0的 { string sql = "SELECT * FROM ipvt_videolinkagetable WHERE DeviceId=?did AND PanelNumber=?pnum;"; MySqlParameter[] ps = new MySqlParameter[2]; ps[0] = new MySqlParameter("?did", did); ps[1] = new MySqlParameter("?pnum", pnum); MySqlDataReader reader = null; try { reader = CustomMySqlHelper.ExecuteDataReader(sql, ps); while (reader.Read()) { model = new VideoLinkageModel(); model.Id = EvaluationHelper.ObjectToInt(reader["ID"]); model.DeviceId = EvaluationHelper.ObjectToInt(reader["DeviceId"]); model.PanelNumber = EvaluationHelper.ObjectToInt(reader["PanelNumber"]); model.ChannelNumber = EvaluationHelper.ObjectToByte(reader["ChannelNumber"]); model.NetConnectMethods = EvaluationHelper.ObjectToByte(reader["NetConnectMethods"]); model.ImgFormat = EvaluationHelper.ObjectToByte(reader["ImgFormat"]); model.TransmitJur = EvaluationHelper.ObjectToByte(reader["TransmitJur"]); model.ReceivePort = EvaluationHelper.ObjectToUshort(reader["ReceivePort"]); model.ForwardingPort = EvaluationHelper.ObjectToUshort(reader["ForwardingPort"]); model.ServerUserId = EvaluationHelper.ObjectToString(reader["ServerUserId"]); model.ServerIp = EvaluationHelper.ObjectToString(reader["ServerIp"]); model.TranServerIp = EvaluationHelper.ObjectToString(reader["TranServerIp"]); model.UserName = EvaluationHelper.ObjectToString(reader["UserName"]); model.UserPwd = EvaluationHelper.ObjectToString(reader["UserPwd"]); model.DeviceType = EvaluationHelper.ObjectToByte(reader["DeviceType"]); model.UserVerify = EvaluationHelper.ObjectToString(reader["UserVerify"]); break; } } catch (Exception ex) { LogHelper.MainLog("error in GetVideoLinkageModel!" + ex.Message); } finally { if (reader != null) { reader.Close(); //读取完关闭reader对象 } } } return(model); }
/// <summary> /// 获取语音文件名 /// </summary> /// <param name="id"></param> /// <returns></returns> public static string GetVoiceNameById(int id) { if (id < 0) { return(string.Empty); } string sql = "SELECT VoiceFileName from ipvt_voicefiletable where ID=?id"; var result = CustomMySqlHelper.ExecuteScalar(sql, new MySqlParameter("?id", id)); return(EvaluationHelper.ObjectToString(result)); }
/// <summary> /// 获取指定分机id的面板名称 /// </summary> /// <param name="num">面板号</param> /// <param name="id">分机id</param> public static string GetPanelName(string id, string num) { string sql = @"select a.PanelName from ipvt_panelinfotable as a inner join ipvt_extensionmessagetable as b on a.ExtensionID=b.ExtensionID where a.PanelNum=?num and b.ExtensionNO=?id "; MySqlParameter[] pars = { new MySqlParameter("?num", num), new MySqlParameter("?id", EvaluationHelper.StringToInt(id)) }; var result = CustomMySqlHelper.ExecuteScalar(sql, pars); return(EvaluationHelper.ObjectToString(result)); }
/// <summary> /// 获取寻呼话筒简要信息 /// </summary> /// <returns></returns> public static void GetPhones(out List <Device> devices) { devices = new List <Device>(); string sql; sql = "select A.DeviceID,A.DeviceName,A.DeviceType,A.DeviceIP,A.ExtensionID,B.ExtensionNo" + " from ipvt_deviceinfotable AS A,ipvt_extensionmessagetable AS B" + " WHERE A.DeviceType=0 and A.ExtensionID=B.ExtensionID"; try { DataSet set = CustomMySqlHelper.ExecuteDataSet(sql); if (set.Tables.Count > 0) { DataRowCollection rows = set.Tables[0].Rows; foreach (DataRow row in rows) { var device = new Device(); device.Name = row["DeviceName"].ToString(); device.Id = EvaluationHelper.ObjectToInt(row["DeviceID"]); device.Type = EvaluationHelper.ObjectToInt(row["DeviceType"]); device.Ip = EvaluationHelper.ObjectToString(row["DeviceIP"]); device.Extension = new Extension { Number = EvaluationHelper.ObjectToString(row["ExtensionNo"]), Id = EvaluationHelper.ObjectToInt(row["ExtensionID"]), }; if (string.IsNullOrEmpty(device.Name)) //如果名称为空给设备添加默认名称=分机号 { device.Name = EvaluationHelper.ObjectToString(row["ExtensionNo"]); } devices.Add(device); } } } catch (Exception ex) { LogHelper.MainLog("error int GetPanels(int extensionId)!" + ex); } }
/// <summary> /// 获取设备 /// </summary> /// <param name="decies"></param> public static void GetDevices(out List <Device> decies) { decies = new List <Device>(); if (HaveDb()) { SQLiteDataReader reader = null; try { string sql = "select * from device"; reader = SqLiteHelper.ExcuteReader(SqLiteHelper.Open(_dbPath), sql); while (reader.Read()) { Device device = new Device(); device.Id = EvaluationHelper.ObjectToInt(reader["did"]); device.Ip = EvaluationHelper.ObjectToString(reader["ip"]); device.Name = EvaluationHelper.ObjectToString(reader["name"]); device.Type = EvaluationHelper.ObjectToInt(reader["type"]); device.IsHaveVideo = EvaluationHelper.ObjectToInt(reader["video"]); device.Generation = EvaluationHelper.ObjectToInt(reader["generation"]); device.Extension.Number = EvaluationHelper.ObjectToString(reader["extno"]); device.PanelNum = EvaluationHelper.ObjectToInt(reader["panelnum"]); //device.StateString = "离线"; //device.StateString = "通话中"; device.StateString = "空闲"; //device.StateString = "呼叫中"; decies.Add(device); } } catch (Exception ex) { LogHelper.MainLog(ex.Message); } finally { if (reader != null) { reader.Close(); } } } }
/// <summary> /// 获取转移设置信息 /// </summary> /// <param name="list"></param> public static void GetTransInfo(out List <TranSetupInfo> list) { list = new List <TranSetupInfo>(); string sql = "select ID,TranType,StartTime,EndTime," + "(SELECT ExtensionNO FROM ipvt_extensionmessagetable where ExtensionID=StairTran) as Stair," + "(SELECT ExtensionNO FROM ipvt_extensionmessagetable where ExtensionID=SecondTran) as Second," + "(SELECT ExtensionNO FROM ipvt_extensionmessagetable where ExtensionID=ThreeTran) as Three," + "IsEnable,Description from ipvt_transetuptable"; MySqlDataReader reader = null; try { reader = CustomMySqlHelper.ExecuteDataReader(sql); while (reader.Read()) { var model = new TranSetupInfo(); model.Id = EvaluationHelper.ObjectToInt(reader["ID"]); model.TranType = EvaluationHelper.ObjectToInt(reader["TranType"]); model.StartTime = EvaluationHelper.ObjectToInt(reader["StartTime"]); model.EndTime = EvaluationHelper.ObjectToInt(reader["EndTime"]); model.IsEnable = EvaluationHelper.ObjectToInt(reader["IsEnable"]); model.StairTran = EvaluationHelper.ObjectToString(reader["Stair"]); model.SecondTran = EvaluationHelper.ObjectToString(reader["Second"]); model.ThreeTran = EvaluationHelper.ObjectToString(reader["Three"]); model.Description = EvaluationHelper.ObjectToString(reader["Description"]); list.Add(model); } } catch (Exception ex) { LogHelper.MainLog(ex.ToString()); } finally { if (reader != null) { reader.Close(); //读取完关闭reader对象 } } }
/// <summary> /// 根据提供的分机号获取设备信息 /// </summary> /// <param name="extenNo"></param> /// <returns></returns> public static Device GetDevice(string extenNo, string geoid = null) { Device device = null; #region 获取设备信息 var sqlBuilder = new StringBuilder(); sqlBuilder.Append("SELECT * FROM (SELECT A.DeviceID,A.DeviceName,A.DeviceType,"); sqlBuilder.Append("A.DeviceRegCode,A.FactoryNum,A.PhoneLevel,A.DeviceTypeInfo,"); sqlBuilder.Append("A.DeviceIP,A.DevicePort,A.SoftVersion,A.HardVersion,A.Manufacturer,A.GeoId,A.GroupID,"); sqlBuilder.Append("B.ExtensionID AS ExtenID,B.ExtensionNo AS ExtenNO,B.StateID AS StateID,B.PhoneState "); sqlBuilder.Append("FROM ipvt_deviceinfotable AS A,ipvt_extensionmessagetable AS B "); sqlBuilder.Append("WHERE B.ExtensionNo=?extenNo AND A.ExtensionID=B.ExtensionID "); if (!string.IsNullOrEmpty(geoid)) { sqlBuilder.Append(" AND A.GroupID= " + geoid); } sqlBuilder.Append(") AS C "); //sqlBuilder.Append(" LEFT JOIN ipvt_geoinfotable AS D ON C.GeoId=D.GeoID "); sqlBuilder.Append(@" LEFT JOIN ipvt_geoinfotable AS D ON C.GeoId=D.GeoID LEFT JOIN ipvt_panelinfotable as E on C.ExtenID=E.ExtensionID ORDER BY ExtenID,E.PanelNum"); var param = new MySqlParameter[1]; param[0] = new MySqlParameter("?extenNo", Convert.ToInt32(extenNo)); MySqlDataReader reader = null; try { reader = CustomMySqlHelper.ExecuteDataReader(sqlBuilder.ToString(), param); if (reader != null) { while (reader.Read()) { if (device == null) { device = new Device(); device.Name = EvaluationHelper.ObjectToString(reader["DeviceName"]); device.Id = EvaluationHelper.ObjectToInt(reader["DeviceID"]); device.Type = EvaluationHelper.ObjectToInt(reader["DeviceType"]); device.Ip = EvaluationHelper.ObjectToString(reader["DeviceIP"]); device.PhoneLevel = EvaluationHelper.ObjectToInt(reader["PhoneLevel"]); device.RegistCode = EvaluationHelper.ObjectToString(reader["DeviceRegCode"]); device.SoftVersion = EvaluationHelper.ObjectToString(reader["SoftVersion"]); device.HardVersion = EvaluationHelper.ObjectToString(reader["HardVersion"]); device.DeviceTypeInfo = EvaluationHelper.ObjectToString(reader["DeviceTypeInfo"]); if (string.IsNullOrEmpty(device.DeviceTypeInfo) || device.DeviceTypeInfo == "IP-Center" || device.DeviceTypeInfo == "IP-Phone") { device.Generation = 1; } else { device.Generation = 2; } device.ColorString = GetColor(device.DeviceTypeInfo); if (reader["GroupID"] != DBNull.Value) { device.GroupId = EvaluationHelper.ObjectToInt(reader["GroupID"]); } device.Port = EvaluationHelper.ObjectToInt(reader["DevicePort"]); device.Extension = new Extension { Number = EvaluationHelper.ObjectToString(reader["ExtenNO"]), Id = EvaluationHelper.ObjectToInt(reader["ExtenID"]), State = StateManager.GetState(EvaluationHelper.ObjectToInt(reader["StateID"])), PhoneState = EvaluationHelper.ObjectToInt(reader["PhoneState"]) == 0 ? State.STAT_INVALID : State.STAT_DEVICE_TALKING }; if (string.IsNullOrEmpty(device.Name)) //如果名称为空给设备添加默认名称=分机号 { device.Name = EvaluationHelper.ObjectToString(reader["ExtenNO"]); } if (reader["GeoId"] != DBNull.Value) { var pnt = new GeoPoint(); pnt.Id = EvaluationHelper.ObjectToInt(reader["GeoID"]); pnt.Name = EvaluationHelper.ObjectToString(reader["Name"]); pnt.Address = EvaluationHelper.ObjectToString(reader["FormattedAddress"]); pnt.Phone = EvaluationHelper.ObjectToString(reader["phone"]); pnt.Latitude = EvaluationHelper.ObjectToDouble(reader["Latitude"]); pnt.Longitude = EvaluationHelper.ObjectToDouble(reader["Longitude"]); pnt.Note = EvaluationHelper.ObjectToString(reader["Note"]); device.GeoPoint = pnt; } else { device.GeoPoint = new GeoPoint(); } device.Manufacturer = EvaluationHelper.ObjectToString(reader["Manufacturer"]); if (!string.IsNullOrEmpty(EvaluationHelper.ObjectToString(reader["PanelID"]))) { var panel = new PanelDevice(); //面板对象 panel.Id = EvaluationHelper.ObjectToInt(reader["PanelID"]); //面板号 panel.Number = EvaluationHelper.ObjectToInt(reader["PanelNum"]); //面板号 int stateNum = EvaluationHelper.ObjectToInt(reader["PanelState"]); //面板状态号 switch (stateNum) { case 0: panel.LineState = State.STAT_DEVICE_ONLINE; //在线 break; case 1: panel.LineState = State.STAT_DEVICE_OFFLINE; //离线 break; } int alarmState = EvaluationHelper.ObjectToInt(reader["TamperAlarm"]); if (alarmState == 2) { panel.State = State.STAT_ANTI_DISMANTLE_ALARM; //防拆警报 } else { panel.State = panel.LineState; } panel.Name = EvaluationHelper.ObjectToString(reader["PanelName"]); //面板名 if (string.IsNullOrEmpty(panel.Name)) { panel.Name = string.Format("面板{0}", panel.Number); } if (device.Extension.State == State.STAT_DEVICE_OFFLINE) { panel.State = State.STAT_DEVICE_OFFLINE; } else if (panel.State == State.STAT_ANTI_DISMANTLE_ALARM) { device.Extension.AlarmState = State.STAT_ANTI_DISMANTLE_ALARM; } device.Panels.Add(panel); } } else { if (!string.IsNullOrEmpty(EvaluationHelper.ObjectToString(reader["PanelID"]))) { var panel = new PanelDevice(); //面板对象 panel.Id = EvaluationHelper.ObjectToInt(reader["PanelID"]); //面板号 panel.Number = EvaluationHelper.ObjectToInt(reader["PanelNum"]); //面板号 int stateNum = EvaluationHelper.ObjectToInt(reader["PanelState"]); //面板状态号 switch (stateNum) { case 0: panel.LineState = State.STAT_DEVICE_ONLINE; //在线 break; case 1: panel.LineState = State.STAT_DEVICE_OFFLINE; //离线 break; } int alarmState = EvaluationHelper.ObjectToInt(reader["TamperAlarm"]); if (alarmState == 2) { panel.State = State.STAT_ANTI_DISMANTLE_ALARM; //防拆警报 } else { panel.State = panel.LineState; } panel.Name = EvaluationHelper.ObjectToString(reader["PanelName"]); //面板名 if (string.IsNullOrEmpty(panel.Name)) { panel.Name = string.Format("面板{0}", panel.Number); } if (device.Extension.State == State.STAT_DEVICE_OFFLINE) { panel.State = State.STAT_DEVICE_OFFLINE; } else if (panel.State == State.STAT_ANTI_DISMANTLE_ALARM) { device.Extension.AlarmState = State.STAT_ANTI_DISMANTLE_ALARM; } device.Panels.Add(panel); } } //break; } } } catch (Exception ex) { LogHelper.MainLog("error int GetDevice(int extenNo)!" + ex.StackTrace); } finally { if (reader != null) { reader.Close(); } } #endregion //#region 获取设备的面板信息 //if (device != null) //{ // List<PanelDevice> list; // GetPanels(device.Extension.Id, out list); // //LogHelper.MainLog(string.Format("in GetDevice(string extenNo),ExtensionNumber:{1} --- PanelNum:{0}", list.Count, device.Extension.Number)); // foreach (PanelDevice panel in list) // { // if (panel.State == State.STAT_ANTI_DISMANTLE_ALARM) // { // device.Extension.AlarmState = State.STAT_ANTI_DISMANTLE_ALARM; // } // device.Panels.Add(panel); // } //} //#endregion return(device); }
/// <summary> /// 获取指定分机id的面板信息 /// </summary> /// <param name="extensionId">分机id</param> /// <param name="list">out 面板信息集合</param> public static void GetPanels(int extensionId, out List <PanelDevice> list) { list = new List <PanelDevice>(); //查询面板信息的sql语句 string sqlStr = "select * from ipvt_panelinfotable where ExtensionID=?id order by PanelNum"; var param = new MySqlParameter[1]; //参数对象 param[0] = new MySqlParameter("?id", extensionId); //获取reader对象 MySqlDataReader reader = null; try { reader = CustomMySqlHelper.ExecuteDataReader(sqlStr, param); if (reader != null) { while (reader.Read()) { var panel = new PanelDevice(); //面板对象 panel.Id = EvaluationHelper.ObjectToInt(reader["PanelID"]); //面板号 panel.Number = EvaluationHelper.ObjectToInt(reader["PanelNum"]); //面板号 int stateNum = EvaluationHelper.ObjectToInt(reader["PanelState"]); //面板状态号 switch (stateNum) { case 0: panel.LineState = State.STAT_DEVICE_ONLINE; //在线 break; case 1: panel.LineState = State.STAT_DEVICE_OFFLINE; //离线 break; } int alarmState = EvaluationHelper.ObjectToInt(reader["TamperAlarm"]); if (alarmState == 2) { panel.State = State.STAT_ANTI_DISMANTLE_ALARM; //防拆警报 } else { panel.State = panel.LineState; } panel.Name = EvaluationHelper.ObjectToString(reader["PanelName"]); //面板名 if (string.IsNullOrEmpty(panel.Name)) { panel.Name = string.Format("面板{0}", panel.Number); } list.Add(panel); //将面板信息对象加入设备面板集合 } } } catch (Exception ex) { LogHelper.MainLog("error int GetPanels(int extensionId)!" + ex); } finally { if (reader != null) { reader.Close(); //读取完关闭reader对象 } } }
/// <summary> /// 根据提供的组id获取设备信息,id为-1表示获取所有 /// </summary> /// <param name="devices">out 设备集合</param> /// <param name="groupid">组id</param> public static void GetDevices(out List <Device> devices, int groupid = -1, string geoid = null, string deviceid = null) { LogHelper.MainLog("GetDevices1 time:" + DateTime.Now.TimeOfDay); devices = new List <Device>(); var points = new List <GeoPoint>(); DataSet set; #region sql语句 StringBuilder sqlBuilder = new StringBuilder(); sqlBuilder.Append("SELECT * FROM (SELECT A.DeviceID,A.DeviceName,A.DeviceType,"); sqlBuilder.Append("A.DeviceRegCode,A.FactoryNum,A.PhoneLevel,A.DeviceTypeInfo,"); sqlBuilder.Append("A.DeviceIP,A.DevicePort,A.SoftVersion,A.HardVersion,A.Manufacturer,A.GeoId,A.GroupID,"); sqlBuilder.Append("B.ExtensionID AS ExtenID,B.ExtensionNo AS ExtenNO,B.StateID AS StateID,B.PhoneState,B.PanelNum "); sqlBuilder.Append("FROM ipvt_deviceinfotable AS A left join ipvt_extensionmessagetable AS B "); sqlBuilder.Append("on A.ExtensionID=B.ExtensionID where 1=1"); if (groupid != -1) { sqlBuilder.Append(" AND A.GroupID=" + groupid); } if (!string.IsNullOrEmpty(geoid)) { sqlBuilder.Append(" AND (A.GroupID=" + geoid + " or A.DeviceIP='" + deviceid + "' )"); } sqlBuilder.Append(") AS C "); sqlBuilder.Append(@" LEFT JOIN ipvt_geoinfotable AS D ON C.GeoId=D.GeoID LEFT JOIN ipvt_panelinfotable as E on C.ExtenID=E.ExtensionID ORDER BY ExtenID,E.PanelNum"); #endregion #region 获取设备集 try { set = CustomMySqlHelper.ExecuteDataSet(sqlBuilder.ToString()); if (set.Tables.Count > 0) { DataRowCollection rows = set.Tables[0].Rows; foreach (DataRow row in rows) { int id = EvaluationHelper.ObjectToInt(row["DeviceID"]); if (!devices.Exists(m => m.Id == id)) { var device = new Device(); device.Name = EvaluationHelper.ObjectToString(row["DeviceName"]); device.Id = EvaluationHelper.ObjectToInt(row["DeviceID"]); device.Type = EvaluationHelper.ObjectToInt(row["DeviceType"]); device.Ip = EvaluationHelper.ObjectToString(row["DeviceIP"]); device.PhoneLevel = EvaluationHelper.ObjectToInt(row["PhoneLevel"]); device.RegistCode = EvaluationHelper.ObjectToString(row["DeviceRegCode"]); device.SoftVersion = EvaluationHelper.ObjectToString(row["SoftVersion"]); device.HardVersion = EvaluationHelper.ObjectToString(row["HardVersion"]); device.DeviceTypeInfo = EvaluationHelper.ObjectToString(row["DeviceTypeInfo"]); if (string.IsNullOrEmpty(device.DeviceTypeInfo) || device.DeviceTypeInfo == "IP-Center" || device.DeviceTypeInfo == "IP-Phone") { device.Generation = 1; } else { device.Generation = 2; } device.ColorString = GetColor(device.DeviceTypeInfo); if (row["GroupID"] != DBNull.Value) { device.GroupId = EvaluationHelper.ObjectToInt(row["GroupID"]); } device.Port = EvaluationHelper.ObjectToInt(row["DevicePort"]); device.Extension = new Extension { Number = EvaluationHelper.ObjectToString(row["ExtenNO"]), Id = EvaluationHelper.ObjectToInt(row["ExtenID"]), State = StateManager.GetState(EvaluationHelper.ObjectToInt(row["StateID"])), PhoneState = EvaluationHelper.ObjectToInt(row["PhoneState"]) == 0 ? State.STAT_INVALID : State.STAT_DEVICE_TALKING, PanelNum = EvaluationHelper.ObjectToString(row["PanelNum"]) }; if (string.IsNullOrEmpty(device.Name)) //如果名称为空给设备添加默认名称=分机号 { device.Name = EvaluationHelper.ObjectToString(row["ExtenNO"]); } GeoPoint pnt = new GeoPoint(); if (row["GeoId"] != DBNull.Value) { pnt.Id = EvaluationHelper.ObjectToInt(row["GeoId"]); bool flag = false; foreach (var p in points) { if (pnt.Equals(p)) { pnt = p; flag = true; break; } } if (!flag) { pnt.Id = EvaluationHelper.ObjectToInt(row["GeoID"]); pnt.Name = EvaluationHelper.ObjectToString(row["Name"]); pnt.Address = EvaluationHelper.ObjectToString(row["FormattedAddress"]); pnt.Phone = EvaluationHelper.ObjectToString(row["phone"]); pnt.Latitude = EvaluationHelper.ObjectToDouble(row["Latitude"]); pnt.Longitude = EvaluationHelper.ObjectToDouble(row["Longitude"]); pnt.Note = EvaluationHelper.ObjectToString(row["Note"]); } } device.GeoPoint = pnt; device.Manufacturer = EvaluationHelper.ObjectToString(row["Manufacturer"]); if (!string.IsNullOrEmpty(EvaluationHelper.ObjectToString(row["PanelID"]))) { var panel = new PanelDevice(); //面板对象 panel.Id = EvaluationHelper.ObjectToInt(row["PanelID"]); //面板号 panel.Number = EvaluationHelper.ObjectToInt(row["PanelNum1"]); //面板号 int stateNum = EvaluationHelper.ObjectToInt(row["PanelState"]); //面板状态号 switch (stateNum) { case 0: panel.LineState = State.STAT_DEVICE_ONLINE; //在线 break; case 1: panel.LineState = State.STAT_DEVICE_OFFLINE; //离线 break; } int alarmState = EvaluationHelper.ObjectToInt(row["TamperAlarm"]); if (alarmState == 2) { panel.State = State.STAT_ANTI_DISMANTLE_ALARM; //防拆警报 } else { panel.State = panel.LineState; } panel.Name = EvaluationHelper.ObjectToString(row["PanelName"]); //面板名 if (string.IsNullOrEmpty(panel.Name)) { panel.Name = string.Format("面板{0}", panel.Number); } if (device.Extension.State == State.STAT_DEVICE_OFFLINE) { panel.State = State.STAT_DEVICE_OFFLINE; } else if (panel.State == State.STAT_ANTI_DISMANTLE_ALARM) { device.Extension.AlarmState = State.STAT_ANTI_DISMANTLE_ALARM; } device.Panels.Add(panel); } devices.Add(device); } else { if (!string.IsNullOrEmpty(EvaluationHelper.ObjectToString(row["PanelID"]))) { Device device = devices.Find(m => m.Id == id); var panel = new PanelDevice(); //面板对象 panel.Id = EvaluationHelper.ObjectToInt(row["PanelID"]); //面板号 panel.Number = EvaluationHelper.ObjectToInt(row["PanelNum1"]); //面板号 int stateNum = EvaluationHelper.ObjectToInt(row["PanelState"]); //面板状态号 switch (stateNum) { case 0: panel.LineState = State.STAT_DEVICE_ONLINE; //在线 break; case 1: panel.LineState = State.STAT_DEVICE_OFFLINE; //离线 break; } int alarmState = EvaluationHelper.ObjectToInt(row["TamperAlarm"]); if (alarmState == 2) { panel.State = State.STAT_ANTI_DISMANTLE_ALARM; //防拆警报 } else { panel.State = panel.LineState; } panel.Name = EvaluationHelper.ObjectToString(row["PanelName"]); //面板名 if (string.IsNullOrEmpty(panel.Name)) { panel.Name = string.Format("面板{0}", panel.Number); } if (device.Extension.State == State.STAT_DEVICE_OFFLINE) { panel.State = State.STAT_DEVICE_OFFLINE; } else if (panel.State == State.STAT_ANTI_DISMANTLE_ALARM) { device.Extension.AlarmState = State.STAT_ANTI_DISMANTLE_ALARM; } device.Panels.Add(panel); } } } } } catch (Exception ex) { LogHelper.MainLog("error int GetDevices!" + ex); } #endregion LogHelper.MainLog("GetDevices2 time:" + DateTime.Now.TimeOfDay); //#region 获取设备的面板信息 //foreach (Device dev in devices) //{ // List<PanelDevice> list; // GetPanels(dev.Extension.Id, out list); // //LogHelper.MainLog(string.Format("GetDevices(int groupid = -1),ExtensionNumber:{1} --- PanelNum:{0}", list.Count, dev.Extension.Number)); // foreach (PanelDevice panel in list) // { // if (dev.Extension.State == State.STAT_DEVICE_OFFLINE) // { // panel.State = State.STAT_DEVICE_OFFLINE; // } // else if (panel.State == State.STAT_ANTI_DISMANTLE_ALARM) // { // dev.Extension.AlarmState = State.STAT_ANTI_DISMANTLE_ALARM; // } // dev.Panels.Add(panel); // } //} //#endregion //LogHelper.MainLog("GetDevices3 time:" + DateTime.Now.TimeOfDay); //#region 获取转移信息 //foreach (Device dev in devices) //{ // if (dev.Type == 0) //刷选寻呼话筒 // { // List<Transfer> trans; // TransferTableManager.GetTransferTableByExtension(out trans, dev.Extension); //转移信息集合 // foreach (Transfer tran in trans) // { // dev.TransferTable.Add(tran); // } // } //} //#endregion //LogHelper.MainLog("GetDevices4 time:" + DateTime.Now.TimeOfDay); points.Clear(); }
/// <summary> /// 获取日志 /// </summary> /// <param name="type">日志类型</param> /// <param name="logs"></param> public static void GetLogs(LogTypeEnum type, out List <LogMessage> logs) { logs = new List <LogMessage>(); if (HaveDb()) { int num = 0; switch (type) { case LogTypeEnum.System: //系统日志10 num = 10; break; case LogTypeEnum.Operation: //操作日志11 num = 11; break; case LogTypeEnum.Call: //呼叫日志12 num = 12; break; case LogTypeEnum.Video: //视频日志13 num = 13; break; case LogTypeEnum.Alarm: //报警日志14 num = 14; break; case LogTypeEnum.OrdinaryMsg: //普通消息 num = 15; break; case LogTypeEnum.MissedCalled: //未接来电16 num = 16; break; case LogTypeEnum.PanelMsg: //面板消息17 num = 17; break; } if (num != 0) { SQLiteDataReader reader = null; try { string sql = "select * from log where logtype=@type order by RowID DESC"; reader = SqLiteHelper.ExcuteReader(SqLiteHelper.Open(_dbPath), sql, new SQLiteParameter("@type", num)); while (reader.Read()) { LogMessage log = new LogMessage(); log.LogTime = EvaluationHelper.ObjectToDateTime(reader["logtime"]); log.LogMsg = EvaluationHelper.ObjectToString(reader["logmsg"]); log.LogType = EvaluationHelper.ObjectToInt(reader["logtype"]); log.OperaterId = EvaluationHelper.ObjectToString(reader["username"]); log.FromNo = EvaluationHelper.ObjectToString(reader["caller"]); log.PanelNum = EvaluationHelper.ObjectToInt(reader["callpanel"]); logs.Add(log); } } catch (Exception ex) { LogHelper.MainLog(ex.Message); } finally { if (reader != null) { reader.Close(); } } } } }