Пример #1
0
        // GET: Orden
        public ActionResult Index()
        {
            try
            {
                var currentUser = System.Web.HttpContext.Current.User as CustomPrincipal;
                if (currentUser == null)
                {
                    return(RedirectToAction("Index", "Account"));
                }

                var proxy = new ServiceProxyB2CClient();

                var lstOrden = proxy.ConsultarClientesOrdenes((int)currentUser.CustId);

                return(View(lstOrden));
            }
            catch (FaultException <ConsultarClientesOrdenesFault> exf)
            {
                throw new Exception("Error al traer las ordenes " + exf.Detail.ConsultarClientesOrdenesFault1.mensaje);
            }
            catch (CommunicationException cex)
            {
                throw new CommunicationException("Error de conmunicacion " + cex);
            }
        }
        // GET: Orden
        public ActionResult Index()
        {
            //for (int i=0;i<=10; i++)
            //{
            //    OrdenModel ord = new OrdenModel();
            //    ord.estatus = SrvProxyB2C.EstatusOrden.VALIDACION;
            //    ord.fechaOrden = DateTime.Now.AddDays(i);
            //    Random r = new Random(i);
            //    ord.id_orden = "ORD-" + (Math.Round(r.NextDouble()*10000,0)).ToString() ;

            //    ord.detalle = new List<SrvProxyB2C.Item>();

            //    double valsum = 0; ;
            //    for (int j = 0; j <= 3; j++)
            //    {
            //        SrvProxyB2C.Item item = new SrvProxyB2C.Item();
            //        item.id_item = "ITM-" + j.ToString();
            //        item.id_prod = j;
            //        item.nombre_prod = "Prod-" + j.ToString();
            //        item.part_num = "Part-" + j.ToString();
            //        item.cantidad = 1;

            //        item.precio = Math.Round( r.NextDouble()*100000,0);
            //        valsum = valsum + item.precio;
            //        ord.detalle.Add(item);

            //    }
            //    ord.precio = valsum;
            //    lstordenes.Add(ord);
            //}

            IEnumerable <Orden> lstOrden;
            var currentUser = System.Web.HttpContext.Current.User as CustomPrincipal;
            var ordenes     = new ServiceProxyB2CClient();

            //Orden o = new Orden();
            //o.estatus = EstatusOrden.VALIDACION

            try
            {
                lstOrden = ordenes.ConsultarClientesOrdenes(currentUser.CustId.ToString());
            }
            catch (FaultException <ConsultarClientesOrdenesFault> exf)
            {
                throw new Exception("Error al traer las ordenes " + exf.Detail.ConsultarClientesOrdenesFault1.mensaje);
            }
            catch (CommunicationException cex)
            {
                throw new CommunicationException("Error de conmunicacion " + cex.ToString());
            }


            var clientConfiguration = new MemcachedClientConfiguration {
                Protocol = MemcachedProtocol.Binary
            };

            //clientConfiguration.Servers.Add(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 32768));
            clientConfiguration.Servers.Add(new IPEndPoint(IPAddress.Parse("192.168.99.100"), 32769));



            using (var ordencache = new MemcachedClient(clientConfiguration))
            {
                // se almacena en cache el listado de ordenes del cliente
                ordencache.Store(StoreMode.Set, "Orden-" + currentUser.UserName, lstOrden);
                //HttpContext.Session["ListaOrden"] = lstorden;
            }

            return(View(lstOrden.ToList()));
        }