public async Task <OrganizationDifferenceImage> GetImage() { DateTime now = DateTime.Now; var result = new OrganizationDifferenceImage() { MachineName = Environment.MachineName, ExecuteUserDomainName = Environment.UserDomainName, ExecuteUserName = Environment.UserName, CreatedOn = now, Connection1Image = new SolutionImage() { ConnectionName = _service1.ConnectionData.Name, ConnectionOrganizationName = _service1.ConnectionData.UniqueOrgName, ConnectionDiscoveryService = _service1.ConnectionData.DiscoveryUrl, ConnectionOrganizationService = _service1.ConnectionData.OrganizationUrl, ConnectionPublicUrl = _service1.ConnectionData.PublicUrl, ConnectionSystemUserName = _service1.ConnectionData.GetUsername, MachineName = Environment.MachineName, ExecuteUserDomainName = Environment.UserDomainName, ExecuteUserName = Environment.UserName, CreatedOn = now, }, Connection2Image = new SolutionImage() { ConnectionName = _service2.ConnectionData.Name, ConnectionOrganizationName = _service2.ConnectionData.UniqueOrgName, ConnectionDiscoveryService = _service2.ConnectionData.DiscoveryUrl, ConnectionOrganizationService = _service2.ConnectionData.OrganizationUrl, ConnectionPublicUrl = _service2.ConnectionData.PublicUrl, MachineName = Environment.MachineName, ExecuteUserDomainName = Environment.UserDomainName, ExecuteUserName = Environment.UserName, CreatedOn = now, }, }; { var list = await Descriptor1.GetSolutionImageComponentsListAsync(this._componentsOnlyIn1); foreach (var item in list) { if (!result.Connection1Image.Components.Contains(item)) { result.Connection1Image.Components.Add(item); } } } { var list = await Descriptor2.GetSolutionImageComponentsListAsync(this._componentsOnlyIn2); foreach (var item in list) { if (!result.Connection2Image.Components.Contains(item)) { result.Connection2Image.Components.Add(item); } } } { var task1 = Descriptor1.GetSolutionImageComponentsListAsync(this._componentsDifferent.Select(e => e.Item1)); var task2 = Descriptor2.GetSolutionImageComponentsListAsync(this._componentsDifferent.Select(e => e.Item2)); await task1; await task2; foreach (var item in this._componentsDifferent) { var list = await Descriptor1.GetSolutionImageComponentsListAsync(new[] { item.Item1 }); foreach (var item1 in list) { var diff = new OrganizationDifferenceImageComponent(item1) { DescriptionSecond = Descriptor2.GetComponentDescription(item.Item2.ComponentType.Value, item.Item2.ObjectId.Value), DescriptionDifference = item.Item3, }; if (!result.DifferentComponents.Contains(diff)) { result.DifferentComponents.Add(diff); } } } } var sorter = new SolutionImageComponentSorter(); result.Connection1Image.Components.Sort(sorter); result.Connection2Image.Components.Sort(sorter); result.DifferentComponents.Sort(sorter); return(result); }