-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from decimo3/restricted-mode
Restricted mode
- Loading branch information
Showing
14 changed files
with
196 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
namespace telbot; | ||
public class WakeUpSAP | ||
{ | ||
private readonly Configuration cfg; | ||
public WakeUpSAP(Configuration cfg) | ||
{ | ||
this.cfg = cfg; | ||
} | ||
public void Start() | ||
{ | ||
Console.WriteLine($"< {DateTime.Now} Manager: Iniciado sistema de despertador do SapAutomation!"); | ||
while(true) | ||
{ | ||
var horario = System.IO.File.GetLastWriteTime("database.db"); | ||
var prazo = DateTime.Now.AddMinutes(-5); | ||
var diferenca = horario - prazo; | ||
Console.WriteLine($"< {DateTime.Now} Manager: Última solicitação registrada às {horario}."); | ||
if(diferenca.TotalMinutes < 0) | ||
{ | ||
Console.WriteLine($"< {DateTime.Now} Manager: Realizando consulta para manter o SAP acordado..."); | ||
var resposta = Temporary.executar(cfg, "desperta", "1380763967"); | ||
if(resposta.Count == 0) resposta.Add("ERRO: O SAP demorou muito tempo na solicitação e foi encerrado!"); | ||
if(resposta[0].StartsWith("ERRO")) | ||
{ | ||
Console.Beep(); | ||
Console.BackgroundColor = ConsoleColor.Red; | ||
Console.WriteLine($"< {DateTime.Now} Manager: A solicitação não pode ser concluída!"); | ||
Console.ResetColor(); | ||
Console.WriteLine($"< {DateTime.Now} Manager: Tentando novamente em daqui a 5 minutos..."); | ||
Database.inserirRelatorio(new logsModel(0,"desperta", "0", false, DateTime.Now)); | ||
} | ||
else | ||
{ | ||
Console.WriteLine($"< {DateTime.Now} Manager: Consulta fantasma realizada com sucesso!"); | ||
Database.inserirRelatorio(new logsModel(0,"desperta", "0", true, DateTime.Now)); | ||
} | ||
} | ||
Console.WriteLine($"< {DateTime.Now} Manager: Última verificação foi realizada agora mesmo."); | ||
System.Threading.Thread.Sleep(cfg.ESPERA); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.