/// <summary>
        /// Business or validation rule implementation.
        /// </summary>
        /// <param name="context">Rule context object.</param>
        protected override void Execute(RuleContext context)
        {
            var sections = (ProcessSections)context.InputPropertyValues[ProcessEdit.SectionListProperty];
            if (sections == null || sections.Count == 0)
                return;

            if ((bool)context.InputPropertyValues[ProcessEdit.IsSystemProperty])
                return;

            var layoutList = (IProcessLayoutList)context.InputPropertyValues[PrimaryProperty];

            var defaultLayout = layoutList.GetDefaultLayout();
            if (defaultLayout == null)
                context.AddErrorResult(LanguageService.Translate("Rule_ProcessDefaultLayout"));

            foreach (var layout in layoutList)
            {
                if (string.IsNullOrEmpty(layout.Name))
                    context.AddErrorResult(PrimaryProperty, LanguageService.Translate("Rule_ProcessLayoutName"));
                if (string.IsNullOrEmpty(layout.LayoutInfo))
                    context.AddErrorResult(PrimaryProperty, LanguageService.Translate("Rule_ProcessSearchMustHaveAtLeastOneField"));
            }

            context.Complete();
        }
        /// <summary>
        /// Business or validation rule implementation.
        /// </summary>
        /// <param name="context">Rule context object.</param>
        protected override void Execute(RuleContext context)
        {
            var sections = (ProcessSections)context.InputPropertyValues[PrimaryProperty];

            if (sections == null || sections.Count == 0)
                return;

            //ignore parent
            var localSections = sections.Where(s => !s.IsBase).ToList();

            //duplicate section name check
            var duplicateSections = localSections.Where(x => localSections.Count(y => y.Name == x.Name) > 1);
            foreach (var section in duplicateSections)
                context.AddErrorResult(string.Format(LanguageService.Translate("Rule_UniqueSectionName"), section.Name));

            //duplicate field's system name check
            var fields = new Dictionary<string, string>();
            foreach (var section in sections.Where(s => s.FieldList != null))
                foreach (var field in section.FieldList.Where(f => !string.IsNullOrEmpty(f.SystemName)))
                    if (fields.Keys.Any(key => key.ToUpperInvariant().Equals(field.SystemName.ToUpperInvariant())))
                    {
                        var duplicate = fields.First(f => f.Key.Equals(field.SystemName, StringComparison.OrdinalIgnoreCase));
                        context.AddErrorResult(string.Format(LanguageService.Translate("Rule_UniqueFieldSystemNames"), field.SystemName, section.Name, duplicate.Value));
                    }
                    else
                        fields.Add(field.SystemName, section.Name);
        }
Пример #3
0
        protected override void Execute(RuleContext context)
        {
            var customerId = (int)ReadProperty(context.Target, RuleBaseClassesRoot.CustomerIdProperty);

            switch (customerId)
            {
            case 4:
                context.AddErrorResult(RuleBaseClassesRoot.NameProperty, "customer name required");
                context.AddErrorResult(RuleBaseClassesRoot.CountryProperty, "country required");
                context.AddErrorResult(RuleBaseClassesRoot.StateProperty, "state required");
                break;

            case 5:
                context.AddWarningResult(RuleBaseClassesRoot.NameProperty, "customer name required");
                context.AddWarningResult(RuleBaseClassesRoot.CountryProperty, "country required");
                context.AddWarningResult(RuleBaseClassesRoot.StateProperty, "state required");
                break;

            case 6:
                context.AddInformationResult(RuleBaseClassesRoot.NameProperty, "customer name required");
                context.AddInformationResult(RuleBaseClassesRoot.CountryProperty, "country required");
                context.AddInformationResult(RuleBaseClassesRoot.StateProperty, "state required");
                break;
            }
        }
Пример #4
0
        /// <summary>
        /// Rule implementation.
        /// </summary>
        /// <param name="context">Rule context.</param>
        protected override void Execute(RuleContext context)
        {
            var ctx = new System.ComponentModel.DataAnnotations.ValidationContext(context.Target, null, null);

            if (PrimaryProperty != null)
            {
                ctx.MemberName = PrimaryProperty.FriendlyName;
            }

            System.ComponentModel.DataAnnotations.ValidationResult result = null;
            try
            {
                if (PrimaryProperty != null)
                {
                    object value = context.InputPropertyValues[PrimaryProperty];
                    result = this.Attribute.GetValidationResult(value, ctx);
                }
                else
                {
                    result = this.Attribute.GetValidationResult(null, ctx);
                }
            }
            catch (Exception ex)
            {
                context.AddErrorResult(ex.Message);
            }
            if (result != null)
            {
                context.AddErrorResult(result.ErrorMessage);
            }
        }
Пример #5
0
        protected override void Execute(RuleContext context)
        {
            if (context == null)
            {
                throw new ArgumentException("Context cannot be null");
            }

            var imageArray = (byte[])context.InputPropertyValues[this.ImageProptery];

            if (imageArray != null && imageArray.Length > 0)
            {
                try
                {
                    using (var ms = new MemoryStream(imageArray))
                    {
                        var image = System.Drawing.Image.FromStream(ms);
                        if (image.Height != ImageConstants.AllowedHeight || image.Width != ImageConstants.AllowedWidth)
                        {
                            context.AddErrorResult(string.Format(CultureInfo.CurrentCulture, "The supplied image must have a height of {0} px and a width of {1} px.", ImageConstants.AllowedHeight, ImageConstants.AllowedWidth));
                        }
                    }
                }
                catch (ArgumentException)
                {
                    context.AddErrorResult("Image must be set with a valid image type.");
                }
            }
        }
        /// <summary>
        /// Executes the rule.
        /// </summary>
        /// <param name="context">The rule context.</param>
        protected override void Execute(RuleContext context)
        {
            try
            {
                var process = (ProcessEdit)context.Target;
                var allFields = GetProcessFields(process);

                foreach (var field in process.GetAllFields())
                {
                    var crossRefStep = field.StepList.OfType<CrossRefOptionsStepEdit>().FirstOrDefault();

                    if (crossRefStep != null)
                    {
                        if (!IsFilterValid(crossRefStep.FilterDefinition, allFields))
                            context.AddErrorResult(
                                string.Format(LanguageService.Translate("Rule_FilterReferencesInvalidFields"), field.Name ?? string.Empty));
                        continue;
                    }

                    var checklistStep = field.StepList.OfType<ChecklistSettingsStepEdit>().FirstOrDefault();

                    if (checklistStep != null)
                    {
                        if (!IsFilterValid(checklistStep.FilterDefinition, allFields))
                            context.AddErrorResult(
                                string.Format(LanguageService.Translate("Rule_FilterReferencesInvalidFields"), field.Name ?? string.Empty));
                    }
                }
            }
            catch (Exception ex)
            {
                context.AddErrorResult(PrimaryProperty, ex.Message);
            }
        }
Пример #7
0
        protected override void Execute(RuleContext context)
        {

            DateTime startTime = (DateTime) context.InputPropertyValues[startPropertyInfo];
            DateTime endTime = (DateTime)context.InputPropertyValues[endPropertyInfo];

            if (DateTime.Compare(startTime, endTime) >= 0)
            {
                context.AddErrorResult(ValidationMessages.InvalidTimeRange);
            }
            else if ((endTime - startTime).Hours <= 0)
            {
                context.AddErrorResult(ValidationMessages.MinHourInvalid);
            }
            else
            {
                var chainedContext1 = context.GetChainedContext(InnerTopOfHourStartRule);
                InnerTopOfHourStartRule.Execute(chainedContext1);

                var chainedContext2 = context.GetChainedContext(InnerTopOfHourEndRule);
                InnerTopOfHourEndRule.Execute(chainedContext2);
            }

            
        }
Пример #8
0
        protected override void Execute(RuleContext context)
        {
            if (context == null)
            {
                throw new ArgumentException("Context cannot be null");
            }

            var imageArray = (byte[])context.InputPropertyValues[this.ImageProptery];
            if (imageArray != null && imageArray.Length > 0)
            {
                try
                {
                    using (var ms = new MemoryStream(imageArray))
                    {
                        var image = System.Drawing.Image.FromStream(ms);
                        if (image.Height != ImageConstants.AllowedHeight || image.Width != ImageConstants.AllowedWidth)
                        {
                            context.AddErrorResult(string.Format(CultureInfo.CurrentCulture, "The supplied image must have a height of {0} px and a width of {1} px.", ImageConstants.AllowedHeight, ImageConstants.AllowedWidth));
                        }
                    }
                }
                catch (ArgumentException)
                {
                    context.AddErrorResult("Image must be set with a valid image type.");
                }
            }
        }
Пример #9
0
            protected override void Execute(RuleContext context)
            {
                if (Csla.ApplicationContext.LogicalExecutionLocation == Csla.ApplicationContext.LogicalExecutionLocations.Client)
                {
                    BackgroundWorker worker = new BackgroundWorker();

                    worker.DoWork += (s, e) =>
                    {
                        System.Threading.Thread.Sleep(2000);
                        var value = context.InputPropertyValues[PrimaryProperty];
                        if (value == null || value.ToString().ToUpper() == "ERROR")
                        {
                            context.AddErrorResult("error detected");
                        }
                    };

                    worker.RunWorkerCompleted += (s, e) => context.Complete();

                    // simulating an asynchronous process.
                    worker.RunWorkerAsync();
                }
                else
                {
                    var value = context.InputPropertyValues[PrimaryProperty];
                    if (value == null || value.ToString().ToUpper() == "ERROR")
                    {
                        context.AddErrorResult("error detected");
                    }
                    context.Complete();
                }
            }
Пример #10
0
        protected override void Execute(RuleContext context)
#endif
        {
            int role = (int)context.InputPropertyValues[PrimaryProperty];

#if __ANDROID__
            var roles = await RoleList.GetListAsync();

            if (!(await RoleList.GetListAsync()).ContainsKey(role))
            {
                context.AddErrorResult("Role must be in RoleList");
            }
            context.Complete();
#elif SILVERLIGHT
            RoleList.GetList((o, e) =>
            {
                if (!e.Object.ContainsKey(role))
                {
                    context.AddErrorResult("Role must be in RoleList");
                }
                context.Complete();
            });
#else
            if (!RoleList.GetList().ContainsKey(role))
            {
                context.AddErrorResult("Role must be in RoleList");
            }
#endif
        }
        /// <summary>
        /// Business or validation rule implementation.
        /// </summary>
        /// <param name="context">Rule context object.</param>
        protected override void Execute(RuleContext context)
        {
            var process = context.Target as ProcessEdit;

            if (process == null)
                return;

            var commands = (ProcessCommandEditList)context.InputPropertyValues[PrimaryProperty];
            var states = process.StateList;

            if (commands == null)
                return;

            if (states != null)
                foreach (var command in commands)
                {
                    if (command.SecurityConfigurationList == null || command.SecurityConfigurationList.Count <= 0)
                        continue;

                    var configurationList = command.SecurityConfigurationList.Where(c => c.StateGuid != Constants.AllStatesGuid);
                    var depricatedConfigurationList = configurationList.Where(c => states.Count(s => s.Guid == c.StateGuid) == 0);

                    foreach (var depricatedItem in depricatedConfigurationList)
                        context.AddErrorResult(PrimaryProperty, string.Format(LanguageService.Translate("Rule_CommandSecurityConfigurationsState"), command.CommandName, depricatedItem));
                }
            else
                foreach (var command in commands)
                {
                    if (command.SecurityConfigurationList == null || command.SecurityConfigurationList.Count <= 0)
                        continue;

                    foreach (var depricatedItem in command.SecurityConfigurationList)
                        context.AddErrorResult(PrimaryProperty, string.Format(LanguageService.Translate("Rule_CommandSecurityConfigurationsState"), command.CommandName, depricatedItem));
                }
        }
        /// <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 selectedFrequency = (int?)context.InputPropertyValues[PrimaryProperty];
            var frequencyTypeString = (string)context.InputPropertyValues[_frequencyTypeProperty];

            var frequencyName = (string)context.InputPropertyValues[_frequencyName];

            FrequencyEventEnum frequencyType;

            if (string.IsNullOrEmpty(frequencyTypeString))
                frequencyTypeString = FrequencyEventEnum.Time.ToString();

            if (!Enum.TryParse(frequencyTypeString, true, out frequencyType))
                return;

            if (frequencyType == FrequencyEventEnum.Event)
            {
                if (!selectedFrequency.HasValue || selectedFrequency.Value == 0)
                {
                    context.AddErrorResult(PrimaryProperty, string.Format(CultureInfo.InvariantCulture, "Frequency event for field \"{0}\" is required.", _frequencyFieldName));
                }

                if (string.IsNullOrEmpty(frequencyName))
                {
                    context.AddErrorResult(PrimaryProperty, string.Format(CultureInfo.InvariantCulture, "Frequency event for field \"{0}\" is required.", _frequencyFieldName));
                }
            }
        }
Пример #13
0
        /// <summary>
        /// Business or validation rule implementation.
        /// </summary>
        /// <param name="context">Rule context object.</param>
        protected override void Execute(RuleContext context)
        {
            var uri = context.InputPropertyValues[PrimaryProperty] as string;

            System.Diagnostics.Debug.WriteLine(uri);

            if (!string.IsNullOrWhiteSpace(uri) && !SystemPath.IsRelative(uri) && !Uri.IsWellFormedUriString(uri, UriKind.Absolute))
                context.AddErrorResult(PrimaryProperty, "Invalid URI");
            else if (SystemPath.IsRelative(uri) && !Uri.IsWellFormedUriString(uri, UriKind.Relative))
                context.AddErrorResult(PrimaryProperty, "Invalid URI");
        }
Пример #14
0
        /// <summary>
        /// Does the check for primary propert less than compareTo property
        /// </summary>
        /// <param name="context">Rule context object.</param>
        protected override void Execute(RuleContext context)
        {
            var value1 = (IComparable)context.InputPropertyValues[PrimaryProperty];
            var value2 = (IComparable)context.InputPropertyValues[CompareTo];

            if (value1.CompareTo(value2) >= 0)
            {
                context.AddErrorResult(string.Format("{0} must be less than {1}", PrimaryProperty.FriendlyName, CompareTo.FriendlyName));
                context.AddErrorResult(CompareTo, string.Format("{0} must be larger than {1}", CompareTo.FriendlyName, PrimaryProperty.FriendlyName));
            }
        }
Пример #15
0
    protected override void Execute(RuleContext context)
#endif
    {
        int role = (int)context.InputPropertyValues[PrimaryProperty];
#if __ANDROID__
        var roles = await RoleList.GetListAsync();
        if (!(await RoleList.GetListAsync()).ContainsKey(role))
            context.AddErrorResult("Role must be in RoleList");
        context.Complete();
#else
      if (!RoleList.GetList().ContainsKey(role))
        context.AddErrorResult("Role must be in RoleList");
#endif
    }
Пример #16
0
        protected override void Execute(RuleContext context)
        {
            var obj  = context.Target.GetType().GetProperty(PrimaryProperty.Name).GetValue(context.Target);
            var msj  = String.Format("Agregue al menos un elemento en {0}.", PrimaryProperty.FriendlyName);
            var list = obj as IList;

            if (list == null)
            {
                context.AddErrorResult(msj);
                return;
            }
            if (!(list.Count > 0))
            {
                context.AddErrorResult(msj);
            }
        }
Пример #17
0
        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));
                }
            }
        }
        /// <summary>
        /// Business or validation rule implementation.
        /// </summary>
        /// <param name="context">Rule context object.</param>
        protected override void Execute(RuleContext context)
        {
            var commands = (ProcessCommandEditList)context.InputPropertyValues[PrimaryProperty];

            if (commands == null) return;

            foreach (var command in commands)
            {
                var foundConfigurations = new HashSet<ProcessCommandSecurityConfigurationEdit>();

                var command1 = command;
                foreach (var configuration in command.SecurityConfigurationList.Where(configuration => !foundConfigurations.Any(f => f.RoleId == configuration.RoleId &&
                                                                                                                                     f.StateGuid == configuration.StateGuid &&
                                                                                                                                     f.BusinessUnitId == configuration.BusinessUnitId &&
                                                                                                                                     f.PersonFieldSystemName == configuration.PersonFieldSystemName)
                                                                                                       && command1.SecurityConfigurationList.Any(x => !x.Equals(configuration) &&
                                                                                                                                                      x.RoleId == configuration.RoleId &&
                                                                                                                                                      x.StateGuid == configuration.StateGuid &&
                                                                                                                                                      x.BusinessUnitId == configuration.BusinessUnitId &&
                                                                                                                                                      x.PersonFieldSystemName == configuration.PersonFieldSystemName))
                    )
                {
                    foundConfigurations.Add(configuration);

                    context.AddErrorResult(PrimaryProperty, string.Format(LanguageService.Translate("Rule_UniqueSecurityConfiguration"), command.CommandName));
                }
            }
        }
        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));
                }
            }
        }
Пример #20
0
        /// <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 value = context.InputPropertyValues[InputProperties[0]];

            if (value == null)
            {
                return;
            }

            var s = value as string;
            if (s != null && string.IsNullOrEmpty(s))
                return;

            if (value is int)
            {
                return;
            }

            if (value is decimal)
            {
                if ((decimal)value < int.MaxValue && (decimal)value > int.MinValue)
                    return;
            }

            context.AddErrorResult("Value must be between -2 147 483 648 and +2 147 483 647");
        }
 protected override void Execute(RuleContext context)
 {
     if (((IAppointmentRequest)context.Target).TimeEntries == null || ((IAppointmentRequest)context.Target).TimeEntries.Count < 1)
     {
         context.AddErrorResult(ValidationMessages.NoTimeEntries);
     }
 }
Пример #22
0
    protected override void Execute(RuleContext context)
    {
#if SILVERLIGHT
        int role = (int)context.InputPropertyValues[PrimaryProperty];
        RoleList.GetList((o, e) =>
          {
            if (!e.Object.ContainsKey(role))
              context.AddErrorResult("Role must be in RoleList");
            context.Complete();
          });
#else
      int role = (int)context.InputPropertyValues[PrimaryProperty];
      if (!RoleList.GetList().ContainsKey(role))
        context.AddErrorResult("Role must be in RoleList");
#endif
    }
Пример #23
0
 /// <summary>
 /// Business or validation rule implementation.
 /// </summary>
 /// <param name="context">Rule context object.</param>
 protected override void Execute(RuleContext context)
 {
     if (string.IsNullOrWhiteSpace((string)context.InputPropertyValues[PrimaryProperty]) && (((SummaryTypes)context.InputPropertyValues[InputProperties[2]]) != SummaryTypes.Count))
     {
         context.AddErrorResult(ProcessMetricEdit.MetricFieldSystemNameRuleHighlightProperty, LanguageService.Translate("Rule_MetricFieldIsRequired"));
     }
 }
 /// <summary>
 /// Business or validation rule implementation.
 /// </summary>
 /// <param name="context">Rule context object.</param>
 protected override void Execute(RuleContext context)
 {
     if ((int)context.InputPropertyValues[ProcessScheduleEdit.ScheduleFrequencyPatternIdProperty] == 0)
     {
         context.AddErrorResult(PrimaryProperty, LanguageService.Translate("Rule_ScheduleFrequencyPattern"));
     }
 }
        /// <summary>
        /// Business or validation rule implementation.
        /// </summary>
        /// <param name="context">Rule context object.</param>
        protected override void Execute(RuleContext context)
        {
            var isSimpleProcess = (bool)context.InputPropertyValues[PrimaryProperty];
            if (!isSimpleProcess) return;

            var sectionsProperty = InputProperties.First(x => x.Name.Equals(ProcessEdit.SectionListProperty.Name));
            var sections = (ProcessSections)context.InputPropertyValues[sectionsProperty];

            if (sections == null || sections.Count == 0)
                return;

            var invalidFieldTypes = string.Format("{0},{1},{2},{3},{4},{5},{6},{7}",
                                                  ColumnTypes.Approval,
                                                  ColumnTypes.Checklist,
                                                  ColumnTypes.DisplayList,
                                                  ColumnTypes.Result,
                                                  ColumnTypes.Sample,
                                                  ColumnTypes.SampleType,
                                                  ColumnTypes.SamplingTechnique,
                                                  ColumnTypes.SPCChart);

            foreach (var section in sections.Where(s => s.FieldList != null))
                foreach (var field in section.FieldList.Where(f => !string.IsNullOrEmpty(f.SystemName)).Where(field => field.FieldType != null && invalidFieldTypes.Contains(field.FieldType.DataType)))
                    context.AddErrorResult(string.Format(LanguageService.Translate("Rule_SympleProcessFields"), field.Name, section.Name));
        }
Пример #26
0
        /// <summary>
        /// Executes the rule in specified context.
        /// </summary>
        /// <param name="context">The context.</param>
        protected override void Execute(RuleContext context)
        {
            foreach (var field in context.InputPropertyValues)
            {
                // smartfields have their own implementation of IsEmpty
                var smartField = field.Value as ISmartField;

                if (smartField != null)
                {
                    if (!smartField.IsEmpty)
                    {
                        return;
                    }
                }
                else if (field.Value != null && !field.Value.Equals(field.Key.DefaultValue))
                {
                    return;
                }
            }

            var fields     = context.InputPropertyValues.Select(p => p.Key.FriendlyName).ToArray();
            var fieldNames = String.Join(", ", fields);

            context.AddErrorResult(string.Format(GetMessage(), fieldNames));
        }
Пример #27
0
 /// <summary>
 /// Business or validation rule implementation.
 /// </summary>
 /// <param name="context">Rule context object.</param>
 protected override void Execute(RuleContext context)
 {
     if (string.IsNullOrEmpty((string)context.InputPropertyValues[ProcessScheduleEdit.ScheduleDisplayDateFieldProperty]))
     {
         context.AddErrorResult(PrimaryProperty, LanguageService.Translate("Rule_ScheduleDate"));
     }
 }
Пример #28
0
 /// <summary>
 /// Business or validation rule implementation.
 /// </summary>
 /// <param name="context">Rule context object.</param>
 protected override void Execute(RuleContext context)
 {
     if ((Guid)context.InputPropertyValues[ProcessScheduleEdit.ScheduleStartStateGuidProperty] == Guid.Empty)
     {
         context.AddErrorResult(PrimaryProperty, LanguageService.Translate("Rule_ScheduleState"));
     }
 }
Пример #29
0
        /// <summary>
        /// Business rule implementation.
        /// </summary>
        /// <param name="context">Rule context object.</param>
        protected override void Execute(RuleContext context)
        {
            object value = context.InputPropertyValues[PrimaryProperty];

            if (Convert.ToDateTime(value) > DateTime.Now)
            {
                var message = string.Format(GetMessage(), PrimaryProperty.FriendlyName);
                context.Results.Add(new RuleResult(RuleName, PrimaryProperty, message)
                {
                    Severity = Severity
                });
                return;
            }

            try
            {
                if (Convert.ToDateTime(value) >= DateTime.MinValue)
                {
                    return;
                }
            }
            catch (Exception ex)
            {
                context.AddErrorResult(string.Format("{0}{1} isn't valid.",
                                                     ex.Message + Environment.NewLine,
                                                     PrimaryProperty.FriendlyName));
            }
        }
Пример #30
0
 /// <summary>
 /// Business or validation rule implementation.
 /// </summary>
 /// <param name="context">Rule context object.</param>
 protected override void Execute(RuleContext context)
 {
     foreach (var item in context.InputPropertyValues.Where(x => (int)x.Value < 10))
     {
         context.AddErrorResult(item.Key, LanguageService.Translate("Rule_PictureSize"));
     }
 }
Пример #31
0
        /// <summary>
        /// Business or validation rule implementation.
        /// </summary>
        /// <param name="context">Rule context object.</param>
        protected override void Execute(RuleContext context)
        {
            var allowRichText = (bool)context.InputPropertyValues[PrimaryProperty];
            var mask = (string)context.InputPropertyValues[TextOptionsStepEdit.MaskProperty];
            var maskType = (string)context.InputPropertyValues[TextOptionsStepEdit.MaskTypeProperty];

            if (allowRichText && !string.IsNullOrEmpty(mask))
            {
                context.AddErrorResult(InputProperties.First(x => x.Name == TextOptionsStepEdit.MaskRuleHighlightProperty.Name), LanguageService.Translate("Rule_OnlyMaskOrRichText1"));
                return;
            }

            if (allowRichText && maskType != "None")
            {
                context.AddErrorResult(InputProperties.First(x => x.Name == TextOptionsStepEdit.MaskTypeRuleHighlightProperty.Name), LanguageService.Translate("Rule_OnlyMaskOrRichText2"));
            }
        }
 protected override void Execute(RuleContext context)
 {
     var target = (IAttachment)context.Target;
     if (target.SourceType == SourceType.None)
     {
         context.AddErrorResult("SourceType is required.");
     }
 }
        protected override void Execute(RuleContext context)
        {
            var primero = (string)context.InputPropertyValues[PrimaryProperty];
            var segundo = (string)context.InputPropertyValues[SecondaryProperty];

            if (primero != segundo)
                context.AddErrorResult("Las contraseñas no son iguales! Verifique por favor");
        }
Пример #34
0
 protected override async void Execute(RuleContext context)
 {
     int role = (int)context.InputPropertyValues[PrimaryProperty];
     var roles = await RoleList.CacheListAsync();
     if (!roles.ContainsKey(role))
         context.AddErrorResult("Role must be in RoleList");
     context.Complete();
 }
Пример #35
0
        protected override void Execute(RuleContext context)
        {
            var target = (IUser)context.Target;

            if (target.Role == Role.None)
            {
                context.AddErrorResult("Role is required.");
            }
        }
Пример #36
0
            protected override void Execute(RuleContext context)
            {
                var cust = (Customer)context.Target;

                if (cust.Zipcode == "12345")
                {
                    context.AddErrorResult("private rule failed");
                }
            }
Пример #37
0
    protected override void Execute(RuleContext context)
    {
        Example target = (Example)context.Target;

        if (!string.IsNullOrEmpty(ReadProperty(target, Example.A).ToString()) && !String.IsNullOrEmpty(ReadProperty(target, Example.B).ToString()))
        {
            context.AddErrorResult("At least on property has to be null !");
        }
    }
        /// <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 value = context.InputPropertyValues[PrimaryProperty] as ICrossRefItemList;
            if (value == null || value.Count == 0)
                context.AddErrorResult(PrimaryProperty, string.Format(System.Globalization.CultureInfo.InvariantCulture, "'{0}' is required.", PrimaryProperty.FriendlyName));
        }
Пример #39
0
        protected override void Execute(RuleContext context)
        {
            var target = (EmployeeInformationEdit)context.Target;

            if (target.State == "NY" && target.Zip != "10108")
            {
                context.AddErrorResult(StringResources.ErrorsMessages.Errors.NYError);
            }
        }
 protected override void Execute(RuleContext context)
 {
     var target = (ICategory)context.Target;
     var users = CategoryInfoList.FetchCategoryInfoList(new CategoryCriteria { Name = target.Name });
     if (users.Count(row => row.CategoryId != target.CategoryId) != 0)
     {
         context.AddErrorResult("That category name is already in use.");
     }
 }
Пример #41
0
        protected override void Execute(RuleContext context)
        {
            var args = new RuleContextArg();

            if (!_delegateRule((T)context.Target, args))
            {
                context.AddErrorResult(args.Description);
            }
        }
Пример #42
0
            protected override void Execute(RuleContext context)
            {
                var target = (Foo)context.Target;

                if (target.Name == "2")
                {
                    context.AddErrorResult("Name can not be 2");
                }
            }
Пример #43
0
 protected override void Execute(RuleContext context)
 {
     var target = (IUser)context.Target;
     var users = UserInfoList.FetchUserInfoList(new UserCriteria { Email = target.Email });
     if (users.Count(row => row.UserId != target.UserId) != 0)
     {
         context.AddErrorResult("That email address is already in use.");
     }
 }
 protected override void Execute(RuleContext context)
 {
     var target = (IStatus)context.Target;
     var users = StatusInfoList.FetchStatusInfoList(new StatusCriteria { Name = target.Name });
     if (users.Count(row => row.StatusId != target.StatusId) != 0)
     {
         context.AddErrorResult("That status name is already in use.");
     }
 }
Пример #45
0
        protected override void Execute(RuleContext context)
        {
            var target = (INote)context.Target;

            if (target.SourceType == SourceType.None)
            {
                context.AddErrorResult("SourceType is required.");
            }
        }
Пример #46
0
        protected override void Execute(RuleContext context)
        {
            var primero = (string)context.InputPropertyValues[PrimaryProperty];
            var segundo = (string)context.InputPropertyValues[SecondaryProperty];

            if (primero != segundo)
            {
                context.AddErrorResult("Las contraseñas no son iguales! Verifique por favor");
            }
        }
Пример #47
0
        protected override void Execute(RuleContext context)
        {
            var pollOptionsProperty = this.InputProperties[0];
            var pollOptions         = context.InputPropertyValues[pollOptionsProperty] as BusinessList <IPollOption>;

            if (pollOptions == null || pollOptions.Count < 2)
            {
                context.AddErrorResult(pollOptionsProperty, "There must be at least two poll answers specified.");
            }
        }
Пример #48
0
            protected override void Execute(RuleContext context)
            {
                var target = (Contact)context.Target;

                if (target.ContactType == BitzConstants.ContactTypes.Employee.Id &&
                    target.LastName.Length == 0)
                {
                    context.AddErrorResult("Lastname required");
                }
            }
Пример #49
0
        /// <summary>
        /// Does the check for primary propert less than compareTo property
        /// </summary>
        /// <param name="context">Rule context object.</param>
        protected override void Execute(RuleContext context)
        {
            var value1 = (dynamic)context.InputPropertyValues[PrimaryProperty];
            var value2 = (dynamic)context.InputPropertyValues[CompareTo];

            if (value1 > value2)
            {
                context.AddErrorResult(string.Format("{0} must be less than or equal {1}", PrimaryProperty.FriendlyName, CompareTo.FriendlyName));
            }
        }
        protected override void Execute(RuleContext context)
        {
            var value1 = (IComparable)context.InputPropertyValues[this.PrimaryProperty];
            var value2 = (IComparable)context.InputPropertyValues[this.CompareToProperty];

            if (value1.CompareTo(value2) != 0)
            {
                context.AddErrorResult(string.Format("{0} must match {1}", this.PrimaryProperty.FriendlyName, this.CompareToProperty.FriendlyName));
            }
        }
Пример #51
0
    /// <summary>
    /// Does the check for primary propert less than compareTo property
    /// </summary>
    /// <param name="context">Rule context object.</param>
    protected override void Execute(RuleContext context)
    {
      var value1 = (dynamic)context.InputPropertyValues[PrimaryProperty];
      var value2 = (dynamic)context.InputPropertyValues[CompareTo];

      if (value1 > value2)
      {
        context.AddErrorResult(string.Format("{0} must be less than or equal {1}", PrimaryProperty.FriendlyName, CompareTo.FriendlyName));
      }
    }
 protected override void Execute(RuleContext context)
 {
     var primaryValue = context.InputPropertyValues[PrimaryProperty] + string.Empty;
     var dependentValue = context.InputPropertyValues[DependentProperty] + string.Empty;
     if (!string.IsNullOrWhiteSpace(dependentValue) && string.IsNullOrWhiteSpace(primaryValue))
     {
         context.AddErrorResult(string.Format(MessageText,
             PrimaryProperty.FriendlyName, DependentProperty.FriendlyName));
     }
 }
Пример #53
0
 protected override void Execute(RuleContext context)
 {
     if (context.InputPropertyValues[PrimaryProperty] != null)
     {
         var val = (T)context.InputPropertyValues[PrimaryProperty];
         if (!ListOfValues.Contains(val))
         {
             context.AddErrorResult(string.Format("'{0}' is not in the list of expected values.", PrimaryProperty.FriendlyName));
         }
     }
 }
Пример #54
0
        protected override void Execute(RuleContext context)
        {
#if SILVERLIGHT
            int role = (int)context.InputPropertyValues[PrimaryProperty];
            RoleList.GetList((o, e) =>
            {
                if (!e.Object.ContainsKey(role))
                {
                    context.AddErrorResult("Role must be in RoleList");
                }
                context.Complete();
            });
#else
            int role = (int)context.InputPropertyValues[PrimaryProperty];
            if (!RoleList.GetList().ContainsKey(role))
            {
                context.AddErrorResult("Role must be in RoleList");
            }
#endif
        }
Пример #55
0
        protected override void Execute(RuleContext context)
        {
            var pollMaxAnswersProperty = this.InputProperties[0];
            var pollOptionsProperty    = this.InputProperties[1];

            var pollMaxAnswers = context.InputPropertyValues[pollMaxAnswersProperty] as short?;
            var pollOptions    = context.InputPropertyValues[pollOptionsProperty] as BusinessList <IPollOption>;

            if (pollMaxAnswers != null)
            {
                if (pollMaxAnswers <= 0)
                {
                    context.AddErrorResult(pollMaxAnswersProperty, "The maximum answer count must be greater than zero.");
                }
                else if (pollOptions != null && pollMaxAnswers > pollOptions.Count)
                {
                    context.AddErrorResult(pollMaxAnswersProperty, "The maximum answer count must be less than or equal to the poll option count.");
                }
            }
        }
Пример #56
0
        protected override async void Execute(RuleContext context)
        {
            int role  = (int)context.InputPropertyValues[PrimaryProperty];
            var roles = await RoleList.CacheListAsync();

            if (!roles.ContainsKey(role))
            {
                context.AddErrorResult("Role must be in RoleList");
            }
            context.Complete();
        }
Пример #57
0
        protected override void Execute(RuleContext context)
        {
            var primaryPropertyValue = (string)context.InputPropertyValues[PrimaryProperty];
            var idProperty           = this.InputProperties.Single(p => p.Name == this.IdPropertyName);
            var idValue = (int)context.InputPropertyValues[idProperty];

            if (DuplicateCommand(idValue, primaryPropertyValue))
            {
                context.AddErrorResult(string.Format(CultureInfo.CurrentCulture, "The value {0} already exists.", primaryPropertyValue));
            }
        }
Пример #58
0
        protected override void Execute(RuleContext context)
        {
            var value1 = (int)context.InputPropertyValues[PrimaryProperty];
            var value2 = (string)context.InputPropertyValues[SecondaryProperty];

            // uses the async methods in DataPortal to perform data access on a background thread.
            DuplicateCompanyCommand.BeginExecute(value1, value2, (o, e) =>
            {
                if (e.Error != null)
                {
                    context.AddErrorResult(string.Format("Error checking for duplicate company name.  {0}", e.Error));
                }
                else if (e.Object.IsDuplicate)
                {
                    context.AddErrorResult("Duplicate company name.");
                }

                context.Complete();
            });
        }
Пример #59
0
        protected override void Execute(RuleContext context)
        {
            var primaryValue   = context.InputPropertyValues[PrimaryProperty] + string.Empty;
            var dependentValue = context.InputPropertyValues[DependentProperty] + string.Empty;

            if (!string.IsNullOrWhiteSpace(dependentValue) && string.IsNullOrWhiteSpace(primaryValue))
            {
                context.AddErrorResult(string.Format(MessageText,
                                                     PrimaryProperty.FriendlyName, DependentProperty.FriendlyName));
            }
        }
Пример #60
0
            protected override void Execute(RuleContext context)
            {
                var usuario       = context.Target as Usuario;
                var valorNumerico = 0;

                bool result = int.TryParse(usuario.Alias, out valorNumerico);

                if (!result)
                {
                    var nombresApellidos = string.Concat(usuario.ApellidoPaterno, usuario.ApellidoMaterno);
                    if (String.IsNullOrEmpty(nombresApellidos))
                    {
                        context.AddErrorResult(Usuario.ApellidoPaternoProperty, "Apellido Paterno deben ser obligatorio");
                        context.AddErrorResult(Usuario.ApellidoMaternoProperty, "Apellido Materno deben ser obligatorio");
                    }
                    else
                    {
                        context.AddSuccessResult(true);
                    }
                }
            }