Exemplo n.º 1
0
        public ConfirmaPed CreaPedido_Sync_Out([System.Xml.Serialization.XmlElementAttribute(Namespace = "urn:creaPedido:modelo:sap")] InfoPedidos PedidoVenta)
        {
            object[] results = this.Invoke("CreaPedido_Sync_Out", new object[] {
                PedidoVenta
            });

            return((ConfirmaPed)(results[0]));
        }
Exemplo n.º 2
0
 /// <remarks/>
 public void CreaPedido_Sync_OutAsync(InfoPedidos PedidoVenta, object userState)
 {
     if ((this.CreaPedido_Sync_OutOperationCompleted == null))
     {
         this.CreaPedido_Sync_OutOperationCompleted = new System.Threading.SendOrPostCallback(this.OnCreaPedido_Sync_OutOperationCompleted);
     }
     this.InvokeAsync("CreaPedido_Sync_Out", new object[] {
         PedidoVenta
     }, this.CreaPedido_Sync_OutOperationCompleted, userState);
 }
Exemplo n.º 3
0
 /// <remarks/>
 public void CreaPedido_Sync_OutAsync(InfoPedidos PedidoVenta)
 {
     this.CreaPedido_Sync_OutAsync(PedidoVenta, null);
 }
Exemplo n.º 4
0
        public string ProcesarPedido(string Nit)
        {
            string xmlPI = "";

            try
            {
                string strUsuario = dicParametros["UsuarioPI"].ToString();
                string strClavePI = dicParametros["ClavePI"].ToString();
                System.Net.NetworkCredential userDefined = new System.Net.NetworkCredential(strUsuario, strClavePI);

                wsPedidos.CreaPedido_Sync_OutService clsPedido = new wsPedidos.CreaPedido_Sync_OutService();
                clsPedido.Credentials = userDefined;

                ClienteService cs          = new ClienteService();
                Cliente        InfoCliente = cs.getInfoClient(Nit);

                //---------------------------------------------------------------------------------------------------------
                //Consulta info cliente
                string strCondicionPago                   = InfoCliente.FormaPago;
                string strTipoDoc_Boutique                = dicParametros["TipoDoc_Boutique"];                //Valor: ""
                string strTipoDoc_BoutiqueEntrega         = dicParametros["TipoDoc_BoutiqueEntrega"];         //Valor: ""
                string strTipoDoc_BoutiqueExterior        = dicParametros["TipoDoc_BoutiqueExterior"];        //Valor: ""
                string strTipoDoc_BoutiqueExteriorEntrega = dicParametros["TipoDoc_BoutiqueExteriorEntrega"]; //Valor: ""
                string strMercado = InfoCliente.TipoMercado;
                clsPedido.Credentials = userDefined;
                //---------------------------------------------------------------------------------------------------------
                //Consulta cartera


                //---------------------------------------------------------------------------------------------------------
                wsPedidos.InfoPedidos oPedido = new wsPedidos.InfoPedidos();
                oPedido.Cabecera = new wsPedidos.CabeceraPed();
                string strCliente = InfoCliente.Nit;                      //DatosCliente.Cliente[0].NitCliente; // "DocumentoCliente";
                oPedido.Cabecera.TipoDoc               = "ZPBT";          //dicParametros["TipoDoc_Boutique"]; // Resp.Cliente[0].Ventas[0].TipoInterfaz.ToString();   //dicParametros["TipoDoc_Boutique"];
                oPedido.Cabecera.DocRef                = "";
                oPedido.Cabecera.Moneda                = "";              //DatosCliente.Cliente[0].Moneda; // "Moneda";
                oPedido.Cabecera.NoCliente             = InfoCliente.Nit; //DatosCliente.Cliente[0].NitCliente; // "DocumentoCliente";
                oPedido.Cabecera.Dest_Mercancia        = InfoCliente.Nit;
                oPedido.Cabecera.Dest_Factura          = InfoCliente.Nit;
                oPedido.Cabecera.Vendedor              = ""; //DatosCliente.Cliente[0].CodigoVendedor;
                oPedido.Cabecera.FechaEntregaSpecified = true;
                oPedido.Cabecera.FechaEntrega          = DateTime.Now;
                oPedido.Cabecera.Observaciones         = "";
                oPedido.Cabecera.FechaDoc              = DateTime.Now;
                oPedido.Cabecera.Condpago              = "";  // strCondicionPago;
                oPedido.Cabecera.Grupovend             = "";
                oPedido.Cabecera.Ind_bloqueo           = "";  //CalcularIndicadorBloqueo -> por cartera vencida
                oPedido.Cabecera.Ind_reserva           = "";  //(" ": Arun contra reserva / "X" contra el stock)
                oPedido.Cabecera.Ind_asigStock         = "";  //sin reserva previa (usuario) -> no liberar
                oPedido.Cabecera.Ind_entrega           = "X"; //Calcular -> if Ind_bloqueo = 1 then Indentrega = 0;  if Ind_bloqueo = 0 then Indentrega = 1
                if (strCondicionPago == dicParametros["CondicionPagoCONTADO"])
                {
                    oPedido.Cabecera.Ind_entrega = " ";

                    if (strMercado == "1010")
                    {
                        oPedido.Cabecera.TipoDoc = strTipoDoc_Boutique;
                    }
                    else if (strMercado == "1020")
                    {
                        oPedido.Cabecera.TipoDoc = strTipoDoc_BoutiqueExterior;
                    }
                }
                else
                {
                    oPedido.Cabecera.Ind_entrega = " ";
                    if (strMercado == "1010")
                    {
                        oPedido.Cabecera.TipoDoc = strTipoDoc_BoutiqueEntrega;
                    }
                    else if (strMercado == "1020")
                    {
                        oPedido.Cabecera.TipoDoc = strTipoDoc_BoutiqueExteriorEntrega;
                    }
                }

                int               intNumItems = 0;
                PedidoService     ps          = new PedidoService();
                List <Referencia> referencias = ps.GetCartItemsByNit(Nit);
                foreach (var referencia in referencias)
                {
                    foreach (Plu plu in referencia.Plu)
                    {
                        if (plu.Cantidad > 0)
                        {
                            intNumItems++;
                        }
                    }
                }

                wsPedidos.PosicionesPed[] oDetalle = new wsPedidos.PosicionesPed[intNumItems];
                //Configura detalle del pedido
                int indPosicion = 0;
                foreach (var referencia in referencias)
                {
                    foreach (Plu plu in referencia.Plu)
                    {
                        if (plu.Cantidad > 0)
                        {
                            string  strPlu            = plu.Codigo;
                            decimal decCantidadPedido = plu.Cantidad;
                            decimal decPrecio         = plu.Precio;
                            oDetalle[indPosicion] = new wsPedidos.PosicionesPed();
                            oDetalle[indPosicion].Tipo_posicion = dicParametros["TipoPosicion"];
                            oDetalle[indPosicion].PLU           = strPlu;
                            oDetalle[indPosicion].Cantidad      = decCantidadPedido;
                            oDetalle[indPosicion].Unidad        = "";

                            oDetalle[indPosicion].Precio        = decPrecio;
                            oDetalle[indPosicion].Observaciones = "";
                            indPosicion++;
                        }
                    }
                }
                oPedido.Posiciones = oDetalle;


                XmlSerializer SerializerObj = new XmlSerializer(typeof(wsPedidos.InfoPedidos));
                // Create a new file stream to write the serialized object to a file
                string     path            = dicParametros["Ruta_Log_Errores_PedidosBT"].ToString();
                TextWriter WriteFileStream = new StreamWriter(path.Replace("Errores_PedidosBT.log", +DateTime.Now.Year + "" + DateTime.Now.Month + "" + DateTime.Now.Day + "" + DateTime.Now.Hour + "" + DateTime.Now.Minute + "" + DateTime.Now.Second + "-" + strCliente + ".xml"));
                XmlSerializerNamespaces ns = new XmlSerializerNamespaces();
                SerializerObj.Serialize(WriteFileStream, oPedido);
                // Cleanup
                WriteFileStream.Close();
                //xmlPI = clsSerializeHelper.serializeSinNameSpaces(typeof(wsPedidos.InfoPedidos), oPedido);

                wsPedidos.ConfirmaPed oRespPedido = clsPedido.CreaPedido_Sync_Out(oPedido);

                if (oRespPedido.Cabecera.TipoPedido == null || oRespPedido.Cabecera.TipoPedido == "")
                {
                    throw new Exception("No ha sido posible almacenar el pedido!");
                    //Boolean bolRespuestaLogError = this.generarRegistroError("Pedidos", oRespPedido.Mensajes[0].TextoMjs.ToString(), "Pedido");
                }

                string strNumeroPedido = oRespPedido.Cabecera.TipoPedido.ToString();
                return("Pedido Guardado: " + strNumeroPedido);
            }
            catch (Exception error)
            {
                //EnviarNotificacionError("PedidosBT", "", "XML Tienda Boutiques" + strDatosPedido + " XML PI: " + xmlPI, error.EstadoValidacion.strMensaje);
                //Boolean bolRespuestaLogError = this.generarRegistroError("Pedidos", error.EstadoValidacion.strMensaje, "XML Tienda Boutiques" + strDatosPedido + " XML PI: " + xmlPI);
                throw new Exception("Ha ocurrido un error al procesar el pedido");
            }
        }