Advertisement
Guest User

Untitled

a guest
Mar 26th, 2019
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 123.16 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Data;
  6. using System.Data.SqlClient;
  7. using System.Configuration;
  8. using System.Web.Services;
  9. using System.Web.Script.Services;
  10. using Newtonsoft.Json;
  11. using System.Net;
  12. using System.Net.Mail;
  13. using System.IO;
  14. using System.Threading.Tasks;
  15. using Emissary.Services;
  16.  
  17. namespace Emissary.Aplicacion
  18. {
  19.  
  20. public partial class Envios : System.Web.UI.Page
  21. {
  22. protected void Page_Load(object sender, EventArgs e)
  23. {
  24.  
  25. }
  26.  
  27.  
  28.  
  29. #region <<Guardar Envío>>
  30. [WebMethod]
  31. //public static string Guardar(string jData)
  32. public static string guardarEnvio(Object pJData, decimal costo, string TrackingNo, string tipoGuia)
  33. {
  34.  
  35.  
  36. Int64 envioId;
  37.  
  38.  
  39. string userId = HttpContext.Current.Session["usuario_id"].ToString();
  40.  
  41.  
  42. dynamic Data = JsonConvert.DeserializeObject(pJData.ToString());
  43.  
  44. string paqueteriaId = Data[0]["paqueteriaId"];
  45. string tipoServicio = Data[0]["tipoServicio"]; //FromName
  46. string precio = Data[0]["precio"];
  47.  
  48.  
  49.  
  50.  
  51. //envioId = Data[0]["envioId"];
  52. //REMITENTE
  53. string nombreRemitente = nombreRemitente = Data[0]["nombreRemitente"];
  54. string correoRemitente = correoRemitente = Data[0]["correoRemitente"];
  55. string telefonoRemitente = telefonoRemitente = Data[0]["telefonoRemitente"];
  56. string direccionRemitente = Data[0]["direccionRemitente"];
  57. string referenciaRemitente = Data[0]["referenciaRemitente"];
  58. string coloniaRemitente = Data[0]["coloniaRemitente"];
  59. string codigoPostalRemitente = Data[0]["codigoPostalRemitente"];
  60. string estadoRemitente = Data[0]["estadoRemitente"];
  61.  
  62. //DESTINATARIO
  63.  
  64.  
  65. string nombreDestinatario = nombreDestinatario = Data[0]["nombreDestinatario"];
  66. //string correoDestinatario = correoDestinatario = Data[0]["correoDestinatario"];
  67. string correoDestinatario = correoDestinatario = correoDestinatario = "envios@gmail.com";
  68.  
  69.  
  70. string telefonoDestinatario = telefonoDestinatario = Data[0]["telefonoDestinatario"];
  71. string direccionDestinatario = Data[0]["direccionDestinatario"];
  72. string referenciaDestinatario = Data[0]["referenciaDestinatario"];
  73. string coloniaDestinatario = Data[0]["coloniaDestinatario"];
  74. string codigoPostalDestinatario = Data[0]["codigoPostalDestinatario"];
  75. string estadoDestinatario = Data[0]["estadoDestinatario"];
  76.  
  77.  
  78. //DIMENSIONES
  79.  
  80. string largo = Data[0]["largo"];
  81. string ancho = Data[0]["ancho"];
  82. string alto = Data[0]["alto"];
  83. string peso = Data[0]["peso"];
  84. string envio = Data[0]["envio"];
  85.  
  86.  
  87. string mensaje = string.Empty;
  88.  
  89.  
  90.  
  91. DataTable DataTable = new DataTable();
  92. dbo.BaseDatos db = null;
  93. SqlParameter prmUserId, prmNombreRemitente, prmCorreoRemitente, prmTelefonoRemitente, prmDireccionRemitente, prmReferenciaRemitente, prmColoniaRemitente, prmCodigoPostalRemitente, prmEstadoRemitente,
  94. prmNombreDestinatario, prmCorreoDestinatario, prmTelefonoDestinatario, prmDireccionDestinatario, prmReferenciaDestinatario, prmColoniaDestinatario, prmCodigoPostalDestinatario, prmEstadoDestinatario,
  95. prmLargo, prmAncho, prmAlto, prmPeso, prmEnvio, prmTipoServicio, prmPaqueteria, prmCosto, prmPrecio, prmTrackingNo, prmTipoGuia;
  96. try
  97. {
  98. db = new dbo.BaseDatos(ConfigurationManager.ConnectionStrings["cnn"].ToString());
  99.  
  100. prmUserId = new SqlParameter("@userId", SqlDbType.BigInt);
  101. prmUserId.Value = userId;
  102. prmTrackingNo = new SqlParameter("@TrackingNo", SqlDbType.BigInt);
  103. prmTrackingNo.Value = TrackingNo;
  104.  
  105. //Datos Envío Remitente
  106. prmNombreRemitente = new SqlParameter("@nombreRemitente", SqlDbType.NVarChar, 50);
  107. prmNombreRemitente.Value = nombreRemitente;
  108. prmCorreoRemitente = new SqlParameter("@correoRemitente", SqlDbType.NVarChar, 50);
  109. prmCorreoRemitente.Value = correoRemitente;
  110. prmTelefonoRemitente = new SqlParameter("@telefonoRemitente", SqlDbType.NVarChar, 50);
  111. prmTelefonoRemitente.Value = telefonoRemitente;
  112. prmDireccionRemitente = new SqlParameter("@direccionRemitente", SqlDbType.NVarChar, 50);
  113. prmDireccionRemitente.Value = direccionRemitente;
  114. prmReferenciaRemitente = new SqlParameter("@referenciaRemitente", SqlDbType.NVarChar, 50);
  115. prmReferenciaRemitente.Value = referenciaRemitente;
  116. prmColoniaRemitente = new SqlParameter("@coloniaRemitente", SqlDbType.NVarChar, 50);
  117. prmColoniaRemitente.Value = coloniaRemitente;
  118. prmCodigoPostalRemitente = new SqlParameter("@codigoPostalRemitente", SqlDbType.NVarChar, 50);
  119. prmCodigoPostalRemitente.Value = codigoPostalRemitente;
  120. prmEstadoRemitente = new SqlParameter("@estadoRemitente", SqlDbType.NVarChar, 50);
  121. prmEstadoRemitente.Value = estadoRemitente;
  122.  
  123. //Datos Envío Destinatario
  124. prmNombreDestinatario = new SqlParameter("@nombreDestinatario", SqlDbType.NVarChar, 50);
  125. prmNombreDestinatario.Value = nombreDestinatario;
  126. prmCorreoDestinatario = new SqlParameter("@correoDestinatario", SqlDbType.NVarChar, 50);
  127. prmCorreoDestinatario.Value = correoDestinatario;
  128. prmTelefonoDestinatario = new SqlParameter("@telefonoDestinatario", SqlDbType.NVarChar, 50);
  129. prmTelefonoDestinatario.Value = telefonoDestinatario;
  130. prmDireccionDestinatario = new SqlParameter("@direccionDestinatario", SqlDbType.NVarChar, 50);
  131. prmDireccionDestinatario.Value = direccionDestinatario;
  132. prmReferenciaDestinatario = new SqlParameter("@referenciaDestinatario", SqlDbType.NVarChar, 50);
  133. prmReferenciaDestinatario.Value = referenciaDestinatario;
  134. prmColoniaDestinatario = new SqlParameter("@coloniaDestinatario", SqlDbType.NVarChar, 50);
  135. prmColoniaDestinatario.Value = coloniaDestinatario;
  136. prmCodigoPostalDestinatario = new SqlParameter("@codigoPostalDestinatario", SqlDbType.NVarChar, 50);
  137. prmCodigoPostalDestinatario.Value = codigoPostalDestinatario;
  138. prmEstadoDestinatario = new SqlParameter("@estadoDestinatario", SqlDbType.NVarChar, 50);
  139. prmEstadoDestinatario.Value = estadoDestinatario;
  140.  
  141. //Datos Dimensiones
  142. prmLargo = new SqlParameter("@largo", SqlDbType.NVarChar, 50);
  143. prmLargo.Value = largo;
  144. prmAncho = new SqlParameter("@ancho", SqlDbType.NVarChar, 50);
  145. prmAncho.Value = ancho;
  146. prmAlto = new SqlParameter("@alto", SqlDbType.NVarChar, 50);
  147. prmAlto.Value = alto;
  148. prmPeso = new SqlParameter("@peso", SqlDbType.NVarChar, 50);
  149. prmPeso.Value = peso;
  150. prmEnvio = new SqlParameter("@envio", SqlDbType.NVarChar, 50);
  151. prmEnvio.Value = envio;
  152.  
  153. prmTipoServicio = new SqlParameter("@tipoServicio", SqlDbType.NVarChar, 50);
  154. prmTipoServicio.Value = tipoServicio;
  155. prmPaqueteria = new SqlParameter("@paqueteria", SqlDbType.NVarChar, 50);
  156. prmPaqueteria.Value = paqueteriaId;
  157.  
  158. prmPrecio = new SqlParameter("@precio", SqlDbType.NVarChar, 50);
  159. prmPrecio.Value = precio;
  160. prmCosto = new SqlParameter("@costo", SqlDbType.NVarChar, 50);
  161. prmCosto.Value = costo;
  162.  
  163. prmTipoGuia = new SqlParameter("@tipoGuia", SqlDbType.NVarChar, 50);
  164. prmTipoGuia.Value = tipoGuia;
  165.  
  166.  
  167. DataTable = db.ObtenerDatosComoDataTable("spac_Emissary_EnvioPrueba", prmUserId, prmNombreRemitente, prmCorreoRemitente, prmTelefonoRemitente, prmDireccionRemitente, prmReferenciaRemitente, prmColoniaRemitente, prmCodigoPostalRemitente, prmEstadoRemitente,
  168. prmNombreDestinatario, prmCorreoDestinatario, prmTelefonoDestinatario, prmDireccionDestinatario, prmReferenciaDestinatario, prmColoniaDestinatario, prmCodigoPostalDestinatario, prmEstadoDestinatario,
  169. prmLargo, prmAncho, prmAlto, prmPeso, prmEnvio, prmTipoServicio, prmPaqueteria, prmCosto, prmPrecio, prmTrackingNo, prmTipoGuia);
  170.  
  171.  
  172. //dataset.TableName = "Usuario";
  173.  
  174. //mensaje = JsonConvert.SerializeObject(DataTable);
  175.  
  176. //mensaje = JsonConvert.SerializeObject(DataTable);
  177. DataRow row = DataTable.Rows[0];
  178.  
  179. string saldo = mensaje = row["saldo"].ToString();
  180.  
  181. //HttpContext.Current.Session["saldo"].ToString();
  182.  
  183. HttpContext.Current.Session["saldo"] = saldo;
  184.  
  185.  
  186. }
  187.  
  188. catch (Exception ex)
  189. {
  190. mensaje = "error|" + ex.Message.ToString();
  191. }
  192. finally
  193. {
  194. db.Finalizar();
  195. }
  196. return mensaje;
  197. }
  198.  
  199.  
  200. #endregion <<Guardar>>
  201.  
  202. private static webServiceRedpack.Paquete DeserializaPaquete(object pJData)
  203. {
  204. dynamic Data = JsonConvert.DeserializeObject(pJData.ToString());
  205. var largo = int.Parse((string)Data[0]["largo"]);
  206. var ancho = int.Parse((string)Data[0]["ancho"]);
  207. var alto = int.Parse((string)Data[0]["alto"]);
  208. var peso = int.Parse((string)Data[0]["peso"]);
  209.  
  210. var paquete = new webServiceRedpack.Paquete
  211. {
  212. alto = alto,
  213. altoSpecified = true,
  214. ancho = ancho,
  215. anchoSpecified = true,
  216. peso = (float)peso,
  217. pesoSpecified = true,
  218. largo = largo,
  219. largoSpecified = true
  220. };
  221.  
  222. return paquete;
  223. }
  224.  
  225. private static webServiceRedpack.Direccion DeserializaConsignatario(object pJData)
  226. {
  227. dynamic Data = JsonConvert.DeserializeObject(pJData.ToString());
  228. var nombreDestinatario = Data[0]["nombreDestinatario"]; //To NAme
  229. //var correoDestinatario = Data[0]["correoDestinatario"];//ToMail
  230. var correoDestinatario = "envios@gmail.com";
  231. var telefonoDestinatario = Data[0]["telefonoDestinatario"]; //ToPhone
  232. var direccionDestinatario = Data[0]["direccionDestinatario"]; //ToStreth
  233. var referenciaDestinatario = Data[0]["referenciaDestinatario"]; //ToComents
  234. var coloniaDestinatario = Data[0]["coloniaDestinatario"]; //ToAdress
  235. var codigoPostalDestinatario = Data[0]["codigoPostalDestinatario"]; //ToPostalCOde
  236. var ciudadDestinatario = Data[0]["ciudadDestinatario"]; //ToCity
  237. var estadoDestinatario = Data[0]["estadoDestinatario"]; //ToCity
  238. var telefonoTo = "+52" + telefonoDestinatario; //FromPhone correct
  239.  
  240. var consignatario = new webServiceRedpack.Direccion
  241. {
  242. codigoPostal = int.Parse((string)codigoPostalDestinatario),
  243. codigoPostalSpecified = true,
  244.  
  245. calle = direccionDestinatario,
  246. ciudad = ciudadDestinatario,
  247. colonia_Asentamiento = coloniaDestinatario,
  248. estado = estadoDestinatario,
  249. email = correoDestinatario,
  250. referenciaUbicacion = referenciaDestinatario,
  251. telefonos = new webServiceRedpack.Telefono[] { new webServiceRedpack.Telefono { telefono = telefonoTo } },
  252. nombre_Compania = nombreDestinatario,
  253. pais = "MX"
  254. };
  255.  
  256. return consignatario;
  257. }
  258.  
  259. private static webServiceRedpack.Direccion DeserializaRemitente(object pJData)
  260. {
  261. dynamic Data = JsonConvert.DeserializeObject(pJData.ToString());
  262. var nombreRemitente = Data[0]["nombreRemitente"]; //FromName
  263. var correoRemitente = Data[0]["correoRemitente"]; //FromeMail
  264. var telefonoRemitente = Data[0]["telefonoRemitente"]; //FromPhone
  265. var telefonoDe = "+52" + telefonoRemitente; //FromPhone correct
  266.  
  267. var direccionRemitente = Data[0]["direccionRemitente"]; //FromStreth
  268. var referenciaRemitente = Data[0]["referenciaRemitente"]; //FromComents
  269. var coloniaRemitente = Data[0]["coloniaRemitente"]; //FromAdress
  270. var codigoPostalRemitente = Data[0]["codigoPostalRemitente"]; //FromPostalCode
  271. var ciudadRemitente = Data[0]["ciudadRemitente"]; //City
  272. var estadoRemitente = Data[0]["estadoRemitente"]; //FromCity
  273.  
  274. var remitente = new webServiceRedpack.Direccion
  275. {
  276. codigoPostal = int.Parse((string)codigoPostalRemitente),
  277. codigoPostalSpecified = true,
  278.  
  279. calle = direccionRemitente,
  280. ciudad = ciudadRemitente,
  281. colonia_Asentamiento = coloniaRemitente,
  282. estado = estadoRemitente,
  283. email = correoRemitente,
  284. referenciaUbicacion = referenciaRemitente,
  285. telefonos = new webServiceRedpack.Telefono[] { new webServiceRedpack.Telefono { telefono = telefonoDe } },
  286. nombre_Compania = nombreRemitente,
  287. pais = "MX"
  288. };
  289.  
  290. return remitente;
  291. }
  292.  
  293.  
  294.  
  295. #region <<Cotizar Envio>>
  296. [WebMethod]
  297. //public static string Guardar(string jData)
  298. public static string cotizarEnvio(Object pJData)
  299. {
  300.  
  301. string precioPaquete = cotizarPaqueteExpress(pJData);
  302.  
  303. //ObtenerCotizacionDhl( pJData);
  304.  
  305. //ObtenerCotizacionFedexPesados(pJData);
  306.  
  307.  
  308. //var cotizar = 1;
  309.  
  310. //zonaExtendida(pJData);
  311. //ObtenerCotizacionRedpack(pJData);
  312.  
  313.  
  314.  
  315. //return precioPaquete;
  316. return string.Empty;
  317.  
  318.  
  319. }
  320.  
  321.  
  322.  
  323.  
  324. #endregion <<Guardar>>
  325.  
  326. #region <<Cotizar Envio Paquete Express Comentado>>
  327.  
  328. [WebMethod]
  329. public static string cotizarPaqueteExpress(Object pJData)
  330. {
  331. dynamic data = JsonConvert.DeserializeObject(pJData.ToString());
  332. dynamic request = data[0];
  333.  
  334. var length = Convert.ToInt32(request["largo"]);
  335. var width = Convert.ToInt32(request["ancho"]);
  336. var heigth = Convert.ToInt32(request["alto"]);
  337. var quotationRequest = new PaquetExpress.Quotation.Data
  338. {
  339. ClientAddrOrig = new PaquetExpress.Quotation.Address
  340. {
  341. ColonyName = request["coloniaRemitente"],
  342. ZipCode = request["codigoPostalRemitente"]
  343. },
  344. ClientAddrDest = new PaquetExpress.Quotation.Address
  345. {
  346. ColonyName = request["coloniaDestinatario"],
  347. ZipCode = request["codigoPostalDestinatario"]
  348. },
  349. Services = new PaquetExpress.Quotation.Services
  350. {
  351. DlvyType = "0", //0=Ocurre, 1=Entrega a domicilio
  352. AckType = "N", //C=CLIENTE, I=INTERNO, X=EXTENDIDA, N=SIN ACUSE
  353. TotlDeclVlue = 0, //Valor declarado para seguro de envío
  354. InvType = "A",//N=SIN SEGURO, A=COBERTURA AMPLIA, L=COBERTURA LIMITADA
  355. RadType = "1", //0=No, 1=Si
  356. },
  357. ShipmentDetail = new PaquetExpress.Quotation.ShipmentDetail
  358. {
  359. Shipments = new List<PaquetExpress.Quotation.Shipment>()
  360. {
  361. {
  362. new PaquetExpress.Quotation.Shipment
  363. {
  364. Sequence =1,
  365. Quantity = 1,
  366. ShpCode ="2", // Tipo de bultos: 1 = Sobre, 2 = Caja
  367. Weight = (int)request["peso"],
  368. Volume = (decimal) (length /100) * (width/100) * (heigth/100),
  369. LongShip = length,
  370. WidthShip = width,
  371. HighShip = heigth
  372. }
  373. }
  374. }
  375. }
  376. };
  377.  
  378. var quotationResponse = AsyncHelpers.RunSync<PaquetExpress.Quotation.Data>(() => PaquetExpress.ServiceQuotation.CreateAsync(quotationRequest));
  379.  
  380. decimal paqueteTerrestre = quotationResponse.Amount.ShpAmnt.Value;
  381.  
  382. string costoPaquete = Convert.ToString(paqueteTerrestre);
  383.  
  384. string userId = HttpContext.Current.Session["usuario_id"].ToString();
  385.  
  386.  
  387. string mensaje;
  388.  
  389. DataSet DataSet = new DataSet();
  390. dbo.BaseDatos db = null;
  391.  
  392. db = new dbo.BaseDatos(ConfigurationManager.ConnectionStrings["cnn"].ToString());
  393. SqlParameter prmUserId, prmCostoPaquete;
  394.  
  395. try
  396. {
  397.  
  398. prmUserId = new SqlParameter("@userId", SqlDbType.SmallInt);
  399. prmUserId.Value = userId;
  400. prmCostoPaquete = new SqlParameter("@costoPaquete", SqlDbType.Decimal);
  401. decimal value;
  402. decimal.TryParse(costoPaquete, out value);
  403. prmCostoPaquete.Value = value;
  404.  
  405.  
  406.  
  407. DataSet = db.ObtenerDatosComoDataSet("spq_Emissary_PreciosPaquete", prmUserId, prmCostoPaquete);
  408. //DataSet.TableName = "Peso";
  409.  
  410. mensaje = JsonConvert.SerializeObject(DataSet);
  411. }
  412. catch (Exception ex)
  413. {
  414. mensaje = ex.Message;
  415. }
  416. finally
  417. {
  418. db.Finalizar();
  419. }
  420. return mensaje;
  421.  
  422.  
  423.  
  424.  
  425. //double terrestrePaquete =(quotationResponse.Amount.ShpAmnt) * 1.10;
  426.  
  427. //HttpContext.Current.Session["Paquete_Terrestre"] = quotationResponse.Amount.ShpAmnt;
  428.  
  429.  
  430.  
  431. //foreach (var service in quotationData.)
  432. //{
  433.  
  434. // if (service.ServiceType == "ground")
  435. // HttpContext.Current.Session["Dhl_Terrestre"] = service.TotalPrice;
  436. // else if (service.ServiceType == "express")
  437. // HttpContext.Current.Session["Dhl_Aereo"] = service.TotalPrice;
  438. // else
  439. // HttpContext.Current.Session["Dhl_" + service.ServiceType] = service;
  440.  
  441. //}
  442.  
  443. //return precioPaquete;
  444. }
  445.  
  446.  
  447.  
  448.  
  449. private static async Task<Emissary.PaquetExpress.Quotation.Data> ObtenerCotizacion(object pJData)
  450. {
  451. dynamic Data = JsonConvert.DeserializeObject(pJData.ToString());
  452. var quotationData = new Emissary.PaquetExpress.Quotation.Data
  453. {
  454. ClientAddrOrig = new Emissary.PaquetExpress.Quotation.Address // Datos del origen solo pide esos dos, nombre de la colonia y codigo postal
  455. {
  456. ColonyName = Data[0]["coloniaRemitente"],
  457. ZipCode = Data[0]["codigoPostalRemitente"]
  458. },
  459. ClientAddrDest = new Emissary.PaquetExpress.Quotation.Address // es lo mismo pero en lugar de Remitente Destinatario
  460. {
  461. ColonyName = Data[0]["coloniaDestinatario"],
  462. ZipCode = Data[0]["codigoPostalDestinatario"]
  463. },
  464. Services = new Emissary.PaquetExpress.Quotation.Services
  465. {
  466. DlvyType = "1", //Tipo de entrega (a domicilio, ocurre)
  467. AckType = "N",//Tipo de acuse de Recibo solicitado por el cliente C=CLIENTE, I=INTERNO, N=SIN ACUSE
  468. TotlDeclVlue = 2000, //Valor declarado para seguro de envío
  469. InvType = "A", //Mantiene la clave del seguro a aplicar INV-1, INV-PF, IV-XF, INV-CX
  470. RadType = "1", //servicio Recoleccion a domicilio (RAD)
  471. },
  472. ShipmentDetail = new Emissary.PaquetExpress.Quotation.ShipmentDetail
  473. {
  474. Shipments = new List<Emissary.PaquetExpress.Quotation.Shipment>()
  475. {
  476. {
  477. new Emissary.PaquetExpress.Quotation.Shipment // Datos del paquete
  478. {
  479. Sequence =1,
  480. Quantity = 1,
  481. ShpCode ="2",
  482. Weight = int.Parse((string)Data[0]["peso"]),
  483. LongShip = int.Parse((string)Data[0]["largo"]),
  484. WidthShip = int.Parse((string)Data[0]["ancho"]),
  485. HighShip = int.Parse((string)Data[0]["alto"]),
  486. Volume = (int.Parse((string)Data[0]["largo"]) * int.Parse((string)Data[0]["ancho"]) * int.Parse((string)Data[0]["alto"])) / 5000
  487. }
  488. }
  489. }
  490. }
  491. };
  492.  
  493. var quotation = await Emissary.PaquetExpress.ServiceQuotation.CreateAsync(quotationData);
  494. return quotation;
  495. }
  496.  
  497.  
  498. #endregion <<Guardar>>
  499.  
  500.  
  501. #region Cotizar Envio Dhl Comentado
  502.  
  503. //[System.Web.Services.WebMethod]
  504. //public static string ObtenerCotizacionDhl(Object pJData)
  505. //{
  506. // dynamic data = JsonConvert.DeserializeObject(pJData.ToString());
  507. // dynamic request = data[0];
  508.  
  509. // var quotationRequest = new Emissary.Dhl.Quotation.Request
  510. // {
  511. // Origin = new Emissary.Dhl.Address
  512. // {
  513. // Name = request["nombreRemitente"],
  514. // Company = request["nombreRemitente"],
  515. // Email = request["correoRemitente"],
  516. // Phone = request["telefonoRemitente"],
  517. // Street = request["direccionRemitente"],
  518. // Number = "0000",
  519. // District = request["coloniaRemitente"],
  520. // City = request["ciudadRemitente"],
  521. // State = request["estadoRemitente"],
  522. // Country = "MX",
  523. // PostalCode = request["codigoPostalRemitente"]
  524. // },
  525. // Destination = new Emissary.Dhl.Address
  526. // {
  527. // Name = request["nombreDestinatario"],
  528. // Company = request["nombreDestinatario"],
  529. // Email = request["correoDestinatario"],
  530. // Phone = request["telefonoDestinatario"],
  531. // Street = request["direccionDestinatario"],
  532. // Number = "0000",
  533. // District = request["coloniaDestinatario"],
  534. // City = request["ciudadDestinatario"],
  535. // State = request["estadoDestinatario"],
  536. // Country = "MX",
  537. // PostalCode = request["codigoPostalDestinatario"]
  538. // },
  539. // Package = new Emissary.Dhl.Package
  540. // {
  541. // Content = request["envio"],
  542. // Amount = 1,
  543. // Type = "box",
  544. // Dimensions = new Emissary.Dhl.Dimensions
  545. // {
  546. // Length = Convert.ToInt32(request["largo"]),
  547. // Width = Convert.ToInt32(request["ancho"]),
  548. // Height = Convert.ToInt32(request["alto"])
  549. // },
  550. // Weight = (int)request["peso"],
  551. // Insurance = 0,
  552. // DeclaredValue = 0
  553. // },
  554. // Shipment = new Emissary.Dhl.Shipment
  555. // {
  556. // Carrier = "dhl"
  557. // }
  558. // };
  559.  
  560. // var quotationData = AsyncHelpers.RunSync<Emissary.Dhl.Quotation.Response>(() => Emissary.Dhl.ServiceQuotation.CreateAsync(quotationRequest));
  561. // foreach (var service in quotationData.Data)
  562. // {
  563.  
  564. // if (service.ServiceType == "ground")
  565. // HttpContext.Current.Session["Dhl_Terrestre"] = service.TotalPrice;
  566. // else if (service.ServiceType == "express")
  567. // HttpContext.Current.Session["Dhl_Aereo"] = service.TotalPrice;
  568. // else
  569. // HttpContext.Current.Session["Dhl_" + service.ServiceType] = service;
  570.  
  571. // }
  572.  
  573. // return string.Empty;
  574. //}
  575.  
  576. #endregion <<Dhl>>
  577.  
  578.  
  579.  
  580. //[System.Web.Services.WebMethod]
  581. //public static string ObtenerCotizacionPaquete(Object pJData)
  582. //{
  583. // dynamic data = JsonConvert.DeserializeObject(pJData.ToString());
  584. // dynamic request = data[0];
  585.  
  586.  
  587. //var quotationRequest = new Emissary.PaquetExpress.Quotation.Request
  588. //{
  589. // Origin = new Emissar
  590. // {
  591. // Name = request["nombreRemitente"],
  592. // Company = request["nombreRemitente"],
  593. // Email = request["correoRemitente"],
  594. // Phone = request["telefonoRemitente"],
  595. // Street = request["direccionRemitente"],
  596. // Number = "0000",
  597. // District = request["coloniaRemitente"],
  598. // City = request["ciudadRemitente"],
  599. // State = request["estadoRemitente"],
  600. // Country = "MX",
  601. // PostalCode = request["codigoPostalRemitente"]
  602. // }
  603.  
  604. //};
  605.  
  606. //var quotationRequest = new Emissary.PaqueteExpress.Quotation.Request
  607. //{
  608. // Origin = new Emissary.Paquete.Address
  609. // {
  610. // Name = request["nombreRemitente"],
  611. // Company = request["nombreRemitente"],
  612. // Email = request["correoRemitente"],
  613. // Phone = request["telefonoRemitente"],
  614. // Street = request["direccionRemitente"],
  615. // Number = "0000",
  616. // District = request["coloniaRemitente"],
  617. // City = request["ciudadRemitente"],
  618. // State = request["estadoRemitente"],
  619. // Country = "MX",
  620. // PostalCode = request["codigoPostalRemitente"]
  621. // },
  622. // Destination = new Emissary.Paquete.Address
  623. // {
  624. // Name = request["nombreDestinatario"],
  625. // Company = request["nombreDestinatario"],
  626. // Email = request["correoDestinatario"],
  627. // Phone = request["telefonoDestinatario"],
  628. // Street = request["direccionDestinatario"],
  629. // Number = "0000",
  630. // District = request["coloniaDestinatario"],
  631. // City = request["ciudadDestinatario"],
  632. // State = request["estadoDestinatario"],
  633. // Country = "MX",
  634. // PostalCode = request["codigoPostalDestinatario"]
  635. // },
  636. // Package = new Emissary.Paquete.Package
  637. // {
  638. // Content = request["envio"],
  639. // Amount = 1,
  640. // Type = "box",
  641. // Dimensions = new Emissary.Paquete.Dimensions
  642. // {
  643. // Length = Convert.ToInt32(request["largo"]),
  644. // Width = Convert.ToInt32(request["ancho"]),
  645. // Height = Convert.ToInt32(request["alto"])
  646. // },
  647. // Weight = (int)request["peso"],
  648. // Insurance = 0,
  649. // DeclaredValue = 0
  650. // },
  651. // Shipment = new Emissary.Paquete.Shipment
  652. // {
  653. // Carrier = "Paquete"
  654. // }
  655. //};
  656.  
  657. //var quotationData = AsyncHelpers.RunSync<Emissary.Paquete.Quotation.Response>(() => Emissary.Paquete.ServiceQuotation.CreateAsync(quotationRequest));
  658. //foreach (var service in quotationData.Data)
  659. //{
  660.  
  661. // if (service.ServiceType == "ground")
  662. // HttpContext.Current.Session["Paquete_Terrestre"] = service.TotalPrice;
  663. // else if (service.ServiceType == "express")
  664. // HttpContext.Current.Session["Paquete_Aereo"] = service.TotalPrice;
  665. // else
  666. // HttpContext.Current.Session["Paquete_" + service.ServiceType] = service;
  667.  
  668. //}
  669.  
  670.  
  671.  
  672.  
  673. // return string.Empty;
  674. //}
  675.  
  676.  
  677.  
  678.  
  679.  
  680. #region Redpack
  681. [System.Web.Services.WebMethod]
  682. public static string ObtenerCotizacionRedpack(Object pJData)
  683. {
  684.  
  685. dynamic Data = JsonConvert.DeserializeObject(pJData.ToString());
  686.  
  687.  
  688.  
  689.  
  690.  
  691.  
  692.  
  693. int tipoServicioRedpack = Data[0]["tipoServicio"];
  694. //int peso = Data[0]["peso"];
  695.  
  696. //int peso = 1;
  697. //int peso = 5;
  698. //int peso = 14;
  699. //int peso = 14;
  700. int peso = 20;
  701. //int peso = 25;
  702. //int peso = 30;
  703. //int peso = 35;
  704. //int peso = 40;
  705. //int peso = 50;
  706. //int peso = 60;
  707. //int peso = 70;
  708.  
  709. if (tipoServicioRedpack == 1 && peso == 1)
  710. {
  711.  
  712. //var idUser = 1332;
  713. //var pin = "PROD oNmnqC0wC1PIP4xOOi+XU9mBaDD3H/WaXerHWc+YTv6/TY1QB+hqLQ==";
  714.  
  715. var idUser = 1127;
  716. var pin = "PROD oNmnqC0wC1OKtdtGe8TaA663C2+gFNOX5kwuSaAvj70=";
  717. var wsClient = new webServiceRedpack.RedpackWS();
  718. var guia = new webServiceRedpack.Guia
  719. {
  720. paquetes = new webServiceRedpack.Paquete[] { DeserializaPaquete(pJData) },
  721. consignatario = DeserializaConsignatario(pJData),
  722. remitente = DeserializaRemitente(pJData),
  723. tipoEntrega = new webServiceRedpack.IdDesc { id = 2, idSpecified = true },
  724. tipoEnvio = new webServiceRedpack.IdDesc { id = 2, idSpecified = true },
  725. tipoServicio = new webServiceRedpack.IdDesc { id = 2, idSpecified = true },
  726. flag = 1,
  727. moneda = "$",
  728. numeroDeGuia = idUser.ToString() + DateTime.Now.Millisecond.ToString()
  729. };
  730.  
  731. decimal TotalDiscount = 0, TotalAmount = 0;
  732. decimal TotalDiscountExpress = 0, TotalAmountExpress = 0;
  733.  
  734. var cotizacionGuias = wsClient.cotizacionNacional(pin, idUser, true, new webServiceRedpack.Guia[] { guia });
  735.  
  736.  
  737. // Asignamos la primera cotizacion al objeto que vamos a enviar a predocumentar
  738.  
  739.  
  740. if (cotizacionGuias != null)
  741. {
  742. foreach (var guiaCotizada in cotizacionGuias)
  743. {
  744. if (guiaCotizada.cotizaciones != null)
  745. {
  746. var ecoExpress = guiaCotizada.cotizaciones.FirstOrDefault(c => c.tipoServicio.descripcion == "ECOEXPRESS");
  747. HttpContext.Current.Session["cotizacion"] = ecoExpress;
  748.  
  749. var Express = guiaCotizada.cotizaciones.FirstOrDefault(c => c.tipoServicio.descripcion == "EXPRESS");
  750. HttpContext.Current.Session["cotizacionExpress"] = Express;
  751. }
  752.  
  753. }
  754.  
  755. }
  756.  
  757. }
  758.  
  759. else
  760. {
  761. //var idUser = 1127;
  762. //var pin = "PROD oNmnqC0wC1OKtdtGe8TaA663C2+gFNOX5kwuSaAvj70=";
  763.  
  764.  
  765. var idUser = 1332;
  766. var pin = "PROD oNmnqC0wC1PIP4xOOi+XU9mBaDD3H/WaXerHWc+YTv6/TY1QB+hqLQ==";
  767. var wsClient = new webServiceRedpack.RedpackWS();
  768. var guia = new webServiceRedpack.Guia
  769. {
  770. paquetes = new webServiceRedpack.Paquete[] { DeserializaPaquete(pJData) },
  771. consignatario = DeserializaConsignatario(pJData),
  772. remitente = DeserializaRemitente(pJData),
  773. tipoEntrega = new webServiceRedpack.IdDesc { id = 2, idSpecified = true },
  774. tipoEnvio = new webServiceRedpack.IdDesc { id = 2, idSpecified = true },
  775. tipoServicio = new webServiceRedpack.IdDesc { id = 2, idSpecified = true },
  776. flag = 1,
  777. moneda = "$",
  778. numeroDeGuia = idUser.ToString() + DateTime.Now.Millisecond.ToString()
  779. };
  780.  
  781. decimal TotalDiscount = 0, TotalAmount = 0;
  782. decimal TotalDiscountExpress = 0, TotalAmountExpress = 0;
  783.  
  784. var cotizacionGuias = wsClient.cotizacionNacional(pin, idUser, true, new webServiceRedpack.Guia[] { guia });
  785.  
  786.  
  787. // Asignamos la primera cotizacion al objeto que vamos a enviar a predocumentar
  788.  
  789.  
  790. if (cotizacionGuias != null)
  791. {
  792. foreach (var guiaCotizada in cotizacionGuias)
  793. {
  794. if (guiaCotizada.cotizaciones != null)
  795. {
  796. var ecoExpress = guiaCotizada.cotizaciones.FirstOrDefault(c => c.tipoServicio.descripcion == "ECOEXPRESS");
  797. HttpContext.Current.Session["cotizacion"] = ecoExpress;
  798.  
  799. var Express = guiaCotizada.cotizaciones.FirstOrDefault(c => c.tipoServicio.descripcion == "EXPRESS");
  800. HttpContext.Current.Session["cotizacionExpress"] = Express;
  801. }
  802.  
  803. }
  804.  
  805. }
  806.  
  807. }
  808.  
  809. //else
  810. //{
  811. // return "Tipo Servicio Incorrecto";
  812. //}
  813.  
  814.  
  815.  
  816.  
  817.  
  818.  
  819.  
  820.  
  821. return string.Empty;
  822. }
  823. #endregion
  824.  
  825.  
  826.  
  827. #region <<Generar Guía Comentado>>
  828.  
  829. [System.Web.Services.WebMethod]
  830. public static string GenerarGuiaPaquete(Object pJData)
  831. {
  832. dynamic data = JsonConvert.DeserializeObject(pJData.ToString());
  833. dynamic request = data[0];
  834. var returnValue = string.Empty;
  835.  
  836. double precio = data[0]["precio"];
  837.  
  838. decimal costo = Convert.ToDecimal(precio / 1.10);
  839. var guideRequest = new List<PaquetExpress.Guide.Data>
  840. {
  841. new PaquetExpress.Guide.Data
  842. {
  843. BillRad = "REQUEST", //Quien pagará la solicitud, sólo con REQUEST o ORIGIN pueden ser a crédito
  844. BillClntId = "5402609", //
  845. PymtMode = "PAID", //Modo de pago (PAID=PAGADO, TO_PAY=Flete por cobrar)
  846. PymtType = "C", //Tipo de pago (C:CREDITO, N:CONTADO)
  847. AddressList = new List<PaquetExpress.Guide.Address>
  848. {
  849. new PaquetExpress.Guide.Address
  850. {
  851. AddrLin1 = "MEXICO",
  852. AddrLin3 = request["estadoRemitente"],
  853. AddrLin4 = request["ciudadRemitente"],
  854. AddrLin5 = request["coloniaRemitente"],
  855. AddrLin6 = request["referenciaRemitente"],
  856. StrtName = request["direccionRemitente"],
  857. Drnr = "10",
  858. Phno1 = request["telefonoRemitente"],
  859. ZipCode = request["codigoPostalRemitente"],
  860. ClntName = request["nombreRemitente"],
  861. Email = request["correoRemitente"],
  862. Contacto = "emissary.mx",
  863. AddrType = "ORIGIN"
  864. },
  865. new PaquetExpress.Guide.Address
  866. {
  867. AddrLin1 = "MEXICO",
  868. AddrLin3 = request["estadoDestinatario"],
  869. AddrLin4 = request["ciudadDestinatario"],
  870. AddrLin5 = request["coloniaDestinatario"],
  871. AddrLin6 = request["referenciaDestinatario"],
  872. StrtName = request["direccionDestinatario"],
  873. Drnr = "20",
  874. Phno1 = request["telefonoDestinatario"],
  875. ZipCode = request["codigoPostalDestinatario"],
  876. ClntName = request["nombreDestinatario"],
  877. Email = request["correoDestinatario"],
  878. Contacto = "emissary.mx",
  879. AddrType = "DESTINATION"
  880. }
  881. },
  882. ItemList = new List<PaquetExpress.Guide.Item>
  883. {
  884. new PaquetExpress.Guide.Item
  885. {
  886. SrvcId = "PACKETS", //Clave de servicio: PACKETS=Paquet es, ENVELOPES=Sob res
  887. Weight = request["peso"], // Peso
  888. VolL = request["largo"], // Largo
  889. VolW = request["ancho"], // Ancho
  890. VolH = request["alto"], // Alto
  891. Cont = "PROTESIS",
  892. Qunt = "1"
  893. }
  894. },
  895. ServiceList = new List<PaquetExpress.Guide.Service>
  896. {
  897. new PaquetExpress.Guide.Service
  898. {
  899. SrvcId = "EAD", //Clave de servicio: RAD = Recolección a domicilio, EAD= Entrega a domicilio, INV= Valor declarado
  900. Value1 = "" //importes varios (COD o Seguro)
  901. },
  902. new PaquetExpress.Guide.Service
  903. {
  904. SrvcId = "RAD",//Clave de servicio: RAD = Recolección a domicilio, EAD= Entrega a domicilio, INV= Valor declarado
  905. Value1 = "" //importes varios (COD o Seguro)
  906. }
  907. }
  908. }
  909. };
  910.  
  911. var guideResponse = AsyncHelpers.RunSync<PaquetExpress.Guide.Response>(() => PaquetExpress.ServiceGuide.CreateAsync(guideRequest));
  912. if (guideResponse.Data != null)
  913. {
  914. using (WebClient client = new WebClient())
  915. {
  916. var service = "https://cc.paquetexpress.com.mx:8082/wsReportPaquetexpress/GenCartaPorte?trackingNoGen=" + guideResponse.Data;
  917. client.DownloadFile(service, System.Web.HttpContext.Current.Server.MapPath("/Files/produccion/") + guideResponse.Data + ".pdf");
  918.  
  919.  
  920.  
  921. var guia = guideResponse.Data;
  922.  
  923.  
  924. //string TrackingNo = service.TrackingNumber;
  925.  
  926. //string tipoGuia = "2";
  927.  
  928. //string TotalPrecio = HttpContext.Current.Session["Dhl_Terrestre"].ToString();
  929.  
  930. decimal TotalAmount = costo;
  931.  
  932. string tipoServicio = "2";
  933.  
  934. returnValue = guardarEnvio(pJData, TotalAmount, guia, tipoServicio);
  935.  
  936. }
  937. }
  938. return returnValue;
  939. }
  940.  
  941. #endregion
  942.  
  943.  
  944. #region <<Generar Guía DHL Comentado>>
  945.  
  946. [System.Web.Services.WebMethod]
  947. public static string GenerarGuiaDhl(Object pJData)
  948. {
  949.  
  950.  
  951. string userId = HttpContext.Current.Session["usuario_id"].ToString();
  952.  
  953.  
  954. dynamic Data = JsonConvert.DeserializeObject(pJData.ToString());
  955. int tipoServicio = Data[0]["tipoServicio"];
  956.  
  957. string numeroguiaDhl;
  958. var returnValue = string.Empty;
  959.  
  960. dynamic data = JsonConvert.DeserializeObject(pJData.ToString());
  961. dynamic request = data[0];
  962.  
  963.  
  964.  
  965. string Servicio = tipoServicio == 1 ? "ECONOMY SELECT DOMESTIC" : "EXPRESS DOMESTIC";
  966. var TotalAmount = tipoServicio == 1 ? 135f : 162.50f;
  967.  
  968. var shipmentRequest = new Common.Shipment.Request
  969. {
  970. ShipmentType = Servicio,
  971. From = new Common.Address
  972. {
  973. Name = request["nombreRemitente"],
  974. Company = request["nombreRemitente"],
  975. Email = request["correoRemitente"],
  976. Phone = request["telefonoRemitente"],
  977. Address1 = request["direccionRemitente"],
  978. Address2 = request["coloniaRemitente"],
  979. Address3 = request["referenciaRemitente"],
  980. City = request["ciudadRemitente"],
  981. State = request["estadoRemitente"],
  982. Country = "Mexico",
  983. ZipCode = request["codigoPostalRemitente"]
  984. },
  985. To = new Common.Address
  986. {
  987. Name = request["nombreDestinatario"],
  988. Company = request["nombreDestinatario"],
  989. Email = "envios@gmail.com",
  990. //Email = request["correoDestinatario"],
  991. Phone = request["telefonoDestinatario"],
  992. Address1 = request["direccionDestinatario"],
  993. Address2 = request["coloniaDestinatario"],
  994. Address3 = request["referenciaDestinatario"],
  995. City = request["ciudadDestinatario"],
  996. State = request["estadoDestinatario"],
  997. Country = "Mexico",
  998. ZipCode = request["codigoPostalDestinatario"]
  999. },
  1000. Package = new Common.Package
  1001. {
  1002. Description = request["envio"],
  1003. Value = 2000,
  1004. Quantity = 1,
  1005. Weight = (int)request["peso"],
  1006. Length = Convert.ToInt32(request["largo"]),
  1007. Width = Convert.ToInt32(request["ancho"]),
  1008. Height = Convert.ToInt32(request["alto"])
  1009. },
  1010. };
  1011.  
  1012. var guideData = AsyncHelpers.RunSync<Common.Shipment.Response>(() => Emissary.Dhl.ServiceShipment.CreateAsync(shipmentRequest));
  1013. if (guideData != null)
  1014. {
  1015. using (WebClient client = new WebClient())
  1016. {
  1017. var xxx = guideData.TrackNumber;
  1018.  
  1019. numeroguiaDhl = guideData.TrackNumber;
  1020. var file = guideData.Files.FirstOrDefault(f => f.Contains("TrackDocument"));
  1021. client.DownloadFile(file, System.Web.HttpContext.Current.Server.MapPath("/Files/produccion/") + numeroguiaDhl + ".pdf");
  1022.  
  1023. //string TrackingNo = guideData.TrackNumber;
  1024.  
  1025. string tipoGuia = "2";
  1026.  
  1027. string TrackingNo = numeroguiaDhl;
  1028. returnValue = guardarEnvio(pJData, (decimal)TotalAmount, TrackingNo, tipoGuia);
  1029.  
  1030. }
  1031. }
  1032.  
  1033. //if (tipoServicio == 1)
  1034. //{
  1035.  
  1036. // string servicio = "Terrestre";
  1037. // //VERSION OFICIAL
  1038.  
  1039. // //Cotización Cuenta 1
  1040. // 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);
  1041.  
  1042.  
  1043. // //Cotización Cuenta 2
  1044. // 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);
  1045.  
  1046.  
  1047.  
  1048. // //tipoGuia;
  1049.  
  1050.  
  1051. // if (TotalAmountCuenta1 < TotalAmountCuenta2)
  1052. // {
  1053. // 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);
  1054.  
  1055. // TotalAmount = TotalAmountCuenta1;
  1056. // }
  1057. // else
  1058. // {
  1059. // 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);
  1060. // TotalAmount = TotalAmountCuenta2;
  1061.  
  1062. // }
  1063.  
  1064.  
  1065.  
  1066.  
  1067. // //string key, string password, string accountnumber, string meternumber,
  1068. // //VERSION PRUEBA
  1069. // //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);
  1070. // //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);
  1071.  
  1072.  
  1073.  
  1074.  
  1075. // returnValue = guardarEnvio(pJData, TotalAmount, TrackingNo, tipoGuia);
  1076. //}
  1077.  
  1078. ///Generar Guía DHL
  1079. //var returnValue = string.Empty;
  1080.  
  1081. //dynamic data = JsonConvert.DeserializeObject(pJData.ToString());
  1082. //dynamic request = data[0];
  1083.  
  1084.  
  1085.  
  1086.  
  1087.  
  1088. return returnValue;
  1089.  
  1090.  
  1091. }
  1092.  
  1093.  
  1094. #endregion
  1095.  
  1096.  
  1097. #region <<Generar Guía>>
  1098. [WebMethod]
  1099. //public static string Guardar(string jData)
  1100. public static string generarGuia(Object pJData)
  1101. {
  1102. var returnValue = string.Empty;
  1103. try
  1104. {
  1105. dynamic Data = JsonConvert.DeserializeObject(pJData.ToString());
  1106.  
  1107.  
  1108. //GenerarGuiaDhl(pJData);
  1109.  
  1110. int paqueteriaId = Data[0]["paqueteriaId"];
  1111. int ordenId = Data[0]["ordenId"];
  1112.  
  1113.  
  1114. if (paqueteriaId == 1)
  1115. {
  1116. returnValue = generarGuiaFedex(pJData);
  1117. }
  1118. else if (paqueteriaId == 2)
  1119. {
  1120.  
  1121.  
  1122. //ObtenerCotizacionRedpack(pJData);
  1123.  
  1124. returnValue = generarGuiaRedpack(pJData);
  1125.  
  1126. }
  1127.  
  1128. else if (paqueteriaId == 3)
  1129. {
  1130. returnValue = generarGuiaFedexPesados(pJData);
  1131.  
  1132. }
  1133.  
  1134. else if (paqueteriaId == 4)
  1135. {
  1136. returnValue = GenerarGuiaDhl(pJData);
  1137.  
  1138. }
  1139.  
  1140. else if (paqueteriaId == 5)
  1141. {
  1142. returnValue = GenerarGuiaPaquete(pJData);
  1143.  
  1144. }
  1145.  
  1146. if (ordenId > 0)
  1147. {
  1148.  
  1149.  
  1150. string mensaje = "";
  1151. DataTable DataTable = new DataTable();
  1152. dbo.BaseDatos db = null;
  1153.  
  1154. db = new dbo.BaseDatos(ConfigurationManager.ConnectionStrings["cnn"].ToString());
  1155. SqlParameter prmOrden;
  1156.  
  1157. try
  1158. {
  1159. prmOrden = new SqlParameter("@ordenId", SqlDbType.BigInt);
  1160. prmOrden.Value = ordenId;
  1161.  
  1162.  
  1163. DataTable = db.ObtenerDatosComoDataTable("spac_Emissary_OrdenGenerada", prmOrden);
  1164. DataTable.TableName = "OrdenGenerada ";
  1165.  
  1166. mensaje = JsonConvert.SerializeObject(DataTable);
  1167. }
  1168. catch (Exception ex)
  1169. {
  1170. mensaje = ex.Message;
  1171. }
  1172. finally
  1173. {
  1174. db.Finalizar();
  1175. }
  1176.  
  1177. }
  1178.  
  1179.  
  1180. }
  1181. catch (Exception ex)
  1182. {
  1183. returnValue = ex.Message + " -- --" + ex.StackTrace;
  1184. }
  1185.  
  1186. return returnValue;
  1187. }
  1188.  
  1189.  
  1190.  
  1191.  
  1192.  
  1193.  
  1194.  
  1195.  
  1196. #endregion <<Guardar>>
  1197.  
  1198.  
  1199.  
  1200.  
  1201.  
  1202.  
  1203. #region <<Generar Guía Redpack>>
  1204. [WebMethod]
  1205. public static string generarGuiaRedpack(Object pJData)
  1206. {
  1207. dynamic Data = JsonConvert.DeserializeObject(pJData.ToString());
  1208.  
  1209.  
  1210.  
  1211.  
  1212. ObtenerCotizacionRedpack(pJData);
  1213.  
  1214.  
  1215. int tipoServicioRedpack = Data[0]["tipoServicio"];
  1216. int peso = Data[0]["peso"];
  1217.  
  1218. var returnValue = string.Empty;
  1219.  
  1220. int numGuiaGenerada;
  1221.  
  1222.  
  1223. var tipoGuia = consultarTipoGuiaRedpack();
  1224.  
  1225.  
  1226. if (tipoServicioRedpack == 1)
  1227. {
  1228.  
  1229.  
  1230.  
  1231.  
  1232. decimal TotalDiscount = 0, TotalAmount = 0;
  1233. decimal TotalDiscountExpress = 0, TotalAmountExpress = 0;
  1234. webServiceRedpack.Cotizacion ecoExpress = (webServiceRedpack.Cotizacion)HttpContext.Current.Session["cotizacion"];
  1235.  
  1236.  
  1237.  
  1238. var costoTotal = ecoExpress.tarifa;
  1239. decimal DescuentoTotal = TotalDiscount;
  1240. decimal CostoTotalExpress = TotalAmountExpress;
  1241. decimal DescuentoTotalExpress = TotalDiscountExpress;
  1242.  
  1243. int idUser;
  1244. string pin;
  1245.  
  1246. if (peso == 1)
  1247. {
  1248.  
  1249. idUser = 1127;
  1250. pin = "PROD oNmnqC0wC1OKtdtGe8TaA663C2+gFNOX5kwuSaAvj70=";
  1251. }
  1252. else
  1253. {
  1254.  
  1255. idUser = 1332;
  1256. pin = "PROD oNmnqC0wC1PIP4xOOi+XU9mBaDD3H/WaXerHWc+YTv6/TY1QB+hqLQ==";
  1257.  
  1258. }
  1259.  
  1260. string nuevoFolio;
  1261.  
  1262.  
  1263. string folio = "";
  1264. DataTable DataTable = new DataTable();
  1265. dbo.BaseDatos db = null;
  1266.  
  1267. db = new dbo.BaseDatos(ConfigurationManager.ConnectionStrings["cnn"].ToString());
  1268. SqlParameter prmTipoServicioR, prmPeso;
  1269.  
  1270. try
  1271. {
  1272.  
  1273. prmTipoServicioR = new SqlParameter("@tipoServicio", SqlDbType.Int);
  1274. prmTipoServicioR.Value = tipoServicioRedpack;
  1275. prmPeso = new SqlParameter("@peso", SqlDbType.Int);
  1276. prmPeso.Value = peso;
  1277.  
  1278.  
  1279.  
  1280. DataTable = db.ObtenerDatosComoDataTable("[spq_UltimoFolioRedpackUsado]", prmTipoServicioR, prmPeso);
  1281. DataTable.TableName = "Direcciones";
  1282.  
  1283. folio = JsonConvert.SerializeObject(DataTable);
  1284.  
  1285.  
  1286. nuevoFolio = DataTable.Rows[0]["folio"].ToString();
  1287.  
  1288. var wsClient = new webServiceRedpack.RedpackWS();
  1289. var guia = new webServiceRedpack.Guia
  1290. {
  1291. paquetes = new webServiceRedpack.Paquete[] { DeserializaPaquete(pJData) },
  1292. consignatario = DeserializaConsignatario(pJData),
  1293. remitente = DeserializaRemitente(pJData),
  1294. tipoEntrega = new webServiceRedpack.IdDesc { id = 2, idSpecified = true },
  1295. tipoEnvio = new webServiceRedpack.IdDesc { id = 2, idSpecified = true },
  1296. tipoServicio = new webServiceRedpack.IdDesc { id = 2, idSpecified = true },
  1297. moneda = "1",
  1298. referencia = Data[0]["referenciaDestinatario"],
  1299. numeroDeGuia = nuevoFolio,
  1300.  
  1301. flag = 2,
  1302. flagSpecified = true
  1303. };
  1304.  
  1305. var guiaGenerada = wsClient.predocumentacion(pin, idUser, true, new webServiceRedpack.Guia[] { guia });
  1306. string LabelPath = System.Web.HttpContext.Current.Server.MapPath("/Files/produccion/");
  1307. if (guiaGenerada[0].paquetes[0].formatoEtiqueta != null)
  1308. {
  1309.  
  1310.  
  1311. numGuiaGenerada = Convert.ToInt32(guiaGenerada[0].numeroDeGuia + DateTime.Now.Ticks.ToString());
  1312. var LabelFile = new FileStream(LabelPath + numGuiaGenerada + ".pdf", FileMode.Create);
  1313. LabelFile.Write(guiaGenerada[0].paquetes[0].formatoEtiqueta, 0, guiaGenerada[0].paquetes[0].formatoEtiqueta.Length);
  1314. LabelFile.Close();
  1315. }
  1316. else
  1317. {
  1318. string numGuia;
  1319. for (int i = 0; i < 100; i++)
  1320. {
  1321. if (guiaGenerada[0].resultadoConsumoWS[0].estatus == 58 || guiaGenerada[0].resultadoConsumoWS[0].estatus == 59)
  1322. {
  1323.  
  1324. nuevoFolio = DataTable.Rows[0]["folio"].ToString();
  1325.  
  1326. int newFolio = Int32.Parse(nuevoFolio) + i;
  1327.  
  1328. nuevoFolio = newFolio.ToString();
  1329.  
  1330. wsClient = new webServiceRedpack.RedpackWS();
  1331. guia = new webServiceRedpack.Guia
  1332. {
  1333. paquetes = new webServiceRedpack.Paquete[] { DeserializaPaquete(pJData) },
  1334. consignatario = DeserializaConsignatario(pJData),
  1335. remitente = DeserializaRemitente(pJData),
  1336. tipoEntrega = new webServiceRedpack.IdDesc { id = 2, idSpecified = true },
  1337. tipoEnvio = new webServiceRedpack.IdDesc { id = 2, idSpecified = true },
  1338. tipoServicio = new webServiceRedpack.IdDesc { id = 2, idSpecified = true },
  1339. moneda = "1",
  1340. referencia = Data[0]["referenciaDestinatario"],
  1341. numeroDeGuia = nuevoFolio + i,
  1342. //numeroDeGuia = idUser.ToString() + DateTime.Now.Millisecond.ToString(),
  1343. flag = 2,
  1344. flagSpecified = true
  1345. };
  1346. guiaGenerada = wsClient.predocumentacion(pin, idUser, true, new webServiceRedpack.Guia[] { guia });
  1347. LabelPath = System.Web.HttpContext.Current.Server.MapPath("/Files/produccion/");
  1348. if (guiaGenerada[0].paquetes[0].formatoEtiqueta != null)
  1349. {
  1350.  
  1351. numGuia = guiaGenerada[0].numeroDeGuia;
  1352. numGuiaGenerada = Convert.ToInt32(guiaGenerada[0].numeroDeGuia);
  1353.  
  1354.  
  1355.  
  1356.  
  1357. var LabelFile = new FileStream(LabelPath + numGuiaGenerada + ".pdf", FileMode.Create);
  1358.  
  1359.  
  1360.  
  1361. LabelFile.Write(guiaGenerada[0].paquetes[0].formatoEtiqueta, 0, guiaGenerada[0].paquetes[0].formatoEtiqueta.Length);
  1362. LabelFile.Close();
  1363.  
  1364.  
  1365.  
  1366.  
  1367. break;
  1368. }
  1369.  
  1370. }
  1371.  
  1372.  
  1373.  
  1374. }
  1375. }
  1376.  
  1377.  
  1378.  
  1379. DataTable = new DataTable();
  1380. db = null;
  1381. SqlParameter prmFolio, prmNoTracking, prmTipoServicio, prmPesoEnviado;
  1382. try
  1383. {
  1384. db = new dbo.BaseDatos(ConfigurationManager.ConnectionStrings["cnn"].ToString());
  1385. numGuiaGenerada = Convert.ToInt32(guiaGenerada[0].numeroDeGuia);
  1386.  
  1387. prmFolio = new SqlParameter("@Folio", SqlDbType.NVarChar, 50);
  1388. prmFolio.Value = guiaGenerada[0].numeroDeGuia;
  1389. prmNoTracking = new SqlParameter("@NoTracking", SqlDbType.NVarChar, 50);
  1390. prmNoTracking.Value = numGuiaGenerada;
  1391. prmTipoServicio = new SqlParameter("@tipoServicio", SqlDbType.NVarChar, 50);
  1392. prmTipoServicio.Value = tipoServicioRedpack;
  1393. prmPesoEnviado = new SqlParameter("@peso", SqlDbType.NVarChar, 50);
  1394. prmPesoEnviado.Value = peso;
  1395.  
  1396.  
  1397.  
  1398. DataTable = db.ObtenerDatosComoDataTable("spa_Emissary_FolioRedpack2019", prmFolio, prmNoTracking, prmTipoServicio, prmPesoEnviado);
  1399. //dataset.TableName = "Usuario";
  1400. //[spac_Emissary_Direccion]
  1401. //mensaje = JsonConvert.SerializeObject(DataTable);
  1402.  
  1403.  
  1404.  
  1405. }
  1406. finally
  1407. {
  1408. string mensaje = "OK";
  1409. }
  1410.  
  1411. string TrackingNo = Convert.ToString(numGuiaGenerada);
  1412. returnValue = guardarEnvio(pJData, (decimal)costoTotal, TrackingNo, tipoGuia);
  1413.  
  1414. }
  1415. catch (Exception ex)
  1416. {
  1417. returnValue = ex.Message + " -- " + ex.StackTrace.ToString();
  1418. folio = ex.Message;
  1419. }
  1420. finally
  1421. {
  1422. db.Finalizar();
  1423. }
  1424.  
  1425.  
  1426.  
  1427.  
  1428.  
  1429. }
  1430.  
  1431.  
  1432.  
  1433. else if (tipoServicioRedpack == 2)
  1434. {
  1435.  
  1436. string servicio = "Áereo";
  1437.  
  1438.  
  1439. decimal TotalDiscount = 0, TotalAmount = 0;
  1440. decimal TotalDiscountExpress = 0, TotalAmountExpress = 0;
  1441. webServiceRedpack.Cotizacion Express = (webServiceRedpack.Cotizacion)HttpContext.Current.Session["cotizacionExpress"];
  1442.  
  1443.  
  1444.  
  1445. var costoTotal = Express.tarifa;
  1446. decimal DescuentoTotal = TotalDiscount;
  1447. decimal CostoTotalExpress = TotalAmountExpress;
  1448. decimal DescuentoTotalExpress = TotalDiscountExpress;
  1449.  
  1450. //var idUser = 1127;
  1451. var idUser = 1332;
  1452. string pin = "PROD oNmnqC0wC1PIP4xOOi+XU9mBaDD3H/WaXerHWc+YTv6/TY1QB+hqLQ==";
  1453. //var idUser = 1127;
  1454. //string pin= "PROD oNmnqC0wC1OKtdtGe8TaA663C2+gFNOX5kwuSaAvj70=";
  1455.  
  1456. string nuevoFolio;
  1457.  
  1458.  
  1459. string folio = "";
  1460. DataTable DataTable = new DataTable();
  1461. dbo.BaseDatos db = null;
  1462.  
  1463. db = new dbo.BaseDatos(ConfigurationManager.ConnectionStrings["cnn"].ToString());
  1464. SqlParameter prmTipoServicioR, prmPeso;
  1465.  
  1466. try
  1467. {
  1468.  
  1469. prmTipoServicioR = new SqlParameter("@tipoServicio", SqlDbType.Int);
  1470. prmTipoServicioR.Value = tipoServicioRedpack;
  1471. prmPeso = new SqlParameter("@peso", SqlDbType.Int);
  1472. prmPeso.Value = peso;
  1473.  
  1474.  
  1475.  
  1476. DataTable = db.ObtenerDatosComoDataTable("[spq_UltimoFolioRedpackUsado]", prmTipoServicioR, prmPeso);
  1477. DataTable.TableName = "Direcciones";
  1478.  
  1479. folio = JsonConvert.SerializeObject(DataTable);
  1480.  
  1481. nuevoFolio = DataTable.Rows[0]["folio"].ToString();
  1482.  
  1483. var wsClient = new webServiceRedpack.RedpackWS();
  1484. var guia = new webServiceRedpack.Guia
  1485. {
  1486. paquetes = new webServiceRedpack.Paquete[] { DeserializaPaquete(pJData) },
  1487. consignatario = DeserializaConsignatario(pJData),
  1488. remitente = DeserializaRemitente(pJData),
  1489. tipoEntrega = new webServiceRedpack.IdDesc { id = 2, idSpecified = true },
  1490. tipoEnvio = new webServiceRedpack.IdDesc { id = 2, idSpecified = true },
  1491. tipoServicio = new webServiceRedpack.IdDesc { id = 2, idSpecified = true },
  1492. moneda = "1",
  1493. referencia = Data[0]["referenciaDestinatario"],
  1494. numeroDeGuia = nuevoFolio,
  1495.  
  1496. flag = 2,
  1497. flagSpecified = true
  1498. };
  1499.  
  1500. var guiaGenerada = wsClient.predocumentacion(pin, idUser, true, new webServiceRedpack.Guia[] { guia });
  1501. string LabelPath = System.Web.HttpContext.Current.Server.MapPath("/Files/produccion/");
  1502. if (guiaGenerada[0].paquetes[0].formatoEtiqueta != null)
  1503. {
  1504.  
  1505.  
  1506.  
  1507. numGuiaGenerada = Convert.ToInt32(guiaGenerada[0].numeroDeGuia);
  1508.  
  1509. var LabelFile = new FileStream(LabelPath + numGuiaGenerada + ".pdf", FileMode.Create);
  1510. LabelFile.Write(guiaGenerada[0].paquetes[0].formatoEtiqueta, 0, guiaGenerada[0].paquetes[0].formatoEtiqueta.Length);
  1511. LabelFile.Close();
  1512. }
  1513. else
  1514. {
  1515. string numGuia;
  1516. for (int i = 0; i < 10; i++)
  1517. {
  1518. if (guiaGenerada[0].resultadoConsumoWS[0].estatus == 58 || guiaGenerada[0].resultadoConsumoWS[0].estatus == 59)
  1519. {
  1520.  
  1521. nuevoFolio = DataTable.Rows[0]["folio"].ToString();
  1522.  
  1523. int newFolio = Int32.Parse(nuevoFolio) + i;
  1524.  
  1525. nuevoFolio = newFolio.ToString();
  1526.  
  1527. wsClient = new webServiceRedpack.RedpackWS();
  1528. guia = new webServiceRedpack.Guia
  1529. {
  1530. paquetes = new webServiceRedpack.Paquete[] { DeserializaPaquete(pJData) },
  1531. consignatario = DeserializaConsignatario(pJData),
  1532. remitente = DeserializaRemitente(pJData),
  1533. tipoEntrega = new webServiceRedpack.IdDesc { id = 2, idSpecified = true },
  1534. tipoEnvio = new webServiceRedpack.IdDesc { id = 2, idSpecified = true },
  1535. tipoServicio = new webServiceRedpack.IdDesc { id = 2, idSpecified = true },
  1536. moneda = "1",
  1537. referencia = Data[0]["referenciaDestinatario"],
  1538. numeroDeGuia = nuevoFolio + i,
  1539. //numeroDeGuia = idUser.ToString() + DateTime.Now.Millisecond.ToString(),
  1540. flag = 2,
  1541. flagSpecified = true
  1542. };
  1543. guiaGenerada = wsClient.predocumentacion(pin, idUser, true, new webServiceRedpack.Guia[] { guia });
  1544. LabelPath = System.Web.HttpContext.Current.Server.MapPath("/Files/produccion/");
  1545. if (guiaGenerada[0].paquetes[0].formatoEtiqueta != null)
  1546. {
  1547. numGuiaGenerada = Convert.ToInt32(guiaGenerada[0].numeroDeGuia);
  1548.  
  1549. numGuia = guiaGenerada[0].numeroDeGuia;
  1550. var LabelFile = new FileStream(LabelPath + numGuiaGenerada + ".pdf", FileMode.Create);
  1551.  
  1552.  
  1553.  
  1554. LabelFile.Write(guiaGenerada[0].paquetes[0].formatoEtiqueta, 0, guiaGenerada[0].paquetes[0].formatoEtiqueta.Length);
  1555. LabelFile.Close();
  1556.  
  1557.  
  1558.  
  1559.  
  1560. break;
  1561. }
  1562.  
  1563. }
  1564.  
  1565.  
  1566.  
  1567. }
  1568. }
  1569.  
  1570.  
  1571.  
  1572. DataTable = new DataTable();
  1573. db = null;
  1574. SqlParameter prmFolio, prmNoTracking, prmTipoServicio;
  1575. try
  1576. {
  1577. db = new dbo.BaseDatos(ConfigurationManager.ConnectionStrings["cnn"].ToString());
  1578. numGuiaGenerada = Convert.ToInt32(guiaGenerada[0].numeroDeGuia);
  1579.  
  1580.  
  1581. prmFolio = new SqlParameter("@Folio", SqlDbType.BigInt);
  1582. prmFolio.Value = guia.numeroDeGuia;
  1583. prmNoTracking = new SqlParameter("@NoTracking", SqlDbType.NVarChar, 50);
  1584. prmNoTracking.Value = numGuiaGenerada;
  1585. prmTipoServicio = new SqlParameter("@tipoServicio", SqlDbType.NVarChar, 50);
  1586. prmTipoServicio.Value = 2;
  1587.  
  1588.  
  1589.  
  1590. DataTable = db.ObtenerDatosComoDataTable("spa_Emissary_FolioRedpack", prmFolio, prmNoTracking, prmTipoServicio);
  1591. //dataset.TableName = "Usuario";
  1592. //[spac_Emissary_Direccion]
  1593. //mensaje = JsonConvert.SerializeObject(DataTable);
  1594.  
  1595.  
  1596.  
  1597. }
  1598. finally
  1599. {
  1600. string mensaje = "OK";
  1601. }
  1602. numGuiaGenerada = Convert.ToInt32(guiaGenerada[0].numeroDeGuia);
  1603.  
  1604. string TrackingNo = Convert.ToString(numGuiaGenerada);
  1605. returnValue = guardarEnvio(pJData, (decimal)costoTotal, TrackingNo, tipoGuia);
  1606. // string folio = "";
  1607. //DataTable DataTable = new DataTable();
  1608. //dbo.BaseDatos db = null;
  1609.  
  1610. //db = new dbo.BaseDatos(ConfigurationManager.ConnectionStrings["cnn"].ToString());
  1611. //SqlParameter prmUserId;
  1612.  
  1613. //try
  1614. //{
  1615.  
  1616.  
  1617.  
  1618. // DataTable = db.ObtenerDatosComoDataTable("spq_Emissary_UltimoFolioRedpackExpress");
  1619. // DataTable.TableName = "Direcciones";
  1620.  
  1621.  
  1622.  
  1623.  
  1624.  
  1625. }
  1626. catch (Exception ex)
  1627. {
  1628. folio = ex.Message;
  1629. }
  1630. finally
  1631. {
  1632. db.Finalizar();
  1633. }
  1634.  
  1635.  
  1636.  
  1637.  
  1638. }
  1639.  
  1640.  
  1641.  
  1642.  
  1643.  
  1644. return returnValue;
  1645. }
  1646.  
  1647.  
  1648. [WebMethod]
  1649. 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)
  1650. {
  1651.  
  1652. //var wsClient = new webServiceRedpack.RedpackWS();
  1653. //var paquete = new webServiceRedpack.Paquete
  1654. //{
  1655. // alto = Length,
  1656. // altoSpecified = true,
  1657. // ancho = Width,
  1658. // anchoSpecified = true,
  1659. // peso = (float)Weight,
  1660. // largo = Length,
  1661. // largoSpecified = true
  1662. //};
  1663.  
  1664. //var guia = new webServiceRedpack.Guia
  1665. //{
  1666. // paquetes = new webServiceRedpack.Paquete[] { paquete },
  1667. // consignatario = new webServiceRedpack.Direccion { codigoPostal = Int32.Parse(FromPostalCode), codigoPostalSpecified = true },
  1668. // remitente = new webServiceRedpack.Direccion { codigoPostal = Int32.Parse(ToPostalCode), codigoPostalSpecified = true },
  1669. // tipoEntrega = new webServiceRedpack.IdDesc { id = 2 },
  1670. // flag = 1
  1671. //};
  1672.  
  1673. //var response = wsClient.cotizacionNacional("PROD oNmnqC0wC1OKtdtGe8TaA663C2+gFNOX5kwuSaAvj70=", 1127, new webServiceRedpack.Guia[] { guia });
  1674. //var guias = wsClient.generaGuiaElectronica("PROD oNmnqC0wC1OKtdtGe8TaA663C2+gFNOX5kwuSaAvj70=", 1127, new webServiceRedpack.Guia[] { guia });
  1675.  
  1676.  
  1677. string userId = HttpContext.Current.Session["usuario_id"].ToString();
  1678. return userId;
  1679. }
  1680.  
  1681.  
  1682.  
  1683.  
  1684.  
  1685.  
  1686.  
  1687. #endregion <<Cotizar Redpack>>
  1688.  
  1689.  
  1690.  
  1691.  
  1692.  
  1693.  
  1694.  
  1695. public static string generarGuiaFedex(Object pJData)
  1696. {
  1697. dynamic Data = JsonConvert.DeserializeObject(pJData.ToString());
  1698.  
  1699. int tipoServicio = Data[0]["tipoServicio"];
  1700.  
  1701. Int64 envioId;
  1702.  
  1703. string userId = HttpContext.Current.Session["usuario_id"].ToString();
  1704.  
  1705. //REMITENTE
  1706. //string tipoServicio;
  1707. string precio;
  1708.  
  1709. //REMITENTE
  1710. string nombreRemitente;
  1711. string correoRemitente;
  1712. string telefonoRemitente;
  1713. string direccionRemitente;
  1714. string referenciaRemitente;
  1715. string coloniaRemitente;
  1716. string codigoPostalRemitente;
  1717. string ciudadRemitente;
  1718. string estadoRemitente;
  1719.  
  1720.  
  1721. //DESTINATARIO
  1722.  
  1723. string nombreDestinatario;
  1724. string correoDestinatario;
  1725. string telefonoDestinatario;
  1726. string direccionDestinatario;
  1727. string referenciaDestinatario;
  1728. string coloniaDestinatario;
  1729. string codigoPostalDestinatario;
  1730. string ciudadDestinatario;
  1731. string estadoDestinatario;
  1732.  
  1733.  
  1734. //DIMENSIONES
  1735.  
  1736. string largo;
  1737. string ancho;
  1738. string alto;
  1739. string peso;
  1740. string envio;
  1741. int paqueteriaId;
  1742.  
  1743.  
  1744.  
  1745. //dynamic Data = JsonConvert.DeserializeObject(pJData.ToString());
  1746.  
  1747. tipoServicio = Data[0]["tipoServicio"]; //FromName
  1748. precio = Data[0]["precio"]; //FromeMail
  1749.  
  1750. //envioId = Data[0]["envioId"];
  1751. //GENERALES
  1752. nombreRemitente = Data[0]["nombreRemitente"]; //FromName
  1753. correoRemitente = Data[0]["correoRemitente"]; //FromeMail
  1754. telefonoRemitente = Data[0]["telefonoRemitente"]; //FromPhone
  1755. direccionRemitente = Data[0]["direccionRemitente"]; //FromStreth
  1756. referenciaRemitente = Data[0]["referenciaRemitente"]; //FromComents
  1757. coloniaRemitente = Data[0]["coloniaRemitente"]; //FromAdress
  1758. codigoPostalRemitente = Data[0]["codigoPostalRemitente"]; //FromPostalCode
  1759. ciudadRemitente = Data[0]["ciudadRemitente"]; //City
  1760. estadoRemitente = Data[0]["estadoRemitente"]; //FromCity
  1761.  
  1762. //string telefonoFrom = "+518119173228"; //FromPhone correct
  1763. //DESTINATARIO
  1764.  
  1765. nombreDestinatario = Data[0]["nombreDestinatario"]; //To NAme
  1766. //correoDestinatario = Data[0]["correoDestinatario"] +"" ;//ToMail
  1767. correoDestinatario = "envios@gmail.com";//ToMail
  1768.  
  1769. telefonoDestinatario = Data[0]["telefonoDestinatario"]; //ToPhone
  1770. direccionDestinatario = Data[0]["direccionDestinatario"]; //ToStreth
  1771. referenciaDestinatario = Data[0]["referenciaDestinatario"]; //ToComents
  1772. coloniaDestinatario = Data[0]["coloniaDestinatario"]; //ToAdress
  1773. codigoPostalDestinatario = Data[0]["codigoPostalDestinatario"]; //ToPostalCOde
  1774. ciudadDestinatario = Data[0]["ciudadDestinatario"]; //ToCity
  1775. estadoDestinatario = Data[0]["estadoDestinatario"]; //ToCity
  1776.  
  1777. //string telefonoTo = "+52" + telefonoDestinatario; //FromPhone correct
  1778.  
  1779.  
  1780. //DIMENSIONES
  1781.  
  1782. largo = Data[0]["largo"];
  1783. ancho = Data[0]["ancho"];
  1784. alto = Data[0]["alto"];
  1785. peso = Data[0]["peso"];
  1786. envio = Data[0]["envio"];
  1787.  
  1788. //PAQUETERIA
  1789. paqueteriaId = Data[0]["paqueteriaId"];
  1790.  
  1791. string mensaje = string.Empty;
  1792.  
  1793. string FromName = nombreRemitente;
  1794. string FromCompany = "Emissary";
  1795. string FromAddress = direccionRemitente;
  1796. string FromColonia = coloniaRemitente;
  1797. string FromReference = referenciaRemitente;
  1798. string FromCity = ciudadRemitente;
  1799. string FromState = estadoRemitente;
  1800. string FromPostalCode = codigoPostalRemitente;
  1801. string FromCountryCode = "MX";
  1802. string telefonoFrom = telefonoRemitente;
  1803.  
  1804. string ReceiverName = nombreDestinatario;
  1805. string ReceiverCompany = "Emissary";
  1806. string ReceiverPhoneNumber = telefonoDestinatario;
  1807. string ReceiverAddress = direccionDestinatario;
  1808. string ReceiverColonia = coloniaDestinatario;
  1809. string ReceiverReference = referenciaDestinatario;
  1810. string ReceiverCity = ciudadDestinatario;
  1811. string ReceiverState = estadoDestinatario;
  1812. string ReceiverPostalCode = codigoPostalDestinatario;
  1813. string ReceiverCountryCode = "MX";
  1814. string telefonoTo = telefonoDestinatario;
  1815. int Quantity = 1;
  1816. int Length = int.Parse(largo);
  1817. int Width = int.Parse(ancho);
  1818. int Height = int.Parse(alto);
  1819. decimal Weight = decimal.Parse(peso);
  1820. byte[] numArray = null;
  1821. string TrackingNo = string.Empty;
  1822. string LabelImage = string.Empty;
  1823. string wsResponseDescription = string.Empty;
  1824. string wsResponseStatus = string.Empty;
  1825. string ShipmentIdentificationNumber = string.Empty;
  1826. string TransportationCharges = string.Empty;
  1827. string ServiceCharge = string.Empty;
  1828. string TotalCost = string.Empty;
  1829.  
  1830. decimal TotalDiscountCuenta1 = 0, TotalAmountCuenta1 = 0;
  1831. decimal TotalDiscountCuenta2 = 0, TotalAmountCuenta2 = 0;
  1832. decimal TotalAmount;
  1833. var returnValue = string.Empty;
  1834.  
  1835. var tipoGuia = consultarTipoGuiaFedex();
  1836.  
  1837. if (tipoServicio == 1)
  1838. {
  1839.  
  1840.  
  1841. string servicio = "Terrestre";
  1842. //VERSION OFICIAL
  1843.  
  1844. //Pesoprueba
  1845.  
  1846. //Cotización Cuenta 1
  1847. 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);
  1848.  
  1849.  
  1850. //Cotización Cuenta 2
  1851.  
  1852. 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);
  1853.  
  1854. if (TotalAmountCuenta1 < TotalAmountCuenta2)
  1855. {
  1856. 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);
  1857.  
  1858. TotalAmount = TotalAmountCuenta1;
  1859. }
  1860. else
  1861. {
  1862. 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);
  1863. TotalAmount = TotalAmountCuenta2;
  1864.  
  1865. }
  1866.  
  1867.  
  1868.  
  1869. //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);
  1870.  
  1871. //TotalAmount = TotalAmountCuenta1;
  1872.  
  1873. //tipoGuia;
  1874.  
  1875. //if CUENTA GRANDE
  1876.  
  1877. //if (TotalAmountCuenta1 < TotalAmountCuenta2)
  1878. //{
  1879. // 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);
  1880.  
  1881. // TotalAmount = TotalAmountCuenta1;
  1882. //}
  1883. //else
  1884. //{
  1885. // 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);
  1886. // TotalAmount = TotalAmountCuenta2;
  1887.  
  1888. //}
  1889.  
  1890.  
  1891.  
  1892.  
  1893. //string key, string password, string accountnumber, string meternumber,
  1894. //VERSION PRUEBA
  1895. //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);
  1896. //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);
  1897.  
  1898.  
  1899.  
  1900.  
  1901. returnValue = guardarEnvio(pJData, TotalAmount, TrackingNo, tipoGuia);
  1902. }
  1903. //else if(tipoServicio ==2)
  1904. else if (tipoServicio == 2)
  1905. {
  1906.  
  1907. //var tipoGuia = consultarTipoGuiaFedex();
  1908.  
  1909. string servicio = "Áereo";
  1910.  
  1911.  
  1912. //VERSION OFICIAL
  1913.  
  1914.  
  1915. //Cotización Cuenta 1
  1916. 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);
  1917.  
  1918.  
  1919. //Cotización Cuenta 2
  1920. 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);
  1921.  
  1922.  
  1923. //if AEREO
  1924.  
  1925. if (TotalAmountCuenta1 < TotalAmountCuenta2)
  1926. {
  1927.  
  1928. 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);
  1929.  
  1930.  
  1931. TotalAmount = TotalAmountCuenta1;
  1932. }
  1933. else
  1934. {
  1935. 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);
  1936. TotalAmount = TotalAmountCuenta2;
  1937.  
  1938. }
  1939.  
  1940.  
  1941. //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);
  1942.  
  1943.  
  1944. //TotalAmount = TotalAmountCuenta1;
  1945.  
  1946.  
  1947.  
  1948.  
  1949.  
  1950.  
  1951.  
  1952.  
  1953.  
  1954. //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);
  1955. //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);
  1956.  
  1957. //TotalAmount = TotalAmountCuenta1;
  1958.  
  1959. returnValue = guardarEnvio(pJData, TotalAmount, TrackingNo, tipoGuia);
  1960. }
  1961.  
  1962. else
  1963. {
  1964. returnValue = "Tipo Servicio Inexistente";
  1965. }
  1966.  
  1967. return returnValue;
  1968. }
  1969.  
  1970.  
  1971.  
  1972. public static string generarGuiaFedexPesados(Object pJData)
  1973. {
  1974. dynamic Data = JsonConvert.DeserializeObject(pJData.ToString());
  1975.  
  1976. int tipoServicio = Data[0]["tipoServicio"];
  1977.  
  1978. Int64 envioId;
  1979.  
  1980. string userId = HttpContext.Current.Session["usuario_id"].ToString();
  1981.  
  1982. //REMITENTE
  1983. //string tipoServicio;
  1984. string precio;
  1985.  
  1986. //REMITENTE
  1987. string nombreRemitente;
  1988. string correoRemitente;
  1989. string telefonoRemitente;
  1990. string direccionRemitente;
  1991. string referenciaRemitente;
  1992. string coloniaRemitente;
  1993. string codigoPostalRemitente;
  1994. string ciudadRemitente;
  1995. string estadoRemitente;
  1996.  
  1997.  
  1998. //DESTINATARIO
  1999.  
  2000. string nombreDestinatario;
  2001. string correoDestinatario;
  2002. string telefonoDestinatario;
  2003. string direccionDestinatario;
  2004. string referenciaDestinatario;
  2005. string coloniaDestinatario;
  2006. string codigoPostalDestinatario;
  2007. string ciudadDestinatario;
  2008. string estadoDestinatario;
  2009.  
  2010.  
  2011. //DIMENSIONES
  2012.  
  2013. string largo;
  2014. string ancho;
  2015. string alto;
  2016. string peso;
  2017. string envio;
  2018. int paqueteriaId;
  2019.  
  2020.  
  2021.  
  2022. //dynamic Data = JsonConvert.DeserializeObject(pJData.ToString());
  2023.  
  2024. tipoServicio = Data[0]["tipoServicio"]; //FromName
  2025. precio = Data[0]["precio"]; //FromeMail
  2026.  
  2027. //envioId = Data[0]["envioId"];
  2028. //GENERALES
  2029. nombreRemitente = Data[0]["nombreRemitente"]; //FromName
  2030. correoRemitente = Data[0]["correoRemitente"]; //FromeMail
  2031. telefonoRemitente = Data[0]["telefonoRemitente"]; //FromPhone
  2032. direccionRemitente = Data[0]["direccionRemitente"]; //FromStreth
  2033. referenciaRemitente = Data[0]["referenciaRemitente"]; //FromComents
  2034. coloniaRemitente = Data[0]["coloniaRemitente"]; //FromAdress
  2035. codigoPostalRemitente = Data[0]["codigoPostalRemitente"]; //FromPostalCode
  2036. ciudadRemitente = Data[0]["ciudadRemitente"]; //City
  2037. estadoRemitente = Data[0]["estadoRemitente"]; //FromCity
  2038.  
  2039. //string telefonoFrom = "+518119173228"; //FromPhone correct
  2040. //DESTINATARIO
  2041.  
  2042. nombreDestinatario = Data[0]["nombreDestinatario"]; //To NAme
  2043. //correoDestinatario = Data[0]["correoDestinatario"];//ToMail
  2044. correoDestinatario = "envios@guias.com";//ToMail
  2045.  
  2046. telefonoDestinatario = Data[0]["telefonoDestinatario"]; //ToPhone
  2047. direccionDestinatario = Data[0]["direccionDestinatario"]; //ToStreth
  2048. referenciaDestinatario = Data[0]["referenciaDestinatario"]; //ToComents
  2049. coloniaDestinatario = Data[0]["coloniaDestinatario"]; //ToAdress
  2050. codigoPostalDestinatario = Data[0]["codigoPostalDestinatario"]; //ToPostalCOde
  2051.  
  2052. ciudadDestinatario = Data[0]["ciudadDestinatario"]; //ToCity
  2053. estadoDestinatario = Data[0]["estadoDestinatario"]; //ToCity
  2054.  
  2055. //string telefonoTo = "+52" + telefonoDestinatario; //FromPhone correct
  2056.  
  2057.  
  2058. //DIMENSIONES
  2059.  
  2060. largo = Data[0]["largo"];
  2061. ancho = Data[0]["ancho"];
  2062. alto = Data[0]["alto"];
  2063. peso = Data[0]["peso"];
  2064. envio = Data[0]["envio"];
  2065.  
  2066. //PAQUETERIA
  2067. paqueteriaId = Data[0]["paqueteriaId"];
  2068.  
  2069. string mensaje = string.Empty;
  2070.  
  2071. string FromName = nombreRemitente;
  2072. string FromCompany = "Emissary";
  2073. string FromAddress = direccionRemitente;
  2074. string FromColonia = coloniaRemitente;
  2075. string FromReference = referenciaRemitente;
  2076.  
  2077. string FromCity = ciudadRemitente;
  2078. string FromState = estadoRemitente;
  2079. string FromPostalCode = codigoPostalRemitente;
  2080. string FromCountryCode = "MX";
  2081. string telefonoFrom = telefonoRemitente;
  2082.  
  2083. string ReceiverName = nombreDestinatario;
  2084. string ReceiverCompany = "Emissary";
  2085. string ReceiverPhoneNumber = telefonoDestinatario;
  2086. string ReceiverAddress = direccionDestinatario;
  2087. string ReceiverColonia = coloniaDestinatario;
  2088. string ReceiverReference = referenciaDestinatario;
  2089.  
  2090. string ReceiverCity = ciudadDestinatario;
  2091. string ReceiverState = estadoDestinatario;
  2092. string ReceiverPostalCode = codigoPostalDestinatario;
  2093. string ReceiverCountryCode = "MX";
  2094. string telefonoTo = telefonoDestinatario;
  2095. int Quantity = 1;
  2096. int Length = int.Parse(largo);
  2097. int Width = int.Parse(ancho);
  2098. int Height = int.Parse(alto);
  2099. decimal Weight = decimal.Parse(peso);
  2100. byte[] numArray = null;
  2101. string TrackingNo = string.Empty;
  2102. string LabelImage = string.Empty;
  2103. string wsResponseDescription = string.Empty;
  2104. string wsResponseStatus = string.Empty;
  2105. string ShipmentIdentificationNumber = string.Empty;
  2106. string TransportationCharges = string.Empty;
  2107. string ServiceCharge = string.Empty;
  2108. string TotalCost = string.Empty;
  2109.  
  2110. decimal TotalDiscount = 0, TotalAmount = 0;
  2111. var returnValue = string.Empty;
  2112.  
  2113. var tipoGuia = consultarTipoGuiaFedex();
  2114.  
  2115.  
  2116. if (tipoServicio == 1)
  2117. {
  2118.  
  2119. //string servicio = "Terrestre";
  2120. //VERSION OFICIAL
  2121.  
  2122. 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);
  2123.  
  2124. string servicio = "Terrestre";
  2125.  
  2126. 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);
  2127.  
  2128.  
  2129.  
  2130. //string key, string password, string accountnumber, string meternumber,
  2131. //VERSION PRUEBA
  2132. //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);
  2133. //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);
  2134.  
  2135.  
  2136.  
  2137.  
  2138. returnValue = guardarEnvio(pJData, TotalAmount, TrackingNo, tipoGuia);
  2139. }
  2140. else if (tipoServicio == 2)
  2141. {
  2142.  
  2143. //string servicio = "Áereo";
  2144.  
  2145.  
  2146. //VERSION OFICIAL
  2147. 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);
  2148.  
  2149. string servicio = "Áereo";
  2150.  
  2151.  
  2152.  
  2153. 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);
  2154.  
  2155.  
  2156. //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);
  2157. //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);
  2158.  
  2159.  
  2160.  
  2161. returnValue = guardarEnvio(pJData, TotalAmount, TrackingNo, tipoGuia);
  2162. }
  2163. else if (tipoServicio == 3)
  2164. {
  2165.  
  2166. string servicio = "Prioridad Áereo";
  2167.  
  2168.  
  2169. //VERSION OFICIAL
  2170. 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);
  2171. 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);
  2172.  
  2173.  
  2174. //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);
  2175. //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);
  2176.  
  2177.  
  2178.  
  2179. returnValue = guardarEnvio(pJData, TotalAmount, TrackingNo, tipoGuia);
  2180. }
  2181. else
  2182. {
  2183. returnValue = "Tipo Servicio Inexistente";
  2184. }
  2185.  
  2186. return returnValue;
  2187. }
  2188.  
  2189. [WebMethod(EnableSession = true)]
  2190. public static string consultarTipoGuiaFedex()
  2191. {
  2192. string mensaje = "";
  2193.  
  2194.  
  2195.  
  2196. string userId = HttpContext.Current.Session["usuario_id"].ToString();
  2197.  
  2198. DataTable DataTable = new DataTable();
  2199. dbo.BaseDatos db = null;
  2200.  
  2201. db = new dbo.BaseDatos(ConfigurationManager.ConnectionStrings["cnn"].ToString());
  2202. SqlParameter prmUserId;
  2203.  
  2204.  
  2205. try
  2206. {
  2207. prmUserId = new SqlParameter("@userId", SqlDbType.SmallInt);
  2208. prmUserId.Value = userId;
  2209.  
  2210.  
  2211. DataTable = db.ObtenerDatosComoDataTable("spq_Emissary_PreferenciaEtiquetaFedex", prmUserId);
  2212. DataTable.TableName = "Envios";
  2213.  
  2214. mensaje = JsonConvert.SerializeObject(DataTable);
  2215.  
  2216.  
  2217. if (mensaje.Length < 3)
  2218. {
  2219.  
  2220. mensaje = "1";
  2221.  
  2222. }
  2223. else
  2224. {
  2225. mensaje = DataTable.Rows[0]["terminacion_id"].ToString();
  2226.  
  2227. }
  2228.  
  2229.  
  2230. }
  2231. catch (Exception ex)
  2232. {
  2233. mensaje = ex.Message;
  2234. }
  2235. finally
  2236. {
  2237. db.Finalizar();
  2238. }
  2239. return mensaje;
  2240. }
  2241.  
  2242.  
  2243. [WebMethod(EnableSession = true)]
  2244. public static string consultarTipoGuiaRedpack()
  2245. {
  2246. string mensaje = "";
  2247.  
  2248.  
  2249.  
  2250. string userId = HttpContext.Current.Session["usuario_id"].ToString();
  2251.  
  2252. DataTable DataTable = new DataTable();
  2253. dbo.BaseDatos db = null;
  2254.  
  2255. db = new dbo.BaseDatos(ConfigurationManager.ConnectionStrings["cnn"].ToString());
  2256. SqlParameter prmUserId;
  2257.  
  2258.  
  2259. try
  2260. {
  2261. prmUserId = new SqlParameter("@userId", SqlDbType.SmallInt);
  2262. prmUserId.Value = userId;
  2263.  
  2264.  
  2265. DataTable = db.ObtenerDatosComoDataTable("spq_Emissary_PreferenciaEtiquetaRedpack", prmUserId);
  2266. DataTable.TableName = "Envios";
  2267.  
  2268. mensaje = JsonConvert.SerializeObject(DataTable);
  2269.  
  2270.  
  2271. if (mensaje.Length < 3)
  2272. {
  2273.  
  2274. mensaje = "2";
  2275.  
  2276. }
  2277. else
  2278. {
  2279. mensaje = DataTable.Rows[0]["terminacion_id"].ToString();
  2280.  
  2281. }
  2282. }
  2283. catch (Exception ex)
  2284. {
  2285. mensaje = ex.Message;
  2286. }
  2287. finally
  2288. {
  2289. db.Finalizar();
  2290. }
  2291. return mensaje;
  2292. }
  2293.  
  2294.  
  2295.  
  2296. public static string guardarGuia(Object pJData, decimal costo, decimal precio, int noTracking)
  2297. {
  2298.  
  2299.  
  2300. return string.Empty;
  2301. }
  2302.  
  2303.  
  2304. #region <<Cargar Datos Peso>>
  2305.  
  2306. [WebMethod(EnableSession = true)]
  2307. public static string cancelarGuia(Int64 envioId)
  2308. {
  2309. string mensaje = "";
  2310.  
  2311.  
  2312. string userId = HttpContext.Current.Session["usuario_id"].ToString();
  2313.  
  2314. DataSet DataSet = new DataSet();
  2315. dbo.BaseDatos db = null;
  2316.  
  2317. db = new dbo.BaseDatos(ConfigurationManager.ConnectionStrings["cnn"].ToString());
  2318. SqlParameter prmUserId, prmIdPeso;
  2319.  
  2320. try
  2321. {
  2322.  
  2323. prmUserId = new SqlParameter("@userId", SqlDbType.SmallInt);
  2324. prmUserId.Value = userId;
  2325. prmIdPeso = new SqlParameter("@envioId", SqlDbType.SmallInt);
  2326. prmIdPeso.Value = envioId;
  2327.  
  2328.  
  2329.  
  2330.  
  2331. DataSet = db.ObtenerDatosComoDataSet("spq_Emissary_CancelarGuia", prmIdPeso, prmUserId);
  2332. //DataSet.TableName = "Peso";
  2333.  
  2334. mensaje = JsonConvert.SerializeObject(DataSet);
  2335.  
  2336. var noGuia = Convert.ToString(DataSet.Tables[0].Rows[0]["TrackingNo"]);
  2337. var precio = Convert.ToString(DataSet.Tables[0].Rows[0]["precio"]);
  2338. var paqueteruia_id = Convert.ToString(DataSet.Tables[0].Rows[0]["paqueteria"]);
  2339.  
  2340.  
  2341.  
  2342.  
  2343.  
  2344.  
  2345.  
  2346. }
  2347. catch (Exception ex)
  2348. {
  2349. mensaje = ex.Message;
  2350. }
  2351. finally
  2352. {
  2353. db.Finalizar();
  2354. }
  2355. return mensaje;
  2356. }
  2357.  
  2358.  
  2359. #endregion
  2360.  
  2361.  
  2362.  
  2363.  
  2364. #region <<Cargar Ciudad Estado>>
  2365.  
  2366. [WebMethod(EnableSession = true)]
  2367. public static string obtenerCiudadEstado(string CP)
  2368. {
  2369. string mensaje = "";
  2370.  
  2371.  
  2372. string userId = HttpContext.Current.Session["usuario_id"].ToString();
  2373.  
  2374. DataSet DataSet = new DataSet();
  2375. dbo.BaseDatos db = null;
  2376.  
  2377. db = new dbo.BaseDatos(ConfigurationManager.ConnectionStrings["cnn"].ToString());
  2378. SqlParameter prmUserId, prmCP;
  2379.  
  2380. try
  2381. {
  2382.  
  2383. prmCP = new SqlParameter("@Cp", SqlDbType.NVarChar);
  2384. prmCP.Value = CP;
  2385.  
  2386.  
  2387.  
  2388.  
  2389. DataSet = db.ObtenerDatosComoDataSet("spq_Emissary_CiudadEstado", prmCP);
  2390. //DataSet.TableName = "Peso";
  2391.  
  2392. mensaje = JsonConvert.SerializeObject(DataSet);
  2393. }
  2394. catch (Exception ex)
  2395. {
  2396. mensaje = ex.Message;
  2397. }
  2398. finally
  2399. {
  2400. db.Finalizar();
  2401. }
  2402. return mensaje;
  2403. }
  2404.  
  2405.  
  2406. #endregion
  2407.  
  2408. #region <<Cargar Datos Direccion>>
  2409.  
  2410. [WebMethod(EnableSession = true)]
  2411. public static string cargarPrecios(Int64 peso)
  2412. {
  2413. string mensaje = "";
  2414. DataTable DataTable = new DataTable();
  2415. dbo.BaseDatos db = null;
  2416.  
  2417. db = new dbo.BaseDatos(ConfigurationManager.ConnectionStrings["cnn"].ToString());
  2418. SqlParameter prmPeso;
  2419.  
  2420. try
  2421. {
  2422. prmPeso = new SqlParameter("@Kilos", SqlDbType.SmallInt);
  2423. prmPeso.Value = peso;
  2424.  
  2425.  
  2426. DataTable = db.ObtenerDatosComoDataTable("spq_Emissary_DatosDireccion", prmPeso);
  2427. DataTable.TableName = "PrecioPeso";
  2428.  
  2429. mensaje = JsonConvert.SerializeObject(DataTable);
  2430. }
  2431. catch (Exception ex)
  2432. {
  2433. mensaje = ex.Message;
  2434. }
  2435. finally
  2436. {
  2437. db.Finalizar();
  2438. }
  2439. return mensaje;
  2440. }
  2441.  
  2442.  
  2443.  
  2444.  
  2445. #endregion
  2446.  
  2447.  
  2448. #region <<Cargar Datos Peso>>
  2449.  
  2450. [WebMethod(EnableSession = true)]
  2451. public static string cargarPeso(Object pJData)
  2452. {
  2453. string mensaje = "";
  2454.  
  2455.  
  2456. string userId = HttpContext.Current.Session["usuario_id"].ToString();
  2457.  
  2458.  
  2459.  
  2460.  
  2461.  
  2462. dynamic Data = JsonConvert.DeserializeObject(pJData.ToString());
  2463.  
  2464. string IdPeso = Data[0]["IdPeso"];
  2465. string codigoPostalRemitente = Data[0]["codigoPostalRemitente"];
  2466. string codigoPostalDestinatario = Data[0]["codigoPostalDestinatario"];
  2467.  
  2468.  
  2469.  
  2470. DataSet DataSet = new DataSet();
  2471. dbo.BaseDatos db = null;
  2472.  
  2473. db = new dbo.BaseDatos(ConfigurationManager.ConnectionStrings["cnn"].ToString());
  2474. SqlParameter prmUserId, prmIdPeso, prmCodigoPostalRemitente, prmCodigoPostalDestinatario;
  2475.  
  2476. try
  2477. {
  2478.  
  2479. prmUserId = new SqlParameter("@userId", SqlDbType.SmallInt);
  2480. prmUserId.Value = userId;
  2481. prmIdPeso = new SqlParameter("@Kilos", SqlDbType.NVarChar, 50);
  2482. prmIdPeso.Value = IdPeso;
  2483. prmCodigoPostalRemitente = new SqlParameter("@CpRemitente", SqlDbType.NVarChar, 50);
  2484. prmCodigoPostalRemitente.Value = codigoPostalRemitente;
  2485. prmCodigoPostalDestinatario = new SqlParameter("@CpDestinatario", SqlDbType.NVarChar, 50);
  2486. prmCodigoPostalDestinatario.Value = codigoPostalDestinatario;
  2487.  
  2488.  
  2489.  
  2490. DataSet = db.ObtenerDatosComoDataSet("spq_Emissary_PreciosPrueba_Mike", prmIdPeso, prmUserId, prmCodigoPostalRemitente, prmCodigoPostalDestinatario);
  2491. //DataSet.TableName = "Peso";
  2492.  
  2493. mensaje = JsonConvert.SerializeObject(DataSet);
  2494. }
  2495. catch (Exception ex)
  2496. {
  2497. mensaje = ex.Message;
  2498. }
  2499. finally
  2500. {
  2501. db.Finalizar();
  2502. }
  2503. return mensaje;
  2504. }
  2505.  
  2506.  
  2507.  
  2508. //[WebMethod(EnableSession = true)]
  2509. //public static string cargarPeso(int pesoId)
  2510. //{
  2511. // string mensaje = "";
  2512.  
  2513.  
  2514. // string userId = HttpContext.Current.Session["usuario_id"].ToString();
  2515.  
  2516.  
  2517.  
  2518.  
  2519.  
  2520.  
  2521. // int IdPeso = pesoId;
  2522.  
  2523.  
  2524.  
  2525.  
  2526. // DataSet DataSet = new DataSet();
  2527. // dbo.BaseDatos db = null;
  2528.  
  2529. // db = new dbo.BaseDatos(ConfigurationManager.ConnectionStrings["cnn"].ToString());
  2530. // SqlParameter prmUserId, prmIdPeso, prmCodigoPostalRemitente, prmCodigoPostalDestinatario;
  2531.  
  2532. // try
  2533. // {
  2534.  
  2535. // prmUserId = new SqlParameter("@userId", SqlDbType.SmallInt);
  2536. // prmUserId.Value = userId;
  2537. // prmIdPeso = new SqlParameter("@Kilos", SqlDbType.NVarChar, 50);
  2538. // prmIdPeso.Value = IdPeso;
  2539.  
  2540.  
  2541.  
  2542. // DataSet = db.ObtenerDatosComoDataSet("spq_Emissary_PreciosPrueba", prmIdPeso);
  2543. // //DataSet.TableName = "Peso";
  2544.  
  2545. // mensaje = JsonConvert.SerializeObject(DataSet);
  2546. // }
  2547. // catch (Exception ex)
  2548. // {
  2549. // mensaje = ex.Message;
  2550. // }
  2551. // finally
  2552. // {
  2553. // db.Finalizar();
  2554. // }
  2555. // return mensaje;
  2556. //}
  2557.  
  2558.  
  2559. #endregion
  2560.  
  2561. #region <<Cargar Datos Direccion>>
  2562.  
  2563. [WebMethod(EnableSession = true)]
  2564. public static string cargarDatosDireccion(Int64 IdDireccion)
  2565. {
  2566. string mensaje = "";
  2567. DataTable DataTable = new DataTable();
  2568. dbo.BaseDatos db = null;
  2569.  
  2570. db = new dbo.BaseDatos(ConfigurationManager.ConnectionStrings["cnn"].ToString());
  2571. SqlParameter prmIdDireccion;
  2572.  
  2573. try
  2574. {
  2575. prmIdDireccion = new SqlParameter("@IdDireccion", SqlDbType.SmallInt);
  2576. prmIdDireccion.Value = IdDireccion;
  2577.  
  2578.  
  2579. DataTable = db.ObtenerDatosComoDataTable("spq_Emissary_DatosDireccion", prmIdDireccion);
  2580. DataTable.TableName = "Direccion";
  2581.  
  2582. mensaje = JsonConvert.SerializeObject(DataTable);
  2583. }
  2584. catch (Exception ex)
  2585. {
  2586. mensaje = ex.Message;
  2587. }
  2588. finally
  2589. {
  2590. db.Finalizar();
  2591. }
  2592. return mensaje;
  2593. }
  2594.  
  2595.  
  2596. #endregion
  2597.  
  2598.  
  2599. #region <<Cargar Datos Paquete>>
  2600.  
  2601. [WebMethod(EnableSession = true)]
  2602. public static string cargarDatosPaquete(Int64 IdPaquete)
  2603. {
  2604. string mensaje = "";
  2605. DataTable DataTable = new DataTable();
  2606. dbo.BaseDatos db = null;
  2607.  
  2608. db = new dbo.BaseDatos(ConfigurationManager.ConnectionStrings["cnn"].ToString());
  2609. SqlParameter prmIdPaquete;
  2610.  
  2611. try
  2612. {
  2613. prmIdPaquete = new SqlParameter("@IdPaquete", SqlDbType.SmallInt);
  2614. prmIdPaquete.Value = IdPaquete;
  2615.  
  2616.  
  2617. DataTable = db.ObtenerDatosComoDataTable("spq_Emissary_DatosPaquete", prmIdPaquete);
  2618. DataTable.TableName = "Paquete";
  2619.  
  2620. mensaje = JsonConvert.SerializeObject(DataTable);
  2621. }
  2622. catch (Exception ex)
  2623. {
  2624. mensaje = ex.Message;
  2625. }
  2626. finally
  2627. {
  2628. db.Finalizar();
  2629. }
  2630. return mensaje;
  2631. }
  2632.  
  2633.  
  2634. #endregion
  2635.  
  2636.  
  2637.  
  2638. #region <<Cargar Datos Direccion>>
  2639.  
  2640. [WebMethod(EnableSession = true)]
  2641. public static string cargarDatosOrden(Int64 ordenId)
  2642. {
  2643. string mensaje = "";
  2644. DataTable DataTable = new DataTable();
  2645. dbo.BaseDatos db = null;
  2646.  
  2647. db = new dbo.BaseDatos(ConfigurationManager.ConnectionStrings["cnn"].ToString());
  2648. SqlParameter prmOrdenId;
  2649.  
  2650. try
  2651. {
  2652. prmOrdenId = new SqlParameter("@ordenId", SqlDbType.SmallInt);
  2653. prmOrdenId.Value = ordenId;
  2654.  
  2655.  
  2656. DataTable = db.ObtenerDatosComoDataTable("spq_Emissary_DatosOrden", prmOrdenId);
  2657. DataTable.TableName = "Orden";
  2658.  
  2659. mensaje = JsonConvert.SerializeObject(DataTable);
  2660. }
  2661. catch (Exception ex)
  2662. {
  2663. mensaje = ex.Message;
  2664. }
  2665. finally
  2666. {
  2667. db.Finalizar();
  2668. }
  2669. return mensaje;
  2670. }
  2671.  
  2672.  
  2673. #endregion
  2674.  
  2675. [WebMethod(EnableSession = true)]
  2676. public static string cargarListadoEnvios()
  2677. {
  2678. string mensaje = "";
  2679.  
  2680.  
  2681.  
  2682. string userId = HttpContext.Current.Session["usuario_id"].ToString();
  2683.  
  2684. DataTable DataTable = new DataTable();
  2685. dbo.BaseDatos db = null;
  2686.  
  2687. db = new dbo.BaseDatos(ConfigurationManager.ConnectionStrings["cnn"].ToString());
  2688. SqlParameter prmUserId;
  2689.  
  2690.  
  2691. try
  2692. {
  2693. prmUserId = new SqlParameter("@userId", SqlDbType.SmallInt);
  2694. prmUserId.Value = userId;
  2695.  
  2696.  
  2697. DataTable = db.ObtenerDatosComoDataTable("spq_Emissary_ListadoEnviosPrueba", prmUserId);
  2698. DataTable.TableName = "Envios";
  2699.  
  2700. mensaje = JsonConvert.SerializeObject(DataTable);
  2701. }
  2702. catch (Exception ex)
  2703. {
  2704. mensaje = ex.Message;
  2705. }
  2706. finally
  2707. {
  2708. db.Finalizar();
  2709. }
  2710. return mensaje;
  2711. }
  2712.  
  2713.  
  2714. [WebMethod(EnableSession = true)]
  2715. public static string cargarListadoEnviosDashboard()
  2716. {
  2717. string mensaje = "";
  2718.  
  2719.  
  2720.  
  2721. string userId = HttpContext.Current.Session["usuario_id"].ToString();
  2722.  
  2723. DataTable DataTable = new DataTable();
  2724. dbo.BaseDatos db = null;
  2725.  
  2726. db = new dbo.BaseDatos(ConfigurationManager.ConnectionStrings["cnn"].ToString());
  2727. SqlParameter prmUserId;
  2728.  
  2729.  
  2730. try
  2731. {
  2732. //prmUserId = new SqlParameter("@userId", SqlDbType.SmallInt);
  2733. //prmUserId.Value = userId;
  2734.  
  2735.  
  2736. DataTable = db.ObtenerDatosComoDataTable("spq_Emissary_ListadoEnviosDashboard");
  2737. DataTable.TableName = "Envios";
  2738.  
  2739. mensaje = JsonConvert.SerializeObject(DataTable);
  2740. }
  2741. catch (Exception ex)
  2742. {
  2743. mensaje = ex.Message;
  2744. }
  2745. finally
  2746. {
  2747. db.Finalizar();
  2748. }
  2749. return mensaje;
  2750. }
  2751.  
  2752.  
  2753.  
  2754. [WebMethod(EnableSession = true)]
  2755. public static string validarSaldo(string precio)
  2756. {
  2757. string mensaje = "";
  2758. decimal precioEnvio;
  2759. decimal saldoUsuario;
  2760.  
  2761. string userId = HttpContext.Current.Session["usuario_id"].ToString();
  2762. string saldo = HttpContext.Current.Session["saldo"].ToString();
  2763.  
  2764. precioEnvio = System.Convert.ToDecimal(precio);
  2765. saldoUsuario = System.Convert.ToDecimal(saldo);
  2766.  
  2767. if (precioEnvio <= saldoUsuario)
  2768. {
  2769. mensaje = "1";
  2770. }
  2771. else
  2772. {
  2773. mensaje = "0";
  2774. }
  2775.  
  2776. return mensaje;
  2777. }
  2778.  
  2779. }
  2780.  
  2781. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement