示例#1
0
 public ComponentDto Fetch(string pdNumber)
 {
     using (var ctx = DbContextManager <Reco3Xml2DbContext> .GetManager(_dbName)) {
         var result = (from r in ctx.DbContext.Components
                       where r.PDNumber == pdNumber
                       select new ComponentDto {
             ComponentId = r.ComponentId,
             PDNumber = r.PDNumber,
             DownloadedTimestamp = r.DownloadedTimestamp,
             Description = r.Description,
             PDStatus = r.PD_Status,
             ComponentType = r.Component_Type,
             Xml = r.XML,
             PDSource = r.PD_Source,
             SourceComponentId = r.SourceComponentId
         }).FirstOrDefault();
         return(result);
     }
 }
示例#2
0
 public List <ComponentDto> FetchAllWSamePDNumber(string pdNumber)
 {
     using (var ctx = DbContextManager <Reco3Xml2DbContext> .GetManager(_dbName)) {
         var result = from r in ctx.DbContext.Components
                      where r.PDNumber.Contains(pdNumber)
                      select new ComponentDto {
             ComponentId         = r.ComponentId,
             PDNumber            = r.PDNumber,
             DownloadedTimestamp = r.DownloadedTimestamp,
             Description         = r.Description,
             PDStatus            = r.PD_Status,
             ComponentType       = r.Component_Type,
             Xml               = r.XML,
             PDSource          = r.PD_Source,
             SourceComponentId = r.SourceComponentId
         };
         return(result.ToList());
     }
 }
示例#3
0
        protected void DataPortal_Fetch(int id)
        {
            using (BypassPropertyChecks)
            {
                using (var contexto = DbContextManager <Colegio> .GetManager())
                {
                    var registro = contexto.DbContext.Alumnos.Find(id);
                    if (registro == null)
                    {
                        throw new InvalidOperationException("El registro no existe");
                    }

                    Id        = registro.Id;
                    Nombres   = registro.Nombres;
                    Apellidos = registro.Apellidos;
                    Edad      = registro.Edad;
                }
            }
        }
示例#4
0
 public List <RoadmapGroupDto> Fetch()
 {
     using (var ctx = DbContextManager <Reco4Context> .GetManager(_dbName)) {
         var result = from r in ctx.DbContext.RoadmapGroups
                      select new RoadmapGroupDto {
             RoadmapGroupId                   = r.RoadmapGroupId,
             OwnerSss                         = r.OwnerSss,
             RoadmapName                      = r.RoadmapName,
             Protected                        = r.Protected,
             CreationTime                     = r.CreationTime,
             StartYear                        = r.StartYear,
             EndYear                          = r.EndYear,
             Xml                              = r.Xml,
             ValidationStatusValue            = r.Validation_Status,
             ConvertToVehicleInputStatusValue = r.ConvertToVehicleInput_Status
         };
         return(result.ToList());
     }
 }
示例#5
0
        public void ConnectionSetting_with_Invalid_DB_Throws_ConfigurationErrorsException_for_DbContextDataContext()
        {
            var conn = ConfigurationManager.ConnectionStrings[EntityConnectionWithMissingDB].ConnectionString;

            using (var context = new DataPortalTestDatabaseEntities(conn))
            {
                using (
                    var dbContextManager = DbContextManager <DataPortalDbContext> .GetManager(context))
                {
                    Assert.IsNotNull(dbContextManager);

                    // Make sure the context is set in DbContext
                    Assert.AreSame(context, ((IObjectContextAdapter)dbContextManager.DbContext).ObjectContext);
                    //Throws EntityException
                    var table = (from p in context.Table2
                                 select p).ToList();
                }
            }
        }
示例#6
0
 public List <OrderDto> Fetch(int idCustomer)
 {
     using (var ctx = DbContextManager <ModelContainer> .GetManager())
     {
         var result = from o in ctx.DbContext.Orders
                      where o.Enable.Equals(true) && o.CustomerIdCustomer.Equals(idCustomer)
                      orderby o.OrderDate
                      select new OrderDto
         {
             IdCustomer   = o.CustomerIdCustomer,
             Id           = o.OrderId,
             OrderDate    = o.OrderDate,
             Status       = o.Status,
             ShippedDate  = o.ShippedDate,
             ReceivedDate = o.ReceivedDate
         };
         return(result.ToList());
     }
 }
示例#7
0
        /// <summary>
        /// select an item from persistent store for given key
        /// </summary>
        /// <param name="aId"></param>
        /// <returns></returns>
        public D_ARK_ENTITY SelectItem(K_ARK_ENTITY aKey)
        {
#if (NOTYET)
            using (var ctx = DbContextManager <RepositoryModel.ApocFormsEntities> .GetManager())
            {
                var lQuery = (from item in ctx.DbContext.ARK_ENTITY
                              select new D_ARK_ENTITY
                {
                    object_id = item.id,
                    event_dts = item.event_dts,
                    logger_nm = item.logger_nm,
                    thread_nm = item.thread_nm,
                    log_level_cd = item.log_level_cd,
                    apoc_user_nm = item.apoc_user_nm,
                    apoc_user_id = item.apoc_user_id,
                    apoc_form_nm = item.apoc_form_nm,
                    apoc_form_id = item.apoc_form_id,
                    location_txt = item.location_txt,
                    browser_nm = item.browser_nm,
                    request_url = item.request_url,
                    referrer_url = item.referrer_url,
                    message_txt = item.message_txt,
                    stack_trace = item.stack_trace,

                    active_yn = item.active_yn,
                    create_by_uid = item.create_by_uid,
                    create_on_dts = item.create_on_dts,
                    update_by_uid = item.update_by_uid,
                    update_on_dts = item.update_on_dts,
                    version_key = item.version_key
                });

                if (aKey.object_id.HasValue)
                {
                    lQuery = lQuery.Where(x => x.object_id == aKey.object_id.Value);
                }

                return(lQuery.FirstOrDefault());
            }
#else
            return(new D_ARK_ENTITY());
#endif
        }
示例#8
0
        public void Insert(ComponentDto data)
        {
            using (var ctx = DbContextManager <Reco3Xml2DbContext> .GetManager(_dbName)) {
                var item = new Reco3Component {
                    ComponentId         = data.ComponentId,
                    PDNumber            = data.PDNumber,
                    DownloadedTimestamp = data.DownloadedTimestamp,
                    Description         = data.Description,
                    PD_Status           = data.PDStatus,
                    Component_Type      = data.ComponentType,
                    XML               = data.Xml,
                    PD_Source         = data.PDSource,
                    SourceComponentId = data.SourceComponentId
                };

                ctx.DbContext.Components.Add(item);
                ctx.DbContext.SaveChanges();
                data.ComponentId = item.ComponentId;
            }
        }
示例#9
0
        protected override void DataPortal_Update()
        {
            using (var ctx = DbContextManager <Colegio> .GetManager())
            {
                var entidad = ctx.DbContext.Set <Alumno>().Find(Id);
                if (entidad == null)
                {
                    throw new InvalidOperationException("No se encuentra el registro");
                }

                entidad.Nombres   = Nombres;
                entidad.Apellidos = Apellidos;
                entidad.Edad      = Edad;

                ctx.DbContext.Set <Alumno>().Attach(entidad);
                ctx.DbContext.Entry(entidad).State = EntityState.Modified;

                ctx.DbContext.SaveChanges();
            }
        }
示例#10
0
 private void DataPortal_Fetch(string criteria)
 {
     // TODO: load values
     using (var ctx = DbContextManager <SeguridadEntities> .GetManager(BaseDatos.ConexionBD))
     {
         var q = ctx.DbContext.SelectEmpresa(criteria).FirstOrDefault();
         if (q != null)
         {
             Id          = q.IdEmpresa;
             Codigo      = q.CodigoEmpresa;
             RazonSocial = q.RazonSocial;
             NombreCorto = q.NombreCorto;
             RUC         = q.RUC;
         }
         else
         {
             throw new InvalidOperationException("No se encontró el registro");
         }
     }
 }
示例#11
0
 private void DataPortal_Fetch(string criteria)
 {
     using (var ctx = DbContextManager <SeguridadEntities> .GetManager(BaseDatos.ConexionBD))
     {
         var app = ctx.DbContext.SelectAplicacion(criteria).FirstOrDefault();
         if (app != null)
         {
             ID       = app.IdAplicacion;
             Nombre   = app.NombreAplicacion;
             Acronimo = app.Acronimo;
             URI      = app.Uri;
             Tipo     = app.Tipo;
             ApplicationContext.LocalContext["AcronimoApp"] = Acronimo;
         }
         else
         {
             throw new InvalidOperationException("No se encontró el registro");
         }
     }
 }
示例#12
0
        public async Task <bool> ResetPasswordAsync(string userName, string newPassword)
        {
            using (var dbContextManager = DbContextManager <LicenseManagerDbContext> .GetManager())
            {
                var userManager = new UserManager <User>(new UserStore <User>(dbContextManager.Context));

                var user = await userManager.FindByNameAsync(userName);

                if (user == null)
                {
                    return(false);
                }

                await userManager.RemovePasswordAsync(user.Id);

                await userManager.AddPasswordAsync(user.Id, newPassword);

                return(true);
            }
        }
示例#13
0
 public List <OrderDetailDto> Fetch(Guid orderId)
 {
     using (var ctx = DbContextManager <ModelContainer> .GetManager())
     {
         var result = from o in ctx.DbContext.OrderDetails
                      where o.OrderOrderId.Equals(orderId)
                      orderby o.LineNo
                      select new OrderDetailDto
         {
             OrderId  = o.OrderOrderId,
             Id       = o.OrderDetailId,
             LineNo   = o.LineNo,
             Item     = o.Item,
             Price    = o.Price,
             Qty      = o.Qty,
             Discount = o.Discount
         };
         return(result.ToList());
     }
 }
示例#14
0
        public void Insert(RoadmapGroupDto data)
        {
            using (var ctx = DbContextManager <Reco4Context> .GetManager(_dbName)) {
                var item = new RoadmapGroup {
                    OwnerSss                     = data.OwnerSss,
                    RoadmapName                  = data.RoadmapName,
                    Protected                    = data.Protected,
                    CreationTime                 = data.CreationTime,
                    StartYear                    = data.StartYear,
                    EndYear                      = data.EndYear,
                    Xml                          = data.Xml,
                    Validation_Status            = data.ValidationStatusValue,
                    ConvertToVehicleInput_Status = data.ConvertToVehicleInputStatusValue
                };

                ctx.DbContext.RoadmapGroups.Add(item);
                ctx.DbContext.SaveChanges();
                data.RoadmapGroupId = item.RoadmapGroupId;
            }
        }
示例#15
0
        /// <summary>
        /// insert an item into persistent store
        /// </summary>
        /// <param name="aDto"></param>
        public D_ARK_ENTITY InsertItem(D_ARK_ENTITY aDto)
        {
#if (NOTYET)
            using (var ctx = DbContextManager <RepositoryModel.ApocFormsEntities> .GetManager())
            {
                // create new persistent object
                var data = new ARK_ENTITY();

                data.event_dts    = aDto.event_dts;
                data.logger_nm    = aDto.logger_nm;
                data.thread_nm    = aDto.thread_nm;
                data.log_level_cd = aDto.log_level_cd;
                data.apoc_user_nm = aDto.apoc_user_nm;
                data.apoc_user_id = aDto.apoc_user_id;
                data.apoc_form_nm = aDto.apoc_form_nm;
                data.apoc_form_id = aDto.apoc_form_id;
                data.location_txt = aDto.location_txt;
                data.browser_nm   = aDto.browser_nm;
                data.request_url  = aDto.request_url;
                data.referrer_url = aDto.referrer_url;
                data.message_txt  = aDto.message_txt;
                data.stack_trace  = aDto.stack_trace;

                data.active_yn     = aDto.active_yn;
                data.create_by_uid = aDto.create_by_uid;
                data.create_on_dts = aDto.create_on_dts;
                data.update_by_uid = aDto.update_by_uid;
                data.update_on_dts = aDto.update_on_dts;

                // persist object and save changes
                ctx.DbContext.ARK_ENTITY.Add(data);
                ctx.DbContext.SaveChanges();

                aDto.object_id     = data.id;
                aDto.create_by_uid = aDto.update_by_uid = data.create_by_uid;
                aDto.create_on_dts = aDto.update_on_dts = data.create_on_dts;
                aDto.version_key   = data.version_key;
            }
#endif
            return(aDto);
        }
示例#16
0
        private void DataPortal_Fetch(FiltroCriteria criteria)
        {
            RaiseListChangedEvents = false;
            IsReadOnly             = false;

            using (var ctx = DbContextManager <SeguridadEntities>
                             .GetManager(BaseDatos.ConexionBD))
            {
                IEnumerable <Empresas> lista;

                switch (criteria.NombreCampo)
                {
                case "RazonSocial":
                    lista = ctx.DbContext.SelectEmpresaByRazonSocial(criteria.ValorBusqueda).ToList();
                    break;

                case "Codigo":
                    lista = ctx.DbContext.SelectEmpresaByCodigo(criteria.ValorBusqueda).ToList();
                    break;

                case "NombreCorto":
                    lista = ctx.DbContext.SelectEmpresaByNombreCorto(criteria.ValorBusqueda).ToList();
                    break;

                case "RUC":
                    lista = ctx.DbContext.SelectEmpresaByRUC(criteria.ValorBusqueda).ToList();
                    break;

                default:
                    lista = ctx.DbContext.SelectAllEmpresas().ToList();
                    break;
                }
                foreach (var item in lista)
                {
                    Add(EmpresaInfo.GetEmpresaInfo(item));
                }
            }

            IsReadOnly             = true;
            RaiseListChangedEvents = true;
        }
        private void DataPortal_Fetch(FiltroCriteria criteria)
        {
            RaiseListChangedEvents = false;
            IsReadOnly             = false;
            try
            {
                using (var ctx = DbContextManager <SeguridadEntities> .GetManager(BaseDatos.ConexionBD))
                {
                    IEnumerable <Aplicaciones> lista;
                    switch (criteria.NombreCampo)
                    {
                    case "Nombre":
                        lista = ctx.DbContext.SelectAplicacionByName(criteria.ValorBusqueda).ToList();
                        break;

                    case "Acronimo":
                        lista = ctx.DbContext.SelectAplicacionByTag(criteria.ValorBusqueda).ToList();
                        break;

                    case "Ruta":
                        lista = ctx.DbContext.SelectAplicacionByUri(criteria.ValorBusqueda).ToList();
                        break;

                    default:
                        lista = ctx.DbContext.SelectAllAplicacion().ToList();
                        break;
                    }
                    foreach (var item in lista)
                    {
                        Add(AplicacionInfo.GetAplicacionInfo(item));
                    }
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.Write(ex.ToString());
                throw;
            }
            IsReadOnly             = true;
            RaiseListChangedEvents = true;
        }
示例#18
0
        public void Insert(OrderDetailDto item)
        {
            using (var ctx = DbContextManager <ModelContainer> .GetManager())
            {
                var newItem = new OrderDetail
                {
                    OrderOrderId  = item.OrderId,
                    OrderDetailId = item.Id,
                    LineNo        = item.LineNo,
                    Item          = item.Item,
                    Price         = item.Price,
                    Qty           = item.Qty,
                    Discount      = item.Discount
                };

                ctx.DbContext.OrderDetails.Add(newItem);
                ctx.DbContext.SaveChanges();

                item.Id = newItem.OrderDetailId;
            }
        }
示例#19
0
 public List <CustomerDto> Fetch()
 {
     using (var ctx = DbContextManager <ModelContainer> .GetManager())
     {
         var result = from c in ctx.DbContext.Customers
                      where c.Enable.Equals(true)
                      orderby c.Name
                      select new CustomerDto
         {
             Address   = c.Address,
             Name      = c.Name,
             Id        = c.IdCustomer,
             Num1      = c.Num1,
             Num2      = c.Num2,
             Sum       = c.Sum,
             StartDate = c.StartDate,
             EndDate   = c.EndDate
         };
         return(result.ToList());
     }
 }
示例#20
0
        public void Insert(OrderDto item)
        {
            using (var ctx = DbContextManager <ModelContainer> .GetManager())
            {
                var newItem = new Order
                {
                    CustomerIdCustomer = item.IdCustomer,
                    OrderId            = item.Id,
                    OrderDate          = item.OrderDate,
                    Status             = item.Status,
                    ShippedDate        = item.ShippedDate,
                    ReceivedDate       = item.ReceivedDate,
                    Enable             = true
                };

                ctx.DbContext.Orders.Add(newItem);
                ctx.DbContext.SaveChanges();

                item.Id = newItem.OrderId;
            }
        }
示例#21
0
        public void Insert(CustomerDto item)
        {
            using (var ctx = DbContextManager <ModelContainer> .GetManager())
            {
                var newItem = new Customer
                {
                    Address   = item.Address,
                    Name      = item.Name,
                    Num1      = item.Num1,
                    Num2      = item.Num2,
                    Sum       = item.Sum,
                    StartDate = item.StartDate,
                    EndDate   = item.EndDate,
                    Enable    = true
                };

                ctx.DbContext.Customers.Add(newItem);
                ctx.DbContext.SaveChanges();

                item.Id = newItem.IdCustomer;
            }
        }
示例#22
0
 protected override void DataPortal_Update()
 {
     try
     {
         using (var ctx = DbContextManager <SeguridadEntities> .GetManager(BaseDatos.ConexionBD))
         {
             if (IsSelfDirty)
             {
                 var app = ctx.DbContext.SelectAplicacion(ID).FirstOrDefault();
                 DoInsertUpdate(app);
             }
             ApplicationContext.LocalContext["IDPadre"] = ID;
             FieldManager.UpdateChildren(this);
             ctx.DbContext.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         System.Diagnostics.Trace.Write(ex.ToString());
         throw ex;
     }
 }
示例#23
0
 private void DataPortal_Fetch(string criteria)
 {
     using (var ctx = DbContextManager <SeguridadEntities> .GetManager(BaseDatos.ConexionBD))
     {
         var recurso = ctx.DbContext.SelectRecurso(criteria).FirstOrDefault();
         if (recurso != null)
         {
             using (BypassPropertyChecks)
             {
                 ID          = recurso.IdRecurso;
                 Descripcion = recurso.Descripcion;
                 RutaRecurso = recurso.RutaRecurso;
                 Nivel       = recurso.Nivel;
                 ApplicationContext.LocalContext["IdPadre"] = ID;
             }
         }
         else
         {
             throw new InvalidOperationException("No se encontró el registro!");
         }
     }
 }
        private void DataPortal_Fetch(FiltroCriteria criteria)
        {
            RaiseListChangedEvents = false;
            IsReadOnly             = false;

            using (var ctx = DbContextManager <SeguridadEntities>
                             .GetManager(BaseDatos.ConexionBD))
            {
                IEnumerable <Recurso> query;

                bool condicion = (string.IsNullOrEmpty(criteria.ValorBusqueda) && !string.IsNullOrEmpty(criteria.NombreCampo));

                if (condicion)
                {
                    query = ctx.DbContext.SelectAllRecurso();
                }
                else
                {
                    //En caso de que no hay ningun campo devolvemos todos los Niveles
                    if (string.IsNullOrEmpty(criteria.NombreCampo))
                    {
                        query = ctx.DbContext.SelectRecursoForApp().ToList();
                    }
                    else
                    {
                        query = ctx.DbContext.SelectRecursoByDescripcion(criteria.ValorBusqueda).ToList();
                    }
                }

                foreach (var item in query)
                {
                    Add(RecursosInfo.GetRecursosInfo(item));
                }
            }

            IsReadOnly             = true;
            RaiseListChangedEvents = true;
        }
        private void DataPortal_Fetch(FiltroCriteria criteria)
        {
            RaiseListChangedEvents = false;
            IsReadOnly             = false;

            using (var ctx = DbContextManager <SeguridadEntities>
                             .GetManager(BaseDatos.ConexionBD))
            {
                var lista = new List <PerfilUsuarioComplex>();
                switch (criteria.NombreCampo)
                {
                case "Aplicacion":
                    lista = ctx.DbContext.SelectPerfilUsuarioByApp(criteria.ValorBusqueda).ToList();
                    break;

                case "CodigoUsuario":
                    lista = ctx.DbContext.SelectPerfilUsuarioByUser(criteria.ValorBusqueda).ToList();
                    break;

                case "IdPerfilUsuario":
                    lista = ctx.DbContext.SelectPerfilUsuarioById(criteria.ValorBusqueda).ToList();
                    break;

                default:
                    lista = ctx.DbContext.SelectAllPerfilUsuario().ToList();
                    break;
                }

                foreach (var item in lista)
                {
                    Add(PerfilUsuarioInfo.GetPerfilUsuarioInfo(item));
                }
            }

            IsReadOnly             = true;
            RaiseListChangedEvents = true;
        }
示例#26
0
 protected override void DataPortal_Update()
 {
     try
     {
         using (var ctx = DbContextManager <SeguridadEntities> .GetManager(BaseDatos.ConexionBD))
         {
             if (IsSelfDirty)
             {
                 var entidad = ctx.DbContext.SelectPerfilUsuario(ID).FirstOrDefault();
                 DoInsertUpdate(entidad);
             }
             RolesPerfiles.Save();
             if (Recursos != null)
             {
                 Recursos.Save();
             }
             ctx.DbContext.SaveChanges();
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
示例#27
0
        public void CreateUserWithRoles(string userName, string password, List <string> userRoles)
        {
            if (!userRoles.Any())
            {
                throw new Exception("No roles were given to the user.", new Exception("To create a User you will have to give atleast 1 role to him."));
            }

            userRoles.ToList().ForEach(role =>
            {
                if (RoleExists(role) == false)
                {
                    throw new Exception("Only created roles can be assigned to Users.", new Exception("The role \"" + role + "\" doesn't exist."));
                }
            });
            using (var dbContextManager = DbContextManager <LicenseManagerDbContext> .GetManager())
            {
                var userManager = new UserManager <User>(new UserStore <User>(dbContextManager.Context));
                var user        = new User {
                    UserName = userName
                };
                userManager.Create(user, password);
                userRoles.ToList().ForEach(x => userManager.AddToRole(user.Id, x));
            }
        }
 public void Delete(Guid id)
 {
     using (var ctx = DbContextManager <EfDbContext> .GetManager())
         ctx.DbContext.DeleteByPK(ctx.DbContext.AppUsers, id);
 }
 protected override void DataPortal_Execute()
 {
     using (var ctx = DbContextManager <SeguridadEntities> .GetManager(BaseDatos.ConexionBD))
         Result = ctx.DbContext.SelectRecursoDetalleByIdRecurso(IdRecurso).ToList();
 }
示例#30
0
 public DalManager()
 {
     ConnectionManager = DbContextManager <ModelContainer> .GetManager();
 }