예제 #1
0
        private void SetRegularExpressions()
        {
            #region Age2 must be 1-99

            ValidationMessage = new ValidationMessage
            {
                Message = string.Format("{0} must be 1-99", ResolveFieldLabel(TemplateReference, GenericSectionName.ARRESTEE, "age2")),
                TargetPath = "age2"
            };

            TargetField = new ValidationField
            {
                FieldPath = "age2",
                SectionName = GenericSectionName.ARRESTEE,
                ControlType = ControlType.Text,
                Mask = Mask.None
            };

            ValidationRule = new Validation(ValidationMessage, TargetField)
                .RegularExpression(ValidationMeta.ZeroToNinetyNineRange)
                    .ImplementStateValidationRule();

            UcrValidationRules.Add(ValidationRule);

            #endregion
        }
예제 #2
0
        private void CompareToCurrentDate()
        {
            #region ArrestDate must be on or before the current date

            UcrValidationRules.Add(new Validation(
                new ValidationMessage
                {
                    Message = string.Format("{0} must be on or before the current date", ResolveFieldLabel(TemplateReference, GenericSectionName.EVENT, "startDate")),
                    TargetPath = "startDate"
                },
                new ValidationField
                {
                    FieldPath = "startDate",
                    SectionName = GenericSectionName.EVENT,
                    ControlType = ControlType.Date,
                    Mask = Mask.DateTime,
                    CompareToMask = Mask.Date
                }).CompareToCurrentDate().ImplementStateValidationRule());

            #endregion
        }
예제 #3
0
        private void SetContains()
        {
            #region WeaponTypes must be 06 when ViolationCode has a UCR Class of 04 and Subclass of b

            TargetFieldLabel      = ResolveFieldLabel(TemplateReference, GenericSectionName.OFFENSES, "weaponTypes");
            AssociatedField1Label = ResolveFieldLabel(TemplateReference, GenericSectionName.OFFENSES, "violationCodeReference");

            classList = new List <string> {
                "06"
            };
            ucrClassList = new List <string> {
                "04"
            };
            ucrSubclassList = new List <string> {
                "b."
            };

            ValidationMessage = new ValidationMessage(string.Format("If UCR code is 04b, the weapon must be 'Knife or other cutting or stabbing instrument' "), "weaponTypes");//ending space to keep messages different - used as unique id

            TargetField = new ValidationField
            {
                FieldPath   = "weaponTypes",
                SectionName = GenericSectionName.OFFENSES,
                ControlType = ControlType.Multiselect,
            };

            ValidationRule = new Validation(ValidationMessage, TargetField)
                             .Contains(classList)
                             .WithConditions()
                             .Required(TargetField)
                             .Contains(ValidationField.ViolationCodeOffenses(ucrClassProperty), ucrClassList)
                             .Contains(ValidationField.ViolationCodeOffenses(ucrSubclassProperty), ucrSubclassList)
                             .ThatBroadcasts()
                             .ImplementStateValidationRule();

            UcrValidationRules.Add(ValidationRule);
            UcrValidationRules.Add(new Validation(ValidationMessage, ValidationField.ViolationCodeOffenses()).ThatBroadcasts().ImplementStateValidationRule());
            #endregion
        }
예제 #4
0
        private void SetCustoms()
        {
            #region Law Enforcement Disposition must be 2, 4, 5 for Juveniles

            TargetFieldLabel      = ResolveFieldLabel(TemplateReference, GenericSectionName.ARREST_CHARGES, "lawEnforcementDisposition");
            AssociatedField1Label = ResolveFieldLabel(TemplateReference, GenericSectionName.EVENT, "juvenile");

            ValidationMessage = new ValidationMessage(string.Format("{0} for Juveniles can only be Turned Over, Juvenile Court, or Department", TargetFieldLabel), "lawEnforcementDisposition");

            TargetField = new ValidationField
            {
                FieldPath   = "lawEnforcementDisposition",
                SectionName = GenericSectionName.ARREST_CHARGES,
                ControlType = ControlType.Code,
            };

            AssociatedField1 = new ValidationField
            {
                FieldPath   = "juvenile",
                SectionName = GenericSectionName.EVENT,
                ControlType = ControlType.Code,
            };

            ValidationRule =
                new Validation(ValidationMessage, TargetField).CustomValidation(
                    "juvenileLawEnforcementDispositionCheck")
                .ThatSelfEvaluates()
                .ThatBroadcasts()
                .SetRuleImplementation(RuleImplementation)
                .ImplementStateValidationRule();

            UcrValidationRules.Add(ValidationRule);

            UcrValidationRules.Add(new Validation(ValidationMessage,
                                                  AssociatedField1).ThatBroadcasts().SetRuleImplementation(RuleImplementation)
                                   .ImplementStateValidationRule());
            #endregion
        }
예제 #5
0
        private void SetCompareToCurrentDates()
        {
            #region Date Received must be on or before the current date

            TargetFieldLabel = ResolveFieldLabel(TemplateReference, GenericSectionName.INCIDENT_EVENT, "dateReceived");

            UcrValidationRules.Add(new Validation(
                                       new ValidationMessage
            {
                Message    = string.Format("{0} must be on or before the current date", TargetFieldLabel),
                TargetPath = "dateReceived"
            },
                                       new ValidationField
            {
                FieldPath     = "dateReceived",
                SectionName   = GenericSectionName.INCIDENT_EVENT,
                ControlType   = ControlType.Date,
                Mask          = Mask.DateTime,
                CompareToMask = Mask.Date
            }).CompareToCurrentDate().ImplementStateValidationRule());

            #endregion
        }
예제 #6
0
        private void SetValueCounts()
        {
            #region ArresteeArmedWith can only have one value when 01 is used

            TargetFieldLabel = ResolveFieldLabel(TemplateReference, GenericSectionName.ARRESTEE, "arresteeArmedWith");

            ValidationMessage = new ValidationMessage(string.Format("{0} can only have one value when 01 is used", TargetFieldLabel), "arresteeArmedWith");

            TargetField = new ValidationField
            {
                FieldPath = "arresteeArmedWith",
                SectionName = GenericSectionName.ARRESTEE,
                ControlType = ControlType.Multiselect,
            };

            UcrValidationRules.Add(new Validation(new Guid("CD8D0BD3-F4D4-4728-942A-4131D297D680"), ValidationMessage, TargetField)
                    .ValueCount("1")
                    .WithConditions()
                    .Contains(TargetField, new List<string> { "01" })
                    .ThatSelfEvaluates()
                    .ImplementStateValidationRule());

            #endregion
        }
예제 #7
0
        private void SetCustoms()
        {
            #region Must Enter Stolen Property Record when UCR Code is 6d, Attempted/Completed is '02' ('Completed')
            ValidationMessage = new ValidationMessage
            {
                Message    = string.Format("Must Enter Stolen Property Record"),
                TargetPath = "attemptedCompleted"
            };

            TargetField = new ValidationField
            {
                FieldPath   = "attemptedCompleted",
                SectionName = GenericSectionName.OFFENSES,
                ControlType = ControlType.Code
            };

            AssociatedField1 = new ValidationField
            {
                FieldPath   = "status",
                SectionName = GenericSectionName.PROPERTY,
                ControlType = ControlType.Code
            };

            ValidationRule = new Validation(ValidationMessage, TargetField)
                             .CustomValidation("stolenPropertyExistsForOffense6d")
                             .ThatSelfEvaluates()
                             .ImplementStateValidationRule();

            UcrValidationRules.Add(ValidationRule);
            UcrValidationRules.Add(Validation.CreateAssociatedRule(ValidationField.ViolationCodeOffenses(), ValidationRule));

            //broadcast rules
            UcrValidationRules.Add(new Validation(ValidationMessage, ValidationField.RelatedOffenseProperty()).ThatBroadcasts().ImplementStateValidationRule());
            UcrValidationRules.Add(new Validation(ValidationMessage, AssociatedField1).ThatBroadcasts().ImplementStateValidationRule());
            #endregion

            #region Must Enter Stolen Vehicle Record when UCR Code is 07a,07b,07c) and Attempted/Completed is 'C' ('Completed')
            ValidationMessage = new ValidationMessage
            {
                Message    = string.Format("Must Enter Stolen Vehicle Record"),
                TargetPath = "attemptedCompleted"
            };

            TargetField = new ValidationField
            {
                FieldPath   = "attemptedCompleted",
                SectionName = GenericSectionName.OFFENSES,
                ControlType = ControlType.Code
            };

            AssociatedField1 = new ValidationField
            {
                FieldPath   = "status",
                SectionName = GenericSectionName.VEHICLES,
                ControlType = ControlType.Code
            };

            ValidationRule = new Validation(ValidationMessage, TargetField)
                             .CustomValidation("stolenVehicleExistsForOffense7a7b7c")
                             .ThatSelfEvaluates()
                             .ImplementStateValidationRule();

            UcrValidationRules.Add(ValidationRule);
            UcrValidationRules.Add(Validation.CreateAssociatedRule(ValidationField.ViolationCodeOffenses(), ValidationRule));

            //broadcast rules
            UcrValidationRules.Add(new Validation(ValidationMessage, ValidationField.RelatedOffenseVehicles()).ThatBroadcasts().ImplementStateValidationRule());
            UcrValidationRules.Add(new Validation(ValidationMessage, AssociatedField1).ThatBroadcasts().ImplementStateValidationRule());
            #endregion

            #region Must Enter Stolen Property or Vehicle Record when UCR code is 03a,b,c,d and Attempted/Completed is 'C' ('Completed')
            ValidationMessage = new ValidationMessage
            {
                Message    = string.Format("Must Enter Stolen Property or Vehicle Record"),
                TargetPath = "attemptedCompleted"
            };

            TargetField = new ValidationField
            {
                FieldPath   = "attemptedCompleted",
                SectionName = GenericSectionName.OFFENSES,
                ControlType = ControlType.Code
            };

            AssociatedField1 = new ValidationField
            {
                FieldPath   = "status",
                SectionName = GenericSectionName.VEHICLES,
                ControlType = ControlType.Code
            };
            AssociatedField2 = new ValidationField
            {
                FieldPath   = "status",
                SectionName = GenericSectionName.PROPERTY,
                ControlType = ControlType.Code
            };

            ValidationRule = new Validation(ValidationMessage, TargetField)
                             .CustomValidation("stolenPropertyOrVehicleExistsForOffense3a3b3c3d")
                             .ThatSelfEvaluates()
                             .ImplementStateValidationRule();

            UcrValidationRules.Add(ValidationRule);
            UcrValidationRules.Add(Validation.CreateAssociatedRule(ValidationField.ViolationCodeOffenses(), ValidationRule));

            //broadcast rules
            UcrValidationRules.Add(new Validation(ValidationMessage, ValidationField.RelatedOffenseProperty()).ThatBroadcasts().ImplementStateValidationRule());
            UcrValidationRules.Add(new Validation(ValidationMessage, ValidationField.RelatedOffenseVehicles()).ThatBroadcasts().ImplementStateValidationRule());
            UcrValidationRules.Add(new Validation(ValidationMessage, AssociatedField1).ThatBroadcasts().ImplementStateValidationRule());
            UcrValidationRules.Add(new Validation(ValidationMessage, AssociatedField2).ThatBroadcasts().ImplementStateValidationRule());

            #endregion

            #region Must Enter a Weapon if UCR Class is 01, 02, 03, 04, 15, or 17 and Domestic Violence is checked

            TargetFieldLabel      = ResolveFieldLabel(TemplateReference, GenericSectionName.OFFENSES, "weaponTypes");
            AssociatedField1Label = ResolveFieldLabel(TemplateReference, GenericSectionName.INCIDENT_EVENT,
                                                      "domesticViolence");

            ucrClassList = new List <string>()
            {
                "01", "02", "03", "04", "15", "17"
            };
            ValidationMessage =
                new ValidationMessage(
                    string.Format("{0} Must Be Entered for {1} incidents",
                                  TargetFieldLabel, AssociatedField1Label), "weaponTypes");

            TargetField = new ValidationField
            {
                FieldPath   = "weaponTypes",
                SectionName = GenericSectionName.OFFENSES,
                ControlType = ControlType.Multiselect,
            };

            AssociatedField1 = new ValidationField
            {
                FieldPath   = "domesticViolence",
                FieldType   = FieldType.Extended,
                SectionName = GenericSectionName.INCIDENT_EVENT,
                ControlType = ControlType.Checkbox,
            };

            ValidationRule = new Validation(ValidationMessage, TargetField)
                             .CustomValidation("mustEnterWeaponForDomesticViolenceEvents")
                             .ThatSelfEvaluates()
                             .AlwaysShowMessage()
                             .ImplementStateValidationRule();

            UcrValidationRules.Add(ValidationRule);
            UcrValidationRules.Add(new Validation(ValidationMessage, ValidationField.ViolationCodeOffenses()).ThatBroadcasts().ImplementStateValidationRule());
            UcrValidationRules.Add(new Validation(ValidationMessage, AssociatedField1).ThatBroadcasts().ImplementStateValidationRule());


            #endregion
        }
예제 #8
0
        private void SetComparisons()
        {
            #region  Date Received must be on or before the Incident Start Date/Time
            TargetFieldLabel      = ResolveFieldLabel(TemplateReference, GenericSectionName.INCIDENT_EVENT, "dateReceived");
            AssociatedField1Label = ResolveFieldLabel(TemplateReference, GenericSectionName.INCIDENT_EVENT, "startDate");

            TargetField = new ValidationField
            {
                FieldPath     = "dateReceived",
                SectionName   = GenericSectionName.INCIDENT_EVENT,
                ControlType   = ControlType.Date,
                Mask          = Mask.DateTime,
                CompareToMask = Mask.DateTime
            };
            AssociatedField1 = new ValidationField
            {
                FieldPath     = "startDate",
                SectionName   = GenericSectionName.INCIDENT_EVENT,
                ControlType   = ControlType.Date,
                Mask          = Mask.DateTime,
                CompareToMask = Mask.DateTime
            };

            ValidationMessage = new ValidationMessage
            {
                Message    = string.Format("{0} must be on or before the {1}", TargetFieldLabel, AssociatedField1Label),
                TargetPath = "dateReceived"
            };

            ValidationRule = new Validation(ValidationMessage, TargetField).Comparison(ValidationOperand.LessThanEqual).ImplementStateValidationRule();

            UcrValidationRules.Add(ValidationRule);
            UcrValidationRules.Add(Validation.CreateAssociatedRule(AssociatedField1, ValidationRule));

            ValidationRule = null;

            #endregion

            #region Incident Start Date/Time must be on or before the Incident End Date/Time
            TargetFieldLabel      = ResolveFieldLabel(TemplateReference, GenericSectionName.INCIDENT_EVENT, "startDate");
            AssociatedField1Label = ResolveFieldLabel(TemplateReference, GenericSectionName.INCIDENT_EVENT, "endDate");

            TargetField = new ValidationField
            {
                FieldPath     = "startDate",
                SectionName   = GenericSectionName.INCIDENT_EVENT,
                ControlType   = ControlType.Date,
                Mask          = Mask.DateTime,
                CompareToMask = Mask.DateTime
            };

            AssociatedField1 = new ValidationField
            {
                FieldPath     = "endDate",
                SectionName   = GenericSectionName.INCIDENT_EVENT,
                ControlType   = ControlType.Date,
                Mask          = Mask.DateTime,
                CompareToMask = Mask.DateTime
            };

            ValidationMessage = new ValidationMessage
            {
                Message    = string.Format("{0} must be on or before the {1}", TargetFieldLabel, AssociatedField1Label),
                TargetPath = "startDate"
            };

            ValidationRule = new Validation(ValidationMessage, TargetField).Comparison(ValidationOperand.LessThanEqual).ImplementStateValidationRule();

            UcrValidationRules.Add(ValidationRule);
            UcrValidationRules.Add(Validation.CreateAssociatedRule(AssociatedField1, ValidationRule));

            ValidationRule = null;

            #endregion
        }
예제 #9
0
        private void SetRequired()
        {
            #region TimeOfDay is required when ViolationCode has a UCR Class of 05

            TargetFieldLabel      = ResolveFieldLabel(TemplateReference, GenericSectionName.OFFENSES, "timeOfDay");
            AssociatedField1Label = ResolveFieldLabel(TemplateReference, GenericSectionName.OFFENSES,
                                                      "violationCodeReference");

            ValidationMessage =
                new ValidationMessage(
                    string.Format("'You Must Enter In {0} If The Offense Is A Burglary", TargetFieldLabel), "timeOfDay");

            TargetField = new ValidationField
            {
                FieldPath   = "timeOfDay",
                SectionName = GenericSectionName.OFFENSES,
                ControlType = ControlType.Code,
            };

            ValidationRule = new Validation(ValidationMessage, TargetField)
                             .Required()
                             .WithConditions()
                             .Contains(ValidationField.ViolationCodeOffenses(ucrClassProperty), new List <string> {
                "05"
            })
                             .ImplementStateValidationRule();


            UcrValidationRules.Add(ValidationRule);
            UcrValidationRules.Add(Validation.CreateAssociatedRule(ValidationField.ViolationCodeOffenses(), ValidationRule));
            #endregion

            #region Structure should be left blank when UCR Class is 08 (Arson) and Sub Class is j,h, or i

            TargetFieldLabel      = ResolveFieldLabel(TemplateReference, GenericSectionName.OFFENSES, "structure");
            AssociatedField1Label = ResolveFieldLabel(TemplateReference, GenericSectionName.OFFENSES,
                                                      "violationCodeReference");

            ucrClassList = new List <string> {
                "08"
            };
            ucrSubclassList = new List <string> {
                "j.", "h.", "i."
            };

            ValidationMessage = new ValidationMessage
            {
                Message    = string.Format("{0} should be left blank for Arson offenses not involving structures", TargetFieldLabel),
                TargetPath = "structure"
            };

            TargetField = new ValidationField
            {
                FieldPath   = "structure",
                SectionName = GenericSectionName.OFFENSES,
                ControlType = ControlType.Code
            };

            ValidationRule = new Validation(
                ValidationMessage, TargetField)
                             .NotRequired()
                             .WithConditions()
                             .Contains(ValidationField.ViolationCodeOffenses(ucrClassProperty), ucrClassList)
                             .Contains(ValidationField.ViolationCodeOffenses(ucrSubclassProperty), ucrSubclassList)
                             .ImplementStateValidationRule();

            UcrValidationRules.Add(ValidationRule);
            UcrValidationRules.Add(Validation.CreateAssociatedRule(ValidationField.ViolationCodeOffenses(), ValidationRule));

            #endregion

            #region Value is required when Status is S (Property, Guns)

            TargetFieldLabel      = ResolveFieldLabel(TemplateReference, GenericSectionName.PROPERTY, "value");
            AssociatedField1Label = ResolveFieldLabel(TemplateReference, GenericSectionName.PROPERTY, "status");

            ValidationMessage =
                new ValidationMessage(
                    string.Format("If {0} is stolen, {1} is required", AssociatedField1Label, TargetFieldLabel), "value");

            TargetField = new ValidationField
            {
                FieldPath   = "value",
                SectionName = GenericSectionName.PROPERTY,
                ControlType = ControlType.Text,
            };

            AssociatedField1 = new ValidationField
            {
                FieldPath   = "status",
                SectionName = GenericSectionName.PROPERTY,
                ControlType = ControlType.Code,
            };

            ValidationRule
                = new Validation(ValidationMessage, TargetField)
                  .Required()
                  .WithConditions()
                  .Contains(AssociatedField1, new List <string> {
                "S"
            })
                  .RelatedOffenseRequired()
                  .ImplementStateValidationRule();

            // Property
            UcrValidationRules.Add(ValidationRule);
            UcrValidationRules.Add(Validation.CreateAssociatedRule(AssociatedField1, ValidationRule));
            UcrValidationRules.Add(
                new Validation(ValidationMessage, ValidationField.RelatedOffenseProperty()).ThatBroadcasts()
                .ImplementStateValidationRule());

            // Guns
            TargetField.SectionName      = GenericSectionName.GUNS;
            AssociatedField1.SectionName = GenericSectionName.GUNS;
            ValidationMessage            =
                new ValidationMessage(
                    string.Format("{0} is required when {1} is 'S'", TargetFieldLabel, AssociatedField1Label), "value");

            ValidationRule
                = new Validation(ValidationMessage, TargetField)
                  .Required()
                  .WithConditions()
                  .Contains(AssociatedField1, new List <string> {
                "S"
            })
                  .RelatedOffenseRequired()
                  .ImplementStateValidationRule();

            UcrValidationRules.Add(ValidationRule);
            UcrValidationRules.Add(Validation.CreateAssociatedRule(AssociatedField1, ValidationRule));
            UcrValidationRules.Add(
                new Validation(ValidationMessage, ValidationField.RelatedOffenseGuns()).ThatBroadcasts()
                .ImplementStateValidationRule());

            #endregion

            #region RecoveredValue can only be entered when Status is R or SR

            TargetFieldLabel      = ResolveFieldLabel(TemplateReference, GenericSectionName.PROPERTY, "recoveredValue");
            AssociatedField1Label = ResolveFieldLabel(TemplateReference, GenericSectionName.PROPERTY, "status");

            ValidationMessage =
                new ValidationMessage(
                    string.Format("{0} can only be entered when {1} is 'Recovered' or 'Stolen/Recovered'", TargetFieldLabel,
                                  AssociatedField1Label), "recoveredValue");

            TargetField = new ValidationField
            {
                FieldPath   = "recoveredValue",
                SectionName = GenericSectionName.PROPERTY,
                ControlType = ControlType.Text,
            };

            AssociatedField1 = new ValidationField
            {
                FieldPath   = "status",
                SectionName = GenericSectionName.PROPERTY,
                ControlType = ControlType.Code,
            };

            ValidationRule
                = new Validation(ValidationMessage, TargetField)
                  .NotRequired()
                  .WithConditions()
                  .DoesNotContain(AssociatedField1, new List <string> {
                "R", "SR"
            })
                  .RelatedOffenseRequired()
                  .ImplementStateValidationRule();

            // Property
            UcrValidationRules.Add(ValidationRule);
            UcrValidationRules.Add(Validation.CreateAssociatedRule(AssociatedField1, ValidationRule));
            UcrValidationRules.Add(
                new Validation(ValidationMessage, ValidationField.RelatedOffenseProperty()).ThatBroadcasts()
                .ImplementStateValidationRule());

            // Guns
            TargetField.SectionName      = GenericSectionName.GUNS;
            AssociatedField1.SectionName = GenericSectionName.GUNS;
            ValidationMessage            =
                new ValidationMessage(
                    string.Format("{0} can only be entered when {1} is 'Recovered' or 'Stolen/Recovered'", TargetFieldLabel,
                                  AssociatedField1Label), "recoveredValue");

            ValidationRule
                = new Validation(ValidationMessage, TargetField)
                  .NotRequired()
                  .WithConditions()
                  .DoesNotContain(AssociatedField1, new List <string> {
                "R", "SR"
            })
                  .RelatedOffenseRequired()
                  .ImplementStateValidationRule();

            UcrValidationRules.Add(Validation.CreateAssociatedRule(AssociatedField1, ValidationRule));
            UcrValidationRules.Add(
                new Validation(ValidationMessage, ValidationField.RelatedOffenseGuns()).ThatBroadcasts()
                .ImplementStateValidationRule());
            UcrValidationRules.Add(ValidationRule);

            // Vehicles
            TargetField.SectionName      = GenericSectionName.VEHICLES;
            AssociatedField1.SectionName = GenericSectionName.VEHICLES;
            ValidationMessage            =
                new ValidationMessage(
                    string.Format("{0} can only be entered when {1} is 'Recovered' or 'Stolen/Recovered'", TargetFieldLabel,
                                  AssociatedField1Label), "recoveredValue");

            ValidationRule
                = new Validation(ValidationMessage, TargetField)
                  .NotRequired()
                  .WithConditions()
                  .DoesNotContain(AssociatedField1, new List <string> {
                "R", "SR"
            })
                  .RelatedOffenseRequired()
                  .ImplementStateValidationRule();

            UcrValidationRules.Add(Validation.CreateAssociatedRule(AssociatedField1, ValidationRule));
            UcrValidationRules.Add(
                new Validation(ValidationMessage, ValidationField.RelatedOffenseVehicles()).ThatBroadcasts()
                .ImplementStateValidationRule());
            UcrValidationRules.Add(ValidationRule);

            #endregion

            #region RecoveryDateTime can only be entered when Status is R or SR

            TargetFieldLabel      = ResolveFieldLabel(TemplateReference, GenericSectionName.PROPERTY, "recoveryDateTime");
            AssociatedField1Label = ResolveFieldLabel(TemplateReference, GenericSectionName.PROPERTY, "status");

            ValidationMessage =
                new ValidationMessage(
                    string.Format("{0} can only be entered when {1} is 'Recovered' or 'Stolen/Recovered'", TargetFieldLabel,
                                  AssociatedField1Label), "recoveryDateTime");

            TargetField = new ValidationField
            {
                FieldPath   = "recoveryDateTime",
                SectionName = GenericSectionName.PROPERTY,
                ControlType = ControlType.Date,
            };

            AssociatedField1 = new ValidationField
            {
                FieldPath   = "status",
                SectionName = GenericSectionName.PROPERTY,
                ControlType = ControlType.Code,
            };

            ValidationRule
                = new Validation(ValidationMessage, TargetField)
                  .NotRequired()
                  .WithConditions()
                  .DoesNotContain(AssociatedField1, new List <string> {
                "R", "SR"
            })
                  .RelatedOffenseRequired()
                  .ImplementStateValidationRule();

            // Property
            UcrValidationRules.Add(ValidationRule);
            UcrValidationRules.Add(Validation.CreateAssociatedRule(AssociatedField1, ValidationRule));
            UcrValidationRules.Add(
                new Validation(ValidationMessage, ValidationField.RelatedOffenseProperty()).ThatBroadcasts()
                .ImplementStateValidationRule());

            // Guns
            TargetField.SectionName      = GenericSectionName.GUNS;
            AssociatedField1.SectionName = GenericSectionName.GUNS;
            ValidationMessage            =
                new ValidationMessage(
                    string.Format("{0} can only be entered when {1} is 'Recovered' or 'Stolen/Recovered'", TargetFieldLabel,
                                  AssociatedField1Label), "recoveryDateTime");

            ValidationRule
                = new Validation(ValidationMessage, TargetField)
                  .NotRequired()
                  .WithConditions()
                  .DoesNotContain(AssociatedField1, new List <string> {
                "R", "SR"
            })
                  .RelatedOffenseRequired()
                  .ImplementStateValidationRule();

            UcrValidationRules.Add(Validation.CreateAssociatedRule(AssociatedField1, ValidationRule));
            UcrValidationRules.Add(
                new Validation(ValidationMessage, ValidationField.RelatedOffenseGuns()).ThatBroadcasts()
                .ImplementStateValidationRule());
            UcrValidationRules.Add(ValidationRule);

            // Vehicles
            TargetField.SectionName      = GenericSectionName.VEHICLES;
            AssociatedField1.SectionName = GenericSectionName.VEHICLES;
            ValidationMessage            =
                new ValidationMessage(
                    string.Format("{0} can only be entered when {1} is 'Recovered' or 'Stolen/Recovered'", TargetFieldLabel,
                                  AssociatedField1Label), "recoveryDateTime");

            ValidationRule
                = new Validation(ValidationMessage, TargetField)
                  .NotRequired()
                  .WithConditions()
                  .DoesNotContain(AssociatedField1, new List <string> {
                "R", "SR"
            })
                  .RelatedOffenseRequired()
                  .ImplementStateValidationRule();

            UcrValidationRules.Add(Validation.CreateAssociatedRule(AssociatedField1, ValidationRule));
            UcrValidationRules.Add(
                new Validation(ValidationMessage, ValidationField.RelatedOffenseVehicles()).ThatBroadcasts()
                .ImplementStateValidationRule());
            UcrValidationRules.Add(ValidationRule);

            #endregion

            #region RecoveredDate must be entered when Status is R or SR

            TargetFieldLabel      = ResolveFieldLabel(TemplateReference, GenericSectionName.PROPERTY, "recoveryDateTime");
            AssociatedField1Label = ResolveFieldLabel(TemplateReference, GenericSectionName.PROPERTY, "status");

            ValidationMessage =
                new ValidationMessage(
                    string.Format("{0} must be entered when {1} is 'Recovered' or 'Stolen/Recovered'", TargetFieldLabel, AssociatedField1Label),
                    "recoveryDateTime");

            TargetField = new ValidationField
            {
                FieldPath   = "recoveryDateTime",
                SectionName = GenericSectionName.PROPERTY,
                ControlType = ControlType.Date,
            };

            AssociatedField1 = new ValidationField
            {
                FieldPath   = "status",
                SectionName = GenericSectionName.PROPERTY,
                ControlType = ControlType.Code,
            };

            ValidationRule
                = new Validation(ValidationMessage, TargetField)
                  .Required()
                  .WithConditions()
                  .Contains(AssociatedField1, new List <string> {
                "R", "SR"
            })
                  .RelatedOffenseRequired()
                  .ImplementStateValidationRule();

            // Property
            UcrValidationRules.Add(ValidationRule);
            UcrValidationRules.Add(Validation.CreateAssociatedRule(AssociatedField1, ValidationRule));
            UcrValidationRules.Add(
                new Validation(ValidationMessage, ValidationField.RelatedOffenseProperty()).ThatBroadcasts()
                .ImplementStateValidationRule());

            // Guns
            TargetField.SectionName      = GenericSectionName.GUNS;
            AssociatedField1.SectionName = GenericSectionName.GUNS;
            ValidationMessage            =
                new ValidationMessage(
                    string.Format("{0} must be entered when {1} is 'Recovered' or 'Stolen/Recovered'", TargetFieldLabel, AssociatedField1Label),
                    "recoveryDateTime");

            ValidationRule
                = new Validation(ValidationMessage, TargetField)
                  .Required()
                  .WithConditions()
                  .Contains(AssociatedField1, new List <string> {
                "R", "SR"
            })
                  .RelatedOffenseRequired()
                  .ImplementStateValidationRule();

            UcrValidationRules.Add(Validation.CreateAssociatedRule(AssociatedField1, ValidationRule));
            UcrValidationRules.Add(
                new Validation(ValidationMessage, ValidationField.RelatedOffenseGuns()).ThatBroadcasts()
                .ImplementStateValidationRule());
            UcrValidationRules.Add(ValidationRule);

            // Vehicles
            TargetField.SectionName      = GenericSectionName.VEHICLES;
            AssociatedField1.SectionName = GenericSectionName.VEHICLES;
            ValidationMessage            =
                new ValidationMessage(
                    string.Format("{0} must be entered when {1} is 'Recovered' or 'Stolen/Recovered'", TargetFieldLabel, AssociatedField1Label),
                    "recoveryDateTime");

            ValidationRule
                = new Validation(ValidationMessage, TargetField)
                  .Required()
                  .WithConditions()
                  .Contains(AssociatedField1, new List <string> {
                "R", "SR"
            })
                  .RelatedOffenseRequired()
                  .ImplementStateValidationRule();

            UcrValidationRules.Add(Validation.CreateAssociatedRule(AssociatedField1, ValidationRule));
            UcrValidationRules.Add(
                new Validation(ValidationMessage, ValidationField.RelatedOffenseVehicles()).ThatBroadcasts()
                .ImplementStateValidationRule());
            UcrValidationRules.Add(ValidationRule);

            #endregion

            #region EstimatedValue must be entered when Status is S or SR

            TargetFieldLabel      = ResolveFieldLabel(TemplateReference, GenericSectionName.VEHICLES, "estimatedValue");
            AssociatedField1Label = ResolveFieldLabel(TemplateReference, GenericSectionName.VEHICLES, "status");

            ValidationMessage =
                new ValidationMessage(
                    string.Format("{0} must be entered when {1} is 'Stolen' or 'Stolen/Recovered", TargetFieldLabel, AssociatedField1Label),
                    "estimatedValue");

            TargetField = new ValidationField
            {
                FieldPath   = "estimatedValue",
                SectionName = GenericSectionName.VEHICLES,
                ControlType = ControlType.Text,
            };

            AssociatedField1 = new ValidationField
            {
                FieldPath   = "status",
                SectionName = GenericSectionName.VEHICLES,
                ControlType = ControlType.Code,
            };

            ValidationRule
                = new Validation(ValidationMessage, TargetField)
                  .Required()
                  .WithConditions()
                  .Contains(AssociatedField1, new List <string> {
                "S", "SR"
            })
                  .RelatedOffenseRequired()
                  .ImplementStateValidationRule();

            UcrValidationRules.Add(ValidationRule);
            UcrValidationRules.Add(Validation.CreateAssociatedRule(AssociatedField1, ValidationRule));
            UcrValidationRules.Add(
                new Validation(ValidationMessage, ValidationField.RelatedOffenseProperty()).ThatBroadcasts()
                .ImplementStateValidationRule());

            #endregion

            #region VehicleRecovery must be entered when Status is R or SR

            TargetFieldLabel      = ResolveFieldLabel(TemplateReference, GenericSectionName.VEHICLES, "vehicleRecovery");
            AssociatedField1Label = ResolveFieldLabel(TemplateReference, GenericSectionName.VEHICLES, "status");

            ValidationMessage =
                new ValidationMessage(
                    string.Format("{0} must be entered when {1} is 'Recovered' or 'Stolen/Recovered'", TargetFieldLabel, AssociatedField1Label),
                    "vehicleRecovery");

            TargetField = new ValidationField
            {
                FieldPath   = "vehicleRecovery",
                SectionName = GenericSectionName.VEHICLES,
                ControlType = ControlType.Code
            };

            AssociatedField1 = new ValidationField
            {
                FieldPath   = "status",
                SectionName = GenericSectionName.VEHICLES,
                ControlType = ControlType.Code,
            };

            ValidationRule
                = new Validation(ValidationMessage, TargetField)
                  .Required()
                  .WithConditions()
                  .Contains(AssociatedField1, new List <string> {
                "R", "SR"
            })
                  .RelatedOffenseRequired()
                  .ImplementStateValidationRule();

            UcrValidationRules.Add(ValidationRule);
            UcrValidationRules.Add(Validation.CreateAssociatedRule(AssociatedField1, ValidationRule));
            UcrValidationRules.Add(
                new Validation(ValidationMessage, ValidationField.RelatedOffenseProperty()).ThatBroadcasts()
                .ImplementStateValidationRule());

            #endregion

            #region Person Number cannot be blank (Suspect)

            UcrValidationRules.Add(
                new Validation(
                    new ValidationMessage
            {
                Message =
                    string.Format("{0} is required",
                                  ResolveFieldLabel(TemplateReference, GenericSectionName.SUSPECTS, "personNumber")),
                TargetPath = "personNumber"
            },
                    new ValidationField
            {
                FieldPath   = "personNumber",
                SectionName = GenericSectionName.SUSPECTS,
                ControlType = ControlType.Text
            })
                .Required().ImplementStateValidationRule());

            #endregion

            #region Person Number cannot be 0 (Victim)

            // this rule was broken in 2 rules to handle more than one operation
            TargetFieldLabel = ResolveFieldLabel(TemplateReference, GenericSectionName.VICTIMS, "personNumber");


            ValidationMessage = new ValidationMessage(string.Format("{0} cannot be '0'", TargetFieldLabel),
                                                      "personNumber");

            TargetField = new ValidationField
            {
                FieldPath   = "personNumber",
                SectionName = GenericSectionName.VICTIMS,
                ControlType = ControlType.Text
            };

            ValidationRule =
                new Validation(ValidationMessage, TargetField)
                .Comparison(ValidationOperand.NotEqual, "0")
                .ImplementStateValidationRule();

            UcrValidationRules.Add(ValidationRule);

            #endregion

            #region 'If Person Number is Not 0, Age or Sex or Race Must be Known

            TargetFieldLabel = ResolveFieldLabel(TemplateReference, GenericSectionName.VICTIMS, "personNumber");
            var ageLabel  = ResolveFieldLabel(TemplateReference, GenericSectionName.VICTIMS, "age");
            var raceLabel = ResolveFieldLabel(TemplateReference, GenericSectionName.VICTIMS, "race");
            var sexLabel  = ResolveFieldLabel(TemplateReference, GenericSectionName.VICTIMS, "sex");

            ValidationMessage = new ValidationMessage(string.Format("If {0} is Not 0, {1} or {2} or {3} Must be Known", TargetFieldLabel, ageLabel, raceLabel, sexLabel),
                                                      "personNumber");

            TargetField = new ValidationField
            {
                FieldPath   = "personNumber",
                SectionName = GenericSectionName.VICTIMS,
                ControlType = ControlType.Text
            };
            var AgeField = new ValidationField
            {
                FieldPath   = "age",
                SectionName = GenericSectionName.VICTIMS,
                ControlType = ControlType.Code
            };
            var RaceField = new ValidationField
            {
                FieldPath   = "race",
                SectionName = GenericSectionName.VICTIMS,
                ControlType = ControlType.Code
            };
            var SexField = new ValidationField
            {
                FieldPath   = "sex",
                SectionName = GenericSectionName.VICTIMS,
                ControlType = ControlType.Code
            };

            ValidationRule =
                new Validation(ValidationMessage, TargetField)
                .Comparison(ValidationOperand.Equal, "0")
                .WithConditions()
                .NotRequired(AgeField)
                .NotRequired(SexField)
                .NotRequired(RaceField)
                .ThatBroadcasts()
                .ImplementStateValidationRule();

            UcrValidationRules.Add(ValidationRule);
            UcrValidationRules.Add(Validation.CreateAssociatedRule(AgeField, ValidationRule));
            UcrValidationRules.Add(Validation.CreateAssociatedRule(RaceField, ValidationRule));
            UcrValidationRules.Add(Validation.CreateAssociatedRule(SexField, ValidationRule));
            #endregion

            #region Status must be entered (Property, Guns)

            TargetFieldLabel = ResolveFieldLabel(TemplateReference, GenericSectionName.PROPERTY, "status");

            ValidationMessage = new ValidationMessage(string.Format("Must Enter {0}", TargetFieldLabel), "status");

            TargetField = new ValidationField
            {
                FieldPath   = "status",
                SectionName = GenericSectionName.PROPERTY,
                ControlType = ControlType.Code,
            };

            ValidationRule
                = new Validation(ValidationMessage, TargetField)
                  .Required()
                  .WithConditions()
                  .ThatBroadcasts()
                  .RelatedOffenseRequired()
                  .ImplementStateValidationRule();

            // Property
            UcrValidationRules.Add(ValidationRule);
            UcrValidationRules.Add(
                new Validation(ValidationMessage, ValidationField.RelatedOffenseProperty()).ThatBroadcasts()
                .ImplementStateValidationRule());

            // Guns
            TargetField.SectionName = GenericSectionName.GUNS;
            ValidationMessage       = new ValidationMessage(string.Format("Must Enter {0}", TargetFieldLabel), "status");

            ValidationRule
                = new Validation(ValidationMessage, TargetField)
                  .Required()
                  .WithConditions()
                  .RelatedOffenseRequired()
                  .ThatBroadcasts()
                  .ImplementStateValidationRule();

            UcrValidationRules.Add(ValidationRule);
            UcrValidationRules.Add(
                new Validation(ValidationMessage, ValidationField.RelatedOffenseGuns()).ThatBroadcasts()
                .ImplementStateValidationRule());

            #endregion

            #region Type must be entered (Property, Guns)

            TargetFieldLabel = ResolveFieldLabel(TemplateReference, GenericSectionName.PROPERTY, "type");

            ValidationMessage = new ValidationMessage(string.Format("{0} is required", TargetFieldLabel), "type");

            TargetField = new ValidationField
            {
                FieldPath   = "type",
                SectionName = GenericSectionName.PROPERTY,
                ControlType = ControlType.Code,
            };

            ValidationRule
                = new Validation(ValidationMessage, TargetField)
                  .Required()
                  .WithConditions()
                  .RelatedOffenseRequired()
                  .ThatBroadcasts()
                  .ImplementStateValidationRule();

            // Property
            UcrValidationRules.Add(ValidationRule);
            UcrValidationRules.Add(
                new Validation(ValidationMessage, ValidationField.RelatedOffenseProperty()).ThatBroadcasts()
                .ImplementStateValidationRule());

            // Guns
            TargetField.SectionName = GenericSectionName.GUNS;
            ValidationMessage       = new ValidationMessage(string.Format("{0} is required", TargetFieldLabel), "type");

            ValidationRule
                = new Validation(ValidationMessage, TargetField)
                  .Required()
                  .WithConditions()
                  .RelatedOffenseRequired()
                  .ThatBroadcasts()
                  .ImplementStateValidationRule();

            UcrValidationRules.Add(ValidationRule);
            UcrValidationRules.Add(
                new Validation(ValidationMessage, ValidationField.RelatedOffenseGuns()).ThatBroadcasts()
                .ImplementStateValidationRule());

            #endregion

            #region Must Enter a Weapon if UCR Class is 01a

            TargetFieldLabel = ResolveFieldLabel(TemplateReference, GenericSectionName.OFFENSES, "weaponTypes");
            ucrClassList     = new List <string>()
            {
                "01"
            };
            ucrSubclassList = new List <string>()
            {
                "a."
            };
            ValidationMessage =
                new ValidationMessage(
                    string.Format("If UCR code is 01a, Weapon Must Be Entered", TargetFieldLabel),
                    "weaponTypes");

            TargetField = new ValidationField
            {
                FieldPath   = "weaponTypes",
                SectionName = GenericSectionName.OFFENSES,
                ControlType = ControlType.Multiselect,
            };

            ValidationRule =
                new Validation(ValidationMessage, TargetField)
                .Required()
                .WithConditions()
                .Contains(ValidationField.ViolationCodeOffenses(ucrClassProperty), ucrClassList)
                .Contains(ValidationField.ViolationCodeOffenses(ucrSubclassProperty), ucrSubclassList)
                .ImplementStateValidationRule();

            UcrValidationRules.Add(ValidationRule);
            UcrValidationRules.Add(Validation.CreateAssociatedRule(ValidationField.ViolationCodeOffenses(), ValidationRule));

            #endregion

            #region Cannot enter a Weapon if UCR Class is 24

            TargetFieldLabel = ResolveFieldLabel(TemplateReference, GenericSectionName.OFFENSES, "weaponTypes");
            ucrClassList     = new List <string>()
            {
                "24"
            };
            ValidationMessage =
                new ValidationMessage(string.Format("Cannot enter a {0} if UCR Class is '24'", TargetFieldLabel),
                                      "weaponTypes");

            TargetField = new ValidationField
            {
                FieldPath   = "weaponTypes",
                SectionName = GenericSectionName.OFFENSES,
                ControlType = ControlType.Multiselect,
            };


            ValidationRule =
                new Validation(ValidationMessage, TargetField)
                .NotRequired()
                .WithConditions()
                .Contains(ValidationField.ViolationCodeOffenses(ucrClassProperty), ucrClassList)
                .ImplementStateValidationRule();

            UcrValidationRules.Add(ValidationRule);
            UcrValidationRules.Add(Validation.CreateAssociatedRule(ValidationField.ViolationCodeOffenses(), ValidationRule));

            #endregion

            #region WeaponTypes must be 06 when ViolationCode has a UCR Class of 04 and Subclass of b -- per PM, needs to fire when no weapon is entered as well

            TargetFieldLabel      = ResolveFieldLabel(TemplateReference, GenericSectionName.OFFENSES, "weaponTypes");
            AssociatedField1Label = ResolveFieldLabel(TemplateReference, GenericSectionName.OFFENSES, "violationCodeReference");

            classList = new List <string> {
                "06"
            };
            ucrClassList = new List <string> {
                "04"
            };
            ucrSubclassList = new List <string> {
                "b."
            };

            ValidationMessage = new ValidationMessage(string.Format("If UCR code is 04b, the weapon must be 'Knife or other cutting or stabbing instrument'"), "weaponTypes");

            TargetField = new ValidationField
            {
                FieldPath   = "weaponTypes",
                SectionName = GenericSectionName.OFFENSES,
                ControlType = ControlType.Multiselect,
            };

            ValidationRule = new Validation(ValidationMessage, TargetField)
                             .Required()
                             .WithConditions()
                             .Contains(ValidationField.ViolationCodeOffenses(ucrClassProperty), ucrClassList)
                             .Contains(ValidationField.ViolationCodeOffenses(ucrSubclassProperty), ucrSubclassList)
                             .ThatBroadcasts()
                             .ImplementStateValidationRule();

            UcrValidationRules.Add(ValidationRule);
            UcrValidationRules.Add(new Validation(ValidationMessage, ValidationField.ViolationCodeOffenses()).ThatBroadcasts().ImplementStateValidationRule());
            #endregion
        }
예제 #10
0
        private void SetRequired()
        {
            #region Arrest Disposition must be entered when the Juvenile dropdown is set to no

            TargetFieldLabel      = ResolveFieldLabel(TemplateReference, GenericSectionName.EVENT, "arrestDisposition");
            AssociatedField1Label = ResolveFieldLabel(TemplateReference, GenericSectionName.EVENT, "juvenile");

            ValidationMessage = new ValidationMessage(string.Format("{0} is required for adult arrests", TargetFieldLabel, AssociatedField1Label), "arrestDisposition");

            TargetField = new ValidationField
            {
                FieldPath   = "arrestDisposition",
                FieldType   = FieldType.Extended,
                SectionName = GenericSectionName.EVENT,
                ControlType = ControlType.Code,
            };

            AssociatedField1 = new ValidationField
            {
                FieldPath   = "juvenile",
                SectionName = GenericSectionName.EVENT,
                ControlType = ControlType.Code,
            };


            ValidationRule =
                new Validation(ValidationMessage, TargetField)
                .Required()
                .WithConditions()
                .Contains(AssociatedField1, new List <string> {
                "N"
            })
                .ImplementStateValidationRule();

            UcrValidationRules.Add(ValidationRule);
            UcrValidationRules.Add(Validation.CreateAssociatedRule(AssociatedField1, ValidationRule));


            #endregion

            #region Must enter arresting agency name

            TargetFieldLabel = ResolveFieldLabel(TemplateReference, GenericSectionName.EVENT, "arrestingAgencyName");

            ValidationMessage = new ValidationMessage(string.Format("{0} is required", TargetFieldLabel), "arrestingAgencyName");

            TargetField = new ValidationField
            {
                FieldPath   = "arrestingAgencyName",
                SectionName = GenericSectionName.EVENT,
                ControlType = ControlType.Text,
            };

            ValidationRule =
                new Validation(ValidationMessage, TargetField)
                .Required()
                .ImplementStateValidationRule();

            UcrValidationRules.Add(ValidationRule);

            #endregion

            #region Must enter felony/misdemeanor

            TargetFieldLabel = ResolveFieldLabel(TemplateReference, GenericSectionName.ARREST_CHARGES, "felonyMisdemeanor");

            ValidationMessage = new ValidationMessage(string.Format("{0} is required", TargetFieldLabel), "felonyMisdemeanor");

            TargetField = new ValidationField
            {
                FieldPath   = "felonyMisdemeanor",
                SectionName = GenericSectionName.ARREST_CHARGES,
                ControlType = ControlType.Code,
            };

            ValidationRule =
                new Validation(ValidationMessage, TargetField)
                .Required()
                .ImplementStateValidationRule();

            UcrValidationRules.Add(ValidationRule);

            #endregion

            #region Must enter law enforcement disposition

            TargetFieldLabel = ResolveFieldLabel(TemplateReference, GenericSectionName.ARREST_CHARGES, "lawEnforcementDisposition");

            ValidationMessage = new ValidationMessage(string.Format("{0} is required", TargetFieldLabel), "lawEnforcementDisposition");

            TargetField = new ValidationField
            {
                FieldPath   = "lawEnforcementDisposition",
                SectionName = GenericSectionName.ARREST_CHARGES,
                ControlType = ControlType.Code,
            };

            ValidationRule =
                new Validation(ValidationMessage, TargetField)
                .Required()
                .ImplementStateValidationRule();

            UcrValidationRules.Add(ValidationRule);

            #endregion
        }
예제 #11
0
        private void SetContains()
        {
            #region Sex must be M or F

            TargetFieldLabel = ResolveFieldLabel(TemplateReference, GenericSectionName.ARRESTEE, "sex");

            UcrValidationRules.Add(new Validation(
                                       new ValidationMessage
            {
                Message    = string.Format("{0} must be M or F", TargetFieldLabel),
                TargetPath = "sex"
            },
                                       new ValidationField
            {
                FieldPath   = "sex",
                SectionName = GenericSectionName.ARRESTEE,
                ControlType = ControlType.Code,
            }).Contains(new List <string> {
                "M", "F"
            }).ImplementStateValidationRule());

            #endregion

            #region Arrestee race cannot be U-Unknown

            TargetFieldLabel = ResolveFieldLabel(TemplateReference, GenericSectionName.ARRESTEE, "race");

            UcrValidationRules.Add(new Validation(
                                       new ValidationMessage
            {
                Message    = string.Format("Arrestee {0} cannot be U-Unknown", TargetFieldLabel),
                TargetPath = "race"
            },
                                       new ValidationField
            {
                FieldPath   = "race",
                SectionName = GenericSectionName.ARRESTEE,
                ControlType = ControlType.Code,
            }).DoesNotContain(new List <string> {
                "X"
            }).ImplementStateValidationRule());

            #endregion

            #region Law Enforcement Disposition cannot be "Felonies" if Fel/Mis is "M


            TargetFieldLabel      = ResolveFieldLabel(TemplateReference, GenericSectionName.ARREST_CHARGES, "lawEnforcementDisposition");
            AssociatedField1Label = ResolveFieldLabel(TemplateReference, GenericSectionName.ARREST_CHARGES, "felonyMisdemeanor");

            ValidationMessage = new ValidationMessage(string.Format("{0} cannot be 'Felonies' if {1} is 'Misdemeanor'", TargetFieldLabel, AssociatedField1Label), "lawEnforcementDisposition");

            TargetField = new ValidationField
            {
                FieldPath   = "lawEnforcementDisposition",
                SectionName = GenericSectionName.ARREST_CHARGES,
                ControlType = ControlType.Code,
            };

            AssociatedField1 = new ValidationField
            {
                FieldPath   = "felonyMisdemeanor",
                SectionName = GenericSectionName.ARREST_CHARGES,
                ControlType = ControlType.Code,
            };

            ValidationRule =
                new Validation(ValidationMessage, TargetField)
                .DoesNotContain(new List <string> {
                "4"
            })                                               //FELONIES
                .WithConditions()
                .Contains(AssociatedField1, new List <string> {
                "2"
            })                                                            //MISDEMEANOR
                .ImplementStateValidationRule();

            UcrValidationRules.Add(ValidationRule);
            UcrValidationRules.Add(Validation.CreateAssociatedRule(AssociatedField1, ValidationRule));

            #endregion

            #region Law Enforcement Disposition cannot be "Misdemeanors" if Fel/Mis is "F


            TargetFieldLabel      = ResolveFieldLabel(TemplateReference, GenericSectionName.ARREST_CHARGES, "lawEnforcementDisposition");
            AssociatedField1Label = ResolveFieldLabel(TemplateReference, GenericSectionName.ARREST_CHARGES, "felonyMisdemeanor");

            ValidationMessage = new ValidationMessage(string.Format("{0} cannot be 'Misdemeanors' if {1} is 'Felony'", TargetFieldLabel, AssociatedField1Label), "lawEnforcementDisposition");

            TargetField = new ValidationField
            {
                FieldPath   = "lawEnforcementDisposition",
                FieldType   = FieldType.Extended,
                SectionName = GenericSectionName.ARREST_CHARGES,
                ControlType = ControlType.Code,
            };

            AssociatedField1 = new ValidationField
            {
                FieldPath   = "felonyMisdemeanor",
                SectionName = GenericSectionName.ARREST_CHARGES,
                ControlType = ControlType.Code,
            };

            ValidationRule =
                new Validation(ValidationMessage, TargetField)
                .DoesNotContain(new List <string> {
                "3"
            })                                               //MISDEMEANORS
                .WithConditions()
                .Contains(AssociatedField1, new List <string> {
                "3"
            })                                                            //FELONY
                .ImplementStateValidationRule();

            UcrValidationRules.Add(ValidationRule);
            UcrValidationRules.Add(Validation.CreateAssociatedRule(AssociatedField1, ValidationRule));

            #endregion

            #region Law Enforcement Disposition must be 2, 4, 5 for Juveniles


            TargetFieldLabel      = ResolveFieldLabel(TemplateReference, GenericSectionName.ARREST_CHARGES, "lawEnforcementDisposition");
            AssociatedField1Label = ResolveFieldLabel(TemplateReference, GenericSectionName.EVENT, "juvenile");

            ValidationMessage = new ValidationMessage(string.Format("{0} for Juveniles can only be Turned Over, Juvenile Court, or Department", TargetFieldLabel), "lawEnforcementDisposition");

            TargetField = new ValidationField
            {
                FieldPath   = "lawEnforcementDisposition",
                FieldType   = FieldType.Extended,
                SectionName = GenericSectionName.ARREST_CHARGES,
                ControlType = ControlType.Code,
            };

            AssociatedField1 = new ValidationField
            {
                FieldPath   = "juvenile",
                SectionName = GenericSectionName.EVENT,
                ControlType = ControlType.Code,
            };

            ValidationRule =
                new Validation(ValidationMessage, TargetField)
                .Contains(new List <string> {
                "2", "5", "6"
            })                                                   //TURNED OVER, JUVENILE COURT, DEPARTMENT
                .WithConditions()
                .Contains(AssociatedField1, new List <string> {
                "Y"
            })                                                            //JUVENILE
                .ImplementStateValidationRule();

            UcrValidationRules.Add(ValidationRule);
            UcrValidationRules.Add(Validation.CreateAssociatedRule(AssociatedField1, ValidationRule));

            #endregion
        }
예제 #12
0
        private void SetRequired()
        {
            #region Race is required

            UcrValidationRules.Add(
                new Validation(
                    new ValidationMessage
                    {
                        Message = string.Format("{0} is required", ResolveFieldLabel(TemplateReference, GenericSectionName.ARRESTEE, "race")),
                        TargetPath = "race"
                    },
                    new ValidationField
                    {
                        FieldPath = "race",
                        SectionName = GenericSectionName.ARRESTEE,
                        ControlType = ControlType.Code
                    })
                    .Required().ImplementStateValidationRule());

            #endregion

            #region Sex is required

            UcrValidationRules.Add(
                new Validation(
                    new ValidationMessage
                    {
                        Message = string.Format("{0} is required", ResolveFieldLabel(TemplateReference, GenericSectionName.ARRESTEE, "sex")),
                        TargetPath = "sex"
                    },
                    new ValidationField
                    {
                        FieldPath = "sex",
                        SectionName = GenericSectionName.ARRESTEE,
                        ControlType = ControlType.Code
                    })
                    .Required().ImplementStateValidationRule());

            #endregion

            #region Age is required

            UcrValidationRules.Add(
                new Validation(
                    new ValidationMessage
                    {
                        Message = string.Format("{0} is required", ResolveFieldLabel(TemplateReference, GenericSectionName.ARRESTEE, "age")),
                        TargetPath = "age"
                    },
                    new ValidationField
                    {
                        FieldPath = "age",
                        SectionName = GenericSectionName.ARRESTEE,
                        ControlType = ControlType.Code
                    })
                    .Required().ImplementStateValidationRule());

            #endregion

            #region Ethnicity is required

            UcrValidationRules.Add(
                new Validation(
                    new ValidationMessage
                    {
                        Message = string.Format("{0} is required", ResolveFieldLabel(TemplateReference, GenericSectionName.ARRESTEE, "ethnicity")),
                        TargetPath = "ethnicity"
                    },
                    new ValidationField
                    {
                        FieldPath = "ethnicity",
                        SectionName = GenericSectionName.ARRESTEE,
                        ControlType = ControlType.Code
                    })
                    .Required().ImplementStateValidationRule());

            #endregion

            #region Must Enter Arrest Date

            UcrValidationRules.Add(
                new Validation(
                    new ValidationMessage
                    {
                        Message = string.Format("Must enter {0}", ResolveFieldLabel(TemplateReference, GenericSectionName.EVENT, "startDate")),
                        TargetPath = "startDate"
                    },
                    new ValidationField
                    {
                        FieldPath = "startDate",
                        SectionName = GenericSectionName.EVENT,
                        ControlType = ControlType.Date
                    })
                    .Required().ImplementStateValidationRule());

            #endregion

            #region Juvenile Disposition must be entered when the Juvenile dropdown is set to yes

            TargetFieldLabel = ResolveFieldLabel(TemplateReference, GenericSectionName.EVENT, "dispositionUnder18");
            AssociatedField1Label = ResolveFieldLabel(TemplateReference, GenericSectionName.EVENT, "juvenile");

            ValidationMessage = new ValidationMessage(string.Format("{0} is required for juvenile arrests", TargetFieldLabel, AssociatedField1Label), "dispositionUnder18");

            TargetField = new ValidationField
            {
                FieldPath = "dispositionUnder18",
                SectionName = GenericSectionName.EVENT,
                ControlType = ControlType.Code,
            };

            AssociatedField1 = new ValidationField
            {
                FieldPath = "juvenile",
                SectionName = GenericSectionName.EVENT,
                ControlType = ControlType.Code,
            };


            ValidationRule =
                new Validation(ValidationMessage, TargetField)
                    .Required()
                    .WithConditions()
                    .Contains(AssociatedField1, new List<string> { "Y" })
                    .ImplementStateValidationRule();

            UcrValidationRules.Add(ValidationRule);

            UcrValidationRules.Add(new Validation(ValidationMessage,
                                                    AssociatedField1).ThatBroadcasts().SetRuleImplementation(RuleImplementation)
                                                                                            .ImplementStateValidationRule());


            #endregion

            #region Offense field is required (Charge)

            UcrValidationRules.Add(
                new Validation(
                    new ValidationMessage
                    {
                        Message = string.Format("Must enter {0}", ResolveFieldLabel(TemplateReference, GenericSectionName.ARREST_CHARGES, "violationCodeReference")),
                        TargetPath = "violationCodeReference"
                    },
                    new ValidationField
                    {
                        FieldPath = "violationCodeReference",
                        SectionName = GenericSectionName.ARREST_CHARGES,
                        ControlType = ControlType.Offense
                    })
                    .AlwaysShowMessage()
                    .Required()
                    .ImplementStateValidationRule());

            #endregion
        }
예제 #13
0
        private void SetCustoms()
        {
            #region Juv Custody Age Must Be Less Than or Equal to (JUVENILE AGE)

            TargetFieldLabel = ResolveFieldLabel(TemplateReference, GenericSectionName.ARRESTEE, "age");
            AssociatedField1Label = ResolveFieldLabel(TemplateReference, GenericSectionName.ARRESTEE, "age2");
            AssociatedField2Label = ResolveFieldLabel(TemplateReference, GenericSectionName.EVENT, "juvenile");

            ValidationMessage = new ValidationMessage(string.Format("Juvenile Custody {0} Must Be Less Than or Equal to maximum juvenile age", TargetFieldLabel), "age"); 

            TargetField = new ValidationField
            {
                FieldPath = "age",
                SectionName = GenericSectionName.ARRESTEE,
                ControlType = ControlType.Code,
            };

            AssociatedField1 = new ValidationField
            {
                FieldPath = "age2",
                SectionName = GenericSectionName.ARRESTEE,
                ControlType = ControlType.Text,
            };

            AssociatedField2 = new ValidationField
            {
                FieldPath = "juvenile",
                SectionName = GenericSectionName.EVENT,
                ControlType = ControlType.Code,
            };

            ValidationRule =
                new Validation(ValidationMessage, TargetField)
                    .CustomValidation("juvenileCustodyAgeMustBeLessThanOrEqualToJuvenileAge")
                    .ThatBroadcasts()
                    .ThatSelfEvaluates()
                    .SetRuleImplementation(RuleImplementation)
                    .ImplementStateValidationRule();


            UcrValidationRules.Add(ValidationRule);

            UcrValidationRules.Add(new Validation(ValidationMessage,
                                                    AssociatedField1).ThatBroadcasts().SetRuleImplementation(RuleImplementation)
                                                                                            .ImplementStateValidationRule());

            UcrValidationRules.Add(new Validation(ValidationMessage,
                                                    AssociatedField2).ThatBroadcasts().SetRuleImplementation(RuleImplementation)
                                                                                            .ImplementStateValidationRule());

            #endregion

            #region Adult Arrestee Age Must Be Greater Than (JUVENILE AGE)

            TargetFieldLabel = ResolveFieldLabel(TemplateReference, GenericSectionName.ARRESTEE, "age");
            AssociatedField1Label = ResolveFieldLabel(TemplateReference, GenericSectionName.ARRESTEE, "age2");
            AssociatedField2Label = ResolveFieldLabel(TemplateReference, GenericSectionName.EVENT, "juvenile");


            ValidationMessage = new ValidationMessage(string.Format("Adult Arrestee {0} Must Be Greater Than maximum juvenile age", TargetFieldLabel), "age");

            TargetField = new ValidationField
            {
                FieldPath = "age",
                SectionName = GenericSectionName.ARRESTEE,
                ControlType = ControlType.Code,
            };

            AssociatedField1 = new ValidationField
            {
                FieldPath = "age2",
                SectionName = GenericSectionName.ARRESTEE,
                ControlType = ControlType.Text,
            };

            AssociatedField2 = new ValidationField
            {
                FieldPath = "juvenile",
                SectionName = GenericSectionName.EVENT,
                ControlType = ControlType.Code,
            };

            ValidationRule =
                new Validation(ValidationMessage, TargetField).CustomValidation(
                    "adultArresteeAgeMustBeGreaterThanJuvenileAge")
                    .ThatSelfEvaluates()
                    .ThatBroadcasts()
                    .SetRuleImplementation(RuleImplementation)
                    .ImplementStateValidationRule();

            UcrValidationRules.Add(ValidationRule);

            UcrValidationRules.Add(new Validation(ValidationMessage,
                                                    AssociatedField1).ThatBroadcasts().SetRuleImplementation(RuleImplementation)
                                                                                            .ImplementStateValidationRule());

            UcrValidationRules.Add(new Validation(ValidationMessage,
                                                    AssociatedField2).ThatBroadcasts().SetRuleImplementation(RuleImplementation)
                                                                                            .ImplementStateValidationRule());

            #endregion
        }
예제 #14
0
        public void SetComparisons()
        {
            #region Age must be 01-99 or 00 for unknown

            TargetFieldLabel = ResolveFieldLabel(TemplateReference, GenericSectionName.ARRESTEE, "age");

            ValidationMessage = new ValidationMessage(string.Format("{0} Must Be Numeric if Not from the List", TargetFieldLabel), "age");

            TargetField = new ValidationField
            {
                FieldPath = "age",
                SectionName = GenericSectionName.ARRESTEE,
                ControlType = ControlType.Code
            };

            // Adding "1-6 DAYS OLD", "7-364 DAYS OLD" and "UNDER 24 HOURS" values
            var contains = new List<string> { "NB", "BB", "NN" };

            // Adding "0" to "9" values
            for (var i = 0; i < 10; i++)
                contains.Add(Convert.ToString(i));

            // Adding "00" to "99" values
            for (var i = 0; i < 100; i++)
                contains.Add(i.ToString("00"));

            UcrValidationRules.Add(new Validation(ValidationMessage, TargetField).Contains(contains).ImplementStateValidationRule());

            #endregion

            #region Age2 must be greater than Age

            TargetFieldLabel = ResolveFieldLabel(TemplateReference, GenericSectionName.ARRESTEE, "age2");
            AssociatedField1Label = ResolveFieldLabel(TemplateReference, GenericSectionName.ARRESTEE, "age");

            ValidationMessage = new ValidationMessage
            {
                Message = string.Format("{0} must be greater than {1}", TargetFieldLabel, AssociatedField1Label),
                TargetPath = "age2"
            };

            TargetField = new ValidationField
            {

                FieldPath = "age2", //age
                SectionName = GenericSectionName.ARRESTEE,
                ControlType = ControlType.Text, //Text
                Mask = Mask.None,
                CompareToMask = Mask.None
            };

            AssociatedField1 = new ValidationField
            {
                FieldPath = "age",  //age2
                SectionName = GenericSectionName.ARRESTEE,
                ControlType = ControlType.Code,
                Mask = Mask.None,
                CompareToMask = Mask.None
            };

            ValidationRule = new Validation(ValidationMessage, TargetField)
            .Comparison(ValidationOperand.GreaterThan)
            .ImplementStateValidationRule();

            UcrValidationRules.Add(ValidationRule);
            UcrValidationRules.Add(Validation.CreateAssociatedRule(AssociatedField1, ValidationRule));

            #endregion

        }