Exemple #1
0
        protected override void OnInit(EventArgs e)
        {
            if (Request.QueryString["color"] != null)
            {
                CreateImage();
                return;
            }
            base.OnInit(e);

            if (!IsPostBack)
            {
                var googleMapsEnabled = true;
                var usuario           = DAOFactory.UsuarioDAO.FindById(WebSecurity.AuthenticatedUser.Id);
                if (usuario != null && usuario.PorEmpresa && usuario.Empresas.Count == 1)
                {
                    var empresa = usuario.Empresas.First() as Empresa;
                    if (empresa != null)
                    {
                        googleMapsEnabled = empresa.GoogleMapsEnabled;
                    }
                }

                Monitor1.EnableTimer = false;
                Monitor1.Initialize(googleMapsEnabled);
                Monitor1.AddLayers(LayerFactory.GetVector(LayerRecorrido, true),
                                   LayerFactory.GetMarkers(LayerEntregas, true));
            }
        }
Exemple #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);
            }
        }
Exemple #3
0
    public static void Run()
    {
        Monitor1      m  = new Monitor1();
        EventReciever er = new EventReciever();

        m.Read += er.DetectRead; // 绑定到事件上
        m.Run();
    }
Exemple #4
0
        protected void btMapa_Command(object sender, CommandEventArgs e)
        {
            var pos    = e.CommandArgument.ToString().Split(',');
            var lat    = Convert.ToDouble(pos[0], CultureInfo.InvariantCulture);
            var lon    = Convert.ToDouble(pos[1], CultureInfo.InvariantCulture);
            var icn    = string.Concat(ImagesDir, "salida.png");
            var size   = DrawingFactory.GetSize(40, 40);
            var offset = DrawingFactory.GetOffset(-20, -32);
            var marker = new Marker("0", icn, lat, lon, size, offset);

            Monitor1.AddMarkers("Posicion", marker);
            Monitor1.SetCenter(lat, lon, 12);
            modalMapa.Show();
            ScriptManager.RegisterStartupScript(this, typeof(string), "hidemap", string.Format("$get('{0}').style.visibility = '';", divMapa.ClientID), true);
        }
Exemple #5
0
        protected void AddMarker(EntregaDistribucion item, string imageUrl)
        {
            if (item.ReferenciaGeografica == null)
            {
                return;
            }
            var id       = item.Id.ToString("0");
            var latitud  = item.ReferenciaGeografica.Latitude;
            var longitud = item.ReferenciaGeografica.Longitude;
            var label    = item.Programado.ToString("HH:mm");
            var marker   = MarkerFactory.CreateLabeledMarker("m" + id, imageUrl, latitud, longitud, label);

            marker.Size   = DrawingFactory.GetSize(20, 20);
            marker.Offset = DrawingFactory.GetOffset(-10, -10);
            Monitor1.AddMarkers(LayerEntregas, marker);
        }
Exemple #6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                var googleMapsEnabled = true;
                var usuario           = DAOFactory.UsuarioDAO.FindById(WebSecurity.AuthenticatedUser.Id);
                if (usuario != null && usuario.PorEmpresa && usuario.Empresas.Count == 1)
                {
                    var empresa = usuario.Empresas.First() as Empresa;
                    if (empresa != null)
                    {
                        googleMapsEnabled = empresa.GoogleMapsEnabled;
                    }
                }

                Monitor1.Initialize(googleMapsEnabled);
                Monitor1.AddLayers(LayerFactory.GetMarkers("Posicion", true));
            }
        }
Exemple #7
0
        protected void ShowMensaje(LogMensaje mensaje)
        {
            var iconDir = IconDir;

            var color = mensaje.Accion != null
                            ? Color.FromArgb(100, mensaje.Accion.Red, mensaje.Accion.Green, mensaje.Accion.Blue)
                            : Color.Gray;

            panelTitle.BackColor = color;
            panelTitle.ForeColor = color.GetBrightness() < 40 ? Color.White: Color.Black;

            if (mensaje.Accion != null && mensaje.Accion.PopIcon > 0)
            {
                imgAccion.ImageUrl = string.Format("{0}/{1}", iconDir, mensaje.Accion.PopUpIcon.PathIcono);
            }
            else
            {
                imgAccion.Visible = false;
            }

            lbMensaje.Text    = mensaje.Texto;
            lblHora.Text      = mensaje.Fecha.ToDisplayDateTime().ToString("dd/MM/yyyy HH:mm");
            lblRecepcion.Text = mensaje.FechaAlta.HasValue
                                    ? "(" + mensaje.FechaAlta.Value.ToDisplayDateTime().ToString("dd/MM/yyyy HH:mm") + ")"
                                    : string.Empty;

            var pos = mensaje.Fecha;

            var link = string.Format(
                "../Monitor/MonitorHistorico/monitorHistorico.aspx?Planta={0}&TypeMobile={1}&Movil={2}&InitialDate={3}&FinalDate={4}&ShowMessages=0&ShowPOIS=0&Empresa={5}",
                mensaje.Coche.Linea != null ? mensaje.Coche.Linea.Id : -1, mensaje.Coche.TipoCoche.Id, mensaje.Coche.Id, pos.Subtract(TimeSpan.FromMinutes(15)).ToString(CultureInfo.InvariantCulture),
                pos.Add(TimeSpan.FromMinutes(1)).ToString(CultureInfo.InvariantCulture), mensaje.Coche.Empresa != null ? mensaje.Coche.Empresa.Id : mensaje.Coche.Linea != null ? mensaje.Coche.Linea.Empresa.Id : -1);

            lbMensaje.OnClientClick = string.Format("window.open('{0}', '" + CultureManager.GetMenu("OPE_MON_HISTORICO") + "')", link);

            lblMovil.Text = mensaje.Coche.Interno;
            var imgMovl = string.Format("{0}/{1}", iconDir, mensaje.Coche.TipoCoche.IconoNormal.PathIcono);

            imgMovil.ImageUrl = imgMovl;

            var chofer = mensaje.Chofer ?? mensaje.Coche.Chofer;

            lblChofer.Text = chofer != null
                                 ? string.Format("{0} - {1}", chofer.Legajo, chofer.Entidad.Descripcion)
                                 : CultureManager.GetString("Labels", "SIN_CHOFER");

            lblDireccion.Text = GeocoderHelper.GetDescripcionEsquinaMasCercana(mensaje.Latitud, mensaje.Longitud);

            lblLatitud.Text  = mensaje.Latitud.ToString(CultureInfo.InvariantCulture);
            lblLongitud.Text = mensaje.Longitud.ToString(CultureInfo.InvariantCulture);

            Monitor1.ImgPath          = Config.Monitor.GetMonitorImagesFolder(this);
            Monitor1.GoogleMapsScript = GoogleMapsKey;
            Monitor1.EnableTimer      = false;
            Monitor1.AddLayers(LayerFactory.GetGoogleStreet(CultureManager.GetLabel("LAYER_GSTREET"), 8),
                               //LayerFactory.GetCompumap(CultureManager.GetLabel("LAYER_COMPUMAP"), Config.Map.CompumapTiles, 8),
                               LayerFactory.GetOpenStreetMap(CultureManager.GetLabel("LAYER_OSM")),
                               LayerFactory.GetGoogleSatellite(CultureManager.GetLabel("LAYER_GSAT"), 8),
                               LayerFactory.GetGoogleHybrid(CultureManager.GetLabel("LAYER_GHIBRIDO"), 8),
                               LayerFactory.GetGooglePhysical(CultureManager.GetLabel("LAYER_GFISICO"), 8),
                               LayerFactory.GetMarkers(LayerVehiculos, true));
            Monitor1.AddControls(ControlFactory.GetLayerSwitcher(),
                                 ControlFactory.GetNavigation());
            Monitor1.SetCenter(mensaje.Latitud, mensaje.Longitud, 7);
            Monitor1.AddMarkers(LayerVehiculos, MarkerFactory.CreateMarker(mensaje.Coche.Id.ToString("#0"), imgMovl, mensaje.Latitud, mensaje.Longitud));

            var empresa = mensaje.Coche.Empresa;
            var linea   = mensaje.Coche.Linea;
            var user    = WebSecurity.AuthenticatedUser != null?DAOFactory.UsuarioDAO.FindById(WebSecurity.AuthenticatedUser.Id) : null;

            var mensajes = DAOFactory.MensajeDAO.FindByTipo(null, empresa, linea, user);
            var messages = mensajes.Where(m => m.TipoMensaje.DeAtencion).OrderBy(m => m.Descripcion);

            cbMensaje.ClearItems();
            cbMensaje.AddItem(CultureManager.GetControl("DDL_NO_MESSAGE"), cbMensaje.NoneValue);
            foreach (var msg in messages)
            {
                cbMensaje.AddItem(msg.Descripcion, msg.Id);
            }

            if (mensaje.Estado > 0)
            {
                btAceptar.Visible  = false;
                btIgnorar.ImageUrl = "~/Operacion/btAtras.gif";

                var atencion = DAOFactory.AtencionEventoDAO.GetByEvento(mensaje.Id);
                if (atencion != null)
                {
                    panelUsuario.Visible = true;
                    lblUsuario.Text      = atencion.Usuario.NombreUsuario;
                    panelFecha.Visible   = true;
                    lblFecha.Text        = atencion.Fecha.ToDisplayDateTime().ToString("dd/MM/yyyy HH:mm");
                    cbMensaje.SetSelectedValue(atencion.Mensaje.Id);
                    cbMensaje.Enabled      = false;
                    txtObservacion.Text    = atencion.Observacion;
                    txtObservacion.Enabled = false;
                }
            }

            if (!WebSecurity.IsSecuredAllowed(Securables.EventAttention))
            {
                btAceptar.Visible  = false;
                btIgnorar.ImageUrl = "~/Operacion/btAtras.gif";
            }
        }
Exemple #8
0
 public void DetectRead(Monitor1 m, Monitor1.ReadEventArgs e)
 {
     Console.WriteLine("Recieve a string from monitor : " + e.str);
 }
Exemple #9
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();
        }
Exemple #10
0
        protected void ShowEvento(LogEvento evento)
        {
            var iconDir = IconDir;

            var color = evento.Accion != null
                            ? Color.FromArgb(100, evento.Accion.Red, evento.Accion.Green, evento.Accion.Blue)
                            : Color.Gray;

            panelTitle.BackColor = color;
            panelTitle.ForeColor = color.GetBrightness() < 40 ? Color.White : Color.Black;

            if (evento.Accion != null && evento.Accion.PopIcon > 0)
            {
                imgAccion.ImageUrl = string.Format("{0}/{1}", iconDir, evento.Accion.PopUpIcon.PathIcono);
            }
            else
            {
                imgAccion.Visible = false;
            }

            lbMensaje.Text     = evento.Texto;
            lblHora.Text       = evento.Fecha.ToDisplayDateTime().ToString("dd \"de\" MMMM \"de\" yyyy HH:mm");
            lblEntidad.Text    = evento.SubEntidad != null ? evento.SubEntidad.Entidad.Descripcion : string.Empty;
            lblSubEntidad.Text = evento.SubEntidad != null ? evento.SubEntidad.Descripcion : string.Empty;
            if (evento.SubEntidad != null)
            {
                foreach (DetalleValor detalle in evento.SubEntidad.Entidad.Detalles)
                {
                    var valor = string.Empty;
                    switch (detalle.Detalle.Tipo)
                    {
                    case 1:
                        valor = detalle.ValorStr;
                        break;

                    case 2:
                        valor = detalle.ValorNum.ToString("#0.00");
                        break;

                    case 3:
                        valor = detalle.ValorDt.HasValue ? detalle.ValorDt.Value.ToString("dd/MM/yyyy HH:mm") : string.Empty;
                        break;
                    }

                    var lbl = new Label {
                        Text = @"<b>" + detalle.Detalle.Nombre + @":</b> " + valor + @"<br/><br/>"
                    };
                    panelDetalles.Controls.Add(lbl);
                }

                lblDireccion.Text = GeocoderHelper.GetDescripcionEsquinaMasCercana(evento.SubEntidad.Entidad.ReferenciaGeografica.Latitude, evento.SubEntidad.Entidad.ReferenciaGeografica.Longitude);
            }

            Monitor1.ImgPath          = Config.Monitor.GetMonitorImagesFolder(this);
            Monitor1.GoogleMapsScript = GoogleMapsKey;
            Monitor1.EnableTimer      = false;
            Monitor1.AddLayers(LayerFactory.GetGoogleStreet(CultureManager.GetLabel("LAYER_GSTREET"), 8),
                               //LayerFactory.GetCompumap(CultureManager.GetLabel("LAYER_COMPUMAP"), Config.Map.CompumapTiles, 8),
                               LayerFactory.GetOpenStreetMap(CultureManager.GetLabel("LAYER_OSM")),
                               LayerFactory.GetGoogleSatellite(CultureManager.GetLabel("LAYER_GSAT"), 8),
                               LayerFactory.GetGoogleHybrid(CultureManager.GetLabel("LAYER_GHIBRIDO"), 8),
                               LayerFactory.GetGooglePhysical(CultureManager.GetLabel("LAYER_GFISICO"), 8),
                               LayerFactory.GetMarkers(LayerEntidades, true));
            Monitor1.AddControls(ControlFactory.GetLayerSwitcher(), ControlFactory.GetNavigation());

            if (evento.SubEntidad != null)
            {
                Monitor1.SetCenter(evento.SubEntidad.Entidad.ReferenciaGeografica.Latitude, evento.SubEntidad.Entidad.ReferenciaGeografica.Longitude, 7);
                var imgEntidad = string.Format("{0}{1}", iconDir, evento.SubEntidad.Entidad.ReferenciaGeografica.Icono.PathIcono);

                Monitor1.AddMarkers(LayerEntidades, MarkerFactory.CreateMarker(evento.SubEntidad.Entidad.Id.ToString("#0"),
                                                                               imgEntidad,
                                                                               evento.SubEntidad.Entidad.ReferenciaGeografica.Latitude,
                                                                               evento.SubEntidad.Entidad.ReferenciaGeografica.Longitude));
            }

            if (evento.Estado > 0)
            {
                btAceptar.Visible  = false;
                btIgnorar.ImageUrl = "~/Operacion/btAtras.gif";
            }
        }