Exemplo n.º 1
0
        private void ShowInstructions(Intercalado viaje)
        {
            if (viaje.ViajeIntercalado == null)
            {
                return;
            }
            var distri = DAOFactory.ViajeDistribucionDAO.FindById(viaje.Id);
            var header = string.Format("<b>Hoja de Ruta: {0}</b> <span class='change'>({1})</span><br/>",
                                       distri.Codigo,
                                       distri.Vehiculo != null ? distri.Vehiculo.Interno : "sin vehiculo");

            const string destino = "<br/><div style='font-size: 1.1em'><span class='change'>DESTINO {3}: [{0}]</span> <b>{1}</b> {2}</div></br>";

            var stepNo = 1;
            var destNo = 1;
            var ins    = header;

            for (int i = 0; i < viaje.ViajeIntercalado.Legs.Count; i++)
            {
                var entrega = distri.Detalles[i];
                ins += string.Format(destino, entrega.Programado.ToString("HH:mm"), entrega.Descripcion, destNo == viaje.Index + 1 ? "(NUEVO)" : "", destNo++);
                var leg = viaje.ViajeIntercalado.Legs[i];
                ins = leg.Steps.Aggregate(ins, (a, n) => string.Concat(a, "<b><span class='change'>", stepNo++, ".</span></b> ", n.Instructions, "<br/>"));
            }
            var last = distri.Detalles.Last();

            ins += string.Format(destino, last.Programado.ToString("HH:mm"), last.Descripcion, destNo == viaje.Index + 1 ? "(NUEVO)" : "", destNo);
            lblInstructions.Text = ins;
        }
Exemplo n.º 2
0
        protected void ShowViaje(Intercalado viaje, int selectedId)
        {
            var color  = GetColor(viaje.Id);
            var line   = new Line("v" + viaje.Id, StyleFactory.GetLineFromColor(color, 4, 0.5));
            var distri = DAOFactory.ViajeDistribucionDAO.FindById(viaje.Id);

            // Agrego los markers de las entregas
            var ordenEntrega = 1;

            foreach (var entrega in distri.Detalles)
            {
                var imageUrl = GetImageUrl(color, ordenEntrega++);
                AddMarker(entrega, imageUrl);
            }

            // Agrego las lineas de recorrido
            var recorrido = viaje.Id == selectedId ? viaje.ViajeIntercalado : viaje.ViajeAnterior;

            if (recorrido != null)
            {
                var stepCount = 0;
                var steps     = recorrido.Legs.SelectMany(l => l.Steps);
                var puntos    = steps.SelectMany(s => s.Points)
                                .Select(p => new Point((stepCount++).ToString("0"), p.Longitud, p.Latitud));
                line.AddPoints(puntos);
                Monitor1.AddGeometries(LayerRecorrido, line);
            }
        }
Exemplo n.º 3
0
        protected void btGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                var intercalados = Intercalados.Get();
                var id           = grid.SelectedIndex > -1 && grid.SelectedIndex < grid.DataKeys.Count
                             ? Convert.ToInt32(grid.DataKeys[grid.SelectedIndex].Value)
                             : -1;
                if (id <= 0)
                {
                    return;
                }


                var         viaje       = DAOFactory.ViajeDistribucionDAO.FindById(id);
                Intercalado intercalado = intercalados.FirstOrDefault(i => i.Id == id);

                var nuevoDetalle = new EntregaDistribucion
                {
                    Viaje        = viaje,
                    PuntoEntrega = DAOFactory.PuntoEntregaDAO.FindById(cbPuntoEntrega.Selected)
                };
                nuevoDetalle.Cliente      = nuevoDetalle.PuntoEntrega.Cliente;
                nuevoDetalle.Descripcion  = nuevoDetalle.PuntoEntrega.Descripcion;
                nuevoDetalle.Orden        = intercalado.Index;
                nuevoDetalle.Programado   = intercalado.Hora;
                nuevoDetalle.TipoServicio = DAOFactory.TipoServicioCicloDAO.FindById(cbTipoServicio.Selected);
                viaje.InsertarEntrega(intercalado.Index, nuevoDetalle);

                DAOFactory.ViajeDistribucionDAO.SaveOrUpdate(viaje);
                ShowInfo("La entrega se ha intercalado correctamente");
                if (InformarPorMail)
                {
                    try
                    {
                        SendMail();
                    }
                    catch (Exception ex)
                    {
                        STrace.Exception("Intercalador de Entregas", ex);
                        ShowError("La entrega se ha intercalado correctamente, pero no se pudo enviar el mail");
                    }
                }
                BtnSearchClick(sender, e);
            }
            catch (Exception ex)
            {
                ShowError(ex);
            }
        }
Exemplo n.º 4
0
        protected void ShowResults(List <Intercalado> intercalados, int selectedId)
        {
            Monitor1.ClearLayer(LayerEntregas);
            Monitor1.ClearLayer(LayerRecorrido);
            lblInstructions.Text = string.Empty;

            IList <EntregaDistribucion> detalles = null;

            if (intercalados != null && selectedId > 0)
            {
                Intercalado selected = intercalados.FirstOrDefault(i => selectedId == i.Id);

                var viaje = DAOFactory.ViajeDistribucionDAO.FindById(selectedId);

                // nueva entrega
                var nuevoDetalle = new EntregaDistribucion
                {
                    Viaje        = viaje,
                    PuntoEntrega = DAOFactory.PuntoEntregaDAO.FindById(cbPuntoEntrega.Selected)
                };
                nuevoDetalle.Cliente      = nuevoDetalle.PuntoEntrega.Cliente;
                nuevoDetalle.Descripcion  = nuevoDetalle.PuntoEntrega.Descripcion;
                nuevoDetalle.TipoServicio = cbTipoServicio.Selected > 0 ?
                                            DAOFactory.TipoServicioCicloDAO.FindById(cbTipoServicio.Selected)
                    : null;

                // intercalo la nueva entrega en el viaje seleccionado
                detalles = viaje.Detalles;

                viaje.InsertarEntrega(selected.Index, nuevoDetalle);
                if (selected.Index > 0)
                {
                    viaje.CalcularHorario(selected.Index, selected.ViajeIntercalado);
                }
                if (selected.Index < detalles.Count)
                {
                    viaje.CalcularHorario(selected.Index, selected.ViajeIntercalado);
                }


                // muestro todos los viajes en el mapa
                foreach (var costo in intercalados)
                {
                    ShowViaje(costo, selectedId);

                    // si el viaje está seleccionado muestro la nueva entrega con el mismo color
                    if (selectedId == costo.Id)
                    {
                        var colorNew    = GetColor(costo.Id);
                        var imageUrlNew = GetImageUrl(colorNew, costo.Index + 1, "sq");
                        AddMarker(nuevoDetalle, imageUrlNew);
                        selected = costo;

                        ShowInstructions(costo);
                    }
                }

                Monitor1.SetCenter(nuevoDetalle.ReferenciaGeografica.Latitude,
                                   nuevoDetalle.ReferenciaGeografica.Longitude);

                selectedIndex = selected.Index;
            }

            // bindeo los detalles con la nueva entrega intercalada
            reorderDetalles.DataSource = detalles;
            reorderDetalles.DataBind();

            updResult.Update();
            updDetalles.Update();
        }