本文整理汇总了C#中Workflow类的典型用法代码示例。如果您正苦于以下问题:C# Workflow类的具体用法?C# Workflow怎么用?C# Workflow使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Workflow类属于命名空间,在下文中一共展示了Workflow类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddWorkflowWithConstraint
public void AddWorkflowWithConstraint()
{
var childWorkflow = Workflow<string>.Definition() as IWorkflow<string>;
_parentWorkflow = Workflow<string>.Definition().Do(childWorkflow, If.IsTrue(true)) as Workflow<string>;
_parentWorkflow.RegisteredOperations.Tasks.Count.ShouldBe(1);
}
示例2: ShouldDeserializeComplexWorkflowConfiguration3
public void ShouldDeserializeComplexWorkflowConfiguration3()
{
var workFlow = new Workflow();
workFlow.Configuration = "{\"default_filter\":{\"queue\":\"WQccc\"},\"filters\":[{\"expression\":\"1==1\",\"friendly_name\":\"Prioritizing Filter\",\"targets\":[{\"priority\":\"1\",\"queue\":\"WQccc\",\"timeout\":\"300\"}]}]}";
var workFlowConfiguration = new WorkflowConfiguration();
var filter = new Filter
{
FriendlyName = "Prioritizing Filter",
Expression = "1==1",
Targets = new List<Target>() {
new Target {
Queue="WQccc",
Priority="1",
Timeout="300"
}
}
};
workFlowConfiguration.Filters.Add(filter);
workFlowConfiguration.DefaultFilter = new Target() { Queue = "WQccc" };
var config = workFlow.WorkflowConfiguration;
Assert.AreEqual(workFlowConfiguration.ToString(), config.ToString());
}
示例3: Init
public void Init()
{
_workStepRepository = new MemoryWorkStepRepository();
_workItemRepository = new MemoryWorkItemRepository();
_workflowRepository = new WorkflowRepository(_workItemRepository, _workStepRepository);
_wp = new Workflow(_workflowRepository);
}
示例4: TestMethod1
public void TestMethod1()
{
// Arrange
WorkflowTestTrace.Arrange();
var activity = new FileReadToEnd() { FileName = Constants.Workflow1Xaml };
var tracking = new ListTrackingParticipant();
var workflow = new Workflow(activity) { Tracking = tracking };
try
{
// Act
WorkflowTestTrace.Act();
var result = workflow.Start().Result.Output.Result;
// Assert
WorkflowTestTrace.Assert();
Assert.AreEqual(2113, result.Length);
}
finally
{
WorkflowTestTrace.Finally();
workflow.Trace();
}
}
示例5: TestSavePerson
public void TestSavePerson()
{
var workflow = new Workflow();
var person = new Person();
Assert.IsTrue(workflow.SavePerson(new Person() { Name = "Kevin", Age = 26 }));
}
示例6: Process
/// <summary>
/// Processes the specified <see cref="Rock.Model.Workflow" />
/// </summary>
/// <param name="workflow">The <see cref="Rock.Model.Workflow" /> instance to process.</param>
/// <param name="errorMessages">A <see cref="System.Collections.Generic.List{String}" /> that contains any error messages that were returned while processing the <see cref="Rock.Model.Workflow" />.</param>
public void Process( Workflow workflow, out List<string> errorMessages )
{
workflow.IsProcessing = true;
this.Context.SaveChanges();
var rockContext = (RockContext)this.Context;
workflow.LoadAttributes( rockContext );
workflow.Process( rockContext, out errorMessages );
if ( workflow.IsPersisted )
{
this.Context.WrapTransaction( () =>
{
this.Context.SaveChanges();
workflow.SaveAttributeValues( rockContext );
foreach ( var activity in workflow.Activities )
{
activity.SaveAttributeValues( rockContext );
}
} );
workflow.IsProcessing = false;
this.Context.SaveChanges();
}
}
示例7: Process
/// <summary>
/// Processes the specified <see cref="Rock.Model.Workflow" />
/// </summary>
/// <param name="workflow">The <see cref="Rock.Model.Workflow" /> instance to process.</param>
/// <param name="entity">The entity.</param>
/// <param name="errorMessages">A <see cref="System.Collections.Generic.List{String}" /> that contains any error messages that were returned while processing the <see cref="Rock.Model.Workflow" />.</param>
/// <returns></returns>
public bool Process( Workflow workflow, object entity, out List<string> errorMessages )
{
var rockContext = (RockContext)this.Context;
if ( workflow.IsPersisted )
{
workflow.IsProcessing = true;
rockContext.SaveChanges();
}
bool result = workflow.ProcessActivities( rockContext, entity, out errorMessages );
if ( workflow.IsPersisted || workflow.WorkflowType.IsPersisted )
{
if ( workflow.Id == 0 )
{
Add( workflow );
}
rockContext.WrapTransaction( () =>
{
rockContext.SaveChanges();
workflow.SaveAttributeValues( rockContext );
foreach ( var activity in workflow.Activities )
{
activity.SaveAttributeValues( rockContext );
}
} );
workflow.IsProcessing = false;
rockContext.SaveChanges();
}
return result;
}
示例8: CheckDataAndCodeIfExist
public bool CheckDataAndCodeIfExist(Workflow entity)
{
if (CheckDataIfExists(entity) || CheckDataIfExists(entity.Code))
{
return true;
}
return false;
}
示例9: GetCurrentApproverByWorkflowAndLevel
public WorkflowMapping GetCurrentApproverByWorkflowAndLevel(Workflow workflow, int level)
{
Dictionary<string, object> parameter = new Dictionary<string, object>();
parameter.Add("Workflow", workflow);
parameter.Add("LevelId", level);
WorkflowMapping workflowMapping = this.workflowMappingRepository.GetFilteredData(parameter).FirstOrDefault();
return workflowMapping;
}
示例10: ShouldCheckIfConstraintIsNull
public void ShouldCheckIfConstraintIsNull()
{
ICheckConstraint expression = null;
_pipe = new Workflow<string>();
var method = new Func<string, string>((s) => { return "result"; });
Assert.Throws<ArgumentNullException>(() => _pipe.Do(method, expression), "Exception not thrown");
}
示例11: ShouldRepeatOperation
public void ShouldRepeatOperation()
{
IWorkflow<Colour> workflow = new Workflow<Colour>();
workflow.Do<DuplicateName>().Repeat().Twice();
var result = workflow.Start(new Colour("Red"));
result.Name.ShouldBe("RedRedRedRedRedRedRedRed");
}
示例12: TestFindAllPeople
public void TestFindAllPeople()
{
var workflow = new Workflow();
workflow.SavePerson(new Person() { Name = "Bubba" });
Assert.AreNotEqual(0, workflow.FindAllPeople().Count);
}
示例13: Freeze
public Freeze(Workflow p, IntPtr windowHandle)
{
if (p.ActiveWindowGDIFreezeWindow)
{
NativeMethods.GetWindowThreadProcessId(windowHandle, out processId);
FreezeThreads((int)processId);
}
}
示例14: TestRemovedPersonsShouldNoLongerBeFindable
public void TestRemovedPersonsShouldNoLongerBeFindable()
{
var workflow = new Workflow();
workflow.SavePerson(new Person() { Name = "Levi"});
workflow.RemovePerson("Levi");
Assert.IsNull(workflow.FindPerson("Levi"));
}
示例15: Archive
/// <summary>
/// Archives a workflow, moving it into the completed store.
/// </summary>
/// <param name="workflow">The workflow to archive.</param>
public override void Archive(Workflow workflow)
{
var coll = GetCollection();
coll.Remove(_queryById(workflow.Id));
var collCompleted = GetCompletedCollection();
collCompleted.Insert(new CompletedWorkflow(workflow));
}