public EntityLabelComparer(string tabSpacer, string connectionName1, string connectionName2, OptionSetComparer optionSetComparer, HashSet <string> notExising)
 {
     this._tabSpacer         = tabSpacer;
     this._connectionName1   = connectionName1;
     this._connectionName2   = connectionName2;
     this._notExising        = notExising;
     this._optionSetComparer = optionSetComparer;
 }
Exemplo n.º 2
0
        private async Task <string> CheckConnectionRoleCategories()
        {
            StringBuilder content = new StringBuilder();

            await _comparerSource.InitializeConnection(_iWriteToOutput, content);

            string operation = string.Format(Properties.OperationNames.CheckingConnectionRoleCategoriesFormat2, Connection1.Name, Connection2.Name);

            content.AppendLine(_iWriteToOutput.WriteToOutputStartOperation(null, operation));

            const string optionSetName = "connectionrole_category";

            var request = new RetrieveOptionSetRequest()
            {
                Name = optionSetName,
            };

            var response1 = (RetrieveOptionSetResponse)_comparerSource.Service1.Execute(request);
            var response2 = (RetrieveOptionSetResponse)_comparerSource.Service2.Execute(request);

            var optionSet1 = (OptionSetMetadata)response1.OptionSetMetadata;
            var optionSet2 = (OptionSetMetadata)response2.OptionSetMetadata;

            var optionSetComparer = new OptionSetComparer(tabSpacer, Connection1.Name, Connection2.Name, new StringMapRepository(_comparerSource.Service1), new StringMapRepository(_comparerSource.Service2));

            if (optionSet1 == null && optionSet2 == null)
            {
                content.AppendFormat(Properties.OrganizationComparerStrings.GlobalOptionSetNotExistsInConnectionsFormat3, optionSetName, Connection1.Name, Connection2.Name);
            }
            else if (optionSet1 != null && optionSet2 == null)
            {
                content.AppendFormat(Properties.OrganizationComparerStrings.GlobalOptionSetOnlyExistsInConnectionFormat2, optionSetName, Connection2.Name);

                this.ImageBuilder.AddComponentSolution1((int)ComponentType.OptionSet, optionSet1.MetadataId.Value);
            }
            else if (optionSet1 == null && optionSet2 != null)
            {
                content.AppendFormat(Properties.OrganizationComparerStrings.GlobalOptionSetOnlyExistsInConnectionFormat2, optionSetName, Connection1.Name);

                this.ImageBuilder.AddComponentSolution2((int)ComponentType.OptionSet, optionSet2.MetadataId.Value);
            }
            else
            {
                List <string> strDifference = await optionSetComparer.GetDifference(optionSet1, optionSet2, "connectionrole", "category");

                if (strDifference.Count > 0)
                {
                    this.ImageBuilder.AddComponentDifferent((int)ComponentType.OptionSet, optionSet1.MetadataId.Value, optionSet2.MetadataId.Value, string.Join(Environment.NewLine, strDifference));

                    content.AppendLine().AppendLine().AppendFormat(Properties.OrganizationComparerStrings.GlobalOptionSetDifferentFormat3, optionSetName, Connection1.Name, Connection2.Name);

                    foreach (var str in strDifference)
                    {
                        content.AppendLine().Append((tabSpacer + tabSpacer + str).TrimEnd());
                    }
                }
                else
                {
                    content.AppendLine(Properties.OrganizationComparerStrings.ConnectionRoleCategoriesNoDifference);
                }
            }

            content.AppendLine(_iWriteToOutput.WriteToOutputEndOperation(null, operation));

            string fileName = EntityFileNameFormatter.GetDifferenceConnectionsForFieldFileName(_OrgOrgName, Properties.OrganizationComparerStrings.ConnectionRoleCategoryFileName);

            string filePath = Path.Combine(_folder, FileOperations.RemoveWrongSymbols(fileName));

            File.WriteAllText(filePath, content.ToString(), new UTF8Encoding(false));

            await SaveOrganizationDifferenceImage();

            return(filePath);
        }