コード例 #1
0
 /// <summary>
 /// 获取指定分机的呼叫转移列表
 /// </summary>
 /// <param name="transfers"></param>
 /// <param name="exten"></param>
 /// <returns></returns>
 public static void GetTransferTableByExtension(out List <Transfer> transfers, Extension exten)
 {
     transfers = new List <Transfer>();
     if (exten != null)
     {
         DataSet set;
         string  sql =
             "SELECT TransferID,TransferLevel,TransferExtensionNo," +
             "TransferLevel FROM ipvt_transferinfotable WHERE ExtensionNo=" +
             exten.Number + " ORDER BY TransferLevel ASC";
         try
         {
             set = CustomMySqlHelper.ExecuteDataSet(sql);
             DataRowCollection rows = set.Tables[0].Rows;
             if (rows != null)
             {
                 foreach (DataRow row in rows)
                 {
                     Transfer tran = new Transfer();
                     tran.Id                  = EvaluationHelper.ObjectToInt(row["TransferID"]);
                     tran.Level               = EvaluationHelper.ObjectToInt(row["TransferLevel"]);
                     tran.ExtensionNo         = exten.Number;
                     tran.TransferExtensionNo = row["TransferExtensionNo"].ToString();
                     transfers.Add(tran);
                 }
             }
         }
         catch (Exception ex)
         {
             LogHelper.MainLog(ex.ToString());
         }
     }
 }
コード例 #2
0
ファイル: GeoPointManager.cs プロジェクト: WeekL/DataMaker
        public static void GetGeo(ref List <GeoPoint> listGeo)
        {
            string          sql = "select * from ipvt_geoinfotable";
            MySqlDataReader rd  = CustomMySqlHelper.ExecuteDataReader(sql);

            try
            {
                DataSet set = CustomMySqlHelper.ExecuteDataSet(sql);
                if (set.Tables.Count > 0)
                {
                    DataRowCollection rows = set.Tables[0].Rows;
                    if (rows != null)
                    {
                        foreach (DataRow row in rows)
                        {
                            var pnt = new GeoPoint();
                            pnt.Id        = EvaluationHelper.ObjectToInt(row["GeoID"]);
                            pnt.Name      = Convert.ToString(row["Name"]);
                            pnt.Address   = Convert.ToString(row["FormattedAddress"]);
                            pnt.Note      = Convert.ToString(row["Note"]);
                            pnt.Phone     = Convert.ToString(row["Phone"]);
                            pnt.Latitude  = EvaluationHelper.ObjectToDouble(row["Latitude"]);
                            pnt.Longitude = EvaluationHelper.ObjectToDouble(row["Longitude"]);
                            listGeo.Add(pnt);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LogHelper.MainLog("GeoPointManager.Get error!" + ex);
            }
        }
コード例 #3
0
ファイル: GeoPointManager.cs プロジェクト: WeekL/DataMaker
        /// <summary>
        /// 从提供的网点id中,筛选出指定范围内的网点
        /// </summary>
        /// <param name="id">网点的id数组</param>
        /// <param name="leftTop">地理范围的左上角经纬度</param>
        /// <param name="rightBottom">地理范围的右下角经纬度</param>
        /// <param name="points">网点集</param>
        /// <returns></returns>
        public static void GetPoints(int[] id, LatLngCoordinate leftTop, LatLngCoordinate rightBottom, out List <GeoPoint> points)
        {
            points = new List <GeoPoint>();

            var sql =
                new StringBuilder(
                    "SELECT GeoID,Name,FormattedAddress,Latitude,Longitude,Phone FROM ipvt_geoinfotable WHERE Latitude>?latStart AND Latitude<?latEnd AND Longitude>?lngStart AND Longitude<?lngEnd");

            if (id.Length > 0)
            {
                sql.Append(" AND GeoID IN (");

                foreach (int i in id)
                {
                    sql.Append(i);
                    sql.Append(",");
                }

                sql.Remove(sql.Length - 1, 1);
                sql.Append(")");
            }

            var parameters = new MySqlParameter[4];

            parameters[0] = new MySqlParameter("?latStart", rightBottom.Latitude);
            parameters[0] = new MySqlParameter("?latEnd", leftTop.Latitude);
            parameters[0] = new MySqlParameter("?lngStart", leftTop.Longitude);
            parameters[0] = new MySqlParameter("?lngEnd", rightBottom.Longitude);

            try
            {
                DataSet set = CustomMySqlHelper.ExecuteDataSet(sql.ToString(), parameters);
                if (set.Tables.Count > 0)
                {
                    DataRowCollection rows = set.Tables[0].Rows;
                    if (rows != null)
                    {
                        foreach (DataRow row in rows)
                        {
                            GeoPoint pnt = new GeoPoint();
                            pnt.Id      = EvaluationHelper.ObjectToInt(row["GeoID"]);
                            pnt.Name    = Convert.ToString(row["Name"]);
                            pnt.Address = Convert.ToString(row["FormattedAddress"]);
                            //pnt.Ip = Convert.ToString(row["ip"]);
                            pnt.Phone     = Convert.ToString(row["phone"]);
                            pnt.Latitude  = EvaluationHelper.ObjectToDouble(row["Latitude"]);
                            pnt.Longitude = EvaluationHelper.ObjectToDouble(row["Longitude"]);
                            points.Add(pnt);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LogHelper.MainLog("GeoPointManager.GetPoints error!" + ex);
            }
        }
コード例 #4
0
ファイル: GeoPointManager.cs プロジェクト: WeekL/DataMaker
        /// <summary>
        /// 根据提供的网点获取网点信息
        /// </summary>
        /// <param name="id">网点id数组</param>
        /// <returns></returns>
        public static List <GeoPoint> GetPoints(int[] id)
        {
            var points = new List <GeoPoint>();

            var sqlBuilder =
                new StringBuilder("SELECT GeoID,Name,FormattedAddress,Latitude,Longitude,Phone FROM ipvt_geoinfotable ");

            if (id.Length > 0)
            {
                sqlBuilder.Append(" WHERE GeoID IN (");

                foreach (int i in id)
                {
                    sqlBuilder.Append(i);
                    sqlBuilder.Append(",");
                }

                sqlBuilder.Remove(sqlBuilder.Length - 1, 1);
                sqlBuilder.Append(")");
            }

            sqlBuilder.Append(" ORDER BY Latitude DESC");
            try
            {
                DataSet set = CustomMySqlHelper.ExecuteDataSet(sqlBuilder.ToString());
                if (set.Tables.Count > 0)
                {
                    DataRowCollection rows = set.Tables[0].Rows;
                    if (rows != null)
                    {
                        foreach (DataRow row in rows)
                        {
                            GeoPoint pnt = new GeoPoint();
                            pnt.Id        = EvaluationHelper.ObjectToInt(row["GeoID"]);
                            pnt.Name      = Convert.ToString(row["Name"]);
                            pnt.Address   = Convert.ToString(row["FormattedAddress"]);
                            pnt.Phone     = Convert.ToString(row["phone"]);
                            pnt.Latitude  = EvaluationHelper.ObjectToDouble(row["Latitude"]);
                            pnt.Longitude = EvaluationHelper.ObjectToDouble(row["Longitude"]);

                            points.Add(pnt);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LogHelper.MainLog(ex.ToString());
            }

            return(points);
        }
コード例 #5
0
ファイル: GeoPointManager.cs プロジェクト: WeekL/DataMaker
        /// <summary>
        /// 按关键字搜索网点
        /// </summary>
        /// <param name="points"></param>
        /// <param name="query">查询关键字</param>
        /// <returns></returns>
        public static void Search(out List <GeoPoint> points, params string[] query)
        {
            points = new List <GeoPoint>();
            DataSet set;

            if (query.Length > 0)
            {
                int           len        = query.Length;
                StringBuilder sqlBuilder = new StringBuilder();
                sqlBuilder.Append("CREATE TEMPORARY TABLE ptemp(ID varchar(100), tempStr varchar(350));");
                sqlBuilder.Append("INSERT INTO ptemp SELECT GeoID,CONCAT(Name,FormattedAddress,Phone,Note) FROM ipvt_geoinfotable;");
                sqlBuilder.Append("SELECT GeoID,Name,FormattedAddress,Latitude,Longitude,Phone,Note FROM ipvt_geoinfotable WHERE GeoID IN");
                sqlBuilder.Append("(");
                sqlBuilder.Append("SELECT ID FROM ptemp WHERE");

                for (int i = 0; i < len;)
                {
                    sqlBuilder.Append(string.Format(" ptemp.tempStr LIKE '%{0}%'", query[i]));
                    if (++i < len)
                    {
                        sqlBuilder.Append(" AND ");
                    }
                }
                sqlBuilder.Append(")");
                try
                {
                    set = CustomMySqlHelper.ExecuteDataSet(sqlBuilder.ToString());
                    DataRowCollection rows = set.Tables[0].Rows;
                    foreach (DataRow row in rows)
                    {
                        GeoPoint pnt = new GeoPoint();
                        pnt.Id        = EvaluationHelper.ObjectToInt(row["GeoID"]);
                        pnt.Name      = Convert.ToString(row["Name"]);
                        pnt.Address   = Convert.ToString(row["FormattedAddress"]);
                        pnt.Note      = Convert.ToString(row["Note"]);
                        pnt.Phone     = Convert.ToString(row["Phone"]);
                        pnt.Latitude  = EvaluationHelper.ObjectToDouble(row["Latitude"]);
                        pnt.Longitude = EvaluationHelper.ObjectToDouble(row["Longitude"]);
                        points.Add(pnt);
                    }
                }
                catch (Exception ex)
                {
                    LogHelper.MainLog(ex.ToString());
                }
            }
        }
コード例 #6
0
ファイル: TestManager.cs プロジェクト: WeekL/DataMaker
        public static DataSet GetTestTable()
        {
            string  sql = @"SELECT a.ExtensionNO,b.PanelNum
                              FROM ipvt_extensionmessagetable as a inner join ipvt_panelinfotable as b on a.ExtensionID=b.ExtensionID 
                                   inner join ipvt_deviceinfotable as c on a.ExtensionID=c.ExtensionID
                              WHERE a.CurrentState!=0 and c.DeviceType=1 order by a.ExtensionNO,b.PanelNum ";
            DataSet set = null;

            try
            {
                set = CustomMySqlHelper.ExecuteDataSet(sql);
            }
            catch (Exception ex)
            {
                LogHelper.MainLog("error in GetTestTable()" + ex.Message);
            }
            return(set);
        }
コード例 #7
0
ファイル: GeoPointManager.cs プロジェクト: WeekL/DataMaker
        public static void Get(LatLngCoordinate leftTop, LatLngCoordinate rightBottom, out List <GeoPoint> points)
        {
            points = new List <GeoPoint>();


            string sql =
                "SELECT GeoID,Name,FormattedAddress,Latitude,Longitude,Phone,Note FROM ipvt_geoinfotable WHERE Latitude>?latStart and Latitude<?latEnd and Longitude>?lngStart and Longitude<?lngEnd";

            var parameters = new MySqlParameter[4];

            parameters[0] = new MySqlParameter("?latStart", rightBottom.Latitude);
            parameters[1] = new MySqlParameter("?latEnd", leftTop.Latitude);
            parameters[2] = new MySqlParameter("?lngStart", leftTop.Longitude);
            parameters[3] = new MySqlParameter("?lngEnd", rightBottom.Longitude);

            try
            {
                DataSet set = CustomMySqlHelper.ExecuteDataSet(sql, parameters);
                if (set.Tables.Count > 0)
                {
                    DataRowCollection rows = set.Tables[0].Rows;
                    if (rows != null)
                    {
                        foreach (DataRow row in rows)
                        {
                            var pnt = new GeoPoint();
                            pnt.Id        = EvaluationHelper.ObjectToInt(row["GeoID"]);
                            pnt.Name      = Convert.ToString(row["Name"]);
                            pnt.Address   = Convert.ToString(row["FormattedAddress"]);
                            pnt.Note      = Convert.ToString(row["Note"]);
                            pnt.Phone     = Convert.ToString(row["Phone"]);
                            pnt.Latitude  = EvaluationHelper.ObjectToDouble(row["Latitude"]);
                            pnt.Longitude = EvaluationHelper.ObjectToDouble(row["Longitude"]);
                            points.Add(pnt);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LogHelper.MainLog("GeoPointManager.Get error!" + ex);
            }
        }
コード例 #8
0
        /// <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);
            }
        }
コード例 #9
0
        /// <summary>
        /// 获取设备分组信息
        /// </summary>
        /// <returns></returns>
        public static void GetDeviceGroups(out List <DeviceGroup> groups)
        {
            groups = new List <DeviceGroup>();
            DataSet set;
            string  sql = "SELECT GroupID,GroupName,ParentID,GroupLevel FROM ipvt_groupinfotable";


            try
            {
                set = CustomMySqlHelper.ExecuteDataSet(sql);
                if (set.Tables.Count > 0)
                {
                    DataRowCollection rows = set.Tables[0].Rows;
                    var grps = new DeviceGroup[rows.Count];
                    int i    = 0;

                    foreach (DataRow row in rows)
                    {
                        var grp = new DeviceGroup();
                        grp.Id       = EvaluationHelper.ObjectToInt(row["GroupID"]);
                        grp.Name     = Convert.ToString(row["GroupName"]);
                        grp.ParentId = EvaluationHelper.ObjectToInt(row["ParentID"]);
                        grp.Level    = EvaluationHelper.ObjectToInt(row["GroupLevel"]);
                        grps[i++]    = grp;
                    }

                    var roots = from r in grps where r.Id == -1 select r;

                    foreach (var r in roots)
                    {
                        FillGroup(r, grps);
                        groups.Add(r);
                    }
                }
            }
            catch (Exception ex)
            {
                LogHelper.MainLog("error int GetDeviceGroups()!" + ex);
            }
        }
コード例 #10
0
        /// <summary>
        /// 获取最大级别的转移信息
        /// </summary>
        /// <param name="extenNo">主分机</param>
        /// <param name="transferExtenNo">转移分机</param>
        /// <returns></returns>
        public static Transfer GetMaxLevelTransfer(string extenNo, string transferExtenNo)
        {
            Transfer transfer = null;
            DataSet  set;
            string   sql =
                "SELECT TransferID,TransferExtensionNo," +
                "TransferLevel FROM ipvt_transferinfotable WHERE ExtensionNo=?en " +
                "AND TransferExtensionNo=?ten " +
                "ORDER BY TransferLevel DESC LIMIT 1";
            var param = new MySqlParameter[2];

            param[0] = new MySqlParameter("?en", extenNo);
            param[1] = new MySqlParameter("?ten", transferExtenNo);

            try
            {
                set = CustomMySqlHelper.ExecuteDataSet(sql, param);
                DataRowCollection rows = set.Tables[0].Rows;
                if (rows != null)
                {
                    if (rows.Count == 1)
                    {
                        transfer                     = new Transfer();
                        transfer.Id                  = EvaluationHelper.ObjectToInt(rows[0]["TransferID"]);
                        transfer.Level               = EvaluationHelper.ObjectToInt(rows[0]["TransferLevel"]);
                        transfer.ExtensionNo         = extenNo;
                        transfer.TransferExtensionNo = rows[0]["TransferExtensionNo"].ToString();
                    }
                }
            }
            catch (Exception ex)
            {
                LogHelper.MainLog(ex.ToString());
            }
            return(transfer);
        }
コード例 #11
0
ファイル: GeoPointManager.cs プロジェクト: WeekL/DataMaker
        /// <summary>
        /// 按关键字和页码搜索
        /// </summary>
        /// <param name="points">out</param>
        /// <param name="pageIndex">页码</param>
        /// <param name="query">关键字</param>
        /// <param name="count">符合查询条件的总结果数</param>
        /// <param name="itemsCountOfPage">每页显示的结果数</param>
        /// <returns></returns>
        public static void Search(out List <GeoPoint> points, int pageIndex, int itemsCountOfPage, out int count, params string[] query)
        {
            points = new List <GeoPoint>();
            DataSet set = null;

            count = 0;
            if (query.Length > 0)
            {
                int           len        = query.Length;
                StringBuilder sqlBuilder = new StringBuilder();
                sqlBuilder.Append("CREATE TEMPORARY TABLE ptemp(ID varchar(100), tempStr varchar(350));");
                sqlBuilder.Append(
                    "INSERT INTO ptemp SELECT GeoID,CONCAT(Name,FormattedAddress,Phone,Note) FROM ipvt_geoinfotable;");
                //||' '
                sqlBuilder.Append("SELECT COUNT(*) FROM ptemp WHERE");

                for (int i = 0; i < len;)
                {
                    sqlBuilder.Append(string.Format(" tempStr LIKE '%{0}%'", query[i]));
                    if (++i < len)
                    {
                        sqlBuilder.Append(" AND ");
                    }
                    else
                    {
                        sqlBuilder.Append(";");
                    }
                }

                sqlBuilder.Append(
                    "SELECT GeoID,Name,FormattedAddress,Latitude,Longitude,Phone,Note FROM ipvt_geoinfotable WHERE GeoID IN");
                sqlBuilder.Append("(");
                sqlBuilder.Append("SELECT ID FROM ptemp WHERE");

                for (int i = 0; i < len;)
                {
                    sqlBuilder.Append(string.Format(" ptemp.tempStr LIKE '%{0}%'", query[i]));
                    if (++i < len)
                    {
                        sqlBuilder.Append(" AND ");
                    }
                }
                sqlBuilder.Append(")");
                sqlBuilder.Append(string.Format(" LIMIT {0},{1}", pageIndex * itemsCountOfPage, itemsCountOfPage));

                set = CustomMySqlHelper.ExecuteDataSet(sqlBuilder.ToString());
            }
            try
            {
                if (set != null && set.Tables.Count == 2)
                {
                    count = EvaluationHelper.ObjectToInt(set.Tables[0].Rows[0][0]);
                    DataRowCollection rows = set.Tables[1].Rows;
                    foreach (DataRow row in rows)
                    {
                        GeoPoint np = new GeoPoint()
                        {
                            Id        = EvaluationHelper.ObjectToInt(row["GeoID"]),
                            Name      = Convert.ToString(row["Name"]),
                            Address   = Convert.ToString(row["FormattedAddress"]),
                            Note      = Convert.ToString(row["Note"]),
                            Latitude  = EvaluationHelper.ObjectToDouble(row["Latitude"]),
                            Longitude = EvaluationHelper.ObjectToDouble(row["Longitude"])
                        };
                        points.Add(np);
                    }
                }
            }
            catch (Exception ex)
            {
                LogHelper.MainLog(ex.ToString());
            }
        }
コード例 #12
0
        /// <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();
        }