public static void SetValidatorsToStartWorkflow( string userProfileValidators, string additionalValidators, SupervisionPlanWorkflow workflow) { if (string.IsNullOrEmpty(userProfileValidators) && additionalValidators.Contains("-mandatory")) { additionalValidators = additionalValidators.Replace("-mandatory", string.Empty); additionalValidators = additionalValidators.TrimEnd('|'); workflow.UserProfileAdditional = string.Empty; if (string.IsNullOrEmpty(additionalValidators)) { throw new Exception(VALIDATOR_ERROR_MESSAGE); } workflow.UserProfileValidators = additionalValidators; } else if (string.IsNullOrEmpty(userProfileValidators)) { throw new Exception(VALIDATOR_ERROR_MESSAGE); } else { workflow.UserProfileValidators = userProfileValidators; workflow.UserProfileAdditional = additionalValidators; } }
public static string BeginK2Workflow( K2CallType callTypeEnum, SupervisionPlanWorkflow workflow, string workflowName, IK2ServiceProxy proxy) { try { return(proxy.BeginWorkflow(callTypeEnum, workflow)); } catch (Exception ex) { Logger.GetLogger().WriteError("SupervisionPlan", "ERROR WHEN STARTING WORKFLOW: ", ex); throw; } }
public virtual ActionResult CreatePlanVersionApprovalRequest( int planVersionId, string operationNumber, int year, string additionalValidators = "") { planVersionId = SupervisionPlanRepository.GetSupervisionPlanVersionIdToValidate( planVersionId, IDBContext.Current.UserName); var spWorkflow = new SupervisionPlanWorkflow { EntityId = planVersionId, FolioID = "0", OperationNumber = operationNumber, EntityType = K2CallType.SupervisionPlanVersion.GetStringValue(), UserName = IDBContext.Current.UserName, UserProfile = IDBContext.Current.FirstRole, UserProfileAdditional = additionalValidators }; int operationId = ClientGenericRepository .GetOperationIDForOperationNumber(operationNumber); decimal currentAmount = OperationModelRepositoryService.CalculateCurrentAmount( operationId, 1); string validators = SupervisionPlanWorkflowManager.GetValidators( _ruleService, currentAmount); SupervisionPlanWorkflowManager.SetValidatorsToStartWorkflow( validators, additionalValidators, spWorkflow); var response = SupervisionPlanWorkflowManager.BeginK2Workflow( K2CallType.SupervisionPlanVersion, spWorkflow, K2CallType.SupervisionPlanVersion.GetStringValue(), K2ServiceProxy); int statusCode = 0; if (response == K2Response.StartWorkFlow_SP.GetStringValue()) { statusCode = 700; } else if (response == K2Response.StartWorkFlow_InProgress.GetStringValue()) { IDBContext.Current.ErrorMessage(response); statusCode = 555; } else { IDBContext.Current.ErrorMessage(response); statusCode = 600; } return(RedirectToAction("DetailsPlanVersionApprovalRequest", new { planVersionId = planVersionId, operationNumber = operationNumber, year = year, state = statusCode, messageK2 = response })); }