private DataTable ConvertToDataTable(SortedDictionary <string, CellComparison> allColumnDictionary) { DataTable dataTable = new DataTable(); var column = new DataColumn(Constants.DatabaseTypeColumnName); dataTable.Columns.Add(column); // Add Columns foreach (var cellComparison in allColumnDictionary) { column = new DataColumn(cellComparison.Value.ColumnName); dataTable.Columns.Add(column); column = new DataColumn(DynamicColumn.GetIsColumnPresentColumnName(cellComparison.Value.ColumnName)); column.DataType = typeof(bool); dataTable.Columns.Add(column); column = new DataColumn(DynamicColumn.GetIsDataEqualColumnName(cellComparison.Value.ColumnName)); column.DataType = typeof(bool); dataTable.Columns.Add(column); column = new DataColumn(DynamicColumn.GetIsVisibleColumnName(cellComparison.Value.ColumnName)); column.DataType = typeof(bool); dataTable.Columns.Add(column); } // Add Rows DataRow firstDbDataRow = dataTable.NewRow(); DataRow secondDbDataRow = dataTable.NewRow(); foreach (var columnComparisonDetail in allColumnDictionary) { var columnName = columnComparisonDetail.Value.ColumnName; // DATABASE firstDbDataRow[Constants.DatabaseTypeColumnName] = ConfigurationManager.AppSettings[Constants.AppSettingKeyDatabaseOneType]; secondDbDataRow[Constants.DatabaseTypeColumnName] = ConfigurationManager.AppSettings[Constants.AppSettingKeyDatabaseTwoType];; // Value firstDbDataRow[columnName] = columnComparisonDetail.Value.FirstDatabaseColumnValue; secondDbDataRow[columnName] = columnComparisonDetail.Value.SecondDatabaseColumnValue; // IsColumnPresent firstDbDataRow[DynamicColumn.GetIsColumnPresentColumnName(columnName)] = columnComparisonDetail.Value.IsColumnAvailableInFirstDatabase; secondDbDataRow[DynamicColumn.GetIsColumnPresentColumnName(columnName)] = columnComparisonDetail.Value.IsColumnAvailableInSecondDatabase; // IsDataEqual firstDbDataRow[DynamicColumn.GetIsDataEqualColumnName(columnName)] = columnComparisonDetail.Value.IsDataEqual; secondDbDataRow[DynamicColumn.GetIsDataEqualColumnName(columnName)] = columnComparisonDetail.Value.IsDataEqual; // IsVisible firstDbDataRow[DynamicColumn.GetIsVisibleColumnName(columnName)] = true; secondDbDataRow[DynamicColumn.GetIsVisibleColumnName(columnName)] = true; } dataTable.Rows.Add(firstDbDataRow); dataTable.Rows.Add(secondDbDataRow); return(dataTable); }
public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if (values != null && values.Count() == 3) { if (values[0] == DependencyProperty.UnsetValue || values[1] == DependencyProperty.UnsetValue || values[2] == DependencyProperty.UnsetValue) { return(Binding.DoNothing); } string columnName = values[0].ConvertToString(); DataRowView dataRow = values[1] as DataRowView; DataTable dataTable = values[2] as DataTable; if (columnName != null && dataRow != null && columnName != Constants.DatabaseTypeColumnName) { var isColumnPresent = DynamicColumn.GetIsColumnPresentColumnName(columnName); if (!dataRow[isColumnPresent].ConvertToBool()) { return(Brushes.Orange); } var isEqualColumnName = DynamicColumn.GetIsDataEqualColumnName(columnName); if (!dataRow[isEqualColumnName].ConvertToBool()) { return(Brushes.Red); } } } return(Binding.DoNothing); }
private void DgResult_OnAutoGeneratedColumns(object sender, EventArgs e) { if (RbOnlyMismatchedData.IsChecked != null && RbOnlyMismatchedData.IsChecked.Value) { var dataTable = DgResult.DataContext as DataTable; if (dataTable != null && dataTable.Rows.Count > 0) { List <DataGridColumn> toRemoveList = new List <DataGridColumn>(); foreach (var dataGridColumn in DgResult.Columns) { if (dataGridColumn.Header.ToString() == Constants.DatabaseTypeColumnName) { continue; } var columnName = DynamicColumn.GetIsDataEqualColumnName(dataGridColumn.Header.ToString()); if (dataTable.Rows[0][columnName].ConvertToBool()) { toRemoveList.Add(dataGridColumn); } } foreach (var dataGridColumn in toRemoveList) { DgResult.Columns.Remove(dataGridColumn); } } } if (RbAllData.IsChecked != null && RbAllData.IsChecked.Value) { foreach (var dataGridColumn in DgResult.Columns) { dataGridColumn.Visibility = Visibility.Visible; } } }