예제 #1
0
        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);
        }
예제 #2
0
        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");
            }
        }
예제 #3
0
        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);
        }
예제 #4
0
        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);
        }
예제 #5
0
        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);
                }
            }
        }
예제 #6
0
        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));
                }
            }
        }
예제 #7
0
        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);
        }
예제 #8
0
        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);
        }
예제 #9
0
        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);
        }
예제 #10
0
        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);
            }
        }
예제 #11
0
        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);
        }
예제 #12
0
        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);
        }
예제 #13
0
        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);
        }