Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Data;
- using System.Data.SqlClient;
- using System.Configuration;
- using System.Web.Services;
- using System.Web.Script.Services;
- using Newtonsoft.Json;
- using System.Net;
- using System.Net.Mail;
- using System.IO;
- using System.Threading.Tasks;
- using Emissary.Services;
- namespace Emissary.Aplicacion
- {
- public partial class Envios : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- }
- #region <<Guardar Envío>>
- [WebMethod]
- //public static string Guardar(string jData)
- public static string guardarEnvio(Object pJData, decimal costo, string TrackingNo, string tipoGuia)
- {
- Int64 envioId;
- string userId = HttpContext.Current.Session["usuario_id"].ToString();
- dynamic Data = JsonConvert.DeserializeObject(pJData.ToString());
- string paqueteriaId = Data[0]["paqueteriaId"];
- string tipoServicio = Data[0]["tipoServicio"]; //FromName
- string precio = Data[0]["precio"];
- //envioId = Data[0]["envioId"];
- //REMITENTE
- string nombreRemitente = nombreRemitente = Data[0]["nombreRemitente"];
- string correoRemitente = correoRemitente = Data[0]["correoRemitente"];
- string telefonoRemitente = telefonoRemitente = Data[0]["telefonoRemitente"];
- string direccionRemitente = Data[0]["direccionRemitente"];
- string referenciaRemitente = Data[0]["referenciaRemitente"];
- string coloniaRemitente = Data[0]["coloniaRemitente"];
- string codigoPostalRemitente = Data[0]["codigoPostalRemitente"];
- string estadoRemitente = Data[0]["estadoRemitente"];
- //DESTINATARIO
- string nombreDestinatario = nombreDestinatario = Data[0]["nombreDestinatario"];
- //string correoDestinatario = correoDestinatario = Data[0]["correoDestinatario"];
- string correoDestinatario = correoDestinatario = correoDestinatario = "envios@gmail.com";
- string telefonoDestinatario = telefonoDestinatario = Data[0]["telefonoDestinatario"];
- string direccionDestinatario = Data[0]["direccionDestinatario"];
- string referenciaDestinatario = Data[0]["referenciaDestinatario"];
- string coloniaDestinatario = Data[0]["coloniaDestinatario"];
- string codigoPostalDestinatario = Data[0]["codigoPostalDestinatario"];
- string estadoDestinatario = Data[0]["estadoDestinatario"];
- //DIMENSIONES
- string largo = Data[0]["largo"];
- string ancho = Data[0]["ancho"];
- string alto = Data[0]["alto"];
- string peso = Data[0]["peso"];
- string envio = Data[0]["envio"];
- string mensaje = string.Empty;
- DataTable DataTable = new DataTable();
- dbo.BaseDatos db = null;
- SqlParameter prmUserId, prmNombreRemitente, prmCorreoRemitente, prmTelefonoRemitente, prmDireccionRemitente, prmReferenciaRemitente, prmColoniaRemitente, prmCodigoPostalRemitente, prmEstadoRemitente,
- prmNombreDestinatario, prmCorreoDestinatario, prmTelefonoDestinatario, prmDireccionDestinatario, prmReferenciaDestinatario, prmColoniaDestinatario, prmCodigoPostalDestinatario, prmEstadoDestinatario,
- prmLargo, prmAncho, prmAlto, prmPeso, prmEnvio, prmTipoServicio, prmPaqueteria, prmCosto, prmPrecio, prmTrackingNo, prmTipoGuia;
- try
- {
- db = new dbo.BaseDatos(ConfigurationManager.ConnectionStrings["cnn"].ToString());
- prmUserId = new SqlParameter("@userId", SqlDbType.BigInt);
- prmUserId.Value = userId;
- prmTrackingNo = new SqlParameter("@TrackingNo", SqlDbType.BigInt);
- prmTrackingNo.Value = TrackingNo;
- //Datos Envío Remitente
- prmNombreRemitente = new SqlParameter("@nombreRemitente", SqlDbType.NVarChar, 50);
- prmNombreRemitente.Value = nombreRemitente;
- prmCorreoRemitente = new SqlParameter("@correoRemitente", SqlDbType.NVarChar, 50);
- prmCorreoRemitente.Value = correoRemitente;
- prmTelefonoRemitente = new SqlParameter("@telefonoRemitente", SqlDbType.NVarChar, 50);
- prmTelefonoRemitente.Value = telefonoRemitente;
- prmDireccionRemitente = new SqlParameter("@direccionRemitente", SqlDbType.NVarChar, 50);
- prmDireccionRemitente.Value = direccionRemitente;
- prmReferenciaRemitente = new SqlParameter("@referenciaRemitente", SqlDbType.NVarChar, 50);
- prmReferenciaRemitente.Value = referenciaRemitente;
- prmColoniaRemitente = new SqlParameter("@coloniaRemitente", SqlDbType.NVarChar, 50);
- prmColoniaRemitente.Value = coloniaRemitente;
- prmCodigoPostalRemitente = new SqlParameter("@codigoPostalRemitente", SqlDbType.NVarChar, 50);
- prmCodigoPostalRemitente.Value = codigoPostalRemitente;
- prmEstadoRemitente = new SqlParameter("@estadoRemitente", SqlDbType.NVarChar, 50);
- prmEstadoRemitente.Value = estadoRemitente;
- //Datos Envío Destinatario
- prmNombreDestinatario = new SqlParameter("@nombreDestinatario", SqlDbType.NVarChar, 50);
- prmNombreDestinatario.Value = nombreDestinatario;
- prmCorreoDestinatario = new SqlParameter("@correoDestinatario", SqlDbType.NVarChar, 50);
- prmCorreoDestinatario.Value = correoDestinatario;
- prmTelefonoDestinatario = new SqlParameter("@telefonoDestinatario", SqlDbType.NVarChar, 50);
- prmTelefonoDestinatario.Value = telefonoDestinatario;
- prmDireccionDestinatario = new SqlParameter("@direccionDestinatario", SqlDbType.NVarChar, 50);
- prmDireccionDestinatario.Value = direccionDestinatario;
- prmReferenciaDestinatario = new SqlParameter("@referenciaDestinatario", SqlDbType.NVarChar, 50);
- prmReferenciaDestinatario.Value = referenciaDestinatario;
- prmColoniaDestinatario = new SqlParameter("@coloniaDestinatario", SqlDbType.NVarChar, 50);
- prmColoniaDestinatario.Value = coloniaDestinatario;
- prmCodigoPostalDestinatario = new SqlParameter("@codigoPostalDestinatario", SqlDbType.NVarChar, 50);
- prmCodigoPostalDestinatario.Value = codigoPostalDestinatario;
- prmEstadoDestinatario = new SqlParameter("@estadoDestinatario", SqlDbType.NVarChar, 50);
- prmEstadoDestinatario.Value = estadoDestinatario;
- //Datos Dimensiones
- prmLargo = new SqlParameter("@largo", SqlDbType.NVarChar, 50);
- prmLargo.Value = largo;
- prmAncho = new SqlParameter("@ancho", SqlDbType.NVarChar, 50);
- prmAncho.Value = ancho;
- prmAlto = new SqlParameter("@alto", SqlDbType.NVarChar, 50);
- prmAlto.Value = alto;
- prmPeso = new SqlParameter("@peso", SqlDbType.NVarChar, 50);
- prmPeso.Value = peso;
- prmEnvio = new SqlParameter("@envio", SqlDbType.NVarChar, 50);
- prmEnvio.Value = envio;
- prmTipoServicio = new SqlParameter("@tipoServicio", SqlDbType.NVarChar, 50);
- prmTipoServicio.Value = tipoServicio;
- prmPaqueteria = new SqlParameter("@paqueteria", SqlDbType.NVarChar, 50);
- prmPaqueteria.Value = paqueteriaId;
- prmPrecio = new SqlParameter("@precio", SqlDbType.NVarChar, 50);
- prmPrecio.Value = precio;
- prmCosto = new SqlParameter("@costo", SqlDbType.NVarChar, 50);
- prmCosto.Value = costo;
- prmTipoGuia = new SqlParameter("@tipoGuia", SqlDbType.NVarChar, 50);
- prmTipoGuia.Value = tipoGuia;
- DataTable = db.ObtenerDatosComoDataTable("spac_Emissary_EnvioPrueba", prmUserId, prmNombreRemitente, prmCorreoRemitente, prmTelefonoRemitente, prmDireccionRemitente, prmReferenciaRemitente, prmColoniaRemitente, prmCodigoPostalRemitente, prmEstadoRemitente,
- prmNombreDestinatario, prmCorreoDestinatario, prmTelefonoDestinatario, prmDireccionDestinatario, prmReferenciaDestinatario, prmColoniaDestinatario, prmCodigoPostalDestinatario, prmEstadoDestinatario,
- prmLargo, prmAncho, prmAlto, prmPeso, prmEnvio, prmTipoServicio, prmPaqueteria, prmCosto, prmPrecio, prmTrackingNo, prmTipoGuia);
- //dataset.TableName = "Usuario";
- //mensaje = JsonConvert.SerializeObject(DataTable);
- //mensaje = JsonConvert.SerializeObject(DataTable);
- DataRow row = DataTable.Rows[0];
- string saldo = mensaje = row["saldo"].ToString();
- //HttpContext.Current.Session["saldo"].ToString();
- HttpContext.Current.Session["saldo"] = saldo;
- }
- catch (Exception ex)
- {
- mensaje = "error|" + ex.Message.ToString();
- }
- finally
- {
- db.Finalizar();
- }
- return mensaje;
- }
- #endregion <<Guardar>>
- private static webServiceRedpack.Paquete DeserializaPaquete(object pJData)
- {
- dynamic Data = JsonConvert.DeserializeObject(pJData.ToString());
- var largo = int.Parse((string)Data[0]["largo"]);
- var ancho = int.Parse((string)Data[0]["ancho"]);
- var alto = int.Parse((string)Data[0]["alto"]);
- var peso = int.Parse((string)Data[0]["peso"]);
- var paquete = new webServiceRedpack.Paquete
- {
- alto = alto,
- altoSpecified = true,
- ancho = ancho,
- anchoSpecified = true,
- peso = (float)peso,
- pesoSpecified = true,
- largo = largo,
- largoSpecified = true
- };
- return paquete;
- }
- private static webServiceRedpack.Direccion DeserializaConsignatario(object pJData)
- {
- dynamic Data = JsonConvert.DeserializeObject(pJData.ToString());
- var nombreDestinatario = Data[0]["nombreDestinatario"]; //To NAme
- //var correoDestinatario = Data[0]["correoDestinatario"];//ToMail
- var correoDestinatario = "envios@gmail.com";
- var telefonoDestinatario = Data[0]["telefonoDestinatario"]; //ToPhone
- var direccionDestinatario = Data[0]["direccionDestinatario"]; //ToStreth
- var referenciaDestinatario = Data[0]["referenciaDestinatario"]; //ToComents
- var coloniaDestinatario = Data[0]["coloniaDestinatario"]; //ToAdress
- var codigoPostalDestinatario = Data[0]["codigoPostalDestinatario"]; //ToPostalCOde
- var ciudadDestinatario = Data[0]["ciudadDestinatario"]; //ToCity
- var estadoDestinatario = Data[0]["estadoDestinatario"]; //ToCity
- var telefonoTo = "+52" + telefonoDestinatario; //FromPhone correct
- var consignatario = new webServiceRedpack.Direccion
- {
- codigoPostal = int.Parse((string)codigoPostalDestinatario),
- codigoPostalSpecified = true,
- calle = direccionDestinatario,
- ciudad = ciudadDestinatario,
- colonia_Asentamiento = coloniaDestinatario,
- estado = estadoDestinatario,
- email = correoDestinatario,
- referenciaUbicacion = referenciaDestinatario,
- telefonos = new webServiceRedpack.Telefono[] { new webServiceRedpack.Telefono { telefono = telefonoTo } },
- nombre_Compania = nombreDestinatario,
- pais = "MX"
- };
- return consignatario;
- }
- private static webServiceRedpack.Direccion DeserializaRemitente(object pJData)
- {
- dynamic Data = JsonConvert.DeserializeObject(pJData.ToString());
- var nombreRemitente = Data[0]["nombreRemitente"]; //FromName
- var correoRemitente = Data[0]["correoRemitente"]; //FromeMail
- var telefonoRemitente = Data[0]["telefonoRemitente"]; //FromPhone
- var telefonoDe = "+52" + telefonoRemitente; //FromPhone correct
- var direccionRemitente = Data[0]["direccionRemitente"]; //FromStreth
- var referenciaRemitente = Data[0]["referenciaRemitente"]; //FromComents
- var coloniaRemitente = Data[0]["coloniaRemitente"]; //FromAdress
- var codigoPostalRemitente = Data[0]["codigoPostalRemitente"]; //FromPostalCode
- var ciudadRemitente = Data[0]["ciudadRemitente"]; //City
- var estadoRemitente = Data[0]["estadoRemitente"]; //FromCity
- var remitente = new webServiceRedpack.Direccion
- {
- codigoPostal = int.Parse((string)codigoPostalRemitente),
- codigoPostalSpecified = true,
- calle = direccionRemitente,
- ciudad = ciudadRemitente,
- colonia_Asentamiento = coloniaRemitente,
- estado = estadoRemitente,
- email = correoRemitente,
- referenciaUbicacion = referenciaRemitente,
- telefonos = new webServiceRedpack.Telefono[] { new webServiceRedpack.Telefono { telefono = telefonoDe } },
- nombre_Compania = nombreRemitente,
- pais = "MX"
- };
- return remitente;
- }
- #region <<Cotizar Envio>>
- [WebMethod]
- //public static string Guardar(string jData)
- public static string cotizarEnvio(Object pJData)
- {
- string precioPaquete = cotizarPaqueteExpress(pJData);
- //ObtenerCotizacionDhl( pJData);
- //ObtenerCotizacionFedexPesados(pJData);
- //var cotizar = 1;
- //zonaExtendida(pJData);
- //ObtenerCotizacionRedpack(pJData);
- //return precioPaquete;
- return string.Empty;
- }
- #endregion <<Guardar>>
- #region <<Cotizar Envio Paquete Express Comentado>>
- [WebMethod]
- public static string cotizarPaqueteExpress(Object pJData)
- {
- dynamic data = JsonConvert.DeserializeObject(pJData.ToString());
- dynamic request = data[0];
- var length = Convert.ToInt32(request["largo"]);
- var width = Convert.ToInt32(request["ancho"]);
- var heigth = Convert.ToInt32(request["alto"]);
- var quotationRequest = new PaquetExpress.Quotation.Data
- {
- ClientAddrOrig = new PaquetExpress.Quotation.Address
- {
- ColonyName = request["coloniaRemitente"],
- ZipCode = request["codigoPostalRemitente"]
- },
- ClientAddrDest = new PaquetExpress.Quotation.Address
- {
- ColonyName = request["coloniaDestinatario"],
- ZipCode = request["codigoPostalDestinatario"]
- },
- Services = new PaquetExpress.Quotation.Services
- {
- DlvyType = "0", //0=Ocurre, 1=Entrega a domicilio
- AckType = "N", //C=CLIENTE, I=INTERNO, X=EXTENDIDA, N=SIN ACUSE
- TotlDeclVlue = 0, //Valor declarado para seguro de envío
- InvType = "A",//N=SIN SEGURO, A=COBERTURA AMPLIA, L=COBERTURA LIMITADA
- RadType = "1", //0=No, 1=Si
- },
- ShipmentDetail = new PaquetExpress.Quotation.ShipmentDetail
- {
- Shipments = new List<PaquetExpress.Quotation.Shipment>()
- {
- {
- new PaquetExpress.Quotation.Shipment
- {
- Sequence =1,
- Quantity = 1,
- ShpCode ="2", // Tipo de bultos: 1 = Sobre, 2 = Caja
- Weight = (int)request["peso"],
- Volume = (decimal) (length /100) * (width/100) * (heigth/100),
- LongShip = length,
- WidthShip = width,
- HighShip = heigth
- }
- }
- }
- }
- };
- var quotationResponse = AsyncHelpers.RunSync<PaquetExpress.Quotation.Data>(() => PaquetExpress.ServiceQuotation.CreateAsync(quotationRequest));
- decimal paqueteTerrestre = quotationResponse.Amount.ShpAmnt.Value;
- string costoPaquete = Convert.ToString(paqueteTerrestre);
- string userId = HttpContext.Current.Session["usuario_id"].ToString();
- string mensaje;
- DataSet DataSet = new DataSet();
- dbo.BaseDatos db = null;
- db = new dbo.BaseDatos(ConfigurationManager.ConnectionStrings["cnn"].ToString());
- SqlParameter prmUserId, prmCostoPaquete;
- try
- {
- prmUserId = new SqlParameter("@userId", SqlDbType.SmallInt);
- prmUserId.Value = userId;
- prmCostoPaquete = new SqlParameter("@costoPaquete", SqlDbType.Decimal);
- decimal value;
- decimal.TryParse(costoPaquete, out value);
- prmCostoPaquete.Value = value;
- DataSet = db.ObtenerDatosComoDataSet("spq_Emissary_PreciosPaquete", prmUserId, prmCostoPaquete);
- //DataSet.TableName = "Peso";
- mensaje = JsonConvert.SerializeObject(DataSet);
- }
- catch (Exception ex)
- {
- mensaje = ex.Message;
- }
- finally
- {
- db.Finalizar();
- }
- return mensaje;
- //double terrestrePaquete =(quotationResponse.Amount.ShpAmnt) * 1.10;
- //HttpContext.Current.Session["Paquete_Terrestre"] = quotationResponse.Amount.ShpAmnt;
- //foreach (var service in quotationData.)
- //{
- // if (service.ServiceType == "ground")
- // HttpContext.Current.Session["Dhl_Terrestre"] = service.TotalPrice;
- // else if (service.ServiceType == "express")
- // HttpContext.Current.Session["Dhl_Aereo"] = service.TotalPrice;
- // else
- // HttpContext.Current.Session["Dhl_" + service.ServiceType] = service;
- //}
- //return precioPaquete;
- }
- private static async Task<Emissary.PaquetExpress.Quotation.Data> ObtenerCotizacion(object pJData)
- {
- dynamic Data = JsonConvert.DeserializeObject(pJData.ToString());
- var quotationData = new Emissary.PaquetExpress.Quotation.Data
- {
- ClientAddrOrig = new Emissary.PaquetExpress.Quotation.Address // Datos del origen solo pide esos dos, nombre de la colonia y codigo postal
- {
- ColonyName = Data[0]["coloniaRemitente"],
- ZipCode = Data[0]["codigoPostalRemitente"]
- },
- ClientAddrDest = new Emissary.PaquetExpress.Quotation.Address // es lo mismo pero en lugar de Remitente Destinatario
- {
- ColonyName = Data[0]["coloniaDestinatario"],
- ZipCode = Data[0]["codigoPostalDestinatario"]
- },
- Services = new Emissary.PaquetExpress.Quotation.Services
- {
- DlvyType = "1", //Tipo de entrega (a domicilio, ocurre)
- AckType = "N",//Tipo de acuse de Recibo solicitado por el cliente C=CLIENTE, I=INTERNO, N=SIN ACUSE
- TotlDeclVlue = 2000, //Valor declarado para seguro de envío
- InvType = "A", //Mantiene la clave del seguro a aplicar INV-1, INV-PF, IV-XF, INV-CX
- RadType = "1", //servicio Recoleccion a domicilio (RAD)
- },
- ShipmentDetail = new Emissary.PaquetExpress.Quotation.ShipmentDetail
- {
- Shipments = new List<Emissary.PaquetExpress.Quotation.Shipment>()
- {
- {
- new Emissary.PaquetExpress.Quotation.Shipment // Datos del paquete
- {
- Sequence =1,
- Quantity = 1,
- ShpCode ="2",
- Weight = int.Parse((string)Data[0]["peso"]),
- LongShip = int.Parse((string)Data[0]["largo"]),
- WidthShip = int.Parse((string)Data[0]["ancho"]),
- HighShip = int.Parse((string)Data[0]["alto"]),
- Volume = (int.Parse((string)Data[0]["largo"]) * int.Parse((string)Data[0]["ancho"]) * int.Parse((string)Data[0]["alto"])) / 5000
- }
- }
- }
- }
- };
- var quotation = await Emissary.PaquetExpress.ServiceQuotation.CreateAsync(quotationData);
- return quotation;
- }
- #endregion <<Guardar>>
- #region Cotizar Envio Dhl Comentado
- //[System.Web.Services.WebMethod]
- //public static string ObtenerCotizacionDhl(Object pJData)
- //{
- // dynamic data = JsonConvert.DeserializeObject(pJData.ToString());
- // dynamic request = data[0];
- // var quotationRequest = new Emissary.Dhl.Quotation.Request
- // {
- // Origin = new Emissary.Dhl.Address
- // {
- // Name = request["nombreRemitente"],
- // Company = request["nombreRemitente"],
- // Email = request["correoRemitente"],
- // Phone = request["telefonoRemitente"],
- // Street = request["direccionRemitente"],
- // Number = "0000",
- // District = request["coloniaRemitente"],
- // City = request["ciudadRemitente"],
- // State = request["estadoRemitente"],
- // Country = "MX",
- // PostalCode = request["codigoPostalRemitente"]
- // },
- // Destination = new Emissary.Dhl.Address
- // {
- // Name = request["nombreDestinatario"],
- // Company = request["nombreDestinatario"],
- // Email = request["correoDestinatario"],
- // Phone = request["telefonoDestinatario"],
- // Street = request["direccionDestinatario"],
- // Number = "0000",
- // District = request["coloniaDestinatario"],
- // City = request["ciudadDestinatario"],
- // State = request["estadoDestinatario"],
- // Country = "MX",
- // PostalCode = request["codigoPostalDestinatario"]
- // },
- // Package = new Emissary.Dhl.Package
- // {
- // Content = request["envio"],
- // Amount = 1,
- // Type = "box",
- // Dimensions = new Emissary.Dhl.Dimensions
- // {
- // Length = Convert.ToInt32(request["largo"]),
- // Width = Convert.ToInt32(request["ancho"]),
- // Height = Convert.ToInt32(request["alto"])
- // },
- // Weight = (int)request["peso"],
- // Insurance = 0,
- // DeclaredValue = 0
- // },
- // Shipment = new Emissary.Dhl.Shipment
- // {
- // Carrier = "dhl"
- // }
- // };
- // var quotationData = AsyncHelpers.RunSync<Emissary.Dhl.Quotation.Response>(() => Emissary.Dhl.ServiceQuotation.CreateAsync(quotationRequest));
- // foreach (var service in quotationData.Data)
- // {
- // if (service.ServiceType == "ground")
- // HttpContext.Current.Session["Dhl_Terrestre"] = service.TotalPrice;
- // else if (service.ServiceType == "express")
- // HttpContext.Current.Session["Dhl_Aereo"] = service.TotalPrice;
- // else
- // HttpContext.Current.Session["Dhl_" + service.ServiceType] = service;
- // }
- // return string.Empty;
- //}
- #endregion <<Dhl>>
- //[System.Web.Services.WebMethod]
- //public static string ObtenerCotizacionPaquete(Object pJData)
- //{
- // dynamic data = JsonConvert.DeserializeObject(pJData.ToString());
- // dynamic request = data[0];
- //var quotationRequest = new Emissary.PaquetExpress.Quotation.Request
- //{
- // Origin = new Emissar
- // {
- // Name = request["nombreRemitente"],
- // Company = request["nombreRemitente"],
- // Email = request["correoRemitente"],
- // Phone = request["telefonoRemitente"],
- // Street = request["direccionRemitente"],
- // Number = "0000",
- // District = request["coloniaRemitente"],
- // City = request["ciudadRemitente"],
- // State = request["estadoRemitente"],
- // Country = "MX",
- // PostalCode = request["codigoPostalRemitente"]
- // }
- //};
- //var quotationRequest = new Emissary.PaqueteExpress.Quotation.Request
- //{
- // Origin = new Emissary.Paquete.Address
- // {
- // Name = request["nombreRemitente"],
- // Company = request["nombreRemitente"],
- // Email = request["correoRemitente"],
- // Phone = request["telefonoRemitente"],
- // Street = request["direccionRemitente"],
- // Number = "0000",
- // District = request["coloniaRemitente"],
- // City = request["ciudadRemitente"],
- // State = request["estadoRemitente"],
- // Country = "MX",
- // PostalCode = request["codigoPostalRemitente"]
- // },
- // Destination = new Emissary.Paquete.Address
- // {
- // Name = request["nombreDestinatario"],
- // Company = request["nombreDestinatario"],
- // Email = request["correoDestinatario"],
- // Phone = request["telefonoDestinatario"],
- // Street = request["direccionDestinatario"],
- // Number = "0000",
- // District = request["coloniaDestinatario"],
- // City = request["ciudadDestinatario"],
- // State = request["estadoDestinatario"],
- // Country = "MX",
- // PostalCode = request["codigoPostalDestinatario"]
- // },
- // Package = new Emissary.Paquete.Package
- // {
- // Content = request["envio"],
- // Amount = 1,
- // Type = "box",
- // Dimensions = new Emissary.Paquete.Dimensions
- // {
- // Length = Convert.ToInt32(request["largo"]),
- // Width = Convert.ToInt32(request["ancho"]),
- // Height = Convert.ToInt32(request["alto"])
- // },
- // Weight = (int)request["peso"],
- // Insurance = 0,
- // DeclaredValue = 0
- // },
- // Shipment = new Emissary.Paquete.Shipment
- // {
- // Carrier = "Paquete"
- // }
- //};
- //var quotationData = AsyncHelpers.RunSync<Emissary.Paquete.Quotation.Response>(() => Emissary.Paquete.ServiceQuotation.CreateAsync(quotationRequest));
- //foreach (var service in quotationData.Data)
- //{
- // if (service.ServiceType == "ground")
- // HttpContext.Current.Session["Paquete_Terrestre"] = service.TotalPrice;
- // else if (service.ServiceType == "express")
- // HttpContext.Current.Session["Paquete_Aereo"] = service.TotalPrice;
- // else
- // HttpContext.Current.Session["Paquete_" + service.ServiceType] = service;
- //}
- // return string.Empty;
- //}
- #region Redpack
- [System.Web.Services.WebMethod]
- public static string ObtenerCotizacionRedpack(Object pJData)
- {
- dynamic Data = JsonConvert.DeserializeObject(pJData.ToString());
- int tipoServicioRedpack = Data[0]["tipoServicio"];
- //int peso = Data[0]["peso"];
- //int peso = 1;
- //int peso = 5;
- //int peso = 14;
- //int peso = 14;
- int peso = 20;
- //int peso = 25;
- //int peso = 30;
- //int peso = 35;
- //int peso = 40;
- //int peso = 50;
- //int peso = 60;
- //int peso = 70;
- if (tipoServicioRedpack == 1 && peso == 1)
- {
- //var idUser = 1332;
- //var pin = "PROD oNmnqC0wC1PIP4xOOi+XU9mBaDD3H/WaXerHWc+YTv6/TY1QB+hqLQ==";
- var idUser = 1127;
- var pin = "PROD oNmnqC0wC1OKtdtGe8TaA663C2+gFNOX5kwuSaAvj70=";
- var wsClient = new webServiceRedpack.RedpackWS();
- var guia = new webServiceRedpack.Guia
- {
- paquetes = new webServiceRedpack.Paquete[] { DeserializaPaquete(pJData) },
- consignatario = DeserializaConsignatario(pJData),
- remitente = DeserializaRemitente(pJData),
- tipoEntrega = new webServiceRedpack.IdDesc { id = 2, idSpecified = true },
- tipoEnvio = new webServiceRedpack.IdDesc { id = 2, idSpecified = true },
- tipoServicio = new webServiceRedpack.IdDesc { id = 2, idSpecified = true },
- flag = 1,
- moneda = "$",
- numeroDeGuia = idUser.ToString() + DateTime.Now.Millisecond.ToString()
- };
- decimal TotalDiscount = 0, TotalAmount = 0;
- decimal TotalDiscountExpress = 0, TotalAmountExpress = 0;
- var cotizacionGuias = wsClient.cotizacionNacional(pin, idUser, true, new webServiceRedpack.Guia[] { guia });
- // Asignamos la primera cotizacion al objeto que vamos a enviar a predocumentar
- if (cotizacionGuias != null)
- {
- foreach (var guiaCotizada in cotizacionGuias)
- {
- if (guiaCotizada.cotizaciones != null)
- {
- var ecoExpress = guiaCotizada.cotizaciones.FirstOrDefault(c => c.tipoServicio.descripcion == "ECOEXPRESS");
- HttpContext.Current.Session["cotizacion"] = ecoExpress;
- var Express = guiaCotizada.cotizaciones.FirstOrDefault(c => c.tipoServicio.descripcion == "EXPRESS");
- HttpContext.Current.Session["cotizacionExpress"] = Express;
- }
- }
- }
- }
- else
- {
- //var idUser = 1127;
- //var pin = "PROD oNmnqC0wC1OKtdtGe8TaA663C2+gFNOX5kwuSaAvj70=";
- var idUser = 1332;
- var pin = "PROD oNmnqC0wC1PIP4xOOi+XU9mBaDD3H/WaXerHWc+YTv6/TY1QB+hqLQ==";
- var wsClient = new webServiceRedpack.RedpackWS();
- var guia = new webServiceRedpack.Guia
- {
- paquetes = new webServiceRedpack.Paquete[] { DeserializaPaquete(pJData) },
- consignatario = DeserializaConsignatario(pJData),
- remitente = DeserializaRemitente(pJData),
- tipoEntrega = new webServiceRedpack.IdDesc { id = 2, idSpecified = true },
- tipoEnvio = new webServiceRedpack.IdDesc { id = 2, idSpecified = true },
- tipoServicio = new webServiceRedpack.IdDesc { id = 2, idSpecified = true },
- flag = 1,
- moneda = "$",
- numeroDeGuia = idUser.ToString() + DateTime.Now.Millisecond.ToString()
- };
- decimal TotalDiscount = 0, TotalAmount = 0;
- decimal TotalDiscountExpress = 0, TotalAmountExpress = 0;
- var cotizacionGuias = wsClient.cotizacionNacional(pin, idUser, true, new webServiceRedpack.Guia[] { guia });
- // Asignamos la primera cotizacion al objeto que vamos a enviar a predocumentar
- if (cotizacionGuias != null)
- {
- foreach (var guiaCotizada in cotizacionGuias)
- {
- if (guiaCotizada.cotizaciones != null)
- {
- var ecoExpress = guiaCotizada.cotizaciones.FirstOrDefault(c => c.tipoServicio.descripcion == "ECOEXPRESS");
- HttpContext.Current.Session["cotizacion"] = ecoExpress;
- var Express = guiaCotizada.cotizaciones.FirstOrDefault(c => c.tipoServicio.descripcion == "EXPRESS");
- HttpContext.Current.Session["cotizacionExpress"] = Express;
- }
- }
- }
- }
- //else
- //{
- // return "Tipo Servicio Incorrecto";
- //}
- return string.Empty;
- }
- #endregion
- #region <<Generar Guía Comentado>>
- [System.Web.Services.WebMethod]
- public static string GenerarGuiaPaquete(Object pJData)
- {
- dynamic data = JsonConvert.DeserializeObject(pJData.ToString());
- dynamic request = data[0];
- var returnValue = string.Empty;
- double precio = data[0]["precio"];
- decimal costo = Convert.ToDecimal(precio / 1.10);
- var guideRequest = new List<PaquetExpress.Guide.Data>
- {
- new PaquetExpress.Guide.Data
- {
- BillRad = "REQUEST", //Quien pagará la solicitud, sólo con REQUEST o ORIGIN pueden ser a crédito
- BillClntId = "5402609", //
- PymtMode = "PAID", //Modo de pago (PAID=PAGADO, TO_PAY=Flete por cobrar)
- PymtType = "C", //Tipo de pago (C:CREDITO, N:CONTADO)
- AddressList = new List<PaquetExpress.Guide.Address>
- {
- new PaquetExpress.Guide.Address
- {
- AddrLin1 = "MEXICO",
- AddrLin3 = request["estadoRemitente"],
- AddrLin4 = request["ciudadRemitente"],
- AddrLin5 = request["coloniaRemitente"],
- AddrLin6 = request["referenciaRemitente"],
- StrtName = request["direccionRemitente"],
- Drnr = "10",
- Phno1 = request["telefonoRemitente"],
- ZipCode = request["codigoPostalRemitente"],
- ClntName = request["nombreRemitente"],
- Email = request["correoRemitente"],
- Contacto = "emissary.mx",
- AddrType = "ORIGIN"
- },
- new PaquetExpress.Guide.Address
- {
- AddrLin1 = "MEXICO",
- AddrLin3 = request["estadoDestinatario"],
- AddrLin4 = request["ciudadDestinatario"],
- AddrLin5 = request["coloniaDestinatario"],
- AddrLin6 = request["referenciaDestinatario"],
- StrtName = request["direccionDestinatario"],
- Drnr = "20",
- Phno1 = request["telefonoDestinatario"],
- ZipCode = request["codigoPostalDestinatario"],
- ClntName = request["nombreDestinatario"],
- Email = request["correoDestinatario"],
- Contacto = "emissary.mx",
- AddrType = "DESTINATION"
- }
- },
- ItemList = new List<PaquetExpress.Guide.Item>
- {
- new PaquetExpress.Guide.Item
- {
- SrvcId = "PACKETS", //Clave de servicio: PACKETS=Paquet es, ENVELOPES=Sob res
- Weight = request["peso"], // Peso
- VolL = request["largo"], // Largo
- VolW = request["ancho"], // Ancho
- VolH = request["alto"], // Alto
- Cont = "PROTESIS",
- Qunt = "1"
- }
- },
- ServiceList = new List<PaquetExpress.Guide.Service>
- {
- new PaquetExpress.Guide.Service
- {
- SrvcId = "EAD", //Clave de servicio: RAD = Recolección a domicilio, EAD= Entrega a domicilio, INV= Valor declarado
- Value1 = "" //importes varios (COD o Seguro)
- },
- new PaquetExpress.Guide.Service
- {
- SrvcId = "RAD",//Clave de servicio: RAD = Recolección a domicilio, EAD= Entrega a domicilio, INV= Valor declarado
- Value1 = "" //importes varios (COD o Seguro)
- }
- }
- }
- };
- var guideResponse = AsyncHelpers.RunSync<PaquetExpress.Guide.Response>(() => PaquetExpress.ServiceGuide.CreateAsync(guideRequest));
- if (guideResponse.Data != null)
- {
- using (WebClient client = new WebClient())
- {
- var service = "https://cc.paquetexpress.com.mx:8082/wsReportPaquetexpress/GenCartaPorte?trackingNoGen=" + guideResponse.Data;
- client.DownloadFile(service, System.Web.HttpContext.Current.Server.MapPath("/Files/produccion/") + guideResponse.Data + ".pdf");
- var guia = guideResponse.Data;
- //string TrackingNo = service.TrackingNumber;
- //string tipoGuia = "2";
- //string TotalPrecio = HttpContext.Current.Session["Dhl_Terrestre"].ToString();
- decimal TotalAmount = costo;
- string tipoServicio = "2";
- returnValue = guardarEnvio(pJData, TotalAmount, guia, tipoServicio);
- }
- }
- return returnValue;
- }
- #endregion
- #region <<Generar Guía DHL Comentado>>
- [System.Web.Services.WebMethod]
- public static string GenerarGuiaDhl(Object pJData)
- {
- string userId = HttpContext.Current.Session["usuario_id"].ToString();
- dynamic Data = JsonConvert.DeserializeObject(pJData.ToString());
- int tipoServicio = Data[0]["tipoServicio"];
- string numeroguiaDhl;
- var returnValue = string.Empty;
- dynamic data = JsonConvert.DeserializeObject(pJData.ToString());
- dynamic request = data[0];
- string Servicio = tipoServicio == 1 ? "ECONOMY SELECT DOMESTIC" : "EXPRESS DOMESTIC";
- var TotalAmount = tipoServicio == 1 ? 135f : 162.50f;
- var shipmentRequest = new Common.Shipment.Request
- {
- ShipmentType = Servicio,
- From = new Common.Address
- {
- Name = request["nombreRemitente"],
- Company = request["nombreRemitente"],
- Email = request["correoRemitente"],
- Phone = request["telefonoRemitente"],
- Address1 = request["direccionRemitente"],
- Address2 = request["coloniaRemitente"],
- Address3 = request["referenciaRemitente"],
- City = request["ciudadRemitente"],
- State = request["estadoRemitente"],
- Country = "Mexico",
- ZipCode = request["codigoPostalRemitente"]
- },
- To = new Common.Address
- {
- Name = request["nombreDestinatario"],
- Company = request["nombreDestinatario"],
- Email = "envios@gmail.com",
- //Email = request["correoDestinatario"],
- Phone = request["telefonoDestinatario"],
- Address1 = request["direccionDestinatario"],
- Address2 = request["coloniaDestinatario"],
- Address3 = request["referenciaDestinatario"],
- City = request["ciudadDestinatario"],
- State = request["estadoDestinatario"],
- Country = "Mexico",
- ZipCode = request["codigoPostalDestinatario"]
- },
- Package = new Common.Package
- {
- Description = request["envio"],
- Value = 2000,
- Quantity = 1,
- Weight = (int)request["peso"],
- Length = Convert.ToInt32(request["largo"]),
- Width = Convert.ToInt32(request["ancho"]),
- Height = Convert.ToInt32(request["alto"])
- },
- };
- var guideData = AsyncHelpers.RunSync<Common.Shipment.Response>(() => Emissary.Dhl.ServiceShipment.CreateAsync(shipmentRequest));
- if (guideData != null)
- {
- using (WebClient client = new WebClient())
- {
- var xxx = guideData.TrackNumber;
- numeroguiaDhl = guideData.TrackNumber;
- var file = guideData.Files.FirstOrDefault(f => f.Contains("TrackDocument"));
- client.DownloadFile(file, System.Web.HttpContext.Current.Server.MapPath("/Files/produccion/") + numeroguiaDhl + ".pdf");
- //string TrackingNo = guideData.TrackNumber;
- string tipoGuia = "2";
- string TrackingNo = numeroguiaDhl;
- returnValue = guardarEnvio(pJData, (decimal)TotalAmount, TrackingNo, tipoGuia);
- }
- }
- //if (tipoServicio == 1)
- //{
- // string servicio = "Terrestre";
- // //VERSION OFICIAL
- // //Cotización Cuenta 1
- // RateWebServiceClient.FedEx.Execute("31eALSU8II86jmE4", "OXrCrRpL0wnxEiR0v9gfrbSEM", "959471452", "112925379", FromAddress, FromCity, "NL", FromPostalCode, FromCountryCode, ReceiverAddress, ReceiverCity, "NL", ReceiverPostalCode, ReceiverCountryCode, 1, Length, Width, Height, Weight, RateWebServiceClient.RateServiceWebReference.ServiceType.FEDEX_EXPRESS_SAVER, ref TotalAmountCuenta1, ref TotalDiscountCuenta1);
- // //Cotización Cuenta 2
- // RateWebServiceClient.FedEx.Execute("dPnfMXBdJITm7S9x", "gHiowUgNb1NbcOMLXjqigM7lG", "912766853", "113250529", FromAddress, FromCity, "NL", FromPostalCode, FromCountryCode, ReceiverAddress, ReceiverCity, "NL", ReceiverPostalCode, ReceiverCountryCode, 1, Length, Width, Height, Weight, RateWebServiceClient.RateServiceWebReference.ServiceType.FEDEX_EXPRESS_SAVER, ref TotalAmountCuenta2, ref TotalDiscountCuenta2);
- // //tipoGuia;
- // if (TotalAmountCuenta1 < TotalAmountCuenta2)
- // {
- // ShipWebServiceClient.FedExShipPackage.PlaceShipment("31eALSU8II86jmE4", "OXrCrRpL0wnxEiR0v9gfrbSEM", "959471452", "112925379", FromName, FromCompany, telefonoFrom, FromAddress, FromColonia, FromCity, FromState, FromPostalCode, FromCountryCode, ReceiverName, ReceiverCompany, ReceiverPhoneNumber, ReceiverAddress, ReceiverColonia, ReceiverCity, ReceiverState, ReceiverPostalCode, ReceiverCountryCode, Quantity, Length, Width, Height, Weight, ShipWebServiceClient.ShipServiceWebReference.ServiceType.FEDEX_EXPRESS_SAVER, ref TrackingNo, ref LabelImage, ref numArray, ref TransportationCharges, ref ServiceCharge, ref TotalCost, false, tipoGuia);
- // TotalAmount = TotalAmountCuenta1;
- // }
- // else
- // {
- // ShipWebServiceClient.FedExShipPackage.PlaceShipment("dPnfMXBdJITm7S9x", "gHiowUgNb1NbcOMLXjqigM7lG", "912766853", "113250529", FromName, FromCompany, telefonoFrom, FromAddress, FromColonia, FromCity, FromState, FromPostalCode, FromCountryCode, ReceiverName, ReceiverCompany, ReceiverPhoneNumber, ReceiverAddress, ReceiverColonia, ReceiverCity, ReceiverState, ReceiverPostalCode, ReceiverCountryCode, Quantity, Length, Width, Height, Weight, ShipWebServiceClient.ShipServiceWebReference.ServiceType.FEDEX_EXPRESS_SAVER, ref TrackingNo, ref LabelImage, ref numArray, ref TransportationCharges, ref ServiceCharge, ref TotalCost, false, tipoGuia);
- // TotalAmount = TotalAmountCuenta2;
- // }
- // //string key, string password, string accountnumber, string meternumber,
- // //VERSION PRUEBA
- // //RateWebServiceClient.FedEx.Execute("p5U6XiI6lzh3IFNh", "lMLDbSqOL0pTPgyI8rnH39JVt", "510087100", "119041229", FromAddress, FromCity, "NL", FromPostalCode, FromCountryCode, ReceiverAddress, ReceiverCity, "NL", ReceiverPostalCode, ReceiverCountryCode, 1, Length, Width, Height, Weight, RateWebServiceClient.RateServiceWebReference.ServiceType.FEDEX_EXPRESS_SAVER, ref TotalAmount, ref TotalDiscount);
- // //ShipWebServiceClient.FedExShipPackage.PlaceShipment("p5U6XiI6lzh3IFNh", "lMLDbSqOL0pTPgyI8rnH39JVt", "510087100", "119041229", FromName, FromCompany, telefonoFrom, FromAddress, FromCity, FromState, FromPostalCode, FromCountryCode, ReceiverName, ReceiverCompany, ReceiverPhoneNumber, ReceiverAddress, ReceiverCity, ReceiverState, ReceiverPostalCode, ReceiverCountryCode, Quantity, Length, Width, Height, Weight, ShipWebServiceClient.ShipServiceWebReference.ServiceType.FEDEX_EXPRESS_SAVER, ref TrackingNo, ref LabelImage, ref numArray, ref TransportationCharges, ref ServiceCharge, ref TotalCost, false);
- // returnValue = guardarEnvio(pJData, TotalAmount, TrackingNo, tipoGuia);
- //}
- ///Generar Guía DHL
- //var returnValue = string.Empty;
- //dynamic data = JsonConvert.DeserializeObject(pJData.ToString());
- //dynamic request = data[0];
- return returnValue;
- }
- #endregion
- #region <<Generar Guía>>
- [WebMethod]
- //public static string Guardar(string jData)
- public static string generarGuia(Object pJData)
- {
- var returnValue = string.Empty;
- try
- {
- dynamic Data = JsonConvert.DeserializeObject(pJData.ToString());
- //GenerarGuiaDhl(pJData);
- int paqueteriaId = Data[0]["paqueteriaId"];
- int ordenId = Data[0]["ordenId"];
- if (paqueteriaId == 1)
- {
- returnValue = generarGuiaFedex(pJData);
- }
- else if (paqueteriaId == 2)
- {
- //ObtenerCotizacionRedpack(pJData);
- returnValue = generarGuiaRedpack(pJData);
- }
- else if (paqueteriaId == 3)
- {
- returnValue = generarGuiaFedexPesados(pJData);
- }
- else if (paqueteriaId == 4)
- {
- returnValue = GenerarGuiaDhl(pJData);
- }
- else if (paqueteriaId == 5)
- {
- returnValue = GenerarGuiaPaquete(pJData);
- }
- if (ordenId > 0)
- {
- string mensaje = "";
- DataTable DataTable = new DataTable();
- dbo.BaseDatos db = null;
- db = new dbo.BaseDatos(ConfigurationManager.ConnectionStrings["cnn"].ToString());
- SqlParameter prmOrden;
- try
- {
- prmOrden = new SqlParameter("@ordenId", SqlDbType.BigInt);
- prmOrden.Value = ordenId;
- DataTable = db.ObtenerDatosComoDataTable("spac_Emissary_OrdenGenerada", prmOrden);
- DataTable.TableName = "OrdenGenerada ";
- mensaje = JsonConvert.SerializeObject(DataTable);
- }
- catch (Exception ex)
- {
- mensaje = ex.Message;
- }
- finally
- {
- db.Finalizar();
- }
- }
- }
- catch (Exception ex)
- {
- returnValue = ex.Message + " -- --" + ex.StackTrace;
- }
- return returnValue;
- }
- #endregion <<Guardar>>
- #region <<Generar Guía Redpack>>
- [WebMethod]
- public static string generarGuiaRedpack(Object pJData)
- {
- dynamic Data = JsonConvert.DeserializeObject(pJData.ToString());
- ObtenerCotizacionRedpack(pJData);
- int tipoServicioRedpack = Data[0]["tipoServicio"];
- int peso = Data[0]["peso"];
- var returnValue = string.Empty;
- int numGuiaGenerada;
- var tipoGuia = consultarTipoGuiaRedpack();
- if (tipoServicioRedpack == 1)
- {
- decimal TotalDiscount = 0, TotalAmount = 0;
- decimal TotalDiscountExpress = 0, TotalAmountExpress = 0;
- webServiceRedpack.Cotizacion ecoExpress = (webServiceRedpack.Cotizacion)HttpContext.Current.Session["cotizacion"];
- var costoTotal = ecoExpress.tarifa;
- decimal DescuentoTotal = TotalDiscount;
- decimal CostoTotalExpress = TotalAmountExpress;
- decimal DescuentoTotalExpress = TotalDiscountExpress;
- int idUser;
- string pin;
- if (peso == 1)
- {
- idUser = 1127;
- pin = "PROD oNmnqC0wC1OKtdtGe8TaA663C2+gFNOX5kwuSaAvj70=";
- }
- else
- {
- idUser = 1332;
- pin = "PROD oNmnqC0wC1PIP4xOOi+XU9mBaDD3H/WaXerHWc+YTv6/TY1QB+hqLQ==";
- }
- string nuevoFolio;
- string folio = "";
- DataTable DataTable = new DataTable();
- dbo.BaseDatos db = null;
- db = new dbo.BaseDatos(ConfigurationManager.ConnectionStrings["cnn"].ToString());
- SqlParameter prmTipoServicioR, prmPeso;
- try
- {
- prmTipoServicioR = new SqlParameter("@tipoServicio", SqlDbType.Int);
- prmTipoServicioR.Value = tipoServicioRedpack;
- prmPeso = new SqlParameter("@peso", SqlDbType.Int);
- prmPeso.Value = peso;
- DataTable = db.ObtenerDatosComoDataTable("[spq_UltimoFolioRedpackUsado]", prmTipoServicioR, prmPeso);
- DataTable.TableName = "Direcciones";
- folio = JsonConvert.SerializeObject(DataTable);
- nuevoFolio = DataTable.Rows[0]["folio"].ToString();
- var wsClient = new webServiceRedpack.RedpackWS();
- var guia = new webServiceRedpack.Guia
- {
- paquetes = new webServiceRedpack.Paquete[] { DeserializaPaquete(pJData) },
- consignatario = DeserializaConsignatario(pJData),
- remitente = DeserializaRemitente(pJData),
- tipoEntrega = new webServiceRedpack.IdDesc { id = 2, idSpecified = true },
- tipoEnvio = new webServiceRedpack.IdDesc { id = 2, idSpecified = true },
- tipoServicio = new webServiceRedpack.IdDesc { id = 2, idSpecified = true },
- moneda = "1",
- referencia = Data[0]["referenciaDestinatario"],
- numeroDeGuia = nuevoFolio,
- flag = 2,
- flagSpecified = true
- };
- var guiaGenerada = wsClient.predocumentacion(pin, idUser, true, new webServiceRedpack.Guia[] { guia });
- string LabelPath = System.Web.HttpContext.Current.Server.MapPath("/Files/produccion/");
- if (guiaGenerada[0].paquetes[0].formatoEtiqueta != null)
- {
- numGuiaGenerada = Convert.ToInt32(guiaGenerada[0].numeroDeGuia + DateTime.Now.Ticks.ToString());
- var LabelFile = new FileStream(LabelPath + numGuiaGenerada + ".pdf", FileMode.Create);
- LabelFile.Write(guiaGenerada[0].paquetes[0].formatoEtiqueta, 0, guiaGenerada[0].paquetes[0].formatoEtiqueta.Length);
- LabelFile.Close();
- }
- else
- {
- string numGuia;
- for (int i = 0; i < 100; i++)
- {
- if (guiaGenerada[0].resultadoConsumoWS[0].estatus == 58 || guiaGenerada[0].resultadoConsumoWS[0].estatus == 59)
- {
- nuevoFolio = DataTable.Rows[0]["folio"].ToString();
- int newFolio = Int32.Parse(nuevoFolio) + i;
- nuevoFolio = newFolio.ToString();
- wsClient = new webServiceRedpack.RedpackWS();
- guia = new webServiceRedpack.Guia
- {
- paquetes = new webServiceRedpack.Paquete[] { DeserializaPaquete(pJData) },
- consignatario = DeserializaConsignatario(pJData),
- remitente = DeserializaRemitente(pJData),
- tipoEntrega = new webServiceRedpack.IdDesc { id = 2, idSpecified = true },
- tipoEnvio = new webServiceRedpack.IdDesc { id = 2, idSpecified = true },
- tipoServicio = new webServiceRedpack.IdDesc { id = 2, idSpecified = true },
- moneda = "1",
- referencia = Data[0]["referenciaDestinatario"],
- numeroDeGuia = nuevoFolio + i,
- //numeroDeGuia = idUser.ToString() + DateTime.Now.Millisecond.ToString(),
- flag = 2,
- flagSpecified = true
- };
- guiaGenerada = wsClient.predocumentacion(pin, idUser, true, new webServiceRedpack.Guia[] { guia });
- LabelPath = System.Web.HttpContext.Current.Server.MapPath("/Files/produccion/");
- if (guiaGenerada[0].paquetes[0].formatoEtiqueta != null)
- {
- numGuia = guiaGenerada[0].numeroDeGuia;
- numGuiaGenerada = Convert.ToInt32(guiaGenerada[0].numeroDeGuia);
- var LabelFile = new FileStream(LabelPath + numGuiaGenerada + ".pdf", FileMode.Create);
- LabelFile.Write(guiaGenerada[0].paquetes[0].formatoEtiqueta, 0, guiaGenerada[0].paquetes[0].formatoEtiqueta.Length);
- LabelFile.Close();
- break;
- }
- }
- }
- }
- DataTable = new DataTable();
- db = null;
- SqlParameter prmFolio, prmNoTracking, prmTipoServicio, prmPesoEnviado;
- try
- {
- db = new dbo.BaseDatos(ConfigurationManager.ConnectionStrings["cnn"].ToString());
- numGuiaGenerada = Convert.ToInt32(guiaGenerada[0].numeroDeGuia);
- prmFolio = new SqlParameter("@Folio", SqlDbType.NVarChar, 50);
- prmFolio.Value = guiaGenerada[0].numeroDeGuia;
- prmNoTracking = new SqlParameter("@NoTracking", SqlDbType.NVarChar, 50);
- prmNoTracking.Value = numGuiaGenerada;
- prmTipoServicio = new SqlParameter("@tipoServicio", SqlDbType.NVarChar, 50);
- prmTipoServicio.Value = tipoServicioRedpack;
- prmPesoEnviado = new SqlParameter("@peso", SqlDbType.NVarChar, 50);
- prmPesoEnviado.Value = peso;
- DataTable = db.ObtenerDatosComoDataTable("spa_Emissary_FolioRedpack2019", prmFolio, prmNoTracking, prmTipoServicio, prmPesoEnviado);
- //dataset.TableName = "Usuario";
- //[spac_Emissary_Direccion]
- //mensaje = JsonConvert.SerializeObject(DataTable);
- }
- finally
- {
- string mensaje = "OK";
- }
- string TrackingNo = Convert.ToString(numGuiaGenerada);
- returnValue = guardarEnvio(pJData, (decimal)costoTotal, TrackingNo, tipoGuia);
- }
- catch (Exception ex)
- {
- returnValue = ex.Message + " -- " + ex.StackTrace.ToString();
- folio = ex.Message;
- }
- finally
- {
- db.Finalizar();
- }
- }
- else if (tipoServicioRedpack == 2)
- {
- string servicio = "Áereo";
- decimal TotalDiscount = 0, TotalAmount = 0;
- decimal TotalDiscountExpress = 0, TotalAmountExpress = 0;
- webServiceRedpack.Cotizacion Express = (webServiceRedpack.Cotizacion)HttpContext.Current.Session["cotizacionExpress"];
- var costoTotal = Express.tarifa;
- decimal DescuentoTotal = TotalDiscount;
- decimal CostoTotalExpress = TotalAmountExpress;
- decimal DescuentoTotalExpress = TotalDiscountExpress;
- //var idUser = 1127;
- var idUser = 1332;
- string pin = "PROD oNmnqC0wC1PIP4xOOi+XU9mBaDD3H/WaXerHWc+YTv6/TY1QB+hqLQ==";
- //var idUser = 1127;
- //string pin= "PROD oNmnqC0wC1OKtdtGe8TaA663C2+gFNOX5kwuSaAvj70=";
- string nuevoFolio;
- string folio = "";
- DataTable DataTable = new DataTable();
- dbo.BaseDatos db = null;
- db = new dbo.BaseDatos(ConfigurationManager.ConnectionStrings["cnn"].ToString());
- SqlParameter prmTipoServicioR, prmPeso;
- try
- {
- prmTipoServicioR = new SqlParameter("@tipoServicio", SqlDbType.Int);
- prmTipoServicioR.Value = tipoServicioRedpack;
- prmPeso = new SqlParameter("@peso", SqlDbType.Int);
- prmPeso.Value = peso;
- DataTable = db.ObtenerDatosComoDataTable("[spq_UltimoFolioRedpackUsado]", prmTipoServicioR, prmPeso);
- DataTable.TableName = "Direcciones";
- folio = JsonConvert.SerializeObject(DataTable);
- nuevoFolio = DataTable.Rows[0]["folio"].ToString();
- var wsClient = new webServiceRedpack.RedpackWS();
- var guia = new webServiceRedpack.Guia
- {
- paquetes = new webServiceRedpack.Paquete[] { DeserializaPaquete(pJData) },
- consignatario = DeserializaConsignatario(pJData),
- remitente = DeserializaRemitente(pJData),
- tipoEntrega = new webServiceRedpack.IdDesc { id = 2, idSpecified = true },
- tipoEnvio = new webServiceRedpack.IdDesc { id = 2, idSpecified = true },
- tipoServicio = new webServiceRedpack.IdDesc { id = 2, idSpecified = true },
- moneda = "1",
- referencia = Data[0]["referenciaDestinatario"],
- numeroDeGuia = nuevoFolio,
- flag = 2,
- flagSpecified = true
- };
- var guiaGenerada = wsClient.predocumentacion(pin, idUser, true, new webServiceRedpack.Guia[] { guia });
- string LabelPath = System.Web.HttpContext.Current.Server.MapPath("/Files/produccion/");
- if (guiaGenerada[0].paquetes[0].formatoEtiqueta != null)
- {
- numGuiaGenerada = Convert.ToInt32(guiaGenerada[0].numeroDeGuia);
- var LabelFile = new FileStream(LabelPath + numGuiaGenerada + ".pdf", FileMode.Create);
- LabelFile.Write(guiaGenerada[0].paquetes[0].formatoEtiqueta, 0, guiaGenerada[0].paquetes[0].formatoEtiqueta.Length);
- LabelFile.Close();
- }
- else
- {
- string numGuia;
- for (int i = 0; i < 10; i++)
- {
- if (guiaGenerada[0].resultadoConsumoWS[0].estatus == 58 || guiaGenerada[0].resultadoConsumoWS[0].estatus == 59)
- {
- nuevoFolio = DataTable.Rows[0]["folio"].ToString();
- int newFolio = Int32.Parse(nuevoFolio) + i;
- nuevoFolio = newFolio.ToString();
- wsClient = new webServiceRedpack.RedpackWS();
- guia = new webServiceRedpack.Guia
- {
- paquetes = new webServiceRedpack.Paquete[] { DeserializaPaquete(pJData) },
- consignatario = DeserializaConsignatario(pJData),
- remitente = DeserializaRemitente(pJData),
- tipoEntrega = new webServiceRedpack.IdDesc { id = 2, idSpecified = true },
- tipoEnvio = new webServiceRedpack.IdDesc { id = 2, idSpecified = true },
- tipoServicio = new webServiceRedpack.IdDesc { id = 2, idSpecified = true },
- moneda = "1",
- referencia = Data[0]["referenciaDestinatario"],
- numeroDeGuia = nuevoFolio + i,
- //numeroDeGuia = idUser.ToString() + DateTime.Now.Millisecond.ToString(),
- flag = 2,
- flagSpecified = true
- };
- guiaGenerada = wsClient.predocumentacion(pin, idUser, true, new webServiceRedpack.Guia[] { guia });
- LabelPath = System.Web.HttpContext.Current.Server.MapPath("/Files/produccion/");
- if (guiaGenerada[0].paquetes[0].formatoEtiqueta != null)
- {
- numGuiaGenerada = Convert.ToInt32(guiaGenerada[0].numeroDeGuia);
- numGuia = guiaGenerada[0].numeroDeGuia;
- var LabelFile = new FileStream(LabelPath + numGuiaGenerada + ".pdf", FileMode.Create);
- LabelFile.Write(guiaGenerada[0].paquetes[0].formatoEtiqueta, 0, guiaGenerada[0].paquetes[0].formatoEtiqueta.Length);
- LabelFile.Close();
- break;
- }
- }
- }
- }
- DataTable = new DataTable();
- db = null;
- SqlParameter prmFolio, prmNoTracking, prmTipoServicio;
- try
- {
- db = new dbo.BaseDatos(ConfigurationManager.ConnectionStrings["cnn"].ToString());
- numGuiaGenerada = Convert.ToInt32(guiaGenerada[0].numeroDeGuia);
- prmFolio = new SqlParameter("@Folio", SqlDbType.BigInt);
- prmFolio.Value = guia.numeroDeGuia;
- prmNoTracking = new SqlParameter("@NoTracking", SqlDbType.NVarChar, 50);
- prmNoTracking.Value = numGuiaGenerada;
- prmTipoServicio = new SqlParameter("@tipoServicio", SqlDbType.NVarChar, 50);
- prmTipoServicio.Value = 2;
- DataTable = db.ObtenerDatosComoDataTable("spa_Emissary_FolioRedpack", prmFolio, prmNoTracking, prmTipoServicio);
- //dataset.TableName = "Usuario";
- //[spac_Emissary_Direccion]
- //mensaje = JsonConvert.SerializeObject(DataTable);
- }
- finally
- {
- string mensaje = "OK";
- }
- numGuiaGenerada = Convert.ToInt32(guiaGenerada[0].numeroDeGuia);
- string TrackingNo = Convert.ToString(numGuiaGenerada);
- returnValue = guardarEnvio(pJData, (decimal)costoTotal, TrackingNo, tipoGuia);
- // string folio = "";
- //DataTable DataTable = new DataTable();
- //dbo.BaseDatos db = null;
- //db = new dbo.BaseDatos(ConfigurationManager.ConnectionStrings["cnn"].ToString());
- //SqlParameter prmUserId;
- //try
- //{
- // DataTable = db.ObtenerDatosComoDataTable("spq_Emissary_UltimoFolioRedpackExpress");
- // DataTable.TableName = "Direcciones";
- }
- catch (Exception ex)
- {
- folio = ex.Message;
- }
- finally
- {
- db.Finalizar();
- }
- }
- return returnValue;
- }
- [WebMethod]
- public static string generarGuiaRedpack(string key, string password, string accountnumber, string meternumber, string FromAddress, string FromCity, string FromState, string FromPostalCode, string FromCountryCode, string ToAddress, string ToCity, string ToState, string ToPostalCode, string ToCountryCode, int Quantity, int Length, int Width, int Height, decimal Weight)
- {
- //var wsClient = new webServiceRedpack.RedpackWS();
- //var paquete = new webServiceRedpack.Paquete
- //{
- // alto = Length,
- // altoSpecified = true,
- // ancho = Width,
- // anchoSpecified = true,
- // peso = (float)Weight,
- // largo = Length,
- // largoSpecified = true
- //};
- //var guia = new webServiceRedpack.Guia
- //{
- // paquetes = new webServiceRedpack.Paquete[] { paquete },
- // consignatario = new webServiceRedpack.Direccion { codigoPostal = Int32.Parse(FromPostalCode), codigoPostalSpecified = true },
- // remitente = new webServiceRedpack.Direccion { codigoPostal = Int32.Parse(ToPostalCode), codigoPostalSpecified = true },
- // tipoEntrega = new webServiceRedpack.IdDesc { id = 2 },
- // flag = 1
- //};
- //var response = wsClient.cotizacionNacional("PROD oNmnqC0wC1OKtdtGe8TaA663C2+gFNOX5kwuSaAvj70=", 1127, new webServiceRedpack.Guia[] { guia });
- //var guias = wsClient.generaGuiaElectronica("PROD oNmnqC0wC1OKtdtGe8TaA663C2+gFNOX5kwuSaAvj70=", 1127, new webServiceRedpack.Guia[] { guia });
- string userId = HttpContext.Current.Session["usuario_id"].ToString();
- return userId;
- }
- #endregion <<Cotizar Redpack>>
- public static string generarGuiaFedex(Object pJData)
- {
- dynamic Data = JsonConvert.DeserializeObject(pJData.ToString());
- int tipoServicio = Data[0]["tipoServicio"];
- Int64 envioId;
- string userId = HttpContext.Current.Session["usuario_id"].ToString();
- //REMITENTE
- //string tipoServicio;
- string precio;
- //REMITENTE
- string nombreRemitente;
- string correoRemitente;
- string telefonoRemitente;
- string direccionRemitente;
- string referenciaRemitente;
- string coloniaRemitente;
- string codigoPostalRemitente;
- string ciudadRemitente;
- string estadoRemitente;
- //DESTINATARIO
- string nombreDestinatario;
- string correoDestinatario;
- string telefonoDestinatario;
- string direccionDestinatario;
- string referenciaDestinatario;
- string coloniaDestinatario;
- string codigoPostalDestinatario;
- string ciudadDestinatario;
- string estadoDestinatario;
- //DIMENSIONES
- string largo;
- string ancho;
- string alto;
- string peso;
- string envio;
- int paqueteriaId;
- //dynamic Data = JsonConvert.DeserializeObject(pJData.ToString());
- tipoServicio = Data[0]["tipoServicio"]; //FromName
- precio = Data[0]["precio"]; //FromeMail
- //envioId = Data[0]["envioId"];
- //GENERALES
- nombreRemitente = Data[0]["nombreRemitente"]; //FromName
- correoRemitente = Data[0]["correoRemitente"]; //FromeMail
- telefonoRemitente = Data[0]["telefonoRemitente"]; //FromPhone
- direccionRemitente = Data[0]["direccionRemitente"]; //FromStreth
- referenciaRemitente = Data[0]["referenciaRemitente"]; //FromComents
- coloniaRemitente = Data[0]["coloniaRemitente"]; //FromAdress
- codigoPostalRemitente = Data[0]["codigoPostalRemitente"]; //FromPostalCode
- ciudadRemitente = Data[0]["ciudadRemitente"]; //City
- estadoRemitente = Data[0]["estadoRemitente"]; //FromCity
- //string telefonoFrom = "+518119173228"; //FromPhone correct
- //DESTINATARIO
- nombreDestinatario = Data[0]["nombreDestinatario"]; //To NAme
- //correoDestinatario = Data[0]["correoDestinatario"] +"" ;//ToMail
- correoDestinatario = "envios@gmail.com";//ToMail
- telefonoDestinatario = Data[0]["telefonoDestinatario"]; //ToPhone
- direccionDestinatario = Data[0]["direccionDestinatario"]; //ToStreth
- referenciaDestinatario = Data[0]["referenciaDestinatario"]; //ToComents
- coloniaDestinatario = Data[0]["coloniaDestinatario"]; //ToAdress
- codigoPostalDestinatario = Data[0]["codigoPostalDestinatario"]; //ToPostalCOde
- ciudadDestinatario = Data[0]["ciudadDestinatario"]; //ToCity
- estadoDestinatario = Data[0]["estadoDestinatario"]; //ToCity
- //string telefonoTo = "+52" + telefonoDestinatario; //FromPhone correct
- //DIMENSIONES
- largo = Data[0]["largo"];
- ancho = Data[0]["ancho"];
- alto = Data[0]["alto"];
- peso = Data[0]["peso"];
- envio = Data[0]["envio"];
- //PAQUETERIA
- paqueteriaId = Data[0]["paqueteriaId"];
- string mensaje = string.Empty;
- string FromName = nombreRemitente;
- string FromCompany = "Emissary";
- string FromAddress = direccionRemitente;
- string FromColonia = coloniaRemitente;
- string FromReference = referenciaRemitente;
- string FromCity = ciudadRemitente;
- string FromState = estadoRemitente;
- string FromPostalCode = codigoPostalRemitente;
- string FromCountryCode = "MX";
- string telefonoFrom = telefonoRemitente;
- string ReceiverName = nombreDestinatario;
- string ReceiverCompany = "Emissary";
- string ReceiverPhoneNumber = telefonoDestinatario;
- string ReceiverAddress = direccionDestinatario;
- string ReceiverColonia = coloniaDestinatario;
- string ReceiverReference = referenciaDestinatario;
- string ReceiverCity = ciudadDestinatario;
- string ReceiverState = estadoDestinatario;
- string ReceiverPostalCode = codigoPostalDestinatario;
- string ReceiverCountryCode = "MX";
- string telefonoTo = telefonoDestinatario;
- int Quantity = 1;
- int Length = int.Parse(largo);
- int Width = int.Parse(ancho);
- int Height = int.Parse(alto);
- decimal Weight = decimal.Parse(peso);
- byte[] numArray = null;
- string TrackingNo = string.Empty;
- string LabelImage = string.Empty;
- string wsResponseDescription = string.Empty;
- string wsResponseStatus = string.Empty;
- string ShipmentIdentificationNumber = string.Empty;
- string TransportationCharges = string.Empty;
- string ServiceCharge = string.Empty;
- string TotalCost = string.Empty;
- decimal TotalDiscountCuenta1 = 0, TotalAmountCuenta1 = 0;
- decimal TotalDiscountCuenta2 = 0, TotalAmountCuenta2 = 0;
- decimal TotalAmount;
- var returnValue = string.Empty;
- var tipoGuia = consultarTipoGuiaFedex();
- if (tipoServicio == 1)
- {
- string servicio = "Terrestre";
- //VERSION OFICIAL
- //Pesoprueba
- //Cotización Cuenta 1
- RateWebServiceClient.FedEx.Execute("31eALSU8II86jmE4", "OXrCrRpL0wnxEiR0v9gfrbSEM", "959471452", "112925379", FromAddress, FromCity, "NL", FromPostalCode, FromCountryCode, ReceiverAddress, ReceiverCity, "NL", ReceiverPostalCode, ReceiverCountryCode, 1, Length, Width, Height, Weight, RateWebServiceClient.RateServiceWebReference.ServiceType.FEDEX_EXPRESS_SAVER, ref TotalAmountCuenta1, ref TotalDiscountCuenta1);
- //Cotización Cuenta 2
- RateWebServiceClient.FedEx.Execute("dPnfMXBdJITm7S9x", "gHiowUgNb1NbcOMLXjqigM7lG", "912766853", "113250529", FromAddress, FromCity, "NL", FromPostalCode, FromCountryCode, ReceiverAddress, ReceiverCity, "NL", ReceiverPostalCode, ReceiverCountryCode, 1, Length, Width, Height, Weight, RateWebServiceClient.RateServiceWebReference.ServiceType.FEDEX_EXPRESS_SAVER, ref TotalAmountCuenta2, ref TotalDiscountCuenta2);
- if (TotalAmountCuenta1 < TotalAmountCuenta2)
- {
- ShipWebServiceClient.FedExShipPackage.PlaceShipment("31eALSU8II86jmE4", "OXrCrRpL0wnxEiR0v9gfrbSEM", "959471452", "112925379", FromName, FromCompany, telefonoFrom, FromAddress, FromColonia, FromReference, FromCity, FromState, FromPostalCode, FromCountryCode, ReceiverName, ReceiverCompany, ReceiverPhoneNumber, ReceiverAddress, ReceiverColonia, ReceiverReference, ReceiverCity, ReceiverState, ReceiverPostalCode, ReceiverCountryCode, Quantity, Length, Width, Height, Weight, ShipWebServiceClient.ShipServiceWebReference.ServiceType.FEDEX_EXPRESS_SAVER, ref TrackingNo, ref LabelImage, ref numArray, ref TransportationCharges, ref ServiceCharge, ref TotalCost, false, tipoGuia);
- TotalAmount = TotalAmountCuenta1;
- }
- else
- {
- ShipWebServiceClient.FedExShipPackage.PlaceShipment("dPnfMXBdJITm7S9x", "gHiowUgNb1NbcOMLXjqigM7lG", "912766853", "113250529", FromName, FromCompany, telefonoFrom, FromAddress, FromColonia, FromReference, FromCity, FromState, FromPostalCode, FromCountryCode, ReceiverName, ReceiverCompany, ReceiverPhoneNumber, ReceiverAddress, ReceiverColonia, ReceiverReference, ReceiverCity, ReceiverState, ReceiverPostalCode, ReceiverCountryCode, Quantity, Length, Width, Height, Weight, ShipWebServiceClient.ShipServiceWebReference.ServiceType.FEDEX_EXPRESS_SAVER, ref TrackingNo, ref LabelImage, ref numArray, ref TransportationCharges, ref ServiceCharge, ref TotalCost, false, tipoGuia);
- TotalAmount = TotalAmountCuenta2;
- }
- //ShipWebServiceClient.FedExShipPackage.PlaceShipment("31eALSU8II86jmE4", "OXrCrRpL0wnxEiR0v9gfrbSEM", "959471452", "112925379", FromName, FromCompany, telefonoFrom, FromAddress, FromColonia, FromCity, FromState, FromPostalCode, FromCountryCode, ReceiverName, ReceiverCompany, ReceiverPhoneNumber, ReceiverAddress, ReceiverColonia, ReceiverCity, ReceiverState, ReceiverPostalCode, ReceiverCountryCode, Quantity, Length, Width, Height, Weight, ShipWebServiceClient.ShipServiceWebReference.ServiceType.FEDEX_EXPRESS_SAVER, ref TrackingNo, ref LabelImage, ref numArray, ref TransportationCharges, ref ServiceCharge, ref TotalCost, false, tipoGuia);
- //TotalAmount = TotalAmountCuenta1;
- //tipoGuia;
- //if CUENTA GRANDE
- //if (TotalAmountCuenta1 < TotalAmountCuenta2)
- //{
- // ShipWebServiceClient.FedExShipPackage.PlaceShipment("31eALSU8II86jmE4", "OXrCrRpL0wnxEiR0v9gfrbSEM", "959471452", "112925379", FromName, FromCompany, telefonoFrom, FromAddress, FromColonia, FromCity, FromState, FromPostalCode, FromCountryCode, ReceiverName, ReceiverCompany, ReceiverPhoneNumber, ReceiverAddress, ReceiverColonia, ReceiverCity, ReceiverState, ReceiverPostalCode, ReceiverCountryCode, Quantity, Length, Width, Height, Weight, ShipWebServiceClient.ShipServiceWebReference.ServiceType.FEDEX_EXPRESS_SAVER, ref TrackingNo, ref LabelImage, ref numArray, ref TransportationCharges, ref ServiceCharge, ref TotalCost, false,tipoGuia);
- // TotalAmount = TotalAmountCuenta1;
- //}
- //else
- //{
- // ShipWebServiceClient.FedExShipPackage.PlaceShipment("dPnfMXBdJITm7S9x", "gHiowUgNb1NbcOMLXjqigM7lG", "912766853", "113250529", FromName, FromCompany, telefonoFrom, FromAddress, FromColonia, FromCity, FromState, FromPostalCode, FromCountryCode, ReceiverName, ReceiverCompany, ReceiverPhoneNumber, ReceiverAddress, ReceiverColonia, ReceiverCity, ReceiverState, ReceiverPostalCode, ReceiverCountryCode, Quantity, Length, Width, Height, Weight, ShipWebServiceClient.ShipServiceWebReference.ServiceType.FEDEX_EXPRESS_SAVER, ref TrackingNo, ref LabelImage, ref numArray, ref TransportationCharges, ref ServiceCharge, ref TotalCost, false,tipoGuia);
- // TotalAmount = TotalAmountCuenta2;
- //}
- //string key, string password, string accountnumber, string meternumber,
- //VERSION PRUEBA
- //RateWebServiceClient.FedEx.Execute("p5U6XiI6lzh3IFNh", "lMLDbSqOL0pTPgyI8rnH39JVt", "510087100", "119041229", FromAddress, FromCity, "NL", FromPostalCode, FromCountryCode, ReceiverAddress, ReceiverCity, "NL", ReceiverPostalCode, ReceiverCountryCode, 1, Length, Width, Height, Weight, RateWebServiceClient.RateServiceWebReference.ServiceType.FEDEX_EXPRESS_SAVER, ref TotalAmount, ref TotalDiscount);
- //ShipWebServiceClient.FedExShipPackage.PlaceShipment("p5U6XiI6lzh3IFNh", "lMLDbSqOL0pTPgyI8rnH39JVt", "510087100", "119041229", FromName, FromCompany, telefonoFrom, FromAddress, FromCity, FromState, FromPostalCode, FromCountryCode, ReceiverName, ReceiverCompany, ReceiverPhoneNumber, ReceiverAddress, ReceiverCity, ReceiverState, ReceiverPostalCode, ReceiverCountryCode, Quantity, Length, Width, Height, Weight, ShipWebServiceClient.ShipServiceWebReference.ServiceType.FEDEX_EXPRESS_SAVER, ref TrackingNo, ref LabelImage, ref numArray, ref TransportationCharges, ref ServiceCharge, ref TotalCost, false);
- returnValue = guardarEnvio(pJData, TotalAmount, TrackingNo, tipoGuia);
- }
- //else if(tipoServicio ==2)
- else if (tipoServicio == 2)
- {
- //var tipoGuia = consultarTipoGuiaFedex();
- string servicio = "Áereo";
- //VERSION OFICIAL
- //Cotización Cuenta 1
- RateWebServiceClient.FedEx.Execute("31eALSU8II86jmE4", "OXrCrRpL0wnxEiR0v9gfrbSEM", "959471452", "112925379", FromAddress, FromCity, "NL", FromPostalCode, FromCountryCode, ReceiverAddress, ReceiverCity, "NL", ReceiverPostalCode, ReceiverCountryCode, 1, Length, Width, Height, Weight, RateWebServiceClient.RateServiceWebReference.ServiceType.STANDARD_OVERNIGHT, ref TotalAmountCuenta1, ref TotalDiscountCuenta1);
- //Cotización Cuenta 2
- RateWebServiceClient.FedEx.Execute("dPnfMXBdJITm7S9x", "gHiowUgNb1NbcOMLXjqigM7lG", "912766853", "113250529", FromAddress, FromCity, "NL", FromPostalCode, FromCountryCode, ReceiverAddress, ReceiverCity, "NL", ReceiverPostalCode, ReceiverCountryCode, 1, Length, Width, Height, Weight, RateWebServiceClient.RateServiceWebReference.ServiceType.STANDARD_OVERNIGHT, ref TotalAmountCuenta2, ref TotalDiscountCuenta2);
- //if AEREO
- if (TotalAmountCuenta1 < TotalAmountCuenta2)
- {
- ShipWebServiceClient.FedExShipPackage.PlaceShipment("31eALSU8II86jmE4", "OXrCrRpL0wnxEiR0v9gfrbSEM", "959471452", "112925379", FromName, FromCompany, telefonoFrom, FromAddress, FromColonia, FromReference, FromCity, FromState, FromPostalCode, FromCountryCode, ReceiverName, ReceiverCompany, ReceiverPhoneNumber, ReceiverAddress, ReceiverColonia, ReceiverReference, ReceiverCity, ReceiverState, ReceiverPostalCode, ReceiverCountryCode, Quantity, Length, Width, Height, Weight, ShipWebServiceClient.ShipServiceWebReference.ServiceType.STANDARD_OVERNIGHT, ref TrackingNo, ref LabelImage, ref numArray, ref TransportationCharges, ref ServiceCharge, ref TotalCost, false, tipoGuia);
- TotalAmount = TotalAmountCuenta1;
- }
- else
- {
- ShipWebServiceClient.FedExShipPackage.PlaceShipment("dPnfMXBdJITm7S9x", "gHiowUgNb1NbcOMLXjqigM7lG", "912766853", "113250529", FromName, FromCompany, telefonoFrom, FromAddress, FromColonia, FromReference, FromCity, FromState, FromPostalCode, FromCountryCode, ReceiverName, ReceiverCompany, ReceiverPhoneNumber, ReceiverAddress, ReceiverColonia, ReceiverReference, ReceiverCity, ReceiverState, ReceiverPostalCode, ReceiverCountryCode, Quantity, Length, Width, Height, Weight, ShipWebServiceClient.ShipServiceWebReference.ServiceType.STANDARD_OVERNIGHT, ref TrackingNo, ref LabelImage, ref numArray, ref TransportationCharges, ref ServiceCharge, ref TotalCost, false, tipoGuia);
- TotalAmount = TotalAmountCuenta2;
- }
- //ShipWebServiceClient.FedExShipPackage.PlaceShipment("31eALSU8II86jmE4", "OXrCrRpL0wnxEiR0v9gfrbSEM", "959471452", "112925379", FromName, FromCompany, telefonoFrom, FromAddress, FromColonia, FromCity, FromState, FromPostalCode, FromCountryCode, ReceiverName, ReceiverCompany, ReceiverPhoneNumber, ReceiverAddress, ReceiverColonia, ReceiverCity, ReceiverState, ReceiverPostalCode, ReceiverCountryCode, Quantity, Length, Width, Height, Weight, ShipWebServiceClient.ShipServiceWebReference.ServiceType.STANDARD_OVERNIGHT, ref TrackingNo, ref LabelImage, ref numArray, ref TransportationCharges, ref ServiceCharge, ref TotalCost, false, tipoGuia);
- //TotalAmount = TotalAmountCuenta1;
- //RateWebServiceClient.FedEx.Execute("p5U6XiI6lzh3IFNh", "lMLDbSqOL0pTPgyI8rnH39JVt", "510087100", "119041229", FromAddress, FromCity, "NL", FromPostalCode, FromCountryCode, ReceiverAddress, ReceiverCity, "NL", ReceiverPostalCode, ReceiverCountryCode, 1, Length, Width, Height, Weight, RateWebServiceClient.RateServiceWebReference.ServiceType.STANDARD_OVERNIGHT, ref TotalAmount, ref TotalDiscount);
- //ShipWebServiceClient.FedExShipPackage.PlaceShipment("p5U6XiI6lzh3IFNh", "lMLDbSqOL0pTPgyI8rnH39JVt", "510087100", "119041229", FromName, FromCompany, telefonoFrom, FromAddress, FromCity, FromState, FromPostalCode, FromCountryCode, ReceiverName, ReceiverCompany, ReceiverPhoneNumber, ReceiverAddress, ReceiverCity, ReceiverState, ReceiverPostalCode, ReceiverCountryCode, Quantity, Length, Width, Height, Weight, ShipWebServiceClient.ShipServiceWebReference.ServiceType.STANDARD_OVERNIGHT, ref TrackingNo, ref LabelImage, ref numArray, ref TransportationCharges, ref ServiceCharge, ref TotalCost, false);
- //TotalAmount = TotalAmountCuenta1;
- returnValue = guardarEnvio(pJData, TotalAmount, TrackingNo, tipoGuia);
- }
- else
- {
- returnValue = "Tipo Servicio Inexistente";
- }
- return returnValue;
- }
- public static string generarGuiaFedexPesados(Object pJData)
- {
- dynamic Data = JsonConvert.DeserializeObject(pJData.ToString());
- int tipoServicio = Data[0]["tipoServicio"];
- Int64 envioId;
- string userId = HttpContext.Current.Session["usuario_id"].ToString();
- //REMITENTE
- //string tipoServicio;
- string precio;
- //REMITENTE
- string nombreRemitente;
- string correoRemitente;
- string telefonoRemitente;
- string direccionRemitente;
- string referenciaRemitente;
- string coloniaRemitente;
- string codigoPostalRemitente;
- string ciudadRemitente;
- string estadoRemitente;
- //DESTINATARIO
- string nombreDestinatario;
- string correoDestinatario;
- string telefonoDestinatario;
- string direccionDestinatario;
- string referenciaDestinatario;
- string coloniaDestinatario;
- string codigoPostalDestinatario;
- string ciudadDestinatario;
- string estadoDestinatario;
- //DIMENSIONES
- string largo;
- string ancho;
- string alto;
- string peso;
- string envio;
- int paqueteriaId;
- //dynamic Data = JsonConvert.DeserializeObject(pJData.ToString());
- tipoServicio = Data[0]["tipoServicio"]; //FromName
- precio = Data[0]["precio"]; //FromeMail
- //envioId = Data[0]["envioId"];
- //GENERALES
- nombreRemitente = Data[0]["nombreRemitente"]; //FromName
- correoRemitente = Data[0]["correoRemitente"]; //FromeMail
- telefonoRemitente = Data[0]["telefonoRemitente"]; //FromPhone
- direccionRemitente = Data[0]["direccionRemitente"]; //FromStreth
- referenciaRemitente = Data[0]["referenciaRemitente"]; //FromComents
- coloniaRemitente = Data[0]["coloniaRemitente"]; //FromAdress
- codigoPostalRemitente = Data[0]["codigoPostalRemitente"]; //FromPostalCode
- ciudadRemitente = Data[0]["ciudadRemitente"]; //City
- estadoRemitente = Data[0]["estadoRemitente"]; //FromCity
- //string telefonoFrom = "+518119173228"; //FromPhone correct
- //DESTINATARIO
- nombreDestinatario = Data[0]["nombreDestinatario"]; //To NAme
- //correoDestinatario = Data[0]["correoDestinatario"];//ToMail
- correoDestinatario = "envios@guias.com";//ToMail
- telefonoDestinatario = Data[0]["telefonoDestinatario"]; //ToPhone
- direccionDestinatario = Data[0]["direccionDestinatario"]; //ToStreth
- referenciaDestinatario = Data[0]["referenciaDestinatario"]; //ToComents
- coloniaDestinatario = Data[0]["coloniaDestinatario"]; //ToAdress
- codigoPostalDestinatario = Data[0]["codigoPostalDestinatario"]; //ToPostalCOde
- ciudadDestinatario = Data[0]["ciudadDestinatario"]; //ToCity
- estadoDestinatario = Data[0]["estadoDestinatario"]; //ToCity
- //string telefonoTo = "+52" + telefonoDestinatario; //FromPhone correct
- //DIMENSIONES
- largo = Data[0]["largo"];
- ancho = Data[0]["ancho"];
- alto = Data[0]["alto"];
- peso = Data[0]["peso"];
- envio = Data[0]["envio"];
- //PAQUETERIA
- paqueteriaId = Data[0]["paqueteriaId"];
- string mensaje = string.Empty;
- string FromName = nombreRemitente;
- string FromCompany = "Emissary";
- string FromAddress = direccionRemitente;
- string FromColonia = coloniaRemitente;
- string FromReference = referenciaRemitente;
- string FromCity = ciudadRemitente;
- string FromState = estadoRemitente;
- string FromPostalCode = codigoPostalRemitente;
- string FromCountryCode = "MX";
- string telefonoFrom = telefonoRemitente;
- string ReceiverName = nombreDestinatario;
- string ReceiverCompany = "Emissary";
- string ReceiverPhoneNumber = telefonoDestinatario;
- string ReceiverAddress = direccionDestinatario;
- string ReceiverColonia = coloniaDestinatario;
- string ReceiverReference = referenciaDestinatario;
- string ReceiverCity = ciudadDestinatario;
- string ReceiverState = estadoDestinatario;
- string ReceiverPostalCode = codigoPostalDestinatario;
- string ReceiverCountryCode = "MX";
- string telefonoTo = telefonoDestinatario;
- int Quantity = 1;
- int Length = int.Parse(largo);
- int Width = int.Parse(ancho);
- int Height = int.Parse(alto);
- decimal Weight = decimal.Parse(peso);
- byte[] numArray = null;
- string TrackingNo = string.Empty;
- string LabelImage = string.Empty;
- string wsResponseDescription = string.Empty;
- string wsResponseStatus = string.Empty;
- string ShipmentIdentificationNumber = string.Empty;
- string TransportationCharges = string.Empty;
- string ServiceCharge = string.Empty;
- string TotalCost = string.Empty;
- decimal TotalDiscount = 0, TotalAmount = 0;
- var returnValue = string.Empty;
- var tipoGuia = consultarTipoGuiaFedex();
- if (tipoServicio == 1)
- {
- //string servicio = "Terrestre";
- //VERSION OFICIAL
- RateWebServiceClient.FedEx.Execute("dPnfMXBdJITm7S9x", "gHiowUgNb1NbcOMLXjqigM7lG", "912766853", "113250529", FromAddress, FromCity, "NL", FromPostalCode, FromCountryCode, ReceiverAddress, ReceiverCity, "NL", ReceiverPostalCode, ReceiverCountryCode, 1, Length, Width, Height, Weight, RateWebServiceClient.RateServiceWebReference.ServiceType.FEDEX_EXPRESS_SAVER, ref TotalAmount, ref TotalDiscount);
- string servicio = "Terrestre";
- ShipWebServiceClient.FedExShipPackage.PlaceShipment("dPnfMXBdJITm7S9x", "gHiowUgNb1NbcOMLXjqigM7lG", "912766853", "113250529", FromName, FromCompany, telefonoFrom, FromAddress, FromColonia, FromReference, FromCity, FromState, FromPostalCode, FromCountryCode, ReceiverName, ReceiverCompany, ReceiverPhoneNumber, ReceiverAddress, ReceiverColonia, ReceiverReference, ReceiverCity, ReceiverState, ReceiverPostalCode, ReceiverCountryCode, Quantity, Length, Width, Height, Weight, ShipWebServiceClient.ShipServiceWebReference.ServiceType.FEDEX_EXPRESS_SAVER, ref TrackingNo, ref LabelImage, ref numArray, ref TransportationCharges, ref ServiceCharge, ref TotalCost, false, tipoGuia);
- //string key, string password, string accountnumber, string meternumber,
- //VERSION PRUEBA
- //RateWebServiceClient.FedEx.Execute("p5U6XiI6lzh3IFNh", "lMLDbSqOL0pTPgyI8rnH39JVt", "510087100", "119041229", FromAddress, FromCity, "NL", FromPostalCode, FromCountryCode, ReceiverAddress, ReceiverCity, "NL", ReceiverPostalCode, ReceiverCountryCode, 1, Length, Width, Height, Weight, RateWebServiceClient.RateServiceWebReference.ServiceType.FEDEX_EXPRESS_SAVER, ref TotalAmount, ref TotalDiscount);
- //ShipWebServiceClient.FedExShipPackage.PlaceShipment("p5U6XiI6lzh3IFNh", "lMLDbSqOL0pTPgyI8rnH39JVt", "510087100", "119041229", FromName, FromCompany, telefonoFrom, FromAddress, FromCity, FromState, FromPostalCode, FromCountryCode, ReceiverName, ReceiverCompany, ReceiverPhoneNumber, ReceiverAddress, ReceiverCity, ReceiverState, ReceiverPostalCode, ReceiverCountryCode, Quantity, Length, Width, Height, Weight, ShipWebServiceClient.ShipServiceWebReference.ServiceType.FEDEX_EXPRESS_SAVER, ref TrackingNo, ref LabelImage, ref numArray, ref TransportationCharges, ref ServiceCharge, ref TotalCost, false);
- returnValue = guardarEnvio(pJData, TotalAmount, TrackingNo, tipoGuia);
- }
- else if (tipoServicio == 2)
- {
- //string servicio = "Áereo";
- //VERSION OFICIAL
- RateWebServiceClient.FedEx.Execute("dPnfMXBdJITm7S9x", "gHiowUgNb1NbcOMLXjqigM7lG", "912766853", "113250529", FromAddress, FromCity, "NL", FromPostalCode, FromCountryCode, ReceiverAddress, ReceiverCity, "NL", ReceiverPostalCode, ReceiverCountryCode, 1, Length, Width, Height, Weight, RateWebServiceClient.RateServiceWebReference.ServiceType.STANDARD_OVERNIGHT, ref TotalAmount, ref TotalDiscount);
- string servicio = "Áereo";
- ShipWebServiceClient.FedExShipPackage.PlaceShipment("dPnfMXBdJITm7S9x", "gHiowUgNb1NbcOMLXjqigM7lG", "912766853", "113250529", FromName, FromCompany, telefonoFrom, FromAddress, FromColonia, FromReference, FromCity, FromState, FromPostalCode, FromCountryCode, ReceiverName, ReceiverCompany, ReceiverPhoneNumber, ReceiverAddress, ReceiverColonia, ReceiverReference, ReceiverCity, ReceiverState, ReceiverPostalCode, ReceiverCountryCode, Quantity, Length, Width, Height, Weight, ShipWebServiceClient.ShipServiceWebReference.ServiceType.STANDARD_OVERNIGHT, ref TrackingNo, ref LabelImage, ref numArray, ref TransportationCharges, ref ServiceCharge, ref TotalCost, false, tipoGuia);
- //RateWebServiceClient.FedEx.Execute("p5U6XiI6lzh3IFNh", "lMLDbSqOL0pTPgyI8rnH39JVt", "510087100", "119041229", FromAddress, FromCity, "NL", FromPostalCode, FromCountryCode, ReceiverAddress, ReceiverCity, "NL", ReceiverPostalCode, ReceiverCountryCode, 1, Length, Width, Height, Weight, RateWebServiceClient.RateServiceWebReference.ServiceType.STANDARD_OVERNIGHT, ref TotalAmount, ref TotalDiscount);
- //ShipWebServiceClient.FedExShipPackage.PlaceShipment("p5U6XiI6lzh3IFNh", "lMLDbSqOL0pTPgyI8rnH39JVt", "510087100", "119041229", FromName, FromCompany, telefonoFrom, FromAddress, FromCity, FromState, FromPostalCode, FromCountryCode, ReceiverName, ReceiverCompany, ReceiverPhoneNumber, ReceiverAddress, ReceiverCity, ReceiverState, ReceiverPostalCode, ReceiverCountryCode, Quantity, Length, Width, Height, Weight, ShipWebServiceClient.ShipServiceWebReference.ServiceType.STANDARD_OVERNIGHT, ref TrackingNo, ref LabelImage, ref numArray, ref TransportationCharges, ref ServiceCharge, ref TotalCost, false);
- returnValue = guardarEnvio(pJData, TotalAmount, TrackingNo, tipoGuia);
- }
- else if (tipoServicio == 3)
- {
- string servicio = "Prioridad Áereo";
- //VERSION OFICIAL
- RateWebServiceClient.FedEx.Execute("dPnfMXBdJITm7S9x", "gHiowUgNb1NbcOMLXjqigM7lG", "912766853", "113250529", FromAddress, FromCity, "NL", FromPostalCode, FromCountryCode, ReceiverAddress, ReceiverCity, "NL", ReceiverPostalCode, ReceiverCountryCode, 1, Length, Width, Height, Weight, RateWebServiceClient.RateServiceWebReference.ServiceType.PRIORITY_OVERNIGHT, ref TotalAmount, ref TotalDiscount);
- ShipWebServiceClient.FedExShipPackage.PlaceShipment("dPnfMXBdJITm7S9x", "gHiowUgNb1NbcOMLXjqigM7lG", "912766853", "113250529", FromName, FromCompany, telefonoFrom, FromAddress, FromColonia, FromReference, FromCity, FromState, FromPostalCode, FromCountryCode, ReceiverName, ReceiverCompany, ReceiverPhoneNumber, ReceiverAddress, ReceiverColonia, ReceiverReference, ReceiverCity, ReceiverState, ReceiverPostalCode, ReceiverCountryCode, Quantity, Length, Width, Height, Weight, ShipWebServiceClient.ShipServiceWebReference.ServiceType.PRIORITY_OVERNIGHT, ref TrackingNo, ref LabelImage, ref numArray, ref TransportationCharges, ref ServiceCharge, ref TotalCost, false, tipoGuia);
- //RateWebServiceClient.FedEx.Execute("p5U6XiI6lzh3IFNh", "lMLDbSqOL0pTPgyI8rnH39JVt", "510087100", "119041229", FromAddress, FromCity, "NL", FromPostalCode, FromCountryCode, ReceiverAddress, ReceiverCity, "NL", ReceiverPostalCode, ReceiverCountryCode, 1, Length, Width, Height, Weight, RateWebServiceClient.RateServiceWebReference.ServiceType.STANDARD_OVERNIGHT, ref TotalAmount, ref TotalDiscount);
- //ShipWebServiceClient.FedExShipPackage.PlaceShipment("p5U6XiI6lzh3IFNh", "lMLDbSqOL0pTPgyI8rnH39JVt", "510087100", "119041229", FromName, FromCompany, telefonoFrom, FromAddress, FromCity, FromState, FromPostalCode, FromCountryCode, ReceiverName, ReceiverCompany, ReceiverPhoneNumber, ReceiverAddress, ReceiverCity, ReceiverState, ReceiverPostalCode, ReceiverCountryCode, Quantity, Length, Width, Height, Weight, ShipWebServiceClient.ShipServiceWebReference.ServiceType.STANDARD_OVERNIGHT, ref TrackingNo, ref LabelImage, ref numArray, ref TransportationCharges, ref ServiceCharge, ref TotalCost, false);
- returnValue = guardarEnvio(pJData, TotalAmount, TrackingNo, tipoGuia);
- }
- else
- {
- returnValue = "Tipo Servicio Inexistente";
- }
- return returnValue;
- }
- [WebMethod(EnableSession = true)]
- public static string consultarTipoGuiaFedex()
- {
- string mensaje = "";
- string userId = HttpContext.Current.Session["usuario_id"].ToString();
- DataTable DataTable = new DataTable();
- dbo.BaseDatos db = null;
- db = new dbo.BaseDatos(ConfigurationManager.ConnectionStrings["cnn"].ToString());
- SqlParameter prmUserId;
- try
- {
- prmUserId = new SqlParameter("@userId", SqlDbType.SmallInt);
- prmUserId.Value = userId;
- DataTable = db.ObtenerDatosComoDataTable("spq_Emissary_PreferenciaEtiquetaFedex", prmUserId);
- DataTable.TableName = "Envios";
- mensaje = JsonConvert.SerializeObject(DataTable);
- if (mensaje.Length < 3)
- {
- mensaje = "1";
- }
- else
- {
- mensaje = DataTable.Rows[0]["terminacion_id"].ToString();
- }
- }
- catch (Exception ex)
- {
- mensaje = ex.Message;
- }
- finally
- {
- db.Finalizar();
- }
- return mensaje;
- }
- [WebMethod(EnableSession = true)]
- public static string consultarTipoGuiaRedpack()
- {
- string mensaje = "";
- string userId = HttpContext.Current.Session["usuario_id"].ToString();
- DataTable DataTable = new DataTable();
- dbo.BaseDatos db = null;
- db = new dbo.BaseDatos(ConfigurationManager.ConnectionStrings["cnn"].ToString());
- SqlParameter prmUserId;
- try
- {
- prmUserId = new SqlParameter("@userId", SqlDbType.SmallInt);
- prmUserId.Value = userId;
- DataTable = db.ObtenerDatosComoDataTable("spq_Emissary_PreferenciaEtiquetaRedpack", prmUserId);
- DataTable.TableName = "Envios";
- mensaje = JsonConvert.SerializeObject(DataTable);
- if (mensaje.Length < 3)
- {
- mensaje = "2";
- }
- else
- {
- mensaje = DataTable.Rows[0]["terminacion_id"].ToString();
- }
- }
- catch (Exception ex)
- {
- mensaje = ex.Message;
- }
- finally
- {
- db.Finalizar();
- }
- return mensaje;
- }
- public static string guardarGuia(Object pJData, decimal costo, decimal precio, int noTracking)
- {
- return string.Empty;
- }
- #region <<Cargar Datos Peso>>
- [WebMethod(EnableSession = true)]
- public static string cancelarGuia(Int64 envioId)
- {
- string mensaje = "";
- string userId = HttpContext.Current.Session["usuario_id"].ToString();
- DataSet DataSet = new DataSet();
- dbo.BaseDatos db = null;
- db = new dbo.BaseDatos(ConfigurationManager.ConnectionStrings["cnn"].ToString());
- SqlParameter prmUserId, prmIdPeso;
- try
- {
- prmUserId = new SqlParameter("@userId", SqlDbType.SmallInt);
- prmUserId.Value = userId;
- prmIdPeso = new SqlParameter("@envioId", SqlDbType.SmallInt);
- prmIdPeso.Value = envioId;
- DataSet = db.ObtenerDatosComoDataSet("spq_Emissary_CancelarGuia", prmIdPeso, prmUserId);
- //DataSet.TableName = "Peso";
- mensaje = JsonConvert.SerializeObject(DataSet);
- var noGuia = Convert.ToString(DataSet.Tables[0].Rows[0]["TrackingNo"]);
- var precio = Convert.ToString(DataSet.Tables[0].Rows[0]["precio"]);
- var paqueteruia_id = Convert.ToString(DataSet.Tables[0].Rows[0]["paqueteria"]);
- }
- catch (Exception ex)
- {
- mensaje = ex.Message;
- }
- finally
- {
- db.Finalizar();
- }
- return mensaje;
- }
- #endregion
- #region <<Cargar Ciudad Estado>>
- [WebMethod(EnableSession = true)]
- public static string obtenerCiudadEstado(string CP)
- {
- string mensaje = "";
- string userId = HttpContext.Current.Session["usuario_id"].ToString();
- DataSet DataSet = new DataSet();
- dbo.BaseDatos db = null;
- db = new dbo.BaseDatos(ConfigurationManager.ConnectionStrings["cnn"].ToString());
- SqlParameter prmUserId, prmCP;
- try
- {
- prmCP = new SqlParameter("@Cp", SqlDbType.NVarChar);
- prmCP.Value = CP;
- DataSet = db.ObtenerDatosComoDataSet("spq_Emissary_CiudadEstado", prmCP);
- //DataSet.TableName = "Peso";
- mensaje = JsonConvert.SerializeObject(DataSet);
- }
- catch (Exception ex)
- {
- mensaje = ex.Message;
- }
- finally
- {
- db.Finalizar();
- }
- return mensaje;
- }
- #endregion
- #region <<Cargar Datos Direccion>>
- [WebMethod(EnableSession = true)]
- public static string cargarPrecios(Int64 peso)
- {
- string mensaje = "";
- DataTable DataTable = new DataTable();
- dbo.BaseDatos db = null;
- db = new dbo.BaseDatos(ConfigurationManager.ConnectionStrings["cnn"].ToString());
- SqlParameter prmPeso;
- try
- {
- prmPeso = new SqlParameter("@Kilos", SqlDbType.SmallInt);
- prmPeso.Value = peso;
- DataTable = db.ObtenerDatosComoDataTable("spq_Emissary_DatosDireccion", prmPeso);
- DataTable.TableName = "PrecioPeso";
- mensaje = JsonConvert.SerializeObject(DataTable);
- }
- catch (Exception ex)
- {
- mensaje = ex.Message;
- }
- finally
- {
- db.Finalizar();
- }
- return mensaje;
- }
- #endregion
- #region <<Cargar Datos Peso>>
- [WebMethod(EnableSession = true)]
- public static string cargarPeso(Object pJData)
- {
- string mensaje = "";
- string userId = HttpContext.Current.Session["usuario_id"].ToString();
- dynamic Data = JsonConvert.DeserializeObject(pJData.ToString());
- string IdPeso = Data[0]["IdPeso"];
- string codigoPostalRemitente = Data[0]["codigoPostalRemitente"];
- string codigoPostalDestinatario = Data[0]["codigoPostalDestinatario"];
- DataSet DataSet = new DataSet();
- dbo.BaseDatos db = null;
- db = new dbo.BaseDatos(ConfigurationManager.ConnectionStrings["cnn"].ToString());
- SqlParameter prmUserId, prmIdPeso, prmCodigoPostalRemitente, prmCodigoPostalDestinatario;
- try
- {
- prmUserId = new SqlParameter("@userId", SqlDbType.SmallInt);
- prmUserId.Value = userId;
- prmIdPeso = new SqlParameter("@Kilos", SqlDbType.NVarChar, 50);
- prmIdPeso.Value = IdPeso;
- prmCodigoPostalRemitente = new SqlParameter("@CpRemitente", SqlDbType.NVarChar, 50);
- prmCodigoPostalRemitente.Value = codigoPostalRemitente;
- prmCodigoPostalDestinatario = new SqlParameter("@CpDestinatario", SqlDbType.NVarChar, 50);
- prmCodigoPostalDestinatario.Value = codigoPostalDestinatario;
- DataSet = db.ObtenerDatosComoDataSet("spq_Emissary_PreciosPrueba_Mike", prmIdPeso, prmUserId, prmCodigoPostalRemitente, prmCodigoPostalDestinatario);
- //DataSet.TableName = "Peso";
- mensaje = JsonConvert.SerializeObject(DataSet);
- }
- catch (Exception ex)
- {
- mensaje = ex.Message;
- }
- finally
- {
- db.Finalizar();
- }
- return mensaje;
- }
- //[WebMethod(EnableSession = true)]
- //public static string cargarPeso(int pesoId)
- //{
- // string mensaje = "";
- // string userId = HttpContext.Current.Session["usuario_id"].ToString();
- // int IdPeso = pesoId;
- // DataSet DataSet = new DataSet();
- // dbo.BaseDatos db = null;
- // db = new dbo.BaseDatos(ConfigurationManager.ConnectionStrings["cnn"].ToString());
- // SqlParameter prmUserId, prmIdPeso, prmCodigoPostalRemitente, prmCodigoPostalDestinatario;
- // try
- // {
- // prmUserId = new SqlParameter("@userId", SqlDbType.SmallInt);
- // prmUserId.Value = userId;
- // prmIdPeso = new SqlParameter("@Kilos", SqlDbType.NVarChar, 50);
- // prmIdPeso.Value = IdPeso;
- // DataSet = db.ObtenerDatosComoDataSet("spq_Emissary_PreciosPrueba", prmIdPeso);
- // //DataSet.TableName = "Peso";
- // mensaje = JsonConvert.SerializeObject(DataSet);
- // }
- // catch (Exception ex)
- // {
- // mensaje = ex.Message;
- // }
- // finally
- // {
- // db.Finalizar();
- // }
- // return mensaje;
- //}
- #endregion
- #region <<Cargar Datos Direccion>>
- [WebMethod(EnableSession = true)]
- public static string cargarDatosDireccion(Int64 IdDireccion)
- {
- string mensaje = "";
- DataTable DataTable = new DataTable();
- dbo.BaseDatos db = null;
- db = new dbo.BaseDatos(ConfigurationManager.ConnectionStrings["cnn"].ToString());
- SqlParameter prmIdDireccion;
- try
- {
- prmIdDireccion = new SqlParameter("@IdDireccion", SqlDbType.SmallInt);
- prmIdDireccion.Value = IdDireccion;
- DataTable = db.ObtenerDatosComoDataTable("spq_Emissary_DatosDireccion", prmIdDireccion);
- DataTable.TableName = "Direccion";
- mensaje = JsonConvert.SerializeObject(DataTable);
- }
- catch (Exception ex)
- {
- mensaje = ex.Message;
- }
- finally
- {
- db.Finalizar();
- }
- return mensaje;
- }
- #endregion
- #region <<Cargar Datos Paquete>>
- [WebMethod(EnableSession = true)]
- public static string cargarDatosPaquete(Int64 IdPaquete)
- {
- string mensaje = "";
- DataTable DataTable = new DataTable();
- dbo.BaseDatos db = null;
- db = new dbo.BaseDatos(ConfigurationManager.ConnectionStrings["cnn"].ToString());
- SqlParameter prmIdPaquete;
- try
- {
- prmIdPaquete = new SqlParameter("@IdPaquete", SqlDbType.SmallInt);
- prmIdPaquete.Value = IdPaquete;
- DataTable = db.ObtenerDatosComoDataTable("spq_Emissary_DatosPaquete", prmIdPaquete);
- DataTable.TableName = "Paquete";
- mensaje = JsonConvert.SerializeObject(DataTable);
- }
- catch (Exception ex)
- {
- mensaje = ex.Message;
- }
- finally
- {
- db.Finalizar();
- }
- return mensaje;
- }
- #endregion
- #region <<Cargar Datos Direccion>>
- [WebMethod(EnableSession = true)]
- public static string cargarDatosOrden(Int64 ordenId)
- {
- string mensaje = "";
- DataTable DataTable = new DataTable();
- dbo.BaseDatos db = null;
- db = new dbo.BaseDatos(ConfigurationManager.ConnectionStrings["cnn"].ToString());
- SqlParameter prmOrdenId;
- try
- {
- prmOrdenId = new SqlParameter("@ordenId", SqlDbType.SmallInt);
- prmOrdenId.Value = ordenId;
- DataTable = db.ObtenerDatosComoDataTable("spq_Emissary_DatosOrden", prmOrdenId);
- DataTable.TableName = "Orden";
- mensaje = JsonConvert.SerializeObject(DataTable);
- }
- catch (Exception ex)
- {
- mensaje = ex.Message;
- }
- finally
- {
- db.Finalizar();
- }
- return mensaje;
- }
- #endregion
- [WebMethod(EnableSession = true)]
- public static string cargarListadoEnvios()
- {
- string mensaje = "";
- string userId = HttpContext.Current.Session["usuario_id"].ToString();
- DataTable DataTable = new DataTable();
- dbo.BaseDatos db = null;
- db = new dbo.BaseDatos(ConfigurationManager.ConnectionStrings["cnn"].ToString());
- SqlParameter prmUserId;
- try
- {
- prmUserId = new SqlParameter("@userId", SqlDbType.SmallInt);
- prmUserId.Value = userId;
- DataTable = db.ObtenerDatosComoDataTable("spq_Emissary_ListadoEnviosPrueba", prmUserId);
- DataTable.TableName = "Envios";
- mensaje = JsonConvert.SerializeObject(DataTable);
- }
- catch (Exception ex)
- {
- mensaje = ex.Message;
- }
- finally
- {
- db.Finalizar();
- }
- return mensaje;
- }
- [WebMethod(EnableSession = true)]
- public static string cargarListadoEnviosDashboard()
- {
- string mensaje = "";
- string userId = HttpContext.Current.Session["usuario_id"].ToString();
- DataTable DataTable = new DataTable();
- dbo.BaseDatos db = null;
- db = new dbo.BaseDatos(ConfigurationManager.ConnectionStrings["cnn"].ToString());
- SqlParameter prmUserId;
- try
- {
- //prmUserId = new SqlParameter("@userId", SqlDbType.SmallInt);
- //prmUserId.Value = userId;
- DataTable = db.ObtenerDatosComoDataTable("spq_Emissary_ListadoEnviosDashboard");
- DataTable.TableName = "Envios";
- mensaje = JsonConvert.SerializeObject(DataTable);
- }
- catch (Exception ex)
- {
- mensaje = ex.Message;
- }
- finally
- {
- db.Finalizar();
- }
- return mensaje;
- }
- [WebMethod(EnableSession = true)]
- public static string validarSaldo(string precio)
- {
- string mensaje = "";
- decimal precioEnvio;
- decimal saldoUsuario;
- string userId = HttpContext.Current.Session["usuario_id"].ToString();
- string saldo = HttpContext.Current.Session["saldo"].ToString();
- precioEnvio = System.Convert.ToDecimal(precio);
- saldoUsuario = System.Convert.ToDecimal(saldo);
- if (precioEnvio <= saldoUsuario)
- {
- mensaje = "1";
- }
- else
- {
- mensaje = "0";
- }
- return mensaje;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement