Beispiel #1
0
        private static async Task MainAsync(Arguments arguments)
        {
            try
            {
                List <Task>           executionTasks = new List <Task>();
                XConnectClientFactory readFactory    = new XConnectClientFactory("read");
                Reader reader;
                switch (arguments.CurrentReadMode)
                {
                case Arguments.ReadMode.IdList:
                    Configuration config = readFactory.Configuration;
                    config.IdListFileName = arguments.FileName;
                    reader = new IdListReader(readFactory.BuildClient(), config);
                    break;

                default:
                    reader = new DataExtractionReader(readFactory.BuildClient(true), readFactory.Configuration);
                    break;
                }

                Task readingTask = reader.Start();
                executionTasks.Add(readingTask);

                Writer writer;
                switch (arguments.CurrentWriteMode)
                {
                default:
                    XConnectClientFactory writeFactory = new XConnectClientFactory("write");
                    for (int i = 0; i < Configuration.WriterThreads; i++)
                    {
                        writer = new XConnectWriter(writeFactory.BuildClient(), writeFactory.Configuration);
                        Task writingTask = writer.Start();
                        executionTasks.Add(writingTask);
                    }

                    break;
                }

                while (CurrentStatus.IsReading() || !CurrentStatus.IsQueueEmpty())
                {
                    WriteLine(CurrentStatus.GetStatus(), ConsoleColor.White);
                    Thread.Sleep(5000);
                }

                await Task.WhenAll(executionTasks);
            }
            catch (Exception ex)
            {
                WriteLine($"FATAL: {ex.Message} at {ex.StackTrace}", ConsoleColor.Red);
            }
        }