コード例 #1
0
        private void TextBoxSourceTextChanged(object sender, EventArgs e)
        {
            var state = ImportState.Load(textBoxSource.Text);

            if (state != null)
            {
                checkBoxOverwrite.Checked = state.Overwrite;
                var profile = ProfileContainer.Profiles.FirstOrDefault(p => p.Name == state.ProfileName);
                if (profile != null)
                {
                    comboBoxProfiles.SelectedItem = profile;
                }

                checkBoxOnlyAfterLastImport.Enabled = true;
                checkBoxOnlyAfterLastImport.Checked = state.OnlyAfterLastImport;
                OnlyAfter = state.Timestamp;
            }
            else
            {
                checkBoxOnlyAfterLastImport.Enabled = false;
                checkBoxOnlyAfterLastImport.Checked = false;
            }

            StartScan();
        }
コード例 #2
0
        private void CompletedImport(ImportStats stats, bool canceled, Exception exception)
        {
            progressBar.Visible = false;

            buttonImport.Text = "&Import";

            if (stats != null)
            {
                var results = new List <string>();

                if (stats.Copied > 0)
                {
                    results.Add($"{stats.Copied:#,##0} copied");
                }
                if (stats.Skipped > 0)
                {
                    results.Add($"{stats.Skipped:#,##0} skipped");
                }
                if (stats.Failed > 0)
                {
                    results.Add($"{stats.Failed:#,##0} failed");
                }
                var result = string.Join(", ", results);
                if (result.NotEmpty())
                {
                    AddProtocol($"result - {result}");
                }
            }

            if (canceled)
            {
                AddProtocol("import aborted.");
            }
            else if (exception != null)
            {
                AddProtocol($"import failed - {exception.Message}");
            }
            else
            {
                var state = new ImportState
                {
                    Timestamp           = DateTime.Now,
                    Overwrite           = checkBoxOverwrite.Checked,
                    OnlyAfterLastImport = checkBoxOnlyAfterLastImport.Checked,
                    ProfileName         = Profile.Name
                };

                if (state.Save(textBoxSource.Text))
                {
                    AddProtocol("state saved");
                }

                AddProtocol($"import completed");
            }

            textBoxSource.Enabled                     =
                buttonSelect.Enabled                  =
                    buttonEdit.Enabled                =
                        comboBoxProfiles.Enabled      =
                            checkBoxOverwrite.Enabled =
                                buttonImport.Enabled  = true;
        }