public DataTable ObtenerDatos() { DataTable afectados; afectados = this.ComplexDataErrorMessages(); if (afectados.Rows.Count == 0) { if (_aplicarExcepciones) { CfgExcepciones helper = new CfgExcepciones(this); afectados = helper.ObtenerAfectados(); if (helper.IsValid && _direccion == TipoComprobacion.ModificacionesPendientesEnSIGUA) { afectados.DefaultView.RowStateFilter = DataViewRowState.ModifiedCurrent; afectados = afectados.DefaultView.ToTable(); } } else { afectados = DBUtils.GetRelationDataSet(this).Tables[0]; if (afectados.TableName != "Excepcion" && _direccion == TipoComprobacion.ModificacionesPendientesEnSIGUA) { afectados.DefaultView.RowStateFilter = DataViewRowState.ModifiedCurrent; afectados = afectados.DefaultView.ToTable(); } } } return(afectados); }
public DataTable Simular() { DataTable resultado; DataTable afectados; bool abortar = false; resultado = this.ComplexDataErrorMessages(); if (resultado.Rows.Count == 0) { if (_aplicarExcepciones) { CfgExcepciones helper = new CfgExcepciones(this); afectados = helper.ObtenerAfectados(); abortar = (helper.IsValid == false); } else { afectados = DBUtils.GetRelationDataSet(this).Tables[0]; abortar = (afectados.TableName == "Excepcion"); } if (!abortar) { resultado = new DataTable(); resultado.Columns.Add(new DataColumn("Incidencia__", System.Type.GetType("System.String"))); foreach (DataColumn dc in afectados.Columns) { resultado.Columns.Add(dc.ColumnName, dc.DataType); } foreach (DataRow dr in _complexData.Tables["Simulaciones"].Rows) { string sql = string.Format("SELECT DISTINCT {0} FROM {1}", dr["CampoAjeno"], dr["TablaAjena"]); DataTable dtLookUp = DBUtils.GetDataSet(dbOrigen.PGSQL, sql, null).Tables[0]; List <object[]> listUnjoined = DBUtils.GetUnjoined(afectados.Copy(), (string)dr["CampoAComprobar"], dtLookUp.Copy(), (string)dr["CampoAjeno"], _direccion); foreach (object[] row in listUnjoined) { int i = row.GetLength(0); object[] newrow = new object[i + 1]; newrow[0] = dr["Descripcion"]; Array.ConstrainedCopy(row, 0, newrow, 1, i); resultado.LoadDataRow(newrow, true); } } } else { resultado = afectados; } } return(resultado); }
public DataTable Sincronizar() { DataTable resultado; DataTable afectados; bool abortar = false; resultado = this.ComplexDataErrorMessages(); if (resultado.Rows.Count == 0) { if (_aplicarExcepciones) { CfgExcepciones helper = new CfgExcepciones(this); afectados = helper.ObtenerAfectados(); abortar = (helper.IsValid == false); } else { afectados = DBUtils.GetRelationDataSet(this).Tables[0]; abortar = (afectados.TableName == "Excepcion"); } if (!abortar) { DataSet ds = new DataSet(); string sql = string.Empty; if (this._tablaSIGUA.Trim().StartsWith("SELECT", StringComparison.InvariantCultureIgnoreCase)) { sql = this._tablaSIGUA.Trim(); } else { sql = string.Format("SELECT * FROM {0} WHERE 0 = 1", this._tablaSIGUA); } switch (_direccion) { case (TipoComprobacion.AltasPendientesEnSIGUA): DataTable afectadosExport = this.ExportData(afectados, this._tablaSIGUA, this._complexData.Tables["Joins"], this._complexData.Tables["Correspondencias"], this._complexData.Tables["Defaults"]); ds.Tables.Add(afectadosExport); if (afectadosExport.TableName == "Excepcion") { resultado = afectadosExport; } else { resultado = DBUtils.UpdateDB(sql, null, ds).Tables[0]; _ultimaEjecucion = DateTime.Now; } break; case (TipoComprobacion.BajasPendientesEnSIGUA): DataTable afectadosCopy = this.CopyData(afectados, this._tablaSIGUA); ds.Tables.Add(afectadosCopy); if (afectadosCopy.TableName == "Excepcion") { resultado = afectadosCopy; } else { //Marcar filas para borrado foreach (DataRow dr in afectadosCopy.Rows) { dr.Delete(); } resultado = DBUtils.UpdateDB(sql, null, ds).Tables[0]; _ultimaEjecucion = DateTime.Now; } break; case (TipoComprobacion.ModificacionesPendientesEnSIGUA): DataTable modificadosCopy = afectados.Copy(); modificadosCopy.TableName = "Table"; ds.Tables.Add(modificadosCopy); if (modificadosCopy.TableName == "Excepcion") { resultado = modificadosCopy; } else { resultado = DBUtils.UpdateDB(sql, null, ds).Tables[0]; _ultimaEjecucion = DateTime.Now; } break; default: DBUtils.FillExceptionDataSet(ds, "No se ejecutó ningún comando"); resultado = ds.Tables[0]; break; } } else { resultado = afectados; } } return(resultado); }