Ejemplo n.º 1
0
        public void ProcessFormInitialize(ref ProcessForm formData)
        {
            if (formData.Id != 0)
            {
                Process process = _workFlowService.GetProcess(formData.Id);
                Mapper.Map(process, formData);
            }
            var mainProcessList = _workFlowService.GetMainProcessList(formData.TaskId);


            formData.MainProcessList = (mainProcessList != null ? new SelectList(mainProcessList, "Id", "Name") : null);

            if (formData.ProcessType == ProcessType.DecisionPoint)
            {
                formData.DecisionMethodList = new SelectList(_workFlowService.GetDecisionMethodList(formData.TaskId), "Id", "MethodName");
                formData.RepetitionHourList = new SelectList(Enumerable.Range(1, 24));
            }
            else if (formData.ProcessType == ProcessType.Process)
            {
                formData.FormViewList = new SelectList(_workFlowService.GetFormViewList(formData.TaskId), "Id", "FormName");
            }


            if (formData.ProcessType == ProcessType.OptionList || formData.ProcessType == ProcessType.Process || formData.ProcessType == ProcessType.SubProcess)
            {
                var monitoringList = formData.MonitoringRoleList;
                formData.MonitoringRoleList = Global.GetAllRoles().Select(rol => new MonitoringRoleCheckbox
                {
                    ProjectRole = rol,
                    IsChecked   = monitoringList != null ? monitoringList.Where(x => x.IsChecked == true).Any(t => t.ProjectRole == rol) : false
                }).ToList();
            }

            if (formData.ConditionId != null && formData.ConditionId != 0)
            {
                var condition = _unitOfWork.Repository <Condition>().Get((int)formData.ConditionId);
                if (condition != null)
                {
                    formData.ConditionName = condition.Name;
                    formData.AssignedRole  = condition.AssignedRole;
                }
            }
            else
            {
                if (formData.Id == 0)
                {
                    formData.AssignedRole = (formData.ProcessType == ProcessType.DecisionPoint || formData.ProcessType == ProcessType.SubProcess ? ProjectRole.System : ProjectRole.Officer);
                }
            }
            formData = ProcessFormLoad(formData);
        }