Example #1
0
        private async void runBtn_Click(object sender, EventArgs e)
        {
            XElement config;

            if (string.IsNullOrWhiteSpace(_filename))
            {
                _logger.Fatal("Please Select a file.");
                return;
            }

            try
            {
                config = XElement.Parse(configTextbox.Text);
            }
            catch (Exception ex)
            {
                _logger.Fatal(string.Format("Error parsing config : {0}", ex.Message));
                return;
            }

            statusListBox.Items.Clear();

            _cancellationTokenSource = new System.Threading.CancellationTokenSource();
            var _runner = new LoadProcess(config, _cancellationTokenSource, _logger);

            var processInfo = new XElement("processinfo", new XAttribute("id", Guid.NewGuid().ToString()), new XElement("filename", _filename));

            await _runner.Run(processInfo);
        }
        public int Execute()
        {
            _configuration["ForceMetadata"]   = "false";
            _configuration["OdsApi:OAuthUrl"] = Path.Combine(_configuration["OdsApi:OAuthUrl"], "oauth/token");
            var result = LoadProcess.Run(_configuration).GetAwaiter().GetResult();

            return(result);
        }
 public BulkLoadValidationResult Validate()
 {
     try
     {
         return(LoadProcess.ValidateXmlFile(_configuration, UnsupportedInterchanges));
     }
     catch (Exception ex)
     {
         return(new BulkLoadValidationResult($"An error occured during file validation: {ex.Message}"));
     }
 }
        public BulkLoadValidationResult Validate()
        {
            var xsdFolderPath = _configuration.GetValue <string>("Folders:Xsd");

            var xsdDirectoryExistWithFiles =
                Directory.Exists(xsdFolderPath) && Directory.GetFiles(xsdFolderPath).Length > 0;
            var odsVersion      = new OdsVersion(_inferOdsApiVersion.Version(_configuration.GetValue <string>("OdsApi:Url")).GetAwaiter().GetResult());
            var requiredVersion = new OdsVersion("5.1.0");

            if (odsVersion < requiredVersion)
            {
                _configuration["OdsApi:Url"] = string.Empty;
            }
            if (xsdDirectoryExistWithFiles)
            {
                _configuration["ForceMetadata"] = "false";
            }
            var result = LoadProcess.ValidateXmlFile(_configuration, UnsupportedInterchanges).GetAwaiter()
                         .GetResult();

            return(result);
        }
Example #5
0
        private Task StartFileProcessLoop()
        {
            var fileSelector = new FileSelector(_connectionString);

            return(Task.Run(async() =>
            {
                while (!_cancellationTokenSource.Token.IsCancellationRequested)
                {
                    ProcessFile fileToProcess = null;
                    try
                    {
                        while ((fileToProcess = fileSelector.GetFileToProcess()) != null && !_cancellationTokenSource.Token.IsCancellationRequested)
                        {
                            _logger.Debug(string.Format("Begin loading {0}", fileToProcess.FilePath));

                            var loadProcess = new LoadProcess(fileToProcess.Config, _cancellationTokenSource, _logger, new DBRowLogger(_connectionString, fileToProcess.Id));

                            await loadProcess.Run(new XElement("processinfo", new XAttribute("id", fileToProcess.Id.ToString()), new XElement("filename", fileToProcess.FilePath)));

                            //TODO POST PROCESS UPDATE
                        }
                    }
                    catch (ConfigException ex)
                    {
                        _logger.Error("Invalid Configuration", ex);
                    }

                    try
                    {
                        await Task.Delay(_pollingTime, _cancellationTokenSource.Token);
                    }
                    catch (OperationCanceledException)
                    {
                        return;
                    }
                }
            }));
        }
Example #6
0
        private static async Task Main(string[] args)
        {
            ConfigureLogging();

            CommandLineOverrides commandLineOverrides = null;

            var parser = new Parser(
                config =>
            {
                config.CaseInsensitiveEnumValues = true;
                config.CaseSensitive             = false;
                config.HelpWriter             = System.Console.Out;
                config.IgnoreUnknownArguments = true;
            })
                         .ParseArguments <CommandLineOverrides>(args)
                         .WithParsed(overrides => commandLineOverrides = overrides)
                         .WithNotParsed(
                errs =>
            {
                System.Console.WriteLine("Invalid options were entered.");
                System.Console.WriteLine(errs.ToString());
                Environment.ExitCode = 1;
                Environment.Exit(Environment.ExitCode);
            });

            try
            {
                var configRoot = new ConfigurationBuilder()
                                 .SetBasePath(Directory.GetParent(AppContext.BaseDirectory).FullName)
                                 .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
                                 .AddCommandLine(args, CommandLineOverrides.SwitchingMapping())
                                 .Build();

                // apply the command line args overrides for boolean values
                if (args.Contains("--include-stats"))
                {
                    configRoot["IncludeStats"] = "true";
                }

                if (args.Contains("--novalidation") || args.Contains("-n"))
                {
                    configRoot["ForceMetadata"] = "true";
                }

                if (args.Contains("--force") || args.Contains("-f"))
                {
                    configRoot["ValidateSchema"] = "true";
                }

                Environment.ExitCode = await LoadProcess.Run(configRoot);
            }
            catch (Exception ex)
            {
                Environment.ExitCode = 1;
                _log.Error(ex);
            }
            finally
            {
                _log.Info($"Exit Code is {Environment.ExitCode}");

                if (Debugger.IsAttached)
                {
                    System.Console.WriteLine("Press enter to continue.");
                    System.Console.ReadLine();
                }

                Environment.Exit(Environment.ExitCode);
            }
        }
        public int Execute()
        {
            var result = LoadProcess.Run(_configuration);

            return(result);
        }