本文整理汇总了C#中RuleContext.AddOutValue方法的典型用法代码示例。如果您正苦于以下问题:C# RuleContext.AddOutValue方法的具体用法?C# RuleContext.AddOutValue怎么用?C# RuleContext.AddOutValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RuleContext
的用法示例。
在下文中一共展示了RuleContext.AddOutValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Execute
protected override void Execute(RuleContext context)
{
//modify property value, to upper
var val1 = (string)context.InputPropertyValues[PrimaryProperty];
if (!string.IsNullOrEmpty(val1))
context.AddOutValue(PrimaryProperty, val1.ToUpper());
}
示例2: Execute
protected override void Execute(RuleContext context)
{
var activityIdValue = (int)context.InputPropertyValues[PrimaryProperty];
var activityStatusProperty = this.InputProperties.Single(p => p.Name == this.StatusName);
var activtyStatusValue = (ActivitySubmissionStatus)context.InputPropertyValues[activityStatusProperty];
var approvedByIdProperty = this.InputProperties.Single(p => p.Name == this.ApprovedByIdName);
var approvedByIdValue = (ActivitySubmissionStatus)context.InputPropertyValues[approvedByIdProperty];
if (approvedByIdValue == 0
&& (activtyStatusValue == ActivitySubmissionStatus.Unset
|| activtyStatusValue == ActivitySubmissionStatus.AwaitingApproval
|| activtyStatusValue == ActivitySubmissionStatus.Approved))
{
try
{
var activityTask = Task.Run(() => IoC.Container.Resolve<IObjectFactory<IActivityEdit>>().FetchAsync(activityIdValue));
var activity = activityTask.Result;
context.AddOutValue(activityStatusProperty,
activity.RequiresApproval
? ActivitySubmissionStatus.AwaitingApproval
: ActivitySubmissionStatus.Approved);
}
catch (Exception)
{
context.AddErrorResult(PrimaryProperty,
string.Format(CultureInfo.CurrentCulture, "Activity id {0} was not able to be retrieved.", activityIdValue));
}
}
}
示例3: Execute
protected override void Execute(RuleContext context)
{
// Use linq Sum to calculate the sum value
var sum = context.InputPropertyValues.Sum(property => (dynamic)property.Value);
// add calculated value to OutValues
// When rule is completed the RuleEngig will update businessobject
context.AddOutValue(PrimaryProperty, sum);
}
示例4: Execute
/// <summary>
/// The execute.
/// </summary>
/// <param name="context">
/// The context.
/// </param>
protected override void Execute(RuleContext context)
{
var id = (int) context.InputPropertyValues[PrimaryProperty];
// use a command or read-only object for lookup
var lookup = LookupCustomerCommand.Execute(id);
context.AddOutValue(NameProperty, lookup.Name);
}
示例5: Execute
/// <summary>
/// Business rule implementation.
/// </summary>
/// <param name="context">Rule context object.</param>
protected override void Execute(RuleContext context)
{
var value = (string) context.InputPropertyValues[PrimaryProperty];
if (string.IsNullOrEmpty(value)) return;
var newValue = value.Trim();
var r = new Regex(@"\s+");
newValue = r.Replace(newValue, @" ");
context.AddOutValue(PrimaryProperty, newValue);
}
示例6: Execute
/// <summary>
/// The execute.
/// </summary>
/// <param name="context">
/// The context.
/// </param>
protected override void Execute(RuleContext context)
{
var value = (string) context.InputPropertyValues[PrimaryProperty];
context.AddOutValue(PrimaryProperty, value.ToUpper());
if (context.IsCheckRulesContext)
Console.WriteLine(".... Rule {0} running from CheckRules", this.GetType().Name);
else
Console.WriteLine(".... Rule {0} running from {1} was changed", this.GetType().Name, this.PrimaryProperty.Name);
}
示例7: Execute
/// <summary>
/// Business or validation rule implementation.
/// </summary>
/// <param name="context">Rule context object.</param>
protected override void Execute(RuleContext context)
{
if (context == null)
return;
var input = context.InputPropertyValues[PrimaryProperty] as int?;
if (input.HasValue && input.Value <= 0)
context.AddOutValue(null);
}
示例8: Execute
/// <summary>
/// Rule implementation.
/// </summary>
/// <param name="context">Rule context.</param>
protected override void Execute(RuleContext context)
{
var valueAsString = (string) context.InputPropertyValues[PrimaryProperty];
if (valueAsString != null && valueAsString.IsNotEmpty())
{
if (!valueAsString.IsUpper())
{
context.AddOutValue(PrimaryProperty, valueAsString.ToUpper());
}
}
}
示例9: Execute
/// <summary>
/// Business or validation rule implementation.
/// </summary>
/// <param name="context">
/// Rule context object.
/// </param>
protected override void Execute(RuleContext context)
{
var value = (string)context.InputPropertyValues[PrimaryProperty];
if (string.IsNullOrEmpty(value)) return;
var newValue = value.Trim(' ');
var r = new Regex(@" +");
newValue = r.Replace(newValue, @" ");
context.AddOutValue(newValue);
if (context.IsCheckRulesContext)
Console.WriteLine(".... Rule {0} running from CheckRules", this.GetType().Name);
else
Console.WriteLine(".... Rule {0} running from {1} was changed", this.GetType().Name, this.PrimaryProperty.Name);
}
示例10: Execute
protected override void Execute(RuleContext context)
{
var badgeTypeValue = (BadgeType)context.InputPropertyValues[PrimaryProperty];
var badgeStatusProperty = this.InputProperties.Single(p => p.Name == this.StatusName);
var badgeStatusValue = (BadgeStatus)context.InputPropertyValues[badgeStatusProperty];
var approvedByIdProperty = this.InputProperties.Single(p => p.Name == this.ApprovedByIdName);
var approvedByIdValue = (int)context.InputPropertyValues[approvedByIdProperty];
if (approvedByIdValue == 0 && (badgeStatusValue == BadgeStatus.AwaitingApproval
|| badgeStatusValue == BadgeStatus.Approved || badgeStatusValue == BadgeStatus.Unset))
{
context.AddOutValue(badgeStatusProperty,
badgeTypeValue == BadgeType.Community ? BadgeStatus.AwaitingApproval : BadgeStatus.Approved);
}
}
示例11: Execute
protected override void Execute(RuleContext context)
{
var dateProperty = this.InputProperties[0];
var value = context.InputPropertyValues[dateProperty];
if (value != null)
{
if (typeof(DateTime?).GetTypeInfo().IsAssignableFrom(value.GetType().GetTypeInfo()))
{
var nullableDate = value as DateTime?;
if (nullableDate != null)
{
context.AddOutValue(dateProperty, nullableDate.Value.ToUniversalTime());
}
}
else if (typeof(DateTime).GetTypeInfo().IsAssignableFrom(value.GetType().GetTypeInfo()))
{
var date = (DateTime)context.InputPropertyValues[dateProperty];
context.AddOutValue(dateProperty, date.ToUniversalTime());
}
}
}
示例12: Execute
protected override void Execute(RuleContext context)
{
var pollEndDateProperty = this.InputProperties[0];
var isActiveProperty = this.InputProperties[1];
var pollEndDate = (DateTime)context.InputPropertyValues[pollEndDateProperty];
var isActive = (bool)context.InputPropertyValues[isActiveProperty];
var now = DateTime.UtcNow;
if (pollEndDate < now)
{
context.AddErrorResult(pollEndDateProperty, "The poll has ended.");
context.AddOutValue(isActiveProperty, false);
}
}
示例13: Execute
/// <summary>
/// Business or validation rule implementation.
/// </summary>
/// <param name="context">
/// Rule context object.
/// </param>
protected override void Execute(RuleContext context)
{
// Use linq Sum to calculate the sum value
var sum = context.InputPropertyValues.Sum(property => (dynamic)property.Value);
// add calculated value to OutValues
// When rule is completed the RuleEngine will update businessobject
context.AddOutValue(PrimaryProperty, sum);
if (context.IsCascadeContext)
Console.WriteLine(".... Rule {0} running from affected property or input property", this.GetType().Name);
else if (context.IsCheckRulesContext)
Console.WriteLine(".... Rule {0} running from CheckRules", this.GetType().Name);
else
Console.WriteLine(".... Rule {0} running from {2} was changed", this.GetType().Name, this.PrimaryProperty.Name);
}
示例14: Execute
/// <summary>
/// The execute.
/// </summary>
/// <param name="context">
/// The context.
/// </param>
protected override void Execute(RuleContext context)
{
var id = (int) context.InputPropertyValues[PrimaryProperty];
// uses the async methods in DataPortal to perform data access on a background thread.
LookupCustomerCommand.BeginExecute(id, (o, e) =>
{
if (e.Error != null)
{
context.AddErrorResult(e.Error.ToString());
}
else
{
context.AddOutValue(NameProperty, e.Object.Name);
}
context.Complete();
});
}
示例15: Execute
/// <summary>
/// Look up State and set the state name
/// </summary>
/// <param name="context">Rule context object.</param>
protected override void Execute(RuleContext context)
{
var stateId = (string)context.InputPropertyValues[PrimaryProperty];
var state = StatesNVL.GetNameValueList().Where(p => p.Key == stateId).FirstOrDefault();
context.AddOutValue(StateName, state == null ? "Unknown state" : state.Value);
}