Exemple #1
0
        public void InsertTaskLog(TaskLogModel item)
        {
            var task = _workTaskService.GetTaskById(item.TaskId);

            var Tasklog = new TaskLog
            {
                CreatedDate = DateTime.Now,
                CreatorId   = _workContext.CurrentCustomer.Id,
                TaskData    = task.ToModel <TaskModel>().toStringJson(),
                TaskId      = item.TaskId,
                Note        = item.Note
            };

            _workTaskService.InsertTaskLog(Tasklog);
        }
Exemple #2
0
        public virtual IActionResult Delete(int taskId)
        {
            var task = _workTaskService.GetTaskById(taskId);

            if (task != null)
            {
                //kiểm tra hạng mục con
                var taskchilds = _workTaskService.getTasksByConTractId(ParentId: taskId);
                if (taskchilds.Count > 0)
                {
                    return(JsonErrorMessage("Hạng mục có chứa hạng mục con !"));
                }
                //kiem tra co nghiem thu khoi luong hay chua
                var acceptancesubs = _contractService.GetallContractAcceptanceSubs(TaskId: taskId, TypeId: (int)ContractAcceptancesType.KhoiLuong);
                if (acceptancesubs.Count > 0)
                {
                    return(JsonErrorMessage("Hạng mục đã nghiệm thu khối lượng !"));
                }
                //kiem tra da quyet toan hay chua
                var settlementsubs = _contractService.GetAllContractSettlementSub(taskId: taskId);
                if (settlementsubs.Count > 0)
                {
                    return(JsonErrorMessage("Hạng mục đã quyết toán !"));
                }
                var model = _taskModelFactory.PrepareDelete(taskId);
                //xoa het cac mapping
                _contractService.DeleteContractAcceptanceTaskMappingbyTaskId(taskId);
                var TaskLogModel = new TaskLogModel
                {
                    TaskId = taskId,
                    Note   = "Xoá công việc "
                };
                _taskModelFactory.InsertTaskLog(TaskLogModel);
                var contract = _contractService.GetContractById(task.Id);
                //neu hop dong dang chay va co ContractTypeId thì chay lai gt do dang
                if (contract != null && contract.StatusId != (int)ContractStatus.Draf && task.ContractTypeId > 0)
                {
                    UpdateContractUnfinish(task.Id);
                }
                return(JsonSuccessMessage(_localizationService.GetResource("admin.common.Deleted"), model));
            }
            return(JsonErrorMessage("Lỗi hệ thống"));
        }
Exemple #3
0
        public virtual IActionResult ProcuringAgencyTaskAdd(TaskModel model)
        {
            var task = _workTaskService.GetTaskById(model.Id);

            if (task != null)
            {
                if (model.TaskProcuringAgencyId > 0)
                {
                    task.TaskProcuringAgencyId = model.TaskProcuringAgencyId;
                }
                else
                {
                    task.TaskProcuringAgencyId = null;
                }
                _workTaskService.UpdateTask(task);
                return(JsonSuccessMessage("Cập nhật liên danh thành công!"));
            }
            //them contractlog vs Tasklog
            //Insert Contract Log
            var contract    = _contractService.GetContractById(task.ContractId);
            var contractLog = new ContractLog()
            {
                ContractId   = contract.Id,
                CreatedDate  = DateTime.Now,
                CreatorId    = _workContext.CurrentCustomer.Id,
                ContractData = task.ToModel <TaskModel>().toStringJson()
            };

            _contractLogService.InsertContractLog(contractLog, "Thêm liên danh cho công việc " + task.Name);
            // Insert TaskLog
            var TaskLogModel = new TaskLogModel
            {
                TaskId = task.Id,
                Note   = "Thêm liên danh cho công việc."
            };

            _taskModelFactory.InsertTaskLog(TaskLogModel);
            return(JsonErrorMessage());
        }
Exemple #4
0
        public virtual IActionResult _Create(TaskModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageContract))
            {
                return(JsonErrorMessage());
            }
            if (ModelState.IsValid)
            {
                var  note            = "";
                var  noti            = "admin.common.Added";
                Task item            = new Task();
                int  PreParentTaskId = model.ParentId;
                if (model.Id > 0)
                {
                    item            = _workTaskService.GetTaskById(model.Id);
                    PreParentTaskId = item.ParentId.GetValueOrDefault();
                    note            = MessageReturn.CreateSuccessMessage("oldData", item.ToModel <TaskModel>()).toStringJson();
                }
                _taskModelFactory.PrepareTask(item, model);
                if (model.Id > 0)
                {
                    _workTaskService.UpdateTask(item);
                    _taskModelFactory.InsertContractLog(item);
                    var TaskLogModel = new TaskLogModel
                    {
                        TaskId = item.Id,
                        Note   = "Cập nhật công việc "
                    };
                    _taskModelFactory.InsertTaskLog(TaskLogModel);
                    noti = "admin.common.Updated";
                    //kiem tra xem co thay doi cha ko, neu co thay doi cha thi phai update lai cha
                    //if(PreParentTaskId!=model.ParentId && PreParentTaskId>0)
                    //{
                    //    _workTaskService.UpdateTaskAmount(PreParentTaskId);
                    //}
                }
                else
                {
                    //neu them cong viec vao hop dong thi mac dinh cong viec o trang thai dang working
                    if (model.ContractId > 0)
                    {
                        var contract1 = _contractService.GetContractById(model.ContractId);
                        if (contract1.StatusId != (int)ContractStatus.Draf)
                        {
                            item.StatusId = (int)TaskStatus.Working;
                        }
                    }
                    _workTaskService.InsertTask(item);
                    //lay lai thong tin da insert
                    item = _workTaskService.GetTaskById(item.Id);
                    _taskModelFactory.InsertContractLog(item);
                    var TaskLogModel = new TaskLogModel
                    {
                        TaskId = item.Id,
                        Note   = "Thêm mới công việc "
                    };
                    _taskModelFactory.InsertTaskLog(TaskLogModel);
                }
                if (model.AppendixId > 0)
                {
                    var taskContract = new TaskContract
                    {
                        TaskId      = item.Id,
                        ContractId  = model.AppendixId,
                        CreatorId   = _workContext.CurrentCustomer.Id,
                        CreatedDate = DateTime.Now,
                        Note        = note,
                    };
                    _workTaskService.InsertTaskContract(taskContract);
                }
                var contract = _contractService.GetContractById(item.ContractId);
                //neu hop dong dang chay va co ContractTypeId thì chay lai gt do dang
                if (contract != null && contract.StatusId != (int)ContractStatus.Draf && item.ContractTypeId > 0 && item.StatusId != (int)TaskStatus.Draf)
                {
                    UpdateContractUnfinish(item.Id);
                }
                return(JsonSuccessMessage(_localizationService.GetResource(noti), item.ToModel <TaskModel>()));
            }
            var list = ModelState.Values.Where(c => c.Errors.Count > 0).ToList();

            return(JsonErrorMessage("Error", list));
        }