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(); } } }
public void Schedule_the_child_workflow() { var description = new WorkflowDescription("1.0") { DefaultChildPolicy = "child", DefaultExecutionStartToCloseTimeout = TimeSpan.FromSeconds(3), DefaultLambdaRole = "lambdarole", DefaultTaskListName = "task", DefaultTaskPriority = 1, DefaultTaskStartToCloseTimeout = TimeSpan.FromSeconds(1), }; var item = new ChildWorkflowItem(_identity, _workflow.Object, description); var swfDecision = item.ScheduleDecisions().First().SwfDecision(); Assert.That(swfDecision.DecisionType, Is.EqualTo(DecisionType.StartChildWorkflowExecution)); var attr = swfDecision.StartChildWorkflowExecutionDecisionAttributes; Assert.That(attr.WorkflowType.Name, Is.EqualTo(WorkflowName)); Assert.That(attr.WorkflowType.Version, Is.EqualTo(Version)); Assert.That(attr.WorkflowId, Is.EqualTo(_scheduleIdentity.ToString())); Assert.That(attr.Control.As <ScheduleData>().PN, Is.EqualTo(_identity.PositionalName)); Assert.That(attr.ChildPolicy.Value, Is.EqualTo("child")); Assert.That(attr.ExecutionStartToCloseTimeout, Is.EqualTo("3")); Assert.That(attr.LambdaRole, Is.EqualTo("lambdarole")); Assert.That(attr.TaskList.Name, Is.EqualTo("task")); Assert.That(attr.TaskPriority, Is.EqualTo("1")); Assert.That(attr.TaskStartToCloseTimeout, Is.EqualTo("1")); Assert.That(attr.TagList, Is.Empty); }
/// <summary> /// Converts the instance into a public <see cref="WorkflowDescription"/>. /// </summary> public WorkflowDescription ToPublic() { var details = new WorkflowDescription() { Configuration = this.ExecutionConfiguration?.ToPublic(), Status = this.WorkflowExecutionInfo?.ToPublic() }; details.PendingActivities = new List <PendingActivityInfo>(); if (this.PendingActivities != null) { foreach (var activity in this.PendingActivities) { details.PendingActivities.Add(activity.ToPublic()); } } details.PendingChildren = new List <PendingChildExecutionInfo>(); if (this.PendingChildren != null) { foreach (var child in this.PendingChildren) { details.PendingChildren.Add(child.ToPublic()); } } return(details); }
private static void ReadBlocks(WorkflowDescription description, string componentFolderPath) { foreach (var block in description.Blocks) { var blockFolderPath = Path.Combine(componentFolderPath, "Blocks", block.Id); ReadActions(block, blockFolderPath); ReadEvents(block, blockFolderPath); ReadProperties(block, blockFolderPath); } }
/// <summary> /// Распарсить описание типового маршрута. /// </summary> /// <param name="workflowDescriptionXml">XML описания маршрута.</param> /// <returns>Описание типового маршрута.</returns> public static WorkflowDescription Parse(string workflowDescriptionXml) { var workflowDescription = new WorkflowDescription(); var parser = new WorkflowDescriptionParser(workflowDescriptionXml); workflowDescription.Actions.AddRange(parser.GetActions()); workflowDescription.Blocks.AddRange(parser.GetBlocks()); workflowDescription.Events.AddRange(parser.GetEvents()); return(workflowDescription); }
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(); }
public void Workflow_description_attribute_has_property_set() { var d = WorkflowDescription.FindOn <WorkflowWithTimeoutSet>(); Assert.That(d.DefaultChildPolicy, Is.EqualTo("policy")); Assert.That(d.DefaultLambdaRole, Is.EqualTo("role")); Assert.That(d.DefaultTaskListName, Is.EqualTo("tlist")); Assert.That(d.DefaultTaskPriority, Is.EqualTo(1)); Assert.That(d.Description, Is.EqualTo("desc")); Assert.That(d.Name, Is.EqualTo("test")); Assert.That(d.Version, Is.EqualTo("1.0")); Assert.That(d.DefaultExecutionStartToCloseTimeout, Is.EqualTo(TimeSpan.FromSeconds(10))); Assert.That(d.DefaultTaskStartToCloseTimeout, Is.EqualTo(TimeSpan.FromSeconds(9))); }
public void Factory_method_has_priority_over_attributes() { var d = WorkflowDescription.FindOn <WorkflowWithDescriptionFactoryMethod>(); Assert.That(d.Name, Is.EqualTo("test")); Assert.That(d.Version, Is.EqualTo("1.0")); Assert.That(d.Description, Is.EqualTo("desc")); Assert.That(d.DefaultTaskListName, Is.EqualTo("tname")); Assert.That(d.DefaultTaskPriority, Is.EqualTo(1)); Assert.That(d.DefaultExecutionStartToCloseTimeout, Is.EqualTo(TimeSpan.FromSeconds(10))); Assert.That(d.DefaultTaskStartToCloseTimeout, Is.EqualTo(TimeSpan.FromSeconds(9))); Assert.That(d.DefaultChildPolicy, Is.EqualTo("policy")); Assert.That(d.DefaultLambdaRole, Is.EqualTo("lambdarole")); }
private async Task RegisterWorkflowAsync(WorkflowDescription workflowDescription) { Ensure.NotNull(workflowDescription, "workflowDescription"); var registeredWorkflowInfos = await ListWorkflowsFromAmazonBy(workflowDescription.Name); var workflowToRegister = registeredWorkflowInfos.FirstOrDefault(w => w.WorkflowType.Version.Equals(workflowDescription.Version)); if (workflowToRegister != null) { return; } await _simpleWorkflowClient.RegisterWorkflowTypeAsync(workflowDescription.RegisterRequest(_name)); }
public void Workflow_description_has_only_version_property_set() { var d = WorkflowDescription.FindOn <WorkflowWithOnlyVersion>(); Assert.That(d.Version, Is.EqualTo("1.0")); Assert.That(d.Name, Is.EqualTo(nameof(WorkflowWithOnlyVersion))); Assert.IsNull(d.Description); Assert.IsNull(d.DefaultTaskListName); Assert.IsNull(d.DefaultChildPolicy); Assert.IsNull(d.DefaultLambdaRole); Assert.That(d.DefaultTaskPriority, Is.EqualTo(0)); Assert.IsNull(d.DefaultExecutionStartToCloseTimeout); Assert.IsNull(d.DefaultTaskStartToCloseTimeout); }
private static void ReadActions(WorkflowDescription description, string componentFolderPath) { foreach (var action in description.Actions) { var actionFile = Path.Combine(componentFolderPath, "Actions", $"{action.Name}.isbl"); if (File.Exists(actionFile)) { action.CalculationText = File.ReadAllText(actionFile, Encoding.GetEncoding(1251)); } else { log.Warn($"File not found {actionFile}"); } } }
public WorkflowViewModel(ScopeViewModel currentScope, WorkflowDescription description, ServiceContext context) : base(currentScope) { this.description = description; this.context = context; this.ShowExternalVariablesCommand = new SimpleActionCommand(this.OnShowExternalVariables); this.ShowInstancesCommand = new SimpleActionCommand(this.OnShowInstances); this.ShowMetadataCommand = new SimpleActionCommand(this.OnShowMetadata); this.ShowConfigurationCommand = new SimpleActionCommand(this.OnShowConfiguration); this.ShowRootActivityCommand = new SimpleActionCommand(this.OnShowRootActivityXaml); if (this.description.Configuration != null) { this.configurationViewModel = new WorkflowConfigurationViewModel(this.description.Configuration); this.ShowConfigurationCommand = new SimpleActionCommand(this.OnShowConfiguration); } }
public static void PublishWorkflowString(this WorkflowManagementClient client, string workflowName, string xamlFile, Collection <ExternalVariable> externalVariables, IDictionary <string, string> configValues, SubscriptionFilter activationFilter = null) { // publish the activity description related with the workflow client.Activities.Publish( new ActivityDescription(WorkflowUtils.TranslateString(xamlFile)) { Name = workflowName }, true, true); // now, publish the workflow description WorkflowDescription description = new WorkflowDescription { Name = workflowName, ActivityPath = workflowName, }; // add external variables if (externalVariables != null) { externalVariables .ToList() .ForEach(ev => description.ExternalVariables.Add(ev)); } // add config if (configValues != null) { description.Configuration = new WorkflowConfiguration(); configValues .ToList() .ForEach(c => description.Configuration.AppSettings.Add(c)); } // add activation filter if (activationFilter != null) { description.ActivationDescription = new SubscriptionActivationDescription { Filter = activationFilter }; } // publish! client.Workflows.Publish(description); }
private void AssertThatAmazonSwfIsSendRegistrationRequestFor(WorkflowDescription attribute) { Func <RegisterWorkflowTypeRequest, bool> parameter = (r) => { Assert.That(r.Name, Is.EqualTo(attribute.Name)); Assert.That(r.Version, Is.EqualTo(attribute.Version)); Assert.That(r.Description, Is.EqualTo(attribute.Description)); Assert.That(r.Domain, Is.EqualTo(_domainName)); Assert.That(r.DefaultTaskList.Name, Is.EqualTo(attribute.DefaultTaskListName)); Assert.That(r.DefaultChildPolicy.Value, Is.EqualTo(attribute.DefaultChildPolicy)); Assert.That(r.DefaultLambdaRole, Is.EqualTo(attribute.DefaultLambdaRole)); Assert.That(r.DefaultExecutionStartToCloseTimeout, Is.EqualTo(attribute.DefaultExecutionStartToCloseTimeout.Seconds())); Assert.That(r.DefaultTaskStartToCloseTimeout, Is.EqualTo(attribute.DefaultTaskStartToCloseTimeout.Seconds())); return(true); }; _amazonWorkflowClient.Verify(a => a.RegisterWorkflowTypeAsync(It.Is <RegisterWorkflowTypeRequest>(req => parameter(req)), default(CancellationToken)), Times.Once); }
private static void NewCreatePOAssociation(WorkflowDescription _dsc, SPWeb _web, SPList _taskList, SPList _historyList, bool _autoStartCreate) { SPWorkflowTemplate _workflowTemplate = _web.WorkflowTemplates[_dsc.WorkflowId]; // create workflow association SPWorkflowAssociation _freightPOLibraryWorkflowAssociation = SPWorkflowAssociation.CreateListAssociation( _workflowTemplate, _dsc.Name, _taskList, _historyList); // configure workflow association and add to WorkflowAssociations collection _freightPOLibraryWorkflowAssociation.Description = _dsc.Description; _freightPOLibraryWorkflowAssociation.AllowManual = true; _freightPOLibraryWorkflowAssociation.AutoStartCreate = _autoStartCreate; _freightPOLibraryWorkflowAssociation.AutoStartChange = false; _freightPOLibraryWorkflowAssociation.AssociationData = _dsc.Name; _web.Lists[CommonDefinition.ShippingListTitle].WorkflowAssociations.Add(_freightPOLibraryWorkflowAssociation); }
public static void PublishWorkflow(this WorkflowManagementClient client, string workflowName, string xamlFilePath, Collection<ExternalVariable> externalVariables, IDictionary<string, string> configValues, SubscriptionFilter activationFilter = null) { // publish the activity description related with the workflow client.Activities.Publish( new ActivityDescription(WorkflowUtils.Translate(xamlFilePath)) { Name = workflowName },true,true); // now, publish the workflow description WorkflowDescription description = new WorkflowDescription { Name = workflowName, ActivityPath = workflowName, }; // add external variables if (externalVariables != null) { externalVariables .ToList() .ForEach(ev => description.ExternalVariables.Add(ev)); } // add config if (configValues != null) { description.Configuration = new WorkflowConfiguration(); configValues .ToList() .ForEach(c => description.Configuration.AppSettings.Add(c)); } // add activation filter if (activationFilter != null) { description.ActivationDescription = new SubscriptionActivationDescription { Filter = activationFilter }; } // publish! client.Workflows.Publish(description); }
private static void ReadEvents(WorkflowDescription description, string componentFolderPath) { foreach (var @event in description.Events) { if (eventFileNames.TryGetValue(@event.Name, out string eventFileName)) { var eventFile = Path.Combine(componentFolderPath, "Events", eventFileName); if (File.Exists(eventFile)) { @event.CalculationText = File.ReadAllText(eventFile, Encoding.GetEncoding(1251)); } //else // log.Warn($"File not found {eventFile}"); } else { log.Warn($"Unknown event {@event.Name}"); } } }
/// <summary> /// Converts the instance into a public <see cref="WorkflowDescription"/>. /// </summary> public WorkflowDescription ToPublic() { var details = new WorkflowDescription() { Configuration = this.ExecutionConfiguration?.ToPublic(), Execution = this.WorkflowExecutionInfo?.ToPublic() }; details.Activities = new List <DescribedActivityInfo>(); if (this.PendingActivities != null) { foreach (var activity in this.PendingActivities) { details.Activities.Add(activity.ToPublic()); } } return(details); }
private static void NewWorkflowAssociation(string _targetList, WorkflowDescription _dsc, SPWeb _web, SPList _taskList, SPList _historyList) { if (string.IsNullOrEmpty(_targetList)) { throw new ApplicationException("The parameter _targetList of the NewWorkflowAssociation cannot be null or empty"); } SPWorkflowTemplate _workflowTemplate = _web.WorkflowTemplates[_dsc.WorkflowId]; // create workflow association SPWorkflowAssociation _workflowAssociation = SPWorkflowAssociation.CreateListAssociation( _workflowTemplate, _dsc.Name, _taskList, _historyList); // configure workflow association and add to WorkflowAssociations collection _workflowAssociation.Description = _dsc.Description; _workflowAssociation.AllowManual = true; _workflowAssociation.AutoStartCreate = false; _workflowAssociation.AutoStartChange = false; _workflowAssociation.AssociationData = _dsc.Name; _web.Lists[_targetList].WorkflowAssociations.Add(_workflowAssociation); }
public void Can_override_scheduling_properties_when_workflow_description_is_provided() { var description = new WorkflowDescription("1.0") { DefaultChildPolicy = "child", DefaultExecutionStartToCloseTimeout = TimeSpan.FromSeconds(3), DefaultLambdaRole = "lambdarole", DefaultTaskListName = "task", DefaultTaskPriority = 1, DefaultTaskStartToCloseTimeout = TimeSpan.FromSeconds(1), }; var item = new ChildWorkflowItem(_identity, _workflow.Object, description); item.WithChildPolicy(_ => "newchild").WithLambdaRole(_ => "newlambda").OnTaskList(_ => "newtask") .WithPriority(_ => 2).WithTimeouts(_ => new WorkflowTimeouts() { ExecutionStartToCloseTimeout = TimeSpan.FromSeconds(4), TaskStartToCloseTimeout = TimeSpan.FromSeconds(5) }).WithTags(_ => new [] { "hello", "hi" }); var swfDecision = item.ScheduleDecisions().First().SwfDecision(); Assert.That(swfDecision.DecisionType, Is.EqualTo(DecisionType.StartChildWorkflowExecution)); var attr = swfDecision.StartChildWorkflowExecutionDecisionAttributes; Assert.That(attr.WorkflowType.Name, Is.EqualTo(WorkflowName)); Assert.That(attr.WorkflowType.Version, Is.EqualTo(Version)); Assert.That(attr.WorkflowId, Is.EqualTo(_scheduleIdentity.ToString())); Assert.That(attr.Control.As <ScheduleData>().PN, Is.EqualTo(_identity.PositionalName)); Assert.That(attr.ChildPolicy.Value, Is.EqualTo("newchild")); Assert.That(attr.ExecutionStartToCloseTimeout, Is.EqualTo("4")); Assert.That(attr.LambdaRole, Is.EqualTo("newlambda")); Assert.That(attr.TaskList.Name, Is.EqualTo("newtask")); Assert.That(attr.TaskPriority, Is.EqualTo("2")); Assert.That(attr.TaskStartToCloseTimeout, Is.EqualTo("5")); Assert.That(attr.TagList, Is.EqualTo(new[] { "hello", "hi" })); }
public void Deserialize_returns_correct_results() { var yesJustificationEnums = new List <JustificationEnum>() { JustificationEnum.ContractNotComplete, JustificationEnum.ServicePeriodNotExpired, JustificationEnum.ContractorFiledClaim, JustificationEnum.WatingOnRelease, JustificationEnum.NoRecentActivity, JustificationEnum.ValidRecurringContract, JustificationEnum.Other }; var noJustificationEnums = new List <JustificationEnum>() { JustificationEnum.ItemInvalid, JustificationEnum.InvalidRecurringContract, JustificationEnum.Other }; var allJustificationEnumsArr = (JustificationEnum[])Enum.GetValues(typeof(JustificationEnum)); var allJustificationEnumsList = new List <JustificationEnum>(); allJustificationEnumsList.AddRange(allJustificationEnumsArr); allJustificationEnumsList = allJustificationEnumsList.Where( j => j != JustificationEnum.ReassignVaction && j != JustificationEnum.ReassignNeedHelp).ToList(); var nextActivityConfig = JsonConvert.SerializeObject(new FieldComparisonActivityChooser.MySettings { Expressions = new List <FieldComparisonActivityChooser.Expression> { new FieldComparisonActivityChooser.Expression { Code = "wf.CurrentWorkflowActivityKey == \"B1\"", WorkflowActivityKey = "B2" }, new FieldComparisonActivityChooser.Expression { Code = "wf.CurrentWorkflowActivityKey == \"B2\" && wfQuestion.Answer == \"Disapprove\"", WorkflowActivityKey = "B1" }, new FieldComparisonActivityChooser.Expression { Code = "wf.CurrentWorkflowActivityKey == \"B2\" && wfQuestion.Answer == \"Approve\"", WorkflowActivityKey = "B3" }, new FieldComparisonActivityChooser.Expression { Code = "wf.CurrentWorkflowActivityKey == \"B3\" && wfQuestion.Answer == \"Not Concur\"", WorkflowActivityKey = "B2" }, new FieldComparisonActivityChooser.Expression { Code = "wf.CurrentWorkflowActivityKey == \"B3\" && wfQuestion.Answer == \"Concur\"", WorkflowActivityKey = "B4" }, new FieldComparisonActivityChooser.Expression { Code = "wf.CurrentWorkflowActivityKey == \"B4\" && wfQuestion.Answer == \"Not Concur\"", WorkflowActivityKey = "B3" }, new FieldComparisonActivityChooser.Expression { Code = "wf.CurrentWorkflowActivityKey == \"B4\" && wfQuestion.Answer == \"Concur\" && wf.UnliquidatedObligation.Valid == true", WorkflowActivityKey = "B5" }, new FieldComparisonActivityChooser.Expression { Code = "wf.CurrentWorkflowActivityKey == \"B4\" && wfQuestion.Answer == \"Concur\" && wf.UnliquidatedObligation.Valid == false", WorkflowActivityKey = "B6" }, new FieldComparisonActivityChooser.Expression { Code = "wf.CurrentWorkflowActivityKey == \"B6\" && wfQuestion.Answer == \"Deobligated\"", WorkflowActivityKey = "B5" } } }); var regionNextActivityConfig = JsonConvert.SerializeObject(new FieldComparisonActivityChooser.MySettings { Expressions = new List <FieldComparisonActivityChooser.Expression> { new FieldComparisonActivityChooser.Expression { Code = "wf.CurrentWorkflowActivityKey == \"B1\"", WorkflowActivityKey = "B2" }, new FieldComparisonActivityChooser.Expression { Code = "wf.CurrentWorkflowActivityKey == \"B2\" && wfQuestion.Answer == \"Disapprove\"", WorkflowActivityKey = "B1" }, new FieldComparisonActivityChooser.Expression { Code = "wf.CurrentWorkflowActivityKey == \"B2\" && wfQuestion.Answer == \"Approve\" && wf.UnliquidatedObligation.Valid == true", WorkflowActivityKey = "B3" }, new FieldComparisonActivityChooser.Expression { Code = "wf.CurrentWorkflowActivityKey == \"B2\" && wfQuestion.Answer == \"Approve\" && wf.UnliquidatedObligation.Valid == false", WorkflowActivityKey = "B4" }, new FieldComparisonActivityChooser.Expression { Code = "wf.CurrentWorkflowActivityKey == \"B4\" && wfQuestion.Answer == \"Deobligated\"", WorkflowActivityKey = "B3" } } }); List <WebActionWorkflowActivity> regionWfDActivities = new List <WebActionWorkflowActivity>() { new WebActionWorkflowActivity { ActionName = "Index", ActivityName = "Region Review", SequenceNumber = 1, ControllerName = "Ulo", DueIn = new TimeSpan(20, 0, 0, 0), NextActivityChooserConfig = regionNextActivityConfig, NextActivityChooserTypeName = "FieldComparisonActivityChooser", WorkflowActivityKey = "B1", OwnerUserName = "******", JustificationNeeded = true, AllowDocumentEdit = true, RouteValueByName = new Dictionary <string, object>(), EmailTemplateId = 1, ExpectedDateForCompletionEditable = true, ExpectedDateForCompletionNeeded = true, ExpectedDateAlwaysShow = false, QuestionChoices = new WorkflowQuestionChoices { QuestionLabel = "Is this Valid?", DefaultJustificationEnums = null, Choices = new List <QuestionChoice>() { new QuestionChoice() { Text = "Yes", Value = "Valid", JustificationsEnums = yesJustificationEnums }, new QuestionChoice() { Text = "No", Value = "Invalid", JustificationsEnums = noJustificationEnums } } } }, new WebActionWorkflowActivity { ActionName = "Index", ActivityName = "Region Approval", SequenceNumber = 2, ControllerName = "Ulo", NextActivityChooserConfig = regionNextActivityConfig, NextActivityChooserTypeName = "FieldComparisonActivityChooser", WorkflowActivityKey = "B2", OwnerUserName = "******", JustificationNeeded = true, AllowDocumentEdit = true, RouteValueByName = new Dictionary <string, object>(), EmailTemplateId = 1, ExpectedDateForCompletionEditable = true, ExpectedDateForCompletionNeeded = true, ExpectedDateAlwaysShow = false, QuestionChoices = new WorkflowQuestionChoices { QuestionLabel = "Do you Approve?", DefaultJustificationEnums = allJustificationEnumsList, Choices = new List <QuestionChoice>() { new QuestionChoice() { Text = "Yes", Value = "Approve" }, new QuestionChoice() { Text = "No", Value = "Disapprove" } } } }, new WebActionWorkflowActivity { ActionName = "Index", ActivityName = "Complete", SequenceNumber = 4, ControllerName = "Ulo", NextActivityChooserConfig = regionNextActivityConfig, NextActivityChooserTypeName = "FieldComparisonActivityChooser", WorkflowActivityKey = "B3", OwnerUserName = "******", JustificationNeeded = false, AllowDocumentEdit = false, RouteValueByName = new Dictionary <string, object>(), EmailTemplateId = 1, ExpectedDateForCompletionEditable = false, ExpectedDateForCompletionNeeded = false, ExpectedDateAlwaysShow = true, QuestionChoices = new WorkflowQuestionChoices { QuestionLabel = "Do you Concur?", DefaultJustificationEnums = allJustificationEnumsList, Choices = new List <QuestionChoice>() { new QuestionChoice() { Text = "Yes", Value = "Concur" }, new QuestionChoice() { Text = "No", Value = "Not Concur" } } } }, new WebActionWorkflowActivity { ActionName = "Index", ActivityName = "Deobligate", SequenceNumber = 3, ControllerName = "Ulo", NextActivityChooserConfig = regionNextActivityConfig, NextActivityChooserTypeName = "FieldComparisonActivityChooser", WorkflowActivityKey = "B4", OwnerUserName = "******", JustificationNeeded = false, AllowDocumentEdit = false, RouteValueByName = new Dictionary <string, object>(), EmailTemplateId = 1, ExpectedDateForCompletionEditable = false, ExpectedDateForCompletionNeeded = false, ExpectedDateAlwaysShow = true, QuestionChoices = new WorkflowQuestionChoices { QuestionLabel = "Has this been Deobligated?", DefaultJustificationEnums = allJustificationEnumsList, Choices = new List <QuestionChoice>() { new QuestionChoice() { Text = "Yes", Value = "Deobligated" }, new QuestionChoice() { Text = "No", Value = "Not Deobligated" } } } } }; List <WebActionWorkflowActivity> wfDActivities = new List <WebActionWorkflowActivity>() { new WebActionWorkflowActivity { ActionName = "Index", ActivityName = "Region Review", SequenceNumber = 1, ControllerName = "Ulo", DueIn = new TimeSpan(20, 0, 0, 0), NextActivityChooserConfig = nextActivityConfig, NextActivityChooserTypeName = "FieldComparisonActivityChooser", WorkflowActivityKey = "B1", OwnerUserName = "******", JustificationNeeded = true, AllowDocumentEdit = true, RouteValueByName = new Dictionary <string, object>(), EmailTemplateId = 1, ExpectedDateForCompletionEditable = true, ExpectedDateForCompletionNeeded = true, ExpectedDateAlwaysShow = false, QuestionChoices = new WorkflowQuestionChoices { QuestionLabel = "Is this Valid?", DefaultJustificationEnums = null, Choices = new List <QuestionChoice>() { new QuestionChoice() { Text = "Yes", Value = "Valid", JustificationsEnums = yesJustificationEnums }, new QuestionChoice() { Text = "No", Value = "Invalid", JustificationsEnums = noJustificationEnums } } } }, new WebActionWorkflowActivity { ActionName = "Index", ActivityName = "Region Approval", SequenceNumber = 2, ControllerName = "Ulo", NextActivityChooserConfig = nextActivityConfig, NextActivityChooserTypeName = "FieldComparisonActivityChooser", WorkflowActivityKey = "B2", OwnerUserName = "******", JustificationNeeded = true, AllowDocumentEdit = true, RouteValueByName = new Dictionary <string, object>(), EmailTemplateId = 1, ExpectedDateForCompletionEditable = true, ExpectedDateForCompletionNeeded = true, ExpectedDateAlwaysShow = false, QuestionChoices = new WorkflowQuestionChoices { QuestionLabel = "Do you Approve?", DefaultJustificationEnums = allJustificationEnumsList, Choices = new List <QuestionChoice>() { new QuestionChoice() { Text = "Yes", Value = "Approve" }, new QuestionChoice() { Text = "No", Value = "Disapprove" } } } }, new WebActionWorkflowActivity { ActionName = "Index", ActivityName = "CO Review 1", SequenceNumber = 3, ControllerName = "Ulo", NextActivityChooserConfig = nextActivityConfig, NextActivityChooserTypeName = "FieldComparisonActivityChooser", WorkflowActivityKey = "B3", OwnerUserName = "******", AllowDocumentEdit = false, JustificationNeeded = false, RouteValueByName = new Dictionary <string, object>(), EmailTemplateId = 1, ExpectedDateForCompletionEditable = false, ExpectedDateForCompletionNeeded = false, ExpectedDateAlwaysShow = true, QuestionChoices = new WorkflowQuestionChoices { QuestionLabel = "Do you Concur", DefaultJustificationEnums = allJustificationEnumsList, Choices = new List <QuestionChoice>() { new QuestionChoice() { Text = "Yes", Value = "Concur" }, new QuestionChoice() { Text = "No", Value = "Not Concur" } } } }, new WebActionWorkflowActivity { ActionName = "Index", ActivityName = "CO Review 2", SequenceNumber = 4, ControllerName = "Ulo", NextActivityChooserConfig = nextActivityConfig, NextActivityChooserTypeName = "FieldComparisonActivityChooser", WorkflowActivityKey = "B4", OwnerUserName = "******", AllowDocumentEdit = false, JustificationNeeded = false, RouteValueByName = new Dictionary <string, object>(), EmailTemplateId = 1, ExpectedDateForCompletionEditable = false, ExpectedDateForCompletionNeeded = false, ExpectedDateAlwaysShow = true, QuestionChoices = new WorkflowQuestionChoices { QuestionLabel = "Do you Concur", DefaultJustificationEnums = allJustificationEnumsList, Choices = new List <QuestionChoice>() { new QuestionChoice() { Text = "Yes", Value = "Concur" }, new QuestionChoice() { Text = "No", Value = "Not Concur" } } } }, new WebActionWorkflowActivity { ActionName = "Index", ActivityName = "Complete", SequenceNumber = 6, ControllerName = "Ulo", NextActivityChooserConfig = nextActivityConfig, NextActivityChooserTypeName = "FieldComparisonActivityChooser", WorkflowActivityKey = "B5", OwnerUserName = "******", JustificationNeeded = false, AllowDocumentEdit = false, RouteValueByName = new Dictionary <string, object>(), EmailTemplateId = 1, ExpectedDateForCompletionEditable = false, ExpectedDateForCompletionNeeded = false, ExpectedDateAlwaysShow = true, QuestionChoices = new WorkflowQuestionChoices { QuestionLabel = "Do you Concur?", DefaultJustificationEnums = allJustificationEnumsList, Choices = new List <QuestionChoice>() { new QuestionChoice() { Text = "Yes", Value = "Concur" }, new QuestionChoice() { Text = "No", Value = "Not Concur" } } } }, new WebActionWorkflowActivity { ActionName = "Index", ActivityName = "Debobligate", SequenceNumber = 5, ControllerName = "Ulo", NextActivityChooserConfig = nextActivityConfig, NextActivityChooserTypeName = "FieldComparisonActivityChooser", WorkflowActivityKey = "B6", OwnerUserName = "******", JustificationNeeded = false, AllowDocumentEdit = false, RouteValueByName = new Dictionary <string, object>(), EmailTemplateId = 1, ExpectedDateForCompletionEditable = false, ExpectedDateForCompletionNeeded = false, ExpectedDateAlwaysShow = true, QuestionChoices = new WorkflowQuestionChoices { QuestionLabel = "Has this been Deobligated?", DefaultJustificationEnums = allJustificationEnumsList, Choices = new List <QuestionChoice>() { new QuestionChoice() { Text = "Yes", Value = "Deobligated" }, new QuestionChoice() { Text = "No", Value = "Not Deobligated" } } } } }; var d = new WorkflowDescription { InitialActivityKey = "B1", WebActionWorkflowActivities = wfDActivities }; var dRegion = new WorkflowDescription { InitialActivityKey = "B1", WebActionWorkflowActivities = regionWfDActivities }; var serialized = dRegion.ToXml(); var deserialized = WorkflowDescription.DeserializeFromXml(serialized); var xml = dRegion.ToXml(); Trace.WriteLine(xml); Assert.IsInstanceOfType(deserialized, typeof(WorkflowDescription)); }
/// <summary> /// Register the workflow type with Amazon SWF if not already registered. It will use the information from WorkflowDescriptionAttribute. /// </summary> /// <param name="workflowType">Workflow type to be registerd.</param> /// <returns></returns> public async Task RegisterWorkflowAsync(Type workflowType) { Ensure.NotNull(workflowType, nameof(workflowType)); await RegisterWorkflowAsync(WorkflowDescription.FindOn(workflowType)); }
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(); }
public void Invalid_arguments_tests() { Assert.Throws <ArgumentNullException>(() => WorkflowDescription.FindOn(null)); }
public void Throws_exception_when_type_does_not_derive_from_workflow_class() { Assert.Throws <NonWorkflowTypeException>(() => WorkflowDescription.FindOn(typeof(NonWorkflow))); }
public void Throws_exception_version_is_empty() { Assert.Throws <ArgumentException>(() => WorkflowDescription.FindOn <WorkflowWithEmptyVersion>()); }
public void Throws_exception_when_workflow_description_is_not_supplied() { Assert.Throws <WorkflowDescriptionMissingException>(() => WorkflowDescription.FindOn <WorkflowWithoutAttribute>()); }
public static string GenerateData(string currenWorkflowActivityKey) { var nextActivityConfig = JsonConvert.SerializeObject(new FieldComparisonActivityChooser.MySettings { Expressions = new List <FieldComparisonActivityChooser.Expression> { new FieldComparisonActivityChooser.Expression { Code = "wf.CurrentWorkflowActivityKey == \"B2\" && wfQuestion.Answer == \"NotConcur\"", WorkflowActivityKey = "B1" }, new FieldComparisonActivityChooser.Expression { Code = "wf.CurrentWorkflowActivityKey == \"B1\" && wfQuestion.Answer == \"Approve\"", WorkflowActivityKey = "B2" }, new FieldComparisonActivityChooser.Expression { Code = "wf.CurrentWorkflowActivityKey == \"B2\" && wfQuestion.Answer == \"Concur\"", WorkflowActivityKey = "B3" } } }); var yesJustificationEnums = new List <JustificationEnum>() { JustificationEnum.ContractNotComplete, JustificationEnum.ServicePeriodNotExpired, JustificationEnum.ContractorFiledClaim, JustificationEnum.WatingOnRelease, JustificationEnum.NoRecentActivity, JustificationEnum.ValidRecurringContract, JustificationEnum.Other }; var noJustificationEnums = new List <JustificationEnum>() { JustificationEnum.ItemInvalid, JustificationEnum.InvalidRecurringContract, JustificationEnum.Other }; List <WebActionWorkflowActivity> wfDActivities = new List <WebActionWorkflowActivity>() { new WebActionWorkflowActivity { ActionName = "Index", ActivityName = "Region Review", SequenceNumber = 1, ControllerName = "Ulo", NextActivityChooserConfig = nextActivityConfig, NextActivityChooserTypeName = "FieldComparisonActivityChooser", WorkflowActivityKey = "B1", OwnerUserName = "******", RouteValueByName = new Dictionary <string, object>(), EmailTemplateId = 1, QuestionChoices = new WorkflowQuestionChoices { QuestionLabel = "Do you Approve", Choices = new List <QuestionChoice>() { new QuestionChoice() { Value = "Yes", Text = "Yes", JustificationsEnums = yesJustificationEnums }, new QuestionChoice() { Value = "No", Text = "No", JustificationsEnums = noJustificationEnums }, } } }, new WebActionWorkflowActivity { ActionName = "Index", ActivityName = "Region Approval", SequenceNumber = 2, ControllerName = "Ulo", NextActivityChooserConfig = nextActivityConfig, NextActivityChooserTypeName = "FieldComparisonActivityChooser", WorkflowActivityKey = currenWorkflowActivityKey, OwnerUserName = "******", RouteValueByName = new Dictionary <string, object>(), EmailTemplateId = 1, QuestionChoices = new WorkflowQuestionChoices { QuestionLabel = "Do you Concur", Choices = new List <QuestionChoice>() { new QuestionChoice() { Value = "Concur", Text = "Concur", JustificationsEnums = yesJustificationEnums }, new QuestionChoice() { Value = "Don't concur", Text = "Don't Concur", JustificationsEnums = noJustificationEnums }, } } }, new WebActionWorkflowActivity { ActionName = "Index", ActivityName = "CO Review", SequenceNumber = 3, ControllerName = "Ulo", NextActivityChooserConfig = nextActivityConfig, NextActivityChooserTypeName = "FieldComparisonActivityChooser", WorkflowActivityKey = "B3", OwnerUserName = "******", RouteValueByName = new Dictionary <string, object>(), EmailTemplateId = 1, QuestionChoices = new WorkflowQuestionChoices { QuestionLabel = "Do you Concur", Choices = new List <QuestionChoice>() { new QuestionChoice() { Value = "Concur", Text = "Concur", JustificationsEnums = yesJustificationEnums }, new QuestionChoice() { Value = "Don't concur", Text = "Don't Concur", JustificationsEnums = noJustificationEnums }, } } } }; var d = new WorkflowDescription { WebActionWorkflowActivities = wfDActivities }; return(JsonConvert.SerializeObject(d)); }
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(); }