/// <summary>
 /// 获取特定类型的摄像头
 /// </summary>
 /// <param name="type">摄像头类型</param>
 /// <returns></returns>
 public List <VideoInfoModel> GetSpecificVideos(VideoTypeModel.VideoType type)
 {
     return(videoManager.GetSpecificVideos(type));
 }
 /// <summary>
 /// 获取矩形区域内特定类型的摄像头
 /// </summary>
 /// <param name="longitude_left">矩形左上角经度</param>
 /// <param name="latitude_left">矩形左上角纬度</param>
 /// <param name="longitude_right">矩形右下角经度</param>
 /// <param name="latitude_right">矩形右下角纬度</param>
 /// <param name="type">摄像头类型</param>
 /// <returns></returns>
 public List <VideoInfoModel> GetSpecificVideosOfRect(double longitude_left, double latitude_left,
                                                      double longitude_right, double latitude_right, VideoTypeModel.VideoType type)
 {
     return(videoManager.GetSpecificVideosOfRect(longitude_left, latitude_left, longitude_right, latitude_right, type));
 }
        /// <summary>
        /// 获取矩形区域内特定类型的摄像头
        /// </summary>
        /// <param name="longitude_left">矩形左上角经度</param>
        /// <param name="latitude_left">矩形左上角纬度</param>
        /// <param name="longitude_right">矩形右下角经度</param>
        /// <param name="latitude_right">矩形右下角纬度</param>
        /// <param name="type">摄像头类型</param>
        /// <returns></returns>
        public List <VideoInfoModel> GetSpecificVideosOfRect(double longitude_left, double latitude_left,
                                                             double longitude_right, double latitude_right, VideoTypeModel.VideoType type)
        {
            List <VideoInfoModel> list = new List <VideoInfoModel>();

            try{
                using (DbConnection conn = new MySqlConnection(this.KedaConnectString))
                {
                    String mysql    = string.Format("select gbid, kdid, kddomainid, name, longitude, latitude, channel from tblGbDevice where longitude between {0} and {1} and latitude between {2} and {3} and length(civilCode)=8 ", longitude_left, longitude_right, latitude_left, latitude_right);
                    String sql_type = null;
                    conn.Open();
                    switch (type)
                    {
                    case VideoTypeModel.VideoType.KeyArea:
                        sql_type = " and substr(civilcode,length(civilcode)-1,2) between '60' and '65'";
                        break;

                    case VideoTypeModel.VideoType.RoadTraffic:
                        sql_type = " and substr(civilcode,length(civilcode)-1,2) between '66' and '69'";
                        break;

                    case VideoTypeModel.VideoType.PublicArea:
                        sql_type = " and substr(civilcode,length(civilcode)-1,2) between '70' and '75'";
                        break;

                    case VideoTypeModel.VideoType.SuperviseArea:
                        sql_type = " and substr(civilcode,length(civilcode)-1,2) = '92'";
                        break;

                    case VideoTypeModel.VideoType.CaseCenter:
                        sql_type = " and substr(civilcode,length(civilcode)-1,2) = '93'";
                        break;

                    case VideoTypeModel.VideoType.WindowUnit:
                        sql_type = " and substr(civilcode,length(civilcode)-1,2) = '94'";
                        break;

                    case VideoTypeModel.VideoType.MoveableVideo:
                        sql_type = " and substr(civilcode,length(civilcode)-1,2) = '77'";
                        break;

                    case VideoTypeModel.VideoType.InternalVideo:
                        sql_type = " and substr(civilcode,length(civilcode)-1,2) = '78'";
                        break;

                    default:
                        break;
                    }//end switch
                    if (sql_type != null)
                    {
                        mysql = mysql + sql_type;
                        using (DbCommand cmd = conn.CreateCommand())
                        {
                            cmd.CommandText = mysql;
                            using (DbDataReader reader = cmd.ExecuteReader())
                            {
                                while (reader.Read())
                                {
                                    if (reader.IsDBNull(0) || reader.IsDBNull(1) || reader.IsDBNull(2) ||
                                        reader.IsDBNull(3) || reader.IsDBNull(4))
                                    {
                                        continue;
                                    }

                                    VideoInfoModel v = new VideoInfoModel();
                                    v.Gbid      = reader[0].ToString();
                                    v.DeviceId  = reader[1].ToString();
                                    v.DomainId  = reader[2].ToString();
                                    v.VideoName = reader[3].ToString();
                                    double longitude;
                                    if (Double.TryParse(reader[4].ToString(), out longitude))
                                    {
                                        v.X = longitude;
                                    }
                                    double latitude;
                                    if (Double.TryParse(reader[5].ToString(), out latitude))
                                    {
                                        v.Y = latitude;
                                    }
                                    v.VideoChannel = reader[6].ToString();
                                    list.Add(v);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LogMgr.Instance.Error("日志记录", ex);
            }

            /*using (NpgsqlConnection conn = new NpgsqlConnection(connectString))
             * {
             *  String sql =
             *      String.Format(
             *          "select kdid55,name,jd,wd from gbid where jd between {0} and {1} and wd between {2} and {3}",
             *          longitude_left, longitude_right, latitude_left, latitude_right);
             *  String sql_type = null;
             *  try
             *  {
             *      conn.Open();
             *      switch (type)
             *      {
             *          case VideoTypeModel.VideoType.KeyArea:
             *              sql_type = " and to_number(substr(civilcode,length(civilcode)-1,2), '999999999D99999999') between 60 and 65";
             *              break;
             *          case VideoTypeModel.VideoType.RoadTraffic:
             *              sql_type = " and to_number(substr(civilcode,length(civilcode)-1,2), '999999999D99999999') between 66 and 69";
             *              break;
             *          case VideoTypeModel.VideoType.PublicArea:
             *              sql_type = " and to_number(substr(civilcode,length(civilcode)-1,2), '999999999D99999999') between 70 and 75";
             *              break;
             *          case VideoTypeModel.VideoType.SuperviseArea:
             *              sql_type = " and to_number(substr(civilcode,length(civilcode)-1,2), '999999999D99999999') = 92";
             *              break;
             *          case VideoTypeModel.VideoType.CaseCenter:
             *              sql_type = " and to_number(substr(civilcode,length(civilcode)-1,2), '999999999D99999999') = 93";
             *              break;
             *          case VideoTypeModel.VideoType.WindowUnit:
             *              sql_type = " and to_number(substr(civilcode,length(civilcode)-1,2), '999999999D99999999') = 94";
             *              break;
             *          case VideoTypeModel.VideoType.MoveableVideo:
             *              sql_type = " and to_number(substr(civilcode,length(civilcode)-1,2), '999999999D99999999') = 77";
             *              break;
             *          case VideoTypeModel.VideoType.InternalVideo:
             *              sql_type = " and to_number(substr(civilcode,length(civilcode)-1,2), '999999999D99999999') = 78";
             *              break;
             *          default:
             *              break;
             *      } //end switch
             *
             *      if (sql_type != null)
             *      {
             *          sql = sql + sql_type;
             *          NpgsqlCommand cmd = new NpgsqlCommand(sql, conn);
             *          NpgsqlDataReader reader = cmd.ExecuteReader();
             *          while (reader.Read())
             *          {
             *              if (reader.IsDBNull(0) || reader.IsDBNull(1) || reader.IsDBNull(2) || reader.IsDBNull(3))
             *              {
             *                  continue;
             *              }
             *              VideoInfoModel video = new VideoInfoModel();
             *              video.VideoChannel = reader.GetString(0);
             *              video.VideoName = reader.GetString(1);
             *              video.X = reader.GetDouble(2);
             *              video.Y = reader.GetDouble(3);
             *              video.VideoPort = "0";
             *              video.VideoSource = 2;
             *              video.FactoryName = "gb";
             *              list.Add(video);
             *          }
             *      }
             *  }
             *  catch (Exception ex)
             *  {
             *      LogMgr.Instance.Error("日志记录", ex);
             *  }
             * }*/
            return(list);
        }