public virtual JsonResult SaveWorkFlowECO(string operationNumber) { ResponseBase response = new ResponseBase(); var jsonDataRequest = PageSerializationHelper.DeserializeJsonForm(Request.Form[0]); var viewModel = PageSerializationHelper.DeserializeObject <WorkflowViewModels>(jsonDataRequest.SerializedData); try { viewModel.UpdateCreationWorkFlowViewModel(jsonDataRequest.ClientFieldData); var workFlow = jsonDataRequest.ClientFieldData.FirstOrDefault(o => o.Name.Equals("changeStatus")); var studiesCommitee = jsonDataRequest.ClientFieldData.FirstOrDefault(x => !string.IsNullOrWhiteSpace(x.Name) && x.Name.Contains("studiesComitte")); var parameters = new Dictionary <string, object>(); var sharepoint = ConfigurationManager.AppSettings["BasePath"]; var linktask = string.Format( "{0}/operation/{1}/Pages/Default?idTask=nro", sharepoint, operationNumber); string userName = string.IsNullOrEmpty(viewModel.UserName) ? IDBContext.Current.UserName : viewModel.UserName; Logger.GetLogger().WriteDebug("SaveController", "Method: SaveWorkflowECO : UserName: "******"SubmitWorkflow": response.IsValid = _k2IntegrationService.StartAdvanceWorkflowECO( viewModel.TaskDataModel.Code, viewModel.TaskDataModel.TaskFolio, operationNumber, K2ECOHelpers.EntityType, entityId, viewModel.TaskDataModel.TaskTypeCode, parameters, K2IntegrationEnumerator.GeneralActions.AcceptWorkflow, viewModel.TaskDataModel.TaskId); if (response.IsValid) { if (viewModel.TaskDataModel.TaskTypeCode.Equals(K2ECOHelpers.WF_ECO_001_T6)) { string roleReturned = viewModel.TaskDataModel.Parameters[K2ECOHelpers.TagRole].ToString(); switch (roleReturned) { case "VPS Knowledge Work Coordinator": response = viewModel.OperationModality.Equals("CIP") ? _eswcipService.ChangeStatus(proposalId, ESWCIPEnums.vpsValidation, viewModel.OperationModality) : _eswcipService.ChangeStatus(proposalId, ESWCIPEnums.vpsReview, viewModel.OperationModality); break; case "VPS Final Validation": response = _eswcipService.ChangeStatus(proposalId, ESWCIPEnums.vpsValidation, viewModel.OperationModality); break; case "VPS Department Reviewer": response = _eswcipService.ChangeStatus(proposalId, ESWCIPEnums.departmentReview, viewModel.OperationModality); break; case "VPS Studies Committee": response = _eswcipService.ChangeStatus(proposalId, ESWCIPEnums.studiees, viewModel.OperationModality); break; } } else { response = _eswcipService.ChangeStatus(proposalId, ESWCIPEnums.departmentReview, viewModel.OperationModality); } } break; case "ValidateWorkflow": bool?isStudiee = null; if (viewModel.TaskDataModel.TaskTypeCode.Equals(K2ECOHelpers.WF_ECO_001_T3) && viewModel.OperationModality.Equals("ESW") && studiesCommitee != null) { isStudiee = Convert.ToBoolean(studiesCommitee.Value); } response.IsValid = _k2IntegrationService.StartAdvanceWorkflowECO( viewModel.TaskDataModel.Code, viewModel.TaskDataModel.TaskFolio, operationNumber, K2ECOHelpers.EntityType, entityId, viewModel.TaskDataModel.TaskTypeCode, parameters, K2IntegrationEnumerator.GeneralActions.AcceptWorkflow, viewModel.TaskDataModel.TaskId, isStudiee); if (response.IsValid) { switch (viewModel.TaskDataModel.TaskTypeCode) { case K2ECOHelpers.WF_ECO_001_T2: if (viewModel.OperationModality.Equals(ESWCIPEnums.TYPE_ESW)) { response = _eswcipService.ChangeStatus(proposalId, ESWCIPEnums.vpsReview, viewModel.OperationModality); } else { response = _eswcipService.ChangeStatus(proposalId, ESWCIPEnums.vpsValidation, viewModel.OperationModality); } break; case K2ECOHelpers.WF_ECO_001_T3: if (isStudiee.HasValue) { if (isStudiee.Value.Equals(true)) { response = _eswcipService.ChangeStatus(proposalId, ESWCIPEnums.studiees, viewModel.OperationModality, isStudiee.Value); } else { response = _eswcipService.ChangeStatus(proposalId, ESWCIPEnums.validated, viewModel.OperationModality, isStudiee.Value); } } else { response = _eswcipService.ChangeStatus(proposalId, ESWCIPEnums.validated, viewModel.OperationModality); } break; case K2ECOHelpers.WF_ECO_001_T4: response = _eswcipService.ChangeStatus(proposalId, ESWCIPEnums.vpsValidation, viewModel.OperationModality); break; case K2ECOHelpers.WF_ECO_001_T5: response = _eswcipService.ChangeStatus(proposalId, ESWCIPEnums.validated, viewModel.OperationModality); break; } } break; case "ReturnWorkflow": bool?isStud = null; if (viewModel.TaskDataModel.TaskTypeCode.Equals(K2ECOHelpers.WF_ECO_001_T3) && viewModel.OperationModality.Equals("ESW") && studiesCommitee != null) { isStud = Convert.ToBoolean(studiesCommitee.Value); } response.IsValid = _k2IntegrationService.StartAdvanceWorkflowECO( viewModel.TaskDataModel.Code, viewModel.TaskDataModel.TaskFolio, operationNumber, K2ECOHelpers.EntityType, entityId, viewModel.TaskDataModel.TaskTypeCode, parameters, K2IntegrationEnumerator.GeneralActions.RejectWorkflow, viewModel.TaskDataModel.TaskId, isStud); if (response.IsValid) { switch (viewModel.TaskDataModel.TaskTypeCode) { case K2ECOHelpers.WF_ECO_001_T2: response = _eswcipService.ChangeStatus(proposalId, ESWCIPEnums.departmentReturned, viewModel.OperationModality); break; case K2ECOHelpers.WF_ECO_001_T3: if (isStud.HasValue) { response = _eswcipService.ChangeStatus(proposalId, ESWCIPEnums.vpsReturned, viewModel.OperationModality, isStud.Value); } else { response = _eswcipService.ChangeStatus(proposalId, ESWCIPEnums.vpsReturned, viewModel.OperationModality); } break; case K2ECOHelpers.WF_ECO_001_T4: response = _eswcipService.ChangeStatus(proposalId, ESWCIPEnums.committeeReturned, viewModel.OperationModality); break; case K2ECOHelpers.WF_ECO_001_T5: response = _eswcipService.ChangeStatus(proposalId, ESWCIPEnums.vpsReturned, viewModel.OperationModality); break; } } break; } } catch (Exception e) { response.IsValid = false; response.ErrorMessage = e.ToString(); } return(Json(response)); }
public virtual JsonResult ProposalOperation(string operationNumber) { SaveProposalResponse response; ResponseBase responseK = new ResponseBase(); var jsonDataRequest = PageSerializationHelper.DeserializeJsonForm(Request.Form[0]); var viewModel = PageSerializationHelper .DeserializeObject <ProposalViewModel>(jsonDataRequest.SerializedData); var userName = IDBContext.Current.UserName; viewModel.UpdateProposalOperationViewModel(jsonDataRequest.ClientFieldData); var errorMessage = SynchronizationHelper.AccessToResources( SynchronizationHelper.EDIT_MODE, UrlProposalOperation, operationNumber, userName); var workFlow = jsonDataRequest.ClientFieldData .FirstOrDefault(o => o.Name.Equals(CHANGE_STATUS_FIELD)); if (!string.IsNullOrWhiteSpace(errorMessage)) { response = new SaveProposalResponse { IsValid = false, ErrorMessage = errorMessage }; } else { response = _eswcipService.SaveProposalOperations(operationNumber, viewModel); switch (workFlow.Value) { case SUBMIT_WORKFLOW: if (viewModel.IsReadyForSubmission) { var parameters = new Dictionary <string, object>(); int entityId = viewModel.ProposalId; var annualAllocationToBeSaved = _proposalOperationRepository .GetOne(x => x.ProposalOperationId == viewModel.ProposalId); var entityWorkflow = _workflowInstanceEntityRepository .GetOne(x => x.EntityId == entityId && x.EntityType == K2ECOHelpers.EntityType); int workflow_instance = entityWorkflow.WorkflowInstanceId; var entityTask = _workflowInstanceTaskRepository .GetByCriteria(x => x.WorkflowInstanceId == workflow_instance && x.Status == string.Empty) .ToList(); int taskID = entityTask != null? entityTask.Last().WorkflowInstanceTaskId : 0; string folio = entityWorkflow.WorkflowInstance.FolioId; var sharepoint = ConfigurationManager.AppSettings["BasePath"]; var linktask = string.Format( "{0}/operation/{1}/Pages/Default?idTask=nro", sharepoint, operationNumber); parameters.Add(K2ECOHelpers.TaskUserName, userName); parameters.Add(K2ECOHelpers.ProposalType, viewModel.ProposalType); parameters.Add(K2ECOHelpers.LinkOpera, linktask); responseK.IsValid = _k2IntegrationService.StartAdvanceWorkflowECO( K2ECOHelpers.WorkflowTypeECO, folio, operationNumber, K2ECOHelpers.EntityType, entityId, K2ECOHelpers.WF_ECO_001_T1, parameters, K2IntegrationEnumerator.GeneralActions.AcceptWorkflow, taskID); if (responseK.IsValid) { responseK = _eswcipService.ChangeStatus( entityId, ESWCIPEnums.departmentReview, viewModel.ProposalType); } } break; } if (response.IsValid && responseK.IsValid) { SynchronizationHelper.TryReleaseLock( UrlProposalOperation, operationNumber, userName); } } return(Json(response)); }