Beispiel #1
0
        public void Import()
        {
            if (string.IsNullOrEmpty(ImportPath))
            {
                Status = "Please specify an import path.";
            }
            else
            {
                ConfigImporter importer = new ConfigImporter(ImportPath, !ImportIncludeRules);
                try
                {
                    Configuration config = importer.Import();
                    if (m_viewModel.OpenFromDB(config.SessionGroupUniqueId))
                    {
                        m_viewModel.ClearViewModels();
                        m_viewModel.SystemState       = SystemState.ConfigurationSaved;
                        m_viewModel.ShowMigrationView = MigrationStatusViews.Progress;
                    }
                    Status = string.Format("The configuration has been successfully imported. The imported configuration name is '{0}' (session group unique id: {1}).", config.FriendlyName, config.SessionGroupUniqueId);
                }
                catch (ConfigNotExistInPackageException)
                {
                    Status = "There is no configuration file in the configuration package to import from.";
                }

                ActiveConfigurationsList.Refresh();
            }
        }
Beispiel #2
0
        /// <summary>
        /// Store configuration associated with specified <see cref="ViewModel&lt;TController, TModel&gt;"/> in migration tools DB.
        /// </summary>
        /// <param name="viewModel">The view model.</param>
        /// <param name="owner">The owner window.</param>
        /// <param name="openPath">The path from which to open.</param>
        public static void Save(ShellViewModel viewModel, Window owner)
        {
            if (viewModel.IsDirty)
            {
                viewModel.SaveToDB(viewModel.DataModel.Configuration.SessionGroupUniqueId, false);
                viewModel.ClearViewModels();
            }

            /*
             * if (!viewModel.IsConfigurationPersisted)
             * {
             *  SaveAsToDBCommand.Save(viewModel, owner);
             * }
             * else
             * {
             *  MessageBoxResult result = MessageBox.Show("Do you want to overwrite the existing configuration?", "Confirm save configuration", MessageBoxButton.YesNoCancel, MessageBoxImage.Exclamation);
             *  if (result == MessageBoxResult.Yes)
             *  {
             *      viewModel.SaveToDB(viewModel.DataModel.Configuration.SessionGroupUniqueId, false);
             *  }
             *  else if (result == MessageBoxResult.No)
             *  {
             *      SaveAsToDBCommand.Save(viewModel, owner);
             *  }
             *  else
             *  {
             *      // do nothing
             *  }
             * }
             */
        }
Beispiel #3
0
        internal static void Execute(ShellViewModel viewModel)
        {
            viewModel.ClearViewModels();

            //To show progress View irrespective of where the user is when Start session is clicked
            viewModel.ShowMigrationView = MigrationStatusViews.Progress;
            StartCommand.Start(viewModel);
        }
Beispiel #4
0
        /// <summary>
        /// Opens a data model for the specified <see cref="ViewModel&lt;TController, TModel&gt;"/>.
        /// </summary>
        /// <param name="viewModel">The view model.</param>
        /// <param name="owner">The owner window.</param>
        /// <param name="openPath">The path from which to open.</param>
        public static void Open(ShellViewModel viewModel, Window owner)
        {
            bool allowOpen = true;

            if (viewModel.SystemState == SystemState.MigrationProgress && !viewModel.CanStart)
            {
                MessageBoxResult messageBoxResult = System.Windows.MessageBox.Show(Properties.ShellResources.StopSessionExistingSession,
                                                                                   Properties.ShellResources.StopSessionTitle, MessageBoxButton.YesNo, MessageBoxImage.Stop);
                if (messageBoxResult == MessageBoxResult.Yes)
                {
                    if (viewModel.CanStop)
                    {
                        viewModel.Stop();
                    }
                    else
                    {
                        allowOpen = false;
                        Utilities.ShowError(Properties.Resources.CannotStopError, Properties.Resources.CannotStopCaption);
                    }
                }
                else
                {
                    allowOpen = false;
                }
            }

            if (allowOpen)
            {
                // Ask the user which SessionGroupConfig they want to open
                OpenFromDBDialog dlg = new OpenFromDBDialog();
                dlg.Owner = owner;
                dlg.ShowDialog();

                // Load the config and set the selected group run
                if (dlg.DialogResult == true && dlg.SelectedConfiguration != null)
                {
                    if (viewModel.OpenFromDB(dlg.SelectedConfiguration.SessionGroupUniqueId))
                    {
                        viewModel.ClearViewModels();
                        viewModel.SystemState       = SystemState.ConfigurationSaved;
                        viewModel.ShowMigrationView = MigrationStatusViews.Progress;
                    }
                }
            }
        }
Beispiel #5
0
        /// <summary>
        /// Opens a data model for the specified <see cref="ViewModel&lt;TController, TModel&gt;"/>.
        /// </summary>
        /// <param name="viewModel">The view model.</param>
        /// <param name="owner">The owner window.</param>
        /// <param name="openPath">The path from which to open.</param>
        public static void Open(ViewModel <TController, TModel> viewModel, Window owner, string openPath)
        {
            bool           allowOpen = true;
            ShellViewModel shellVM   = viewModel as ShellViewModel;

            if (shellVM != null && shellVM.SystemState == SystemState.MigrationProgress && !shellVM.CanStart)
            {
                MessageBoxResult messageBoxResult = System.Windows.MessageBox.Show(Properties.ShellResources.StopSessionNewMigration,
                                                                                   Properties.ShellResources.StopSessionTitle, MessageBoxButton.YesNo, MessageBoxImage.Stop);
                if (messageBoxResult == MessageBoxResult.Yes)
                {
                    if (shellVM.CanStop)
                    {
                        shellVM.Stop();
                    }
                    else
                    {
                        allowOpen = false;
                        Utilities.ShowError(Properties.Resources.CannotStopError, Properties.Resources.CannotStopCaption);
                    }
                }
                else
                {
                    allowOpen = false;
                }
            }

            if (allowOpen)
            {
                // Get the open path from the user
                if (string.IsNullOrEmpty(openPath))
                {
                    string currentDirectory = Environment.CurrentDirectory; // this is line X.  line X and line Y are necessary for back-compat with windows XP.

                    // NOTE: For now, use the WinForms OpenFileDialog since it supports the Vista style common open file dialog.
                    OpenFileDialog openFileDialog       = new OpenFileDialog();
                    string         assemblyParentFolder = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().CodeBase);
                    openFileDialog.InitialDirectory = Path.Combine(assemblyParentFolder, "Configurations");
                    openFileDialog.Filter           = "Configuration file (*.xml)|*.xml";
                    openFileDialog.Title            = "Choose a template";

                    //if (openFileDialog.ShowDialog (owner) == true)
                    if (openFileDialog.ShowDialog() == DialogResult.OK)
                    {
                        openPath = openFileDialog.FileName;
                    }

                    Environment.CurrentDirectory = currentDirectory; // this is line Y.  line X and line Y are necessary for back-compat with windows XP.
                }

                // Open the file
                if (!string.IsNullOrEmpty(openPath))
                {
                    viewModel.Open(openPath);
                    if (shellVM != null)
                    {
                        shellVM.IsCompleted = false;
                        shellVM.ClearViewModels();
                        shellVM.PushViewModel(new HomeViewModel(shellVM));
                    }
                }
            }
        }
Beispiel #6
0
 /// <summary>
 /// Opens a data model for the specified <see cref="ViewModel&lt;TController, TModel&gt;"/>.
 /// </summary>
 /// <param name="viewModel">The view model.</param>
 public static void Open(ShellViewModel viewModel)
 {
     viewModel.ClearViewModels();
     viewModel.ShowMigrationView = MigrationStatusViews.Progress;
 }
Beispiel #7
0
 /// <summary>
 /// Opens a data model for the specified <see cref="ViewModel&lt;TController, TModel&gt;"/>.
 /// </summary>
 /// <param name="viewModel">The view model.</param>
 public static void Open(ShellViewModel viewModel)
 {
     viewModel.ClearViewModels();
     viewModel.ShowMigrationView = MigrationStatusViews.Configuration;
 }