Beispiel #1
0
        private void Install(string currentDirectory, string platform)
        {
            log.Info("Platform is {0}.", platform);

            log.Info("OS is {0}.", Environment.OSVersion);

            if (virtualPrinterManager.IsMonitorAlreadyInstalled(printer.MonitorName))
            {
                log.Warning("Monitor {0} already installed.", printer.MonitorName);
            }
            else
            {
                log.Info("Installing monitor {0}.", printer.MonitorName);

                try
                {
                    virtualPrinterManager.AddPrinterMonitor(currentDirectory, platform, printer.MonitorName);
                    log.Success("Monitor {0} successfully installed.", printer.MonitorName);
                }
                catch (Exception ex)
                {
                    log.Error("Install monitor failed: {0}", ex.Message);
                }
            }

            if (virtualPrinterManager.IsPortAlreadyInstalled(printer.PortName))
            {
                log.Warning("Port {0} already installed.", printer.PortName);
            }
            else
            {
                log.Info("Installing port {0}.", printer.PortName);
                virtualPrinterManager.AddPrinterPort(printer.PortName, printer.MonitorName);
                log.Success("Port {0} successfully installed.", printer.PortName);
            }

            if (virtualPrinterManager.IsDriverAlreadyInstalled(printer.DriverName))
            {
                log.Warning("Driver {0} already installed.", printer.DriverName);
            }
            else
            {
                log.Info("Installing driver {0}.", printer.DriverName);
                virtualPrinterManager.AddPrinterDriver(currentDirectory, platform, printer.DriverName);
                log.Success("Driver {0} successfully installed.", printer.DriverName);
            }

            if (virtualPrinterManager.IsPrinterAlreadyInstalled(printer.PrinterName))
            {
                log.Warning("Printer {0} already installed.", printer.PrinterName);
            }
            else
            {
                log.Info("Installing printer {0}.", printer.PrinterName);
                virtualPrinterManager.AddPrinter(printer);
                log.Success("Printer {0} successfully installed.", printer.PrinterName);
            }

            log.Info("Installing PDF engine.");
            var pdfEngine = new PdfEngine(currentDirectory, platform);

            pdfEngine.Install();

            log.Success("PDF engine installed successfully.");

            log.Info("Configuring port.");
            virtualPrinterManager.ConfigureVirtualPort(printer, pdfEngine);
            log.Success("Port configured successfully.");

            log.Info("Restarting spool service. Please wait...");
            virtualPrinterManager.RestartSpoolService();
            log.Success("Restart spool service complete.");
        }