示例#1
0
        public List <entradassalidasDTO> getDetallesRecorridos(DateTime fecha, int grupo, string placa)
        {
            fecha = fecha.Date;
            DateTime fechaFin = new DateTime(fecha.Year, fecha.Month, fecha.Day, 23, 59, 59);
            List <entradassalidasDTO> lEsDto = new List <entradassalidasDTO>();
            entradassalidasDTO        eSDto;

            using (ctx = new tvEntities()) {
                List <entradassalidas> lEs = ctx.entradassalidas.OrderBy(t => t.Fecha).Where(t => t.Fecha > fecha && t.Fecha < fechaFin && t.Placa == placa).ToList();
                //rutagrupo rG = ctx.rutagrupo.Where(t=> t.Grupo==grupo).FirstOrDefault().rutas;
                rutas ruta = ctx.rutagrupo.Where(t => t.Grupo == grupo).FirstOrDefault().rutas;

                eSDto = new entradassalidasDTO();
                foreach (entradassalidas eS in lEs)
                {
                    if (eS.Estado == "S")
                    {
                        eSDto.Fecha   = eS.Fecha;
                        eSDto.HoraIni = (eS.Fecha.TimeOfDay).ToString();
                    }
                    else
                    {
                        eSDto.FechaFin = eS.Fecha;
                        eSDto.HoraFin  = (eS.Fecha.TimeOfDay).ToString();
                        eSDto.Tiempo   = Convert.ToInt32((eSDto.FechaFin - eSDto.Fecha).TotalMinutes);
                        eSDto.Coleo    = (eSDto.Tiempo - Convert.ToInt32(ruta.TiempoRecorrido.Value));
                        lEsDto.Add(eSDto);

                        eSDto = new entradassalidasDTO();
                    }
                }

                return(lEsDto);
            }
        }
示例#2
0
 public objRes Insert(rutasDto Reg)
 {
     using (ctx = new tvEntities())
     {
         objRes Respuesta = new objRes();
         try
         {
             rutas RutaOld = ctx.rutas.Where(t => t.NomRuta == Reg.NomRuta).FirstOrDefault();
             if (RutaOld == null)
             {
                 rutas ruta = new rutas();
                 Mapper.Map(Reg, ruta);
                 ctx.rutas.Add(ruta);
                 ctx.SaveChanges();
                 Respuesta.Error = false;
                 Respuesta.Mensaje = "Operacion realizada satisfactoriamente!!!";
                 return Respuesta;
             }
             else
             {
                 Respuesta.Error = true;
                 Respuesta.Mensaje = "Ya se encuentra registrado un bus con esta placa...";
                 return Respuesta;
             }
         }
         catch (Exception e)
         {
             Respuesta.Error = true;
             Respuesta.Mensaje = e.Message;
             return Respuesta;
         }
     }
 }
示例#3
0
        public rutasDto Get(string Vial)
        {
            using(ctx=new tvEntities()){
                DateTime fecha = DateTime.Now.Date;
                rutasDto rutaDto = new rutasDto();

                detallesplanilla dP = ctx.detallesplanilla.Where(t => t.buses.Vial == Vial && t.planillacontrol.Fecha==fecha).FirstOrDefault();
                rutas ruta = ctx.rutas.Where(t => t.NomRuta == dP.Ruta).FirstOrDefault();

                Mapper.Map(ruta,rutaDto);
                return rutaDto;
            }
        }
示例#4
0
        private void createListaHor(ref List <horarioDTO> lHor, rutas ruta, horario hor)
        {
            horarioDTO horDTO = new horarioDTO();

            System.TimeSpan time = hor.hora.Value;

            for (int i = 1; i <= ruta.Capacidad; i++)
            {
                horDTO.hora = time;
                horDTO.time = time.ToString();
                lHor.Add(horDTO);
                horDTO = new horarioDTO();
                time   = time + new TimeSpan(0, ruta.Frecuencia.Value, 0);
            }
        }
示例#5
0
        public objRes Delete(string NomRuta)
        {
            using (ctx = new tvEntities())
            {
                objRes Res = new objRes();
                try
                {
                    rutas oRuta = ctx.rutas.Where(t => t.NomRuta == NomRuta).FirstOrDefault();
                    if (oRuta != null)
                    {
                        foreach (coordenadasrutas item in oRuta.coordenadasrutas.ToList())
                        {
                            ctx.coordenadasrutas.Remove(item);
                            ctx.SaveChanges();
                        }

                        ctx.rutas.Remove(oRuta);
                        ctx.SaveChanges();
                        Res.Error = false;

                        Res.Mensaje = "Operacion realizada satisfactoriamente!!!";
                    }
                    else
                    {
                        Res.Error = true;
                        Res.Mensaje = "No existe ruta con este nombre!!!";
                    }
                    return Res;
                }
                catch (Exception e)
                {
                    Res.Error = true;
                    Res.Mensaje = e.Message;
                    return Res;
                }
            }
        }
示例#6
0
        private List <List <detallesplanillaDTO> > crearRotacionesBuses(ref string[] nBus, ref int mes, ref DateTime fcha,
                                                                        ref int grupo, ref List <rutagrupo> lrGrupo,
                                                                        ref List <buses> lBus)
        {
            planillacontrol pC;

            int diasMes = DateTime.DaysInMonth(fcha.Year, fcha.Month);
            int d       = 1;
            int k       = 1;
            int daysToToday;

            daysToToday = Convert.ToInt32((fcha - (new DateTime(DateTime.Now.Year, 1, 1))).TotalDays);
            string[] mBus = new string[30];
            List <List <detallesplanillaDTO> > lldP = new List <List <detallesplanillaDTO> >();

            for (int i = 1; i <= mesTurno.GetLength(1); i++)
            {
                mBus[i] = nBus[mesTurno[mes - 1, i - 1]];
            }

            for (int i = 0; i < dia.GetLength(0); i++)
            {
                if (diasMes == lldP.Count)
                {
                    break;
                }

                List <detallesplanillaDTO> ldP = new List <detallesplanillaDTO>();
                for (int j = 0; j < dia.GetLength(1); j++)
                {
                    detallesplanillaDTO dP = new detallesplanillaDTO();
                    dP.Vial     = mBus[dia[i, j]];
                    dP.PlacaBus = lBus.Find(t => t.Vial == dP.Vial).Placa;
                    ldP.Add(dP);
                    k++;
                }

                if (i == dia.GetLength(0) - 1)
                {
                    i = 0;
                }


                lldP.Add(ldP);

                /////////////// Rutas para cada dia //////////////////
                //En el primer objeto de la lista de detallesplanilla
                if ((lldP.Count + daysToToday) % 2 == 0)
                {
                    ldP.ElementAt(0).Ruta = lrGrupo.ElementAt(0).Ruta;
                }
                else
                {
                    try
                    {
                        ldP.ElementAt(0).Ruta = lrGrupo.ElementAt(1).Ruta;
                    }
                    catch (ArgumentOutOfRangeException e)
                    {
                        ldP.ElementAt(0).Ruta = lrGrupo.ElementAt(0).Ruta;
                    }
                }
                /////////////////////////////////////////////////////
            }

            ///Guardar Detalles de Planilla (Rotaciones del mes)
            ///
            using (ctx = new tvEntities()){
                foreach (List <detallesplanillaDTO> lDp in lldP)
                {
                    ////Creo una nueva Planilla control
                    pC       = new planillacontrol();
                    pC.Fecha = new DateTime(DateTime.Now.Year, mes, d);
                    pC.Grupo = grupo;
                    ctx.planillacontrol.Add(pC);
                    ctx.SaveChanges();
                    d++;

                    string ru   = lDp.ElementAt(0).Ruta;
                    rutas  ruta = ctx.rutas.Where(t => t.NomRuta == ru).FirstOrDefault();
                    int    frec = ruta.Frecuencia.Value;
                    time = ctx.horario.Where(t => t.id == ruta.idHorario).FirstOrDefault().hora.Value;

                    foreach (detallesplanillaDTO DpDTO in lDp)
                    {
                        DpDTO.idPlanillaControl = pC.id;
                        DpDTO.Ruta       = lDp.ElementAt(0).Ruta;
                        DpDTO.HoraSalida = time;
                        detallesplanilla dP = new detallesplanilla();
                        Mapper.Map(DpDTO, dP);
                        ctx.detallesplanilla.Add(dP);
                        ctx.SaveChanges();
                        DpDTO.id = dP.id;

                        time = time + new TimeSpan(0, frec, 0);
                    }
                }
            }
            ////////////////////////////////


            return(lldP);
        }
示例#7
0
 public objRes Insert(rutasDto Reg)
 {
     using (ctx = new tvEntities())
     {
         objRes Respuesta = new objRes();
         try
         {
             rutas RutaOld = ctx.rutas.Where(t => t.NomRuta == Reg.NomRuta).FirstOrDefault();
             if (RutaOld == null)
             {
                 rutas ruta = new rutas();
                 Mapper.Map(Reg, ruta);
                 ctx.rutas.Add(ruta);
                 ctx.SaveChanges();
                 Respuesta.Error = false;
                 Respuesta.Mensaje = "Operacion realizada satisfactoriamente!!!";
                 return Respuesta;
             }
             else
             {
                 Respuesta.Error = true;
                 Respuesta.Mensaje = "Ya se encuentra registrado un bus con esta placa...";
                 return Respuesta;
             }
         }
         catch (Exception e)
         {
             Respuesta.Error = true;
             Respuesta.Mensaje = e.Message;
             return Respuesta;
         }
     }
 }
示例#8
0
        private void createListaHor(ref List<horarioDTO> lHor, rutas ruta, horario hor)
        {
            horarioDTO horDTO = new horarioDTO();
              System.TimeSpan time = hor.hora.Value;

               for (int i = 1; i <= ruta.Capacidad; i++)
               {
               horDTO.hora = time;
               horDTO.time = time.ToString();
               lHor.Add(horDTO);
               horDTO = new horarioDTO();
               time = time + new TimeSpan(0, ruta.Frecuencia.Value, 0);
               }
        }
示例#9
0
        public List <List <horarioDTO> > getHorarioPlanilla(string nomRuta, DateTime fecha, int grupo)
        {
            List <List <horarioDTO> > llHorDTO = new List <List <horarioDTO> >();
            List <horarioDTO>         lHorDTO  = new List <horarioDTO>();
            horarioDTO horDTO = new horarioDTO();
            TimeSpan   extra;
            int        cap = 0;

            using (ctx = new tvEntities()) {
                rutas           ruta = ctx.rutas.Where(t => t.NomRuta == nomRuta).FirstOrDefault();
                horario         Hor  = ctx.horario.Where(t => t.id == ruta.idHorario).FirstOrDefault();
                planillacontrol pC   = ctx.planillacontrol.Where(t => t.Fecha == fecha && t.Grupo == grupo).FirstOrDefault();
                cap = ctx.detallesplanilla.Where(t => t.Ruta == nomRuta && t.idPlanillaControl == pC.id).Count();

                if (ruta != null || Hor != null || pC != null || cap != 0)
                {
                    ruta.Capacidad = cap;/// capacidad del Bus

                    for (int i = 1; i <= ruta.NumeroRecorridos; i++)
                    {
                        createListaHor(ref lHorDTO, ruta, Hor);

                        if (nomRuta.ToUpper() != "RUTA 10B")
                        {
                            if (i % 2 == 0 && i != 1)
                            {
                                extra = new TimeSpan(0, 8, 0);
                            }
                            else
                            {
                                extra = new TimeSpan(0, 0, 0);
                            }
                        }
                        else
                        {
                            if (nomRuta.ToUpper() == "RUTA 8" || nomRuta.ToUpper() == "RUTA 12" || nomRuta.ToUpper() == "RUTA 10A")
                            {
                                if (i % 2 == 0 && i != 1)
                                {
                                    extra = new TimeSpan(0, 0, 0);
                                }
                                else
                                {
                                    extra = new TimeSpan(0, 8, 0);
                                }
                            }
                            else
                            {
                                extra = new TimeSpan(0, 0, 0);
                            }
                        }

                        Hor.hora = lHorDTO.ElementAt(0).hora + new TimeSpan(0, ruta.TiempoRecorrido.Value, 0) + extra;
                        llHorDTO.Add(lHorDTO);
                        lHorDTO = new List <horarioDTO>();
                    }

                    return(llHorDTO);
                }
                else
                {
                    return(null);
                }
            }
        }