Exemplo n.º 1
0
        public Geocerca FindGeocerca(int id)
        {
            var geo = LogicCache.Retrieve <Geocerca>(typeof(Geocerca), GetGeocercaByIdKey(id));

            return(geo ?? GetGeocercaById(id));
        }
Exemplo n.º 2
0
        protected override void OnExecute(Timer timer)
        {
            if (IdEmpresa <= 0)
            {
                return;
            }

            var keyUpdate     = Component + "_update_" + IdEmpresa;
            var keyLastUpdate = Component + "_lastUpdate_" + IdEmpresa;

            if (LogicCache.KeyExists(typeof(bool), keyUpdate))
            {
                _update = (bool)LogicCache.Retrieve <object>(typeof(bool), keyUpdate);
            }

            STrace.Trace(Component, string.Format("Init Update: {0}", _update ? "TRUE" : "FALSE"));

            if (LogicCache.KeyExists(typeof(DateTime), keyLastUpdate))
            {
                _lastUpdate = (DateTime)LogicCache.Retrieve <object>(typeof(DateTime), keyLastUpdate);
            }

            //var archivoPendiente = DaoFactory.LogicLinkFileDAO.GetNextPendiente(IdEmpresa);
            //if (archivoPendiente != null)
            //{
            //    STrace.Trace(Component, "Archivo a procesar: " + archivoPendiente.FilePath);
            //
            //    var te = new TimeElapsed();
            //    ProcessArchivo(archivoPendiente);
            //    STrace.Trace(Component, "Archivo procesado en: " + te.getTimeElapsed().TotalSeconds + " segundos.");
            //}

            var archivosPendientes = DaoFactory.LogicLinkFileDAO.GetPendientes(IdEmpresa).ToList();

            STrace.Trace(Component, "Archivos pendientes: " + archivosPendientes.Count());

            //var archivo = DaoFactory.LogicLinkFileDAO.FindById();
            //archivosPendientes.Add(archivo);

            foreach (var archivoPendiente in archivosPendientes)
            {
                STrace.Trace(Component, "Archivo a procesar: " + archivoPendiente.FilePath);

                var te = new TimeElapsed();
                ProcessArchivo(archivoPendiente);
                STrace.Trace(Component, "Archivo procesado en: " + te.getTimeElapsed().TotalSeconds + " segundos.");
            }

            var empresa           = DaoFactory.EmpresaDAO.FindById(IdEmpresa);
            var now               = DateTime.UtcNow;
            var lastUpdateMinutes = now.Subtract(_lastUpdate).TotalMinutes;

            STrace.Trace(Component, string.Format("Last Update: {0} - {1} minutos", _lastUpdate.ToString("dd/MM/yyyy HH:mm:ss"), lastUpdateMinutes));
            STrace.Trace(Component, string.Format("Update: {0}", _update ? "TRUE" : "FALSE"));

            if (lastUpdateMinutes > empresa.LogiclinkMinutosUpdate && _update)
            {
                var lineas = new List <int>();
                var dict   = new Dictionary <int, List <int> >();

                var todaslaslineas = DaoFactory.LineaDAO.GetList(new[] { IdEmpresa });
                lineas.Add(-1);
                lineas.AddRange(todaslaslineas.Select(l => l.Id));
                dict.Add(IdEmpresa, lineas);

                DaoFactory.ReferenciaGeograficaDAO.UpdateGeocercas(dict);
                _update     = false;
                _lastUpdate = now;
            }

            STrace.Trace(Component, string.Format("Store Update: {0}", _update ? "TRUE" : "FALSE"));

            LogicCache.Store(typeof(bool), keyUpdate, _update);
            LogicCache.Store(typeof(DateTime), keyLastUpdate, _lastUpdate);
        }
Exemplo n.º 3
0
        private static object Retrieve(Coche vehiculo, int geocerca, string variable)
        {
            const string prefix = "[EV({0}:{1})][{2}]";

            return(LogicCache.Retrieve <object>(string.Format(prefix, vehiculo.Dispositivo.Id, geocerca, variable)));
        }