/// <summary>
        /// Installs the PrintDriver With LPR Queue Details as in activity Data
        /// </summary>
        private void InstallPrintDriverWithLPRQueue()
        {
            DriverDetails driver = CreateDriver(_activityData.PrintDriver, _pluginSettings["PrintDriverServer"]);

            UpdateStatus($"Installing driver from {driver.InfPath}");
            ExecutionServices.SystemTrace.LogDebug($"Installing driver from {driver.InfPath}");
            DriverInstaller.Install(driver);
            UpdateStatus("Driver Installation Completed");

            UpdateStatus(string.Format("Creating LPR Port connecting to HPAC Server :{0}, QueueName : {1}", _hpacServerIP, _activityData.LprQueueName));
            ExecutionServices.SystemTrace.LogDebug($"Creating LPR Port connecting to HPAC Server :{_hpacServerIP}, QueueName : {_activityData.LprQueueName}");
            string portName = string.Format("_IP {0}_{1}", _hpacServerIP, _activityData.LprQueueName);

            PrintPortManager.AddLprPort(portName, LprPrinterPortInfo.DefaultPortNumber, _hpacServerIP, _activityData.LprQueueName);
            UpdateStatus("Port Creation Completed");

            UpdateStatus(string.Format("Creating LocalPrintDevice with Driver :{0} and port : {1}", driver.Name, portName));
            ExecutionServices.SystemTrace.LogDebug(string.Format("Creating LocalPrintDevice with Driver :{0} and port : {1}", driver.Name, portName));

            string queueName = string.Format("{0} ({1})", driver.Name, portName);

            if (!PrintQueueInstaller.IsInstalled(queueName))
            {
                PrintQueueInstaller.CreatePrintQueue(queueName, driver.Name, portName, driver.PrintProcessor);
                PrintQueueInstaller.WaitForInstallationComplete(queueName, driver.Name);
                UpdateStatus("Print Device Installation Completed");
            }

            PrintQueue queue = PrintQueueController.GetPrintQueue(queueName);

            if (_activityData.IsDefaultPrinter)
            {
                PrintQueueController.SetDefaultQueue(queue);
                UpdateStatus("Setting the Installed Print Device as a default Print Device");
            }

            ConfigurePrinterAttributes(queue);
            UpdateStatus("Printer Attributes Configuration Completed");
        }
Esempio n. 2
0
        private void CreatePrintQueue()
        {
            //no shortcut selected, use winspool to install
            if (string.IsNullOrEmpty(_configFile))
            {
                PrintQueueInstaller.CreatePrintQueue(QueueName, _driver.Name, _portName, _driver.PrintProcessor);
            }
            else
            {
                //the installer is always in the driver directory
                string installerPath = Path.GetDirectoryName(_driver.InfPath).Trim('\\') + "\\install.exe";
                if (!File.Exists(installerPath))
                {
                    throw new PrintQueueInstallationException("UPD Installer missing");
                }

                //derive the printer IP from the Portname
                string printerIp = _portName.Substring(_portName.LastIndexOf("_") + 1);

                //use the command line arguments to install the print queue
                string cfm;
                if (string.IsNullOrEmpty(_defaultShortcut) || _defaultShortcut.Equals("None"))
                {
                    cfm = _configFile;
                }
                else
                {
                    cfm = BuildShortcut();
                }

                FileInfo installer = new FileInfo(installerPath);
                FileInfo cfmFile   = new FileInfo(cfm);
                PrintQueueInstaller.InstallUpdPrinter(installer, QueueName, printerIp, cfmFile);
            }
            TraceFactory.Logger.Info("Adding print queue complete.");
        }