Ejemplo n.º 1
0
        internal static void AssertCredentialsValidation(IDataValidator validator, ICredentialSet credentailSet, int expectedErrorsCount)
        {
            credentailSet.Name = LongText;
            var results = validator.Validate(credentailSet);

            Assert.AreEqual(expectedErrorsCount, results.Count(), "CredentailSet validation failed");
        }
Ejemplo n.º 2
0
 public TransactionFromXMLParser(
     IDataValidator dataValidator,
     ILogger logger)
 {
     _dataValidator = dataValidator;
     _logger        = logger;
 }
Ejemplo n.º 3
0
        internal static void AssertNameOnlyValidation(IDataValidator validator, IGroup group)
        {
            ValidationStates results = validator.ValidateNameProperty(group);

            Assert.AreEqual(1, results.Count(), "Group name validation failed");
            Assert.AreEqual(Validations.NAME_PROPERTY, results.First().PropertyName, "Failed property is not a 'Name'");
        }
Ejemplo n.º 4
0
 internal ImportWithDialogs(IImportUi importUi, IPersistence persistence, ConnectionManager connectionManager)
 {
     this.importUi          = importUi;
     this.persistence       = persistence;
     this.validator         = persistence.Factory.CreateValidator();
     this.connectionManager = connectionManager;
 }
Ejemplo n.º 5
0
        internal static void AssertGroupValidation(IDataValidator validator, IGroup group)
        {
            group.Name = String.Empty;
            var results = validator.Validate(group);

            Assert.AreEqual(1, results.Count, "Group name validation failed");
        }
Ejemplo n.º 6
0
 public AccountCommand(
     IRepositoryManager repositoryManager,
     IDataValidator dataValidator,
     IMapper mapper
     ) : base(repositoryManager, dataValidator, mapper)
 {
 }
Ejemplo n.º 7
0
 public UserService(IEntityRepository <Entities.User> userRepo, IEntityRepository <Entities.UserOperation> operationRepo,
                    IDataValidator dataValidator, ICalculator calculator)
 {
     _userRepo      = userRepo;
     _operationRepo = operationRepo;
     _dataValidator = dataValidator;
     _calculator    = calculator;
 }
Ejemplo n.º 8
0
        }                                        //TODO: Localize??

        public DataValidation(string Name, string Description, IDataValidator Validator, IDataValidationSettings ValidationSettings, string ErrorMessage)
        {
            this.Name               = Name;
            this.Description        = Description;
            this.Validator          = Validator;
            this.ValidationSettings = ValidationSettings;
            this.ErrorMessage       = ErrorMessage;
        }
Ejemplo n.º 9
0
 public NewTerminalFormValidator(IPersistence persistence, ConnectionManager connectionManager, INewTerminalForm form)
 {
     this.persistence       = persistence;
     this.validator         = persistence.Factory.CreateValidator();
     this.nameValidator     = new FavoriteNameValidator(persistence);
     this.form              = form;
     this.connectionManager = connectionManager;
 }
Ejemplo n.º 10
0
        public ShellViewModel(IEmployeeService employeeService, IDataValidator dataValidator, ISerializeService serializeService)
        {
            _employeeService  = employeeService;
            _dataValidator    = dataValidator;
            _serializeService = serializeService;

            Populate();
        }
Ejemplo n.º 11
0
 public Command(
     IRepositoryManager repositoryManager,
     IDataValidator dataValidator,
     IMapper mapper
     ) : base(repositoryManager, mapper)
 {
     _dataValidator = dataValidator;
 }
Ejemplo n.º 12
0
 public static void NoEvidence(IWrapper wrapper, IDataValidator validator)
 {
     using (var data = wrapper.Pipeline.CreateFlowData())
     {
         data.Process();
         validator.ValidateData(data, false);
     }
 }
Ejemplo n.º 13
0
        public DataRepository(IDataValidator iDataValidator, IPoint iPoint)
        {
            PointsByX           = new List <Point>();
            this.iPoint         = iPoint;
            this.iDataValidator = iDataValidator;

            DataSort();
        }
Ejemplo n.º 14
0
 public static void CaseInsensitiveEvidenceKeys(IWrapper wrapper, IDataValidator validator)
 {
     using (var data = wrapper.Pipeline.CreateFlowData())
     {
         data.AddEvidence("header.USER-AGENT", Constants.MobileUserAgent)
         .Process();
         validator.ValidateData(data);
     }
 }
Ejemplo n.º 15
0
 public static void NoUsefulHeaders(IWrapper wrapper, IDataValidator validator)
 {
     using (var data = wrapper.Pipeline.CreateFlowData())
     {
         data.AddEvidence("header.irrelevant-header", "some evidence")
         .Process();
         validator.ValidateData(data, false);
     }
 }
Ejemplo n.º 16
0
 public static void EmptyUserAgent(IWrapper wrapper, IDataValidator validator)
 {
     using (var data = wrapper.Pipeline.CreateFlowData())
     {
         data.AddEvidence("header.user-agent", "")
         .Process();
         validator.ValidateData(data, false);
     }
 }
Ejemplo n.º 17
0
 public Repository(IJsonReader jsonReader, IDataValidator <T> dataValidator)
 {
     //string appDir = System.AppContext.BaseDirectory;
     //var dataSourceDir = System.IO.Directory.GetParent(appDir).Parent.Parent.Parent;
     //string dataSourceFileName = string.Concat(dataSourceDir.FullName, @"\dataSource\",
     //    typeof(T).Name.ToLower(), "s.json");
     this.jsonReader    = jsonReader;
     this.dataValidator = dataValidator;
 }
        /// <summary>
        /// 校验属性值校验器初始化,用于在扩展组件中提供快捷初始化方法
        /// </summary>
        /// <param name="dbCacheManager"></param>
        protected internal void OpenDataValidation(IDataValidator dataValidator)
        {
            if (DataValidator != null)
            {
                throw new InvalidOperationException("DataValidator has been Initialized.");
            }

            DataValidator = dataValidator;
        }
Ejemplo n.º 19
0
 public static void ProfileOverrideNoHeaders(IWrapper wrapper, IDataValidator validator)
 {
     string[] profileIds = { "12280", "17779", "17470", "18092" };
     using (var data = wrapper.Pipeline.CreateFlowData())
     {
         data.AddEvidence("query.51D_ProfileIds", string.Join("|", profileIds))
         .Process();
         validator.ValidateProfileIds(data, profileIds);
     }
 }
Ejemplo n.º 20
0
 public CompanyController(ICompanyRepository companyRepository,
                          IDataValidator dataValidator,
                          IConfigurableOptions configurableOptions,
                          ISellerRepository sellerRepository)
 {
     _companyRepository   = companyRepository;
     _dataValidator       = dataValidator;
     _configurableOptions = configurableOptions;
     _sellerRepository    = sellerRepository;
 }
Ejemplo n.º 21
0
 public TasksService(
     DataContext dataContext,
     IDataValidator dataValidator,
     IMailer mailer
     )
 {
     _dataContext   = dataContext;
     _dataValidator = dataValidator;
     _mailer        = mailer;
 }
Ejemplo n.º 22
0
 public MetersMessageEventBuilder(IDataPopulator dataPopulator, IDataValidator validator, ILoggingService loggingService)
 {
     _dataPopulator = dataPopulator;
     _validator     = validator;
     //_serverSideRunTimeCalibrationDeviceTypes = String.IsNullOrWhiteSpace(ConfigurationManager.AppSettings["ServerSideRunTimeCalibrationDeviceTypes"]) ? new List<string>() :
     //	ConfigurationManager.AppSettings["ServerSideRunTimeCalibrationDeviceTypes"].Split(',').ToList();
     //_newlySupportedServerSideRunTimeCalibrationDeviceTypes = String.IsNullOrWhiteSpace(ConfigurationManager.AppSettings["NewlySupportedRunTimeCalibrationDeviceTypes"]) ? new List<string>() :
     //	ConfigurationManager.AppSettings["NewlySupportedRunTimeCalibrationDeviceTypes"].Split(',').ToList();
     _loggingService = loggingService;
     //_kafkaPublisher = new DeviceMessageKafkaPublisher(configuration.Value, transaction);
 }
Ejemplo n.º 23
0
 /// <summary>
 /// 检查参数是否合法(根据约定的属性值检查)
 /// </summary>
 /// <param name="dataValidator"></param>
 /// <returns></returns>
 public static bool CheckValid(this IDataValidator dataValidator)
 {
     try
     {
         return(dataValidator.IsValid());
     }
     catch (UserFriendlyException ex)
     {
         MessageBox.Show(ex.Message);
     }
     return(false);
 }
Ejemplo n.º 24
0
 public Report(
     IDataGetter dataGetter,
     IDataValidator dataValidator,
     IDataFormatter dataFormatter,
     IReportDistributor reportDistributor
     )
 {
     _dataGetter        = dataGetter;
     _dataValidator     = dataValidator;
     _dataFormatter     = dataFormatter;
     _reportDistributor = reportDistributor;
 }
Ejemplo n.º 25
0
        /// <summary>
        /// Validates the specified check.
        /// </summary>
        /// <param name="check">The check.</param>
        /// <param name="context">The context.</param>
        /// <returns>A validation result.</returns>
        private ValidationResult Validate(IDataValidator check, ValidationContext context)
        {
            try
            {
                var timer = new Stopwatch();

                EventPublisher.Raise(new CheckStartedEvent {
                    Name = check.Name
                });

                timer.Start();
                var result = check.Validate(context);
                timer.Stop();

                result.Duration = timer.Elapsed;

                if (result.Status < 0)
                {
                    if (result.Metadata.Severity == CheckSeverity.Error)
                    {
                        Interlocked.Increment(ref this.checkErrorCount);
                    }

                    EventPublisher.Raise(
                        new CheckFailedEvent
                    {
                        Name      = check.Name,
                        CheckType = result.CheckType,
                        Goal      = result.Metadata.Goal,
                        Value     = result.Value,
                        Message   = result.Status < 0 ? Resources.CheckFailedMessage : Resources.CheckPassedMessage,
                        Details   = result.AdditionalInformation.ToString(),
                        Severity  = result.Metadata.Severity,
                        Duration  = timer.Elapsed
                    });
                }
                else
                {
                    EventPublisher.Raise(new CheckPassedEvent {
                        Name = check.Name, Duration = timer.Elapsed
                    });
                }

                return(result);
            }
            catch (Exception ex)
            {
                var properties = new Dictionary <string, string>();
                EventPublisher.Raise(new CheckErrorEvent(check, ex, properties));
                throw;
            }
        }
Ejemplo n.º 26
0
        internal ManageCredentialForm(IPersistence persistence, ICredentialSet editedCredential)
        {
            InitializeComponent();

            this.persistence                = persistence;
            this.validator                  = persistence.Factory.CreateValidator();
            this.editedCredential           = editedCredential;
            this.credentialsPanel1.Settings = Settings.Instance;
            this.credentialsPanel1.tableLayoutPanel1.Location = new Point(78, 0);
            this.credentialsPanel1.tableLayoutPanel1.Size     = new Size(this.NameTextbox.Width + 35, 80);
            this.credentialsPanel1.LoadMRUs();
            FillControlsFromCredential();
        }
Ejemplo n.º 27
0
        public MessageConstructor(IOptions <CommonModels.Configurations> configurations, ITransactions transactions, ILoggingService loggingService)
        {
            _loggingService = loggingService;
            _deviceService  = new MessageConstructorDeviceService(configurations);
            _dataPopulator  = new DataPopulator();
            _kafkaPublisher = new DeviceMessageKafkaPublisher(configurations.Value, transactions);
            _dataValidator  = new DataValidator();

            _updateRequestStatusEventBuilder = new UpdateDeviceRequestStatusBuilder(new LocationUpdateRequestEventGenerator(), new FuelUpdateRequestEventGenerator(), new ECMInfoUpdateRequestEventGenerator(),
                                                                                    new TPMSPingUpdateRequestEventGenerator(), new PTOHoursVia1939UpdateRequestEventGenerator(), new BatteryVoltageVia1939UpdateRequestEventGenerator(),
                                                                                    new EventDiagonsticUpdateRequestEventGenerator());
            _updateEventMessageBuilder = new UpdateDeviceRequestMessageBuilder(_updateRequestStatusEventBuilder);
            _deviceTypeFamilyContainer = _deviceService.GetDeviceTypeFamily();
            _groupContainer            = GetGroupBuilderTypes();
        }
Ejemplo n.º 28
0
        private void CreateAndRegisterValidator(String name, String groupname, String description, String helpurl, Dictionary <String, String> config, Type valididatorType)
        {
            try
            {
                if (log.IsDebugEnabled)
                {
                    log.DebugFormat("Creating an instance of {0}...", valididatorType);
                }
                object validatorObj = Activator.CreateInstance(valididatorType);
                if (null == validatorObj)
                {
                    if (log.IsWarnEnabled)
                    {
                        log.WarnFormat("Could not create instance of type {0}...", valididatorType);
                    }
                    return;
                }
                IDataValidator validator = validatorObj as IDataValidator;
                if (null == validator)
                {
                    if (log.IsWarnEnabled)
                    {
                        log.WarnFormat("Type {0} could not be converted to IDataValidator. Did you forget to implement IDataValidator?...", valididatorType);
                    }
                    return;
                }

                validator.Name        = name;
                validator.Description = description;
                validator.HelpURL     = helpurl;
                validator.GroupName   = groupname;

                validator.Init(config);

                lock (this.validators)
                {
                    if (this.validators.Contains(validator) == false)
                    {
                        validators.Add(validator);
                    }
                }
            }
            catch
            {
                return;
            }
        }
Ejemplo n.º 29
0
 /// <summary>
 /// 設置驗證器
 /// </summary>
 /// <param name="dataValidator"></param>
 public virtual void SetValidator(IDataValidator dataValidator)
 {
     validator = dataValidator;
 }
Ejemplo n.º 30
0
 /// <summary>
 /// Validates data for a given table with a data validator.
 /// </summary>
 /// <param name="dataValidator">Data validator which should validate the data.</param>
 /// <param name="table">Table on which to validate data.</param>
 /// <param name="tableData">Data to be validated.</param>
 /// <param name="endOfData">Indicates whether this is the last data for the table.</param>
 /// <param name="command">Execute command for the delivery engine.</param>
 private void Validate(IDataValidator dataValidator, ITable table, IDictionary <ITable, IEnumerable <IEnumerable <IDataObjectBase> > > tableData, bool endOfData, IDeliveryEngineExecuteCommand command)
 {
     if (dataValidator == null)
     {
         throw new ArgumentNullException("dataValidator");
     }
     if (table == null)
     {
         throw new ArgumentNullException("table");
     }
     if (tableData == null)
     {
         throw new ArgumentNullException("tableData");
     }
     if (command == null)
     {
         throw new ArgumentNullException("command");
     }
     try
     {
         dataValidator.Validate(table, tableData, endOfData, command);
     }
     catch (ThreadInterruptedException)
     {
         throw;
     }
     catch (DeliveryEngineConvertException ex)
     {
         lock (_syncRoot)
         {
             bool continueValidation;
             ExceptionHandler.HandleException(ex, out continueValidation);
             if (continueValidation == false)
             {
                 throw new DeliveryEngineAlreadyHandledException(ex.Message, ex);
             }
         }
         if (command.ValidationOnly)
         {
             RemoveInvalidData(tableData, ex.Information.ConvertObjectData);
         }
         Validate(dataValidator, table, tableData, endOfData, command);
     }
     catch (DeliveryEngineMappingException ex)
     {
         lock (_syncRoot)
         {
             bool continueValidation;
             ExceptionHandler.HandleException(ex, out continueValidation);
             if (continueValidation == false)
             {
                 throw new DeliveryEngineAlreadyHandledException(ex.Message, ex);
             }
         }
         if (command.ValidationOnly)
         {
             RemoveInvalidData(tableData, ex.Information.MappingObjectData);
         }
         Validate(dataValidator, table, tableData, endOfData, command);
     }
     catch (DeliveryEngineValidateException ex)
     {
         lock (_syncRoot)
         {
             bool continueValidation;
             ExceptionHandler.HandleException(ex, out continueValidation);
             if (continueValidation == false)
             {
                 throw new DeliveryEngineAlreadyHandledException(ex.Message, ex);
             }
         }
         if (command.ValidationOnly)
         {
             RemoveInvalidData(tableData, ex.Information.ValidateObjectData);
         }
         Validate(dataValidator, table, tableData, endOfData, command);
     }
     catch (Exception ex)
     {
         var threadInterruptedException = ex.InnerException as ThreadInterruptedException;
         if (threadInterruptedException != null)
         {
             throw threadInterruptedException;
         }
         lock (_syncRoot)
         {
             bool continueValidation;
             ExceptionHandler.HandleException(ex, out continueValidation);
             if (continueValidation == false)
             {
                 throw new DeliveryEngineAlreadyHandledException(ex.Message, ex);
             }
         }
         Validate(dataValidator, table, tableData, endOfData, command);
     }
 }
Ejemplo n.º 31
0
 public FaultCodeReportingEventBuilder(IDataPopulator dataPopulator, IDataValidator validator, ILoggingService loggingService)
 {
     _dataPopulator  = dataPopulator;
     _validator      = validator;
     _loggingService = loggingService;
 }