public TokenService(TokenConfiguration tokenConfiguration,
                     SigningConfiguration signingConfiguration)
 {
     _tokenConfiguration   = tokenConfiguration;
     _signingConfiguration = signingConfiguration;
     InitialDate           = DateTime.Now;
     ExpirationDate        = InitialDate.AddDays(_tokenConfiguration.DaysTokenExpiration);
 }
Beispiel #2
0
        protected override int GetHashCodeCore()
        {
            int hashCode = InitialDate.GetHashCode();

            hashCode = (hashCode * 397) ^ EndDate.GetHashCode();

            return(hashCode);
        }
Beispiel #3
0
        private void UpdateInitialDateData(DateTime initialDate)
        {
            // Make a request from [initialDate, InitialDate[:
            MakeRequest(BasePath, Action, initialDate, InitialDate.AddDays(-1));

            // Updating InitialDate:
            InitialDate = initialDate;
        }
        private void SetInitialFilterValues()
        {
            GetQueryStringParameters();

            dtDesde.SelectedDate   = InitialDate.ToDisplayDateTime();
            dtHasta.SelectedDate   = FinalDate.ToDisplayDateTime();
            tpStopped.SelectedTime = Stopped;
            npDistance.Number      = Distance;
            npStoppedEvent.Number  = StoppedEvent;
        }
        protected override void OnLoad(EventArgs e)
        {
            Monitor.ContextMenuPostback += Monitor_ContextMenuPostback;
            chkQtree.Visible             = WebSecurity.IsSecuredAllowed(Securables.ViewQtree);

            base.OnLoad(e);

            if (!IsPostBack)
            {
                this.RegisterCss(ResolveUrl("~/App_Styles/openlayers.css"));
                RegisterExtJsStyleSheet();

                dtDesde.SelectedDate = InitialDate.Get().ToDisplayDateTime();
                dtHasta.SelectedDate = FinalDate.Get().ToDisplayDateTime();
                WestPanel.Enabled    = !LockFilters.Get();
                dtDesde.Enabled      = !LockFilters.Get();
                dtHasta.Enabled      = !LockFilters.Get();
                if (Distrito.Get() > 0)
                {
                    ddlDistrito.SetSelectedValue(Distrito.Get());
                }
                if (Location.Get() > 0)
                {
                    ddlPlanta.SetSelectedValue(Location.Get());
                }
                if (Chofer.Get() > 0)
                {
                    ddlEmpleado.SetSelectedValue(Chofer.Get());
                }
                if (TypeMobile.Get() > 0)
                {
                    ddlTipoVehiculo.SetSelectedValue(TypeMobile.Get());
                }
                if (Mobile.Get() > 0)
                {
                    ddlMovil.SetSelectedValue(Mobile.Get());
                }

                foreach (var id in PoisTypesIds.Get())
                {
                    var it = lbPuntosDeInteres.Items.FindByValue(id.ToString());
                    if (it != null)
                    {
                        it.Selected = true;
                    }
                }
                PoisTypesIds.Set(lbPuntosDeInteres.SelectedValues);

                InitializeMap();
                if (Mobile.Get() > 0)
                {
                    LoadPositions(true);
                }
            }
        }
Beispiel #6
0
 public string DatesToString()
 {
     if (FinalDate.HasValue)
     {
         return($"{InitialDate.ToShortDateString()}-{FinalDate.Value.ToShortDateString()}");
     }
     else
     {
         return(InitialDate.ToShortDateString());
     }
 }
Beispiel #7
0
        /// <summary>
        /// Searchs result positions to be displayed.
        /// </summary>

        /*private void SearchPositions()
         * {
         *  var route = DAOFactory.RoutePositionDAO.GetPositions(Mobile, InitialDate.ToDataBaseDateTime(), FinalDate.ToDataBaseDateTime());
         *
         *  if (route.Count == 0)
         *  {
         *      ShowInfo("No se encontraron posiciones para los parametros de busqueda ingresados!");
         *
         *      return;
         *  }
         *
         *  var pos = "[";
         *
         *  for (var i = 0; i < route.Count; i++)
         *  {
         *      var dist = i == route.Count - 1 ? 0 : Distancias.Loxodromica(route[i].Latitude, route[i].Longitude, route[i + 1].Latitude, route[i + 1].Longitude);
         *
         *      var duration = i == route.Count - 1 ? 0 : route[i + 1].Date.Subtract(route[i].Date).TotalSeconds;
         *
         *      if (i > 0) pos = string.Concat(pos, ',');
         *
         *      pos = string.Concat(pos, string.Format("{{lon: {0}, lat: {1}, speed: {2}, distance: {3}, duration: {4}, time: new Date{5}}}",
         *          route[i].Longitude.ToString(CultureInfo.InvariantCulture), route[i].Latitude.ToString(CultureInfo.InvariantCulture), route[i].Speed,
         *          dist.ToString(CultureInfo.InvariantCulture), duration.ToString(CultureInfo.InvariantCulture), route[i].Date.ToString("(yyyy, MM, dd, HH, mm, ss)")));
         *  }
         *
         *  pos = string.Concat(pos, "]");
         *
         *  System.Web.UI.ScriptManager.RegisterStartupScript(this, typeof(string), "route", string.Format("simulador.createRoute({0});", pos), true);
         * }
         */
        private void SearchPositions()
        {
            var colorGenerator = new ColorGenerator(new List <Color> {
                Color.Red, Color.Blue, Color.Green, Color.Orange, Color.Violet, Color.Cyan, Color.Purple
            });
            var empresa   = DAOFactory.EmpresaDAO.FindById(ddlDistrito.Selected);
            var maxMonths = empresa != null && empresa.Id > 0 ? empresa.MesesConsultaPosiciones : 3;

            var route = DAOFactory.RoutePositionsDAO.GetPositionsByRoute(Mobile, InitialDate.ToDataBaseDateTime(), FinalDate.ToDataBaseDateTime(), TimeSpan.Zero, maxMonths);

            if (route.Count == 0)
            {
                ShowInfo("No se encontraron posiciones para los parametros de busqueda ingresados!");

                return;
            }

            var pos = "[";

            for (var j = 0; j < route.Count; j++)
            {
                var tramo = route[j];
                var color = HexColorUtil.ColorToHex(colorGenerator.GetNextColor(j)).Substring(1);
                color = color.Substring(4, 2) + color.Substring(2, 2) + color.Substring(0, 2);
                for (var i = 0; i < tramo.Count; i++)
                {
                    var posicion = tramo[i];
                    var next     = i == tramo.Count - 1
                                   ? j == route.Count - 1 ? null : route[j + 1][0]
                                   : tramo[i + 1];
                    var dist = next == null ? 0 : Distancias.Loxodromica(posicion.Latitude, posicion.Longitude, next.Latitude, next.Longitude);

                    var duration = next == null ? 0 : next.Date.Subtract(posicion.Date).TotalSeconds;

                    if (j > 0 || i > 0)
                    {
                        pos = string.Concat(pos, ',');
                    }

                    pos = string.Concat(pos, string.Format("{{lon: {0}, lat: {1}, speed: {2}, distance: {3}, duration: {4}, time: new Date{5}, 'color': '{6}' }}",
                                                           posicion.Longitude.ToString(CultureInfo.InvariantCulture), posicion.Latitude.ToString(CultureInfo.InvariantCulture), posicion.Speed,
                                                           dist.ToString(CultureInfo.InvariantCulture), duration.ToString(CultureInfo.InvariantCulture), posicion.Date.ToDisplayDateTime().ToString("(yyyy, MM, dd, HH, mm, ss)"), color));
                }
            }
            pos = string.Concat(pos, "]");

            var startflag = CreateAbsolutePath("~/images/salida.png");
            var endflag   = CreateAbsolutePath("~/images/llegada.png");

            System.Web.UI.ScriptManager.RegisterStartupScript(this, typeof(string), "route", string.Format("simulador.createRoute({0},'{1}','{2}');", pos, startflag, endflag), true);
        }
        private void LoadPositions(bool center)
        {
            var par = new Parameters
            {
                Empresa  = Distrito.Get(),
                Linea    = Location.Get(),
                Chofer   = Chofer.Get(),
                Vehiculo = Mobile.Get(),
                Desde    = InitialDate.Get(),
                Hasta    = FinalDate.Get(),
                TiposPoi = PoisTypesIds.Get().ToArray()
            };

            Monitor.ExecuteScript(string.Format("CallForData('{0}', {1});", par.Serialize(), center ? "true" : "false"));
        }
Beispiel #9
0
    public override int GetHashCode()
    {
        int hash = 1;

        if (initialDate_ != null)
        {
            hash ^= InitialDate.GetHashCode();
        }
        if (finalDate_ != null)
        {
            hash ^= FinalDate.GetHashCode();
        }
        if (_unknownFields != null)
        {
            hash ^= _unknownFields.GetHashCode();
        }
        return(hash);
    }
Beispiel #10
0
        protected void btnSearch_Click(object sender, EventArgs e)
        {
            Distrito.Set(ddlDistrito.Selected);
            Location.Set(ddlPlanta.Selected);
            Chofer.Set(ddlEmpleado.Selected);
            Mobile.Set(ddlMovil.Selected);
            InitialDate.Set(SecurityExtensions.ToDataBaseDateTime(dtDesde.SelectedDate.Value));
            FinalDate.Set(SecurityExtensions.ToDataBaseDateTime(dtHasta.SelectedDate.Value));
            PoisTypesIds.Set(lbPuntosDeInteres.SelectedValues);

            var deltaTime = FinalDate.Get().Subtract(InitialDate.Get());

            if (deltaTime > dtvalidator.MaxRange)
            {
                ShowError("El rango de tiempo debe ser menor o igual a " + dtvalidator.MaxRange.ToString());
                return;
            }
            LoadPositions(true);
        }
        protected void BtnSearchClick(object sender, EventArgs e)
        {
            if (!dtFecha.SelectedDate.HasValue)
            {
                return;
            }

            InitialDate      = SecurityExtensions.ToDataBaseDateTime(dtFecha.SelectedDate.Value);
            FinalDate        = InitialDate.AddDays(1);
            Empresa          = cbEmpresa.Selected;
            Linea            = cbLinea.Selected;
            Transportista    = cbTransportista.Selected;
            Departamento     = cbDepartamento.Selected;
            CentroDeCosto    = cbCentroDeCostos.Selected;
            SubCentroDeCosto = cbSubCentroDeCostos.Selected;
            Vehiculos        = cbVehiculo.SelectedValues;

            SearchPositions();
        }
Beispiel #12
0
 public void MergeFrom(TimePeriod other)
 {
     if (other == null)
     {
         return;
     }
     if (other.initialDate_ != null)
     {
         if (initialDate_ == null)
         {
             InitialDate = new global::Date();
         }
         InitialDate.MergeFrom(other.InitialDate);
     }
     if (other.finalDate_ != null)
     {
         if (finalDate_ == null)
         {
             FinalDate = new global::Date();
         }
         FinalDate.MergeFrom(other.FinalDate);
     }
     _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
 }
Beispiel #13
0
 private void RigthButtonClicked(object sender, EventArgs e)
 {
     InitialDate  = InitialDate.AddMonths(1);
     this.Content = RefreshGrid();
 }
Beispiel #14
0
        public async Task <ActionResult> Index(string sortOrder, string currentFilter, string searchString, int?page, string InitialDate, string InitialFilter,
                                               string FinalDate, string FinalFilter)
        {
            int    inicio = 0, final = 0, pos1 = 0, pos2 = 0;
            string trans;

            ViewBag.CurrentSort = sortOrder;


            ViewBag.UnitSortParm = String.IsNullOrEmpty(sortOrder) ? "UNIT" : "";
            ViewBag.FeeSortParm  = String.IsNullOrEmpty(sortOrder) ? "FEE" : "";
            ViewBag.DateSortParm = String.IsNullOrEmpty(sortOrder) ? "MMYY" : "";


            if (searchString != null)
            {
                page = 1;
            }
            else
            {
                searchString = currentFilter;
            }

            if (InitialDate != null)
            {
                page = 1;
            }
            else
            {
                InitialDate = InitialFilter;
            }

            if (FinalDate != null)
            {
                page = 1;
            }
            else
            {
                FinalDate = FinalFilter;
            }

            ViewBag.CurrentFilter = searchString;
            ViewBag.InitialFilter = InitialDate;
            ViewBag.FinalFilter   = FinalDate;

            //Busqueda por fechas


            if (String.IsNullOrEmpty(InitialDate))
            {
                inicio = 19000101;
            }
            else              // 3/6/2017
            {
                pos1  = InitialDate.IndexOf('/');
                pos2  = InitialDate.LastIndexOf('/');
                trans = InitialDate.Substring(pos2 + 1);
                if (pos1 == 1)
                {
                    trans += "0" + InitialDate.Substring(0, 1);
                }
                else
                {
                    trans += InitialDate.Substring(0, 2);
                }

                if (pos2 - pos1 <= 2)
                {
                    trans += "0" + InitialDate.Substring(pos1 + 1, 1);
                }
                else
                {
                    trans += InitialDate.Substring(pos1 + 1, 2);
                }
                inicio = Convert.ToInt32(trans);
            }

            if (String.IsNullOrEmpty(FinalDate))
            {
                final = Convert.ToInt32(DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString("00") + DateTime.Now.Day.ToString("00"));
            }
            else
            {
                pos1  = FinalDate.IndexOf('/');
                pos2  = FinalDate.LastIndexOf('/');
                trans = FinalDate.Substring(pos2 + 1);
                if (pos1 == 1)
                {
                    trans += "0" + FinalDate.Substring(0, 1);
                }
                else
                {
                    trans += FinalDate.Substring(0, 2);
                }

                if (pos2 - pos1 <= 2)
                {
                    trans += "0" + FinalDate.Substring(pos1 + 1, 1);
                }
                else
                {
                    trans += FinalDate.Substring(pos1 + 1, 2);
                }
                final = Convert.ToInt32(trans);
            }


            var fleets = from s in db.FeeCodes
                         where s.MMYY >= inicio && s.MMYY <= final
                         select s;

            if (!String.IsNullOrEmpty(searchString))
            {
                fleets = fleets.Where(s => s.Fee.ToString().Equals(searchString) || s.Fleet.ToString().Equals(searchString) || s.Unit.ToString().Equals(searchString) || s.LogNo.ToString().Equals(searchString));
            }
            else
            {
                fleets = fleets.Take(100000000);
            }

            switch (sortOrder)
            {
            case "FEE":
                fleets = fleets.OrderByDescending(s => s.Fee);
                break;

            case "UNIT":
                fleets = fleets.OrderBy(s => s.Unit);
                break;

            case "MMYY":
                fleets = fleets.OrderByDescending(s => s.MMYY);
                break;

            default:
                fleets = fleets.OrderBy(s => s.Fleet);
                break;
            }

            int pageSize   = 20;
            int pageNumber = (page ?? 1);

            return(View(fleets.ToPagedList(pageNumber, pageSize)));
        }
Beispiel #15
0
        protected override void OnLoad(EventArgs e)
        {
            Monitor.ContextMenuPostback += Monitor_ContextMenuPostback;

            LoadQtreeInfo();

            base.OnLoad(e);

            var empresa  = DAOFactory.EmpresaDAO.FindById(ddlDistrito.Selected);
            var maxHours = empresa != null && empresa.Id > 0 ? empresa.MaxHorasMonitor : 24;

            dtvalidator.MaxRange = new TimeSpan(maxHours, 0, 0);

            if (!IsPostBack)
            {
                this.RegisterCss(ResolveUrl("~/App_Styles/openlayers.css"));
                RegisterExtJsStyleSheet();

                dtDesde.SelectedDate = InitialDate.Get().ToDisplayDateTime();
                dtHasta.SelectedDate = FinalDate.Get().ToDisplayDateTime();
                WestPanel.Enabled    = !LockFilters.Get();
                dtDesde.Enabled      = !LockFilters.Get();
                dtHasta.Enabled      = !LockFilters.Get();
                if (Distrito.Get() > 0)
                {
                    ddlDistrito.SetSelectedValue(Distrito.Get());
                }
                if (Location.Get() > 0)
                {
                    ddlPlanta.SetSelectedValue(Location.Get());
                }
                if (Chofer.Get() > 0)
                {
                    ddlEmpleado.SetSelectedValue(Chofer.Get());
                }
                if (TypeMobile.Get() > 0)
                {
                    ddlTipoVehiculo.SetSelectedValue(TypeMobile.Get());
                }
                if (Mobile.Get() > 0)
                {
                    ddlMovil.SetSelectedValue(Mobile.Get());
                }

                foreach (var id in PoisTypesIds.Get())
                {
                    var it = lbPuntosDeInteres.Items.FindByValue(id.ToString());
                    if (it != null)
                    {
                        it.Selected = true;
                    }
                }
                PoisTypesIds.Set(lbPuntosDeInteres.SelectedValues);

                InitializeMap();
                if (Mobile.Get() > 0)
                {
                    LoadPositions(true);
                }
            }
        }
Beispiel #16
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            var recruiterName = (Recruiter == null ? "None Assigned" : Recruiter.ToString());

            return($"InitialDate: {InitialDate.ToString(Common.Utilities.DateFormat)}, Recruiter: {recruiterName}, ApproachMethod: {ApproachMethod}");
        }
 public override string ToString()
 {
     return(String.Format("Turma: {0} - Data Início: {1} - Professor: {2}", Course.Description, InitialDate.ToShortDateString(), Teacher.Name));
 }
Beispiel #18
0
        public void Show()
        {
            Console.Clear();
            if (Spendings == null)
            {
                Console.WriteLine("You dont have a budget plan.");
                Console.ReadLine();
                return;
            }

            Console.WriteLine("Here is your budget plan : \n");
            Console.Write("Initial amount of money : ");
            Console.ForegroundColor = ConsoleColor.Cyan;
            Console.WriteLine($"{InitialMoney.ToString("C",_culture)}");
            Console.ResetColor();

            Console.Write("Total money spent : ");
            Console.ForegroundColor = ConsoleColor.Cyan;
            Console.WriteLine($"{TotatSpendings.ToString("C",_culture)}");
            Console.WriteLine();
            Console.ResetColor();
            for (int i = 0; i < 9; i++)
            {
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.Write($"{ Spendings[i].Category} : ");
                Console.ResetColor();
                Console.ForegroundColor = ConsoleColor.Cyan;
                Console.Write($"{Spendings[i].SpentAmount.ToString("C",_culture)}");
                Console.Write(@"/");
                Console.ForegroundColor = ConsoleColor.Red;
                Console.Write($"{Spendings[i].PlannedAmount.ToString("C",_culture)}");

                double dif = Spendings[i].PlannedAmount - Spendings[i].SpentAmount;
                if (dif < 0)
                {
                    Console.ResetColor();
                    Console.Write(" (");
                    Console.ForegroundColor = ConsoleColor.Yellow;
                    Console.Write(dif.ToString("C", _culture));
                    Console.ResetColor();
                    Console.WriteLine(" excess)");
                }
                else
                {
                    Console.WriteLine();
                }
                Console.ResetColor();
            }
            Console.WriteLine();
            Console.Write("Money saved : ");
            Console.ForegroundColor = ConsoleColor.Cyan;
            Console.WriteLine($"{SavedMoney.ToString("C",_culture)}");
            Console.ResetColor();
            Console.WriteLine();

            Console.Write("Initial date : ");
            Console.ForegroundColor = ConsoleColor.Cyan;
            Console.WriteLine($"{InitialDate.ToLocalTime().ToString("yyyy-MM-dd")}");
            Console.ResetColor();

            Console.Write("Expiration date : ");
            Console.ForegroundColor = ConsoleColor.Cyan;
            Console.WriteLine($"{ExpirationDate.ToLocalTime().ToString("yyyy-MM-dd")}");
            Console.ResetColor();

            Console.ReadLine();
        }
Beispiel #19
0
        /// <summary>
        /// Transforms the mobile event into a javascript object.
        /// </summary>
        /// <returns></returns>
        private void GetMessages()
        {
            var messages = lbMessages.SelectedStringValues;

            if (MessagesIds.Count == 0 && messages.Count == 0)
            {
                return;
            }

            var empresa   = DAOFactory.EmpresaDAO.FindById(ddlDistrito.Selected);
            var maxMonths = empresa != null && empresa.Id > 0 ? empresa.MesesConsultaPosiciones : 3;
            var events    = (from ev in DAOFactory.LogMensajeDAO.GetByMobilesAndTypes(ddlMovil.SelectedValues, GetSelectedMessagesCodes(messages), InitialDate.ToDataBaseDateTime(), FinalDate.ToDataBaseDateTime(), maxMonths) orderby ev.Fecha select ev).ToList();

            var eventarray = "[";

            for (var i = 0; i < events.Count; i++)
            {
                var evento = events[i];
                if (!evento.HasValidLatitudes())
                {
                    continue;
                }

                var messageIconUrl = evento.GetIconUrl();
                var iconUrl        = CreateAbsolutePath(string.IsNullOrEmpty(messageIconUrl) ? DefaultMessageImgUrl : string.Concat(IconDir, messageIconUrl));

                if (i > 0)
                {
                    eventarray += ",";
                }

                eventarray += string.Format("{{ id: 'ev_{0}', name: '{1}', lat: {2}, lon:{3}, icon:'{4}', time: new Date{5} }}",
                                            evento.Id, evento.Texto, evento.Latitud.ToString(CultureInfo.InvariantCulture), evento.Longitud.ToString(CultureInfo.InvariantCulture),
                                            iconUrl, evento.Fecha.ToDisplayDateTime().ToString("(yyyy, MM, dd, HH, mm, ss)"));

                //Monitor.AddMarkers(MENSAJES, new Marker(i.ToString(), iconUrl, events[i].Latitud, events[i].Longitud,
                //    string.Format("javascript:gMSP({0})", events[i].Id), DrawingFactory.GetSize(24, 24), DrawingFactory.GetOffset(-12, -12)));

                //if (events[i].HasDuration()) AddMessageWithElapsedTime(events[i]);
            }
            eventarray += "]";

            System.Web.UI.ScriptManager.RegisterStartupScript(this, typeof(string), "events", string.Format("simulador.addEvents({0});", eventarray), true);
            //SetMessagesCenterIndex(events);
        }
Beispiel #20
0
        /// <summary>
        /// Searchs for positions.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSearch_Click(object sender, EventArgs e)
        {
            Distrito    = ddlDistrito.Selected;
            Location    = ddlPlanta.Selected;
            Mobile      = ddlMovil.Selected;
            InitialDate = dtDesde.SelectedDate.HasValue ? dtDesde.SelectedDate.Value.ToDataBaseDateTime(): DateTime.UtcNow.ToDataBaseDateTime();
            FinalDate   = dtHasta.SelectedDate.HasValue ? dtHasta.SelectedDate.Value.ToDataBaseDateTime() : InitialDate.AddDays(1);
            MessageType = ddlTipo.Selected;
            MessagesIds = lbMessages.SelectedStringValues;

            SearchPositions();
            GetMessages();
        }
Beispiel #21
0
        protected void BtnPosicionarTicketClick(object sender, EventArgs e)
        {
            if (lstTicket.SelectedValue.Equals(""))
            {
                infoLabel1.Text = "No se ha seleccionado ningún Ticket.";
                return;
            }

            var split   = lstTicket.SelectedValue.Split('-');
            var prefijo = split[0];
            var id      = Convert.ToInt32((string)split[1]);

            switch (prefijo)
            {
            case "T":
                var ticket = DAOFactory.TicketDAO.FindById(id);

                var detalles = ticket.Detalles.Cast <DetalleTicket>()
                               .Where(d => d.Automatico.HasValue)
                               .OrderBy(t => t.Automatico.Value);

                var primerDetalle = detalles.FirstOrDefault();
                var ultimoDetalle = detalles.LastOrDefault();

                InitialDate = primerDetalle != null ? primerDetalle.Automatico.Value : DateTime.UtcNow.Date.ToDataBaseDateTime();

                if (ticket.Estado == Logictracker.Types.BusinessObjects.Tickets.Ticket.Estados.EnCurso)
                {
                    FinalDate = DateTime.UtcNow;
                }
                else
                {
                    FinalDate = ultimoDetalle != null ? ultimoDetalle.Automatico.Value : DateTime.UtcNow.Date.AddHours(23).AddMinutes(59).ToDataBaseDateTime();
                }

                dtDesde.SelectedDate = InitialDate.ToDisplayDateTime();
                dtHasta.SelectedDate = FinalDate.ToDisplayDateTime();

                if (ticket.Vehiculo != null)
                {
                    Mobile = ticket.Vehiculo.Id;
                }
                break;

            case "V":
                var viaje = DAOFactory.ViajeDistribucionDAO.FindById(id);
                InitialDate = viaje.InicioReal.HasValue
                                     ? viaje.InicioReal.Value
                                     : viaje.Inicio;
                FinalDate = viaje.Fin;

                dtDesde.SelectedDate = InitialDate.ToDisplayDateTime();
                dtHasta.SelectedDate = FinalDate.ToDisplayDateTime();

                if (viaje.Vehiculo != null)
                {
                    Mobile = viaje.Vehiculo.Id;
                }
                break;
            }

            var mensajes = DAOFactory.MensajeDAO.FindAll().Where(m => m.TipoMensaje != null && m.TipoMensaje.DeEstadoLogistico).ToList();
            var msj      = DAOFactory.MensajeDAO.FindAll().Where(m => m.Codigo == MessageCode.EstadoLogisticoCumplido.GetMessageCode() ||
                                                                 m.Codigo == MessageCode.EstadoLogisticoCumplidoEntrada.GetMessageCode() ||
                                                                 m.Codigo == MessageCode.EstadoLogisticoCumplidoManual.GetMessageCode() ||
                                                                 m.Codigo == MessageCode.EstadoLogisticoCumplidoManualRealizado.GetMessageCode() ||
                                                                 m.Codigo == MessageCode.EstadoLogisticoCumplidoManualNoRealizado.GetMessageCode() ||
                                                                 m.Codigo == MessageCode.EstadoLogisticoCumplidoSalida.GetMessageCode() ||
                                                                 m.Codigo == MessageCode.CicloLogisticoIniciado.GetMessageCode() ||
                                                                 m.Codigo == MessageCode.CicloLogisticoCerrado.GetMessageCode()).ToList();

            mensajes.AddRange(msj);

            lbMessages.SetSelectedValues(mensajes.Select(m => m.Codigo));

            Distrito     = ddlDistrito.Selected;
            Location     = ddlPlanta.Selected;
            Stopped      = tpStopped.SelectedTime;
            Distance     = npDistance.Number;
            StoppedEvent = npStoppedEvent.Number;
            MessageType  = ddlTipo.Selected;
            PoisTypesIds = lbPuntosDeInteres.SelectedValues;
            MessagesIds  = lbMessages.SelectedStringValues;

            SearchPositions();
        }
Beispiel #22
0
        private Grid RefreshGrid()
        {
            var newCalendarGrid = new Grid {
                RowSpacing = 1, ColumnSpacing = 1
            };

            newCalendarGrid.RowDefinitions.Add(new RowDefinition {
                Height = new GridLength(1, GridUnitType.Star)
            });
            newCalendarGrid.RowDefinitions.Add(new RowDefinition {
                Height = new GridLength(0.5, GridUnitType.Star)
            });
            for (var i = 2; i <= 6; i++)
            {
                newCalendarGrid.RowDefinitions.Add(new RowDefinition {
                    Height = new GridLength(1, GridUnitType.Star)
                });
            }
            for (var i = 0; i <= 6; i++)
            {
                newCalendarGrid.ColumnDefinitions.Add(new ColumnDefinition {
                    Width = new GridLength(1, GridUnitType.Star)
                });
            }
            var firstDayOfMonth = new DateTime(InitialDate.Year, InitialDate.Month, 1);
            var dayOfWeekEU     = firstDayOfMonth.DayOfWeek == 0 ? 7 : (int)firstDayOfMonth.DayOfWeek;
            var currCalDay      = firstDayOfMonth.AddDays(-dayOfWeekEU + 1);
            var leftButton      = new Button {
                Text = "<", Style = UnselectedDateStyle, IsEnabled = true
            };

            leftButton.Clicked += LeftButtonClicked;
            newCalendarGrid.Children.Add(leftButton, 0, 0);
            var rightButton = new Button {
                Text = ">", Style = UnselectedDateStyle, IsEnabled = true
            };

            rightButton.Clicked += RigthButtonClicked;
            newCalendarGrid.Children.Add(rightButton, 6, 0);
            bool IsEnabled = true;

            for (var y = 2; y <= 7; y++)
            {
                for (var x = 0; x <= 6; x++)
                {
                    if (y == 2)
                    {
                        var dayOfWeekLabel = new Label()
                        {
                            VerticalTextAlignment   = TextAlignment.Center,
                            HorizontalTextAlignment = TextAlignment.Center,
                            Text = currCalDay.ToString("ddd")
                        };
                        newCalendarGrid.Children.Add(dayOfWeekLabel, x, 1);
                    }
                    ;
                    if (HideOtherMonthsDates && currCalDay.Month != InitialDate.Month)
                    {
                        currCalDay = currCalDay.AddDays(1);
                        continue;
                    }


                    IsEnabled = currCalDay.Month == InitialDate.Month;

                    int currentDayOfWeek = Convert.ToInt32(Math.Pow(2, (double)currCalDay.DayOfWeek));
                    var buttonStyle      = ((currentDayOfWeek & WeeklyHolydays) > 0) ? HolydayStyle : UnselectedDateStyle;

                    //TODO need check with Resharper
                    buttonStyle = (UnplannedWorkingDays?.Contains(currCalDay) ?? false) ? UnselectedDateStyle : buttonStyle;
                    buttonStyle = (UnplannedHolydays?.Contains(currCalDay) ?? false) ? HolydayStyle : buttonStyle;

                    var dateButton = new Button {
                        Text = currCalDay.Day.ToString(), Style = buttonStyle, IsEnabled = IsEnabled
                    };
                    dateButton.Clicked += DateClicked;
                    newCalendarGrid.Children.Add(dateButton, x, y);
                    currCalDay = currCalDay.AddDays(1);
                }
            }

            var monthLabel = new Label
            {
                Text = InitialDate.ToString("MMMM yyyy"),
                HorizontalTextAlignment = TextAlignment.Center,
                VerticalTextAlignment   = TextAlignment.Center,
                TextColor = Color.Black,
                FontSize  = 20
            };

            newCalendarGrid.Children.Add(monthLabel, 1, 0);
            Grid.SetColumnSpan(monthLabel, 5);
            return(newCalendarGrid);
        }
        public async Task <ActionResult> Index(string sortOrder, string currentFilter, string searchString, int?page,
                                               string currentUnit, string searchUnit, string currentLlogNo, string searchLogNo,
                                               string currentFee, string searchFee,
                                               string InitialDate, string InitialFilter, string FinalDate, string FinalFilter)
        {
            try
            {
                int  inicio = 0, final = 0, pos1 = 0, pos2 = 0;
                bool band = true;

                if ((!String.IsNullOrEmpty(InitialDate)) || (!String.IsNullOrEmpty(FinalDate)))
                {
                    if (String.IsNullOrEmpty(InitialDate))
                    {
                        this.HttpContext.Session["Display1"] = "The Initial Date cannot be empty, please set a correct date.";
                        band = false;
                    }


                    if (String.IsNullOrEmpty(FinalDate))
                    {
                        this.HttpContext.Session["Display1"] = "The Final Date cannot be empty, please set a correct date.";
                        band = false;
                    }

                    if (band)
                    {
                        if (Convert.ToDateTime(FinalDate) < Convert.ToDateTime(InitialDate))
                        {
                            this.HttpContext.Session["Display1"] = "The Initial Date cannot be major than Final Date, please set a correct date.";
                            band = false;
                        }
                        else if (Convert.ToDateTime(FinalDate) > Convert.ToDateTime(InitialDate).AddDays(7))
                        {
                            this.HttpContext.Session["Display1"] = "The Final Date cannot be more than 7 days major than Initial Date, please set a correct date.)";
                            band = false;
                        }
                    }
                }

                if (((!String.IsNullOrEmpty(searchString)) || (!String.IsNullOrEmpty(searchUnit)) || (!String.IsNullOrEmpty(searchLogNo)) || (!String.IsNullOrEmpty(searchFee)) ||
                     (!String.IsNullOrEmpty(InitialDate)) || (!String.IsNullOrEmpty(FinalDate) || (!String.IsNullOrEmpty(currentFilter)) || (!String.IsNullOrEmpty(currentUnit)) ||
                                                              (!String.IsNullOrEmpty(currentLlogNo)) || (!String.IsNullOrEmpty(currentFee)) || (!String.IsNullOrEmpty(InitialFilter)) || (!String.IsNullOrEmpty(FinalFilter)))) && band)
                {
                    ViewBag.CurrentSort = sortOrder;

                    ViewBag.UnitSortParm  = String.IsNullOrEmpty(sortOrder) ? "Unit" : "";
                    ViewBag.FeeSortParm   = String.IsNullOrEmpty(sortOrder) ? "Fee" : "";
                    ViewBag.DateSortParm  = String.IsNullOrEmpty(sortOrder) ? "MMYY" : "";
                    ViewBag.LogNoSortParm = String.IsNullOrEmpty(sortOrder) ? "LogNo" : "";


                    if ((searchString != null) || (searchUnit != null) || (searchLogNo != null) || (searchFee != null))
                    {
                        page = 1;
                    }
                    else
                    {
                        searchString = currentFilter;
                        searchUnit   = currentUnit;
                        searchLogNo  = currentLlogNo;
                        searchFee    = currentFee;
                        InitialDate  = InitialFilter;
                        FinalDate    = FinalFilter;
                    }

                    ViewBag.currentFilter = searchString;
                    ViewBag.currentUnit   = searchUnit;
                    ViewBag.currentLlogNo = searchLogNo;
                    ViewBag.currentFee    = searchFee;
                    ViewBag.InitialFilter = InitialDate;
                    ViewBag.FinalFilter   = FinalDate;

                    var fleets = from s in db.FeeCodes
                                 select s;

                    //Busqueda por fechas
                    if ((!String.IsNullOrEmpty(InitialDate)) && (!String.IsNullOrEmpty(FinalDate)))
                    {
                        //fecha inicial
                        trans  = InitialDate.Replace("-", "");
                        inicio = Convert.ToInt32(trans);

                        //Fecha final
                        trans = FinalDate.Replace("-", "");
                        final = Convert.ToInt32(trans);

                        fleets = fleets.Where(s => (s.MMYY >= inicio) && (s.MMYY <= final));
                    }

                    if (!String.IsNullOrEmpty(searchString))
                    {
                        fleets = fleets.Where(s => s.Fleet.ToString().Contains(searchString));
                    }

                    if (!String.IsNullOrEmpty(searchUnit))
                    {
                        fleets = fleets.Where(s => s.Unit.ToString().Contains(searchUnit));
                    }

                    if (!String.IsNullOrEmpty(searchLogNo))
                    {
                        fleets = fleets.Where(s => s.LogNo.ToString().Contains(searchLogNo));
                    }

                    if (!String.IsNullOrEmpty(searchFee))
                    {
                        fleets = fleets.Where(s => s.Fee.ToString().Contains(searchFee));
                    }

                    switch (sortOrder)
                    {
                    case "Fee":
                        fleets = fleets.OrderByDescending(s => s.Fee);
                        break;

                    case "Unit":
                        fleets = fleets.OrderBy(s => s.Unit);
                        break;

                    case "MMYY":
                        fleets = fleets.OrderByDescending(s => s.MMYY);
                        break;

                    case "LogNo":
                        fleets = fleets.OrderByDescending(s => s.LogNo);
                        break;

                    default:
                        fleets = fleets.OrderBy(s => s.Fleet);
                        break;
                    }
                    this.HttpContext.Session["Display1"] = this.HttpContext.Session["Display2"] = "";
                    int pageSize   = 100;
                    int pageNumber = (page ?? 1);
                    return(View(fleets.ToPagedList(pageNumber, pageSize)));
                }
                else
                {
                    if (band)
                    {
                        this.HttpContext.Session["Display1"] = "You must set filters";
                    }
                    else
                    {
                        this.HttpContext.Session["Display1"] = this.HttpContext.Session["Display2"] = "";
                    }
                    var fleets = from s in db.FeeCodes
                                 where s.LogNo.Equals(0)
                                 select s;
                    int pageSize   = 100;
                    int pageNumber = (page ?? 1);
                    return(View(fleets.ToPagedList(pageNumber, pageSize)));
                }
            }
            catch (Exception ex)
            {
                this.HttpContext.Session["Display1"] = "Error: " + ex.Message + " Try again with more filters";
                return(RedirectToAction("Index"));
            }
        }
Beispiel #24
0
 /// <summary>
 /// Method for comparing two events by initial date
 /// </summary>
 /// <param name="aEvent">A event to compare</param>
 /// <returns>A indication of its relative values.</returns>
 public int CompareTo(RouteEvent aEvent)
 {
     return(InitialDate.CompareTo(aEvent.InitialDate));
 }