Exemple #1
0
        /// <summary>
        /// Initializes this control by loading all drivers from the asset inventory
        /// with the specified driver selected.
        /// </summary>
        /// <param name="printDriver">The print driver to select.</param>
        /// <exception cref="ArgumentNullException"><paramref name="printDriver" /> is null.</exception>
        public void Initialize(PrintDriverInfo printDriver)
        {
            if (printDriver == null)
            {
                throw new ArgumentNullException(nameof(printDriver));
            }

            Initialize();
            SetSelectedPrintDriver(printDriver.PrintDriverId);
        }
        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();
        }
Exemple #3
0
        private void SetSelectedPrintDriver(Guid printDriverId)
        {
            _suppressSelectionChanged = true;

            PrintDriverInfo driverToSelect = _drivers.FirstOrDefault(n => n.PrintDriverId == printDriverId);

            if (driverToSelect != null)
            {
                driverPackage_ComboBox.SelectedItem = driverToSelect.PackageName;
                driverModel_ComboBox.SelectedItem   = driverToSelect;
            }

            _suppressSelectionChanged = false;
        }
        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();
        }
        /// <summary>
        /// Retrieves print driver configurations that match the specified device and driver.
        /// </summary>
        /// <param name="device">The device.</param>
        /// <param name="driver">The driver.</param>
        /// <returns>Print driver configurations for the specified device and driver.</returns>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="device" /> is null.
        /// <para>or</para>
        /// <paramref name="driver" /> is null.
        /// </exception>
        public IEnumerable <string> GetPrintDriverConfigurations(IDeviceInfo device, PrintDriverInfo driver)
        {
            if (device == null)
            {
                throw new ArgumentNullException(nameof(device));
            }

            if (driver == null)
            {
                throw new ArgumentNullException(nameof(driver));
            }

            // No filtering in the mock
            return(GetPrintDriverConfigurations());
        }
        /// <summary>
        /// Retrieves <see cref="PrintDriverInfo" /> for all print drivers in the inventory.
        /// </summary>
        /// <returns><see cref="PrintDriverInfo" /> for all print drivers in the inventory.</returns>
        public IEnumerable <PrintDriverInfo> GetPrintDrivers()
        {
            List <PrintDriverInfo> printDrivers = new List <PrintDriverInfo>();

            DatabaseQuery(Resources.SelectPrintDrivers, record =>
            {
                PrintDriverInfo driverInfo = new PrintDriverInfo
                                             (
                    (Guid)record["PrintDriverId"],
                    record["DriverName"] as string,
                    record["PackageName"] as string,
                    record["PrintProcessor"] as string,
                    record["InfX86"] as string,
                    record["InfX64"] as string
                                             );
                printDrivers.Add(driverInfo);
            });

            return(printDrivers);
        }
        private static DriverDetails CreateDriver(PrintDriverInfo printDriverInfo, string printDriverServer)
        {
            var driver = new DriverDetails();

            driver.Name           = printDriverInfo.DriverName;
            driver.PrintProcessor = printDriverInfo.PrintProcessor;

            if (!Environment.Is64BitOperatingSystem)
            {
                driver.Architecture = DriverArchitecture.NTx86;
                driver.InfPath      = Path.Combine(printDriverServer, printDriverInfo.InfX86);
            }
            else
            {
                driver.Architecture = DriverArchitecture.NTAMD64;
                driver.InfPath      = Path.Combine(printDriverServer, printDriverInfo.InfX64);
            }

            return(driver);
        }
Exemple #8
0
        /// <summary>
        /// Retrieves print driver configurations that match the specified device and driver.
        /// </summary>
        /// <param name="device">The device.</param>
        /// <param name="driver">The driver.</param>
        /// <returns>Print driver configurations for the specified device and driver.</returns>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="device" /> is null.
        /// <para>or</para>
        /// <paramref name="driver" /> is null.
        /// </exception>
        public IEnumerable <string> GetPrintDriverConfigurations(IDeviceInfo device, PrintDriverInfo driver)
        {
            if (device == null)
            {
                throw new ArgumentNullException(nameof(device));
            }

            if (driver == null)
            {
                throw new ArgumentNullException(nameof(driver));
            }

            // Extract the version value out of the selected package's version
            string version = driver.PackageName.Split('\\').First();

            using (AssetInventoryContext context = new AssetInventoryContext(_connectionString))
            {
                return(context.PrintDriverConfigs.Where(n => n.PrintDriverProducts.Any(m => m.Name == device.ProductName) &&
                                                        n.PrintDriverVersions.Any(m => m.Value == version))
                       .Select(n => n.ConfigFile).ToList());
            }
        }
Exemple #9
0
        private IEnumerable <PrintQueueInfo> CreateDynamicPrintQueues(PrintQueueSelectionData printQueueSelectionData)
        {
            using (AssetInventoryContext context = DbConnect.AssetInventoryContext())
            {
                var printQueueDefinitions = printQueueSelectionData.SelectedPrintQueues.OfType <DynamicLocalPrintQueueDefinition>();
                var assetIds  = printQueueDefinitions.Select(n => n.AssetId);
                var driverIds = printQueueDefinitions.Select(n => n.PrintDriverId);

                var assets  = context.Assets.Where(n => assetIds.Contains(n.AssetId)).ToAssetInfoCollection();
                var drivers = context.PrintDrivers.Where(n => driverIds.Contains(n.PrintDriverId)).ToPrintDriverInfoCollection();

                foreach (DynamicLocalPrintQueueDefinition definition in printQueueDefinitions)
                {
                    IPrinterInfo    printDevice = assets.FirstOrDefault(n => n.AssetId == definition.AssetId) as IPrinterInfo;
                    PrintDriverInfo printDriver = drivers.FirstOrDefault(n => n.PrintDriverId == definition.PrintDriverId);
                    if (printDevice != null && printDriver != null)
                    {
                        yield return(new DynamicLocalPrintQueueInfo(printDevice, printDriver, definition.PrinterPort, definition.PrintDriverConfiguration));
                    }
                }
            }
        }
Exemple #10
0
        private void LoadPrintQueues(PrintQueueDefinitionCollection printQueueDefinitions)
        {
            _printQueues.Clear();

            foreach (LocalPrintQueueDefinition local in printQueueDefinitions.OfType <LocalPrintQueueDefinition>())
            {
                _printQueues.Add(new LocalPrintQueueInfo(local.QueueName, local.AssociatedAssetId));
            }

            var remotePrintQueues = ConfigurationServices.AssetInventory.GetRemotePrintQueues().ToList();

            foreach (RemotePrintQueueDefinition remote in printQueueDefinitions.OfType <RemotePrintQueueDefinition>())
            {
                var queue = remotePrintQueues.FirstOrDefault(n => n.PrintQueueId == remote.PrintQueueId);
                if (queue != null)
                {
                    _printQueues.Add(queue);
                }
            }

            var dynamicQueueDefinitions = printQueueDefinitions.OfType <DynamicLocalPrintQueueDefinition>().ToList();

            if (dynamicQueueDefinitions.Any())
            {
                var printers = ConfigurationServices.AssetInventory.GetAssets(dynamicQueueDefinitions.Select(n => n.AssetId)).OfType <IPrinterInfo>().ToList();
                var drivers  = ConfigurationServices.AssetInventory.AsInternal().GetPrintDrivers().ToList();
                foreach (DynamicLocalPrintQueueDefinition definition in dynamicQueueDefinitions)
                {
                    IPrinterInfo    printer = printers.FirstOrDefault(n => n.AssetId == definition.AssetId);
                    PrintDriverInfo driver  = drivers.FirstOrDefault(n => n.PrintDriverId == definition.PrintDriverId);
                    if (printer != null && driver != null)
                    {
                        _printQueues.Add(new DynamicLocalPrintQueueInfo(printer, driver, definition.PrinterPort, definition.PrintDriverConfiguration));
                    }
                }
            }
        }