Пример #1
0
        ///////////////////////////////////////////////////////////////////////////////
        // Public methods                                                            //
        ///////////////////////////////////////////////////////////////////////////////
        #region Public Methods and Operators

        /// <summary>
        ///   Starts a multiple dialog routine for reading AOIs
        ///   from a log file into the programs database.
        /// </summary>
        public static void Start()
        {
            try
            {
                // Show assistant start screen with instructions
                var objfrmImportAssistent = new ImportAOIAssistentDialog();
                if (objfrmImportAssistent.ShowDialog() == DialogResult.OK)
                {
                    // Show open file dialog
OpenFile:
                    if (asciiSettings.FileDialog.ShowDialog() == DialogResult.OK)
                    {
                        // Save import file
                        asciiSettings.Filename = asciiSettings.FileDialog.FileName;

                        // Show ascii file parse dialog with preview
                        var objfrmImportReadFile = new ImportParseFileDialog(ref asciiSettings);
ReadFile:
                        DialogResult resultReadFile = objfrmImportReadFile.ShowDialog();
                        if (resultReadFile == DialogResult.OK)
                        {
                            // Show assign columns dialog
                            var objfrmImportAOIAssignColumns = new ImportAOIAssignColumnsDialog();

                            DialogResult resultAssign = objfrmImportAOIAssignColumns.ShowDialog();
                            if (resultAssign == DialogResult.OK)
                            {
                                // Show import splash window
                                asciiSettings.WaitingSplash.RunWorkerAsync();

                                // Give some time to show the splash ...
                                Application.DoEvents();

                                var columnHeaders = new List <string>();

                                // Read import log file
                                asciiSettings.Rows = FileImport.ParseFile(asciiSettings.Filename, -1, ref columnHeaders);

                                // Convert log file to AOI
                                GenerateOgamaAOIDataList();

                                // Save the import into ogamas database and the mdf file.
                                SaveImportIntoTablesAndDB();

                                // Import has finished.
                                asciiSettings.WaitingSplash.CancelAsync();

                                // Inform user about success.
                                string message = "AOI import data successfully written to database.";
                                ExceptionMethods.ProcessMessage("Successfull", message);
                            }
                            else if (resultAssign == DialogResult.Cancel)
                            {
                                goto ReadFile;
                            }
                        }
                        else if (resultReadFile == DialogResult.Cancel)
                        {
                            goto OpenFile;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                string message = "Something failed during import." + Environment.NewLine
                                 + "Please try again with other settings. " + Environment.NewLine + "Error: " + ex.Message;
                ExceptionMethods.ProcessErrorMessage(message);

                // CleanUp
                if (asciiSettings.WaitingSplash.IsBusy)
                {
                    asciiSettings.WaitingSplash.CancelAsync();
                }
            }
        }
Пример #2
0
    ///////////////////////////////////////////////////////////////////////////////
    // Public methods                                                            //
    ///////////////////////////////////////////////////////////////////////////////
    #region Public Methods and Operators

    /// <summary>
    ///   Starts a multiple dialog routine for reading AOIs
    ///   from a log file into the programs database.
    /// </summary>
    public static void Start()
    {
      try
      {
        // Show assistant start screen with instructions
        var objfrmImportAssistent = new ImportAOIAssistentDialog();
        if (objfrmImportAssistent.ShowDialog() == DialogResult.OK)
        {
        // Show open file dialog
        OpenFile:
          if (asciiSettings.FileDialog.ShowDialog() == DialogResult.OK)
          {
            // Save import file
            asciiSettings.Filename = asciiSettings.FileDialog.FileName;

            // Show ascii file parse dialog with preview
            var objfrmImportReadFile = new ImportParseFileDialog(ref asciiSettings);
          ReadFile:
            DialogResult resultReadFile = objfrmImportReadFile.ShowDialog();
            if (resultReadFile == DialogResult.OK)
            {
              // Show assign columns dialog
              var objfrmImportAOIAssignColumns = new ImportAOIAssignColumnsDialog();

              DialogResult resultAssign = objfrmImportAOIAssignColumns.ShowDialog();
              if (resultAssign == DialogResult.OK)
              {
                // Show import splash window
                asciiSettings.WaitingSplash.RunWorkerAsync();

                // Give some time to show the splash ...
                Application.DoEvents();

                var columnHeaders = new List<string>();

                // Read import log file
                asciiSettings.Rows = FileImport.ParseFile(asciiSettings.Filename, -1, ref columnHeaders);

                // Convert log file to AOI
                GenerateOgamaAOIDataList();

                // Save the import into ogamas database and the mdf file.
                SaveImportIntoTablesAndDB();

                // Import has finished.
                asciiSettings.WaitingSplash.CancelAsync();

                // Inform user about success.
                string message = "AOI import data successfully written to database.";
                ExceptionMethods.ProcessMessage("Successfull", message);
              }
              else if (resultAssign == DialogResult.Cancel)
              {
                goto ReadFile;
              }
            }
            else if (resultReadFile == DialogResult.Cancel)
            {
              goto OpenFile;
            }
          }
        }
      }
      catch (Exception ex)
      {
        string message = "Something failed during import." + Environment.NewLine
                         + "Please try again with other settings. " + Environment.NewLine + "Error: " + ex.Message;
        ExceptionMethods.ProcessErrorMessage(message);

        // CleanUp
        if (asciiSettings.WaitingSplash.IsBusy)
        {
          asciiSettings.WaitingSplash.CancelAsync();
        }
      }
    }