Exemplo n.º 1
0
        /// <summary>
        /// 查询任务详情
        /// </summary>
        /// <param name="userid">人员id</param>
        /// <param name="StartDate">开始时间</param>
        /// <returns></returns>
        public QW_UserTasksModel GetUserTask(int userid, DateTime StartDate)
        {
            Entities          db    = new Entities();
            DateTime          dt1   = StartDate.Date;
            DateTime          dt2   = StartDate.AddDays(1).Date;
            QW_UserTasksModel model = (from ut in db.qw_usertasks
                                       join sa in db.qw_signinareas on ut.signinareaid equals sa.signinareaid
                                       join pa in db.qw_patrolareas on ut.patrolid equals pa.patrolid
                                       where ut.userid == userid && ut.taskstarttime >= dt1 && ut.taskstarttime < dt2
                                       select new QW_UserTasksModel
            {
                usertaskid = ut.usertaskid,
                patrolid = ut.patrolid,
                signingrometry = sa.grometry,
                patrolgrometry = pa.grometry,
                signinareaid = ut.signinareaid,
                sszd = ut.sszd,
                ssbc = ut.ssbc,
                userid = ut.userid,
                taskstarttime = ut.taskstarttime,
                taskendtime = ut.taskendtime,
                taskexplain = ut.taskexplain,
            }).SingleOrDefault();

            return(model);
        }
Exemplo n.º 2
0
        public HttpResponseMessage ModifyUserTask()
        {
            HttpRequestBase   request = ((HttpContextWrapper)this.Request.Properties["MS_HttpContext"]).Request;
            QW_UserTasksBLL   bll     = new QW_UserTasksBLL();
            QW_UserTasksModel model   = new QW_UserTasksModel();

            if (!string.IsNullOrEmpty(request.Form["userid"]))
            {
                model.userid = Convert.ToInt32(request.Form["userid"]);
            }
            if (!string.IsNullOrEmpty(request.Form["taskstarttime"]))
            {
                model.taskstarttime = Convert.ToDateTime(request.Form["taskstarttime"]);
            }
            if (!string.IsNullOrEmpty(request.Form["signinareaid"]))
            {
                model.signinareaid = Convert.ToInt32(request.Form["signinareaid"]);
            }
            if (!string.IsNullOrEmpty(request.Form["patrolid"]))
            {
                model.patrolid = Convert.ToInt32(request.Form["patrolid"]);
            }
            model.taskexplain = request.Form["taskexplain"];
            bll.ModifyUserTask(model);

            HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK);

            response.Content = new StringContent("{\"success\":true}", Encoding.GetEncoding("UTF-8"), "text/html");

            return(response);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 修改任务
        /// </summary>
        /// <param name="model"></param>
        public int ModifyUserTask(QW_UserTasksModel model)
        {
            using (Entities db = new Entities())
            {
                qw_usertasks task = db.qw_usertasks.Where(a => a.userid == model.userid && a.taskstarttime == model.taskstarttime).FirstOrDefault();

                if (task != null)
                {
                    task.patrolid     = model.patrolid;
                    task.signinareaid = model.signinareaid;
                    task.taskexplain  = model.taskexplain;
                }
                return(db.SaveChanges());
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 添加巡查任务
        /// </summary>
        /// <param name="model"></param>
        public void AddUserTask(QW_UserTasksModel model)
        {
            DateTime      StartDate = model.taskstarttime;
            DateTime      EndDate   = model.taskendtime;
            List <string> weeks     = model.weeks;
            List <int>    userids   = model.userids;

            int Hour   = EndDate.Hour;
            int Minute = EndDate.Minute;
            int day    = Math.Abs(((TimeSpan)(EndDate - StartDate)).Days);


            for (int i = 0; i < userids.Count(); i++)
            {
                for (int j = 0; j < day + 1; j++)
                {
                    bool result = IsAdd(weeks, StartDate.AddDays(j));
                    if (result == true)
                    {
                        qw_usertasks task = GetUserTaskModel(userids[i], StartDate.AddDays(j));
                        if (task == null)
                        {
                            qw_usertasks qumodel = new qw_usertasks();
                            qumodel.patrolid      = model.patrolid;
                            qumodel.signinareaid  = model.signinareaid;
                            qumodel.sszd          = model.sszd;
                            qumodel.ssbc          = model.ssbc;
                            qumodel.userid        = userids[i];
                            qumodel.taskstarttime = StartDate.AddDays(j);
                            qumodel.taskendtime   = StartDate.AddDays(j).Date.AddHours(Hour).AddMinutes(Minute);
                            qumodel.taskexplain   = model.taskexplain;
                            qumodel.createtime    = model.createtime;
                            qumodel.createuserid  = model.createuserid;
                            Add(qumodel);
                        }
                    }
                }
            }
        }
Exemplo n.º 5
0
        public HttpResponseMessage AddTeamDuty()
        {
            HttpRequestBase   request = ((HttpContextWrapper)this.Request.Properties["MS_HttpContext"]).Request;
            QW_UserTasksModel model   = new QW_UserTasksModel();

            if (!string.IsNullOrEmpty(request.Form["userids[]"]))
            {
                List <int> userlist = new List <int>();
                foreach (var item in request.Form["userids[]"].Split(','))
                {
                    userlist.Add(Convert.ToInt32(item));
                }
                model.userids = userlist;
            }
            if (!string.IsNullOrEmpty(request.Form["weeks[]"]))
            {
                List <string> weeklist = new List <string>();
                foreach (var item in request.Form["weeks[]"].Split(','))
                {
                    weeklist.Add(item);
                }
                model.weeks = weeklist;
            }
            if (!string.IsNullOrEmpty(request.Form["taskstarttime"]))
            {
                model.taskstarttime = Convert.ToDateTime(request.Form["taskstarttime"]);
            }
            if (!string.IsNullOrEmpty(request.Form["taskendtime"]))
            {
                model.taskendtime = Convert.ToDateTime(request.Form["taskendtime"]);
            }
            if (!string.IsNullOrEmpty(request.Form["patrolid"]))
            {
                model.patrolid = Convert.ToInt32(request.Form["patrolid"]);
            }
            if (!string.IsNullOrEmpty(request.Form["signinareaid"]))
            {
                model.signinareaid = Convert.ToInt32(request.Form["signinareaid"]);
            }
            if (!string.IsNullOrEmpty(request.Form["sszd"]))
            {
                model.sszd = Convert.ToInt32(request.Form["sszd"]);
            }
            if (!string.IsNullOrEmpty(request.Form["ssbc"]))
            {
                model.ssbc = Convert.ToInt32(request.Form["ssbc"]);
            }
            if (!string.IsNullOrEmpty(request.Form["personid"]))
            {
                model.userid = Convert.ToInt32(request.Form["personid"]);
            }

            model.taskexplain  = request.Form["taskexplain"];
            model.createtime   = DateTime.Now;
            model.createuserid = Convert.ToInt32(request.Form["userid"]);

            QW_UserTasksBLL bll = new QW_UserTasksBLL();

            bll.AddUserTask(model);
            HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK);

            response.Content = new StringContent("{\"success\":true}", Encoding.GetEncoding("UTF-8"), "text/html");
            return(response);
        }
Exemplo n.º 6
0
 /// <summary>
 /// 修改任务
 /// </summary>
 /// <param name="model"></param>
 public int ModifyUserTask(QW_UserTasksModel model)
 {
     return(dal.ModifyUserTask(model));
 }
Exemplo n.º 7
0
 /// <summary>
 /// 添加巡查任务
 /// </summary>
 /// <param name="model"></param>
 public void AddUserTask(QW_UserTasksModel model)
 {
     dal.AddUserTask(model);
 }