Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.keymax.vendingtouch.utilitarios;
- import java.io.IOException;
- import java.util.ArrayList;
- import java.util.List;
- import com.keymax.vendingtouch.comunicacao.Campos;
- import com.keymax.vendingtouch.comunicacao.ComunicacaoServidor;
- import com.keymax.vendingtouch.interfaces.FramePrincipal;
- import com.keymax.vendingtouch.parameters.PropertiesLoader;
- public class StarterHelper {
- boolean statusWeb;
- public StarterHelper() {
- new Thread(new Runnable() {
- @Override
- public void run() {
- enviaStatus();
- }
- }).start();
- }
- public boolean enviaStatus(){
- String machine = "";
- System.out.println("START THREAD ENVIA STATUS...");
- while(true){
- try {
- machine = PropertiesLoader.getProperties(PropertiesLoader.ID_MACHINE);
- } catch (Exception e2) {
- // TODO Auto-generated catch block
- System.err.println("ID MACHINE NAO ENCONTRADA");
- }
- if(machine != null){
- if(TesteConexao.teste() == true){
- List<Campos> parametros = new ArrayList<Campos>();
- Campos c = null;
- @SuppressWarnings("unused")
- String resposta;
- c = new Campos();
- c.setParametro("id_machine");
- c.setValor(String.valueOf(machine));
- parametros.add(c);
- c = new Campos();
- c.setParametro("nome_cliente");
- c.setValor("UpVending");
- parametros.add(c);
- System.out.println(parametros);
- ComunicacaoServidor cs = new ComunicacaoServidor();
- try {
- System.out.println("ENVIANDO...");
- System.out.println("AQUI");
- System.out.println(cs.envia("http://www.keymax.com.br/painel/api/ping.php",parametros, 0));
- } catch (IOException e) {
- e.printStackTrace();
- System.out.println("Erro");
- }
- try {
- Thread.sleep(60000);
- } catch (InterruptedException e1) {
- // TODO Auto-generated catch block
- e1.printStackTrace();
- }
- if(FramePrincipal.getInstance().ultimaTela.equals("tela_sem_conexao")){
- FramePrincipal.getInstance().mudaPainel(FramePrincipal.TELA_INICIAL);
- }
- postVerificaAlteracao();
- }else {
- if(!FramePrincipal.getInstance().ultimaTela.equals("tela_sem_conexao")){
- // System.err.println("MACHINE SEM CONEXAO COM INTERNET");
- if(!FramePrincipal.getInstance().ultimaTela.equals("tela_nota_fiscal")){
- if(!FramePrincipal.getInstance().ultimaTela.equals("tela_siga")){
- FramePrincipal.getInstance().mudaPainel(FramePrincipal.TELA_SEM_CONEXAO);
- }
- }
- }
- }
- }else {
- // System.err.println("ID DA MACHINE NAO CADASTRADA NO TEF");
- }
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- }
- //-------------------------------------------------------------
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement