本文整理汇总了C#中RuleContext.AddWarningResult方法的典型用法代码示例。如果您正苦于以下问题:C# RuleContext.AddWarningResult方法的具体用法?C# RuleContext.AddWarningResult怎么用?C# RuleContext.AddWarningResult使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RuleContext
的用法示例。
在下文中一共展示了RuleContext.AddWarningResult方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Execute
/// <summary>
/// Business or validation rule implementation.
/// </summary>
/// <param name="context">Rule context object.</param>
protected override void Execute(RuleContext context)
{
var target = (FieldGenericStepEdit)context.Target;
if (!target.IsNew)
{
var originalFieldType = (FieldTypeInfo)context.InputPropertyValues[FieldGenericStepEdit.OriginalFieldTypeProperty];
var newFieldType = (FieldTypeInfo)context.InputPropertyValues[PrimaryProperty];
//if process published already and current type is changed then check for data loss
if (originalFieldType.ColumnType != newFieldType.ColumnType)
{
// no data loss should be
if (newFieldType.ColumnType == ColumnTypes.String &&
(originalFieldType.ColumnType.IsValueType() ||
originalFieldType.ColumnType == ColumnTypes.DateTime))
return;
if ((originalFieldType.ColumnType == ColumnTypes.Reference &&
newFieldType.ColumnType == ColumnTypes.MultiReference) ||
(originalFieldType.ColumnType == ColumnTypes.MultiReference &&
newFieldType.ColumnType == ColumnTypes.Reference) ||
(originalFieldType.ColumnType == ColumnTypes.ReverseReference &&
newFieldType.ColumnType == ColumnTypes.ReverseMultiReference) ||
(originalFieldType.ColumnType == ColumnTypes.ReverseMultiReference &&
newFieldType.ColumnType == ColumnTypes.ReverseReference))
return;
context.AddWarningResult(PrimaryProperty, string.Format("Existing data in \"{0}\" fields will be lost during conversion.", target.Name));
}
}
}
示例2: Execute
/// <summary>
/// Business or validation rule implementation.
/// </summary>
/// <param name="context">Rule context object.</param>
protected override void Execute(RuleContext context)
{
string definition = null;
if (context.Target is CrossRefOptionsStepEdit)
definition = context.InputPropertyValues[CrossRefOptionsStepEdit.FilterDefinitionProperty] as string;
else if (context.Target is ChecklistSettingsStepEdit)
definition = context.InputPropertyValues[ChecklistSettingsStepEdit.FilterDefinitionProperty] as string;
else if (context.Target is DisplayListRequiredStepEdit)
definition = context.InputPropertyValues[DisplayListRequiredStepEdit.FilterDefinitionProperty] as string;
if (string.IsNullOrWhiteSpace((string)definition))
return;
var message = LanguageService.Translate("Rule_OutdatedFilterDifinition");
var regenerateMessage = LanguageService.Translate("Rule_OutdatedFormatFilterDifinition");
string fieldName = null;
var fieldtarget = context.Target as BusinessBase;
var fieldEdit = fieldtarget.GetParent<FieldEdit>();
if (fieldEdit != null)
fieldName = fieldEdit.Name;
var target = context.Target as BusinessBase;
var process = target.GetParent<ProcessEdit>();
if (process == null)
return;
var filter = FilterDescriptor.FromJSON((string)definition);
if (filter.Value == null && filter.FilterGuid == Guid.Empty)
return;
if (filter.IsLastVersion() && process.CurrentFilterDifinitionList.Any(x => x.FilterGuid == filter.FilterGuid.ToString()))
{
var currentFilter = process.CurrentFilterDifinitionList.FirstOrDefault(x => x.FilterGuid == filter.FilterGuid.ToString());
if (currentFilter != null)
if (filter.TimeStamp != FilterDescriptor.FromJSON(currentFilter.FilterDefinition).TimeStamp)
context.AddErrorResult(string.Format(message, fieldName));
}
else if (filter.IsLastVersion() && filter.FilterGuid == Guid.Empty)
context.AddWarningResult(string.Format(regenerateMessage, fieldName));
else if (!filter.IsLastVersion())
context.AddWarningResult(string.Format(message, fieldName));
}
示例3: Execute
/// <summary>
/// Business or validation rule implementation.
/// </summary>
/// <param name="context">Rule context object.</param>
protected override void Execute(RuleContext context)
{
if (context == null)
throw new ArgumentNullException("context");
var list = context.InputPropertyValues[PrimaryProperty] as ISampleList;
if (list != null && list.Count > 500)
context.AddWarningResult(PrimaryProperty, "Sample size must be between 0 and 500");
}
示例4: Execute
/// <summary>
/// Executes the business rule.
/// </summary>
/// <param name="context">The rule context.</param>
protected override void Execute(RuleContext context)
#endif
{
Initialize();
try
{
var name = context.InputPropertyValues[PrimaryProperty] as string;
if (string.IsNullOrEmpty(name))
return;
var processGuid = (Guid)context.InputPropertyValues[ProcessEdit.GuidProperty];
#if SILVERLIGHT
var nameExists = await Validator.ExecuteAsync(name, processGuid);
#else
var nameExists = Validator.Execute(name, processGuid);
#endif
if (nameExists)
context.AddWarningResult(LanguageService.Translate("Rule_UniqueProcessName"));
}
catch (Exception ex)
{
context.AddErrorResult(ex.Message);
}
}