private void printerSelect_button_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(device_textBox.Text))
     {
         using (DynamicLocalPrintQueueForm localQueueForm = new DynamicLocalPrintQueueForm(false))
         {
             localQueueForm.ShowDialog(this);
             if (localQueueForm.DialogResult == DialogResult.OK)
             {
                 _localPrintQueueInfo = localQueueForm.PrintQueues.First();
                 device_textBox.Text  = _localPrintQueueInfo.AssociatedAssetId + @", " + _localPrintQueueInfo.PrintDriver.DriverName;
             }
         }
     }
     else
     {
         using (DynamicLocalPrintQueueForm localQueueForm = new DynamicLocalPrintQueueForm(_localPrintQueueInfo, false))
         {
             localQueueForm.ShowDialog(this);
             {
                 if (localQueueForm.DialogResult == DialogResult.OK)
                 {
                     _localPrintQueueInfo = localQueueForm.PrintQueues.First();
                     device_textBox.Text  = _localPrintQueueInfo.AssociatedAssetId + @", " + _localPrintQueueInfo.PrintDriver.DriverName;
                 }
             }
         }
     }
 }
        public void Initialize(PluginConfigurationData configuration, PluginEnvironment environment)
        {
            // Initialize the activity data by deserializing it from an existing copy of configuration information.
            _activityData = configuration.GetMetadata <MailMergeActivityData>();

            DynamicLocalPrintQueueDefinition definition = configuration.PrintQueues.SelectedPrintQueues.First() as DynamicLocalPrintQueueDefinition;
            IPrinterInfo    printDevice = ConfigurationServices.AssetInventory.GetAsset(definition.AssetId) as IPrinterInfo;
            PrintDriverInfo printDriver = ConfigurationServices.AssetInventory.AsInternal().GetPrintDrivers().First(n => n.PrintDriverId == definition.PrintDriverId);

            _localPrintQueueInfo = new DynamicLocalPrintQueueInfo(printDevice, printDriver, definition.PrinterPort, definition.PrintDriverConfiguration);

            PopulateMailMergeUi();
        }
        public void Initialize(PluginConfigurationData configuration, PluginEnvironment environment)
        {
            _activityData          = configuration?.GetMetadata <PrintQueueManagementActivityData>();
            _documentSelectionData = configuration?.Documents;

            DynamicLocalPrintQueueDefinition definition = configuration?.PrintQueues.SelectedPrintQueues.First() as DynamicLocalPrintQueueDefinition;
            IPrinterInfo printDevice = ConfigurationServices.AssetInventory.GetAsset(definition.AssetId) as IPrinterInfo;

            _printDriver         = ConfigurationServices.AssetInventory.AsInternal().GetPrintDrivers().First(n => n.PrintDriverId == definition.PrintDriverId);
            _localPrintQueueInfo = new DynamicLocalPrintQueueInfo(printDevice, _printDriver, definition.PrinterPort, definition.PrintDriverConfiguration);

            LoadDocuments();
            LoadUi();
        }
Exemplo n.º 4
0
        private void EditDynamicQueue(LocalPrintQueueRow row, DynamicLocalPrintQueueInfo dynamicQueue)
        {
            using (DynamicLocalPrintQueueForm form = new DynamicLocalPrintQueueForm(dynamicQueue, true))
            {
                if (form.ShowDialog(this) == DialogResult.OK)
                {
                    _printQueueRows.Remove(row);
                    _printQueues.Remove(dynamicQueue);

                    foreach (DynamicLocalPrintQueueInfo queue in form.PrintQueues)
                    {
                        _printQueues.Add(queue);
                        _printQueueRows.Add(new LocalPrintQueueRow(queue));
                    }
                }
            }
        }
Exemplo n.º 5
0
        public LocalPrintDeviceInstaller(DynamicLocalPrintQueueInfo printQueueInfo)
        {
            _printQueueInfo = printQueueInfo;
            if (!string.IsNullOrEmpty(printQueueInfo.PrintDriverConfiguration.FileName))
            {
                _portName = string.Format("{0}_IP_{1}:{2}", printQueueInfo.PrintDriverConfiguration.FileName, printQueueInfo.Address, printQueueInfo.PortNumber);
            }
            else
            {
                _portName = string.Format("IP_{0}:{1}", printQueueInfo.Address, printQueueInfo.PortNumber);
            }

            _driver          = CreateDriver(printQueueInfo.PrintDriver, GlobalSettings.Items[Setting.PrintDriverServer]);
            _configFile      = printQueueInfo.PrintDriverConfiguration.ConfigurationFile;
            _defaultShortcut = printQueueInfo.PrintDriverConfiguration.DefaultShortcut;

            QueueName       = printQueueInfo.QueueName;
            DriverName      = _driver.Name;
            DefaultShortcut = _defaultShortcut;
        }
Exemplo n.º 6
0
            public PrintQueueRow(PrintQueueInfo queue)
            {
                QueueName   = queue.QueueName;
                PrintServer = "Client";
                QueueType   = "Local";
                Device      = queue.AssociatedAssetId;

                RemotePrintQueueInfo remoteQueue = queue as RemotePrintQueueInfo;

                if (remoteQueue != null)
                {
                    PrintServer = remoteQueue.ServerHostName;
                    QueueType   = "Remote";
                }

                DynamicLocalPrintQueueInfo dynamicLocalQueue = queue as DynamicLocalPrintQueueInfo;

                if (dynamicLocalQueue != null)
                {
                    QueueName = string.Format("{0}\\{1} on {2}", dynamicLocalQueue.PrintDriver.PackageName, dynamicLocalQueue.PrintDriver.DriverName, dynamicLocalQueue.AssociatedAssetId);
                }
            }
Exemplo n.º 7
0
        private void edit_ToolStripButton_Click(object sender, EventArgs e)
        {
            var selectedRow = printQueue_GridView.SelectedRows.FirstOrDefault();

            if (selectedRow != null)
            {
                LocalPrintQueueRow row = selectedRow.DataBoundItem as LocalPrintQueueRow;
                if (row != null)
                {
                    LocalPrintQueueInfo localQueue = row.PrintQueueInfo as LocalPrintQueueInfo;
                    if (localQueue != null)
                    {
                        EditLocalQueue(row, localQueue);
                    }

                    DynamicLocalPrintQueueInfo dynamicQueue = row.PrintQueueInfo as DynamicLocalPrintQueueInfo;
                    if (dynamicQueue != null)
                    {
                        EditDynamicQueue(row, dynamicQueue);
                    }
                }
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DynamicLocalPrintQueueForm"/> class
        /// using information from the specified print queue.
        /// </summary>
        /// <param name="printQueue">The print queue whose information should be populated into the form.</param>
        /// <param name="allowMultipleDevices">if set to <c>true</c> allow multiple devices to be selected.</param>
        /// <exception cref="ArgumentNullException"><paramref name="printQueue" /> is null.</exception>
        public DynamicLocalPrintQueueForm(DynamicLocalPrintQueueInfo printQueue, bool allowMultipleDevices)
            : this()
        {
            if (printQueue == null)
            {
                throw new ArgumentNullException(nameof(printQueue));
            }

            _allowMultipleDevices = allowMultipleDevices;
            if (!string.IsNullOrEmpty(printQueue.AssociatedAssetId))
            {
                if (ConfigurationServices.AssetInventory.GetAsset(printQueue.AssociatedAssetId) is IPrinterInfo printDevice)
                {
                    _selectedPrintDevices.Add(printDevice);
                    printDevices_TextBox.Text = printQueue.AssociatedAssetId;
                }
            }
            printDriverSelectionControl.Initialize(printQueue.PrintDriver.PrintDriverId);

            if (printQueue.PrinterPort is LprPrinterPortInfo lprPrinterPort)
            {
                portType_ComboBox.SelectedItem = PrinterPortProtocol.Lpr;
                queueName_TextBox.Text         = lprPrinterPort.QueueName;
            }
            else
            {
                portType_ComboBox.SelectedItem = PrinterPortProtocol.Raw;
            }

            LoadCfmFiles();
            if (printQueue.PrintDriverConfiguration != null && printQueue.PrintDriverConfiguration.ConfigurationFile != null)
            {
                cfmFile_ComboBox.SelectedItem  = printQueue.PrintDriverConfiguration.ConfigurationFile;
                shortcut_ComboBox.SelectedItem = printQueue.PrintDriverConfiguration.DefaultShortcut;
            }
        }
Exemplo n.º 9
0
        public PluginExecutionResult Execute(PluginExecutionData executionData)
        {
            _activityData       = executionData?.GetMetadata <PrintQueueManagementActivityData>();
            _documentCollection = executionData?.Documents;

            _localPrintQueueInfo = executionData?.PrintQueues.First() as DynamicLocalPrintQueueInfo;

            _taskCounter = 0;

            foreach (var pqmTask in _activityData.PrintQueueTasks)
            {
                activityStatus_dataGridView.DataSource = null;

                switch (pqmTask.Operation)
                {
                case PrintQueueOperation.Install:
                {
                    pqmTask.Status = InstallPrintQueue(executionData);
                }
                break;

                case PrintQueueOperation.Upgrade:
                {
                    UpgradePrintQueue(pqmTask, executionData.Environment.PluginSettings);
                }
                break;

                case PrintQueueOperation.Uninstall:
                {
                    pqmTask.Status = UninstallPrintQueue();
                }
                break;

                case PrintQueueOperation.Print:
                {
                    pqmTask.Status = PrintDocument(pqmTask.TargetObject.ToString());
                }
                break;

                case PrintQueueOperation.Cancel:
                {
                    pqmTask.Status = CancelDocument(pqmTask.TargetObject.ToString(), pqmTask.Delay);
                }
                break;

                case PrintQueueOperation.Configure:
                {
                    ConfigureQueueForm(pqmTask);
                }
                break;
                }
                activityStatus_dataGridView.Visible = false;

                activityStatus_dataGridView.DataSource = _activityData.PrintQueueTasks;
                activityStatus_dataGridView.Visible    = true;

                _taskCounter++;
            }

            return(_activityData.PrintQueueTasks.All(x => x.Status == Status.Passed) ? new PluginExecutionResult(PluginResult.Passed) : new PluginExecutionResult(PluginResult.Failed));
        }
Exemplo n.º 10
0
        private static PrintQueue GetCitrixPrintQueue(PrintQueueInfo printQueueInfo)
        {
            // Special handling for Citrix session queues - they are connections to a remote server,
            // but don't show up when querying the local server for a list of queues.
            // Connect to the queue directly by parsing the queue name
            LocalPrintQueueInfo localPrintQueueInfo = printQueueInfo as LocalPrintQueueInfo;

            if (localPrintQueueInfo != null)
            {
                LogDebug("Attempting to parse Citrix session queue.");
                var match = Regex.Match(localPrintQueueInfo.QueueName, @"^\\\\([\S\s]+)\\([\S\s]+)$");
                if (match.Success)
                {
                    LogDebug("Parse success.");
                    var serverName = match.Groups[1];
                    var queueName  = match.Groups[2];

                    LogDebug($"Server Name: {serverName}");
                    LogDebug($"Queue Name: {queueName}");

                    PrintServer server = new PrintServer($@"\\{serverName}");
                    return(new PrintQueue(server, localPrintQueueInfo.QueueName));
                }
                else
                {
                    LogDebug("Parse failure.");
                }
            }

            // When Citrix auto-generates a print queue on the Citrix server, it creates a queue with the
            // same name as the local print queue on the client machine, but appends some session information
            // to the end.  To find the real name of the print queue on the Citrix server, we need to
            // find a print queue installed on the system that starts with the same text generated by the base class.
            LogDebug($"Looking for {printQueueInfo.QueueName}");

            List <string> queueNames = PrintQueueController.GetPrintQueues().Select(n => n.FullName).ToList();
            string        clientName = Environment.GetEnvironmentVariable("CLIENTNAME");

            RemotePrintQueueInfo remotePrintQueueInfo = printQueueInfo as RemotePrintQueueInfo;

            if (remotePrintQueueInfo != null)
            {
                string citrixQueueName = queueNames.FirstOrDefault(
                    n => n.StartsWith(remotePrintQueueInfo.QueueName, StringComparison.OrdinalIgnoreCase) &&
                    n.Contains(remotePrintQueueInfo.ServerHostName, StringComparison.OrdinalIgnoreCase) &&
                    n.Contains(clientName, StringComparison.OrdinalIgnoreCase));

                if (citrixQueueName != null)
                {
                    LogDebug($"Found Citrix queue {citrixQueueName}");
                    return(PrintQueueController.GetPrintQueue(citrixQueueName));
                }
                else
                {
                    LogDebug($"Did not find mapped queue.  Looking for directly attached queue.");
                    return(PrintQueueController.GetPrintQueue(remotePrintQueueInfo.GetPrinterName()));
                }
            }

            DynamicLocalPrintQueueInfo dynamicPrintQueueInfo = printQueueInfo as DynamicLocalPrintQueueInfo;

            if (dynamicPrintQueueInfo != null)
            {
                string citrixQueueName = queueNames.FirstOrDefault(
                    n => n.StartsWith(dynamicPrintQueueInfo.QueueName, StringComparison.OrdinalIgnoreCase) &&
                    n.Contains(clientName, StringComparison.OrdinalIgnoreCase));
                if (citrixQueueName != null)
                {
                    LogDebug($"Found Citrix queue {citrixQueueName}");
                    return(PrintQueueController.GetPrintQueue(citrixQueueName));
                }
                else
                {
                    throw new PrintQueueNotFoundException($"Could not find mapped queue for {dynamicPrintQueueInfo.QueueName}");
                }
            }

            // Default to the usual behavior
            return(PrintQueueController.Connect(printQueueInfo));
        }
Exemplo n.º 11
0
 public LocalPrintQueueRow(DynamicLocalPrintQueueInfo queue)
     : this((PrintQueueInfo)queue)
 {
     QueueName = string.Format("{0}\\{1} on {2}", queue.PrintDriver.PackageName, queue.PrintDriver.DriverName, queue.AssociatedAssetId);
     QueueType = "Dynamic";
 }