Пример #1
0
 public static synchronized void printPS(Origin o, String printerAlias, int copyCount)
     throws Exception {
   String command = Properties.get(Names.PS_PRINT_APP);
   Printer printer = find(printerAlias);
   File printTemp =
       new File(
           Properties.get(Names.TEMP_DIR) + Names.PATH_SEPARATOR + "print-queue",
           "print-" + getNextCount());
   if (printTemp.exists()) FileUtil.delete(printTemp);
   printTemp.mkdirs();
   InputStream in = Downloader.download(o);
   File print = new File(printTemp, o.getName());
   if (print.exists()) print.delete();
   FileUtil.save(in, print, true);
   File work =
       new File(
           Properties.get(Names.WORKING_DIR) + Names.PATH_SEPARATOR + "print",
           "work-" + getNextCount());
   if (!work.exists()) work.mkdirs();
   int i;
   for (i = 0; i < copyCount; i++) {
     ExecShell shell = new ExecShell();
     shell.setExecutable(command);
     shell.setWorkingDirectory(work);
     shell.addCommandLineArgument("/D:" + printer.getPath(), false);
     shell.addCommandLineArgument(print.getAbsolutePath(), true);
     {
     } // Logwriter.printOnConsole("sleeping for 2..");
     Thread.sleep(2000);
     {
     } // Logwriter.printOnConsole("waking up");
     shell.execute();
   }
 }
Пример #2
0
 public static Collection getPrinterNames() {
   Collection names = new Vector();
   Collection c = findAll();
   if (null == c) return names;
   Iterator i = c.iterator();
   String name;
   Printer p;
   while (i.hasNext()) {
     p = (Printer) i.next();
     name = p.getName();
     names.add(name);
   }
   return names;
 }
Пример #3
0
 public static void update(Printer named) {
   remove(named.getName());
   try {
     add(named);
   } catch (Exception a) {
   }
 }
Пример #4
0
 public static void remove(Printer named) {
   remove(named.getName());
 }