public void AtualizarEstoque(BotItemEstoque estoque)
        {
            BotWoWEntities n = new BotWoWEntities();
            Estoque est = new Estoque();

            try
            {
                est = (from p in n.Estoques where p.idItem == estoque.itemID && p.NomePersonagem == estoque.Personagem select p).First();

                est.Qtd = estoque.Qtd;
                est.dtAtualizado = DateTime.Now;

                n.SaveChanges();

            }
            catch (InvalidOperationException)
            {
                est.idItem = estoque.itemID;
                est.NomePersonagem = estoque.Personagem;
                est.Qtd = estoque.Qtd;
                est.dtAtualizado = DateTime.Now;
                est.dtFabricado = DateTime.Now;

                n.Estoques.AddObject(est);
                n.SaveChanges();
            }
            catch (Exception ex)
            {
                throw new Exception(String.Format("Erro na rotina BotControlaEstoque.AtualizarEstoque. {0} itemID: {1} {0}",Environment.NewLine, estoque.itemID), ex);
            }
        }
示例#2
0
        public void AtualizaEstoque(BotItemEstoque estoque, string key)
        {
            if (key != "3kl4j3lk5n3lk3j43kl4j34n3,m4n34k34hj3l4h34nm3,.n43")
            {
                throw new Exception("Chave inválida");
            }

            BotControlaEstoque contrEst = new BotControlaEstoque();

            contrEst.AtualizarEstoque(estoque);
        }
        public List<BotItemEstoque> RetornaGrupoGemas(string nome)
        {
            List<BotItemEstoque> l = new List<BotItemEstoque>();
            const int VALOR_EM_ESTOQUE = 18;
            const decimal VALOR_MINIMO_AH = 249999;
            BotWoWEntities n = new BotWoWEntities();
            BotWoWEntities n1 = new BotWoWEntities();

            var a = (from i in n.Items
                     join
                         isp in n.SpellItems on i.id equals isp.idItem
                     join
                         est in n.Estoques on isp.idItem equals est.idItem
                     where i.itemClass == 3 && est.Qtd < VALOR_EM_ESTOQUE && est.NomePersonagem == nome
                           && est.dtFabricado < est.dtAtualizado
                           && i.ValorMinnaAH > VALOR_MINIMO_AH
                     select new { idItem = i.id, idSpell = isp.idSpell, qtd = (VALOR_EM_ESTOQUE - est.Qtd) });

            foreach (var item in a)
            {
                BotItemEstoque b = new BotItemEstoque();
                b.itemID = (int)item.idItem;
                b.Personagem = nome;
                b.Qtd = (int)item.qtd;
                b.SpellQueCriaOItem = (int)item.idSpell;
                l.Add(b);

                var x = (from p in n1.Estoques where p.idItem == item.idItem && p.NomePersonagem == nome select p).First();
                x.dtFabricado = DateTime.Now;
                n1.SaveChanges();

            }

            return l;
        }
        public List<BotItemEstoque> RetornaItensEnchantInscr(string Real, string Faccao)
        {
            List<BotItemEstoque> l = new List<BotItemEstoque>();
            List<decimal> IDs = new List<decimal>();

            const int VALOR_EM_ESTOQUE = 18;

            IDs.Add(87559);
            IDs.Add(87560);
            IDs.Add(83007);
            IDs.Add(83006);

            BotWoWEntities n = new BotWoWEntities();
            BotWoWEntities n1 = new BotWoWEntities();

            var a = (from i in n.Items
                     join
                         isp in n.SpellItems on i.id equals isp.idItem
                     join
                         est in n.Estoques on isp.idItem equals est.idItem
                     where IDs.Any(x => x == i.id)
                           && est.Qtd < VALOR_EM_ESTOQUE
                           && est.dtFabricado < est.dtAtualizado
                     select new { idItem = i.id, idSpell = isp.idSpell, qtd = (VALOR_EM_ESTOQUE - est.Qtd), nome = est.NomePersonagem });

            foreach (var item in a)
            {
                BotItemEstoque b = new BotItemEstoque();
                b.itemID = (int)item.idItem;
                b.Personagem = item.nome;
                b.Qtd = (int)item.qtd;
                b.SpellQueCriaOItem = (int)item.idSpell;
                l.Add(b);

                var x = (from p in n1.Estoques where p.idItem == item.idItem && p.NomePersonagem == item.nome select p).First();
                x.dtFabricado = DateTime.Now;
                n1.SaveChanges();

            }

            return l;
        }