Exemplo n.º 1
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public DataAngineSet.Model.surveillance_task GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select id,name,person_dataset_id,device_id,type,create_time,start_time,end_time,remark from surveillance_task ");
            strSql.Append(" where id=@id");
            //strSql.Append("select st.id,st.name,st.person_dataset_id,st.device_id,stt.name as type,st.create_time,st.start_time,st.end_time,st.remark from surveillance_task as st INNER JOIN surveillance_task_type as stt on st.type = stt.id ");
            //strSql.Append(" where st.id=@id");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@id", MySqlDbType.Int32)
            };
            parameters[0].Value = id;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 2
0
        bool Init(int taskID)
        {
            DataAngineSet.Model.surveillance_task task = taskBll.GetModel(taskID);
            if (null == task)
            {
                Log.Debug("检索任务失败"); return(false);
            }
            DataAngineSet.Model.device device = deviceBll.GetModel(task.device_id);
            if (null == device)
            {
                Log.Debug("检索设备失败"); return(false);
            }
            DataAngineSet.Model.person_dataset person_dataset = datasetBll.GetModel(task.person_dataset_id);
            if (null == person_dataset)
            {
                Log.Debug("检索库失败"); return(false);
            }

            InitFRS();
            fa.LoadData(person_dataset.id);
            cap.TaskID = taskID;
            cap.HitAlertReturnEvent += new Capture.HitAlertCallback(OnHit);


            int id = -1;

            try
            {
                Log.Debug(device.video_address);
                id = Convert.ToInt32(device.video_address);
            }
            catch
            {
            }
            if (id == -1)
            {
                if (cap.Start(device.video_address) != ReturnCode.SUCCESS)
                {
                    Log.Debug("打开摄像头失败");
                    return(false);
                }
            }
            else
            {
                if (cap.Start(id) != ReturnCode.SUCCESS)
                {
                    Log.Debug("打开摄像头失败");
                    return(false);
                }
            }
            return(true);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(DataAngineSet.Model.surveillance_task model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update surveillance_task set ");
            strSql.Append("name=@name,");
            strSql.Append("person_dataset_id=@person_dataset_id,");
            strSql.Append("device_id=@device_id,");
            strSql.Append("type=@type,");
            strSql.Append("create_time=@create_time,");
            strSql.Append("start_time=@start_time,");
            strSql.Append("end_time=@end_time,");
            strSql.Append("remark=@remark");
            strSql.Append(" where id=@id");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@name",              MySqlDbType.VarChar,   50),
                new MySqlParameter("@person_dataset_id", MySqlDbType.Int32,     11),
                new MySqlParameter("@device_id",         MySqlDbType.Int32,     11),
                new MySqlParameter("@type",              MySqlDbType.VarChar,   50),
                new MySqlParameter("@create_time",       MySqlDbType.DateTime),
                new MySqlParameter("@start_time",        MySqlDbType.DateTime),
                new MySqlParameter("@end_time",          MySqlDbType.DateTime),
                new MySqlParameter("@remark",            MySqlDbType.VarChar,   50),
                new MySqlParameter("@id",                MySqlDbType.Int32, 11)
            };
            parameters[0].Value = model.name;
            parameters[1].Value = model.person_dataset_id;
            parameters[2].Value = model.device_id;
            parameters[3].Value = model.type;
            parameters[4].Value = model.create_time;
            parameters[5].Value = model.start_time;
            parameters[6].Value = model.end_time;
            parameters[7].Value = model.remark;
            parameters[8].Value = model.id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public DataAngineSet.Model.surveillance_task DataRowToModel(DataRow row)
 {
     DataAngineSet.Model.surveillance_task model = new DataAngineSet.Model.surveillance_task();
     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["person_dataset_id"] != null && row["person_dataset_id"].ToString() != "")
         {
             model.person_dataset_id = int.Parse(row["person_dataset_id"].ToString());
         }
         if (row["device_id"] != null && row["device_id"].ToString() != "")
         {
             model.device_id = int.Parse(row["device_id"].ToString());
         }
         if (row["type"] != null)
         {
             model.type = row["type"].ToString();
         }
         if (row["create_time"] != null && row["create_time"].ToString() != "")
         {
             model.create_time = DateTime.Parse(row["create_time"].ToString());
         }
         if (row["start_time"] != null && row["start_time"].ToString() != "")
         {
             model.start_time = DateTime.Parse(row["start_time"].ToString());
         }
         if (row["end_time"] != null && row["end_time"].ToString() != "")
         {
             model.end_time = DateTime.Parse(row["end_time"].ToString());
         }
         if (row["remark"] != null)
         {
             model.remark = row["remark"].ToString();
         }
     }
     return(model);
 }
Exemplo n.º 5
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(DataAngineSet.Model.surveillance_task model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into surveillance_task(");
            strSql.Append("name,person_dataset_id,device_id,type,create_time,start_time,end_time,remark)");
            strSql.Append(" values (");
            strSql.Append("@name,@person_dataset_id,@device_id,@type,@create_time,@start_time,@end_time,@remark)");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@name",              MySqlDbType.VarChar,   50),
                new MySqlParameter("@person_dataset_id", MySqlDbType.Int32,     11),
                new MySqlParameter("@device_id",         MySqlDbType.Int32,     11),
                new MySqlParameter("@type",              MySqlDbType.VarChar,   50),
                new MySqlParameter("@create_time",       MySqlDbType.DateTime),
                new MySqlParameter("@start_time",        MySqlDbType.DateTime),
                new MySqlParameter("@end_time",          MySqlDbType.DateTime),
                new MySqlParameter("@remark",            MySqlDbType.VarChar, 50)
            };
            parameters[0].Value = model.name;
            parameters[1].Value = model.person_dataset_id;
            parameters[2].Value = model.device_id;
            parameters[3].Value = model.type;
            parameters[4].Value = model.create_time;
            parameters[5].Value = model.start_time;
            parameters[6].Value = model.end_time;
            parameters[7].Value = model.remark;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }