private int LeeArchivo(string Archivo) { int result = 0; try { StreamReader objReader = new StreamReader(fupArchivo.FileContent, System.Text.Encoding.GetEncoding(1252), false); string [] strEntities; string sLine = ""; StringBuilder sbtxt = new StringBuilder(); List<ListaNegraService.ListaNegra> lstListaNegra = new List<ListaNegraService.ListaNegra>(); int count = 0; sLine = objReader.ReadLine(); if (identificaColumnas(sLine) == 1) { while (sLine != null) { if (sLine != null) { if (count != 0) { sLine = sLine.Replace("|", ""); ListaNegraService.ListaNegra listaNegra = new ListaNegraService.ListaNegra(); strEntities = sLine.Split(new char[] { '\t' }); if (strEntities[entity[0]] != "" && strEntities[entity[20]] != "" && strEntities[entity[7]] != "") { listaNegra.VCHTIPOLISTA = strEntities[entity[0]]; listaNegra.VCHIDQEQ = strEntities[entity[0]] + '|'; listaNegra.VCHNOMBRE = entity[1] != -1 ? QuitarCaracteresEspeciales(strEntities[entity[1]]).ToUpper() + '|' : "" + '|'; listaNegra.VCHAPPATERNO = entity[2] != -1 ? QuitarCaracteresEspeciales(strEntities[entity[2]]).ToUpper() + '|' : "" + '|'; listaNegra.VCHAPMATERNO = entity[3] != -1 ? QuitarCaracteresEspeciales(strEntities[entity[3]]).ToUpper() + '|' : "" + '|'; listaNegra.iProveedorId = ddlProveedores.SelectedValue; if (entity[4] != -1) listaNegra.VCHCURP = strEntities[entity[4]] + '|'; else listaNegra.VCHCURP = "" + '|'; if (entity[5] != -1) listaNegra.VCHRFC = strEntities[entity[5]] + '|'; else listaNegra.VCHRFC = "" + '|'; if (entity[6] != -1) listaNegra.VCHFECHANAC = strEntities[entity[6]] + '|'; else listaNegra.VCHFECHANAC = "" + '|'; if (entity[7] != -1) listaNegra.VCHTIPOLISTA = strEntities[entity[7]] + '|'; else listaNegra.VCHTIPOLISTA = "" + '|'; if (entity[8] != -1) listaNegra.VCHESTATUS = strEntities[entity[8]] + '|'; else listaNegra.VCHESTATUS = "" + '|'; if (entity[9] != -1) listaNegra.VCHDEPENDENCIA = strEntities[entity[9]] + '|'; else listaNegra.VCHDEPENDENCIA = "" + '|'; if (entity[10] != -1) listaNegra.VCHPUESTO = strEntities[entity[10]] + '|'; else listaNegra.VCHPUESTO = "" + '|'; if (entity[11] != -1) listaNegra.INTIDDISPO = strEntities[entity[11]] + '|'; else listaNegra.INTIDDISPO = "" + '|'; if (entity[12] != -1) listaNegra.BITCURPOK = strEntities[entity[12]] + '|'; else listaNegra.BITCURPOK = "" + '|'; if (entity[13] != -1) listaNegra.VCHIDREL = strEntities[entity[13]] + '|'; else listaNegra.VCHIDREL = "" + '|'; if (entity[14] != -1) listaNegra.VCHPARENTESCO = strEntities[entity[14]] + '|'; else listaNegra.VCHPARENTESCO = "" + '|'; if (entity[15] != -1) listaNegra.VCHRAZONSOCIAL = strEntities[entity[15]] + '|'; else listaNegra.VCHRAZONSOCIAL = "" + '|'; if (entity[16] != -1) listaNegra.VCHRFCMORAL = strEntities[entity[16]] + '|'; else listaNegra.VCHRFCMORAL = "" + '|'; if (entity[17] != -1) listaNegra.VCHISSSTE = strEntities[entity[17]] + '|'; else listaNegra.VCHISSSTE = "" + '|'; if (entity[18] != -1) listaNegra.VCHIMSS = strEntities[entity[18]] + '|'; else listaNegra.VCHIMSS = "" + '|'; if (entity[19] != -1) listaNegra.VCHINGRESOS = strEntities[entity[19]] + '|'; else listaNegra.VCHINGRESOS = "" + '|'; if (entity[20] != -1) listaNegra.VCHNOMCOMPLETO = QuitarCaracteresEspeciales(strEntities[entity[20]]).ToUpper() + '|'; else listaNegra.VCHNOMCOMPLETO = "" + '|'; if (entity[21] != -1) listaNegra.VCHAPELLIDOS = QuitarCaracteresEspeciales(strEntities[entity[21]]).ToUpper() + '|'; else listaNegra.VCHAPELLIDOS = "" + '|'; if (listaNegra.VCHNOMBRE.Replace("|", "") != string.Empty && listaNegra.VCHAPPATERNO.Replace("|", "") != string.Empty && listaNegra.VCHAPMATERNO.Replace("|", "") != string.Empty) { listaNegra.vchCadenaNPM = listaNegra.VCHNOMBRE.Replace("|", "").Replace(".", "").Replace(" ", "").Replace(",", "").Replace(";", "").Replace("'", "").Replace("\"", "").Replace("/", "").Replace("\\", "") + listaNegra.VCHAPPATERNO.Replace("|", "").Replace(".", "").Replace(" ", "").Replace(",", "").Replace(";", "").Replace("'", "").Replace("\"", "").Replace("/", "").Replace("\\", "") + listaNegra.VCHAPMATERNO.Replace("|", "").Replace(".", "").Replace(" ", "").Replace(",", "").Replace(";", "").Replace("'", "").Replace("\"", "").Replace("/", "").Replace("\\", ""); listaNegra.vchCadenaNMP = listaNegra.VCHNOMBRE.Replace("|", "").Replace(".", "").Replace(" ", "").Replace(",", "").Replace(";", "").Replace("'", "").Replace("\"", "").Replace("/", "").Replace("\\", "") + listaNegra.VCHAPMATERNO.Replace("|", "").Replace(".", "").Replace(" ", "").Replace(",", "").Replace(";", "").Replace("'", "").Replace("\"", "").Replace("/", "").Replace("\\", "") + listaNegra.VCHAPPATERNO.Replace("|", "").Replace(".", "").Replace(" ", "").Replace(",", "").Replace(";", "").Replace("'", "").Replace("\"", "").Replace("/", "").Replace("\\", ""); } if (listaNegra.VCHNOMBRE.Replace("|", "") != string.Empty && listaNegra.VCHAPPATERNO.Replace("|", "") == string.Empty || listaNegra.VCHAPMATERNO.Replace("|", "") == string.Empty && (listaNegra.VCHAPPATERNO.Replace("|", "") != string.Empty || listaNegra.VCHAPMATERNO.Replace("|", "") != string.Empty)) { listaNegra.vchCadenaNPM = listaNegra.VCHNOMBRE.Replace("|", "").Replace(".", "").Replace(" ", "").Replace(",", "").Replace(";", "").Replace("'", "").Replace("\"", "").Replace("/", "").Replace("\\", "") + listaNegra.VCHAPPATERNO.Replace("|", "").Replace(".", "").Replace(" ", "").Replace(",", "").Replace(";", "").Replace("'", "").Replace("\"", "").Replace("/", "").Replace("\\", "") + listaNegra.VCHAPMATERNO.Replace("|", "").Replace(".", "").Replace(" ", "").Replace(",", "").Replace(";", "").Replace("'", "").Replace("\"", "").Replace("/", "").Replace("\\", ""); } if (listaNegra.VCHNOMBRE.Replace("|", "") == string.Empty && listaNegra.VCHAPPATERNO.Replace("|", "") == string.Empty && listaNegra.VCHAPMATERNO.Replace("|", "") == string.Empty) { if (listaNegra.VCHNOMCOMPLETO.Replace("|", "") == listaNegra.VCHRAZONSOCIAL.Replace("|", "")) listaNegra.vchCadenaNPM = listaNegra.VCHNOMCOMPLETO.Replace("|", "").Replace(".", "").Replace(" ", "").Replace(",", "").Replace(";", "").Replace("'", "").Replace("\"", "").Replace("/", "").Replace("\\", ""); } if (listaNegra.VCHNOMBRE.Replace("|", "") == string.Empty && listaNegra.VCHAPPATERNO.Replace("|", "") == string.Empty && listaNegra.VCHAPMATERNO.Replace("|", "") == string.Empty) { if (listaNegra.VCHNOMCOMPLETO.Replace("|", "") != listaNegra.VCHRAZONSOCIAL.Replace("|", "")) { listaNegra.vchCadenaNPM = listaNegra.VCHRAZONSOCIAL.Replace("|", "").Replace(".", "").Replace(" ", "").Replace(",", "").Replace(";", "").Replace("'", "").Replace("\"", "").Replace("/", "").Replace("\\", ""); listaNegra.vchCadenaNMP = listaNegra.VCHNOMCOMPLETO.Replace("|", "").Replace(".", "").Replace(" ", "").Replace(",", "").Replace(";", "").Replace("'", "").Replace("\"", "").Replace("/", "").Replace("\\", ""); } } try { if (entity[22] != -1) listaNegra.VCHENTIDAD = strEntities[entity[22]] + '|'; else listaNegra.VCHENTIDAD = "" + '|'; if (entity[23] != -1) listaNegra.VCHGENERO = strEntities[entity[23]] + '|'; else listaNegra.VCHGENERO = "" + '|'; } catch { listaNegra.VCHENTIDAD = "|"; listaNegra.VCHGENERO = "|"; } lstListaNegra.Add(listaNegra); sbtxt.AppendLine(listaNegra.VCHIDQEQ + listaNegra.VCHTIPOLISTA + listaNegra.VCHNOMBRE + listaNegra.VCHAPPATERNO + listaNegra.VCHAPMATERNO + listaNegra.VCHCURP + listaNegra.VCHRFC + listaNegra.VCHFECHANAC + listaNegra.VCHESTATUS + listaNegra.VCHDEPENDENCIA + listaNegra.VCHPUESTO + listaNegra.INTIDDISPO + listaNegra.BITCURPOK + listaNegra.VCHIDREL + listaNegra.VCHPARENTESCO + listaNegra.VCHRAZONSOCIAL + listaNegra.VCHRFCMORAL + listaNegra.VCHISSSTE + listaNegra.VCHIMSS + listaNegra.VCHINGRESOS + listaNegra.VCHNOMCOMPLETO + listaNegra.VCHAPELLIDOS + listaNegra.VCHENTIDAD + listaNegra.VCHGENERO + Session["User"] + "|" + DateTime.Now.ToString("yyyy/MM/dd") + "|" + listaNegra.vchCadenaNPM + "|" + listaNegra.vchCadenaNMP + "|" + listaNegra.iProveedorId); } } count++; sLine = objReader.ReadLine(); } } objReader.Close(); EscribeServidor(sbtxt); result = 1; } //else //{ //} } catch (Exception ex) { escribeLog(ex.Message); throw ex; } return result; }
private int LeeArchivo(string Archivo) { int result = 0; try { StreamReader objReader = new StreamReader(fupArchivo.FileContent, System.Text.Encoding.GetEncoding(1252), false); string [] strEntities; string sLine = ""; StringBuilder sbtxt = new StringBuilder(); List <ListaNegraService.ListaNegra> lstListaNegra = new List <ListaNegraService.ListaNegra>(); int count = 0; sLine = objReader.ReadLine(); if (identificaColumnas(sLine) == 1) { while (sLine != null) { if (sLine != null) { if (count != 0) { sLine = sLine.Replace("|", ""); ListaNegraService.ListaNegra listaNegra = new ListaNegraService.ListaNegra(); strEntities = sLine.Split(new char[] { '\t' }); if (strEntities[entity[0]] != "" && strEntities[entity[1]] != "" && strEntities[entity[2]] != "" && strEntities[entity[3]] != "" && strEntities[entity[7]] != "") { listaNegra.VCHTIPOLISTA = strEntities[entity[0]]; listaNegra.VCHIDQEQ = strEntities[entity[0]] + '|'; listaNegra.VCHNOMBRE = QuitarCaracteresEspeciales(strEntities[entity[1]]).ToUpper() + '|'; listaNegra.VCHAPPATERNO = QuitarCaracteresEspeciales(strEntities[entity[2]]).ToUpper() + '|'; listaNegra.VCHAPMATERNO = QuitarCaracteresEspeciales(strEntities[entity[3]]).ToUpper() + '|'; listaNegra.iProveedorId = ddlProveedores.SelectedValue; if (entity[4] != -1) { listaNegra.VCHCURP = strEntities[entity[4]] + '|'; } else { listaNegra.VCHCURP = "" + '|'; } if (entity[5] != -1) { listaNegra.VCHRFC = strEntities[entity[5]] + '|'; } else { listaNegra.VCHRFC = "" + '|'; } if (entity[6] != -1) { listaNegra.VCHFECHANAC = strEntities[entity[6]] + '|'; } else { listaNegra.VCHFECHANAC = "" + '|'; } if (entity[7] != -1) { listaNegra.VCHTIPOLISTA = strEntities[entity[7]] + '|'; } else { listaNegra.VCHTIPOLISTA = "" + '|'; } if (entity[8] != -1) { listaNegra.VCHESTATUS = strEntities[entity[8]] + '|'; } else { listaNegra.VCHESTATUS = "" + '|'; } if (entity[9] != -1) { listaNegra.VCHDEPENDENCIA = strEntities[entity[9]] + '|'; } else { listaNegra.VCHDEPENDENCIA = "" + '|'; } if (entity[10] != -1) { listaNegra.VCHPUESTO = strEntities[entity[10]] + '|'; } else { listaNegra.VCHPUESTO = "" + '|'; } if (entity[11] != -1) { listaNegra.INTIDDISPO = strEntities[entity[11]] + '|'; } else { listaNegra.INTIDDISPO = "" + '|'; } if (entity[12] != -1) { listaNegra.BITCURPOK = strEntities[entity[12]] + '|'; } else { listaNegra.BITCURPOK = "" + '|'; } if (entity[13] != -1) { listaNegra.VCHIDREL = strEntities[entity[13]] + '|'; } else { listaNegra.VCHIDREL = "" + '|'; } if (entity[14] != -1) { listaNegra.VCHPARENTESCO = strEntities[entity[14]] + '|'; } else { listaNegra.VCHPARENTESCO = "" + '|'; } if (entity[15] != -1) { listaNegra.VCHRAZONSOCIAL = strEntities[entity[15]] + '|'; } else { listaNegra.VCHRAZONSOCIAL = "" + '|'; } if (entity[16] != -1) { listaNegra.VCHRFCMORAL = strEntities[entity[16]] + '|'; } else { listaNegra.VCHRFCMORAL = "" + '|'; } if (entity[17] != -1) { listaNegra.VCHISSSTE = strEntities[entity[17]] + '|'; } else { listaNegra.VCHISSSTE = "" + '|'; } if (entity[18] != -1) { listaNegra.VCHIMSS = strEntities[entity[18]] + '|'; } else { listaNegra.VCHIMSS = "" + '|'; } if (entity[19] != -1) { listaNegra.VCHINGRESOS = strEntities[entity[19]] + '|'; } else { listaNegra.VCHINGRESOS = "" + '|'; } if (entity[20] != -1) { listaNegra.VCHNOMCOMPLETO = QuitarCaracteresEspeciales(strEntities[entity[20]]).ToUpper() + '|'; } else { listaNegra.VCHNOMCOMPLETO = "" + '|'; } if (entity[21] != -1) { listaNegra.VCHAPELLIDOS = QuitarCaracteresEspeciales(strEntities[entity[21]]).ToUpper() + '|'; } else { listaNegra.VCHAPELLIDOS = "" + '|'; } if (listaNegra.VCHNOMBRE.Replace("|", "") != string.Empty && listaNegra.VCHAPPATERNO.Replace("|", "") != string.Empty && listaNegra.VCHAPMATERNO.Replace("|", "") != string.Empty) { listaNegra.vchCadenaNPM = listaNegra.VCHNOMBRE.Replace("|", "").Replace(".", "").Replace(" ", "").Replace(",", "").Replace(";", "").Replace("'", "").Replace("\"", "").Replace("/", "").Replace("\\", "") + listaNegra.VCHAPPATERNO.Replace("|", "").Replace(".", "").Replace(" ", "").Replace(",", "").Replace(";", "").Replace("'", "").Replace("\"", "").Replace("/", "").Replace("\\", "") + listaNegra.VCHAPMATERNO.Replace("|", "").Replace(".", "").Replace(" ", "").Replace(",", "").Replace(";", "").Replace("'", "").Replace("\"", "").Replace("/", "").Replace("\\", ""); listaNegra.vchCadenaNMP = listaNegra.VCHNOMBRE.Replace("|", "").Replace(".", "").Replace(" ", "").Replace(",", "").Replace(";", "").Replace("'", "").Replace("\"", "").Replace("/", "").Replace("\\", "") + listaNegra.VCHAPMATERNO.Replace("|", "").Replace(".", "").Replace(" ", "").Replace(",", "").Replace(";", "").Replace("'", "").Replace("\"", "").Replace("/", "").Replace("\\", "") + listaNegra.VCHAPPATERNO.Replace("|", "").Replace(".", "").Replace(" ", "").Replace(",", "").Replace(";", "").Replace("'", "").Replace("\"", "").Replace("/", "").Replace("\\", ""); } if (listaNegra.VCHNOMBRE.Replace("|", "") != string.Empty && listaNegra.VCHAPPATERNO.Replace("|", "") == string.Empty || listaNegra.VCHAPMATERNO.Replace("|", "") == string.Empty && (listaNegra.VCHAPPATERNO.Replace("|", "") != string.Empty || listaNegra.VCHAPMATERNO.Replace("|", "") != string.Empty)) { listaNegra.vchCadenaNPM = listaNegra.VCHNOMBRE.Replace("|", "").Replace(".", "").Replace(" ", "").Replace(",", "").Replace(";", "").Replace("'", "").Replace("\"", "").Replace("/", "").Replace("\\", "") + listaNegra.VCHAPPATERNO.Replace("|", "").Replace(".", "").Replace(" ", "").Replace(",", "").Replace(";", "").Replace("'", "").Replace("\"", "").Replace("/", "").Replace("\\", "") + listaNegra.VCHAPMATERNO.Replace("|", "").Replace(".", "").Replace(" ", "").Replace(",", "").Replace(";", "").Replace("'", "").Replace("\"", "").Replace("/", "").Replace("\\", ""); } if (listaNegra.VCHNOMBRE.Replace("|", "") == string.Empty && listaNegra.VCHAPPATERNO.Replace("|", "") == string.Empty && listaNegra.VCHAPMATERNO.Replace("|", "") == string.Empty) { if (listaNegra.VCHNOMCOMPLETO.Replace("|", "") == listaNegra.VCHRAZONSOCIAL.Replace("|", "")) { listaNegra.vchCadenaNPM = listaNegra.VCHNOMCOMPLETO.Replace("|", "").Replace(".", "").Replace(" ", "").Replace(",", "").Replace(";", "").Replace("'", "").Replace("\"", "").Replace("/", "").Replace("\\", ""); } } if (listaNegra.VCHNOMBRE.Replace("|", "") == string.Empty && listaNegra.VCHAPPATERNO.Replace("|", "") == string.Empty && listaNegra.VCHAPMATERNO.Replace("|", "") == string.Empty) { if (listaNegra.VCHNOMCOMPLETO.Replace("|", "") != listaNegra.VCHRAZONSOCIAL.Replace("|", "")) { listaNegra.vchCadenaNPM = listaNegra.VCHRAZONSOCIAL.Replace("|", "").Replace(".", "").Replace(" ", "").Replace(",", "").Replace(";", "").Replace("'", "").Replace("\"", "").Replace("/", "").Replace("\\", ""); listaNegra.vchCadenaNMP = listaNegra.VCHNOMCOMPLETO.Replace("|", "").Replace(".", "").Replace(" ", "").Replace(",", "").Replace(";", "").Replace("'", "").Replace("\"", "").Replace("/", "").Replace("\\", ""); } } try { if (entity[22] != -1) { listaNegra.VCHENTIDAD = strEntities[entity[22]] + '|'; } else { listaNegra.VCHENTIDAD = "" + '|'; } if (entity[23] != -1) { listaNegra.VCHGENERO = strEntities[entity[23]] + '|'; } else { listaNegra.VCHGENERO = "" + '|'; } } catch { listaNegra.VCHENTIDAD = "|"; listaNegra.VCHGENERO = "|"; } lstListaNegra.Add(listaNegra); sbtxt.AppendLine(listaNegra.VCHIDQEQ + listaNegra.VCHTIPOLISTA + listaNegra.VCHNOMBRE + listaNegra.VCHAPPATERNO + listaNegra.VCHAPMATERNO + listaNegra.VCHCURP + listaNegra.VCHRFC + listaNegra.VCHFECHANAC + listaNegra.VCHESTATUS + listaNegra.VCHDEPENDENCIA + listaNegra.VCHPUESTO + listaNegra.INTIDDISPO + listaNegra.BITCURPOK + listaNegra.VCHIDREL + listaNegra.VCHPARENTESCO + listaNegra.VCHRAZONSOCIAL + listaNegra.VCHRFCMORAL + listaNegra.VCHISSSTE + listaNegra.VCHIMSS + listaNegra.VCHINGRESOS + listaNegra.VCHNOMCOMPLETO + listaNegra.VCHAPELLIDOS + listaNegra.VCHENTIDAD + listaNegra.VCHGENERO + Session["User"] + "|" + DateTime.Now.ToString("yyyy/MM/dd") + "|" + listaNegra.vchCadenaNPM + "|" + listaNegra.vchCadenaNMP + "|" + listaNegra.iProveedorId); } } count++; sLine = objReader.ReadLine(); } } objReader.Close(); EscribeServidor(sbtxt); result = 1; } //else //{ //} } catch (Exception ex) { escribeLog(ex.Message); throw ex; } return(result); }