private static void UpdateValidation(InternalDataRow dataRow1, InternalDataRow dataRow2) { if (dataRow2 != null && (bool)dataRow1[DiffUtility.DiffEnabledKey] == true) { foreach (var item in dataRow1.Table.Columns) { if (item is InternalDataColumn dataColumn) { var field1 = dataRow1[dataColumn.ColumnName]; var dataColumn2 = GetColumn(dataRow2, dataColumn.Index); var field2 = dataRow2[dataColumn2]; DiffDataTable.Validate((CremaDataRow)dataRow1, (CremaDataColumn)dataColumn); } } if (dataRow1.GetColumnsInError().Any()) { dataRow1.RowError = rowError; } else { dataRow1.RowError = string.Empty; } } }
private void WriteAttribute(XmlWriter writer, InternalDataRow dataRow, InternalAttribute dataColumn) { var field = dataRow[dataColumn]; if (field == DBNull.Value || object.Equals(field, dataColumn.DefaultValue) == true) { return; } var textValue = CremaXmlConvert.ToString(field, dataColumn.DataType); if (string.IsNullOrEmpty(textValue) == false) { writer.WriteStartAttribute(dataColumn.AttributeName); writer.WriteValue(textValue); writer.WriteEndAttribute(); } }
private static void Update(InternalDataRow dataRow1, InternalDataRow dataRow2, DiffState defaultState, string[] filters) { if (dataRow2 == null || (bool)dataRow1[DiffUtility.DiffEnabledKey] == false) { DiffUtility.SetDiffFields(dataRow1, null); DiffUtility.SetDiffState(dataRow1, DiffState.Imaginary); } else { var fieldsList = new List <string>(dataRow1.Table.Columns.Count); var diffState = defaultState; foreach (var item in dataRow1.Table.Columns) { if (item is InternalDataColumn dataColumn) { if (filters.Contains(dataColumn.ColumnName) == true) { continue; } var field1 = dataRow1[dataColumn.ColumnName]; var dataColumn2 = GetColumn(dataRow2, dataColumn.Index); var field2 = dataRow2[dataColumn2]; if (object.Equals(field1, field2) == false) { fieldsList.Add(dataColumn.ColumnName); } DiffDataTable.Validate((CremaDataRow)dataRow1, (CremaDataColumn)dataColumn); } else if (item is InternalAttribute attribute) { if (attribute.ColumnMapping == MappingType.Hidden || filters.Contains(attribute.AttributeName) == true) { continue; } var field1 = dataRow1[attribute.AttributeName]; var field2 = dataRow2[attribute.AttributeName]; if (object.Equals(field1, field2) == false) { fieldsList.Add(attribute.AttributeName); } } } if (dataRow1.GetColumnsInError().Any()) { dataRow1.RowError = rowError; } else { dataRow1.RowError = string.Empty; } if ((bool)dataRow2[DiffUtility.DiffEnabledKey] == true) { if (fieldsList.Any() == true || object.Equals(dataRow1[CremaSchema.Index], dataRow2[CremaSchema.Index]) == false) { diffState = DiffState.Modified; } else { diffState = DiffState.Unchanged; } DiffUtility.SetDiffFields(dataRow1, fieldsList); DiffUtility.SetDiffState(dataRow1, diffState); } else { DiffUtility.SetDiffFields(dataRow1, null); DiffUtility.SetDiffState(dataRow1, diffState); } } }