Exemplo n.º 1
0
        public async Task <bool> Validate(string sourceTable)
        {
            try
            {
                var validators    = _validatorRepository.GetByExtract(sourceTable);
                int count         = 0;
                var validatorList = validators.ToList();

                foreach (var validator in validatorList)
                {
                    using (var command = _validatorRepository.GetConnection().CreateCommand())
                    {
                        var provider = _validatorRepository.GetConnectionProvider();
                        command.CommandText = validator.GenerateValidateSql(provider);

                        try
                        {
                            await GetTask(command);
                        }
                        catch (Exception e)
                        {
                            Log.Debug(e.Message);
                            throw;
                        }
                        count++;
                    }
                }
                return(true);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(false);
            }
        }
Exemplo n.º 2
0
        public async Task <bool> Validate(Guid extractId, int extracted, string extractName, string sourceTable)
        {
            DomainEvents.Dispatch(
                new MgsExtractActivityNotification(extractId, new ExtractProgress(
                                                       extractName,
                                                       nameof(ExtractStatus.Validating),
                                                       extracted, 0, 0, 0, 0)));
            try
            {
                var validators    = _validatorRepository.GetByExtract(sourceTable);
                int count         = 0;
                var validatorList = validators.ToList();

                foreach (var validator in validatorList)
                {
                    using (var command = _validatorRepository.GetConnection().CreateCommand())
                    {
                        var provider = _validatorRepository.GetConnectionProvider();
                        command.CommandText = validator.GenerateValidateSql(provider);

                        try
                        {
                            if (command.Connection.State != ConnectionState.Open)
                            {
                                command.Connection.Open();
                            }
                            await GetTask(command);
                        }
                        catch (Exception e)
                        {
                            Log.Debug(e.Message);
                            throw;
                        }
                        count++;
                    }
                }
                DomainEvents.Dispatch(
                    new MgsExtractActivityNotification(extractId, new ExtractProgress(
                                                           extractName,
                                                           nameof(ExtractStatus.Validated),
                                                           extracted, 0, 0, 0, 0)));
                return(true);
            }
            catch (Exception e)
            {
                DomainEvents.Dispatch(
                    new MgsExtractActivityNotification(extractId, new ExtractProgress(
                                                           extractName,
                                                           nameof(ExtractStatus.Idle),
                                                           extracted, 0, 0, 0, 0)));
                Console.WriteLine(e);
                return(false);
            }
        }