Beispiel #1
0
        public async Task <ActionResult> StartUpdate(LogUpdate updateChecklist)
        {
            var checklist = await _repo.UpdateExists(updateChecklist);

            if (checklist != null)
            {
                return(BadRequest($"{updateChecklist.Process} {updateChecklist.SiteKml} already exists. Please Try again"));
            }
            updateChecklist.StartTime = DateTime.Now;
            updateChecklist.Status    = "In Progress";
            _repo.Add(updateChecklist);
            var steps = await _repo.GetSteps(updateChecklist.Idchecklist, updateChecklist.Version);

            foreach (var s in steps)
            {
                var step = new LogUpdateSteps
                {
                    Step     = s.Step,
                    StepText = s.StepText,
                    Title    = s.Title,
                    Idupdate = updateChecklist.Idupdate
                };

                _repo.Add(step);
            }
            if (await _repo.SaveAll())
            {
                return(CreatedAtAction("GetUpdate", new { id = updateChecklist.Idupdate }, updateChecklist));
            }

            return(BadRequest("Failed to Create Update"));
        }
        private void LogHistory(LogUpdateSteps step, string status, string action)
        {
            var user    = WindowsIdentity.GetCurrent().Name;
            var history = new LogUpdateHistory
            {
                Idupdate   = step.Idupdate,
                FileTime   = DateTime.Now,
                FileBy     = user.Substring(user.IndexOf(@"\") + 1),
                Status     = status,
                FileAction = action + step.Step
            };

            _repo.Add(history);
        }
Beispiel #3
0
        private void LogHistory(LogUpdateSteps step, string status, string action)
        {
            var user = this.httpContextAccessor.HttpContext.User.Identity.Name;

            user = user.Substring(user.IndexOf(@"\") + 1);
            var history = new LogUpdateHistory
            {
                Idupdate   = step.Idupdate,
                FileTime   = DateTime.Now,
                FileBy     = user.Substring(user.IndexOf(@"\") + 1),
                Status     = status,
                FileAction = action + step.Step
            };

            _repo.Add(history);
        }