Exemple #1
0
        public async Task <IActionResult> Post([FromBody] DailyCheck DailyCheck)
        {
            ModelState.Remove("User");
            // error to handle if the user input the correct info in order to use the api
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            // Grab current user
            User user = await _context.User.Where(u => u.UserName == User.Identity.Name).SingleOrDefaultAsync();

            DailyCheck.User = user;

            //Save to database
            _context.DailyCheck.Add(DailyCheck);

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                // check if the User Id already exists in the database and throw an error
                if (UserExists(DailyCheck.DailyCheckId))
                {
                    return(new StatusCodeResult(StatusCodes.Status409Conflict));
                }
                else
                {
                    throw;
                }
            }
            return(CreatedAtRoute("GetSingleDailyCheck", new { id = DailyCheck.DailyCheckId }, DailyCheck));
        }
Exemple #2
0
        public string NowTaskList()
        {
            ManageUserModel uM   = (ManageUserModel)Session["logUser"];
            var             list = DailyCheck.GetNowTaskList(uM.UserID);

            return(CommonLib.Helper.JsonSerializeObject(list, "yyyy-MM-dd HH:mm:ss"));
        }
Exemple #3
0
        public IActionResult Get(int id)
        {
            // error to handle if the user input the correct info in order to use the api
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            // search database to try and find a match for the computer id entered
            try
            {
                DailyCheck DailyCheck = _context.DailyCheck.Single(g => g.DailyCheckId == id);

                if (DailyCheck == null)
                {
                    return(NotFound());
                }

                return(Ok(DailyCheck));
            }
            catch (System.InvalidOperationException ex)
            {
                Console.Write(ex);
                return(NotFound());
            }
        }
Exemple #4
0
        public IActionResult Put(int id, [FromBody] DailyCheck DailyCheck)
        {
            // error to handle if the user input the correct info in order to use the api
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != DailyCheck.DailyCheckId)
            {
                return(BadRequest());
            }
            _context.DailyCheck.Update(DailyCheck);
            try
            {
                _context.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!UserExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(new StatusCodeResult(StatusCodes.Status204NoContent));
        }
Exemple #5
0
        private static void UpdateDailyChecks(ApplicationDbContext context)
        {
            DailyCheck check = new DailyCheck()
            {
                Checked = true
            };

            context.DailyCheck.Add(check);
            context.SaveChanges();
        }
    private async void RaiseDailyCheckInitiatedEvent()
    {
        await _dispatcher.Dispatch(new DailyCheckInitiatedEvent());

        _logger.LogInformation("Daily Check Event Raised");

        DailyCheck dailyCheck = new DailyCheck();

        dailyCheck.Date = DateTime.Now;
        await _repository.AddAsync(dailyCheck);
    }
Exemple #7
0
 public string DeleteDailyCheck(int id)
 {
     if (DailyCheck.DeleteDailyCheck(id))
     {
         return("1");
     }
     else
     {
         return("0");
     }
 }
Exemple #8
0
        public IActionResult Delete(int id)
        {
            DailyCheck DailyCheck = _context.DailyCheck.Single(g => g.DailyCheckId == id);

            if (User == null)
            {
                return(NotFound());
            }
            _context.DailyCheck.Remove(DailyCheck);
            _context.SaveChanges();
            return(Ok(User));
        }
Exemple #9
0
        public string AddRecord(int dcid, string taskName, string taskVal, string remark = "")
        {
            ManageUserModel      uM = (ManageUserModel)Session["logUser"];
            Sys_DailyCheckRecord cr = new Sys_DailyCheckRecord();

            cr.dcId        = dcid;
            cr.TaskName    = taskName;
            cr.TaskValue   = taskVal;
            cr.Operator    = uM.Name;
            cr.OperateTime = DateTime.Now;
            cr.Remark      = remark;
            return(DailyCheck.AddRecord(cr).ToString());
        }
Exemple #10
0
        public string AddTask(string taskName, int repeatType, string repeatTime, string reminder)
        {
            Sys_DailyCheck dailyModel = new Sys_DailyCheck();

            dailyModel.TaskName   = taskName;
            dailyModel.RepeatType = repeatType;

            if (repeatTime.Length > 0)
            {
                if (repeatType == 1)
                {
                    dailyModel.RemindTime = Convert.ToDateTime(repeatTime);
                    dailyModel.IsRepeat   = 0;
                }
                else
                {
                    dailyModel.RepeatTime = "," + repeatTime + ",";
                    dailyModel.IsRepeat   = 1;
                }
            }
            else
            {
                return("-2");//请选择提醒 时间
            }
            if (reminder.Length > 0)
            {
                dailyModel.Reminder = "," + reminder.ToString() + ",";
            }
            else
            {
                return("-1");//请选择提醒 人
            }

            ManageUserModel uM = (ManageUserModel)Session["logUser"];

            dailyModel.Recorder   = uM.Name;
            dailyModel.RecordTime = DateTime.Now;


            return(DailyCheck.AddTask(dailyModel).ToString());
        }
Exemple #11
0
        /// <summary>
        /// 得到日志
        /// </summary>
        /// <param name="tid"></param>
        /// <returns></returns>
        public string GetRecord(string tid)
        {
            List <int> tidList = new List <int>();

            foreach (string t in tid.Split(','))
            {
                int id = 0;
                if (int.TryParse(t, out id))
                {
                    tidList.Add(id);
                }
            }

            if (tidList.Count > 0)
            {
                return(CommonLib.Helper.JsonSerializeObject(DailyCheck.GetNowDateRecordList(tidList.ToArray()), "HH:mm:ss"));
            }
            else
            {
                return("");
            }
        }
Exemple #12
0
 public string GetRemindUsr()
 {
     return(CommonLib.Helper.JsonSerializeObject(DailyCheck.GetRemindUsr()));
 }
Exemple #13
0
        public string GetRecordList(int page, string uName = "", int pagesize = 15)
        {
            var list = DailyCheck.GetRecordList(page, pagesize, uName);

            return(CommonLib.Helper.JsonSerializeObject(list, "yyyy-MM-dd HH:mm:ss"));
        }
Exemple #14
0
        /// <summary>
        /// 得到任务列表
        /// </summary>
        /// <param name="page"></param>
        /// <returns></returns>
        public string GetList(int page)
        {
            var list = DailyCheck.GetList(page, 15, "");

            return(CommonLib.Helper.JsonSerializeObject(list));
        }