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);
        }
예제 #2
0
        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);
        }