private void LoadControlToPlaceHolder(bool bindData)
        {
            if (MainPlaceHolder.Controls.Count > 0)
            {
                MainPlaceHolder.Controls.Clear();
            }

            if (!String.IsNullOrEmpty(ControlName))
            {
                MCDataSavedControl control = (MCDataSavedControl)LoadControl(ControlName);
                control.ID = "MCControl";
                MainPlaceHolder.Controls.Add(control);

                if (bindData)
                {
                    if (instance != null)                       // create from instance
                    {
                        SchemaMaster currentShemaMaster = SchemaManager.GetShemaMaster(instance.SchemaId);
                        object       rootActivity       = McWorkflowSerializer.GetObject(instance.Xaml);

                        WorkflowDescription wfDescription = new WorkflowDescription(Guid.NewGuid(), instance.Name, currentShemaMaster, rootActivity);

                        wfDescription.PlanFinishTimeType = (TimeType)instance.PlanFinishTimeType;

                        int duration = 60 * 24;                         // 1 day
                        if (instance.PlanDuration.HasValue && instance.PlanDuration.Value > 0)
                        {
                            duration = instance.PlanDuration.Value;
                        }
                        wfDescription.PlanDuration   = duration;
                        wfDescription.PlanFinishDate = instance.PlanFinishDate;

                        control.DataItem = wfDescription;
                    }
                    else if (template != null)                          // edit
                    {
                        SchemaMaster currentShemaMaster = SchemaManager.GetShemaMaster(template.SchemaId);
                        object       rootActivity       = McWorkflowSerializer.GetObject(template.Xaml);

                        WorkflowDescription wfDescription = new WorkflowDescription((Guid)template.PrimaryKeyId.Value, template.Name, currentShemaMaster, rootActivity);

                        wfDescription.PlanFinishTimeType = (TimeType)template.PlanFinishTimeType;
                        int duration = 60 * 24;                         // 1 day
                        if (template.PlanDuration.HasValue && template.PlanDuration.Value > 0)
                        {
                            duration = template.PlanDuration.Value;
                        }
                        wfDescription.PlanDuration   = duration;
                        wfDescription.PlanFinishDate = template.PlanFinishDate;

                        control.DataItem = wfDescription;
                    }
                    else
                    {
                        control.DataItem = null;
                    }
                    control.DataBind();
                }
            }
        }
Esempio n. 2
0
        private void LoadControlToPlaceHolder(bool bindData)
        {
            if (MainPlaceHolder.Controls.Count > 0)
            {
                MainPlaceHolder.Controls.Clear();
            }

            if (!String.IsNullOrEmpty(ControlName))
            {
                MCDataSavedControl control = (MCDataSavedControl)LoadControl(ControlName);
                MainPlaceHolder.Controls.Add(control);

                if (bindData)
                {
                    control.DataItem = activity;
                    control.DataBind();
                }
            }
        }
Esempio n. 3
0
        protected void SaveButton_ServerClick(object sender, EventArgs e)
        {
            if (activity == null)             // new
            {
                ActivityMaster currentActivityMaster = shemaMaster.GetActivityMaster(ActivityTypeList.SelectedValue);
                activity = currentActivityMaster.InstanceFactory.CreateInstance();

                if (MainPlaceHolder.Controls.Count > 0)
                {
                    MCDataSavedControl control = (MCDataSavedControl)MainPlaceHolder.Controls[0];
                    control.Save(activity);
                }

                object parentActivity = WorkflowActivityWrapper.GetActivityByName(rootActivity, ParentActivityName);
                WorkflowActivityWrapper.AddActivity(parentActivity, activity);
            }
            else             // edit
            {
                if (MainPlaceHolder.Controls.Count > 0)
                {
                    MCDataSavedControl control = (MCDataSavedControl)MainPlaceHolder.Controls[0];
                    control.Save(activity);
                }
            }

            // Save data
            instance.Xaml = McWorkflowSerializer.GetString(rootActivity);
            BusinessManager.Update(instance);

            // Close popup
            if (!String.IsNullOrEmpty(Request["closeFramePopup"]))
            {
                Mediachase.Ibn.Web.UI.WebControls.CommandHandler.RegisterCloseOpenedFrameScript(this.Page, string.Empty, true);
            }
            else
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), Guid.NewGuid().ToString(),
                                                        "<script language='javascript'>" +
                                                        "try {window.opener.location.href=window.opener.location.href;}" +
                                                        "catch (e){} window.close();</script>");
            }
        }
        protected void SaveButton_ServerClick(object sender, EventArgs e)
        {
            if (template != null)             // edit
            {
                // Step 1. Modify template
                template.Name        = NameText.Text.Trim();
                template.Description = DescriptionText.Text;

                SchemaMaster currentShemaMaster = SchemaManager.GetShemaMaster(template.SchemaId);

                object rootActivity = McWorkflowSerializer.GetObject(template.Xaml);

                if (ProjectControl.ObjectId > 0)
                {
                    template.ProjectId = ProjectControl.ObjectId;
                }
                else
                {
                    template.ProjectId = null;
                }

                // Object types
                List <int> selectedObjectTypes = new List <int>();
                if (DocumentCheckBox.Enabled && DocumentCheckBox.Checked)
                {
                    selectedObjectTypes.Add((int)ObjectTypes.Document);
                }
                if (TaskCheckBox.Enabled && TaskCheckBox.Checked)
                {
                    selectedObjectTypes.Add((int)ObjectTypes.Task);
                }
                if (TodoCheckBox.Enabled && TodoCheckBox.Checked)
                {
                    selectedObjectTypes.Add((int)ObjectTypes.ToDo);
                }
                if (IncidentCheckBox.Enabled && IncidentCheckBox.Checked)
                {
                    selectedObjectTypes.Add((int)ObjectTypes.Issue);
                }

                template.SupportedIbnObjectTypes = selectedObjectTypes.ToArray();

                // Step 2. Create WorkflowDescription
                WorkflowDescription wfDescription = new WorkflowDescription((Guid)template.PrimaryKeyId.Value, template.Name, currentShemaMaster, rootActivity);

                // Step 3. Apply Modifications
                if (MainPlaceHolder.Controls.Count > 0)
                {
                    MCDataSavedControl control = (MCDataSavedControl)MainPlaceHolder.Controls[0];
                    control.Save(wfDescription);
                }

                template.PlanFinishTimeType = (int)wfDescription.PlanFinishTimeType;
                if (wfDescription.PlanFinishTimeType == TimeType.Duration)
                {
                    template.PlanDuration   = wfDescription.PlanDuration;
                    template.PlanFinishDate = null;
                }
                else if (wfDescription.PlanFinishTimeType == TimeType.DateTime)
                {
                    template.PlanFinishDate = wfDescription.PlanFinishDate;
                    template.PlanDuration   = null;
                }

                template.Xaml = McWorkflowSerializer.GetString(wfDescription.TransientWorkflow);

                // Template Group
                if (TemplateGroupValue != null)
                {
                    template.TemplateGroup = (int)TemplateGroupValue;
                }

                // Lock Library
                WorkflowParameters.SetOwnerReadOnly(template, LockLibraryCheckBox.Checked);

                // Overdue Action
                WorkflowParameters.SetAssignmentOverdueAction(template, (AssignmentOverdueAction)int.Parse(AssignmentOverdueActionList.SelectedValue));

                BusinessManager.Update(template);
            }
            else             // new or create from instance
            {
                // Step 1. Initialize a new template
                template             = BusinessManager.InitializeEntity <WorkflowDefinitionEntity>(WorkflowDefinitionEntity.ClassName);
                template.Name        = NameText.Text.Trim();
                template.Description = DescriptionText.Text;

                template.SchemaId = new Guid(SchemaMasterList.SelectedValue);

                SchemaMaster currentShemaMaster = SchemaManager.GetShemaMaster(template.SchemaId);
                object       rootActivity       = currentShemaMaster.InstanceFactory.CreateInstance();

                if (ProjectControl.ObjectId > 0)
                {
                    template.ProjectId = ProjectControl.ObjectId;
                }

                // Object types
                List <int> selectedObjectTypes = new List <int>();
                if (DocumentCheckBox.Enabled && DocumentCheckBox.Checked)
                {
                    selectedObjectTypes.Add((int)ObjectTypes.Document);
                }
                if (TaskCheckBox.Enabled && TaskCheckBox.Checked)
                {
                    selectedObjectTypes.Add((int)ObjectTypes.Task);
                }
                if (TodoCheckBox.Enabled && TodoCheckBox.Checked)
                {
                    selectedObjectTypes.Add((int)ObjectTypes.ToDo);
                }
                if (IncidentCheckBox.Enabled && IncidentCheckBox.Checked)
                {
                    selectedObjectTypes.Add((int)ObjectTypes.Issue);
                }

                template.SupportedIbnObjectTypes = selectedObjectTypes.ToArray();

                // Step 2. Create WorkflowDescription
                WorkflowDescription wfDescription = new WorkflowDescription(template.Name, currentShemaMaster, rootActivity);

                // Step 3. Apply Modifications
                if (MainPlaceHolder.Controls.Count > 0)
                {
                    MCDataSavedControl control = (MCDataSavedControl)MainPlaceHolder.Controls[0];
                    control.Save(wfDescription);
                }

                template.PlanFinishTimeType = (int)wfDescription.PlanFinishTimeType;
                if (wfDescription.PlanFinishTimeType == TimeType.Duration)
                {
                    template.PlanDuration   = wfDescription.PlanDuration;
                    template.PlanFinishDate = null;
                }
                else if (wfDescription.PlanFinishTimeType == TimeType.DateTime)
                {
                    template.PlanFinishDate = wfDescription.PlanFinishDate;
                    template.PlanDuration   = null;
                }

                template.Xaml = McWorkflowSerializer.GetString(wfDescription.TransientWorkflow);

                // Template Group
                if (TemplateGroupValue != null)
                {
                    template.TemplateGroup = (int)TemplateGroupValue;
                }

                // Lock Library
                WorkflowParameters.SetOwnerReadOnly(template, LockLibraryCheckBox.Checked);

                // Overdue Action
                WorkflowParameters.SetAssignmentOverdueAction(template, (AssignmentOverdueAction)int.Parse(AssignmentOverdueActionList.SelectedValue));

                BusinessManager.Create(template);
            }

            // Step Final. Redirect
            RedirectToList();
        }
Esempio n. 5
0
        protected void SaveButton_ServerClick(object sender, EventArgs e)
        {
            if (ObjectId != PrimaryKeyId.Empty)                 // edit
            {
                // Step 1. Modify instance
                instance.Name        = NameText.Text.Trim();
                instance.Description = DescriptionText.Text;

                // Step 2. Create WorkflowChangesScope
                using (WorkflowChangesScope scope = WorkflowChangesScope.Create(instance))
                {
                    SchemaMaster currentShemaMaster = SchemaManager.GetShemaMaster(instance.SchemaId);

                    WorkflowDescription wfDescription = new WorkflowDescription((Guid)instance.PrimaryKeyId.Value, instance.Name, currentShemaMaster, scope.TransientWorkflow);

                    // Step 3. Apply Modifications
                    if (MainPlaceHolder.Controls.Count > 0)
                    {
                        MCDataSavedControl control = (MCDataSavedControl)MainPlaceHolder.Controls[0];
                        control.Save(wfDescription);
                    }

                    instance.PlanFinishTimeType = (int)wfDescription.PlanFinishTimeType;
                    if (wfDescription.PlanFinishTimeType == TimeType.Duration)
                    {
                        instance.PlanDuration = wfDescription.PlanDuration;
                    }
                    else if (wfDescription.PlanFinishTimeType == TimeType.DateTime)
                    {
                        instance.PlanFinishDate = wfDescription.PlanFinishDate;
                    }

                    // Lock Library
                    WorkflowParameters.SetOwnerReadOnly(instance, LockLibraryCheckBox.Checked);

                    // Overdue Action
                    WorkflowParameters.SetAssignmentOverdueAction(instance, (AssignmentOverdueAction)int.Parse(AssignmentOverdueActionList.SelectedValue));

                    // Step 4. Accept Changes
                    scope.ApplyWorkflowChanges();
                }
            }
            else             // new or duplicate
            {
                // Step 1. Initialize a new instance
                instance             = BusinessManager.InitializeEntity <WorkflowInstanceEntity>(WorkflowInstanceEntity.ClassName);
                instance.Name        = NameText.Text.Trim();
                instance.Description = DescriptionText.Text;

                if (!String.IsNullOrEmpty(OwnerName) && OwnerId > 0)
                {
                    instance[OwnerName] = OwnerId;
                }

                instance.SchemaId = new Guid(SchemaMasterList.SelectedValue);

                SchemaMaster currentShemaMaster = SchemaManager.GetShemaMaster(instance.SchemaId);
                object       rootActivity       = currentShemaMaster.InstanceFactory.CreateInstance();

                instance.Xaml = McWorkflowSerializer.GetString(rootActivity);

                // Step 2. Create WorkflowChangesScope
                WorkflowDescription wfDescription = new WorkflowDescription(instance.Name, currentShemaMaster, rootActivity);

                // Step 3. Apply Modifications
                if (MainPlaceHolder.Controls.Count > 0)
                {
                    MCDataSavedControl control = (MCDataSavedControl)MainPlaceHolder.Controls[0];
                    control.Save(wfDescription);
                }

                instance.PlanFinishTimeType = (int)wfDescription.PlanFinishTimeType;
                if (wfDescription.PlanFinishTimeType == TimeType.Duration)
                {
                    instance.PlanDuration = wfDescription.PlanDuration;
                }
                else if (wfDescription.PlanFinishTimeType == TimeType.DateTime)
                {
                    instance.PlanFinishDate = wfDescription.PlanFinishDate;
                }

                // Lock Library
                WorkflowParameters.SetOwnerReadOnly(instance, LockLibraryCheckBox.Checked);

                // Overdue Action
                WorkflowParameters.SetAssignmentOverdueAction(instance, (AssignmentOverdueAction)int.Parse(AssignmentOverdueActionList.SelectedValue));

                // Step 4. Accept Changes
                instance.Xaml = McWorkflowSerializer.GetString(wfDescription.TransientWorkflow);
                BusinessManager.Create(instance);
            }

            // Final Redirect
            RedirectToOwner();
        }