public string exist(string file) { //if (!Program.registrado) { return "falha"; } try { string ret = "falha"; if (dxm.FileExist(file)) { ret = "ok"; } return(ret); } catch (Exception ex) { return(ex.Message); } }
public static void DXMLog() { int contador = 0; while (true) { long hora = DateTime.Now.ToFileTime(); int linhas = vt.quantidade; int comparador = vt.tickLog + 60; contador++; if (contador > comparador && dxm.Connected) { ///* loging = true; try { DXM_Procotolo dxm_api = new DXM_Procotolo(Program.dxm.IPAddress); if (dxm_api.FileExist("Sbfile1.dat")) { dxm_api = new DXM_Procotolo(Program.dxm.IPAddress); string tempStr = ""; string tempStr2 = ""; List <string> temp = new List <string>(); List <string> temp2 = new List <string>(); dxm_api.destravar(); dxm_api = new DXM_Procotolo(Program.dxm.IPAddress); temp2 = dxm_api.getFile("LogFile1.txt"); Thread.Sleep(200); dxm_api = new DXM_Procotolo(Program.dxm.IPAddress); temp = dxm_api.getFile("Sbfile1.dat"); try { if (temp[0] == "") { } else { for (int x = 0; x < temp2.Count; x++) { tempStr2 = tempStr2 + temp2[x]; } for (int x = 0; x < temp.Count; x++) { tempStr = tempStr + temp[x]; } vt.flush(); banco.exec_log(tempStr, vt.quantidade, tempStr2); dxm_api = new DXM_Procotolo(Program.dxm.IPAddress); dxm_api.deleteFile("Sbfile1.dat"); Thread.Sleep(200); dxm_api = new DXM_Procotolo(Program.dxm.IPAddress); dxm_api.deleteFile("LogFile1.txt"); Thread.Sleep(1000); } } catch (Exception ex) { Console.WriteLine(ex); } dxm_api = new DXM_Procotolo(Program.dxm.IPAddress); dxm_api.travar(); } } catch (Exception ex) { Console.WriteLine(ex); } /* * contador = 0; * for (int z = 0; z < linhas; z++) * { * try * { * if (!vt.motores[z].Estado.Contains("DXM")) { * vt.flush(); * banco.exec_log(vt.motores[z]); * } * } * catch { } * } */ banco.set_fabrica(JsonConvert.SerializeObject(vt)); contador = 0; } else { loging = false; } Thread.Sleep(1000); } }
public string forceLoging() { string ret = "falha"; if (Program.dxm.Connected) { try { Program.loging = true; DXM_Procotolo dxm_api = new DXM_Procotolo(Program.dxm.IPAddress); if (dxm_api.FileExist("Sbfile1.dat")) { Program.loging = true; dxm_api = new DXM_Procotolo(Program.dxm.IPAddress); string tempStr = ""; string tempStr2 = ""; List <string> temp = new List <string>(); List <string> temp2 = new List <string>(); dxm_api.destravar(); dxm_api = new DXM_Procotolo(Program.dxm.IPAddress); temp2 = dxm_api.getFile("LogFile1.txt"); Thread.Sleep(200); dxm_api = new DXM_Procotolo(Program.dxm.IPAddress); temp = dxm_api.getFile("Sbfile1.dat"); try { if (temp[0] == "") { } else { for (int x = 0; x < temp2.Count; x++) { tempStr2 = tempStr2 + temp2[x]; } for (int x = 0; x < temp.Count; x++) { tempStr = tempStr + temp[x]; } Program.vt.flush(); Program.banco.exec_log(tempStr, Program.vt.quantidade, tempStr2); dxm_api = new DXM_Procotolo(Program.dxm.IPAddress); dxm_api.deleteFile("Sbfile1.dat"); Thread.Sleep(200); dxm_api = new DXM_Procotolo(Program.dxm.IPAddress); dxm_api.deleteFile("LogFile1.txt"); Thread.Sleep(200); ret = "ok"; } } catch (Exception ex) { Console.WriteLine(ex); } dxm_api = new DXM_Procotolo(Program.dxm.IPAddress); dxm_api.travar(); } } catch (Exception ex) { Console.WriteLine(ex); } Program.loging = false; } return(ret); }
public string baixaLog() { string ret = "falha"; if (Program.dxm.Connected) { try { Program.loging = true; DXM_Procotolo dxm_api = new DXM_Procotolo(Program.dxm.IPAddress); if (dxm_api.FileExist("Sbfile1.dat")) { dxm_api = new DXM_Procotolo(Program.dxm.IPAddress); string tempStr = ""; string tempStr2 = ""; List <string> temp = new List <string>(); List <string> temp2 = new List <string>(); temp2 = dxm_api.getFile("LogFile1.txt"); Thread.Sleep(200); dxm_api = new DXM_Procotolo(Program.dxm.IPAddress); temp = dxm_api.getFile("Sbfile1.dat"); try { if (temp[0] == "") { } else { for (int x = 0; x < temp2.Count; x++) { tempStr2 = tempStr2 + temp2[x]; } for (int x = 0; x < temp.Count; x++) { tempStr = tempStr + temp[x]; } Program.vt.flush(); Program.banco.exec_log(tempStr, Program.vt.quantidade, tempStr2); dxm_api = new DXM_Procotolo(Program.dxm.IPAddress); dxm_api.deleteFile("Sbfile1.dat"); Thread.Sleep(200); dxm_api = new DXM_Procotolo(Program.dxm.IPAddress); dxm_api.deleteFile("LogFile1.txt"); ret = "ok"; } } catch { ret = "falha - não foi possivel baixar o log, execute um diagnóstico e tente novamente"; dxm_api = new DXM_Procotolo(Program.dxm.IPAddress); dxm_api.travar(); } } } catch { ret = "falha - não foi possivel baixar o log, execute um diagnóstico e tente novamente"; } } Program.loging = false; return(ret); }