Пример #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;
         }
     }
 }
Пример #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);
        }
Пример #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());
 }
Пример #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);
            }
        }
Пример #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);
            }
        }
Пример #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
     });
 }
Пример #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);
Пример #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));
 }
Пример #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));
 }
Пример #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));
 }