/// <summary> /// Gets the activity master. /// </summary> /// <param name="schemaMaster">The schema master.</param> /// <param name="activityRoot">The activity root.</param> /// <param name="activityQualifiedName">Name of the activity qualified.</param> /// <returns></returns> public static ActivityMaster GetActivityMaster(SchemaMaster schemaMaster, object activityRoot, string activityQualifiedName) { Activity root = activityRoot as Activity; if (root == null) { return(null); } Activity element = root.GetActivityByName(activityQualifiedName); if (element == null) { return(null); } ActivityMaster activityMaster = schemaMaster.GetActivityMaster(element.GetType()); if (activityMaster == null) { return(null); } return(activityMaster); }
private void DisableUnsupportedObjectTypes(SchemaMaster currentShemaMaster) { // enable all DocumentCheckBox.Enabled = true; TaskCheckBox.Enabled = true; TodoCheckBox.Enabled = true; IncidentCheckBox.Enabled = true; if (currentShemaMaster != null) { List <int> supportedIbnObjectTypes = currentShemaMaster.Description.SupportedIbnObjectTypes; if (supportedIbnObjectTypes.Count > 0) // not all supported { if (!supportedIbnObjectTypes.Contains((int)ObjectTypes.Document)) { DocumentCheckBox.Enabled = false; } if (!supportedIbnObjectTypes.Contains((int)ObjectTypes.Task)) { TaskCheckBox.Enabled = false; } if (!supportedIbnObjectTypes.Contains((int)ObjectTypes.ToDo)) { TodoCheckBox.Enabled = false; } if (!supportedIbnObjectTypes.Contains((int)ObjectTypes.Issue)) { IncidentCheckBox.Enabled = false; } } } }
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(); } } }
protected void SchemaMasterList_SelectedIndexChanged(object sender, EventArgs e) { SchemaMaster currentShemaMaster = SchemaManager.GetShemaMaster(new Guid(SchemaMasterList.SelectedValue)); ControlName = currentShemaMaster.Description.UI.CreateControl; LoadControlToPlaceHolder(true); }
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(); }
/// <summary> /// Initializes a new instance of the <see cref="WorkflowDescription"/> class. /// </summary> public WorkflowDescription(string name, SchemaMaster schemaMaster, object transientWorkflow) { if (name == null) { throw new ArgumentNullException("name"); } if (schemaMaster == null) { throw new ArgumentNullException("schemaMaster"); } if (transientWorkflow == null) { throw new ArgumentNullException("transientWorkflow"); } this.Name = name; this.SchemaMaster = schemaMaster; this.TransientWorkflow = transientWorkflow; this.PlanFinishTimeType = TimeType.NotSet; }
/// <summary> /// Gets the activity primitive. /// </summary> /// <param name="activity">The activity.</param> /// <param name="pageInstanse">The page instanse.</param> /// <returns></returns> public static Control GetActivityPrimitive(Activity activity, SchemaMaster shemaMaster, Page pageInstanse) { //ToDo: get additional info from activity ActivityMaster am = WorkflowActivityWrapper.GetActivityMaster(shemaMaster, activity, activity.Name); if (am != null) { return(pageInstanse.LoadControl(am.Description.UI.ViewControl)); } else { return(null); } //if (activity is CompositeActivity && ((CompositeActivity)activity).Activities.Count > 0) //{ // return pageInstanse.LoadControl("~/Apps/BusinessProcess/Primitives/CompositeActivity.ascx"); //} //else //{ // return pageInstanse.LoadControl("~/Apps/BusinessProcess/Primitives/SimpleActivity.ascx"); //} }
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); }
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(); }
private void BindData() { RebuildTemplateGroupList(); if (instance != null) // create from instance { NameText.Text = instance.Name; if (instance.Description != null) { DescriptionText.Text = instance.Description; } SchemaMaster currentShemaMaster = SchemaManager.GetShemaMaster(instance.SchemaId); string title = currentShemaMaster.Description.Comment; if (string.IsNullOrEmpty(title)) { title = currentShemaMaster.Description.Name; } SchemaMasterList.Items.Add(new ListItem(CHelper.GetResFileString(title), currentShemaMaster.Description.Id.ToString())); SchemaMasterList.Enabled = false; ControlName = currentShemaMaster.Description.UI.EditControl; // Object types DisableUnsupportedObjectTypes(currentShemaMaster); // Lock Library LockLibraryCheckBox.Checked = WorkflowParameters.GetOwnerReadOnly(instance); // Overdue Action CHelper.SafeSelect(AssignmentOverdueActionList, ((int)WorkflowParameters.GetAssignmentOverdueAction(instance)).ToString()); } else if (template != null) // edit { NameText.Text = template.Name; if (template.Description != null) { DescriptionText.Text = template.Description; } SchemaMaster currentShemaMaster = SchemaManager.GetShemaMaster(template.SchemaId); string title = currentShemaMaster.Description.Comment; if (string.IsNullOrEmpty(title)) { title = currentShemaMaster.Description.Name; } SchemaMasterList.Items.Add(new ListItem(CHelper.GetResFileString(title), currentShemaMaster.Description.Id.ToString())); SchemaMasterList.Enabled = false; ControlName = currentShemaMaster.Description.UI.EditControl; if (template.ProjectId.HasValue) { ProjectControl.ObjectId = (int)template.ProjectId.Value; } // Object types DisableUnsupportedObjectTypes(currentShemaMaster); List <int> selectedObjectTypes = new List <int>(template.SupportedIbnObjectTypes); DocumentCheckBox.Checked = selectedObjectTypes.Contains((int)ObjectTypes.Document); IncidentCheckBox.Checked = selectedObjectTypes.Contains((int)ObjectTypes.Issue); TaskCheckBox.Checked = selectedObjectTypes.Contains((int)ObjectTypes.Task); TodoCheckBox.Checked = selectedObjectTypes.Contains((int)ObjectTypes.ToDo); // Lock Library LockLibraryCheckBox.Checked = WorkflowParameters.GetOwnerReadOnly(template); // Overdue Action CHelper.SafeSelect(AssignmentOverdueActionList, ((int)WorkflowParameters.GetAssignmentOverdueAction(template)).ToString()); // Template Group TemplateGroupValue = template.TemplateGroup; } else // new { SchemaMaster[] list = SchemaManager.GetAvailableShemaMasters(); if (list != null && list.Length > 0) { List <ListItem> listItems = new List <ListItem>(); foreach (SchemaMaster item in list) { string title = item.Description.Comment; if (string.IsNullOrEmpty(title)) { title = item.Description.Name; } listItems.Add(new ListItem(CHelper.GetResFileString(title), item.Description.Id.ToString())); } listItems.Sort(delegate(ListItem x, ListItem y) { return(x.Text.CompareTo(y.Text)); }); SchemaMasterList.Items.AddRange(listItems.ToArray()); SchemaMasterList.SelectedIndex = 0; SchemaMaster currentShemaMaster = null;; string selectedItem = SchemaMasterList.SelectedValue; foreach (SchemaMaster item in list) { if (item.Description.Id.ToString() == selectedItem) { currentShemaMaster = item; break; } } ControlName = currentShemaMaster.Description.UI.CreateControl; DisableUnsupportedObjectTypes(currentShemaMaster); } } string url = String.Format(CultureInfo.InvariantCulture, "{0}?type=TemplateGroups&btn={1}", ResolveClientUrl("~/Apps/MetaDataBase/Pages/Public/EnumView.aspx"), Page.ClientScript.GetPostBackEventReference(RefreshButton, "")); EditItemsButton.Attributes.Add("onclick", String.Format(CultureInfo.InvariantCulture, "enumEdit_OpenWindow(\"{0}\", 750, 500, 1)", url)); }
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(); }
private void BindData() { if (instance == null) // new { SchemaMaster[] list = SchemaManager.GetAvailableShemaMasters(); if (list != null && list.Length > 0) { List <ListItem> listItems = new List <ListItem>(); foreach (SchemaMaster item in list) { string title = item.Description.Comment; if (string.IsNullOrEmpty(title)) { title = item.Description.Name; } listItems.Add(new ListItem(CHelper.GetResFileString(title), item.Description.Id.ToString())); } listItems.Sort(delegate(ListItem x, ListItem y) { return(x.Text.CompareTo(y.Text)); }); SchemaMasterList.Items.AddRange(listItems.ToArray()); SchemaMasterList.SelectedIndex = 0; SchemaMaster currentShemaMaster = null;; string selectedItem = SchemaMasterList.SelectedValue; foreach (SchemaMaster item in list) { if (item.Description.Id.ToString() == selectedItem) { currentShemaMaster = item; break; } } ControlName = currentShemaMaster.Description.UI.CreateControl; } } else // edit { NameText.Text = instance.Name; if (instance.Description != null) { DescriptionText.Text = instance.Description; } SchemaMaster currentShemaMaster = SchemaManager.GetShemaMaster(instance.SchemaId); string title = currentShemaMaster.Description.Comment; if (string.IsNullOrEmpty(title)) { title = currentShemaMaster.Description.Name; } SchemaMasterList.Items.Add(new ListItem(CHelper.GetResFileString(title), currentShemaMaster.Description.Id.ToString())); SchemaMasterList.Enabled = false; // Lock Library LockLibraryCheckBox.Checked = WorkflowParameters.GetOwnerReadOnly(instance); // Overdue Action CHelper.SafeSelect(AssignmentOverdueActionList, ((int)WorkflowParameters.GetAssignmentOverdueAction(instance)).ToString()); ControlName = currentShemaMaster.Description.UI.EditControl; } }
public IEnumerable <SchemaMaster> UpdateSchemaMaster([FromBody] SchemaMaster SchemaMaster, string UserId, string SchemeMasterId) { return(objCountry.UpdateSchemaMaster(SchemaMaster, UserId, SchemeMasterId)); }
public IEnumerable <SchemaMaster> AddSchemaMaster([FromBody] SchemaMaster SchemaMaster, string UserId) { return(objCountry.AddSchemaMaster(SchemaMaster, UserId)); }