public List <PEntidades.Proveedor> getDatoMaestro(PEntidades.SrvSAPUProv.ZELIFNR_PROV[] lifnrs, string endpointAddres, string[] userPass) { PEntidades.SrvSAPUProv.ZWS_UPROVEEDORESClient srv = new PPersistencia.WebServices().getZWS_UPROVEEDORESInstanceNew( endpointAddres, userPass ); srv.Open(); srv.InnerChannel.OperationTimeout = new TimeSpan(0, 10, 0); PEntidades.SrvSAPUProv.Z_UDATA_MASTER master = new PEntidades.SrvSAPUProv.Z_UDATA_MASTER(); master.PROVEEDOR = lifnrs; var result = srv.Z_UDATA_MASTER(master); List <PEntidades.Proveedor> listaDatosMaestrosPorsoc = new List <PEntidades.Proveedor>(); //var result = srv.Z_DATA_MASTER(lifnrs); for (int i = 0; i < result.DATOS_MAESTROS.Length; i++) { var resul = result.DATOS_MAESTROS[i];//Devuelve una tabla, entonces se accede a la fila 0. PEntidades.Proveedor tmpProveedor = new PEntidades.Proveedor(); tmpProveedor.Liftnr = resul.LIFNR; tmpProveedor.TITLE_MEDI = resul.TITLE_MEDI; tmpProveedor.NAME1 = resul.NAME1; tmpProveedor.NAME2 = resul.NAME2; tmpProveedor.SORT1 = resul.SORT1; tmpProveedor.STREET = resul.STREET; tmpProveedor.HOUSE_NUM1 = resul.HOUSE_NUM1.ToString();// int tmpProveedor.POST_CODE1 = resul.POST_CODE1; tmpProveedor.ADDR1_DATA = resul.ADDR1_DATA; tmpProveedor.COUNTRY = resul.COUNTRY; tmpProveedor.NAMECOUNTRY = resul.NAMECOUNTRY; tmpProveedor.REGION = resul.REGION; tmpProveedor.NAMEREGION = resul.NAMEREGION; tmpProveedor.PO_BOX = resul.PO_BOX; tmpProveedor.POST_CODE2 = resul.POST_CODE2; tmpProveedor.LANGU = resul.LANGU; tmpProveedor.TEL_NUMBER = resul.TEL_NUMBER; tmpProveedor.FAX_NUMBER = resul.FAX_NUMBER; tmpProveedor.EXTENSION1 = resul.EXTENSION1; tmpProveedor.EXTENSION2 = resul.EXTENSION2; srv.Close(); listaDatosMaestrosPorsoc.Add(tmpProveedor); } return(listaDatosMaestrosPorsoc); }
private Panel pintarDatosMestros(PEntidades.Proveedor objProveedor) { //------ Panel panelInterno = new Panel(); panelInterno.CssClass = "datMtrWrap"; //------ Table tabla1_1 = new Table(); tabla1_1.CssClass = "tblDatMtr"; //------ TableRow tr_1 = new TableRow(); TableCell celda1_1 = new TableCell(); celda1_1.Text = "N° Proveedor"; TableCell celda1_2 = new TableCell(); Label lbltexto1_2 = new Label(); lbltexto1_2.Text = ""; lbltexto1_2.CssClass = "lblDM"; lbltexto1_2.Text = objProveedor.Liftnr; celda1_2.Controls.Add(lbltexto1_2); tr_1.Cells.Add(celda1_1); tr_1.Cells.Add(celda1_2); //------ TableRow tr_2 = new TableRow(); TableCell celda2_1 = new TableCell(); celda2_1.Text = "País"; TableCell celda2_2 = new TableCell(); Label lbltexto2_2 = new Label(); lbltexto2_2.Text = ""; lbltexto2_2.CssClass = "lblDM"; lbltexto2_2.Text = objProveedor.NAMECOUNTRY; celda2_2.Controls.Add(lbltexto2_2); tr_2.Cells.Add(celda2_1); tr_2.Cells.Add(celda2_2); //------ TableRow tr_3 = new TableRow(); TableCell celda3_1 = new TableCell(); celda3_1.Text = "Nombre"; TableCell celda3_2 = new TableCell(); Label lbltexto3_2 = new Label(); lbltexto3_2.Text = ""; lbltexto3_2.CssClass = "lblDM"; lbltexto3_2.Text = objProveedor.NAME1; celda3_2.Controls.Add(lbltexto3_2); tr_3.Cells.Add(celda3_1); tr_3.Cells.Add(celda3_2); //------ TableRow tr_4 = new TableRow(); TableCell celda4_1 = new TableCell(); celda4_1.Text = "Ciudad"; TableCell celda4_2 = new TableCell(); Label lbltexto4_2 = new Label(); lbltexto4_2.Text = ""; lbltexto4_2.CssClass = "lblDM"; lbltexto4_2.Text = objProveedor.ADDR1_DATA; celda4_2.Controls.Add(lbltexto4_2); tr_4.Cells.Add(celda4_1); tr_4.Cells.Add(celda4_2); //------ tabla1_1.Rows.Add(tr_1); tabla1_1.Rows.Add(tr_2); tabla1_1.Rows.Add(tr_3); tabla1_1.Rows.Add(tr_4); //this.pnlDatosMaestros.Controls.Add(espacio); //------ Table tabla2_1 = new Table(); tabla2_1.CssClass = "tblDatMtr"; //------ TableRow tr_1_2 = new TableRow(); TableCell celda1_1_2 = new TableCell(); celda1_1_2.Text = "Estado"; TableCell celda1_2_2 = new TableCell(); Label lbltexto5_2 = new Label(); lbltexto5_2.Text = ""; lbltexto5_2.CssClass = "lblDM"; lbltexto5_2.Text = objProveedor.NAMEREGION; celda1_2_2.Controls.Add(lbltexto5_2); tr_1_2.Cells.Add(celda1_1_2); tr_1_2.Cells.Add(celda1_2_2); //------ TableRow tr_2_2 = new TableRow(); TableCell celda2_1_2 = new TableCell(); celda2_1_2.Text = "Calle"; TableCell celda2_2_2 = new TableCell(); Label lbltexto6_2 = new Label(); lbltexto6_2.Text = ""; lbltexto6_2.CssClass = "lblDM"; lbltexto6_2.Text = objProveedor.STREET; celda2_2_2.Controls.Add(lbltexto6_2); tr_2_2.Cells.Add(celda2_1_2); tr_2_2.Cells.Add(celda2_2_2); //------ TableRow tr_3_2 = new TableRow(); TableCell celda3_1_2 = new TableCell(); celda3_1_2.Text = "Colonia"; TableCell celda3_2_2 = new TableCell(); Label lbltexto7_2 = new Label(); lbltexto7_2.Text = ""; lbltexto7_2.CssClass = "lblDM"; lbltexto7_2.Text = ""; celda3_2_2.Controls.Add(lbltexto7_2); tr_3_2.Cells.Add(celda3_1_2); tr_3_2.Cells.Add(celda3_2_2); //------ TableRow tr_4_2 = new TableRow(); TableCell celda4_1_2 = new TableCell(); celda4_1_2.Text = "CP"; TableCell celda4_2_2 = new TableCell(); Label lbltexto8_2 = new Label(); lbltexto8_2.Text = ""; lbltexto8_2.CssClass = "lblDM"; lbltexto8_2.Text = objProveedor.POST_CODE1; celda4_2_2.Controls.Add(lbltexto8_2); tr_4_2.Cells.Add(celda4_1_2); tr_4_2.Cells.Add(celda4_2_2); //------ tabla2_1.Rows.Add(tr_1_2); tabla2_1.Rows.Add(tr_2_2); tabla2_1.Rows.Add(tr_3_2); tabla2_1.Rows.Add(tr_4_2); //------ //------ panelInterno.Controls.Add(tabla1_1); panelInterno.Controls.Add(tabla2_1); return(panelInterno); }
private void cargar() { PEntidades.Proveedor datProveedor = (PEntidades.Proveedor)Session["proveedor"]; if ((this.file != null) && (this.file.ContentLength > 0)) { this.filName = System.IO.Path.GetFileName(this.file.FileName); string absoluteURL = Server.MapPath("Files") + "\\" + this.filName; string ext = System.IO.Path.GetExtension(absoluteURL).ToLower(); if (ext == ".xml") //Cuando si es XML { try { HttpPostedFile file2 = file; this.xmlDoc = new System.Xml.XmlDocument(); this.xmlDoc.Load(this.file.InputStream); this.index = buscarIndexByXBLNR(this.xmlDoc); //Para saber de que item en lista vamos a hacer la validación con SAP y SAT List <string[]> listaDiferentesInstancias = (List <string[]>)Session["listaDiferentesInstancias"]; if (this.index != "") //Cuando si se encuentra la factura { string raw = ""; if (validarSAT(this.xmlDoc)) //Cuando es válido en SAT { if (validarSAP()) //Cuando es válido en SAP { PNegocio.CargarFV60 cf = new PNegocio.CargarFV60(); raw = this.xmlDoc.InnerXml; this.listFV60[int.Parse(index)].UrlXML = this.filName; Session["lstFacturas"] = this.listFV60; } else //Cuando no es válido en SAP { PNegocio.CargarFV60 cf = new PNegocio.CargarFV60(); } } else //Cuando no es válido en SAT { PNegocio.CargarFV60 cf = new PNegocio.CargarFV60(); } // Para llenar la lista con las facturas que si se encontraron. this.lstResumen.Add(this.listFV60[int.Parse(index)]); Session["lstResumen"] = this.lstResumen; } else//Cuando no se encuentra la factura en la lista { string[] noEnc = new string[2]; noEnc[0] = this.filName; noEnc[1] = this.xmlDoc.GetElementsByTagName("cfdi:Comprobante")[0].Attributes["folio"].Value; this.lstNoEnc.Add(noEnc); Session["lstNoEnc"] = this.lstNoEnc; } } catch (Exception ex) { Response.Write("Error: " + ex.Message); } } else//Cuando no es la extención .xml { this.listFV60[int.Parse(index)].DescripcionErrorSAP = "N/A"; this.listFV60[int.Parse(index)].DescripcionErrorSAT = "No es XML"; } } else//Cuando el Request.Files[0] biene vacio { this.listFV60[int.Parse(index)].DescripcionErrorSAP = "N/A"; this.listFV60[int.Parse(index)].DescripcionErrorSAT = "No es XML"; } }
private void cargar() { PEntidades.Proveedor datProveedor = (PEntidades.Proveedor)Session["proveedor"]; if ((this.file != null) && (this.file.ContentLength > 0)) { this.filName = System.IO.Path.GetFileName(this.file.FileName); string absoluteURL = Server.MapPath("Files") + "\\" + this.filName; string ext = System.IO.Path.GetExtension(absoluteURL).ToLower(); if (ext == ".xml")//Cuando si es XML { try { HttpPostedFile file2 = file; this.xmlDoc = new System.Xml.XmlDocument(); this.xmlDoc.Load(this.file.InputStream); //string d = System.Text.Encoding.UTF8.GetString(this.file.InputStream.ToString()); //byte[] filed = null; //using (var binaryReader = new BinaryReader(file2.InputStream)) //{ // filed = binaryReader.ReadBytes(file.ContentLength); //} //string e = System.Text.Encoding.UTF8.GetString(filed); //string ot = this.xmlDoc.ToString(); //string endpoint = ""; //string[] userPass = null; this.index = buscarIndexByXBLNR(this.xmlDoc); //Para saber de que item en lista vamos a hacer la validación con SAP y SAT List <string[]> listaDiferentesInstancias = (List <string[]>)Session["listaDiferentesInstancias"]; if (this.index != "") //Cuando si se encuentra la factura { string raw = ""; if (validarSAT(this.xmlDoc)) //Cuando es válido en SAT { if (validarSAP()) //Cuando es válido en SAP { //this.file.SaveAs(absoluteURL); PNegocio.CargarFactura cf = new PNegocio.CargarFactura(); raw = this.xmlDoc.InnerXml; //cf.setFacturascargadas(datProveedor.Liftnr, this.listFact[int.Parse(index)].XBLNR, "1", this.filName.ToString(), this.listFact[int.Parse(index)].DescripcionErrorSAP.ToString(), this.listFact[int.Parse(index)].DescripcionErrorSAT.ToString(), this.listFact[int.Parse(index)].InsidenciaPersonal, endpoint,userPass); int indexInstanciaCorrespondiente = Gen.Util.CS.Gen.buscarIndexUbicacionInstanciaCorrres(listaDiferentesInstancias, listFact[int.Parse(index)].IDINSTANCIA); // cf.setFacturascargadasNew(listFact[int.Parse(index)].BUKRS, listFact[int.Parse(index)].EBELN, listFact[int.Parse(index)].LIFNR, listFact[int.Parse(index)].DescripcionErrorSAP, listFact[int.Parse(index)].DescripcionErrorSAT, "1", listFact[int.Parse(index)].TIPO, listFact[int.Parse(index)].WERKS, listFact[int.Parse(index)].XBLNR, filName.ToString(), //listaDiferentesInstancias[indexInstanciaCorrespondiente][1].ToString().Trim(), //listaDiferentesInstancias[indexInstanciaCorrespondiente][4].Split(new Char[] { ',' }), //raw, // listFact[int.Parse(index)].uuid, // listFact[int.Parse(index)].total, // listFact[int.Parse(index)].posicion, // listFact[int.Parse(index)].BELNR, // listFact[int.Parse(index)].BWTAR, // listFact[int.Parse(index)].KSCHL //); //this.file.SaveAs(absoluteURL); this.listFact[int.Parse(index)].UrlXML = this.filName; Session["lstFacturas"] = this.listFact; } else//Cuando no es válido en SAP { PNegocio.CargarFactura cf = new PNegocio.CargarFactura(); //cf.setFacturascargadas(datProveedor.Liftnr, this.listFact[int.Parse(index)].XBLNR, "3", this.filName.ToString(), this.listFact[int.Parse(index)].DescripcionErrorSAP.ToString(), this.listFact[int.Parse(index)].DescripcionErrorSAT.ToString(), this.listFact[int.Parse(index)].InsidenciaPersonal, endpoint, userPass); int indexInstanciaCorrespondiente = Gen.Util.CS.Gen.buscarIndexUbicacionInstanciaCorrres(listaDiferentesInstancias, listFact[int.Parse(index)].IDINSTANCIA); //cf.setFacturascargadasNew(listFact[int.Parse(index)].BUKRS, listFact[int.Parse(index)].EBELN, listFact[int.Parse(index)].LIFNR, listFact[int.Parse(index)].DescripcionErrorSAP, listFact[int.Parse(index)].DescripcionErrorSAT, "3", listFact[int.Parse(index)].TIPO, listFact[int.Parse(index)].WERKS, listFact[int.Parse(index)].XBLNR, filName.ToString(), // listaDiferentesInstancias[indexInstanciaCorrespondiente][1].ToString().Trim(), // listaDiferentesInstancias[indexInstanciaCorrespondiente][4].Split(new Char[] { ',' }), // raw, // listFact[int.Parse(index)].uuid, // listFact[int.Parse(index)].total, // listFact[int.Parse(index)].posicion, // listFact[int.Parse(index)].BELNR, // listFact[int.Parse(index)].BWTAR, // listFact[int.Parse(index)].KSCHL // ); } } else //Cuando no es válido en SAT { PNegocio.CargarFactura cf = new PNegocio.CargarFactura(); //cf.setFacturascargadas(datProveedor.Liftnr, this.listFact[int.Parse(index)].XBLNR, "2", this.filName.ToString(), "", this.listFact[int.Parse(index)].DescripcionErrorSAT, this.listFact[int.Parse(index)].InsidenciaPersonal, endpoint, userPass); int indexInstanciaCorrespondiente = Gen.Util.CS.Gen.buscarIndexUbicacionInstanciaCorrres(listaDiferentesInstancias, listFact[int.Parse(index)].IDINSTANCIA); //cf.setFacturascargadasNew(listFact[int.Parse(index)].BUKRS, listFact[int.Parse(index)].EBELN, listFact[int.Parse(index)].LIFNR, listFact[int.Parse(index)].DescripcionErrorSAP, listFact[int.Parse(index)].DescripcionErrorSAT, "3", listFact[int.Parse(index)].TIPO, listFact[int.Parse(index)].WERKS, listFact[int.Parse(index)].XBLNR, filName.ToString(), // listaDiferentesInstancias[indexInstanciaCorrespondiente][1].ToString().Trim(), // listaDiferentesInstancias[indexInstanciaCorrespondiente][4].Split(new Char[] { ',' }), // raw, // listFact[int.Parse(index)].uuid, // listFact[int.Parse(index)].total, // listFact[int.Parse(index)].posicion, // listFact[int.Parse(index)].BELNR, // listFact[int.Parse(index)].BWTAR, // listFact[int.Parse(index)].KSCHL // ); } // Para llenar la lista con las facturas que si se encontraron. this.lstResumen.Add(this.listFact[int.Parse(index)]); Session["lstResumen"] = this.lstResumen; } else//Cuando no se encuentra la factura en la lista { string[] noEnc = new string[2]; noEnc[0] = this.filName; noEnc[1] = this.xmlDoc.GetElementsByTagName("cfdi:Comprobante")[0].Attributes["folio"].Value; this.lstNoEnc.Add(noEnc); Session["lstNoEnc"] = this.lstNoEnc; //Session["prueba"] += "Archivo:" + this.filName + ", Folio factura:" + this.xmlDoc.GetElementsByTagName("cfdi:Comprobante")[0].Attributes["folio"].Value + " -|-"; //var v = Session["prueba"]; } } catch (Exception ex) { Response.Write("Error: " + ex.Message); } } else//Cuando no es la extención .xml { this.listFact[int.Parse(index)].DescripcionErrorSAP = "N/A"; this.listFact[int.Parse(index)].DescripcionErrorSAT = "No es XML"; } } else//Cuando el Request.Files[0] biene vacio { this.listFact[int.Parse(index)].DescripcionErrorSAP = "N/A"; this.listFact[int.Parse(index)].DescripcionErrorSAT = "No es XML"; } }