예제 #1
0
        /// <summary>
        /// Adds the drivers to the STF repository.
        /// </summary>
        /// <param name="driverSet">The drivers.</param>
        /// <param name="overwrite">if set to <c>true</c> [overwrite].</param>
        /// <returns></returns>
        private bool AddDrivers(Collection <PrintDeviceDriverCollection> driverSet, bool overwrite = false)
        {
            try
            {
                // Attempt to add the drivers to the environment.  If it works, return true;
                // This also adds any necessary database entries for each driver.
                PrintDriversManager.AddToFrameworkRepository(driverSet, overwrite);
                return(true);
            }
            catch (IOException ex)
            {
                TraceFactory.Logger.Error(ex.Message);
                // If we were not trying to overwrite, ask the user if they want to
                if (!overwrite)
                {
                    DialogResult result = MessageBox.Show("One or more of the selected print drivers have already been added to the test environment.\n"
                                                          + "Do you wish to overwrite these drivers?",
                                                          "Confirm Overwrite", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                    if (result == DialogResult.Yes)
                    {
                        // User wants to overwrite - call the method again
                        return(AddDrivers(driverSet, overwrite: true));
                    }
                }

                // If we were trying to overwrite and it failed, or the user opted not to overwrite,
                // return a failure condition.
                return(false);
            }
            catch (OperationCanceledException)
            {
                // The user canceled the copy operation.
                return(false);
            }
        }
예제 #2
0
        /// <summary>
        /// Import the drivers from the central repository location to the STF repository.
        /// </summary>
        private void ImportFromCentral()
        {
            Collection <string> paths = _welcomeControl.PrintDriverPaths;

            string sharePath = GlobalSettings.Items[Setting.UniversalPrintDriverBaseLocation];

            Cursor.Current = Cursors.WaitCursor;

            Collection <PrintDeviceDriverCollection> drivers = new Collection <PrintDeviceDriverCollection>();

            foreach (string path in paths)
            {
                string sourcePath = Path.Combine(sharePath, path);
                drivers.Add(PrintDriversManager.LoadDrivers(sourcePath, sharePath));
            }

            bool success = AddDrivers(drivers);

            Cursor.Current = Cursors.Default;
        }