Exemplo n.º 1
0
 public Personaje(Cuenta cuenta)
 {
     inventario      = new InventarioGeneral(cuenta);
     caracteristicas = new CaracteristicasInformacion();
     hechizos        = new List <Hechizo>();
     oficios         = new List <Oficio>();
 }
Exemplo n.º 2
0
        public PersonajeJuego(Cuenta _cuenta)
        {
            cuenta             = _cuenta;
            timer_regeneracion = new Timer(regeneracion_TimerCallback, null, Timeout.Infinite, Timeout.Infinite);
            timer_afk          = new Timer(anti_Afk, null, Timeout.Infinite, Timeout.Infinite);//1200000

            inventario      = new InventarioGeneral(cuenta);
            caracteristicas = new Caracteristicas();
            hechizos        = new Dictionary <short, Hechizo>();
            oficios         = new List <Oficio>();
        }
Exemplo n.º 3
0
        public PersonajeJuego(Cuenta _cuenta)
        {
            cuenta             = _cuenta;
            timer_regeneracion = new Timer(regeneracion_TimerCallback, null, Timeout.Infinite, Timeout.Infinite);
            timer_afk          = new Timer(anti_Afk, null, Timeout.Infinite, Timeout.Infinite);//1200000

            inventario      = new InventarioGeneral(cuenta);
            caracteristicas = new Caracteristicas();
            hechizos        = new Dictionary <short, Hechizo>();
            oficios         = new OficiosJuego();
            derechos        = new Derechos(0);
            restricciones   = new Restricciones(0);
            esta_conectado  = false;
            en_grupo        = false;
        }
        internal override async Task <ResultadosAcciones> proceso(Cuenta cuenta)
        {
            InventarioGeneral inventario = cuenta.juego.personaje.inventario;

            foreach (ObjetosInventario objeto in inventario.objetos)
            {
                if (!objeto.objeto_esta_equipado())
                {
                    cuenta.conexion.enviar_Paquete($"EMO+{objeto.id_inventario}|{objeto.cantidad}");
                    inventario.eliminar_Objeto(objeto, 0, false);
                    await Task.Delay(300);
                }
            }
            return(ResultadosAcciones.HECHO);
        }
        internal override async Task <ResultadosAcciones> proceso(Account cuenta)
        {
            InventarioGeneral inventario = cuenta.Game.Character.inventario;

            foreach (ObjetosInventario objeto in inventario.objetos)
            {
                if (!objeto.objeto_esta_equipado())
                {
                    cuenta.Connection.Send($"EMO+{objeto.id_inventario}|{objeto.cantidad}");
                    inventario.eliminar_Objeto(objeto, 0, false);
                    await Task.Delay(300);
                }
            }
            return(ResultadosAcciones.HECHO);
        }
Exemplo n.º 6
0
        // Token: 0x06000199 RID: 409 RVA: 0x00007424 File Offset: 0x00005824
        internal override async Task <ResultadosAcciones> proceso(Cuenta cuenta)
        {
            InventarioGeneral inventario = cuenta.juego.personaje.inventario;

            foreach (ObjetosInventario objeto in inventario.objetos)
            {
                bool flag = !objeto.objeto_esta_equipado();
                if (flag)
                {
                    cuenta.conexion.enviar_Paquete(string.Format("EMO+{0}|{1}", objeto.id_inventario, objeto.cantidad), false);
                    inventario.eliminar_Objeto(objeto, 0, false);
                    await Task.Delay(300);
                }
                objeto = null;
            }
            IEnumerator <ObjetosInventario> enumerator = null;

            return(ResultadosAcciones.HECHO);
        }
Exemplo n.º 7
0
        public Personaje(int _id, string _nombre_personaje, byte _nivel, byte _sexo, int _gfxID, Cuenta _cuenta)
        {
            id = _id;
            nombre_personaje = _nombre_personaje;
            nivel            = _nivel;
            sexo             = _sexo;
            gfxID            = _gfxID;
            cuenta           = _cuenta;
            mapa             = new Mapa(cuenta);
            manejador        = new Manejador(cuenta, mapa);
            inventario       = new InventarioGeneral(cuenta);
            caracteristicas  = new CaracteristicasInformacion();
            hechizos         = new List <Hechizo>();
            oficios          = new List <Oficio>();

            oficios.Add(new Oficio(1));
            oficios[0].skills.Add(new SkillsOficio(22, 1, 1, -1));
            oficios[0].skills.Add(new SkillsOficio(110, 1, 1, -1));
            oficios[0].skills.Add(new SkillsOficio(121, 1, 1, -1));
            oficios[0].skills.Add(new SkillsOficio(181, 1, 1, -1));
            oficios[0].skills.Add(new SkillsOficio(44, 1, 1, -1));
            oficios[0].skills.Add(new SkillsOficio(114, 1, 1, -1));
        }
Exemplo n.º 8
0
        public async Task <long> identifyDetail(OrdenReciboDetalleForIdentifyDto command)
        {
            InventarioGeneral dominio = null;

            //Agrupación...
            InvLod invLod = null;


            DateTime Fecha_out;

            var huelladetalle = await _context.HuellaDetalle.SingleOrDefaultAsync(x => x.HuellaId == command.HuellaId &&
                                                                                  x.UnidadMedidaId == command.UnidadMedidaId);

            var huelladetalle_aux = await _context.HuellaDetalle.Where(x => x.HuellaId == command.HuellaId).ToListAsync();

            int interacciones = 0;
            int cantidadTotal = 0;


            if (huelladetalle.Pallet) // pallet
            {
                cantidadTotal            = huelladetalle.UntQty * command.CantidadRecibida;
                interacciones            = cantidadTotal / huelladetalle.UntQty;
                command.CantidadRecibida = huelladetalle.UntQty;
            }
            else
            {
                cantidadTotal = huelladetalle.UntQty * command.CantidadRecibida;
                interacciones = 1;
            }
            var linea = await _context.OrdenesReciboDetalle.SingleOrDefaultAsync(x => x.Id == command.Id);

            var cab = await _context.OrdenesRecibo.SingleOrDefaultAsync(x => x.Id == linea.OrdenReciboId);

            var ubicacion = await _context.Ubicacion.Where(x => x.Id == cab.UbicacionId).SingleAsync();


            if (linea.CantidadRecibida == null)
            {
                linea.CantidadRecibida = 0;
            }

            using (var transaction = _context.Database.BeginTransaction())
            {
                try
                {
                    for (int i = 0; i < interacciones; i++)
                    {
                        invLod = new InvLod();
                        invLod.FechaHoraRegistro = DateTime.Now;
                        invLod.LodNum            = "";
                        //En el origen, Stage de entrada.
                        invLod.UbicacionId = cab.UbicacionId;
                        await _context.AddAsync <InvLod>(invLod);

                        await _context.SaveChangesAsync();

                        // Secuencia de LPN
                        invLod.LodNum = 'E' + (invLod.Id).ToString().PadLeft(8, '0');



                        dominio = new InventarioGeneral();
                        //Vinculo INVLOD
                        dominio.LodId          = invLod.Id;
                        dominio.FechaRegistro  = DateTime.Now;
                        dominio.HuellaId       = huelladetalle_aux.Where(x => x.Cas == true).SingleOrDefault().Id;        //command.HuellaId;
                        dominio.LotNum         = command.Lote;
                        dominio.ProductoId     = linea.ProductoId;
                        dominio.UsuarioIngreso = 1;
                        dominio.LineaId        = linea.Id;
                        dominio.OrdenReciboId  = linea.OrdenReciboId;
                        dominio.EstadoId       = command.EstadoID;
                        dominio.UntCas         = huelladetalle_aux.Where(x => x.Cas == true).SingleOrDefault().UntQty;
                        linea.EstadoID         = command.EstadoID;
                        dominio.ClienteId      = cab.PropietarioId;
                        linea.Lote             = command.Lote;

                        #region validar Fechas

                        if (command.FechaExpire == "" || command.FechaExpire == null)
                        {
                            dominio.FechaExpire = null;
                        }
                        else
                        if (!DateTime.TryParse(command.FechaExpire, out Fecha_out))
                        {
                            throw new ArgumentException("Fecha de Expiración incorrecta");
                        }
                        else
                        {
                            dominio.FechaExpire = Convert.ToDateTime(command.FechaExpire);
                        }


                        if (command.FechaManufactura == "" || command.FechaManufactura == null)
                        {
                            dominio.FechaManufactura = null;
                        }
                        else
                        if (!DateTime.TryParse(command.FechaExpire, out Fecha_out))
                        {
                            throw new ArgumentException("Fecha de Expiración incorrecta");
                        }
                        else
                        {
                            dominio.FechaManufactura = Convert.ToDateTime(command.FechaManufactura);
                        }

                        #endregion


                        linea.CantidadRecibida = linea.CantidadRecibida + command.CantidadRecibida;

                        if (linea.Cantidad < linea.CantidadRecibida)
                        {
                            throw new ArgumentException("err010");
                        }
                        else if (linea.Cantidad == linea.CantidadRecibida)
                        {
                            linea.Completo = true;
                        }
                        dominio.UntQty = command.CantidadRecibida;
                        await _context.AddAsync <InventarioGeneral>(dominio);
                    }
                    cab.EstadoId       = (Int16)Constantes.EstadoOrdenIngreso.Recibiendo;
                    ubicacion.EstadoId = 10;         // Libre
                    await _context.SaveChangesAsync();



                    transaction.Commit();
                }
                catch (Exception ex)
                {
                    transaction.Rollback();
                    throw ex;
                }
                finally
                {
                    transaction.Dispose();
                }
            }

            return(interacciones);
        }
        public async Task <InventarioGeneral> ActualizarInventario(InventarioForEdit command)
        {
            InventarioGeneral dominio        = null;
            AjusteInventario  dominio_ajuste = new AjusteInventario();
            InvLod            dominio_invlod = null;
            DateTime          Fecha_out;

            dominio        = _context.InventarioGeneral.SingleOrDefaultAsync(x => x.Id == command.Id).Result;
            dominio_invlod = _context.InvLod.SingleOrDefaultAsync(x => x.Id == dominio.LodId).Result;


            #region validar Fechas

            if (command.FechaExpire == "" || command.FechaExpire == null)
            {
                dominio.FechaExpire = null;
            }
            else
            if (!DateTime.TryParse(command.FechaExpire, out Fecha_out))
            {
                throw new ArgumentException("Fecha de Expiración incorrecta");
            }
            else
            {
                dominio.FechaExpire = Convert.ToDateTime(command.FechaExpire);
            }

            #endregion

            dominio_ajuste.Almacenado = dominio.Almacenado;
            dominio_ajuste.ClienteId  = dominio.ClienteId;
            dominio_ajuste.EstadoId   = command.EstadoId;
            if (command.FechaExpire != null)
            {
                dominio_ajuste.FechaExpire = Convert.ToDateTime(command.FechaExpire);
            }
            dominio_ajuste.FechaHoraAjuste = DateTime.Now;
            dominio_ajuste.FechaIngreso    = dominio.FechaRegistro;
            if (command.FechaManufactura != null)
            {
                dominio_ajuste.FechaManufactura = Convert.ToDateTime(command.FechaManufactura);
            }
            dominio_ajuste.HuellaId          = dominio.HuellaId;
            dominio_ajuste.InventarioId      = dominio.Id;
            dominio_ajuste.LineaId           = dominio.LineaId;
            dominio_ajuste.LodNum            = dominio_invlod.LodNum;
            dominio_ajuste.LotNum            = command.LotNum;
            dominio_ajuste.OrdenReciboId     = dominio.OrdenReciboId;
            dominio_ajuste.ProductoId        = dominio.ProductoId;
            dominio_ajuste.UbicacionId       = dominio_invlod.UbicacionId;
            dominio_ajuste.UntQty            = command.UntQty;
            dominio_ajuste.UsuarioRegistroId = command.UsuarioActualizar;



            dominio.LotNum = command.LotNum;
            dominio.UntQty = command.UntQty;
            if (command.FechaExpire != null)
            {
                dominio.FechaExpire = Convert.ToDateTime(command.FechaExpire);
            }
            if (command.FechaManufactura != null)
            {
                dominio.FechaManufactura = Convert.ToDateTime(command.FechaManufactura);
            }
            dominio.EstadoId = command.EstadoId;


            using (var transaction = _context.Database.BeginTransaction())
            {
                try
                {
                    await _context.AddAsync <AjusteInventario>(dominio_ajuste);

                    await _context.SaveChangesAsync();

                    transaction.Commit();
                }
                catch (Exception ex)
                {
                    transaction.Rollback();
                    throw ex;
                }
                return(dominio);
            }
        }
        public async Task <InventarioGeneral> RegistrarInventario(InventarioForRegister command)
        {
            InventarioGeneral dominio = null;
            DateTime          Fecha_out;


            if (command.Id.HasValue)
            {
                dominio = _context.InventarioGeneral.SingleOrDefaultAsync(x => x.Id == command.Id).Result;
            }
            else
            {
                dominio = new InventarioGeneral();
            }


            #region validar Fechas

            if (command.FechaExpire == "" || command.FechaExpire == null)
            {
                dominio.FechaExpire = null;
            }
            else
            if (!DateTime.TryParse(command.FechaExpire, out Fecha_out))
            {
                throw new ArgumentException("Fecha de Expiración incorrecta");
            }
            else
            {
                dominio.FechaExpire = Convert.ToDateTime(command.FechaExpire);
            }

            #endregion



            dominio.FechaRegistro = DateTime.Now;
            dominio.HuellaId      = command.HuellaId;
            dominio.LotNum        = command.LotNum;
            dominio.ProductoId    = command.ProductoId;
            // dominio.UbicacionId = command.UbicacionId;
            // dominio.UbicacionIdUlt = command.UbicacionIdUlt;
            dominio.UntCas         = command.UntCas;
            dominio.UntPak         = command.UntPak;
            dominio.UntQty         = command.UntQty;
            dominio.UsuarioIngreso = command.UsuarioIngreso;
            dominio.ClienteId      = command.ClienteId;


            using (var transaction = _context.Database.BeginTransaction())
            {
                try
                {
                    //var max = await _context.InventarioGeneral.MaxAsync(x=>x.LodNum);
                    // if(max==null) max = "E00000001";
                    // max  = 'E' + (Convert.ToInt64(max.Substring(1,8)) + 1).ToString().PadLeft(8,'0');
                    // dominio.LodNum = max;

                    await _context.AddAsync <InventarioGeneral>(dominio);

                    await _context.SaveChangesAsync();

                    transaction.Commit();
                }
                catch (Exception ex)
                {
                    transaction.Rollback();
                    throw ex;
                }
                return(dominio);
            }
        }
        public async Task <long> MergeInventario(MergeInventarioRegister mergeInventarioRegister)
        {
            string[]          prm     = mergeInventarioRegister.ids.Split(',');
            InventarioGeneral dominio = new InventarioGeneral();
            InvLod            invLod  = null;
            int total = 0;
            List <AjusteInventario> ajustes = new List <AjusteInventario>();
            AjusteInventario        ajuste  = null;



            var aux = _context.InventarioGeneral.Where(x => x.Id == Convert.ToInt64(prm[1])).SingleOrDefault();
            var lod = _context.InvLod.Where(x => x.Id == aux.LodId).SingleOrDefault();


            //dominio.UntQty = total;

            using (var transaction = _context.Database.BeginTransaction())
            {
                try
                {
                    invLod = new InvLod();
                    invLod.FechaHoraRegistro = DateTime.Now;
                    invLod.LodNum            = "";
                    invLod.UbicacionId       = lod.UbicacionId;

                    await _context.AddAsync <InvLod>(invLod);

                    await _context.SaveChangesAsync();

                    // Secuencia de LPN
                    invLod.LodNum = 'E' + (invLod.Id).ToString().PadLeft(8, '0');

                    foreach (var item in prm)
                    {
                        var inventarios = _context.InventarioGeneral.Where(x => x.LodId == Convert.ToInt64(item)).ToList();
                        foreach (var item2 in inventarios)
                        {
                            //Vinculo INVLOD
                            item2.LodId = invLod.Id;
                            _context.SaveChanges();
                        }
                    }



                    // foreach (var item in prm)
                    // {

                    //      var inventarios = _context.InventarioGeneral.Where(x=>x.LodId == Convert.ToInt64(item)).ToList();
                    //      foreach (var objInventario in inventarios)
                    //      {
                    //             ajuste = new AjusteInventario();
                    //             ajuste.EstadoId = (int) Constantes.EstadoInventario.Eliminado;
                    //             ajuste.FechaExpire= objInventario.FechaExpire;
                    //             ajuste.FechaHoraAjuste = DateTime.Now;
                    //             ajuste.FechaIngreso = objInventario.FechaRegistro;
                    //             ajuste.FechaManufactura = objInventario.FechaManufactura;
                    //             ajuste.LotNum = invLod.LodNum ;
                    //             ajuste.UntQty = objInventario.UntQty;
                    //             ajuste.ProductoId = objInventario.ProductoId;
                    //             ajuste.InventarioId = objInventario.Id;
                    //             ajuste.ClienteId = objInventario.ClienteId;
                    //             ajuste.LineaId = objInventario.LineaId;
                    //             ajuste.OrdenReciboId = objInventario.OrdenReciboId;
                    //             ajuste.Almacenado = objInventario.Almacenado;
                    //             ajuste.HuellaId = objInventario.HuellaId;
                    //             ajuste.UsuarioRegistroId = 1;
                    //             ajustes.Add(ajuste);


                    //      }



                    // }
                    //agregar a ajustes
                    await _context.AddRangeAsync(ajustes);

                    await _context.SaveChangesAsync();


                    transaction.Commit();
                }
                catch (Exception ex)
                {
                    transaction.Rollback();
                    throw ex;
                }
                return(dominio.Id);
            }
        }
        public async Task <long> AssignarUbicacion(InventarioForAssingment command)
        {
            string            query             = "";
            InventarioGeneral dominio           = null;
            Ubicacion         dominio_ubicacion = null;

            //Ubicacion dominio_ubicacionanterior = null;

            dominio_ubicacion = await _context.Ubicacion.SingleOrDefaultAsync(x => x.Id == command.UbicacionId);



            if (command.Id.Split(',').Length > 0)
            {
                using (var transaction = _context.Database.BeginTransaction())
                {
                    //Ver nivel de ocupabilidad;
                    query = string.Format("update inventario.invlod"
                                          + " set UbicacionProxId = '{0}' "
                                          + " where id in ({1}) Select * from inventario.invlod where id in ({1}) ",
                                          command.UbicacionId.ToString(), command.Id);

                    try
                    {
                        var resp = _context.InvLod
                                   .FromSql(query)
                                   .ToList();

                        dominio_ubicacion.EstadoId = 17; //Parcial
                        await _context.SaveChangesAsync();

                        transaction.Commit();
                    }
                    catch (Exception ex)
                    {
                        transaction.Rollback();
                        throw ex;
                    }
                    return(command.UbicacionId);
                }
            }
            else
            {
                dominio = await _context.InventarioGeneral.SingleOrDefaultAsync(x => x.Id == Convert.ToInt64(command.Id));

                // if(dominio.UbicacionIdProx != null)
                // {
                //     dominio_ubicacionanterior =  await _context.Ubicacion.SingleOrDefaultAsync(x=>x.Id == dominio.UbicacionIdProx);
                //     dominio_ubicacionanterior.EstadoId = 10;// Liberarlo
                // }
                using (var transaction = _context.Database.BeginTransaction())
                {
                    dominio_ubicacion.EstadoId = 11;     //Separarlo
                    // dominio.UbicacionIdProx = command.UbicacionId;
                    try
                    {
                        await _context.SaveChangesAsync();

                        transaction.Commit();
                    }
                    catch (Exception ex)
                    {
                        transaction.Rollback();
                        throw ex;
                    }
                    return(dominio.Id);
                }
            }
        }
        public CommandResult Handle(InsertarActualizarInventarioCommand command)
        {
            if (command == null)
            {
                throw new ArgumentException("Producto no cargado");
            }
            InventarioGeneral dominio = null;


            var producto = _ProductoRepository.Get(x => x.idproducto == command.idproducto).FirstOrDefault();

            if (command.idinventario.HasValue)
            {
                dominio = _InventarioRepository.Get(x => x.idinventario.Equals(command.idinventario.Value)).SingleOrDefault();
            }
            else
            {
                if (producto.idrequisitoascanear == 137) //solo serie
                {
                    dominio = _InventarioRepository.Get(x =>
                                                        x.idproducto == command.idproducto &&
                                                        x.idalmacen == command.idalmacen &&
                                                        x.serie == command.serie).LastOrDefault();
                }
                else if (producto.idrequisitoascanear == 138)//Serie/Imei
                {
                    dominio = _InventarioRepository.Get(x =>
                                                        x.idproducto == command.idproducto &&
                                                        x.idalmacen == command.idalmacen &&
                                                        x.serie == command.serie &&
                                                        x.imei == command.imei).LastOrDefault();
                }
                else if (producto.idrequisitoascanear == 139)// serie/imei/mac
                {
                    dominio = _InventarioRepository.Get(x =>
                                                        x.idproducto == command.idproducto &&
                                                        x.idalmacen == command.idalmacen &&
                                                        x.serie == command.serie &&
                                                        x.imei == command.imei &&
                                                        x.mac == command.mac).LastOrDefault();
                }
                else if (producto.idrequisitoascanear == 140)// mac
                {
                    dominio = _InventarioRepository.Get(x =>
                                                        x.idproducto == command.idproducto &&
                                                        x.idalmacen == command.idalmacen &&
                                                        x.mac == command.mac).LastOrDefault();
                }
                else if (producto.idrequisitoascanear == 163)// IMEI
                {
                    dominio = _InventarioRepository.Get(x =>
                                                        x.idproducto == command.idproducto &&
                                                        x.idalmacen == command.idalmacen &&
                                                        x.imei == command.imei).LastOrDefault();
                }

                else
                {
                    dominio = _InventarioRepository.Get(x => x.idproducto == command.idproducto &&
                                                        x.idalmacen == command.idalmacen).LastOrDefault();
                }
            }

            if (dominio == null)
            {
                switch (command.__idoperacion)
                {
                case 1:     // Nuevo
                    dominio = new InventarioGeneral
                    {
                        cantidad             = command.cantidad,
                        fechahoraregistro    = command.fechahoraregistro,
                        idalmacen            = command.idalmacen,
                        iddocumentorecepcion = command.iddocumentorecepcion,
                        idestado             = command.idestado,
                        idproducto           = command.idproducto,
                        serie             = command.serie,
                        imei              = command.imei,
                        mac               = command.mac,
                        ubicacion         = command.ubicacion,
                        caja              = command.caja,
                        idpartner         = command.idpartner,
                        pallet            = command.pallet,
                        idusuarioregistro = command.idusuarioregistro
                    };
                    break;

                default:
                    break;
                }

                _InventarioRepository.Add(dominio);
            }
            else
            {
                switch (command.__idoperacion)
                {
                case 2:     // Actualizar
                    dominio.cantidad = command.cantidad;
                    dominio.idestado = command.idestado;
                    break;

                case 1:     // Incrementar
                    dominio.cantidad = dominio.cantidad + command.cantidad;
                    break;

                case 3:     //Operaciones de inventario
                    if (command.idalmacennuevo != null)
                    {
                        dominio.idalmacen = command.idalmacennuevo.Value;
                    }
                    if (command.idestadonuevo != null)
                    {
                        dominio.idestado = command.idestadonuevo.Value;
                    }
                    if (command.cantidadnueva != null)
                    {
                        dominio.cantidad = command.cantidadnueva.Value;
                    }
                    break;

                case 4:     //Cambio de estado
                    dominio.idestado = command.idestado;
                    break;

                default:
                    break;
                }
            }
            try
            {
                _InventarioRepository.SaveChanges();
                return(new InsertarActualizarInventarioOutput()
                {
                    idinventario = dominio.idinventario
                });
            }
            catch (Exception)
            {
                throw;
            }
        }