예제 #1
0
 private void ExecuteImport()
 {
     if (!chkDropAndRecreate.Checked)
     {
         var result = MessageBox.Show("This action will append data to existing tables and data duplication is likely to occur. Are you sure you wish to continue?", "Confirm action",
                                      MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation);
         if (result == DialogResult.Cancel)
         {
             return;
         }
     }
     btnImport.Enabled         = btnValidate.Enabled = false;
     pictureBoxSpinner.Visible = true;
     var task = Task.Run(() =>
     {
         try
         {
             DatabaseImport.Import(GetParameters(), (s) => lblStatus.SetPropertyThreadSafe(() => lblStatus.Text, s));
         }
         catch (Exception e)
         {
             var result = MessageBox.Show("The database import failed because: " + e.Message, "Database import failed",
                                          MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }).ContinueWith((o) =>
     {
         btnImport.Enabled         = btnValidate.Enabled = true;
         pictureBoxSpinner.Visible = false;
         lblStatus.Text            = "Ready!";
     });
 }
예제 #2
0
        private bool ValidateInput()
        {
            var validationResult = DatabaseImport.Validate(GetParameters());

            if (validationResult.Count > 0)
            {
                MessageBox.Show(string.Join("\r\n", validationResult.Select(v => v.ErrorMessage).ToArray()), "Validation error",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }

            return(true);
        }