Ejemplo n.º 1
0
 public void UndeleteRoutes(GrupoRuta grupo)
 {
     using (SmartTransaction transaction = SmartTransaction.BeginTransaction())
     {
         try
         {
             UndeleteRoutesWithoutTransaction(grupo);
             try
             {
                 transaction.Commit();
             }
             catch (Exception ex)
             {
                 STrace.Exception(typeof(RutaDAO).FullName, ex, "Exception in UndeleteRoutes(GrupoRuta) -> transaction.Commit();");
                 throw ex;
             }
         }
         catch (Exception ex)
         {
             STrace.Exception(typeof(RutaDAO).FullName, ex, "Exception in UndeleteRoutes(GrupoRuta)");
             try
             {
                 transaction.Rollback();
             }
             catch (Exception ex2)
             {
                 STrace.Exception(typeof(RutaDAO).FullName, ex2, "Exception in UndeleteRoutes(GrupoRuta) -> transaction.Rollback();");
             }
             throw ex;
         }
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Inserts all necesary data associated to the specified distributor into the export sqlite database.
        /// </summary>
        /// <param name="distributor"></param>
        public void InsertForDistributor(GrupoRuta distributor)
        {
            CreateTable();

            var data = GetInsertData(distributor);

            Insert(data);
        }
Ejemplo n.º 3
0
 /// <summary>
 ///     Gets the routes associated to the specified distributor.
 /// </summary>
 /// <param name="distributor"></param>
 /// <returns></returns>
 public IEnumerable <Ruta> GetRoutes(GrupoRuta distributor)
 {
     return
         (Session.Query <Ruta>()
          .Where(
              route =>
              route.CodigoDistribuidor == distributor.Distribuidor.Codigo && route.NumeroRuta == distributor.NumeroRuta && route.Estado <= 2 &&
              route.Dispositivo == null && !route.FechaBaja.HasValue)
          .ToList());
 }
Ejemplo n.º 4
0
        protected void UndeleteRoutesWithoutTransaction(GrupoRuta grupo)
        {
            List <Ruta> routes =
                Query.Where(
                    route =>
                    route.CodigoDistribuidor == grupo.Distribuidor.Codigo && route.NumeroRuta == grupo.NumeroRuta && route.Estado <= 2 &&
                    route.Dispositivo == null && route.FechaBaja.HasValue).ToList();

            foreach (Ruta route in routes)
            {
                route.FechaBaja = null;

                SaveOrUpdate(route);
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        ///     Unassings all open routes associated to the givenn distributor.
        /// </summary>
        /// <param name="grupo"></param>
        protected void UnassignRoutesWithoutTransaction(GrupoRuta grupo)
        {
            List <Ruta> routes =
                Session.Query <Ruta>()
                .Where(
                    route =>
                    route.CodigoDistribuidor == grupo.Distribuidor.Codigo && route.NumeroRuta == grupo.NumeroRuta && route.Estado <= 2 &&
                    route.Dispositivo != null && !route.FechaBaja.HasValue)
                .ToList();

            foreach (Ruta route in routes)
            {
                route.Dispositivo  = null;
                route.Distribuidor = null;
                route.Estado       = 0;

                SaveOrUpdate(route);
            }
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Inserts into sql export database the givenn distributor.
 /// </summary>
 /// <param name="distributor"></param>
 protected override IEnumerable <Distribuidor> GetInsertData(GrupoRuta distributor)
 {
     return(new List <Distribuidor> {
         distributor.Distribuidor
     });
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Gets the list of objects to be insertes into the export sqlite database.
 /// </summary>
 /// <param name="distributor"></param>
 /// <returns></returns>
 protected abstract IEnumerable <T> GetInsertData(GrupoRuta distributor);
Ejemplo n.º 8
0
 /// <summary>
 /// Gets the routes that should be inserted for the specified distributor.
 /// </summary>
 /// <param name="distributor"></param>
 /// <returns></returns>
 protected override IEnumerable <Ruta> GetInsertData(GrupoRuta distributor)
 {
     return(DaoFactory.RutaDAO.GetRoutes(distributor));
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Inserts the reason codes specified for the current distributor route.
 /// </summary>
 /// <param name="distributor"></param>
 protected override IEnumerable <Motivo> GetInsertData(GrupoRuta distributor)
 {
     return(GetReasons(distributor.Distribuidor));
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Gets the service type associated to the specified distributor that must be inserted into the sqlite export database.
 /// </summary>
 /// <param name="distributor"></param>
 /// <returns></returns>
 protected override IEnumerable <TipoServicio> GetInsertData(GrupoRuta distributor)
 {
     return(DaoFactory.TipoServicioDAO.GetServiceTypes(distributor.Distribuidor));
 }