Ejemplo n.º 1
0
        public RowControl(ClientToolsReference.Task task) : this()
        {
            TaskHistory taskHistory = new TaskHistory(task);

            SetHistory(taskHistory);
            lblId.Content = Id.ToString();
        }
Ejemplo n.º 2
0
        public async Task <TaskPageDTO> FinishTask(int taskId)
        {
            var task = await taskRepo.FindByIdAsync(taskId);

            TaskHistory history = new TaskHistory();

            task.UpdatedById = task.ExecutorId;

            task.DateUpdated    = DateTime.Now;
            history.DateUpdated = DateTime.Now;

            history.UpdatedByUser   = task.Executor;
            history.StartTaskStatus = await statusRepo.FindByIdAsync((int)task.TaskStatusId);

            var status = (await statusRepo.GetWithIncludeAsync(s => s.Type == "Ready for verification"))
                         .FirstOrDefault();

            task.TaskStatusId       = status.Id;
            history.FinalTaskStatus = status;

            await taskRepo.UpdateAsync(task);

            await historyRepo.CreateAsync(history);

            return(mapper.Map <FreelanceLand.Models.Task, TaskPageDTO>(task));
        }
Ejemplo n.º 3
0
 public RowControl(TaskHistory taskHistory) : this()
 {
     SetHistory(taskHistory);
     lblId.Content   = Id.ToString();
     lblTime.Content = taskControl.historyControl.GetFormatedTimeStamp(taskControl.historyControl.TotalTime);
     TimerType       = taskHistory.TimerType;
 }
Ejemplo n.º 4
0
        public async Task <ExcecutorDTO> AddExcecutor(ExcecutorDTO user)
        {
            var task = await taskRepo.FindByIdAsync(user.TaskId);

            TaskHistory history = new TaskHistory();

            history.DateUpdated     = DateTime.Now;
            history.UpdatedByUser   = task.Customer;
            history.StartTaskStatus = await statusRepo.FindByIdAsync((int)task.TaskStatusId);

            task.ExecutorId  = user.ExcecutorId;
            task.UpdatedById = task.CustomerId;
            task.DateUpdated = DateTime.Now;

            var status = (await statusRepo.GetWithIncludeAsync(s => s.Type == "In progress")).FirstOrDefault();

            task.TaskStatusId = status.Id;

            history.FinalTaskStatus = await statusRepo.FindByIdAsync(status.Id);

            await taskRepo.UpdateAsync(task);

            await historyRepo.CreateAsync(history);

            return(user);
        }
Ejemplo n.º 5
0
        public ActionResult UpdateHistory([Bind(Include = "id, note, state")] TaskHistory model)
        {
            try
            {
                string      user_id = User.Identity.GetUserId();
                TaskHistory history = db.task_history.Where(qu => qu.id == model.id).FirstOrDefault();
                if (history == null)
                {
                    return(new HttpStatusCodeResult(404, "Not Found History"));
                }

                Tasks task = db.tasks.Where(qu => qu.id == history.task_id).FirstOrDefault();

                if (!User.IsInRole("Admin") && task.user_id != user_id)
                {
                    return(new HttpStatusCodeResult(403, "Forbidden!"));
                }



                history.note  = model.note;
                history.state = model.state;
                setLastHistory(task.id);

                db.SaveChanges();
                return(new HttpStatusCodeResult(200));
            }
            catch (Exception exs)
            {
                return(new HttpStatusCodeResult(500, exs.Message.ToString()));
            }
        }
Ejemplo n.º 6
0
        public void Execute_Creates_History_Record()
        {
            // Setup
            InitializeTestEntities();

            // Act
            DateTime start = DateTime.Now;

            new EditTaskCommand(_serviceFactory.Object).Execute(new EditTaskCommandParams
            {
                TaskId           = _task.Id,
                Name             = "Name",
                TaskDate         = _changedDate,
                Completed        = true,
                ContactId        = _contact.Id,
                Category         = "Category",
                RequestingUserId = _user.Id
            });
            DateTime end = DateTime.Now;

            // Verify
            Task        task    = _unitOfWork.Tasks.Fetch().Single();
            TaskHistory history = task.History.Single();

            Assert.AreEqual("Name", history.Name, "The history record's name was incorrect");
            Assert.AreEqual(_changedDate, history.TaskDate, "The history record's date value was incorrect");
            Assert.AreEqual(_task.CompletionDate, history.CompletionDate, "The history record's completion date value was incorrect");
            Assert.AreEqual(_user, history.AuthoringUser, "The history record's author was incorrect");
            Assert.AreEqual(_contact, history.Contact, "The history record had an incorrect contact");
            Assert.AreEqual("Category", history.Category, "The history record's category value was incorrect");
            Assert.AreEqual(MJLConstants.HistoryUpdate, history.HistoryAction, "The history record's action value was incorrect");
            Assert.IsTrue(history.DateModified >= start && history.DateModified <= end, "The history record's modification date was incorrect");
        }
Ejemplo n.º 7
0
        private void AddFreeTimerRow(TaskHistory th)
        {
            RowControl rowControl = new RowControl(th);

            rowControl.AddListener(this);
            FreeTimers.Children.Add(rowControl);
        }
Ejemplo n.º 8
0
 private void ControlTasks(int projectID)
 {
     if (db.TaskHistories.Where(t => t.ID_Project == projectID).Count() == 0)
     {
         TaskHistory taskHistory = new TaskHistory();
         taskHistory.CreateCount   = 0;
         taskHistory.FinishCount   = 0;
         taskHistory.ProgressCount = 0;
         taskHistory.ID_Project    = projectID;
         if (db.Projects.Find(projectID).DateCreated.HasValue)
         {
             taskHistory.Date = db.Projects.Find(projectID).DateCreated.Value;
         }
         else
         {
             taskHistory.Date = DateTime.Now;
         }
         try
         {
             db.TaskHistories.Add(taskHistory);
             db.SaveChanges();
         }catch (Exception ex)
         {
             Console.WriteLine(ex.Message);
         }
     }
 }
Ejemplo n.º 9
0
        public ActionResult AddHistory([Bind(Include = "note, added, task_id, state")] TaskHistory model)
        {
            try
            {
                string user_id = User.Identity.GetUserId();
                Tasks  task    = db.tasks.Where(qu => qu.id == model.task_id && qu.user_id == user_id).FirstOrDefault();
                if (task == null)
                {
                    return(new HttpStatusCodeResult(500, "Not permit to customer"));
                }

                TaskHistory q = new TaskHistory
                {
                    note    = model.note,
                    added   = DateTime.Now,
                    state   = model.state,
                    task_id = model.task_id
                };
                db.task_history.Add(q);

                task.order_state  = model.state;
                task.contact_date = DateTime.Now;

                db.SaveChanges();

                setLastHistory(task.id);

                return(new HttpStatusCodeResult(200));
            }
            catch (Exception exs)
            {
                return(new HttpStatusCodeResult(500, exs.Message.ToString()));
            }
        }
Ejemplo n.º 10
0
        public ActionResult DeleteHistory(int?id)
        {
            string user_id = User.Identity.GetUserId();

            try
            {
                TaskHistory s = db.task_history.Where(src => src.id == id).FirstOrDefault();

                Tasks task = db.tasks.Where(f => f.id == s.task_id).FirstOrDefault();

                if (!User.IsInRole("Admin") && task.user_id != user_id)
                {
                    return(new HttpStatusCodeResult(403, "Forbidden!"));
                }

                if (s == null)
                {
                    return(new HttpStatusCodeResult(404));
                }
                db.task_history.Remove(s);
                db.SaveChanges();
                setLastHistory(task.id);
                return(new HttpStatusCodeResult(200));
            }
            catch (Exception ex)
            {
                return(new HttpStatusCodeResult(500));

                throw;
            }
        }
Ejemplo n.º 11
0
        public async Task <bool> Delete(TaskHistory taskHistory)
        {
            _dbContext.Set <TaskHistory>().Remove(taskHistory);
            var res = await _dbContext.SaveChangesAsync();

            return(res > 0);
        }
Ejemplo n.º 12
0
        public async Task <TaskHistory> Update(TaskHistory taskHistory)
        {
            _dbContext.Entry(taskHistory).State = EntityState.Modified;
            await _dbContext.SaveChangesAsync();

            return(taskHistory);
        }
Ejemplo n.º 13
0
        public ActionResult AJAXCreate([Bind(Include = "TaskID,Title")] TaskItem taskItem)
        {
            if (ModelState.IsValid)
            {
                string userID      = User.Identity.GetUserId();
                var    currentUser = db.Users.FirstOrDefault(i => i.Id == userID);
                taskItem.User = currentUser;

                taskItem.TaskID    = Guid.NewGuid();
                taskItem.Completed = false;
                TaskHistory hist = new TaskHistory
                {
                    HistID      = Guid.NewGuid(),
                    TaskID      = taskItem.TaskID,
                    TimeStamp   = DateTime.Now,
                    TaskItem    = taskItem,
                    Description = "Created"
                };


                db.History.Add(hist);
                db.TaskList.Add(taskItem);
                db.SaveChanges();
            }

            return(PartialView("_TasksView", GetTaskItems()));
        }
Ejemplo n.º 14
0
        public ActionResult Create([Bind(Include = "TaskID,Title,Completed")] TaskItem taskItem)
        {
            if (ModelState.IsValid)
            {
                string userID      = User.Identity.GetUserId();
                var    currentUser = db.Users.FirstOrDefault(id => id.Id == userID);
                taskItem.User = currentUser;

                if (currentUser == null)
                {
                    return(HttpNotFound());
                }

                taskItem.TaskID = Guid.NewGuid();
                db.TaskList.Add(taskItem);

                TaskHistory hist = new TaskHistory
                {
                    TaskID      = taskItem.TaskID,
                    TimeStamp   = DateTime.Now,
                    Description = "Created"
                };

                db.History.Add(hist);

                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(taskItem));
        }
Ejemplo n.º 15
0
        public ActionResult AJAXEdit(Guid?id, bool value)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TaskItem taskItem = db.TaskList.Find(id);

            if (taskItem == null)
            {
                return(HttpNotFound());
            }

            taskItem.Completed       = value;
            db.Entry(taskItem).State = EntityState.Modified;
            TaskHistory hist = new TaskHistory
            {
                HistID      = Guid.NewGuid(),
                TaskID      = taskItem.TaskID,
                TimeStamp   = DateTime.Now,
                TaskItem    = taskItem,
                Description = "Task modified"
            };

            db.History.Add(hist);
            db.SaveChanges();


            return(PartialView("_TasksView", GetTaskItems()));
        }
        public async Task <TaskHistoryResponseModel> UpdateTaskHistoryById(int id, TaskHistoryRequestModel taskHistoryRequestModel)
        {
            var taskHistory = new TaskHistory()
            {
                TaskId      = id,
                UserId      = taskHistoryRequestModel.UserId,
                Title       = taskHistoryRequestModel.Title,
                Description = taskHistoryRequestModel.Description,
                DueDate     = taskHistoryRequestModel.DueDate,
                Completed   = taskHistoryRequestModel.Completed,
                Remarks     = taskHistoryRequestModel.Remarks,
            };
            var createdTaskHistory = await _taskHistoryRepository.UpdateAsync(taskHistory);

            var taskHistoryResponse = new TaskHistoryResponseModel()
            {
                TaskId      = createdTaskHistory.TaskId,
                UserId      = createdTaskHistory.UserId,
                Title       = createdTaskHistory.Title,
                Description = createdTaskHistory.Description,
                DueDate     = createdTaskHistory.DueDate,
                Completed   = createdTaskHistory.Completed,
                Remarks     = createdTaskHistory.Remarks,
            };

            return(taskHistoryResponse);
        }
        public object GetAll(int taskId)
        {
            try
            {
                Logger.LogInfo("Get: Task history process start");
                IList <TaskHistory> taskHistories =
                    new List <TaskHistory>();

                DataTable dtAppConfig = DataBase.DBService.ExecuteCommand(
                    string.Format(SELECT_TASK_HISTORY, taskId));
                foreach (DataRow dr in dtAppConfig.Rows)
                {
                    TaskHistory task = convertToTaskHistory(dr);
                    taskHistories.Add(task);
                }
                Logger.LogInfo("Get: Task history process completed.");
                return(taskHistories);
            }
            catch (Exception ex)
            {
                StackTrace st = new StackTrace();
                StackFrame sf = st.GetFrame(0);
                MethodBase currentMethodName = sf.GetMethod();
                LogDebug(currentMethodName.Name, ex);
                return(null);
            }
        }
        public async Task UpdateBook_StateUnderTest_ExpectedBehavior()
        {
            // Arrange
            MessageInfo messageInfo = new MessageInfo()
            {
                ActionType = "PUT",
                BookDto    = _fixture.Build <BookDto>()
                             .Create()
            };
            Book newBook = new Book()
            {
                Id          = messageInfo.BookDto.Id,
                AuthorId    = Guid.NewGuid(),
                Date        = DateTime.Now,
                Description = "",
                TaskId      = messageInfo.BookDto.TaskId,
                Title       = ""
            };

            mockMapper.Setup(x => x.Map <Book>(messageInfo.BookDto)).Returns(newBook);
            mockGenericRepository.Setup(x => x.Get(messageInfo.BookDto.Id)).ReturnsAsync(newBook);
            mockGenericRepository.Setup(x => x.Update(newBook)).Returns(true);

            TaskDto taskDto = new TaskDto()
            {
                Id          = messageInfo.BookDto.TaskId,
                CreatedDate = DateTime.Now,
                Finish      = "",
                Requested   = "",
                StatusId    = 1,
                UpdatedDate = DateTime.Now
            };
            TaskHistory task = new TaskHistory()
            {
                Id          = taskDto.Id,
                CreatedDate = DateTime.Now,
                Finish      = "",
                Requested   = "",
                StatusId    = 1,
                UpdatedDate = DateTime.Now,
            };

            mockTaskService.Setup(x => x.GetTask(messageInfo.BookDto.TaskId)).ReturnsAsync(taskDto);
            mockMapper.Setup(x => x.Map <TaskHistory>(taskDto)).Returns(task);
            mockTaskService.Setup(x => x.UpdateTask(task)).ReturnsAsync(true);

            mockUnitOfWork.Setup(x => x.CommitAsync()).Returns(Task.CompletedTask);

            var service = this.CreateService();


            // Act
            var result = await service.SaveBook(
                messageInfo);

            // Assert
            Assert.True(result);
            this.mockRepository.VerifyAll();
        }
Ejemplo n.º 19
0
 public void Delete(int id)
 {
     using (UnitOfWork uow = new UnitOfWork())
     {
         TaskHistory entity = uow.GetRepository <TaskHistory>().GetById(id);
         uow.GetRepository <TaskHistory>().Delete(entity);
     }
 }
Ejemplo n.º 20
0
        public async Task <TaskHistory> Create(TaskHistory obj)
        {
            await _dbContext.AddAsync(obj);

            await _dbContext.SaveChangesAsync();

            return(obj);
        }
Ejemplo n.º 21
0
 // Default contructor that set entity to field
 public TaskHistoryModel(TaskHistory taskhistory)
 {
     this._task_history        = taskhistory;
     this._id                  = taskhistory.Id;
     this._user_id             = taskhistory.UserId;
     this._created_date        = taskhistory.CreatedDate;
     this._task_id             = taskhistory.TaskId;
     this._content             = taskhistory.Content;
     this._originalTaskHistory = taskhistory.DeepClone();
 }
        public async Task <bool> SaveBook(MessageInfo messageInfo)
        {
            try
            {
                //save book
                BookDto bookDto = messageInfo.BookDto;
                Book    newBook = _mapper.Map <Book>(bookDto);
                Book    book    = await _repository.Get(newBook.Id);

                if (book == null)
                {
                    await _repository.Insert(newBook);
                }
                else
                {
                    book.Title       = newBook.Title;
                    book.Description = newBook.Description;
                    _repository.Update(book);
                }
                //save history


                var taskDto = await _taskService.GetTask(messageInfo.BookDto.TaskId);

                TaskHistory taskHistory = _mapper.Map <TaskHistory>(taskDto);
                string      finish      = DateTime.Now.ToString("yyyyMMddHHmmss");
                if (taskHistory == null)
                {
                    taskHistory = new TaskHistory
                    {
                        Id        = messageInfo.BookDto.Id,
                        Requested = messageInfo.BookDto.Date.ToString("yyyyMMddHHmmssff"),
                        Finish    = finish,
                        StatusId  = 1
                    };
                    await _taskService.InsertTask(taskHistory);
                }
                else
                {
                    taskHistory.Finish = finish;
                    await _taskService.UpdateTask(taskHistory);
                }
                await _unitOfWork.CommitAsync();

                _logger.LogInformation("Saved a book successfully");

                return(await Task.FromResult(true));
            }
            catch (Exception ex)
            {
                _logger.LogError(string.Format("Saved a book fail \n {0}", ex.Message));
                return(await Task.FromResult(false));
            }
        }
    //phase d'initialisation
    //initialiser MissionHistory pour la premiere foi (pa d'historique) avec les tache charger par le moteur de scénario
    public static TaskHistory getLoadedTaskHistory(int iD, Task task)
    {
        TaskHistory th = new TaskHistory();

        th.id     = iD;
        th.name   = task.getName();
        th.label  = task.getLabel();
        th.scene  = task.getScene();
        th.status = task.getStatut();
        return(th);
    }
Ejemplo n.º 24
0
        /// <summary>
        /// Load history detail
        /// </summary>
        /// <param name="historyId"></param>
        /// <returns></returns>
        public async Task <ResultModel <TaskHistoryModel> > LoadHistoryDetail(int historyId)
        {
            ResultModel <TaskHistoryModel> result = new ResultModel <TaskHistoryModel>();

            TaskHistory data = await UnitOfWork.TaskHistoryRepository.Entity
                               .Include(c => c.Task).AsNoTracking()
                               .FirstOrDefaultAsync(c => c.Id == historyId);

            result.Data = data.ToModel();

            return(result);
        }
Ejemplo n.º 25
0
        public Task <bool> UpdateTask(TaskHistory taskHistory)
        {
            bool success = false;

            try
            {
                success = _repository.Update(taskHistory);
            }
            catch (Exception)
            {
            }
            return(Task.FromResult(success));
        }
Ejemplo n.º 26
0
        public static TaskHistory GenerateDiff(string action, string updatedField, string newVal, string origVal, int updateUser, int taskID)
        {
            var obj = new TaskHistory();

            obj.TaskID          = taskID;
            obj.UpdatedDateTime = DateTime.Now;
            obj.UpdatedUser     = updateUser;
            obj.Action          = action;
            obj.UpdatedField    = (compareFieldTitle.ContainsKey(updatedField) ? compareFieldTitle[updatedField] : updatedField);
            obj.NewValue        = newVal;
            obj.OriginalValue   = origVal;
            return(obj);
        }
        public async Task AddBook_StateUnderTest_ExpectedBehavior()
        {
            MessageInfo messageInfo = new MessageInfo()
            {
                ActionType = "POST",
                BookDto    = _fixture.Create <BookDto>()
            };
            Book newBook = new Book()
            {
                Id          = messageInfo.BookDto.Id,
                AuthorId    = messageInfo.BookDto.AuthorId,
                Date        = messageInfo.BookDto.Date,
                Description = messageInfo.BookDto.Description,
                Title       = messageInfo.BookDto.Title,
                TaskId      = messageInfo.BookDto.TaskId
            };

            mockMapper.Setup(m => m.Map <Book>(messageInfo.BookDto)).Returns(newBook);
            Book book = null;

            mockGenericRepository.Setup(x => x.Get(messageInfo.BookDto.Id)).ReturnsAsync(book);
            mockGenericRepository.Setup(x => x.Insert(newBook)).ReturnsAsync(true);

            //    TaskHistory taskHistory = null;// new TaskHistory();
            //TaskDto taskDto = new TaskDto()
            //{
            //    Id = messageInfo.BookDto.TaskId,
            //    CreatedDate = DateTime.Now,
            //    Finish = "",
            //    Requested = "",
            //    StatusId = 1,
            //    UpdatedDate = DateTime.Now
            //};
            TaskHistory task    = null;
            TaskDto     taskDto = null;

            mockTaskService.Setup(x => x.GetTask(messageInfo.BookDto.TaskId)).ReturnsAsync(taskDto);
            mockMapper.Setup(x => x.Map <TaskHistory>(taskDto)).Returns(task);
            mockTaskService.Setup(x => x.InsertTask(It.IsAny <TaskHistory>())).ReturnsAsync(true);//It.IsAny<TaskHistory>())

            mockUnitOfWork.Setup(x => x.CommitAsync()).Returns(Task.CompletedTask);
            var service = this.CreateService();
            // Act
            var result = await service.SaveBook(
                messageInfo);

            // Assert
            Assert.True(result);
            this.mockRepository.VerifyAll();
        }
        private TaskHistory convertToTaskHistory(DataRow dr)
        {
            TaskHistory taskHistory = new TaskHistory();

            taskHistory.Id        = dr.Field <int>("ID");
            taskHistory.TaskId    = dr.Field <int>("TaskId");
            taskHistory.FieldName = dr.Field <string>("FieldName");
            taskHistory.OldValue  = dr.Field <string>("OldValue");
            taskHistory.NewValue  = dr.Field <string>("NewValue");
            taskHistory.Username  = dr.Field <string>("UserName");
            taskHistory.UpdatedBy = dr.Field <int>("UpdatedBy");
            taskHistory.UpdatedOn = dr.Field <DateTime>("UpdatedOn");
            return(taskHistory);
        }
Ejemplo n.º 29
0
        private void AddFreeTimerRow(int id)
        {
            TaskHistory th = new TaskHistory();

            th.ExpectedTime = 10000000;
            th.Id           = id;
            th.Summary      = freeTimerPopup.tbTaskName.Text;
            RowControl rowControl = new RowControl(th);

            rowControl.TimerType = TimerType.Free;

            rowControl.AddListener(this);
            FreeTimers.Children.Add(rowControl);
        }
Ejemplo n.º 30
0
        public async Task <bool> InsertTask(TaskHistory taskHistory)
        {
            bool success;

            try
            {
                success = await _repository.Insert(taskHistory);
            }
            catch (Exception)
            {
                success = false;
            }
            return(await Task.FromResult(success));
        }