protected override void OnLoad(EventArgs e) { base.OnLoad(e); if (!IsPostBack) { ParsearQueryString(); Monitor.AddCallbackScript(string.Format("$get('clock').innerHTML = '{0}<blink>:</blink>{1}';", DateTime.UtcNow.ToDisplayDateTime().ToString("HH"), DateTime.UtcNow.ToDisplayDateTime().ToString("mm"))); RegisterStatusCheck(); RegisterEvents(); Monitor.AddCallbackScript(string.Format("startClock(new Date({0},{1},{2},{3},{4},{5}));", DateTime.UtcNow.ToDisplayDateTime().Year, DateTime.UtcNow.ToDisplayDateTime().Month, DateTime.UtcNow.ToDisplayDateTime().Day, DateTime.UtcNow.ToDisplayDateTime().Hour, DateTime.UtcNow.ToDisplayDateTime().Minute, DateTime.UtcNow.ToDisplayDateTime().Second)); } }
void MonitorTick(object sender, MonitorEventArgs e) { if (Usuario == null) { return; } try { Monitor.TimerInterval = 20; Monitor.CallbackArgument = DateTime.UtcNow.ToString(); var count = 0; if (SelectedEntidades.Count > 0) { foreach (var entidad in SelectedEntidades) { var style = GetMarkerStyle(entidad); AddMarker(entidad, style); count++; if (SelectedEntidades.Count == 1) { Monitor.SetCenter(entidad.ReferenciaGeografica.Latitude, entidad.ReferenciaGeografica.Longitude); } } if (SelectedMessages.Count > 0) { var selectedDispositivos = SelectedEntidades.Select(entidad => entidad.Dispositivo).ToList(); var popups = SharedPositions.GetNewPopupsM2M(selectedDispositivos, DAOFactory) .Where(p => SelectedMessages.Contains(p.CodigoMensaje)); var sonidos = new List <string>(); var lastMsg = LastMessage; var newPopups = 0; foreach (var popup in popups) { if (popup.Id > lastMsg) { Monitor.AddCallbackScript("AddEvent('" + GetMessageM2M(popup) + "');"); if (!string.IsNullOrEmpty(popup.Sound) && !sonidos.Contains(Config.Directory.SoundsDir + popup.Sound)) { sonidos.Add(Config.Directory.SoundsDir + popup.Sound); } LastMessage = Math.Max(popup.Id, LastMessage); newPopups++; } } if (sonidos.Count > 0) { Monitor.AddCallbackScript("enqueueSounds(['" + string.Join("','", sonidos.ToArray()) + "']);"); } if (newPopups > 0) { Monitor.AddCallbackScript("if(!PopupPanelOpen)ShowEvents();"); } } } // Inserto un script personalizado que muestra un mensaje en pantalla Monitor.AddCallbackScript(string.Format("$get('{0}').innerHTML = '{1}';", lblInfo.ClientID, string.Format(CultureManager.GetSystemMessage("ONLINE_UPDATED_POSITIONS"), count, DateTime.UtcNow.ToDisplayDateTime().ToString("HH:mm:ss")))); } catch (Exception ex) { // Inserto un script personalizado que muestra el error en pantalla Monitor.AddCallbackScript(string.Format("$get('{0}').innerHTML = '{1}';", lblInfo.ClientID, ex.Message)); } Monitor.AddCallbackScript("lastUpdate = new Date();"); }