static void TestCreate() { DataContext.Current = new DataContext("Data source=S2;Initial catalog=ibn48portal;Integrated Security=SSPI;"); using (TransactionScope tran = DataContext.Current.BeginTransaction()) { WorkflowDefinitionEntity entity1 = new WorkflowDefinitionEntity(); entity1.Name = "Test 111"; entity1.SupportedIbnObjectTypes = new int[] { 16 }; BusinessManager.Create(entity1); WorkflowDefinitionEntity entity2 = new WorkflowDefinitionEntity(); entity2.Name = "Test 222"; entity2.SupportedIbnObjectTypes = new int[] { 16, 5, 6, 7 }; BusinessManager.Create(entity2); WorkflowDefinitionEntity entity3 = new WorkflowDefinitionEntity(); entity3.Name = "Test 333"; entity3.SupportedIbnObjectTypes = new int[] { 5, 6, 7 }; BusinessManager.Create(entity3); tran.Commit(); } }
/// <summary> /// Initializes a new instance of the <see cref="WorkflowChangesScope"/> class. /// </summary> /// <param name="entity">The entity.</param> protected WorkflowChangesScope(WorkflowDefinitionEntity entity) { this.InstanceId = entity.PrimaryKeyId.HasValue? (Guid)entity.PrimaryKeyId.Value: Guid.Empty; this.WorkflowEntity = entity; this.TransientWorkflow = McWorkflowSerializer.GetObject <CompositeActivity>((string)this.WorkflowEntity[WorkflowInstanceEntity.FieldXaml]); }
/// <summary> /// Initializes a new instance of the <see cref="WorkflowChangesScope"/> class. /// </summary> /// <param name="entity">The entity.</param> protected WorkflowChangesScope(WorkflowDefinitionEntity entity) { this.InstanceId = entity.PrimaryKeyId.HasValue? (Guid)entity.PrimaryKeyId.Value: Guid.Empty; this.WorkflowEntity = entity; this.TransientWorkflow = McWorkflowSerializer.GetObject<CompositeActivity>((string)this.WorkflowEntity[WorkflowInstanceEntity.FieldXaml]); }
/// <summary> /// Creates the entity object. /// </summary> /// <param name="metaClassName">Name of the meta class.</param> /// <param name="primaryKeyId">The primary key id.</param> /// <returns></returns> protected override EntityObject CreateEntityObject(string metaClassName, PrimaryKeyId? primaryKeyId) { if (metaClassName == WorkflowDefinitionEntity.ClassName) { WorkflowDefinitionEntity retVal = new WorkflowDefinitionEntity(); retVal.PrimaryKeyId = primaryKeyId; return retVal; } return base.CreateEntityObject(metaClassName, primaryKeyId); }
/// <summary> /// Creates the specified entity. /// </summary> /// <param name="entity">The entity.</param> /// <returns></returns> public static WorkflowChangesScope Create(WorkflowDefinitionEntity entity) { if (entity == null) { throw new ArgumentNullException("entity"); } WorkflowChangesScope retVal = new WorkflowChangesScope(entity); return(retVal); }
/// <summary> /// Creates the entity object. /// </summary> /// <param name="metaClassName">Name of the meta class.</param> /// <param name="primaryKeyId">The primary key id.</param> /// <returns></returns> protected override EntityObject CreateEntityObject(string metaClassName, PrimaryKeyId?primaryKeyId) { if (metaClassName == WorkflowDefinitionEntity.ClassName) { WorkflowDefinitionEntity retVal = new WorkflowDefinitionEntity(); retVal.PrimaryKeyId = primaryKeyId; return(retVal); } return(base.CreateEntityObject(metaClassName, primaryKeyId)); }
/// <summary> /// Creates the specified entity. /// </summary> /// <param name="entity">The entity.</param> /// <returns></returns> public static WorkflowChangesScope Create(WorkflowDefinitionEntity entity) { if (entity == null) throw new ArgumentNullException("entity"); WorkflowChangesScope retVal = new WorkflowChangesScope(entity); return retVal; }
static void TestCreate() { DataContext.Current = new DataContext("Data source=S2;Initial catalog=ibn48portal;Integrated Security=SSPI;"); using (TransactionScope tran = DataContext.Current.BeginTransaction()) { WorkflowDefinitionEntity entity1 = new WorkflowDefinitionEntity(); entity1.Name = "Test 111"; entity1.SupportedIbnObjectTypes = new int[] { 16 }; BusinessManager.Create(entity1); WorkflowDefinitionEntity entity2 = new WorkflowDefinitionEntity(); entity2.Name = "Test 222"; entity2.SupportedIbnObjectTypes = new int[] { 16, 5, 6, 7 }; BusinessManager.Create(entity2); WorkflowDefinitionEntity entity3 = new WorkflowDefinitionEntity(); entity3.Name = "Test 333"; entity3.SupportedIbnObjectTypes = new int[] { 5, 6, 7 }; BusinessManager.Create(entity3); tran.Commit(); } }
protected void Page_Load(object sender, EventArgs e) { if (ObjectId != PrimaryKeyId.Empty) template = (WorkflowDefinitionEntity)BusinessManager.Load(WorkflowDefinitionEntity.ClassName, ObjectId); else if (FromInstanceId != PrimaryKeyId.Empty) instance = (WorkflowInstanceEntity)BusinessManager.Load(WorkflowInstanceEntity.ClassName, FromInstanceId); if (!IsPostBack) { BindInfo(); // texts, icons BindData(); BindToolbar(); } LoadControlToPlaceHolder(!IsPostBack); if (!this.Page.ClientScript.IsStartupScriptRegistered(this.Page.GetType(), "EnumEdit")) this.Page.ClientScript.RegisterStartupScript(this.Page.GetType(), "EnumEdit", @"function enumEdit_OpenWindow(query, w, h, resize){ var l = (screen.width - w) / 2; var t = (screen.height - h) / 2; winprops = 'height='+h+',width='+w+',top='+t+',left='+l; if (scroll) winprops+=',scrollbars=1'; if (resize) winprops+=',resizable=1'; else winprops+=',resizable=0'; var f = window.open(query, '_blank', winprops); }", true); }
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(); }