private async void mnuiFileOpen_Click(object sender, RoutedEventArgs e)
        {
            tabControlMain.SelectedItem = ImportTab;

            var openAsteroidsCSV = new Microsoft.Win32.OpenFileDialog();

            openAsteroidsCSV.Multiselect = false;

            if (openAsteroidsCSV.ShowDialog() ?? false)
            {
                //MessageBox.Show("Selected Filename: " + openAsteroidsCSV.FileName);

                // Erfassung vorbereiten
                mko.TraceHlp.ThrowArgExIfNot(File.Exists(openAsteroidsCSV.FileName), "Die Datei " + openAsteroidsCSV.FileName + " existiert nicht");

                ((AsteroidsCollectorMVVM)FindResource("Collector")).StartCollect();
                collector = ((AsteroidsCollectorMVVM)FindResource("Collector")).Collector;

                clock.AutoReset = true;
                clock.Elapsed  += new System.Timers.ElapsedEventHandler(clock_Elapsed);
                clock.Enabled   = true;

                log.Log(mko.Log.RC.CreateStatus("Einlesevorgang gestartet"));

                await Task.Run(() =>
                {
                    var reader = new AsteroidsDAL.CSV.AsteroidsCSVReader(openAsteroidsCSV.FileName, 2);

                    // geht nicht aus einem anderen Thread
                    //lblImportCsvCountAsteroids.Text = "HAllo";

                    while (!reader.EOF)
                    {
                        collector.Add(reader.Read());
                    }
                });

                clock.Stop();

                //UpdateCollectorCounterTimer_Tick(null, null);

                mvvmRepo.Repo = collector.CreateRepository();
                //presenter = new Impl.PresenterV1(this, repo);

                log.Log(mko.Log.RC.CreateStatus("Einlesen erfolgreich beendet"));
            }
        }
Exemple #2
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            // Add framework services.

            // Hier wird die CSV zu Programmstart eingelesen und als Repository
            // den Controllern bereitgestellt
            services.AddSingleton <AsteroidsBL.IAsteroidsRepository>(scv =>
            {
                var reader    = new AsteroidsDAL.CSV.AsteroidsCSVReader(Configuration[AppSettKeyAsteroidsCsv], 2);
                var collector = new AsteroidsBL.AsteroidsCollector();
                while (!reader.EOF)
                {
                    collector.Add(reader.Read());
                }

                return(collector.CreateRepository());
            });

            services.AddMvc();
        }
        private async void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            tabControl1.SelectedTab = tabImportCSV;

            if (openAsteroidsCSV.ShowDialog() == DialogResult.OK)
            {
                // Erfassung vorbereiten
                mko.TraceHlp.ThrowArgExIfNot(File.Exists(openAsteroidsCSV.FileName), "Die Datei " + openAsteroidsCSV.FileName + " existiert nicht");


                collector = new AsteroidsBL.AsteroidsCollector();

                //UpdateCollectorCounterTimer.Enabled = true;
                UpdateCollectorCounterTimer.Start();

                log.Log(mko.Log.RC.CreateStatus("Einlesevorgang gestartet"));

                await Task.Run(() =>
                {
                    var reader = new AsteroidsDAL.CSV.AsteroidsCSVReader(openAsteroidsCSV.FileName, 2);

                    // geht nicht aus einem anderen Thread
                    //lblImportCsvCountAsteroids.Text = "HAllo";

                    while (!reader.EOF)
                    {
                        collector.Add(reader.Read());
                    }
                });

                UpdateCollectorCounterTimer.Stop();

                //UpdateCollectorCounterTimer_Tick(null, null);

                repo      = collector.CreateRepository();
                presenter = new Impl.PresenterV1(this, repo);

                log.Log(mko.Log.RC.CreateStatus("Einlesen erfolgreich beendet"));
            }
        }