public async void ReintentarInterrogacion(object state) { CentralReintento reintento = (CentralReintento)state; reintento.SiguienteReintento(); // Chequeamos que siga existiendo if (CentralMonitoreoManager.Instance.ExisteCentral(reintento.SocketID)) { // Si se puede reintentar if (reintento.Reintentos < config.Reintentos) { await MessagesHandler.Instance.InvokeClientMethodOnlyAsync(reintento.SocketID, "intSecuencial", reintento.Reintentos); } // Si llegó al límite de reintentos else { // Destruyo el timer if (centralesSinRespuesta.TryGetValue(reintento.SocketID, out Timer timer)) { timer.Dispose(); centralesSinRespuesta.Remove(reintento.SocketID); } // Logeo la pérdida de conexión... CentralLog log = new CentralLog(CentralMonitoreoManager.Instance.ObtenerCentral(reintento.SocketID), CentralLogTipo.Get(ECentralLogTipo.PerdidaConexion)); log.Save(); // Me desconecto de la central... await MessagesHandler.Instance.OnDisconnected(reintento.SocketID); } } }
private void BuildAppSettingsProvider(string enviropment) { CentralLog.LogInfo(String.Concat(":: Runing in :: ", enviropment)); AppSettingsProvider.IsDevelopment = enviropment == "Development"; AppSettingsProvider.Enviropment = enviropment; AppSettingsProvider.NameAPIOne = StaticConfig.GetSection("Settings").GetSection("API").GetSection("NameAPIOne").Value; }
/** * Desconecta una central */ public bool DesconectarCentral(string socketId) { if (centrales.TryGetValue(socketId, out CentralMonitoreo c)) { CentralLog log = new CentralLog(c, CentralLogTipo.Get(ECentralLogTipo.Desconectado)); log.Save(); centrales.Remove(socketId); return(true); } return(false); }
private static string genralRequest(string EndpointTO, string ARGS, string transactionIDCancell = "") { if (EndPoints.debugMode) { CentralLog.LogInfo($"ENDPOINTS :: CALL {EndpointTO} with [{ARGS}]"); } string url = EndpointTO; string parametros = "/" + ARGS; const string authHeaders = ""; const string postDataSend = ""; if (EndPoints.debugMode) { CentralLog.LogInfo("ENDPOINTS :: JSON"); CentralLog.LogInfo(postDataSend); } string returnStrng = ""; try { string returnStr = RequestAPI.GetT(url, parametros, authHeaders); if (EndPoints.debugMode) { CentralLog.LogInfo("ENDPOINT :: Return from API"); CentralLog.LogInfo(returnStr); } if (returnStr.Length > 0) { var now = JsonParse.parseSWAPJSON(returnStr); returnStrng = returnStr; } } catch (Exception e) { Dictionary <string, string> myResp = new Dictionary <string, string> () { { "status", "500" }, { "message", e.Message }, { "erroMessage", "imposibilitado de acessar API, tente novamente" }, { "erro", e.ToString( ) } }; returnStrng = JsonParse.genJson(myResp, new List <string>()); CentralLog.LogError(e, ":: ENDPOINTS ERROR :: >> CANOT ACCESS TOKEN ::"); } return(returnStrng); }
public static string GetT(string url, string parametros, string authHeaders) { string responseFromServer = ""; try { string urlPram = HttpUtility.UrlDecode(url + parametros); WebRequest request = WebRequest.Create(urlPram); request.Method = MethodFor; request.Timeout = LimitTimeout; using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) using (Stream stream = response.GetResponseStream()) using (StreamReader reader = new StreamReader(stream)) { responseFromServer = reader.ReadToEnd(); } } catch (WebException e) { Dictionary <string, string> ErroResponse = new Dictionary <string, string> () { { "message", e.Message }, { "Status", e.Status.ToString( ) }, { "stack", new StreamReader(e.Response.GetResponseStream()).ReadToEnd() }, { "erro", e.ToString( ) } }; responseFromServer = JsonParse.genJson(ErroResponse, new List <string>() { }); CentralLog.LogError(e, ":: ERROR >> CANOT ACCESS URL ::"); } catch (Exception e) { Dictionary <string, string> ErroResponse = new Dictionary <string, string> () { { "message", e.Message }, { "Status", "5001" }, { "Erro", e.ToString( ) } }; responseFromServer = JsonParse.genJson(ErroResponse, new List <string>() { }); CentralLog.LogError(e, ":: ERROR >> CANOT ACCESS URL ::"); } return(responseFromServer); }
public IActionResult Get(string id) { List <CentralLog> logs = CentralLog.GetAll(id); List <object> res = new List <object>(); foreach (CentralLog log in logs) { res.Add(new { Fecha = log.Fecha, estado = log.TipoLog.TipoLogId.GetValueOrDefault() }); } return(Ok(res)); }
//public static List<MensagemTable> parseJSON ( string json ) //{ // return JsonConvert.DeserializeObject <List <MensagemTable>>(json, // new JsonSerializerSettings() { DateFormatString = "yyyy-MM-ddThh:mm:ssZ" }); //} public static dynamic parseSWAPJSON(string json) { try { return(JObject.Parse(json)); //JsonConvert.DeserializeObject<List<JObject>>(json); //, // new JsonSerializerSettings() { DateFormatString = "yyyy-MM-ddThh:mm:ssZ" }); } catch (Exception e) { CentralLog.LogError(e, "Error in Parse JSON"); return(new List <JObject> { }); } }
/** * Conecta una central y la agrega al diccionario. */ public bool ConectarCentral(string socketId, string centralId, string contraseña) { CentralMonitoreo c = CentralMonitoreo.Get(centralId); if (c == null || !c.Contraseña.Equals(contraseña)) { return(false); } CentralLog log = new CentralLog(c, CentralLogTipo.Get(ECentralLogTipo.Conectado)); log.Save(); centrales[socketId] = c; return(true); }
public IActionResult Get() { List <CentralMonitoreo> centrales = CentralMonitoreo.GetAll(); List <object> res = new List <object>(); foreach (CentralMonitoreo central in centrales) { CentralLog log = CentralLog.GetLast(central.CentralID); int estado = 0; if (log != null) { estado = log.TipoLog.TipoLogId.GetValueOrDefault(); } res.Add(new { Id = central.CentralID, Barrio = central.Barrio.Nombre, estado }); } return(Ok(res)); }
public Startup(IConfiguration configuration) { CentralLog.LogInfo("Begin Burn"); }