Пример #1
0
        /// <summary>
        /// NÃO IMPLEMENTADO - COLOCAR ELE COMO PUBLICO DEPOIS.
        /// </summary>
        /// <param name="o"></param>
        /// <param name="n"></param>
        public void GravaOrdem(Order o, NSAADMEntities n)
        {
            try
            {
                ML_Order Ordem;
                ConverterObjetoMLparaEF cf = new ConverterObjetoMLparaEF();

                Ordem = (from p in n.ML_Order where p.id == o.id select p).FirstOrDefault();
                if (Ordem == null)
                {
                    Ordem = cf.ConverteOrdem(o, n);
                    n.ML_Order.AddObject(Ordem);
                }
                else
                {
                    cf.AtualizaOrdem(Ordem, o, n);
                }

                n.SaveChanges();
            }
            catch (Exception ex)
            {
                throw new Exception("Erro na rotina GravaOrdem.", ex);
            }
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            try
            {

                int cont = 0;
                ConstruirEF cef = new ConstruirEF();
                NSAADMEntities n = (NSAADMEntities)cef.RecuperaEntity(Entities.MercadoLivre);
                ConverterObjetoMLparaEF cf = new ConverterObjetoMLparaEF();
                Usuario u = cm.RetornaUsuario();
                ConverterObjetoMLparaEF c = new ConverterObjetoMLparaEF();
                ListOrder o;
                ML_Order Ordem;

                ConverteVendas cv = new ConverteVendas();
                GerenciarVendas gv = new GerenciarVendas();
                NSAADM_HMLEntities ent = new NSAADM_HMLEntities();

                do
                {
                    o = cm.RetornarOrdens(u, cont);
                    cont = o.results.Count + cont;

                    foreach (Order or in o.results)
                    {
                        Ordem = (from p in n.ML_Order where p.id == or.id select p).FirstOrDefault();
                        if (Ordem == null)
                        {
                            Ordem = cf.ConverteOrdem(or, n);
                            n.ML_Order.AddObject(Ordem);

                            gv.IncluirVenda(cv.ConverteMLVendaEmVenda(Ordem, ent), ent);

                        }
                        else
                        {
                            cf.AtualizaOrdem(Ordem, or, n);

                            gv.IncluirVenda(cv.ConverteMLVendaEmVenda(Ordem, ent), ent);

                        }

                        n.SaveChanges();

                    }
                } while (o.results.Count == 50);

            }
            catch (Exception ex)
            {

                throw new Exception("Erro na rotina Button1_Click",ex);
            }
        }
Пример #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            NSAADMEntities n;

            ConstruirEF cf = new ConstruirEF();
            n = (NSAADMEntities)cf.RecuperaEntity(Entities.MercadoLivre);

            //*****************************************
            Request.InputStream.Position = 0;
            System.IO.StreamReader str = new System.IO.StreamReader(Request.InputStream);

            CallBackTemp c = new CallBackTemp();
            c = JsonConvert.DeserializeObject<CallBackTemp>(str.ReadToEnd());
            //*****************************************

            try
            {
                CallBackML teste = (from p in n.CallBackMLs where p.resource == c.resource select p).First();

            }
            catch (Exception)
            {

                CallBackML call = new CallBackML();
                call.received = c.received;
                call.resource = c.resource;
                call.sent = c.sent;
                call.topic = c.topic;
                call.userID = c.user_id;

                n.CallBackMLs.AddObject(call);

                n.SaveChanges();

                if (c.topic == "questions")
                {
                    ControlaMeli cm = new ControlaMeli();

                    ControlaPerguntas cp = new ControlaPerguntas();

                    cp.GravaPergunta(cm.RetonarQuestion(c.resource), cm.n);
                }
                if (c.topic == "orders")
                {
                    ControlaMeli cm = new ControlaMeli();
                    ControlaOrdens co = new ControlaOrdens();
                    ConverterObjetoMLparaEF conv = new ConverterObjetoMLparaEF();
                    co.GravaOrdem(cm.RetornaOrder(c.resource),cm.n);

                }
            }
        }
Пример #4
0
        protected void Button9_Click(object sender, EventArgs e)
        {
            try
            {
                ControlaMeli cm = new ControlaMeli();
                ControlaOrdens co = new ControlaOrdens();
                ConverterObjetoMLparaEF conv = new ConverterObjetoMLparaEF();
                co.GravaOrdem(cm.RetornaOrder("/orders/779622738"), cm.n);
            }
            catch (Exception ex)
            {

                throw new Exception("Erro no Button9_Click.", ex);
            }
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            ControlaMeli cm = new ControlaMeli();
            ConverterObjetoMLparaEF conv = new ConverterObjetoMLparaEF();

            var x = (from p in cm.n.CallBackMLs where p.topic == "questions" select p);

            foreach (CallBackML c in x.ToList())
            {
                if (c.topic == "questions")
                {

                    Question q = cm.RetonarQuestion(c.resource);

                    ControlaPerguntas p = new ControlaPerguntas();
                    p.GravaPergunta(q, cm.n);

                }
            }
        }