Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main;
- import java.io.File;
- import java.io.IOException;
- import java.io.PrintWriter;
- import java.text.DateFormat;
- import java.text.ParseException;
- import java.text.SimpleDateFormat;
- import java.time.DayOfWeek;
- import java.util.Calendar;
- import java.util.Date;
- import javafx.application.Application;
- import javafx.scene.Scene;
- import javafx.scene.control.Button;
- import javafx.scene.control.Label;
- import javafx.scene.layout.BorderPane;
- import javafx.scene.layout.GridPane;
- import javafx.stage.Stage;
- import podaci.SyncPipe;
- public class Main extends Application
- {
- public static void main(String[] args)
- {
- launch(args);
- }
- @Override
- public void start(Stage primaryStage) throws Exception
- {
- GridPane bp = new GridPane();
- Label lbl = new Label("Trenutan datum: ");
- DateFormat fa = new SimpleDateFormat("dd-MM-yyyy");
- Date fu = new Date();
- lbl.setText(lbl.getText() + fa.format(fu));
- Button dugme = new Button("Dugmeeee");
- Button provera = new Button("Provera");
- bp.add(dugme, 0, 0);
- bp.add(lbl, 0, 1);
- bp.add(provera, 0, 2);
- dugme.setOnAction(e->
- {
- DateFormat datum1 = new SimpleDateFormat("dd-MM-yyyy");
- Date date = new Date();
- lbl.setText(lbl.getText() + datum1.format(date));
- Calendar kalendar = Calendar.getInstance();
- String[] command =
- {
- "cmd",
- };
- Process p;
- try
- {
- p = Runtime.getRuntime().exec(command);
- new Thread(new SyncPipe(p.getErrorStream(), System.err)).start();
- new Thread(new SyncPipe(p.getInputStream(), System.out)).start();
- PrintWriter stdin = new PrintWriter(p.getOutputStream());
- //-----------------------------LEKOVI------------------------------------//
- for(int i = 0; i < 30; i++)
- {
- int dan = kalendar.get(Calendar.DAY_OF_MONTH);
- int mesec = kalendar.get(Calendar.MONTH);
- int godina = kalendar.get(Calendar.YEAR);
- if(dan<10 && mesec<10)
- {
- stdin.println("wget -r --output-document=rfzo_lekovi.zip --http-user=aukm --http-password=mkua "
- + "http://portal.rfzo.rs/recepti-pomagala/Sifarnici/novo/novafaktura_s_lekovi_0"
- + (dan) + "_0" + (mesec+1) + "_" + (godina) + ".zip");
- }
- else
- {
- if(dan<10)
- {
- stdin.println("wget -r --output-document=rfzo_lekovi.zip --http-user=aukm --http-password=mkua "
- + "http://portal.rfzo.rs/recepti-pomagala/Sifarnici/novo/novafaktura_s_lekovi_0"
- + (dan) + "_" + (mesec+1) + "_" + (godina) + ".zip");
- }
- else if(mesec<10)
- {
- stdin.println("wget -r --output-document=rfzo_lekovi.zip --http-user=aukm --http-password=mkua "
- + "http://portal.rfzo.rs/recepti-pomagala/Sifarnici/novo/novafaktura_s_lekovi_"
- + (dan) + "_0" + (mesec+1) + "_" + (godina) + ".zip");
- }
- else
- {
- stdin.println("wget -r --output-document=rfzo_lekovi.zip --http-user=aukm --http-password=mkua "
- + "http://portal.rfzo.rs/recepti-pomagala/Sifarnici/novo/novafaktura_s_lekovi_"
- + (dan) + "_" + (mesec+1) + "_" + (godina) + ".zip");
- }
- }
- stdin.println("7za e rfzo_lekovi.zip");
- if(dan<10 && mesec<10)
- {
- File tmpDir = new File("novafaktura_s_lekovi_0" + (dan) + "_0" + (mesec+1) + "_" + (godina) + ".xml");
- System.out.println(tmpDir.getAbsolutePath());
- if(tmpDir.exists())
- break;
- }
- else
- {
- if(dan<10)
- {
- File tmpDir = new File("novafaktura_s_lekovi_0" + (dan) + "_" + (mesec+1) + "_" + (godina) + ".xml");
- if(tmpDir.exists())
- break;
- }
- else if(mesec<10)
- {
- File tmpDir = new File("novafaktura_s_lekovi_" + (dan) + "_0" + (mesec+1) + "_" + (godina) + ".xml");
- if(tmpDir.exists())
- break;
- }
- else
- {
- File tmpDir = new File("novafaktura_s_lekovi_" + (dan) + "_" + (mesec+1) + "_" + (godina) + ".xml");
- if(tmpDir.exists())
- break;
- }
- }
- kalendar.add(Calendar.DATE, -1);
- }
- kalendar = Calendar.getInstance();
- //-----------------------------LEKARI------------------------------------//
- /*for(int i = 0; i < 30; i++)
- {
- int dan = kalendar.get(Calendar.DAY_OF_MONTH);
- int mesec = kalendar.get(Calendar.MONTH);
- int godina = kalendar.get(Calendar.YEAR);
- if(dan<10 && mesec<10)
- {
- stdin.println("wget -r --output-document=rfzo_lekari.zip --http-user=aukm --http-password=mkua "
- + "http://portal.rfzo.rs/recepti-pomagala/Sifarnici/novo/novafaktura_s_lekari_0"
- + (dan) + "_0" + (mesec+1) + "_" + (godina) + ".zip");
- }
- else
- {
- if(dan<10)
- {
- stdin.println("wget -r --output-document=rfzo_lekari.zip --http-user=aukm --http-password=mkua "
- + "http://portal.rfzo.rs/recepti-pomagala/Sifarnici/novo/novafaktura_s_lekari_0"
- + (dan) + "_" + (mesec+1) + "_" + (godina) + ".zip");
- }
- else if(mesec<10)
- {
- stdin.println("wget -r --output-document=rfzo_lekari.zip --http-user=aukm --http-password=mkua "
- + "http://portal.rfzo.rs/recepti-pomagala/Sifarnici/novo/novafaktura_s_lekari_"
- + (dan) + "_0" + (mesec+1) + "_" + (godina) + ".zip");
- }
- else
- {
- stdin.println("wget -r --output-document=rfzo_lekari.zip --http-user=aukm --http-password=mkua "
- + "http://portal.rfzo.rs/recepti-pomagala/Sifarnici/novo/novafaktura_s_lekari_"
- + (dan) + "_" + (mesec+1) + "_" + (godina) + ".zip");
- }
- }
- stdin.println("7za e rfzo_lekari.zip");
- File tmpDir = null;
- if(dan<10 && mesec<10)
- {
- tmpDir = new File("novafaktura_s_lekari_0" + (dan) + "_0" + (mesec+1) + "_" + (godina) + ".xml");
- }
- else
- {
- if(dan<10)
- {
- tmpDir = new File("novafaktura_s_lekari_0" + (dan) + "_" + (mesec+1) + "_" + (godina) + ".zip");
- }
- else if(mesec<10)
- {
- tmpDir = new File("novafaktura_s_lekari_" + (dan) + "_0" + (mesec+1) + "_" + (godina) + ".zip");
- }
- else
- {
- tmpDir = new File("novafaktura_s_lekari_" + (dan) + "_" + (mesec+1) + "_" + (godina) + ".zip");
- }
- }
- if(tmpDir.exists())
- {
- break;
- }
- kalendar.add(Calendar.DATE, -1);
- }
- kalendar = Calendar.getInstance();*/
- //-----------------------------OOP------------------------------------//
- /*for(int i = 0; i < 30; i++)
- {
- int dan = kalendar.get(Calendar.DAY_OF_MONTH);
- int mesec = kalendar.get(Calendar.MONTH);
- int godina = kalendar.get(Calendar.YEAR);
- if(dan<10 && mesec<10)
- {
- stdin.println("wget -r --output-document=rfzo_oop.zip --http-user=aukm --http-password=mkua "
- + "http://portal.rfzo.rs/recepti-pomagala/Sifarnici/novo/novafaktura_oop_0"
- + (dan) + "_0" + (mesec+1) + "_" + (godina) + ".zip");
- }
- else
- {
- if(dan<10)
- {
- stdin.println("wget -r --output-document=rfzo_oop.zip --http-user=aukm --http-password=mkua "
- + "http://portal.rfzo.rs/recepti-pomagala/Sifarnici/novo/novafaktura_oop_0"
- + (dan) + "_" + (mesec+1) + "_" + (godina) + ".zip");
- }
- else if(mesec<10)
- {
- stdin.println("wget -r --output-document=rfzo_oop.zip --http-user=aukm --http-password=mkua "
- + "http://portal.rfzo.rs/recepti-pomagala/Sifarnici/novo/novafaktura_oop_"
- + (dan) + "_0" + (mesec+1) + "_" + (godina) + ".zip");
- }
- else
- {
- stdin.println("wget -r --output-document=rfzo_oop.zip --http-user=aukm --http-password=mkua "
- + "http://portal.rfzo.rs/recepti-pomagala/Sifarnici/novo/novafaktura_oop"
- + (dan) + "_" + (mesec+1) + "_" + (godina) + ".zip");
- }
- }
- stdin.println("7za e rfzo_oop.zip");
- File tmpDir = null;
- if(dan<10 && mesec<10)
- {
- tmpDir = new File("novafaktura_oop_0" + (dan) + "_0" + (mesec+1) + "_" + (godina) + ".xml");
- }
- else
- {
- if(dan<10)
- {
- tmpDir = new File("novafaktura_oop_0" + (dan) + "_" + (mesec+1) + "_" + (godina) + ".zip");
- }
- else if(mesec<10)
- {
- tmpDir = new File("novafaktura_oop_" + (dan) + "_0" + (mesec+1) + "_" + (godina) + ".zip");
- }
- else
- {
- tmpDir = new File("novafaktura_oop_" + (dan) + "_" + (mesec+1) + "_" + (godina) + ".zip");
- }
- }
- if(tmpDir.exists())
- {
- break;
- }
- kalendar.add(Calendar.DATE, -1);
- }
- kalendar = Calendar.getInstance();*/
- //-----------------------------MTP------------------------------------//
- /*for(int i = 0; i < 30; i++)
- {
- int dan = kalendar.get(Calendar.DAY_OF_MONTH);
- int mesec = kalendar.get(Calendar.MONTH);
- int godina = kalendar.get(Calendar.YEAR);
- if(dan<10 && mesec<10)
- {
- stdin.println("wget -r --output-document=rfzo_mtp.zip --http-user=aukm --http-password=mkua "
- + "http://portal.rfzo.rs/recepti-pomagala/Sifarnici/novo/novafaktura_s_mtp_0"
- + (dan) + "_0" + (mesec+1) + "_" + (godina) + ".zip");
- }
- else
- {
- if(dan<10)
- {
- stdin.println("wget -r --output-document=rfzo_mtp.zip --http-user=aukm --http-password=mkua "
- + "http://portal.rfzo.rs/recepti-pomagala/Sifarnici/novo/novafaktura_s_mtp_0"
- + (dan) + "_" + (mesec+1) + "_" + (godina) + ".zip");
- }
- else if(mesec<10)
- {
- stdin.println("wget -r --output-document=rfzo_mtp.zip --http-user=aukm --http-password=mkua "
- + "http://portal.rfzo.rs/recepti-pomagala/Sifarnici/novo/novafaktura_s_mtp_"
- + (dan) + "_0" + (mesec+1) + "_" + (godina) + ".zip");
- }
- else
- {
- stdin.println("wget -r --output-document=rfzo_mtp.zip --http-user=aukm --http-password=mkua "
- + "http://portal.rfzo.rs/recepti-pomagala/Sifarnici/novo/novafaktura_s_mtp_"
- + (dan) + "_" + (mesec+1) + "_" + (godina) + ".zip");
- }
- }
- stdin.println("7za e rfzo_mtp.zip");
- File tmpDir = null;
- if(dan<10 && mesec<10)
- {
- tmpDir = new File("novafaktura_mtp_0" + (dan) + "_0" + (mesec+1) + "_" + (godina) + ".xml");
- }
- else
- {
- if(dan<10)
- {
- tmpDir = new File("novafaktura_mtp_0" + (dan) + "_" + (mesec+1) + "_" + (godina) + ".zip");
- }
- else if(mesec<10)
- {
- tmpDir = new File("novafaktura_mtp_" + (dan) + "_0" + (mesec+1) + "_" + (godina) + ".zip");
- }
- else
- {
- tmpDir = new File("novafaktura_mtp_" + (dan) + "_" + (mesec+1) + "_" + (godina) + ".zip");
- }
- }
- if(tmpDir.exists())
- {
- break;
- }
- kalendar.add(Calendar.DATE, -1);
- }*/
- stdin.println("del rfzo_lekovi.zip");
- /*stdin.println("del rfzo_lekari.zip");
- stdin.println("del rfzo_oop.zip");
- stdin.println("del rfzo_mtp.zip");*/
- stdin.close();
- int returnCode = p.waitFor();
- System.out.println("Return code = " + returnCode);
- } catch (IOException e1)
- {
- // TODO Auto-generated catch block
- e1.printStackTrace();
- } catch (InterruptedException e1)
- {
- // TODO Auto-generated catch block
- e1.printStackTrace();
- }
- });
- Scene sc = new Scene(bp, 600,400);
- primaryStage.setScene(sc);
- primaryStage.show();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement