Beispiel #1
0
 /// <summary>
 /// Sets the job render location for the specified print queue.
 /// </summary>
 /// <param name="queue">The <see cref="PrintQueue" /> to modify.</param>
 /// <param name="location">The <see cref="PrintJobRenderLocation" />.</param>
 /// <exception cref="ArgumentException"><paramref name="location" /> is <see cref="PrintJobRenderLocation.Unknown" /></exception>
 public static void SetJobRenderLocation(PrintQueue queue, PrintJobRenderLocation location)
 {
     // This feature only applies to Vista and greater
     if (Environment.OSVersion.Version.Major >= 6)
     {
         PrintRegistryUtil.SetJobRenderLocation(queue, location);
     }
 }
Beispiel #2
0
        /// <summary>
        /// Sets the job render location for the specified print queue.
        /// </summary>
        /// <param name="queue">The <see cref="PrintQueue" /> to modify.</param>
        /// <param name="location">The <see cref="PrintJobRenderLocation" />.</param>
        /// <exception cref="ArgumentException"><paramref name="location" /> is <see cref="PrintJobRenderLocation.Unknown" /></exception>
        internal static void SetJobRenderLocation(PrintQueue queue, PrintJobRenderLocation location)
        {
            if (location == PrintJobRenderLocation.Unknown)
            {
                throw new ArgumentException("Cannot set job render location to Unknown.", nameof(location));
            }

            RegistryKey driverData = Registry.LocalMachine.OpenSubKey(_printersSubKey).OpenSubKey(queue.FullName).OpenSubKey("PrinterDriverData", true);

            driverData?.SetValue("EMFDespoolingSetting", (int)location);
            driverData?.Close();
        }
Beispiel #3
0
        private MonitoredQueueInfoCache GetQueueInfo(string queueName)
        {
            MonitoredQueueInfoCache cachedInfo = null;

            try
            {
                //Try to retrieve from the cache
                if (!_cache.TryGetValue(queueName, out cachedInfo))
                {
                    cachedInfo = new MonitoredQueueInfoCache(queueName)
                    {
                        PrintServer   = Environment.MachineName,
                        PrintServerOS = Environment.OSVersion.ToString()
                    };
                    _cache.Add(queueName, cachedInfo);
                }

                // Refresh queue data if older than 5 minutes
                if (cachedInfo.QueueSettingsRetrieved < DateTime.Now.AddMinutes(-5))
                {
                    PrintQueue queue = PrintQueueController.GetPrintQueue(queueName);
                    cachedInfo.Refresh(queue);

                    PrintJobRenderLocation location = PrintQueueController.GetJobRenderLocation(queue);
                    if (location != PrintJobRenderLocation.Unknown)
                    {
                        cachedInfo.RenderOnClient = (location == PrintJobRenderLocation.Client);
                    }
                    else
                    {
                        cachedInfo.RenderOnClient = null;
                    }

                    cachedInfo.QueueSettingsRetrieved = DateTime.Now;
                }
            }
            catch (Win32Exception ex)
            {
                TraceFactory.Logger.Error("Unable to get queue data for {0}".FormatWith(queueName), ex);
            }

            return(cachedInfo);
        }