/// <summary> /// Installs a local print queue that points to this print device. /// </summary> /// <param name="installCheck">if set to <c>true</c> and the driver is already installed, then this will return.</param> /// <example> /// The example below shows how to install a driver and associated queue for a given local print /// device. In this example, all drivers for a given distribution are first loaded, then one /// driver is chosen based on the system architecture. In addition, a port is created that points /// to the target device. The port, driver and platform type for the device are given to the print /// device object when then proceeds to install the driver and queue on the system. /// <code> /// // Load all drivers in the driver package located in the given directory /// PrintDeviceDriverCollection drivers = new PrintDeviceDriverCollection(); /// drivers.LoadFromDirectory(@"\\DriverRepository\5.7.0\UPD\pcl6\winxp_vista_x64", includeAllArchitectures: true); /// if (drivers.Count() > 0) /// { /// // Use the first driver from the distribution that matches this architecture /// PrintDeviceDriver driver = drivers.Where(x => x.Architecture == ProcessorArchitectureInfo.Current).FirstOrDefault(); /// if (driver == null) /// { /// throw new InvalidOperationException("Device driver for this architecture not found in the distribution"); /// } /// // Construct a port that the print queue will use when printing jobs. /// var port = StandardTcpIPPort.CreateRawPortData("15.198.212.221", portName: "IP_15.198.212.221", snmpEnabled: false); /// // Construct a local print device using all of the data built thus far. /// var device = new LocalPrintDevice(driver, port, DevicePlatform.Physical); /// // Install the device, which includes installing the driver and creating the queue /// device.Install(); /// } /// </code></example> /// <remarks>This method goes through a series of calls to incrementally build the queue. It starts by /// installing the driver if not already installed. It then creates the printer port, then /// sets up the configuration file (CFM) if there is one, then applies the printer shortcut /// if it exists. Then it adds the actual print queue, followed by the setup of client rendering /// and then configures the shared queue setting. It then waits until all these steps are complete.</remarks> public void Install() { if (PrintQueueInstaller.IsInstalled(QueueName)) { TraceFactory.Logger.Info("Print queue is already installed"); return; } // Install the print driver CopyDriver(); DriverInstaller.Install(_driver); // Create the Printer Port CreatePort(); // Create the print queue CreatePrintQueue(); // Wait until all the queue creation activity has completed. PrintQueueInstaller.WaitForInstallationComplete(QueueName, _driver.Name); }
/// <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"); }