示例#1
0
        private static bool StockThinkRetail(string referencia, string talla, string idPedido, string almacen, string almacenSalida, string idUsuario, string userThinkretail, string passThinkretail, string idTicket)
        {
            try
            {
                bool hayStock = false;

                //string keyArticuloTienda = string.Empty;
                // keyArticuloTienda = string.Format(KEY_ARTICULO_FORMAT, referencia, talla, KEY_CENTRAL);

                ThinkRetailServiceWeb.wsThinkRetail wsThinkRetail = new ThinkRetailServiceWeb.wsThinkRetail();
                // wsThinkRetail.Url = System.Configuration.ConfigurationManager.AppSettings["UrlHermes"].ToString();


                List <ThinkRetailServiceWeb.Row_Input> row_Inputs = new List <ThinkRetailServiceWeb.Row_Input>();
                row_Inputs.Add(new ThinkRetailServiceWeb.Row_Input()
                {
                    Cantidad = 1, NumMaterial = referencia, Posicion = 001, Talla = talla
                });


                wsThinkRetail.CookieContainer = new System.Net.CookieContainer();


                if (wsThinkRetail.Login(userThinkretail, passThinkretail))
                {
                    ThinkRetailServiceWeb.Salida respuesta = wsThinkRetail.CreaReservaTR(idTicket, almacen, almacenSalida, idUsuario, row_Inputs.ToArray());

                    if (respuesta.Sts.Equals("ERROR"))
                    {
                        hayStock = false;
                    }
                    else
                    {
                        hayStock = true;
                    }
                    try
                    {
                        string Descrip = "";

                        if (respuesta.Mensajes != null)
                        {
                            foreach (ThinkRetailServiceWeb.Mensaje msjs in respuesta.Mensajes)
                            {
                                Descrip = Descrip + msjs.Descripcion;
                            }
                            log.Error("Descripcion_Reserva: " + Descrip);
                        }
                        else
                        {
                            log.Error("respuesta.Mensajes devuelto es null ");
                        }



                        CapaDatos.StockTiendaDAL.ActualizarReservaThinkRetail(Convert.ToInt32(idPedido), Descrip, respuesta.Sts);
                    }
                    catch (Exception ex)
                    {
                        log.Error(ex.Message.ToString());
                    }
                }

                //StockTienda stockCentral = new StockTienda();
                //stockCentral.tienda = KEY_ECOMMERCE;
                //stockCentral.stock = 0; //Lo que devuelva el servicio.

                //hayStock = ValidarStockEnTienda(keyArticuloTienda, stockCentral, ref stockSolicitado);

                return(hayStock);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
示例#2
0
        public bool cancelarReservaAC(string idCarrito, string idTienda, string idUsuario, string userThinkretail, string passThinkretail, string idTerminal, string Tienda)

        {
            Dictionary <string, int> stockSolicitado = new Dictionary <string, int>();
            string referencia;
            string talla;
            string idLineaCarrito;
            string idArticulo;
            string idPedido;
            string idTicket;

            //Obtenemos las lineas del carrito
            DataSet       dsLineasCarrito   = StockTiendaDAL.GetLineasCarrito(idCarrito);
            List <string> articulosSinStock = new List <string>();

            ThinkRetailServiceWeb.wsThinkRetail wsThinkRetail = new ThinkRetailServiceWeb.wsThinkRetail();

            wsThinkRetail.CookieContainer = new System.Net.CookieContainer();


            if (wsThinkRetail.Login(userThinkretail, passThinkretail))
            {
                foreach (DataRow row in dsLineasCarrito.Tables[0].Rows)
                {
                    string estadoReserva = row["EstadoReservaThinkRetail"].ToString();
                    if (estadoReserva != null && estadoReserva.Equals("OK"))
                    {
                        referencia     = StockTiendaDAL.GetReferencia(row["IdArticulo"].ToString());
                        talla          = StockTiendaDAL.GetTallaLineaCarrito(row["IdPedido"].ToString());
                        idLineaCarrito = row["id_Carrito_Detalle"].ToString();
                        idPedido       = row["IdPedido"].ToString();

                        idTicket = StockTiendaDAL.ObtieneUltimoTicketTR(Tienda, idTerminal);
                        if (idTicket != "")
                        {
                            idTicket = idTicket + "/" + idTerminal + "/" + Tienda + "-" + idPedido;
                            ThinkRetailServiceWeb.SalidaMsg respuesta = wsThinkRetail.CancelaReservaTR(idTicket, KEY_TIENDA_CENTRAL);
                            try
                            {
                                string Descrip = "";
                                log.Error("Descripcion:" + respuesta.Descripcion);

                                if (respuesta.Mensajes != null)
                                {
                                    foreach (ThinkRetailServiceWeb.Mensaje msjs in respuesta.Mensajes)
                                    {
                                        Descrip = Descrip + msjs.Descripcion;
                                    }
                                    log.Error("Descripcion_Cancelacion_Carro: " + Descrip);
                                }
                                else
                                {
                                    log.Error("respuesta.Mensajes devuelto es null ");
                                }
                            }
                            catch (Exception ex)
                            {
                                log.Error(ex.Message.ToString());
                            }
                        }
                        else
                        {
                            log.Error("No se ha obtenido ticket");
                        }
                    }
                }
            }
            return(true);
        }