Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 12.08 KB | None | 0 0
  1. package main;
  2.  
  3. import java.io.File;
  4. import java.io.IOException;
  5. import java.io.PrintWriter;
  6. import java.text.DateFormat;
  7. import java.text.ParseException;
  8. import java.text.SimpleDateFormat;
  9. import java.time.DayOfWeek;
  10. import java.util.Calendar;
  11. import java.util.Date;
  12.  
  13. import javafx.application.Application;
  14. import javafx.scene.Scene;
  15. import javafx.scene.control.Button;
  16. import javafx.scene.control.Label;
  17. import javafx.scene.layout.BorderPane;
  18. import javafx.scene.layout.GridPane;
  19. import javafx.stage.Stage;
  20. import podaci.SyncPipe;
  21.  
  22. public class Main extends Application
  23. {
  24.  
  25.     public static void main(String[] args)
  26.     {
  27.         launch(args);
  28.  
  29.     }
  30.  
  31.     @Override
  32.     public void start(Stage primaryStage) throws Exception
  33.     {
  34.         GridPane bp = new GridPane();
  35.         Label lbl = new Label("Trenutan datum: ");
  36.         DateFormat fa = new SimpleDateFormat("dd-MM-yyyy");
  37.         Date fu = new Date();
  38.         lbl.setText(lbl.getText() + fa.format(fu));
  39.         Button dugme = new Button("Dugmeeee");
  40.         Button provera = new Button("Provera");
  41.         bp.add(dugme, 0, 0);
  42.         bp.add(lbl, 0, 1);
  43.         bp.add(provera, 0, 2);
  44.         dugme.setOnAction(e->
  45.         {
  46.             DateFormat datum1 = new SimpleDateFormat("dd-MM-yyyy");
  47.             Date date = new Date();
  48.             lbl.setText(lbl.getText() + datum1.format(date));
  49.             Calendar kalendar = Calendar.getInstance();
  50.             String[] command =
  51.                 {
  52.                     "cmd",
  53.                 };
  54.                 Process p;
  55.                 try
  56.                 {
  57.                     p = Runtime.getRuntime().exec(command);
  58.  
  59.                 new Thread(new SyncPipe(p.getErrorStream(), System.err)).start();
  60.                 new Thread(new SyncPipe(p.getInputStream(), System.out)).start();
  61.  
  62.                 PrintWriter stdin = new PrintWriter(p.getOutputStream());
  63.  
  64.               //-----------------------------LEKOVI------------------------------------//
  65.                 for(int i = 0; i < 30; i++)
  66.                 {
  67.                     int dan = kalendar.get(Calendar.DAY_OF_MONTH);
  68.                     int mesec = kalendar.get(Calendar.MONTH);
  69.                     int godina = kalendar.get(Calendar.YEAR);
  70.  
  71.                     if(dan<10 && mesec<10)
  72.                     {
  73.                         stdin.println("wget -r --output-document=rfzo_lekovi.zip --http-user=aukm --http-password=mkua "
  74.                                 + "http://portal.rfzo.rs/recepti-pomagala/Sifarnici/novo/novafaktura_s_lekovi_0"
  75.                                     + (dan) + "_0" + (mesec+1) + "_" + (godina) + ".zip");
  76.                     }
  77.                     else
  78.                     {
  79.                         if(dan<10)
  80.                         {
  81.                             stdin.println("wget -r --output-document=rfzo_lekovi.zip --http-user=aukm --http-password=mkua "
  82.                                     + "http://portal.rfzo.rs/recepti-pomagala/Sifarnici/novo/novafaktura_s_lekovi_0"
  83.                                         + (dan) + "_" + (mesec+1) + "_" + (godina) + ".zip");
  84.                         }
  85.                         else if(mesec<10)
  86.                         {
  87.                             stdin.println("wget -r --output-document=rfzo_lekovi.zip --http-user=aukm --http-password=mkua "
  88.                                     + "http://portal.rfzo.rs/recepti-pomagala/Sifarnici/novo/novafaktura_s_lekovi_"
  89.                                         + (dan) + "_0" + (mesec+1) + "_" + (godina) + ".zip");
  90.                         }
  91.                         else
  92.                         {
  93.                             stdin.println("wget -r --output-document=rfzo_lekovi.zip --http-user=aukm --http-password=mkua "
  94.                                     + "http://portal.rfzo.rs/recepti-pomagala/Sifarnici/novo/novafaktura_s_lekovi_"
  95.                                         + (dan) + "_" + (mesec+1) + "_" + (godina) + ".zip");
  96.                         }
  97.                     }
  98.                     stdin.println("7za e rfzo_lekovi.zip");
  99.  
  100.                     if(dan<10 && mesec<10)
  101.                     {
  102.                         File tmpDir = new File("novafaktura_s_lekovi_0" + (dan) + "_0" + (mesec+1) + "_" + (godina) + ".xml");
  103.                         System.out.println(tmpDir.getAbsolutePath());
  104.                         if(tmpDir.exists())
  105.                             break;
  106.                     }
  107.                     else
  108.                     {
  109.                         if(dan<10)
  110.                         {
  111.                             File tmpDir = new File("novafaktura_s_lekovi_0" + (dan) + "_" + (mesec+1) + "_" + (godina) + ".xml");
  112.                             if(tmpDir.exists())
  113.                                 break;
  114.                         }
  115.                         else if(mesec<10)
  116.                         {
  117.                             File tmpDir = new File("novafaktura_s_lekovi_" + (dan) + "_0" + (mesec+1) + "_" + (godina) + ".xml");
  118.                             if(tmpDir.exists())
  119.                                 break;
  120.                         }
  121.                         else
  122.                         {
  123.                             File tmpDir = new File("novafaktura_s_lekovi_" + (dan) + "_" + (mesec+1) + "_" + (godina) + ".xml");
  124.                             if(tmpDir.exists())
  125.                                 break;
  126.                         }
  127.                     }
  128.                     kalendar.add(Calendar.DATE, -1);
  129.  
  130.                 }
  131.  
  132.                 kalendar = Calendar.getInstance();
  133.  
  134.               //-----------------------------LEKARI------------------------------------//
  135.                 /*for(int i = 0; i < 30; i++)
  136.                 {
  137.                     int dan = kalendar.get(Calendar.DAY_OF_MONTH);
  138.                     int mesec = kalendar.get(Calendar.MONTH);
  139.                     int godina = kalendar.get(Calendar.YEAR);
  140.  
  141.                     if(dan<10 && mesec<10)
  142.                     {
  143.                         stdin.println("wget -r --output-document=rfzo_lekari.zip --http-user=aukm --http-password=mkua "
  144.                                 + "http://portal.rfzo.rs/recepti-pomagala/Sifarnici/novo/novafaktura_s_lekari_0"
  145.                                     + (dan) + "_0" + (mesec+1) + "_" + (godina) + ".zip");
  146.                     }
  147.                     else
  148.                     {
  149.                         if(dan<10)
  150.                         {
  151.                             stdin.println("wget -r --output-document=rfzo_lekari.zip --http-user=aukm --http-password=mkua "
  152.                                     + "http://portal.rfzo.rs/recepti-pomagala/Sifarnici/novo/novafaktura_s_lekari_0"
  153.                                         + (dan) + "_" + (mesec+1) + "_" + (godina) + ".zip");
  154.                         }
  155.                         else if(mesec<10)
  156.                         {
  157.                             stdin.println("wget -r --output-document=rfzo_lekari.zip --http-user=aukm --http-password=mkua "
  158.                                     + "http://portal.rfzo.rs/recepti-pomagala/Sifarnici/novo/novafaktura_s_lekari_"
  159.                                         + (dan) + "_0" + (mesec+1) + "_" + (godina) + ".zip");
  160.                         }
  161.                         else
  162.                         {
  163.                             stdin.println("wget -r --output-document=rfzo_lekari.zip --http-user=aukm --http-password=mkua "
  164.                                     + "http://portal.rfzo.rs/recepti-pomagala/Sifarnici/novo/novafaktura_s_lekari_"
  165.                                         + (dan) + "_" + (mesec+1) + "_" + (godina) + ".zip");
  166.                         }
  167.                     }
  168.                     stdin.println("7za e rfzo_lekari.zip");
  169.  
  170.                     File tmpDir = null;
  171.                     if(dan<10 && mesec<10)
  172.                     {
  173.                         tmpDir = new File("novafaktura_s_lekari_0" + (dan) + "_0" + (mesec+1) + "_" + (godina) + ".xml");
  174.                     }
  175.                     else
  176.                     {
  177.                         if(dan<10)
  178.                         {
  179.                             tmpDir = new File("novafaktura_s_lekari_0" + (dan) + "_" + (mesec+1) + "_" + (godina) + ".zip");
  180.                         }
  181.                         else if(mesec<10)
  182.                         {
  183.                             tmpDir = new File("novafaktura_s_lekari_" + (dan) + "_0" + (mesec+1) + "_" + (godina) + ".zip");
  184.                         }
  185.                         else
  186.                         {
  187.                             tmpDir = new File("novafaktura_s_lekari_" + (dan) + "_" + (mesec+1) + "_" + (godina) + ".zip");
  188.                         }
  189.                     }
  190.  
  191.                     if(tmpDir.exists())
  192.                     {
  193.                         break;
  194.                     }
  195.  
  196.                     kalendar.add(Calendar.DATE, -1);
  197.                 }
  198.  
  199.                 kalendar = Calendar.getInstance();*/
  200.  
  201.               //-----------------------------OOP------------------------------------//
  202.                 /*for(int i = 0; i < 30; i++)
  203.                 {
  204.                     int dan = kalendar.get(Calendar.DAY_OF_MONTH);
  205.                     int mesec = kalendar.get(Calendar.MONTH);
  206.                     int godina = kalendar.get(Calendar.YEAR);
  207.  
  208.                     if(dan<10 && mesec<10)
  209.                     {
  210.                         stdin.println("wget -r --output-document=rfzo_oop.zip --http-user=aukm --http-password=mkua "
  211.                                 + "http://portal.rfzo.rs/recepti-pomagala/Sifarnici/novo/novafaktura_oop_0"
  212.                                     + (dan) + "_0" + (mesec+1) + "_" + (godina) + ".zip");
  213.                     }
  214.                     else
  215.                     {
  216.                         if(dan<10)
  217.                         {
  218.                             stdin.println("wget -r --output-document=rfzo_oop.zip --http-user=aukm --http-password=mkua "
  219.                                     + "http://portal.rfzo.rs/recepti-pomagala/Sifarnici/novo/novafaktura_oop_0"
  220.                                         + (dan) + "_" + (mesec+1) + "_" + (godina) + ".zip");
  221.                         }
  222.                         else if(mesec<10)
  223.                         {
  224.                             stdin.println("wget -r --output-document=rfzo_oop.zip --http-user=aukm --http-password=mkua "
  225.                                     + "http://portal.rfzo.rs/recepti-pomagala/Sifarnici/novo/novafaktura_oop_"
  226.                                         + (dan) + "_0" + (mesec+1) + "_" + (godina) + ".zip");
  227.                         }
  228.                         else
  229.                         {
  230.                             stdin.println("wget -r --output-document=rfzo_oop.zip --http-user=aukm --http-password=mkua "
  231.                                     + "http://portal.rfzo.rs/recepti-pomagala/Sifarnici/novo/novafaktura_oop"
  232.                                         + (dan) + "_" + (mesec+1) + "_" + (godina) + ".zip");
  233.                         }
  234.                     }
  235.                     stdin.println("7za e rfzo_oop.zip");
  236.  
  237.                     File tmpDir = null;
  238.                     if(dan<10 && mesec<10)
  239.                     {
  240.                         tmpDir = new File("novafaktura_oop_0" + (dan) + "_0" + (mesec+1) + "_" + (godina) + ".xml");
  241.                     }
  242.                     else
  243.                     {
  244.                         if(dan<10)
  245.                         {
  246.                             tmpDir = new File("novafaktura_oop_0" + (dan) + "_" + (mesec+1) + "_" + (godina) + ".zip");
  247.                         }
  248.                         else if(mesec<10)
  249.                         {
  250.                             tmpDir = new File("novafaktura_oop_" + (dan) + "_0" + (mesec+1) + "_" + (godina) + ".zip");
  251.                         }
  252.                         else
  253.                         {
  254.                             tmpDir = new File("novafaktura_oop_" + (dan) + "_" + (mesec+1) + "_" + (godina) + ".zip");
  255.                         }
  256.                     }
  257.  
  258.                     if(tmpDir.exists())
  259.                     {
  260.                         break;
  261.                     }
  262.  
  263.                     kalendar.add(Calendar.DATE, -1);
  264.  
  265.                 }
  266.  
  267.                 kalendar = Calendar.getInstance();*/
  268.  
  269.               //-----------------------------MTP------------------------------------//
  270.                 /*for(int i = 0; i < 30; i++)
  271.                 {
  272.                     int dan = kalendar.get(Calendar.DAY_OF_MONTH);
  273.                     int mesec = kalendar.get(Calendar.MONTH);
  274.                     int godina = kalendar.get(Calendar.YEAR);
  275.  
  276.                     if(dan<10 && mesec<10)
  277.                     {
  278.                         stdin.println("wget -r --output-document=rfzo_mtp.zip --http-user=aukm --http-password=mkua "
  279.                                 + "http://portal.rfzo.rs/recepti-pomagala/Sifarnici/novo/novafaktura_s_mtp_0"
  280.                                     + (dan) + "_0" + (mesec+1) + "_" + (godina) + ".zip");
  281.                     }
  282.                     else
  283.                     {
  284.                         if(dan<10)
  285.                         {
  286.                             stdin.println("wget -r --output-document=rfzo_mtp.zip --http-user=aukm --http-password=mkua "
  287.                                     + "http://portal.rfzo.rs/recepti-pomagala/Sifarnici/novo/novafaktura_s_mtp_0"
  288.                                         + (dan) + "_" + (mesec+1) + "_" + (godina) + ".zip");
  289.                         }
  290.                         else if(mesec<10)
  291.                         {
  292.                             stdin.println("wget -r --output-document=rfzo_mtp.zip --http-user=aukm --http-password=mkua "
  293.                                     + "http://portal.rfzo.rs/recepti-pomagala/Sifarnici/novo/novafaktura_s_mtp_"
  294.                                         + (dan) + "_0" + (mesec+1) + "_" + (godina) + ".zip");
  295.                         }
  296.                         else
  297.                         {
  298.                             stdin.println("wget -r --output-document=rfzo_mtp.zip --http-user=aukm --http-password=mkua "
  299.                                     + "http://portal.rfzo.rs/recepti-pomagala/Sifarnici/novo/novafaktura_s_mtp_"
  300.                                         + (dan) + "_" + (mesec+1) + "_" + (godina) + ".zip");
  301.                         }
  302.                     }
  303.                     stdin.println("7za e rfzo_mtp.zip");
  304.  
  305.                     File tmpDir = null;
  306.                     if(dan<10 && mesec<10)
  307.                     {
  308.                         tmpDir = new File("novafaktura_mtp_0" + (dan) + "_0" + (mesec+1) + "_" + (godina) + ".xml");
  309.                     }
  310.                     else
  311.                     {
  312.                         if(dan<10)
  313.                         {
  314.                             tmpDir = new File("novafaktura_mtp_0" + (dan) + "_" + (mesec+1) + "_" + (godina) + ".zip");
  315.                         }
  316.                         else if(mesec<10)
  317.                         {
  318.                             tmpDir = new File("novafaktura_mtp_" + (dan) + "_0" + (mesec+1) + "_" + (godina) + ".zip");
  319.                         }
  320.                         else
  321.                         {
  322.                             tmpDir = new File("novafaktura_mtp_" + (dan) + "_" + (mesec+1) + "_" + (godina) + ".zip");
  323.                         }
  324.                     }
  325.  
  326.                     if(tmpDir.exists())
  327.                     {
  328.                         break;
  329.                     }
  330.  
  331.                     kalendar.add(Calendar.DATE, -1);
  332.                 }*/
  333.                 stdin.println("del rfzo_lekovi.zip");
  334.                 /*stdin.println("del rfzo_lekari.zip");
  335.                 stdin.println("del rfzo_oop.zip");
  336.                 stdin.println("del rfzo_mtp.zip");*/
  337.                 stdin.close();
  338.                 int returnCode = p.waitFor();
  339.                 System.out.println("Return code = " + returnCode);
  340.                 } catch (IOException e1)
  341.                 {
  342.                     // TODO Auto-generated catch block
  343.                     e1.printStackTrace();
  344.                 } catch (InterruptedException e1)
  345.                 {
  346.                     // TODO Auto-generated catch block
  347.                     e1.printStackTrace();
  348.                 }
  349.  
  350.         });
  351.        
  352.         Scene sc = new Scene(bp, 600,400);
  353.         primaryStage.setScene(sc);
  354.         primaryStage.show();
  355.     }
  356.  
  357. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement