Пример #1
0
        public JsonResult ReassignmentConfirm(ReassignmentViewModel model)
        {
            bool   isSuccess = true;
            string msg       = string.Empty;

            try
            {
                ActivityRepository repository = new ActivityRepository(false);
                var settingTask = repository.GetSettingTasks(st => st.Id == model.Id).FirstOrDefault();
                if (settingTask != null)
                {
                    settingTask.ExecutorId = Guid.Parse(model.ExecutorId.Id);
                    //settingTask.TaskTypeId = model.TaskTypeId;
                    repository.UpdateSettingTask(settingTask);
                }
                else
                {
                    var activityDicId = repository.GetActivityTypeIdByCode(model.ActivityTypeCode);
                    var taskTypeDicId = repository.GetTaskTypeIdByCode(model.TaskTypeCode);

                    var parentSettingTask = repository.GetSettingTasks(st => st.EXP_AgreementProcSettingsActivities.ActivityTypeId == activityDicId && st.TaskTypeId == taskTypeDicId)
                                            .OrderByDescending(st => st.OrderNum).FirstOrDefault();

                    Guid?activityId = null;
                    if (parentSettingTask == null)
                    {
                        activityId =
                            repository.GetSettingActivities(psa => psa.ActivityTypeId == activityDicId)
                            .Select(psa => psa.Id)
                            .FirstOrDefault();
                    }


                    settingTask = new EXP_AgreementProcSettingsTasks()
                    {
                        Id           = Guid.NewGuid(),
                        ActivityId   = parentSettingTask?.ActivityId ?? activityId.Value,
                        TaskTypeId   = taskTypeDicId.Value,
                        ExecutorId   = Guid.Parse(model.ExecutorId.Id),
                        ParentTaskId = parentSettingTask?.Id,
                        OrderNum     = parentSettingTask?.OrderNum + 1 ?? 1
                    };
                    repository.AddSettingTask(settingTask);
                }

                repository.Save();
            }
            catch (Exception e)
            {
                isSuccess = false;
                msg       = e.ToString();
            }

            return(Json(new { IsSuccess = isSuccess, msg }, JsonRequestBehavior.AllowGet));
        }
Пример #2
0
        private AgreementTreeItemViewModel ConvertSettingTaskToTreeItem(EXP_AgreementProcSettingsTasks task)
        {
            AgreementTreeItemViewModel model = new AgreementTreeItemViewModel
            {
                Id               = task.Id.ToString(),
                OrderN           = task.OrderNum,
                Executor         = task.Executor != null ? task.Executor.FullName : string.Empty,
                CreatedDatetime  = DateTime.Now.ToString("dd.MM.yyyy"),
                ExecutedDatetime = null,
                Comment          = task.OrderNum.ToString(),
                Status           = String.Empty
            };

            return(model);
        }
Пример #3
0
 public void UpdateSettingTask(EXP_AgreementProcSettingsTasks settingTask)
 {
     AppContext.EXP_AgreementProcSettingsTasks.AddOrUpdate(settingTask);
 }
Пример #4
0
 public void AddSettingTask(EXP_AgreementProcSettingsTasks settingTask)
 {
     AppContext.EXP_AgreementProcSettingsTasks.Add(settingTask);
 }
Пример #5
0
        public Employee GetExecutor(Guid documentId, string documentTypeCode, string activityTypeCode, EXP_AgreementProcSettingsTasks taskSetting)
        {
            Func <ncelsEntities, DocumentAction> docActionInitizlizer;
            var documentTypeId = _activityRepository.GetDocumentTypeIdByCode(documentTypeCode);
            var activityTypeId = _activityRepository.GetActivityTypeIdByCode(activityTypeCode);

            //var documentType = _activityRepository.GetDocumentTypeById(documentTypeId.Value);
            //var activityType = _activityRepository.GetActivityTypeById(activityTypeId.Value);
            _documentActions.TryGetValue(new DocumentActionTypeKey(documentTypeCode, activityTypeCode),
                                         out docActionInitizlizer);
            var documentAction = docActionInitizlizer != null?docActionInitizlizer(_context) : null;

            if (taskSetting == null || documentAction == null)
            {
                return(null);
            }

            var executorId = documentAction.GetExecutor(documentId, activityTypeId.Value, taskSetting.OrderNum);

            return(_activityRepository.GetExecutorById(executorId));
        }