Beispiel #1
0
        public void BuildGfiTest()
        {
            service = new GfiBuilderService(new List <Company> {
                allCompanies.First()
            });

            service.BuildGfis();
        }
Beispiel #2
0
        private async void BtnBuildGfi_Click(object sender, RoutedEventArgs e)
        {
            var selectedCompanies = LbDirectories.SelectedItems.Cast <Company>().ToList();
            var validCompanies    = new DirectoryService(Settings.Default.RootDir).GetCompaniesWithoutNewGfi().Intersect(selectedCompanies);

            var skipCompanies = selectedCompanies.Except(validCompanies).Select(c => c.DisplayName);

            if (skipCompanies.Any())
            {
                var msg = $"Preskačem sljedeće firme jer nedostaje datoteka ili imaju već izrađen GFI: {string.Join(", ", skipCompanies)}";
                await ShowInfoDialog(msg, "Neispravne firme označene");
            }

            var service = new GfiBuilderService(validCompanies);

            Loader.Visibility = Visibility.Visible;

            var sw = Stopwatch.StartNew();
            var dispatcherTimer = PrepareTimer(sw);

            dispatcherTimer.Start();
            try
            {
                await Task.Run(() => service.BuildGfis()).ConfigureAwait(false);
            }
            catch (Exception ex)
            {
                HandleException(ex);
            }

            sw.Stop();
            dispatcherTimer.Stop();

            _ = Dispatcher.Invoke(async() =>
            {
                Loader.Visibility = Visibility.Hidden;
                var sb            = new StringBuilder();
                sb.AppendLine("Obrada završena");
                sb.Append($"Proteklo vremena: {sw.ElapsedMilliseconds / 1000f}s");
                await ShowInfoDialog(sb.ToString(), "Završeno");
                LoadCompanies();

                await NotesControl.RefreshCompaniesAsync();
            });
        }