Beispiel #1
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public DataAngine_Set.Model.device DataRowToModel(DataRow row)
 {
     DataAngine_Set.Model.device model = new DataAngine_Set.Model.device();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["name"] != null)
         {
             model.name = row["name"].ToString();
         }
         if (row["address"] != null)
         {
             model.address = row["address"].ToString();
         }
         if (row["departmentmentid"] != null)
         {
             model.departmentmentid = row["departmentmentid"].ToString();
         }
         //model.longitude=row["longitude"].ToString();
         //model.latitude=row["latitude"].ToString();
         if (row["locationtype"] != null && row["locationtype"].ToString() != "")
         {
             model.locationtype = int.Parse(row["locationtype"].ToString());
         }
         if (row["remark"] != null)
         {
             model.remark = row["remark"].ToString();
         }
     }
     return(model);
 }
Beispiel #2
0
        bool  Init(int taskID)
        {
            DataAngine_Set.Model.surveillancetask task = taskBll.GetModel(taskID);
            if (null == task)
            {
                Log.Debug("检索任务失败"); return(false);
            }
            DataAngine_Set.Model.device device = deviceBll.GetModel(task.deviceid);
            if (null == device)
            {
                Log.Debug("检索设备失败"); return(false);
            }
            DataAngine_Set.Model.dataset dataset = datasetBll.GetModel(task.databaseid);
            if (null == dataset)
            {
                Log.Debug("检索库失败"); return(false);
            }

            InitFRS();

            fa.LoadData(dataset.datasetname);
            cap.HitAlertReturnEvent += new Capture.HitAlertCallback(OnHit);


            int id = -1;

            try
            {
                Log.Debug(device.address);
                id = Convert.ToInt32(device.address);
            }
            catch
            {
            }
            if (id == -1)
            {
                if (cap.Start(device.address) != ReturnCode.SUCCESS)
                {
                    Log.Debug("打开摄像头失败");
                    return(false);
                }
            }
            else
            {
                if (cap.Start(id) != ReturnCode.SUCCESS)
                {
                    Log.Debug("打开摄像头失败");
                    return(false);
                }
            }

            return(true);
        }
Beispiel #3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(DataAngine_Set.Model.device model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update device set ");
            strSql.Append("name=@name,");
            strSql.Append("address=@address,");
            strSql.Append("departmentmentid=@departmentmentid,");
            strSql.Append("longitude=@longitude,");
            strSql.Append("latitude=@latitude,");
            strSql.Append("locationtype=@locationtype,");
            strSql.Append("remark=@remark");
            strSql.Append(" where id=@id");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@name",             MySqlDbType.VarChar, 50),
                new MySqlParameter("@address",          MySqlDbType.VarChar, 50),
                new MySqlParameter("@departmentmentid", MySqlDbType.VarChar, 50),
                new MySqlParameter("@longitude",        MySqlDbType.Double,   5),
                new MySqlParameter("@latitude",         MySqlDbType.Double,   5),
                new MySqlParameter("@locationtype",     MySqlDbType.Int32,   11),
                new MySqlParameter("@remark",           MySqlDbType.VarChar, 50),
                new MySqlParameter("@id",               MySqlDbType.Int32, 11)
            };
            parameters[0].Value = model.name;
            parameters[1].Value = model.address;
            parameters[2].Value = model.departmentmentid;
            parameters[3].Value = model.longitude;
            parameters[4].Value = model.latitude;
            parameters[5].Value = model.locationtype;
            parameters[6].Value = model.remark;
            parameters[7].Value = model.id;

            int rows = DbHelperMySQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #4
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(DataAngine_Set.Model.device model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into device(");
            strSql.Append("name,address,departmentmentid,longitude,latitude,locationtype,remark)");
            strSql.Append(" values (");
            strSql.Append("@name,@address,@departmentmentid,@longitude,@latitude,@locationtype,@remark)");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@name",             MySqlDbType.VarChar, 50),
                new MySqlParameter("@address",          MySqlDbType.VarChar, 50),
                new MySqlParameter("@departmentmentid", MySqlDbType.VarChar, 50),
                new MySqlParameter("@longitude",        MySqlDbType.Double,   5),
                new MySqlParameter("@latitude",         MySqlDbType.Double,   5),
                new MySqlParameter("@locationtype",     MySqlDbType.Int32,   11),
                new MySqlParameter("@remark",           MySqlDbType.VarChar, 50)
            };
            parameters[0].Value = model.name;
            parameters[1].Value = model.address;
            parameters[2].Value = model.departmentmentid;
            parameters[3].Value = model.longitude;
            parameters[4].Value = model.latitude;
            parameters[5].Value = model.locationtype;
            parameters[6].Value = model.remark;

            int rows = DbHelperMySQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #5
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public DataAngine_Set.Model.device GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select id,name,address,departmentmentid,longitude,latitude,locationtype,remark from device ");
            strSql.Append(" where id=@id");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@id", MySqlDbType.Int32)
            };
            parameters[0].Value = id;

            DataAngine_Set.Model.device model = new DataAngine_Set.Model.device();
            DataSet ds = DbHelperMySQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }