예제 #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
 private File getWorkingDirectory(File f) {
   try {
     File workingDir =
         new File(
             Properties.get(Names.WORKING_DIR)
                 + Names.PATH_SEPARATOR
                 + getOpType()
                 + Names.PATH_SEPARATOR
                 + "work"
                 + getNewCount());
     if (!workingDir.exists()) workingDir.mkdirs();
     FileUtil.deleteContents(workingDir);
     return workingDir;
   } catch (Exception ignore) {
     // ++ notify of error - maybe out of disk space
     ignore.printStackTrace();
     return null;
   }
 }