private void CompareManyToMany(OrganizationDifferenceImageBuilder imageBuilder, List <string> strDifference, string entityName, IEnumerable <ManyToManyRelationshipMetadata> listRel1, IEnumerable <ManyToManyRelationshipMetadata> listRel2) { Dictionary <string, List <string> > dictDifference = new Dictionary <string, List <string> >(StringComparer.InvariantCultureIgnoreCase); foreach (var rel1 in listRel1.OrderBy(s => s.SchemaName)) { var rel2 = listRel2.FirstOrDefault(s => s.SchemaName == rel1.SchemaName); if (rel2 == null) { continue; } if (_notExising.Contains(rel1.Entity1LogicalName) || _notExising.Contains(rel1.Entity2LogicalName)) { continue; } if (_notExising.Contains(rel2.Entity1LogicalName) || _notExising.Contains(rel2.Entity2LogicalName)) { continue; } List <string> diff = GetDifferenceManyToMany(rel1, rel2); if (diff.Count > 0) { dictDifference.Add(rel1.SchemaName, diff); imageBuilder.AddComponentDifferent((int)ComponentType.EntityRelationship, rel1.MetadataId.Value, rel2.MetadataId.Value, string.Join(Environment.NewLine, diff)); } } if (dictDifference.Count > 0) { if (strDifference.Count > 0) { strDifference.Add(string.Empty); } strDifference.Add(string.Format("ManyToMany DIFFERENT in {0} and {1}: {2}", _connectionName1, _connectionName2, dictDifference.Count)); foreach (var item in dictDifference.OrderBy(e => e.Key)) { if (strDifference.Count > 0) { strDifference.Add(string.Empty); } strDifference.Add(string.Format("Different ManyToMany {0}", item.Key)); item.Value.ForEach(s => strDifference.Add(_tabSpacer + s)); } } }
private async Task CompareAttributes(OrganizationDifferenceImageBuilder imageBuilder, List <string> strDifference, string entityName, IEnumerable <AttributeMetadata> attributes1, IEnumerable <AttributeMetadata> attributes2) { Dictionary <string, List <string> > dictDifference = new Dictionary <string, List <string> >(StringComparer.InvariantCultureIgnoreCase); foreach (var attr1 in attributes1.OrderBy(s => s.LogicalName)) { var attr2 = attributes2.FirstOrDefault(s => s.LogicalName == attr1.LogicalName); if (attr2 == null) { continue; } List <string> diff = await GetDifferenceAttribute(attr1, attr2); if (diff.Count > 0) { dictDifference.Add(attr1.LogicalName, diff); imageBuilder.AddComponentDifferent((int)ComponentType.Attribute, attr1.MetadataId.Value, attr2.MetadataId.Value, string.Join(Environment.NewLine, diff)); } } if (dictDifference.Count > 0) { if (strDifference.Count > 0) { strDifference.Add(string.Empty); } strDifference.Add(string.Format("Attributes DIFFERENT in {0} and {1}: {2}", _connectionName1, _connectionName2, dictDifference.Count)); foreach (var item in dictDifference.OrderBy(e => e.Key)) { if (strDifference.Count > 0) { strDifference.Add(string.Empty); } strDifference.Add(string.Format("Different Attribute {0}", item.Key)); item.Value.ForEach(s => strDifference.Add(_tabSpacer + s)); } } }
private void CompareKeys(OrganizationDifferenceImageBuilder imageBuilder, List <string> strDifference, string entityName, IEnumerable <EntityKeyMetadata> keys1, IEnumerable <EntityKeyMetadata> keys2) { Dictionary <string, List <string> > dictDifference = new Dictionary <string, List <string> >(StringComparer.InvariantCultureIgnoreCase); foreach (var key1 in keys1.OrderBy(s => s.LogicalName)) { var key2 = keys2.FirstOrDefault(s => s.LogicalName == key1.LogicalName); if (key2 == null) { continue; } List <string> diff = GetDifferenceKey(key1, key2); if (diff.Count > 0) { dictDifference.Add(key1.LogicalName, diff.Select(s => _tabSpacer + s).ToList()); imageBuilder.AddComponentDifferent((int)ComponentType.EntityKey, key1.MetadataId.Value, key2.MetadataId.Value, string.Join(Environment.NewLine, diff)); } } if (dictDifference.Count > 0) { if (strDifference.Count > 0) { strDifference.Add(string.Empty); } strDifference.Add(string.Format("Keys DIFFERENT in {0} and {1}: {2}", _connectionName1, _connectionName2, dictDifference.Count)); foreach (var item in dictDifference.OrderBy(e => e.Key)) { if (strDifference.Count > 0) { strDifference.Add(string.Empty); } strDifference.Add(string.Format("Different Keys {0}", item.Key)); strDifference.AddRange(item.Value); } } }