当前位置: 首页>>代码示例>>C#>>正文


C# RuleContext.AddWarningResult方法代码示例

本文整理汇总了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));
                }
            }
        }
开发者ID:mparsin,项目名称:Elements,代码行数:36,代码来源:ChangingFieldRule.cs

示例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));
        }
开发者ID:mparsin,项目名称:Elements,代码行数:51,代码来源:FilterDifinitionShouldByNonAffectedRule.cs

示例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");
        }
开发者ID:mparsin,项目名称:Elements,代码行数:13,代码来源:SampleListSize.cs

示例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);
            }
        }
开发者ID:mparsin,项目名称:Elements,代码行数:31,代码来源:ProcessNameExistsRule.cs


注:本文中的RuleContext.AddWarningResult方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。