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(); } } }
private void BindData() { SchemaMaster currentShemaMaster = SchemaManager.GetShemaMaster(instance.SchemaId); object rootActivity = McWorkflowSerializer.GetObject(instance.Xaml); WorkflowDescription wfDescription = new WorkflowDescription((Guid)instance.PrimaryKeyId.Value, instance.Name, currentShemaMaster, rootActivity); ActivityGrid.DataSource = WorkflowActivityWrapper.GetActivityList(wfDescription, rootActivity); ActivityGrid.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { Response.Redirect("~/Modules/Pages/WorkflowList.aspx"); WorkflowDefinitionEntity en = BusinessManager.InitializeEntity <WorkflowDefinitionEntity>(WorkflowDefinitionEntity.ClassName); SequentialWorkflowActivity item = McWorkflowSerializer.GetObject <SequentialWorkflowActivity>(en.Xaml); CreateAssignmentAndWaitResultActivity act1 = new CreateAssignmentAndWaitResultActivity(); act1.Name = "Guid1"; //act1.Subject =" Subject Here " ; //a //item.Activities.Add(act1); }
/// <summary> /// When overridden in an abstract class, creates the control hierarchy that is used to render the composite data-bound control based on the values from the specified data source. /// </summary> /// <param name="dataSource">An <see cref="T:System.Collections.IEnumerable"/> that contains the values to bind to the control.</param> /// <param name="dataBinding">true to indicate that the <see cref="M:System.Web.UI.WebControls.CompositeDataBoundControl.CreateChildControls(System.Collections.IEnumerable,System.Boolean)"/> is called during data binding; otherwise, false.</param> /// <returns> /// The number of items created by the <see cref="M:System.Web.UI.WebControls.CompositeDataBoundControl.CreateChildControls(System.Collections.IEnumerable,System.Boolean)"/>. /// </returns> protected override int CreateChildControls(System.Collections.IEnumerable dataSource, bool dataBinding) { if (this.CurrentRootActivity == null) { //EntityObject[] arr = BusinessManager.List(WorkflowDefinitionEntity.ClassName, new Mediachase.Ibn.Data.FilterElement[] { new Mediachase.Ibn.Data.FilterElement("WorkflowDefinitionId", FilterElementType.Equal, this.WorkflowId) }); EntityObject obj = null; try { obj = BusinessManager.Load(WorkflowDefinitionEntity.ClassName, this.WorkflowId); } catch { } if (obj == null) { obj = BusinessManager.Load(WorkflowInstanceEntity.ClassName, this.WorkflowId); if (obj == null) { throw new ArgumentNullException(String.Format("Cant find workflow with id: {0}", this.WorkflowId)); } else { WorkflowInstanceEntity wfe = (WorkflowInstanceEntity)obj; this.CurrentRootActivity = McWorkflowSerializer.GetObject<SequentialWorkflowActivity>(wfe.Xaml); } } else { WorkflowDefinitionEntity wf = (WorkflowDefinitionEntity)obj; this.CurrentRootActivity = McWorkflowSerializer.GetObject<SequentialWorkflowActivity>(wf.Xaml); } } divContainer = new Panel(); divContainer.CssClass = "wfMainContainer"; divContainer.ID = this.ID + "_wfMainContainerId"; _counter = 0; if (this.CurrentRootActivity != null) ProcessNodeCollection(this.CurrentRootActivity, divContainer); this.Controls.Add(divContainer); return 1; }
/// <summary> /// Binds the value. /// </summary> private void BindValue() { EntityObject eo = BusinessManager.Load(WorkflowDefinitionEntity.ClassName, PrimaryKeyId.Parse(WorkflowId)); SequentialWorkflowActivity root = McWorkflowSerializer.GetObject <SequentialWorkflowActivity>(((WorkflowDefinitionEntity)eo).Xaml); Activity ac = root.GetActivityByName(ActivityName); if (ac is CreateAssignmentAndWaitResultActivity) { AssignmentPrototypePropertyEntityCollection props = ((CreateAssignmentAndWaitResultActivity)ac).PrototypeUserProperties; if (props.Contains("Assignment.Properties.Subject")) { tbSubject.Text = props.GetValue("Assignment.Properties.Subject").ToString(); } else { props.SetValue("Assignment.Properties.Subject", string.Empty); } } }
/// <summary> /// Handles the Click event of the btnOk control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> void btnOk_Click(object sender, EventArgs e) { EntityObject eo = BusinessManager.Load(WorkflowDefinitionEntity.ClassName, PrimaryKeyId.Parse(WorkflowId)); SequentialWorkflowActivity root = McWorkflowSerializer.GetObject <SequentialWorkflowActivity>(((WorkflowDefinitionEntity)eo).Xaml); Activity ac = root.GetActivityByName(ActivityName); if (ac is CreateAssignmentAndWaitResultActivity) { AssignmentPrototypePropertyEntityCollection props = ((CreateAssignmentAndWaitResultActivity)ac).PrototypeUserProperties; props.SetValue("Assignment.Properties.Subject", tbSubject.Text); } string xaml = McWorkflowSerializer.GetString <SequentialWorkflowActivity>(root); ((WorkflowDefinitionEntity)eo).Xaml = xaml; BusinessManager.Update(eo); Page.ClientScript.RegisterClientScriptBlock(this.GetType(), Guid.NewGuid().ToString(), "window.opener.__doPostBack('', ''); window.close();", true); //BusinessManager.Update(((CreateAssignmentAndWaitResultActivity)ac); }
protected void Page_Load(object sender, EventArgs e) { if (InstanceId != PrimaryKeyId.Empty) { instance = (WorkflowInstanceEntity)BusinessManager.Load(WorkflowInstanceEntity.ClassName, InstanceId); shemaMaster = SchemaManager.GetShemaMaster(instance.SchemaId); rootActivity = McWorkflowSerializer.GetObject(instance.Xaml); if (!String.IsNullOrEmpty(ActivityName)) { activity = WorkflowActivityWrapper.GetActivityByName(rootActivity, ActivityName); } } if (!IsPostBack) { BindInfo(); BindData(); } LoadControlToPlaceHolder(!IsPostBack); }
/// <summary> /// When overridden in an abstract class, creates the control hierarchy that is used to render the composite data-bound control based on the values from the specified data source. /// </summary> /// <param name="dataSource">An <see cref="T:System.Collections.IEnumerable"/> that contains the values to bind to the control.</param> /// <param name="dataBinding">true to indicate that the <see cref="M:System.Web.UI.WebControls.CompositeDataBoundControl.CreateChildControls(System.Collections.IEnumerable,System.Boolean)"/> is called during data binding; otherwise, false.</param> /// <returns> /// The number of items created by the <see cref="M:System.Web.UI.WebControls.CompositeDataBoundControl.CreateChildControls(System.Collections.IEnumerable,System.Boolean)"/>. /// </returns> protected override int CreateChildControls(System.Collections.IEnumerable dataSource, bool dataBinding) { if (this.CurrentRootActivity == null) { EntityObject[] arr = BusinessManager.List(WorkflowDefinitionEntity.ClassName, new Mediachase.Ibn.Data.FilterElement[] { new Mediachase.Ibn.Data.FilterElement("WorkflowDefinitionId", FilterElementType.Equal, this.WorkflowId) }); if (arr.Length == 1) { WorkflowDefinitionEntity wf = (WorkflowDefinitionEntity)arr[0]; this.CurrentRootActivity = McWorkflowSerializer.GetObject <SequentialWorkflowActivity>(wf.Xaml); } else { throw new ArgumentNullException(String.Format("Cant find workflow with id: {0}", this.WorkflowId)); } } btnSave = new Button(); btnSave.Text = "Save workflow"; btnSave.Click += new EventHandler(btnSave_Click); divContainer = new Panel(); divContainer.CssClass = "wfMainContainer"; divContainer.ID = this.ID + "_wfMainContainerId"; _counter = 0; if (this.CurrentRootActivity != null) { ProcessNodeCollection(this.CurrentRootActivity, divContainer); } divContainer.Controls.Add(btnSave); this.Controls.Add(divContainer); return(1); }
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(); }
/// <summary> /// Gets the user list. /// </summary> /// <param name="entity">The entity.</param> /// <returns></returns> private int[] GetUserList(WorkflowInstanceEntity entity) { object workflowRoot = McWorkflowSerializer.GetObject(entity.Xaml); return(WorkflowActivityWrapper.GetActivityUserList(workflowRoot)); }