Exemplo n.º 1
0
        protected Boolean ApplyChanges()
        {
            Boolean success = false;

            Boolean isModified = false;

            Boolean isValid = false;

            Dictionary <String, String> validationResponse;


            if (MercuryApplication == null)
            {
                return(false);
            }


            Mercury.Client.Core.Work.Workflow workflowUnmodified = (Mercury.Client.Core.Work.Workflow)Session[SessionCachePrefix + "WorkflowUnmodified"];


            workflow.Name = WorkflowName.Text;

            workflow.Description = WorkflowDescription.Text;

            workflow.Enabled = WorkflowEnabled.Checked;

            workflow.Visible = WorkflowVisible.Checked;



            workflow.EntityType = (Mercury.Server.Application.EntityType)Convert.ToInt32(WorkflowEntityType.SelectedValue);

            workflow.ActionVerb = WorkflowActionVerb.Text;


            workflow.Framework = (Mercury.Server.Application.WorkflowFramework)Convert.ToInt32(WorkflowFramework.SelectedValue);

            workflow.AssemblyPath = WorkflowAssemblyPath.Text;

            workflow.AssemblyName = WorkflowAssemblyName.Text;

            workflow.AssemblyClassName = WorkflowAssemblyClassName.Text;


            if (workflowUnmodified.Id == 0)
            {
                isModified = true;
            }

            if (!isModified)
            {
                isModified = !workflow.IsEqual(workflowUnmodified);
            }


            validationResponse = workflow.Validate();

            isValid = (validationResponse.Count == 0);


            if ((isModified) && (isValid))
            {
                if (!MercuryApplication.HasEnvironmentPermission(Mercury.Server.EnvironmentPermissions.WorkflowManage))
                {
                    SaveResponseLabel.Text = "Permission Denied.";

                    return(false);
                }

                success = MercuryApplication.WorkflowSave(workflow);

                if (success)
                {
                    workflow = MercuryApplication.WorkflowGet(workflow.Id, false);

                    Session[SessionCachePrefix + "Workflow"] = workflow;

                    Session[SessionCachePrefix + "WorkflowUnmodified"] = workflow.Copy();

                    SaveResponseLabel.Text = "Save Successful.";

                    InitializeAll();
                }

                else
                {
                    SaveResponseLabel.Text = "Unable to Save.";

                    if (MercuryApplication.LastException != null)
                    {
                        SaveResponseLabel.Text = SaveResponseLabel.Text + " [" + MercuryApplication.LastException.Message + "]";
                    }

                    success = false;
                }
            }

            else if (!isModified)
            {
                SaveResponseLabel.Text = "No Changes Detected."; success = true;
            }

            else if (!isValid)
            {
                foreach (String validationKey in validationResponse.Keys)
                {
                    SaveResponseLabel.Text = "Invalid [" + validationKey + "]: " + validationResponse[validationKey];

                    break;
                }

                success = false;
            }

            return(success);
        }
Exemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Int64 forWorkflowId = 0;


            if (MercuryApplication == null)
            {
                return;
            }

            if ((!MercuryApplication.HasEnvironmentPermission(Mercury.Server.EnvironmentPermissions.WorkflowReview))

                && (!MercuryApplication.HasEnvironmentPermission(Mercury.Server.EnvironmentPermissions.WorkflowManage)))

            {
                Response.Redirect("/PermissionDenied.aspx", true); return;
            }

            if (!Page.IsPostBack)
            {
                #region Initial Page Load

                if (Request.QueryString["WorkflowId"] != null)
                {
                    forWorkflowId = Int64.Parse(Request.QueryString["WorkflowId"]);
                }

                if (forWorkflowId != 0)
                {
                    workflow = MercuryApplication.WorkflowGet(forWorkflowId, false);

                    if (workflow == null)
                    {
                        workflow = new Mercury.Client.Core.Work.Workflow(MercuryApplication);
                    }

                    Page.Title = "Workflow - " + workflow.Name;
                }

                else
                {
                    workflow = new Mercury.Client.Core.Work.Workflow(MercuryApplication);
                }

                InitializeAll();

                Session[SessionCachePrefix + "Workflow"] = workflow;

                Session[SessionCachePrefix + "WorkflowUnmodified"] = workflow.Copy();

                #endregion
            } // Initial Page Load

            else   // Postback

            {
                workflow = (Mercury.Client.Core.Work.Workflow)Session[SessionCachePrefix + "Workflow"];
            }

            ApplySecurity();

            if (!String.IsNullOrEmpty(workflow.Name))
            {
                Page.Title = "Workflow - " + workflow.Name;
            }
            else
            {
                Page.Title = "New Workflow";
            }

            return;
        }