Exemplo n.º 1
0
        public static EstadoVehiculo GetEstadoVehiculo(Coche vehiculo, DAOFactory daoFactory)
        {
            if (vehiculo == null)
            {
                return(null);
            }

            var ts             = new TimeElapsed();
            var estadoVehiculo = EstadoVehiculo.Load(vehiculo, daoFactory);

            if (ts.getTimeElapsed().TotalSeconds > 1)
            {
                STrace.Debug("DispatcherLock", vehiculo.Dispositivo.Id, String.Format("EstadoVehiculo.Load ({0} secs)", ts.getTimeElapsed().TotalSeconds));
            }

            if (estadoVehiculo == null)
            {
                var posicion = daoFactory.LogPosicionDAO.GetLastOnlineVehiclePosition(vehiculo);
                if (posicion == null)
                {
                    return(null);
                }
                var point = new GPSPoint(posicion.FechaMensaje, (float)posicion.Latitud, (float)posicion.Longitud, posicion.Velocidad, GPSPoint.SourceProviders.Unknown, 0);
                return(CalcularEstadoVehiculo(vehiculo, point, daoFactory));
            }

            return(estadoVehiculo);
        }
Exemplo n.º 2
0
        protected override void OnExecute(Timer timer)
        {
            STrace.Trace(GetType().FullName, "Iniciando tarea...");

            var te = new TimeElapsed();

            try
            {
                var empresas = DaoFactory.EmpresaDAO.FindAll().Where(e => e.Baja == false);
                var lineas   = DaoFactory.LineaDAO.FindAll().Where(l => l.Baja == false);

                foreach (var empresa in empresas)
                {
                    var lineaEmpresa = lineas.Where(l => l.Empresa.Id == empresa.Id);

                    GeocercaManager.GetQtreeTest(empresa.Id, -1);

                    foreach (var linea in lineaEmpresa)
                    {
                        GeocercaManager.GetQtreeTest(empresa.Id, linea.Id);
                    }
                }

                var ts = te.getTimeElapsed().TotalSeconds;
                STrace.Trace(GetType().FullName, string.Format("Tarea finalizada en {0} segundos", ts));
            }
            catch (Exception ex)
            {
                AddError(ex);
            }
            finally
            {
                ClearData();
            }
        }
Exemplo n.º 3
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (TimeElapsed != 0D)
            {
                hash ^= TimeElapsed.GetHashCode();
            }
            if (TimeUser != 0D)
            {
                hash ^= TimeUser.GetHashCode();
            }
            if (TimeSystem != 0D)
            {
                hash ^= TimeSystem.GetHashCode();
            }
            if (TotalCpuTime != 0UL)
            {
                hash ^= TotalCpuTime.GetHashCode();
            }
            if (IdleCpuTime != 0UL)
            {
                hash ^= IdleCpuTime.GetHashCode();
            }
            return(hash);
        }
Exemplo n.º 4
0
        public override bool CreateConfigurationMenu(ExtensionParameter extensionParameter, ref Dictionary <String, Object> Parameters)
        {
            ImGui.TextDisabled("Condition Info");
            ImGuiExtension.ToolTip("This condition is used to determine if we can use a specific flask.\nIt will ensure that health/hybrid/mana potions are not used when we are at full health/mana.\nThis will also ensure that we do not use up reserved uses.");

            base.CreateConfigurationMenu(extensionParameter, ref Parameters);

            TimerName = ImGuiExtension.InputText("Timer Name", TimerName, 30, InputTextFlags.Default);
            ImGuiExtension.ToolTip("Name for this timer");
            Parameters[TimerNameString] = TimerName.ToString();

            var tempTimerLength = ImGuiExtension.InputText("Time Elapsed (ms)", TimeElapsed.ToString(), 30, InputTextFlags.Default);

            if (Int32.TryParse(tempTimerLength, out int convertedTimerLength))
            {
                TimeElapsed = convertedTimerLength;
            }
            ImGuiExtension.ToolTip("True if timer has run longer than specified time\n1000 ms = 1 sec");
            Parameters[TimeElapsedString] = TimeElapsed.ToString();

            TrueIfStopped = ImGuiExtension.Checkbox("True if stopped", TrueIfStopped);
            ImGuiExtension.ToolTip("When enabled, returns true if timer is stopped (or never started)");
            Parameters[TrueIfStoppedString] = TrueIfStopped.ToString();

            return(true);
        }
Exemplo n.º 5
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (TimeElapsed != 0D)
            {
                hash ^= TimeElapsed.GetHashCode();
            }
            if (TimeUser != 0D)
            {
                hash ^= TimeUser.GetHashCode();
            }
            if (TimeSystem != 0D)
            {
                hash ^= TimeSystem.GetHashCode();
            }
            if (TotalCpuTime != 0UL)
            {
                hash ^= TotalCpuTime.GetHashCode();
            }
            if (IdleCpuTime != 0UL)
            {
                hash ^= IdleCpuTime.GetHashCode();
            }
            if (CqPollCount != 0UL)
            {
                hash ^= CqPollCount.GetHashCode();
            }
            if (coreStats_ != null)
            {
                hash ^= CoreStats.GetHashCode();
            }
            return(hash);
        }
Exemplo n.º 6
0
        private void GuardarEvento(LogMensaje log)
        {
            var t = new TimeElapsed();

            DaoFactory.LogMensajeDAO.Save(log);
            var totalSeconds = t.getTimeElapsed().TotalSeconds;

            if (totalSeconds > 1)
            {
                STrace.Debug("DispatcherLock", log.Dispositivo.Id, String.Format("GuardarEvento/LogMensajeDAO.Save ({0} secs)", totalSeconds));
            }

            if (log.Viaje == null && log.Entrega == null)
            {
                return;
            }

            t.Restart();
            var evenDistri = new EvenDistri
            {
                LogMensaje = log,
                Fecha      = log.Fecha,
                Entrega    = log.Entrega,
                Viaje      = log.Viaje ?? log.Entrega.Viaje
            };

            DaoFactory.EvenDistriDAO.Save(evenDistri);

            totalSeconds = t.getTimeElapsed().TotalSeconds;
            if (totalSeconds > 1)
            {
                STrace.Debug("DispatcherLock", log.Dispositivo.Id, String.Format("GuardarEvento/EvenDistriDAO.Save ({0} secs)", totalSeconds));
            }
        }
Exemplo n.º 7
0
    public virtual void AddStatus(Status status)
    {
        if (status.imediate == true)
        {
            status.nextInterval = 0f;
        }
        else
        {
            status.nextInterval = Time.time + status.intervalLength;
        }

        if (status.HasDurationType(typeof(TimeElapsed)))
        {
            TimeElapsed tE = status.GetDurationOfType <TimeElapsed>();
            tE.endTime = Time.time + tE.timeDuration;
        }

        status.FinishStatus = FinishStatus;
        for (int i = 0; i < curStatuses.Count; i++)//TODO: This might not be needed
        {
            if (curStatuses[i].OnStatusAdded(this, status) == false)
            {
                return;
            }
        }
        curStatuses.Add(status);

        status.DoStatusInitialEffect(this);
    }
Exemplo n.º 8
0
 private void OnTimeElasped(TimeElapsed @event)
 {
     menu.Update(mutator =>
     {
         mutator.UpdateRemainingTime(@event.RemainingTime.ToTimeString());
     });
 }
Exemplo n.º 9
0
 private void OnTimeElapsed(TimeElapsed @event)
 {
     if (window != null)
     {
         window.UpdateTimeDisplay(@event.RemainingTime.ToTimeString());
     }
 }
Exemplo n.º 10
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (latencies_ != null)
            {
                hash ^= Latencies.GetHashCode();
            }
            if (TimeElapsed != 0D)
            {
                hash ^= TimeElapsed.GetHashCode();
            }
            if (TimeUser != 0D)
            {
                hash ^= TimeUser.GetHashCode();
            }
            if (TimeSystem != 0D)
            {
                hash ^= TimeSystem.GetHashCode();
            }
            hash ^= requestResults_.GetHashCode();
            if (CqPollCount != 0UL)
            {
                hash ^= CqPollCount.GetHashCode();
            }
            return(hash);
        }
Exemplo n.º 11
0
 private void labelTime_TextChanged(object sender, EventArgs e)
 {
     if (TimeLeft == 0)
     {
         TimeElapsed?.Invoke();
     }
 }
Exemplo n.º 12
0
        /// <summary>
        /// Updates the timer.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            if (!timerEnabled)
            {
                return;
            }

            currentInterval -= gameTime.ElapsedGameTime;

            if (currentInterval < TimeSpan.Zero)
            {
                TimeElapsed?.Invoke(this, EventArgs.Empty);

                if (AutoReset)
                {
                    currentInterval = Interval;
                }
                else
                {
                    timerEnabled = false;
                }
            }
        }
Exemplo n.º 13
0
        public IEnumerable <Geocerca> GetGeocercasFor(int empresaId, int lineaId)
        {
            Dictionary <int, Poligono>  poligonos;
            Dictionary <int, Direccion> direcciones;

            var t             = new TimeElapsed();
            var poligonosList = GetPoligonosVigentes(empresaId, lineaId);
            var ts            = t.getTimeElapsed().TotalSeconds;

            if (ts > 1)
            {
                STrace.Trace("DispatcherLock", string.Format("GetPoligonosVigentes({0},{1}): {2} segundos", empresaId, lineaId, ts));
            }

            t.Restart();
            if (poligonosList != null &&
                poligonosList.Any())
            {
                poligonos = poligonosList.ToDictionary(x => x.Id, x => x);
            }
            else
            {
                poligonos = new Dictionary <int, Poligono>();
            }

            ts = t.getTimeElapsed().TotalSeconds;
            if (ts > 1)
            {
                STrace.Trace("DispatcherLock", string.Format("poligonosList.ToDictionary({0},{1}): {2} segundos", empresaId, lineaId, ts));
            }

            t.Restart();
            var direccionesList = GetDireccionesVigentes(empresaId, lineaId);

            ts = t.getTimeElapsed().TotalSeconds;
            if (ts > 1)
            {
                STrace.Trace("DispatcherLock", string.Format("GetDireccionesVigentes({0},{1}): {2} segundos", empresaId, lineaId, ts));
            }

            t.Restart();
            if (direccionesList != null &&
                direccionesList.Any())
            {
                direcciones = direccionesList.ToDictionary(x => x.Id, x => x);
            }
            else
            {
                direcciones = new Dictionary <int, Direccion>();
            }

            ts = t.getTimeElapsed().TotalSeconds;
            if (ts > 1)
            {
                STrace.Trace("DispatcherLock", string.Format("direccionesList.ToDictionary({0},{1}): {2} segundos", empresaId, lineaId, ts));
            }

            return(GetGeocercasFor(empresaId, lineaId, direcciones, poligonos));
        }
Exemplo n.º 14
0
        private void LoadPosiciones()
        {
            var posicionDao = DaoFactory.LogPosicionDAO;

            var maxMonths = Vehiculo.Empresa != null ? Vehiculo.Empresa.MesesConsultaPosiciones : 3;

            var t = new TimeElapsed();

            PosicionSiguiente = posicionDao.GetFirstPositionNewerThanDate(Vehiculo.Id, Fin, maxMonths);
            var ts = t.getTimeElapsed().TotalSeconds;

            if (ts > 1)
            {
                STrace.Error("Logictracker.Scheduler.Tasks.Mantenimiento.DatamartGeneration", string.Format("GetFirstPositionNewerThanDate en {0} segundos", ts));
            }

            t.Restart();
            PosicionAnterior = Vehiculo.LastOdometerUpdate.HasValue ? posicionDao.GetFirstPositionOlderThanDate(Vehiculo.Id, Inicio, maxMonths) : null;
            ts = t.getTimeElapsed().TotalSeconds;
            if (ts > 1)
            {
                STrace.Error("Logictracker.Scheduler.Tasks.Mantenimiento.DatamartGeneration", string.Format("GetFirstPositionOlderThanDate en {0} segundos", ts));
            }

            t.Restart();
            var originalPositions = posicionDao.GetPositionsBetweenDates(Vehiculo.Id, Inicio, Fin, maxMonths);

            ts = t.getTimeElapsed().TotalSeconds;
            if (ts > 1)
            {
                STrace.Error("Logictracker.Scheduler.Tasks.Mantenimiento.DatamartGeneration", string.Format("GetPositionsBetweenDates: {0} posiciones en {1} segundos", originalPositions.Count, ts));
            }

            if (Vehiculo.Dispositivo != null && !DaoFactory.DetalleDispositivoDAO.GetDiscardsInvalidPositionsValue(Vehiculo.Dispositivo.Id))
            {
                Posiciones = CorrectGeorefferenciation(originalPositions);
            }
            else
            {
                var cleanPositions    = new List <LogPosicion>();
                var lastValidPosition = PosicionAnterior;
                foreach (var position in originalPositions)
                {
                    if (!EsPosicionValida(lastValidPosition, position))
                    {
                        posicionDao.Delete(position);
                        var discartedPosition = new LogPosicionDescartada(position, DiscardReason.DatamartCleanUp);
                        DaoFactory.LogPosicionDescartadaDAO.Save(discartedPosition);
                    }
                    else
                    {
                        cleanPositions.Add(position);
                        lastValidPosition = position;
                    }
                }
                Posiciones = CorrectGeorefferenciation(cleanPositions);
            }
        }
Exemplo n.º 15
0
    // Use this for initialization
    void Start()
    {
        NumberOfDaysForAlienToShowUp = 7;

        // should find objects with tags instead of object's names
        t = GameObject.Find("Game Manager").transform.GetComponent <TimeElapsed>();

        this.gameObject.transform.GetChild(0).gameObject.SetActive(false);
    }
Exemplo n.º 16
0
 public void Start(int secondsToWait, TimeElapsed args)
 {
     _arg                   = args;
     _sendtime              = secondsToWait;
     _updateTimer.Enabled   = false;
     _updateTimer.AutoReset = true;
     _updateTimer.Interval  = _checkTime; // 500 milliseconds wait to start async ops
     _updateTimer.Elapsed  += timer_elapsed;
 }
Exemplo n.º 17
0
        private void MessageReceived(IAsyncResult ar)
        {
            var t = new TimeElapsed();

            try
            {
                var msg     = MessageQueue.EndReceive(ar);
                var payload = (IMessage)msg.Body;
                if (payload == null)
                {
                    STrace.Debug(GetType().FullName, String.Format("MessageConsumer: IMessage no castea. Body.ToString='{0}'", msg.Body));
                    if (DeadMessageQueue != null)
                    {
                        DeadMessageQueue.Send(msg);
                    }
                    return;
                }
                if (DispatcherLayer.Dispatch(payload).Action == ReplyAction.None)
                {
                    return;
                }
                if (DeadMessageQueue != null)
                {
                    DeadMessageQueue.Send(msg);
                }
            }
            catch (System.Messaging.MessageQueueException e)
            {
                if (e.MessageQueueErrorCode != System.Messaging.MessageQueueErrorCode.IOTimeout)
                {
                    STrace.Exception(GetType().FullName, e);
                }
            }
            catch (Exception e)
            {
                STrace.Exception(GetType().FullName, e);
            }
            finally
            {
                if (!CountMore(MessageQueue, MinMessagesToSleep))
                {
                    //STrace.Debug(GetType().FullName, "Sleep");
                    Thread.Sleep(SleepTime);
                }
                if (MessageQueue != null)
                {
                    MessageQueue.BeginReceive(AsyncTimeout, null, MessageReceived);
                }

                var ts = t.getTimeElapsed().TotalSeconds;
                if (ts > 1)
                {
                    STrace.Debug("DispatcherLock", "MessageReceived: " + ts);
                }
            }
        }
Exemplo n.º 18
0
        public void FireTimeElapsedIfActive()
        {
            if (_isDisposed || _dueTime == Timeout.Infinite)
            {
                return;
            }

            _dueTime = Timeout.Infinite;

            TimeElapsed?.Invoke();
        }
Exemplo n.º 19
0
        private static String GetFilePath(INode Device, String ext)
        {
            var t    = new TimeElapsed();
            var path = Process.GetApplicationFolder("FOTA");

            if (t.getTimeElapsed().TotalSeconds > 1)
            {
                STrace.Debug("ParserLock", Device.Id, String.Format("Inside GetFilePath (GetApplicationFolder)({0} secs)", t.getTimeElapsed().TotalSeconds.ToString()));
            }
            return(GetFilePath(Device.Id, path, ext));
        }
        /// <summary>
        /// Initializes this VideoView instance.
        /// </summary>
        private void Init()
        {
            Status = MediaPlayerStatus.Idle;
            SetMediaController(new MediaController(Context));
            _timer          = new Timer();
            _timer.Elapsed += (sender, args) => TimeElapsed.RaiseEvent(this);

            // Register Events
            Prepared   += OnPrepared;
            Completion += OnCompletion;
            Error      += OnError;
        }
Exemplo n.º 21
0
        public void ParseAsignaciones(out int rutas, out string observaciones)
        {
            var te   = new TimeElapsed();
            var rows = ParseExcelFile(Llfile.FilePath, true);

            STrace.Trace(Component, string.Format("Archivo parseado en {0} segundos", te.getTimeElapsed().TotalSeconds));
            te.Restart();
            PreBufferAsignaciones(rows);
            STrace.Trace(Component, string.Format("PreBufferAsignaciones en {0} segundos", te.getTimeElapsed().TotalSeconds));

            var listViajes = new List <ViajeDistribucion>();

            rutas         = 0;
            observaciones = string.Empty;

            STrace.Trace(Component, "Cantidad de filas: " + rows.Count);
            var filas = 0;

            foreach (var row in rows)
            {
                filas++;
                STrace.Trace(Component, string.Format("Procesando fila: {0}/{1}", filas, rows.Count));

                var planilla = row[Properties.AsignacionCCU.Planilla].ToString().Trim();
                var viaje    = _viajesBuffer.SingleOrDefault(l => l.Codigo == planilla);
                if (viaje == null)
                {
                    observaciones = observaciones + "PLANILLA: " + planilla + " no encontrada. ";
                    continue;
                }

                var patente  = row[Properties.AsignacionCCU.Patente].ToString().Trim();
                var vehiculo = _cochesBuffer.SingleOrDefault(v => v.Patente == patente);
                if (vehiculo == null)
                {
                    observaciones = observaciones + "PATENTE: " + patente + " no encontrada. ";
                    continue;
                }

                viaje.Vehiculo = vehiculo;

                listViajes.Add(viaje);
                rutas++;
            }

            STrace.Trace(Component, "Guardando Viajes: " + listViajes.Count);
            te.Restart();
            foreach (var viajeDistribucion in listViajes)
            {
                DaoFactory.ViajeDistribucionDAO.SaveOrUpdate(viajeDistribucion);
            }
            STrace.Trace(Component, string.Format("Viajes guardados en {0} segundos", te.getTimeElapsed().TotalSeconds));
        }
Exemplo n.º 22
0
        private void GuardarEvento(LogMensajeAdmin log)
        {
            var t = new TimeElapsed();

            DaoFactory.LogMensajeAdminDAO.Save(log);
            var totalSeconds = t.getTimeElapsed().TotalSeconds;

            if (totalSeconds > 1)
            {
                STrace.Debug("DispatcherLock", log.Dispositivo.Id, String.Format("GuardarEvento/LogMensajeAdminDAO.Save ({0} secs)", totalSeconds));
            }
        }
Exemplo n.º 23
0
        public static void GetQtreeTest(int empresa, int linea)
        {
            var t = new TimeElapsed();

            GetQtree(empresa, linea);
            var ts = t.getTimeElapsed().TotalSeconds;

            if (ts > 1)
            {
                STrace.Trace("DispatcherLock", string.Format("GetQtree({0},{1}): {2} segundos", empresa, linea, ts));
            }
        }
Exemplo n.º 24
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = Map?.GetHashCode() ?? 0;
         hashCode = (hashCode * 397) ^ (GameMode?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ FragLimit;
         hashCode = (hashCode * 397) ^ TimeLimit;
         hashCode = (hashCode * 397) ^ TimeElapsed.GetHashCode();
         hashCode = (hashCode * 397) ^ (Scoreboard?.GetHashCode() ?? 0);
         return(hashCode);
     }
 }
Exemplo n.º 25
0
 private void TimerTick(object sender, EventArgs e)
 {
     if (TimeElapsed > 1)
     {
         TimeElapsed--;
         this.RemainingTime = TimeElapsed.ToString();
     }
     else
     {
         timer.Stop();
         this.events.PublishOnCurrentThread(new ViewEnglishCommand());
     }
 }
Exemplo n.º 26
0
 public static void Dequeue(IFoteable Device, ulong?msgid)
 {
     if (!Device.LastSent.IsOnTheFly())
     {
         var t = new TimeElapsed();
         UpdateFotaCommand(Device, msgid, BaseDeviceCommand.Attributes.Status_Sent);
         if (t.getTimeElapsed().TotalSeconds > 1)
         {
             STrace.Debug("ParserLock", Device.Id, String.Format("Dequeue ({0} secs)", t.getTimeElapsed().TotalSeconds.ToString()));
         }
     }
     Device.LastSent = null;
 }
Exemplo n.º 27
0
        /// <summary>
        /// Gets datamart regeneration periods.
        /// </summary>
        /// <param name="vehicle"></param>
        /// <param name="from"></param>
        /// <param name="to"></param>
        /// <param name="refference"></param>
        /// <returns></returns>
        public List <RegenerateDatamart> GetDaysToRegenerate(Coche vehicle, DateTime from, DateTime to, DateTime refference)
        {
            var posicionesDao = new LogPosicionDAO();

            int maxMonths;

            try
            {
                maxMonths = vehicle != null && vehicle.Empresa != null ? vehicle.Empresa.MesesConsultaPosiciones : 3;
            }
            catch (Exception)
            {
                maxMonths = 3;
            }

            var te    = new TimeElapsed();
            var start = posicionesDao.GetRegenerationStartDate(vehicle.Id, from, to, refference, maxMonths);
            var ts    = te.getTimeElapsed().TotalSeconds;

            if (ts > 1)
            {
                STrace.Error("Logictracker.Scheduler.Tasks.Mantenimiento.DatamartGeneration", string.Format("GetRegenerationStartDate en {0} segundos", ts));
            }

            if (!start.HasValue)
            {
                return(new List <RegenerateDatamart>());
            }

            var startDate = start.Value;

            te.Restart();
            var endDate = posicionesDao.GetRegenerationEndDate(vehicle.Id, from, to, maxMonths);

            ts = te.getTimeElapsed().TotalSeconds;
            if (ts > 1)
            {
                STrace.Error("Logictracker.Scheduler.Tasks.Mantenimiento.DatamartGeneration", string.Format("GetRegenerationEndDate en {0} segundos", ts));
            }

            var result = new List <RegenerateDatamart>();

            while (startDate < endDate)
            {
                var period = new RegenerateDatamart(startDate);
                result.Add(period);
                startDate = startDate.AddDays(1);
            }

            return(result);
        }
Exemplo n.º 28
0
        public void Parse(out int viajes, out string observaciones)
        {
            var te   = new TimeElapsed();
            var rows = ParseExcelFile(Llfile.FilePath, true);

            STrace.Trace(Component, string.Format("Archivo parseado en {0} segundos", te.getTimeElapsed().TotalSeconds));
            te.Restart();
            PreBufferRows(rows);
            STrace.Trace(Component, string.Format("PreBufferRows en {0} segundos", te.getTimeElapsed().TotalSeconds));

            var listViajes = new List <ViajeDistribucion>(rows.Count);

            viajes        = 0;
            observaciones = string.Empty;

            STrace.Trace(Component, "Cantidad de filas: " + rows.Count);
            var filas = 0;

            foreach (var row in rows)
            {
                filas++;
                STrace.Trace(Component, string.Format("Procesando fila: {0}/{1}", filas, rows.Count));

                var codigo = row[Properties.AsignacionCodigoViaje.Codigo].ToString().Trim();
                var viaje  = row[Properties.AsignacionCodigoViaje.Viaje].ToString().Trim();
                var oViaje = _viajesBuffer.SingleOrDefault(v => v.Codigo == viaje);

                if (oViaje == null)
                {
                    observaciones = "Valor inválido para el campo VIAJE";
                    continue;
                }

                oViaje.Codigo = codigo;
                listViajes.Add(oViaje);
                viajes++;
            }

            STrace.Trace(Component, "Guardando viajes: " + listViajes.Count);
            te.Restart();
            var i = 1;

            foreach (var viaje in listViajes)
            {
                STrace.Trace(Component, string.Format("Guardando: {0}/{1}", i++, listViajes.Count()));
                DaoFactory.ViajeDistribucionDAO.SaveOrUpdate(viaje);
            }
            STrace.Trace(Component, string.Format("Viajes guardados en {0} segundos", te.getTimeElapsed().TotalSeconds));
        }
Exemplo n.º 29
0
        public IEnumerable <Geocerca> GetGeocercasFor(int empresaId, int lineaId, Dictionary <int, Direccion> direcciones, Dictionary <int, Poligono> poligonos)
        {
            var t    = new TimeElapsed();
            var sqlQ = Session.CreateSQLQuery("exec [dbo].[sp_getReferenciasGeoVigentes] @company = :company, @branch = :branch;");

            sqlQ.SetInt32("company", empresaId);
            sqlQ.SetInt32("branch", lineaId);
            sqlQ.SetResultTransformer(Transformers.AliasToBean(typeof(Geocerca)));
            var results = sqlQ.List <Geocerca>();

            STrace.Debug("DispatcherLock", string.Format("sp_getReferenciasGeoVigentes {0} en {1} segundos", results.Count(), t.getTimeElapsed().TotalSeconds));

            t = new TimeElapsed();
            foreach (var geo in results)
            {
                Direccion direccion = null;
                if (geo.DireccionId != null)
                {
                    if (direcciones.ContainsKey(geo.DireccionId.Value))
                    {
                        direccion = direcciones[geo.DireccionId.Value];
                    }
                    else
                    {
                        STrace.Error("DispatcherLock", string.Format("ERROR DIRECCION NO ENCONTRADA EN CACHE !!! {0} ({1},{2}) ", geo.DireccionId.Value, empresaId, lineaId));
                    }
                }

                Poligono poligono = null;
                if (geo.PoligonoId != null)
                {
                    if (poligonos.ContainsKey(geo.PoligonoId.Value))
                    {
                        poligono = poligonos[geo.PoligonoId.Value];
                    }
                    else
                    {
                        STrace.Error("DispatcherLock", string.Format("ERROR POLIGONO NO ENCONTRADO EN CACHE !!! {0} ({1},{2}) ", geo.PoligonoId.Value, empresaId, lineaId));
                    }
                }

                if (direccion != null || poligono != null)
                {
                    geo.Calculate(direccion, poligono);
                }
            }
            STrace.Debug("DispatcherLock", string.Format("geo.Calculate {0} en {1} segundos", results.Count(), t.getTimeElapsed().TotalSeconds));
            return(results);
        }
Exemplo n.º 30
0
        /// <summary>
        /// Instanciates a new position vo based on the givenn position.
        /// </summary>
        /// <param name="lastPosition"></param>
        public LogPosicionVo(LogPosicionBase lastPosition)
        {
            var te = new TimeElapsed();

            Id             = lastPosition.Id;
            FechaRecepcion = lastPosition.FechaRecepcion;
            FechaMensaje   = lastPosition.FechaMensaje;
            Longitud       = lastPosition.Longitud;
            Latitud        = lastPosition.Latitud;
            Altitud        = lastPosition.Altitud;
            IdDispositivo  = lastPosition.Dispositivo.Id;
            try
            {
                Dispositivo     = lastPosition.Dispositivo.Codigo;
                TipoDispositivo = String.Format("{0} - {1}", lastPosition.Dispositivo.TipoDispositivo.Fabricante, lastPosition.Dispositivo.TipoDispositivo.Modelo);
                //Firmware = lastPosition.Dispositivo.FullFirmwareVersion;
                //Qtree = lastPosition.Dispositivo.QtreeRevision;
                EstadoDispositivo = lastPosition.Dispositivo.Estado;
            }
            catch {}

            Velocidad = lastPosition.Velocidad;
            Curso     = lastPosition.Curso;
            MotorOn   = lastPosition.MotorOn;
            HDop      = lastPosition.HDop;

            var totalSecs = te.getTimeElapsed().TotalSeconds;

            if (totalSecs > 1)
            {
                STrace.Error("DispatcherLock", lastPosition.Dispositivo.Id, "LogPosicionVo #1: " + totalSecs);
            }

            te.Restart();
            ApplyVehicleData(lastPosition.Coche);
            totalSecs = te.getTimeElapsed().TotalSeconds;
            if (totalSecs > 1)
            {
                STrace.Error("DispatcherLock", lastPosition.Dispositivo.Id, "ApplyVehicleData: " + totalSecs);
            }

            te.Restart();
            HasValidParents(lastPosition);
            totalSecs = te.getTimeElapsed().TotalSeconds;
            if (totalSecs > 1)
            {
                STrace.Error("DispatcherLock", lastPosition.Dispositivo.Id, "HasValidParents: " + totalSecs);
            }
        }
 public void SetTotalTime()
 {
     TotalTime = timerScript.GetTimeElapsedFromStart();
 }