public void CrearOrden(OrdenCargaDTO orden) { CreateOrden.CreateAPISoapClient c = new CreateOrden.CreateAPISoapClient(); System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12; c.ClientCredentials.ClientCertificate.SetCertificate(StoreLocation.LocalMachine, StoreName.Root, X509FindType.FindBySubjectName, "Starfield Root Certificate Authority"); List <CreateOrden.ItemWithExtras> items = new List <CreateOrden.ItemWithExtras>(); orden.jobs.ForEach(j => { items.Add(new CreateOrden.ItemWithExtras() { Quantity = j.Quantity, ProductID = j.ProductID, JobName = j.Name }); }); var response1 = c.CreateOrderWithMethods(new CreateOrden.APIOrderWithMethods() { Username = orden.Username, ProducerID = this._conexion.ProducerID, CompanyID = this._conexion.CompanyID, MasterKey = this._conexion.MasterKey, Address1 = orden.Address1, Address2 = orden.Address2, Address3 = orden.Address3, //Address1 = "Este es un texto", //calle + numero //Address2 = "Este es un texto 2",// municipio //Address3 = "Este es un texto 3", //CompanyName = "Varela Incoporacion", Email = orden.Email, FirstName = orden.Firstname, LastName = orden.Lastname, Items = items.ToArray(), PostalCode = orden.PostalCode, Country = "MX", City = orden.City, BillingMethodID = 7271, SendNotifications = false //ShippingMethodID=6543, //ShippingPrice=500, //UseDefaultAddress= true, //UseFirstStoreCreditBillingMethod= true, //CostCentreID=0, //ShippingMethodName="RedPack", //BillingMethodID=5845, //BillingMethodName="Facturacion por pedido", // SendNotifications= true }); Console.WriteLine(response1.OrderID); }
public void LeerOrdenes(string directorio) { this._archivos = new DirectoryInfo(directorio).GetFiles("*.xlsx"); foreach (FileInfo archivo in this._archivos) { using (ExcelPackage package = new ExcelPackage(archivo)) { //get the first worksheet in the workbook ExcelWorksheet worksheet = package.Workbook.Worksheets[1]; var start = worksheet.Dimension.Start; var end = worksheet.Dimension.End; int columnaInicialProd = 11; int factor = (end.Column - columnaInicialProd) / 3; for (int row = start.Row + 1; row <= end.Row; row++) { OrdenCargaDTO orden; try { if (worksheet.Cells[row, 2].Value == null) { continue; } Console.WriteLine($"Row :{row} {worksheet.Cells[row, 2].Value.ToString().Trim()}"); orden = new OrdenCargaDTO() { Username = worksheet.Cells[row, 2].Value.ToString().Trim(), Firstname = worksheet.Cells[row, 3].Value.ToString().Trim(), Lastname = worksheet.Cells[row, 4].Value.ToString().Trim(), Address1 = worksheet.Cells[row, 5].Value.ToString().Trim(), Address2 = worksheet.Cells[row, 6].Value == null ? " " : worksheet.Cells[row, 6].Value.ToString().Trim(), Address3 = worksheet.Cells[row, 7].Value == null ? " " : worksheet.Cells[row, 7].Value.ToString().Trim(), PostalCode = worksheet.Cells[row, 8].Value.ToString().Trim(), Email = worksheet.Cells[row, 9].Value.ToString().Trim(), Phone = worksheet.Cells[row, 10].Value == null ? " " : worksheet.Cells[row, 10].Value.ToString().Trim(), City = worksheet.Cells[row, 11].Value == null ? "." : worksheet.Cells[row, 11].Value.ToString().Trim(), }; this._jobs = new List <JobCargarDTO>(); //Leer los jobs por bloques de 3 for (int i = 0; i < factor; i++) { this.LeerJob(worksheet, row, 12 + (i * 3)); } orden.jobs = this._jobs; this._ordenes.Add(orden); } catch (Exception e) { Console.WriteLine("Exception en la aplicacion"); } } } } }
public void CrearOrden(OrdenCargaDTO orden) { CreateOrden.CreateAPISoapClient c = new CreateOrden.CreateAPISoapClient(); System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12; c.ClientCredentials.ClientCertificate.SetCertificate(StoreLocation.LocalMachine, StoreName.Root, X509FindType.FindBySubjectName, "Starfield Root Certificate Authority"); List <CreateOrden.ItemWithExtras> items = new List <CreateOrden.ItemWithExtras>(); orden.jobs.ForEach(j => { items.Add(new CreateOrden.ItemWithExtras() { Quantity = j.Quantity, ProductID = j.ProductID, JobName = j.Name, }); }); var response1 = c.CreateOrderWithMethods(new CreateOrden.APIOrderWithMethods() { Username = orden.Username, ProducerID = this._conexion.ProducerID, CompanyID = this._conexion.CompanyID, MasterKey = this._conexion.MasterKey, Address1 = orden.Address1, Address2 = orden.Address2, Address3 = orden.Address3, Phone = orden.Phone, Email = orden.Email, FirstName = orden.Firstname, LastName = orden.Lastname, Items = items.ToArray(), PostalCode = orden.PostalCode, Country = "MX", City = orden.City, BillingMethodID = 7214, SendNotifications = false }); Console.WriteLine(response1.OrderID); }
public List <OrdenCargaDTO> LeerOrdenesSBK() { List <OrdenCargaDTO> ordenesCarga = new List <OrdenCargaDTO>(); var s = new FileStream("C:\\Desarrollo\\sbk.xlsx", FileMode.Open, FileAccess.Read); #region Lectura del Excel List <LineExcel> lineas = new List <LineExcel>(); using (ExcelPackage package = new ExcelPackage(s)) { ExcelWorksheet sheet = package.Workbook.Worksheets[1]; for (int i = 3; i <= sheet.Dimension.End.Row; i++) { lineas.Add(new LineExcel() { Username = sheet.Cells[i, 2].Value.ToString(), Firstname = sheet.Cells[i, 3].Value.ToString(), Lastname = sheet.Cells[i, 4].Value.ToString(), Address1 = sheet.Cells[i, 5].Value == null ? "" : sheet.Cells[i, 5].Value.ToString(), Address2 = sheet.Cells[i, 6].Value == null ? "" : sheet.Cells[i, 6].Value.ToString(), Address3 = sheet.Cells[i, 7].Value == null ? "" : sheet.Cells[i, 7].Value.ToString(), PostalCode = sheet.Cells[i, 8].Value.ToString(), Email = sheet.Cells[i, 9].Value.ToString(), Phone = sheet.Cells[i, 10].Value.ToString(), City = sheet.Cells[i, 11].Value.ToString(), ProductoID = sheet.Cells[i, 12].Value.ToString(), JobName = sheet.Cells[i, 13].Value.ToString(), Quantity = Int32.Parse(sheet.Cells[i, 14].Value.ToString()), ID_BillingMethod = Int32.Parse(sheet.Cells[i, 15].Value.ToString()), ShippingPrice = Decimal.Parse(sheet.Cells[i, 16].Value.ToString()), UserNote = sheet.Cells[i, 17].Value.ToString() }); } } var result = lineas.GroupBy(x => x.Username, (key, data) => new { key, data = data.ToList() }).ToList(); #endregion #region Llenado de DTO result.ForEach(z => { var o = z.data.FirstOrDefault(); OrdenCargaDTO or = new OrdenCargaDTO() { Username = o.Username, Lastname = o.Lastname, Address1 = o.Address1, Address2 = o.Address2, Address3 = o.Address3, City = o.City, Email = o.Email, Firstname = o.Firstname, Phone = o.Phone, PostalCode = o.PostalCode, Id_BillingMethod = o.ID_BillingMethod, ShipingPrice = o.ShippingPrice }; or.jobs = new List <JobCargarDTO>(); //Console.WriteLine(z.key); z.data.ForEach(e => { or.jobs.Add(new JobCargarDTO() { Name = e.JobName, ProductID = Int32.Parse(e.ProductoID), Quantity = e.Quantity, UserNote = e.UserNote }); // Console.WriteLine(e.ProductoID); }); ordenesCarga.Add(or); }); #endregion return(ordenesCarga); }