public void SetStep(CodeTorch.Core.Workflow workflow, WorkflowStep step, string entityIDValue, string comment) { List <ScreenDataCommandParameter> parameters = new List <ScreenDataCommandParameter>(); ScreenDataCommandParameter p = null; p = new ScreenDataCommandParameter(ParameterWorkflowStatusID, null); parameters.Add(p); p = new ScreenDataCommandParameter(ParameterWorkflowCode, workflow.Code); parameters.Add(p); p = new ScreenDataCommandParameter(ParameterWorkflowStepCode, step.Code); parameters.Add(p); p = new ScreenDataCommandParameter(ParameterEntityID, entityIDValue); parameters.Add(p); string userName; userName = UserIdentityService.GetInstance().IdentityProvider.GetUserName(); p = new ScreenDataCommandParameter(ParameterCreatedBy, userName); parameters.Add(p); p = new ScreenDataCommandParameter(ParameterComment, comment); parameters.Add(p); p = new ScreenDataCommandParameter(ParameterUpdateCurrent, step.UpdateEntityWithStatusCode); parameters.Add(p); //get data from data command ExecuteDataCommand(DataCommandWorkflowSetStep, parameters); }
public override void InitControl(object sender, EventArgs e) { try { base.InitControl(sender, e); if (workflow == null) { workflow = GetWorkflow(); } if (!String.IsNullOrEmpty(Me.Width)) { this.ctrl.Style.Add(HtmlTextWriterStyle.Width, Me.Width); } ChangeStatus.Attributes.Add("class", "WorkflowChangeStatusButton"); ChangeStatus.Value = GetGlobalResourceString("WorkflowChangeStatusButton.Label", "Change Status"); } catch (Exception ex) { string ErrorMessageFormat = "ERROR - {0} - Control {1} ({2} - {3}) - InitControl"; string ErrorMessages = String.Format(ErrorMessageFormat, ex.Message, this.ControlID, Me.Type, this.ID); this.ctrl.InnerHtml = ErrorMessages; this.ctrl.Style.Add(HtmlTextWriterStyle.BackgroundColor, "Color.Red"); } }
public WorkflowStep GetCurrentWorkflowStep(CodeTorch.Core.Workflow workflow, string entityIDValue) { WorkflowStep retVal = null; List <ScreenDataCommandParameter> parameters = new List <ScreenDataCommandParameter>(); ScreenDataCommandParameter p = null; p = new ScreenDataCommandParameter(ParameterWorkflowCode, workflow.Code); parameters.Add(p); p = new ScreenDataCommandParameter(ParameterEntityType, workflow.EntityName); parameters.Add(p); p = new ScreenDataCommandParameter(ParameterEntityID, entityIDValue); parameters.Add(p); //get data from data command DataTable data = GetDataForDataCommand(DataCommandWorkflowGetCurrentStep, parameters); if (data.Rows.Count > 0) { string CurrentCode = data.Rows[0][ColumnCurrentStepCode].ToString(); retVal = workflow.GetStepByCode(CurrentCode); } return(retVal); }
private void InsertWorkflow(CodeTorch.Core.Workflow workflow) { List <ScreenDataCommandParameter> parameters = new List <ScreenDataCommandParameter>(); ScreenDataCommandParameter p = null; p = new ScreenDataCommandParameter(ParameterWorkflowCode, workflow.Code); parameters.Add(p); p = new ScreenDataCommandParameter(ParameterWorkflowName, workflow.EntityName); parameters.Add(p); p = new ScreenDataCommandParameter(ParameterWorkflowDescription, workflow.Description); parameters.Add(p); p = new ScreenDataCommandParameter(ParameterEntityName, workflow.EntityName); parameters.Add(p); p = new ScreenDataCommandParameter(ParameterEntityKeyField, workflow.EntityKeyColumn); parameters.Add(p); p = new ScreenDataCommandParameter(ParameterEntityStatusField, workflow.EntityStatusColumn); parameters.Add(p); ExecuteDataCommand(DataCommandWorkflowInsert, parameters); }
protected void Page_Load(object sender, EventArgs e) { WorkflowCode = Request.QueryString["WorkflowCode"]; EntityID = Request.QueryString["EntityID"]; FieldName.Text = String.Format("'{0}'", Request.QueryString["FieldName"]); ReloadAfterStatusChange = Convert.ToBoolean(Request.QueryString["Reload"]); // first determine current status of workflow item workflow = Workflow.GetWorkflowByCode(WorkflowCode); step = workflowService.GetProvider(workflow).GetCurrentWorkflowStep(workflow, EntityID); if (workflow != null) { if (!IsPostBack) { if (step != null) { CurrentStatusLabel.Text = step.Name; } else { CurrentStatusLabel.Text = "None"; } FillStatusList(workflow); } } }
private void FillStatusList(CodeTorch.Core.Workflow workflow) { if (step != null) { StatusList.Items.Clear(); StatusList.Items.Insert(0, new ListItem("-- Select --", String.Empty)); List <WorkflowNextStep> possibleSteps = Workflow.GetPossibleNextSteps(workflow, step, EntityID, Common.UserName); foreach (WorkflowNextStep possibleStep in possibleSteps) { StatusList.Items.Add(new ListItem(possibleStep.Name, possibleStep.Code)); } } else { //default to new workflow step (ie the first workflow step only) if (workflow.Steps.Count > 0) { StatusList.Items.Clear(); StatusList.Items.Insert(0, new ListItem(workflow.Steps[0].Name, workflow.Steps[0].Code)); } else { StatusList.Items.Clear(); StatusList.Items.Insert(0, new ListItem("No Worflow Steps Configured", String.Empty)); } } }
public bool ChangeWorkflowStep(CodeTorch.Core.Workflow workflow, WorkflowNextStep nextStep, string entityIDValue, string comment) { bool success = false; //get current workflow step WorkflowStep currentStep = GetCurrentWorkflowStep(workflow, entityIDValue); //see if next workflowstep is in possible WorkflowNextStep validNextStep = currentStep.PossibleNextSteps. Where(s => s.Code.ToLower() == nextStep.Code.ToLower()).SingleOrDefault(); if (validNextStep != null) { //check comments if ((validNextStep.RequireComment) && (String.IsNullOrEmpty(comment))) { throw new ApplicationException("Comments are required to change to this step"); } else { WorkflowStep step = workflow.GetStepByCode(validNextStep.Code); string userName; userName = UserIdentityService.GetInstance().IdentityProvider.GetUserName(); using (TransactionScope rootScope = TransactionUtils.CreateTransactionScope()) { foreach (BaseWorkflowAction action in step.Actions) { action.Execute(null, workflow.Code, currentStep.Code, validNextStep.Code, entityIDValue, comment, userName); } //update workflow step SetStep(workflow, step, entityIDValue, comment); if (step.UpdateEntityWithStatusCode) { //update existing table status SetEntityStatus(workflow, step, entityIDValue); } success = true; rootScope.Complete(); } } } else { //invalid - someone may have changed status throw new ApplicationException("Status cannot be changed at this time"); } return(success); }
public void Delete(CodeTorch.Core.Workflow workflow) { List <ScreenDataCommandParameter> parameters = new List <ScreenDataCommandParameter>(); ScreenDataCommandParameter p = null; p = new ScreenDataCommandParameter(ParameterWorkflowCode, workflow.Code); parameters.Add(p); ExecuteDataCommand(DataCommandWorkflowDelete, parameters); }
private void GetCurrentStep() { BasePage p = ((BasePage)this.Page); if (workflow == null) { workflow = GetWorkflow(); } EntityIDValue = p.GetEntityIDValue(p.Screen, Me.EntityID, Me.EntityInputType); step = workflowService.GetProvider(workflow).GetCurrentWorkflowStep(workflow, EntityIDValue); }
public void Save(CodeTorch.Core.Workflow workflow) { Delete(workflow); InsertWorkflow(workflow); int StepSequence = 0; foreach (WorkflowStep step in workflow.Steps) { StepSequence++; InsertWorkflowStep(workflow, step, StepSequence); } }
private CodeTorch.Core.Workflow GetWorkflow() { CodeTorch.Core.Workflow workflow = null; string workflowCode = null; switch (Me.WorkflowSelectionMode) { case WorkflowSelectionMode.Static: if (String.IsNullOrEmpty(Me.WorkflowCode)) { throw new ApplicationException("Invalid Workflow Code"); } workflowCode = Me.WorkflowCode; break; case WorkflowSelectionMode.DataCommand: //call screen datacommand if (String.IsNullOrEmpty(Me.WorkflowSelectionCommandName) || String.IsNullOrEmpty(Me.WorkflowSelectionFieldName)) { throw new ApplicationException("Invalid WorkflowSelectionCommandName OR WorkflowSelectionFieldName"); } List <ScreenDataCommandParameter> parameters = pageDB.GetPopulatedCommandParameters(Me.WorkflowSelectionCommandName, ((CodeTorch.Web.Templates.BasePage) this.Page)); DataTable data = dataCommand.GetDataForDataCommand(Me.WorkflowSelectionCommandName, parameters); if (data.Rows.Count > 0) { workflowCode = data.Rows[0][Me.WorkflowSelectionFieldName].ToString(); } break; } if (!String.IsNullOrEmpty(workflowCode)) { workflow = CodeTorch.Core.Workflow.GetWorkflowByCode(workflowCode); } return(workflow); }
public void SetEntityStatus(CodeTorch.Core.Workflow workflow, WorkflowStep step, string entityIDValue) { List <ScreenDataCommandParameter> parameters = new List <ScreenDataCommandParameter>(); ScreenDataCommandParameter p = null; p = new ScreenDataCommandParameter(ParameterEntityName, workflow.EntityName); parameters.Add(p); p = new ScreenDataCommandParameter(ParameterEntityStatusField, workflow.EntityStatusColumn); parameters.Add(p); p = new ScreenDataCommandParameter(ParameterEntityID, entityIDValue); parameters.Add(p); p = new ScreenDataCommandParameter(ParameterStatus, step.Code); parameters.Add(p); p = new ScreenDataCommandParameter(ParameterEntityKeyField, workflow.EntityKeyColumn); parameters.Add(p); //get data from data command ExecuteDataCommand(DataCommandWorkflowSetEntityStatus, parameters); }
private void InsertWorkflowStep(CodeTorch.Core.Workflow workflow, WorkflowStep step, int stepSequence) { List <ScreenDataCommandParameter> parameters = new List <ScreenDataCommandParameter>(); ScreenDataCommandParameter p = null; p = new ScreenDataCommandParameter(ParameterWorkflowCode, workflow.Code); parameters.Add(p); p = new ScreenDataCommandParameter(ParameterWorkflowStepCode, step.Code); parameters.Add(p); p = new ScreenDataCommandParameter(ParameterWorkflowStepSequence, stepSequence); parameters.Add(p); p = new ScreenDataCommandParameter(ParameterWorkflowStepName, step.Name); parameters.Add(p); p = new ScreenDataCommandParameter(ParameterUpdateEntityWithStatusCode, step.UpdateEntityWithStatusCode); parameters.Add(p); ExecuteDataCommand(DataCommandWorkflowInsertStep, parameters); }