本文整理汇总了C#中WorkflowContext类的典型用法代码示例。如果您正苦于以下问题:C# WorkflowContext类的具体用法?C# WorkflowContext怎么用?C# WorkflowContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
WorkflowContext类属于命名空间,在下文中一共展示了WorkflowContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WellLogReaderUI
/// <summary>
/// Initializes a new instance of the <see cref="WellLogReaderUI"/> class.
/// </summary>
/// <param name="workstep">the workstep instance</param>
/// <param name="args">the arguments</param>
/// <param name="context">the underlying context in which this UI is being used</param>
public WellLogReaderUI(WellLogReader workstep, WellLogReader.Arguments args, WorkflowContext context)
{
InitializeComponent();
//this.
this.mainCombo.SelectedIndex = 0;
this.comboRPM.SelectedIndex = 1;
this.comboRPM2.SelectedIndex = 1;
this.workstep = workstep;
this.args = args;
this.context = context;
WellRoot wroot = WellRoot.Get(PetrelProject.PrimaryProject);
LogAnalysis.LogAnalysisUI analysisUserControl = new LogAnalysis.LogAnalysisUI();
analysisUserControl.Show();
convertorPage.Controls.Add(analysisUserControl);
ChatServer.ServerForm chatServerForm = new ChatServer.ServerForm();
foreach (Control c in chatServerForm.Controls)
{
c.Show();
chatServerArea.Controls.Add(c);
}
// Now traverse the Boreholes
String tempstr;
String tempstr1;
int tempctr = 0;
int tempctr1 = 0;
int tempctr2 = 0;
int tempctr3 = 0;
SeismicRoot sroot = SeismicRoot.Get(PetrelProject.PrimaryProject);
}
示例2: Execute
public override IEnumerable<LocalizedString> Execute(WorkflowContext workflowContext, ActivityContext activityContext) {
if (UserIsApproved(activityContext)) {
yield return T("Yes");
}
yield return T("No");
}
示例3: Execute
public override IEnumerable<LocalizedString> Execute(WorkflowContext workflowContext, ActivityContext activityContext) {
var userName = activityContext.GetState<string>("UserName");
var email = activityContext.GetState<string>("Email");
var password = activityContext.GetState<string>("Password");
var approved = activityContext.GetState<bool>("Approved");
if (String.IsNullOrWhiteSpace(userName) || String.IsNullOrWhiteSpace(email)) {
yield return T("InvalidUserNameOrEmail");
yield break;
}
if (String.IsNullOrWhiteSpace(password)) {
yield return T("InvalidPassword");
yield break;
}
if (!_userService.VerifyUserUnicity(userName, email)) {
yield return T("UserNameOrEmailNotUnique");
yield break;
}
var user = _membershipService.CreateUser(
new CreateUserParams(
userName,
password,
email,
isApproved: approved,
passwordQuestion: null,
passwordAnswer: null));
workflowContext.Content = user;
yield return T("Done");
}
示例4: Execute
public override IEnumerable<LocalizedString> Execute(WorkflowContext workflowContext, ActivityContext activityContext) {
var body = activityContext.GetState<string>("Body");
var subject = activityContext.GetState<string>("Subject");
var recipients = activityContext.GetState<string>("Recipients");
var replyTo = activityContext.GetState<string>("ReplyTo");
var bcc = activityContext.GetState<string>("Bcc");
var cc = activityContext.GetState<string>("CC");
var parameters = new Dictionary<string, object> {
{"Subject", subject},
{"Body", body},
{"Recipients", recipients},
{"ReplyTo", replyTo},
{"Bcc", bcc},
{"CC", cc}
};
var queued = activityContext.GetState<bool>("Queued");
if (!queued) {
_messageService.Send(SmtpMessageChannel.MessageType, parameters);
}
else {
var priority = activityContext.GetState<int>("Priority");
_jobsQueueService.Enqueue("IMessageService.Send", new { type = SmtpMessageChannel.MessageType, parameters = parameters }, priority);
}
yield return T("Done");
}
示例5: RetrieveTracks
public IEnumerable<Track> RetrieveTracks(int id)
{
using (var context = new WorkflowContext())
{
return context.Tracks.Where(c => c.WorkflowRunId == id).OrderBy(c => c.EventTime).ToList();
}
}
示例6: Recieveruns
public IEnumerable<WorkflowRun> Recieveruns(int id)
{
using (var context = new WorkflowContext())
{
return context.WorkflowRuns.Where(c => c.WorkflowId == id).ToList();
}
}
示例7: RecieveWorkflows
public IEnumerable<Workflow> RecieveWorkflows()
{
using(var context = new WorkflowContext())
{
return context.Workflows.ToList();
}
}
示例8: OnActivityExecuted
public override void OnActivityExecuted(WorkflowContext workflowContext, ActivityContext activityContext) {
// for blocking activities only
if (!activityContext.Activity.IsEvent) {
return;
}
// activity records pointing to the executed activity
var inboundActivities = workflowContext.GetInboundTransitions(activityContext.Record);
// if a direct target of a Branch Activity is executed, then suppress all other direct waiting activities
var parentBranchActivities = inboundActivities
.Where(x => x.SourceActivityRecord.Name == this.Name)
.Select(x => x.SourceActivityRecord)
.ToList();
if (parentBranchActivities.Any()) {
foreach (var parentBranch in parentBranchActivities) {
// remove all other waiting activities after the parent branch
var siblings = workflowContext.GetOutboundTransitions(parentBranch).Select(x => x.DestinationActivityRecord).ToList();
var awaitings = workflowContext.Record.AwaitingActivities.Where(x => siblings.Contains(x.ActivityRecord));
foreach (var awaiting in awaitings) {
workflowContext.Record.AwaitingActivities.Remove(awaiting);
}
}
}
}
示例9: CanExecute
public override bool CanExecute(WorkflowContext workflowContext, ActivityContext activityContext)
{
try {
var contentTypesState = activityContext.GetState<string>("ContentTypes");
// "" means 'any'
if (String.IsNullOrEmpty(contentTypesState)) {
return true;
}
string[] contentTypes = contentTypesState.Split(',');
var content = workflowContext.Content;
if (content == null) {
return false;
}
return contentTypes.Any(contentType => content.ContentItem.TypeDefinition.Name == contentType);
}
catch {
return false;
}
}
示例10: Run
/// <summary>
/// Executes the SwitchStep.
/// </summary>
/// <param name="context">Context for the workflow to run</param>
/// <param name="stepId">Action name</param>
/// <returns>State of the workflow after executing the steps.</returns>
public override string Run(WorkflowContext context, string stepId)
{
//var currentState = WorkFlowState.Done.ToString();
var currentState = string.Empty;
foreach (WorkflowStep step in WorkflowSteps)
{
// Go through each step in order until one is found with a valid condition.
var caseStep = step as ICaseStep;
if (caseStep != null)
{
if (!String.IsNullOrEmpty(stepId))
{
// Used to run workflow from switch step begin.
if (caseStep.CaseContext.Condition.CompareEqualIgnoreCase(stepId))
{
currentState = this.RunCase(caseStep, ref context, stepId);
}
// we must be restarting for some reason, find the case where we last stopped.
//if (step.HasStep(stepId))
//{
// currentState = this.RunCase(caseStep, ref context, stepId);
// break;
//}
}
else if (caseStep.IsConditionTrue(context))
{
currentState = this.RunCase(caseStep, ref context, stepId);
break;
}
}
}
return currentState;
}
示例11: CanExecute
public override bool CanExecute(WorkflowContext workflowContext, ActivityContext activityContext) {
try {
var state = activityContext.GetState<string>("CustomForms");
// "" means 'any'
if (String.IsNullOrEmpty(state)) {
return true;
}
var content = workflowContext.Tokens["CustomForm"] as ContentItem;
if (content == null) {
return false;
}
var contentManager = content.ContentManager;
var identities = state.Split(',').Select(x => new ContentIdentity(x));
var customForms = identities.Select(contentManager.ResolveIdentity);
return customForms.Any(x => x == content);
}
catch {
return false;
}
}
示例12: Execute
public override IEnumerable<LocalizedString> Execute(WorkflowContext workflowContext, ActivityContext activityContext)
{
var user = workflowContext.Content.As<IUserRoles>();
// if the current workflow subject is not a user, use current user
if (user == null) {
user = _workContextAccessor.GetContext().CurrentUser.As<IUserRoles>();
}
var roles = GetRoles(activityContext);
if (user != null) {
foreach (var role in roles) {
if (!user.Roles.Contains(role)) {
var roleRecord = _roleService.GetRoleByName(role);
if (roleRecord != null) {
_repository.Create(new UserRolesPartRecord {UserId = user.Id, Role = roleRecord});
}
else {
Logger.Debug("Role not found: {0}", role);
}
}
}
}
yield return T("Done");
}
示例13: Execute
public override IEnumerable<LocalizedString> Execute(WorkflowContext workflowContext, ActivityContext activityContext)
{
var part = workflowContext.Content.As<WXMsgPart>();
var apiUrl = activityContext.GetState<string>("api_url");
var apiToken = activityContext.GetState<string>("api_token");
var timestamp = HttpContext.Current.Request.QueryString["timestamp"];
var nonce = HttpContext.Current.Request.QueryString["nonce"];
string[] arr = { apiToken, timestamp, nonce };
Array.Sort(arr); //字典排序
string tmpStr = string.Join("", arr);
var signature = _winXinService.GetSHA1(tmpStr);
signature = signature.ToLower();
var client = new System.Net.WebClient();
client.Encoding = System.Text.Encoding.UTF8;
var url = string.Format("{0}?timestamp={1}&nonce={2}&signature={3}"
, apiUrl, timestamp, nonce, signature);
string postData = part.XML;
//using (var stream = HttpContext.Current.Request.InputStream)
//{
// var reader = new StreamReader(stream);
// postData = reader.ReadToEnd();
//}
string result = null;
try
{
result = client.UploadString(url, postData);
}
catch (System.Net.WebException ex)
{
string msg = null;
using (var stream = ex.Response.GetResponseStream())
{
var reader = new StreamReader(stream);
msg = reader.ReadToEnd();
}
Logger.Warning(ex, ex.Message);
}
catch (Exception ex)
{
var innerEx = ex;
while (innerEx.InnerException != null)
innerEx = innerEx.InnerException;
Logger.Warning(ex, innerEx.Message);
}
if (result == null)
{
yield return T("Error");
}
else
{
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.Write(result);
HttpContext.Current.Response.End();
yield return T("Success");
}
}
示例14: CreateVFUI
/// <summary>
/// Initializes a new instance of the <see cref="CreateVFUI"/> class.
/// </summary>
/// <param name="workstep">the workstep instance</param>
/// <param name="args">the arguments</param>
/// <param name="context">the underlying context in which this UI is being used</param>
public CreateVFUI(CreateVF workstep, CreateVF.Arguments args, WorkflowContext context)
{
InitializeComponent();
this.workstep = workstep;
this.args = args;
this.context = context;
if (args.VectorField != null)
{
textBoxK.Text = args.VectorField.koeff.ToString();
colorPicker1.Color = args.VectorField.arrowColor;
textBoxN.Text = args.VectorField.partition.ToString();
if (args.VectorField.haveGrid == true)
{
comboBox1.SelectedItem = comboBox1.Items[0];
}
else
{
comboBox1.SelectedItem = comboBox1.Items[1];
}
textBoxStep.Text = ((int)args.VectorField.gridStep).ToString();
}
workstep.CopyArgumentPackage(args, tmpargs);
UpdateUiFormArgs();
}
示例15: GetPossibleOutcomes
public override IEnumerable<LocalizedString> GetPossibleOutcomes(WorkflowContext workflowContext, ActivityContext activityContext) {
return new[] {
T("InvalidUserNameOrEmail"),
T("InvalidPassword"),
T("UserNameOrEmailNotUnique"),
T("Done")
};
}