Example #1
0
 private void cmdPurgeQueue_Click(object sender, RoutedEventArgs e)
 {
     if (lstQueues.SelectedValue != null)
     {
         PrintQueue queue = printServer.GetPrintQueue(lstQueues.SelectedValue.ToString());
         queue.Purge();
     }
 }
Example #2
0
        public string ClearQueue()
        {
            LocalPrintServer ps = new LocalPrintServer();
            PrintQueue       pq = ps.GetPrintQueue("");/// ( DefaultPrintQueue;

            pq.Purge();
            return("Ok");
        }
Example #3
0
        protected static void PurgeLocalPrintQueues()
        {
            LocalPrintServer localMachine = new LocalPrintServer(PrintSystemDesiredAccess.AdministrateServer);

            foreach (var queue in localMachine.GetPrintQueues())
            {
                // Need to create another print queue object with sufficient privileges to purge
                PrintQueue privilegedQueue = new PrintQueue(localMachine, queue.Name, PrintSystemDesiredAccess.AdministratePrinter);
                privilegedQueue.Purge();
            }
        }
Example #4
0
 private static void PurgeRemotePrintQueue(string serverName, string printQueueName)
 {
     try
     {
         using (PrintServer ps = new PrintServer(@"\\" + serverName))
         {
             using (PrintQueue queue = new PrintQueue(ps, printQueueName, PrintSystemDesiredAccess.AdministratePrinter))
             {
                 queue.Purge();
             }
         }
     }
     catch (Exception e)
     {
         TraceFactory.Logger.Debug(e);
     }
 }
Example #5
0
 public static bool CleanPrintQueue(string PrinterName)
 {
     try
     {
         LocalPrintServer _printServer = new LocalPrintServer(PrintSystemDesiredAccess.AdministratePrinter);
         PrintQueue       printqueue   = new PrintQueue(_printServer, PrinterName);
         printqueue.Refresh();
         if (printqueue.NumberOfJobs != 0)
         {
             printqueue.Purge();
         }
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }