Ejemplo n.º 1
0
        public async Task <HttpResponseMessage> MigrateToCloudIAPartner(string filePath, string name, PartnerMigrationItemViewModel serverPartnerItem, IntegrationAccountDetails iaDetails, AuthenticationResult authResult)
        {
            try
            {
                IntegrationAccountContext sclient = new IntegrationAccountContext();
                try
                {
                    List <KeyValuePair <string, string> > partnerIdentities = new List <KeyValuePair <string, string> >();
                    var    partnerInIA      = sclient.GetArtifactsFromIA(UrlHelper.GetPartnerUrl(name, iaDetails), authResult);
                    string responseAsString = await partnerInIA.Content.ReadAsStringAsync();

                    JObject responseAsJObject = JsonConvert.DeserializeObject <JObject>(responseAsString);
                    var     partner           = responseAsJObject;
                    if (partner["properties"] != null && partner["properties"]["content"] != null && partner["properties"]["content"]["b2b"] != null && partner["properties"]["content"]["b2b"]["businessIdentities"] != null)
                    {
                        foreach (var identity in partner["properties"]["content"]["b2b"]["businessIdentities"])
                        {
                            if (identity["qualifier"] != null && identity["value"] != null)
                            {
                                KeyValuePair <string, string> kvpair = new KeyValuePair <string, string>(identity["qualifier"].ToString(), identity["value"].ToString());
                                if (!partnerIdentities.Contains(kvpair))
                                {
                                    partnerIdentities.Add(kvpair);
                                }
                            }
                        }
                    }
                    var partnersFromLocalFile = File.ReadAllText(filePath);
                    var partnerContent        = JsonConvert.DeserializeObject <JsonPartner.Rootobject>(partnersFromLocalFile);
                    var partnerIdentityDict   = partnerContent.properties.content.b2b.businessIdentities.ToDictionary(xc => new KeyValuePair <string, string>(xc.qualifier, xc.value), xc => xc.value);
                    var partnerIdentityList   = partnerContent.properties.content.b2b.businessIdentities.ToList();
                    foreach (var identity in partnerIdentities)
                    {
                        if (!partnerIdentityDict.ContainsKey(identity))
                        {
                            partnerIdentityDict.Add(identity, identity.Value);
                            partnerIdentityList.Add(new JsonPartner.Businessidentity {
                                qualifier = identity.Key, value = identity.Value
                            });
                        }
                    }
                    partnerContent.properties.content.b2b.businessIdentities = partnerIdentityList.ToArray();
                    var finalcontent = JsonConvert.SerializeObject(partnerContent);
                    File.WriteAllText(filePath, finalcontent);
                }
                catch (Exception)
                {
                    //do nothing
                }
                var x = await sclient.LAIntegrationFromFile(UrlHelper.GetPartnerUrl(name, iaDetails), filePath, authResult);

                return(x);
            }
            catch (Exception ex)
            {
                serverPartnerItem.ExportStatus     = MigrationStatus.Failed;
                serverPartnerItem.ExportStatusText = ex.Message;
                TraceProvider.WriteLine(string.Format("Partner Migration Failed. Reason:{0}", ExceptionHelper.GetExceptionMessage(ex)));
                TraceProvider.WriteLine();
                throw ex;
            }
        }
Ejemplo n.º 2
0
        public override void Initialize(IApplicationContext applicationContext)
        {
            base.Initialize(applicationContext);
            pMigrator  = new PartnerMigrator(this.ApplicationContext);
            aMigrator  = new AgreementMigrator(this.ApplicationContext);
            sMigrator  = new SchemaMigrator(this.ApplicationContext);
            mMigrator  = new MapMigrator(this.ApplicationContext);
            c1Migrator = new CerificateMigrator <PartnerMigrationItemViewModel>(this.ApplicationContext);
            c2Migrator = new CerificateMigrator <Certificate>(this.ApplicationContext);

            ExportedItems = new ObservableCollection <ExportedArtifact>();

            selectedSchemas = this.ApplicationContext.GetProperty(AppConstants.SelectedSchemasContextPropertyName) as IEnumerable <SchemaMigrationItemViewModel>;
            importedSchemas = selectedSchemas.Where(item => item.ImportStatus == MigrationStatus.Succeeded);

            selectedMaps = this.ApplicationContext.GetProperty(AppConstants.SelectedMapsContextPropertyName) as IEnumerable <MapMigrationItemViewModel>;
            importedMaps = selectedMaps.Where(item => item.ImportStatus == MigrationStatus.Succeeded);

            selectedPartners = this.ApplicationContext.GetProperty(AppConstants.SelectedPartnersContextPropertyName) as IEnumerable <PartnerMigrationItemViewModel>;
            if (applicationContext.GetProperty("MigrationCriteria").ToString() == "Partner")
            {
                importedPartners = selectedPartners.Where(item => item.ImportStatus == MigrationStatus.Succeeded);
            }
            if (applicationContext.GetProperty("MigrationCriteria").ToString() == "Partner")
            {
                importedPartnersWithCertificates = selectedPartners.Where(item => item.CertificationRequired == true && item.CertificateImportStatus == MigrationStatus.Succeeded);
            }

            selectedAgreements = this.ApplicationContext.GetProperty(AppConstants.SelectedAgreementsContextPropertyName) as IEnumerable <AgreementMigrationItemViewModel>;
            if (applicationContext.GetProperty("MigrationCriteria").ToString() == "Partner")
            {
                importedAgreements = selectedAgreements.Where(item => item.ImportStatus == MigrationStatus.Succeeded);
            }

            otherCerts = this.ApplicationContext.GetProperty("OtherCertificates") as List <Certificate>;

            ExportSchemasFlag      = Convert.ToBoolean(this.ApplicationContext.GetProperty("ExportSchemas"));
            ExportMapsFlag         = Convert.ToBoolean(this.ApplicationContext.GetProperty("ExportMaps"));
            ExportCertificatesFlag = Convert.ToBoolean(this.ApplicationContext.GetProperty("ExportCertificates"));
            ExportPartnersFlag     = Convert.ToBoolean(this.ApplicationContext.GetProperty("ExportPartners"));
            ExportAgreementsFlag   = Convert.ToBoolean(this.ApplicationContext.GetProperty("ExportAgreements"));

            bool consolidateAgreements   = Convert.ToBoolean(this.ApplicationContext.GetProperty(AppConstants.ConsolidationEnabled));
            bool generateMetadataContext = Convert.ToBoolean(this.ApplicationContext.GetProperty(AppConstants.ContextGenerationEnabled));

            if (ExportSchemasFlag || ExportCertificatesFlag || ExportPartnersFlag || ExportAgreementsFlag || ExportMapsFlag)
            {
                if (ExportSchemasFlag)
                {
                    foreach (var item in importedSchemas)
                    {
                        ExportedItems.Add(new ExportedArtifact
                        {
                            ArtifactName     = item.MigrationEntity.fullNameOfSchemaToUpload,
                            ArtifactType     = ArtifactTypes.Schema,
                            ExportStatus     = MigrationStatus.NotStarted,
                            ExportStatusText = null
                        });
                    }
                }
                if (ExportMapsFlag)
                {
                    foreach (var item in importedMaps)
                    {
                        ExportedItems.Add(new ExportedArtifact
                        {
                            ArtifactName     = item.MigrationEntity.fullNameOfMapToUpload,
                            ArtifactType     = ArtifactTypes.Map,
                            ExportStatus     = MigrationStatus.NotStarted,
                            ExportStatusText = null
                        });
                    }
                }
                if (ExportCertificatesFlag)
                {
                    foreach (var item in importedPartnersWithCertificates)
                    {
                        ExportedItems.Add(new ExportedArtifact
                        {
                            ArtifactName     = item.MigrationEntity.CertificateName,
                            ArtifactType     = ArtifactTypes.Certificate,
                            ExportStatus     = MigrationStatus.NotStarted,
                            ExportStatusText = null
                        });
                    }
                    if (otherCerts != null)
                    {
                        otherExtractedCerts = otherCerts.Where(item => item.ImportStatus == MigrationStatus.Succeeded);
                        foreach (var item in otherExtractedCerts)
                        {
                            ExportedItems.Add(new ExportedArtifact
                            {
                                ArtifactName     = item.certificateName,
                                ArtifactType     = ArtifactTypes.Certificate,
                                ExportStatus     = MigrationStatus.NotStarted,
                                ExportStatusText = null
                            });
                        }
                    }
                }
                if (ExportPartnersFlag)
                {
                    foreach (var item in importedPartners)
                    {
                        ExportedItems.Add(new ExportedArtifact
                        {
                            ArtifactName     = item.MigrationEntity.Name,
                            ArtifactType     = ArtifactTypes.Partner,
                            ExportStatus     = MigrationStatus.NotStarted,
                            ExportStatusText = null
                        });
                    }
                }

                if (ExportAgreementsFlag)
                {
                    if (consolidateAgreements)
                    {
                        AuthenticationResult authresult = this.ApplicationContext.GetProperty("IntegrationAccountAuthorization") as AuthenticationResult;
                        List <X12AgreementJson.Rootobject> x12AgreementsInIA = AgreementMigrator.GetAllX12AgreementsInIA(this.ApplicationContext.GetService <IntegrationAccountDetails>(), authresult).Result;
                        this.ApplicationContext.SetProperty("X12AgreementsInIntegrationAccount", x12AgreementsInIA);

                        List <EDIFACTAgreementJson.Rootobject> edifactAgreementsInIA = AgreementMigrator.GetAllEdifactAgreementsInIA(this.ApplicationContext.GetService <IntegrationAccountDetails>(), authresult).Result;
                        this.ApplicationContext.SetProperty("EdifactAgreementsInIntegrationAccount", edifactAgreementsInIA);
                    }
                    foreach (var item in importedAgreements)
                    {
                        if (consolidateAgreements)
                        {
                            TraceProvider.WriteLine(string.Format("Checking {0} for Agreement consolidation..", item.Name));
                            AgreementMigrator agmtMigrator = new AgreementMigrator(this.ApplicationContext);
                            try
                            {
                                agmtMigrator.CheckIfAgreementHasToBeConsolidated(item);
                            }
                            catch (Exception ex)
                            {
                                StatusBarViewModel.StatusInfoType = StatusInfoType.Error;
                                StatusBarViewModel.ShowError(string.Format("Error was encountered during the check for consolidating agreement {0} with IA agreements. Reason: {1}. The agreement will be migrated as such", item.Name, ExceptionHelper.GetExceptionMessage(ex)));
                                TraceProvider.WriteLine(string.Format("Error was encountered during the check for consolidating agreement {0} with IA agreements. Reason: {1}. The agreement will be migrated as such", item.Name, ExceptionHelper.GetExceptionMessage(ex)));
                                TraceProvider.WriteLine();
                            }
                        }
                        ExportedItems.Add(new ExportedArtifact
                        {
                            ArtifactName     = item.Name,
                            ArtifactType     = ArtifactTypes.Agreement,
                            ExportStatus     = MigrationStatus.NotStarted,
                            ExportStatusText = null
                        });
                    }
                }
                countArtifactsMigrated       = 0;
                countTotalArtifactsToMigrate = ExportedItems.Count();
                TotalArtifacts  = countTotalArtifactsToMigrate;
                ProgressVisible = false;
                UpdateProgress();
                ExportArtifacts();
            }
            else
            {
                var lastNavigation = this.ApplicationContext.LastNavigation;
                if (lastNavigation == NavigateAction.Next)
                {
                    this.ApplicationContext.GetService <WizardNavigationViewModel>().MoveToNextStep();
                }
                else if (lastNavigation == NavigateAction.Previous)
                {
                    this.ApplicationContext.GetService <WizardNavigationViewModel>().MoveToPreviousStep();
                }
            }
        }
Ejemplo n.º 3
0
        private async Task ExportCertificates()
        {
            try
            {
                if (importedPartnersWithCertificates != null)
                {
                    foreach (var partner in importedPartnersWithCertificates)
                    {
                        try
                        {
                            await c1Migrator.ExportToIA(partner, this.ApplicationContext.GetService <IntegrationAccountDetails>());
                        }
                        catch (Exception ex)
                        {
                            partner.CertificateExportStatus     = MigrationStatus.Failed;
                            partner.CertificateExportStatusText = string.Format("An exception occured:{0}", ex.Message);
                            TraceProvider.WriteLine(string.Format("An exception occured:{0}", ex.Message));
                        }
                        finally
                        {
                            ExportedItems.Where(item => item.ArtifactName == partner.MigrationEntity.CertificateName).First().ExportStatus     = partner.CertificateExportStatus;
                            ExportedItems.Where(item => item.ArtifactName == partner.MigrationEntity.CertificateName).First().ExportStatusText = partner.CertificateExportStatusText;
                            countArtifactsMigrated++;
                            UpdateProgress();
                        }
                    }
                }
            }

            catch (Exception ex)
            {
                StatusBarViewModel.StatusInfoType = StatusInfoType.Error;
                StatusBarViewModel.ShowError("Error was encountered. Reason: " + ex.Message);
                TraceProvider.WriteLine("Error was encountered. Reason: " + ex.InnerException.StackTrace);
            }
            try
            {
                if (otherExtractedCerts != null)
                {
                    foreach (var cert in otherExtractedCerts)
                    {
                        try
                        {
                            await c2Migrator.ExportToIA(cert, this.ApplicationContext.GetService <IntegrationAccountDetails>());
                        }
                        catch (Exception ex)
                        {
                            cert.ExportStatus     = MigrationStatus.Failed;
                            cert.ExportStatusText = string.Format("An exception occured:{0}", ex.Message);
                            TraceProvider.WriteLine(string.Format("An exception occured:{0}", ex.Message));
                        }
                        finally
                        {
                            ExportedItems.Where(item => item.ArtifactName == cert.certificateName).First().ExportStatus     = cert.ExportStatus;
                            ExportedItems.Where(item => item.ArtifactName == cert.certificateName).First().ExportStatusText = cert.ExportStatusText;
                            countArtifactsMigrated++;
                            UpdateProgress();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                StatusBarViewModel.StatusInfoType = StatusInfoType.Error;
                StatusBarViewModel.ShowError("Error was encountered. Reason: " + ex.Message);
                TraceProvider.WriteLine("Error was encountered. Reason: " + ex.InnerException.StackTrace);
            }
            if (ExportedItems != null)
            {
                foreach (var item in ExportedItems)
                {
                    if (item.ExportStatus == MigrationStatus.Failed)
                    {
                        StatusBarViewModel.StatusInfoType = StatusInfoType.Error;
                        StatusBarViewModel.ShowError("Error(s) were encountered. Please refer the Status Tool Tip / Log File for more details.");
                        break;
                    }
                }
            }
        }
Ejemplo n.º 4
0
        private async Task ExportAgreements()
        {
            try
            {
                AuthenticationResult        authresult  = this.ApplicationContext.GetProperty("IntegrationAccountAuthorization") as AuthenticationResult;
                Dictionary <string, string> schemasInIA = await AgreementMigrator.GetAllSchemasInIA(this.ApplicationContext.GetService <IntegrationAccountDetails>(), authresult);

                Dictionary <KeyValuePair <string, string>, string> partnerIdentitiesInIA = await AgreementMigrator.GetAllPartnerIdentitiesInIA(this.ApplicationContext.GetService <IntegrationAccountDetails>(), authresult);

                this.ApplicationContext.SetProperty("SchemasInIntegrationAccount", schemasInIA);
                this.ApplicationContext.SetProperty("PartnerIdentitiesInIntegrationAccount", partnerIdentitiesInIA);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Following error occured : " + ExceptionHelper.GetExceptionMessage(ex));
                TraceProvider.WriteLine("Following error occured : " + ExceptionHelper.GetExceptionMessage(ex));
            }
            try
            {
                if (importedAgreements != null)
                {
                    foreach (var agreement in importedAgreements)
                    {
                        try
                        {
                            await aMigrator.ExportToIA(agreement, this.ApplicationContext.GetService <IntegrationAccountDetails>());
                        }
                        catch (Exception ex)
                        {
                            agreement.ExportStatus     = MigrationStatus.Failed;
                            agreement.ExportStatusText = ex.Message;
                            TraceProvider.WriteLine(string.Format("An exception occured:{0}", ex.Message));
                            TraceProvider.WriteLine();
                        }
                        finally
                        {
                            ExportedItems.Where(item => item.ArtifactName == agreement.Name).First().ExportStatus     = agreement.ExportStatus;
                            ExportedItems.Where(item => item.ArtifactName == agreement.Name).First().ExportStatusText = agreement.ExportStatusText;
                            countArtifactsMigrated++;
                            UpdateProgress();
                        }
                    }

                    foreach (var item in importedAgreements)
                    {
                        if (item.ExportStatus == MigrationStatus.Failed)
                        {
                            StatusBarViewModel.StatusInfoType = StatusInfoType.Error;
                            StatusBarViewModel.ShowError("Error(s) were encountered. Please refer the Status Tool Tip / Log File for more details.");
                            break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                StatusBarViewModel.StatusInfoType = StatusInfoType.Error;
                StatusBarViewModel.ShowError("Error was encountered. Reason: " + ex.Message);
                TraceProvider.WriteLine("Error was encountered. Reason: " + ex.InnerException.StackTrace);
            }
        }
Ejemplo n.º 5
0
        private void InitializeSummaryText()
        {
            StringBuilder summaryBuilder = new StringBuilder();

            var appException = this.ApplicationContext.ApplicationException;

            if (appException != null)
            {
                summaryBuilder.Append(Resources.ErrorSummaryMessage);
                summaryBuilder.Append(' ');
                summaryBuilder.Append(GetErrorMessage(appException));
                summaryBuilder.Append(Environment.NewLine);
            }

            var selectedPartners   = this.ApplicationContext.GetProperty(AppConstants.SelectedPartnersContextPropertyName) as IEnumerable <PartnerMigrationItemViewModel>;
            var selectedAgreements = this.ApplicationContext.GetProperty(AppConstants.SelectedAgreementsContextPropertyName) as IEnumerable <AgreementMigrationItemViewModel>;
            var selectedSchemas    = this.ApplicationContext.GetProperty(AppConstants.SelectedSchemasContextPropertyName) as IEnumerable <SchemaMigrationItemViewModel>;
            var selectedMaps       = this.ApplicationContext.GetProperty(AppConstants.SelectedMapsContextPropertyName) as IEnumerable <MapMigrationItemViewModel>;
            var otherCerts         = this.ApplicationContext.GetProperty("OtherCertificates") as List <Certificate>;

            #region ImportStatus
            summaryBuilder.Append(Resources.ExportToJsonSummaryTitle);
            summaryBuilder.Append(Environment.NewLine);
            if (selectedPartners != null)
            {
                summaryBuilder.AppendLine("Certificate(s) :");
                var totalPartnerCertificates = selectedPartners.Count(item => item.CertificationRequired == true);
                var totalOtherCerts          = otherCerts != null?otherCerts.Count() : 0;

                var failedPartnerCertificateImports = selectedPartners.Count(item => item.CertificateImportStatus == MigrationStatus.Failed && item.CertificationRequired == true);
                var failedOtherCertificateImports   = otherCerts != null?otherCerts.Count(item => item.ImportStatus == MigrationStatus.Failed) : 0;

                int totalcerts             = totalPartnerCertificates + totalOtherCerts;
                int totalFailedCertImports = failedPartnerCertificateImports + failedOtherCertificateImports;
                if (totalcerts > 0)
                {
                    summaryBuilder.Append(string.Format(
                                              CultureInfo.InvariantCulture,
                                              Resources.CertificateImportSummaryFormat,
                                              totalcerts - totalFailedCertImports,
                                              totalcerts));
                    summaryBuilder.Append(Environment.NewLine);

                    if (failedPartnerCertificateImports > 0)
                    {
                        summaryBuilder.Append(string.Format(Resources.MigrationErrorSummaryMessageForCert, Resources.ExportToJsonText));
                        summaryBuilder.Append(Environment.NewLine);
                    }
                }
                else
                {
                    summaryBuilder.Append(Resources.NoCertificatesRequiredSummary);
                    summaryBuilder.Append(Environment.NewLine);
                }
                summaryBuilder.AppendLine("Partner(s) :");
                if (selectedPartners.Count() != 0)
                {
                    var numSelectedPartners     = selectedPartners.Count();
                    var numFailedPartnerImports = selectedPartners.Count(p => p.ImportStatus == MigrationStatus.Failed);
                    summaryBuilder.Append(string.Format(
                                              CultureInfo.InvariantCulture,
                                              Resources.PartnerImportSummaryFormat,
                                              numSelectedPartners - numFailedPartnerImports,
                                              numSelectedPartners));
                    summaryBuilder.Append(Environment.NewLine);
                    if (failedPartnerCertificateImports > 0)
                    {
                        summaryBuilder.Append(string.Format(Resources.MigrationErrorSummaryMessageForCert, Resources.ExportToJsonText));
                        summaryBuilder.Append(Environment.NewLine);
                    }
                }
                else
                {
                    summaryBuilder.Append("No Partners were selected");
                    summaryBuilder.Append(Environment.NewLine);
                }
            }


            if (selectedAgreements != null)
            {
                summaryBuilder.AppendLine("Agreement(s):");
                if (selectedAgreements.Count() != 0)
                {
                    var numSelectedAgreements     = selectedAgreements.Count();
                    var numFailedAgreementImports = selectedAgreements.Count(agr => agr.ImportStatus == MigrationStatus.Failed);
                    summaryBuilder.Append(string.Format(
                                              CultureInfo.InvariantCulture,
                                              Resources.AgreementImportSummaryFormat,
                                              numSelectedAgreements - numFailedAgreementImports,
                                              numSelectedAgreements));
                    summaryBuilder.Append(Environment.NewLine);
                    if (numFailedAgreementImports > 0)
                    {
                        summaryBuilder.Append(string.Format(Resources.MigrationErrorSummaryMessageForAgreement, Resources.ExportToJsonText));
                        summaryBuilder.Append(Environment.NewLine);
                    }
                }
                else
                {
                    summaryBuilder.Append("No Agreements were selected");
                    summaryBuilder.Append(Environment.NewLine);
                }
            }

            if (selectedSchemas != null)
            {
                summaryBuilder.AppendLine("Schema(s):");
                if (selectedSchemas.Count() != 0)
                {
                    var numSelectedSchemas      = selectedSchemas.Count();
                    var numFailedSchemasImports = selectedSchemas.Count(agr => agr.ImportStatus == MigrationStatus.Failed);
                    summaryBuilder.Append(string.Format(
                                              CultureInfo.InvariantCulture,
                                              Resources.SchemaImportSummaryFormat,
                                              numSelectedSchemas - numFailedSchemasImports,
                                              numSelectedSchemas));
                    summaryBuilder.Append(Environment.NewLine);
                    if (numFailedSchemasImports > 0)
                    {
                        summaryBuilder.Append(string.Format(Resources.MigrationErrorSummaryMessageForSchema, "preparing definitions"));
                        summaryBuilder.Append(Environment.NewLine);
                    }
                }
                else
                {
                    summaryBuilder.Append("No Schemas were selected");
                    summaryBuilder.Append(Environment.NewLine);
                }
            }

            if (selectedMaps != null)
            {
                summaryBuilder.AppendLine("Map(s):");
                if (selectedMaps.Count() != 0)
                {
                    var numSelectedMaps      = selectedMaps.Count();
                    var numFailedMapsImports = selectedMaps.Count(agr => agr.ImportStatus == MigrationStatus.Failed);
                    summaryBuilder.Append(string.Format(
                                              CultureInfo.InvariantCulture,
                                              Resources.MapImportSummaryFormat,
                                              numSelectedMaps - numFailedMapsImports,
                                              numSelectedMaps));
                    summaryBuilder.Append(Environment.NewLine);
                    if (numFailedMapsImports > 0)
                    {
                        summaryBuilder.Append(string.Format(Resources.MigrationErrorSummaryMessageForSchema, "preparing definitions"));
                        summaryBuilder.Append(Environment.NewLine);
                    }
                }
                else
                {
                    summaryBuilder.Append("No Maps were selected");
                    summaryBuilder.Append(Environment.NewLine);
                }
            }
            #endregion

            summaryBuilder.Append(Environment.NewLine);
            summaryBuilder.Append(Environment.NewLine);

            #region ExportStatus
            summaryBuilder.Append(Resources.MigrateToIASumaryTitle);
            summaryBuilder.Append(Environment.NewLine);

            bool exportedSchemas    = Convert.ToBoolean(this.ApplicationContext.GetProperty("ExportSchemas"));
            bool exportedMaps       = Convert.ToBoolean(this.ApplicationContext.GetProperty("ExportMaps"));
            bool exportedCerts      = Convert.ToBoolean(this.ApplicationContext.GetProperty("ExportCertificates"));
            bool exportedPartners   = Convert.ToBoolean(this.ApplicationContext.GetProperty("ExportPartners"));
            bool exportedAgreements = Convert.ToBoolean(this.ApplicationContext.GetProperty("ExportAgreements"));
            bool overwrite          = Convert.ToBoolean(this.ApplicationContext.GetProperty("OverwriteEnabled"));

            if (selectedSchemas != null)
            {
                summaryBuilder.AppendLine("Schema(s):");
                if (selectedSchemas.Count() != 0)
                {
                    var numSelectedSchemas      = selectedSchemas.Count();
                    var numFailedSchemaExports  = selectedSchemas.Count(p => p.ExportStatus != MigrationStatus.Succeeded && p.ExportStatus != MigrationStatus.Partial);
                    var numFailedSchemasImports = selectedSchemas.Count(agr => agr.ImportStatus == MigrationStatus.Failed);
                    if (exportedSchemas)
                    {
                        if (numFailedSchemasImports > 0)
                        {
                            summaryBuilder.Append(string.Format(Resources.UnSuccesfullImport, numFailedSchemasImports, numSelectedSchemas, "Schema(s)"));
                            summaryBuilder.Append(Environment.NewLine);
                        }
                        int schemasAlreadyInIA = selectedSchemas.Count(item => item.ExportStatusText != null && item.ExportStatusText.Contains("already exists in IA"));
                        if (!overwrite && schemasAlreadyInIA != 0)
                        {
                            summaryBuilder.Append(string.Format(Resources.NoOverWriteArtfact, schemasAlreadyInIA, numSelectedSchemas, "Schema(s)"));
                            summaryBuilder.Append(Environment.NewLine);
                        }
                        if (numFailedSchemasImports == 0 && numFailedSchemaExports > 0)
                        {
                            summaryBuilder.Append(string.Format(Resources.UnSuccesfullExport, numFailedSchemaExports, numSelectedSchemas, "Schema(s)"));
                            summaryBuilder.Append(Environment.NewLine);
                        }
                        summaryBuilder.Append(string.Format(
                                                  CultureInfo.InvariantCulture,
                                                  Resources.SchemaExportSummaryFormat,
                                                  numSelectedSchemas - (numFailedSchemaExports + schemasAlreadyInIA),
                                                  numSelectedSchemas));
                        summaryBuilder.Append(Environment.NewLine);
                    }
                    else
                    {
                        summaryBuilder.Append("Schema(s) migration was not selected");
                        summaryBuilder.Append(Environment.NewLine);
                    }
                }
                else
                {
                    summaryBuilder.Append("No Schemas to migrate");
                    summaryBuilder.Append(Environment.NewLine);
                }
            }

            if (selectedMaps != null)
            {
                summaryBuilder.AppendLine("Map(s):");
                if (selectedMaps.Count() != 0)
                {
                    var numSelectedMaps      = selectedMaps.Count();
                    var numFailedMapExports  = selectedMaps.Count(p => p.ExportStatus != MigrationStatus.Succeeded && p.ExportStatus != MigrationStatus.Partial);
                    var numFailedMapsImports = selectedMaps.Count(agr => agr.ImportStatus == MigrationStatus.Failed);
                    if (exportedMaps)
                    {
                        if (numFailedMapsImports > 0)
                        {
                            summaryBuilder.Append(string.Format(Resources.UnSuccesfullImport, numFailedMapsImports, numSelectedMaps, "Map(s)"));
                            summaryBuilder.Append(Environment.NewLine);
                        }
                        int mapsAlreadyInIA = selectedMaps.Count(item => item.ExportStatusText != null && item.ExportStatusText.Contains("already exists in IA"));
                        if (!overwrite && mapsAlreadyInIA != 0)
                        {
                            summaryBuilder.Append(string.Format(Resources.NoOverWriteArtfact, mapsAlreadyInIA, numSelectedMaps, "Map(s)"));
                            summaryBuilder.Append(Environment.NewLine);
                        }
                        if (numFailedMapsImports == 0 && numFailedMapExports > 0)
                        {
                            summaryBuilder.Append(string.Format(Resources.UnSuccesfullExport, numFailedMapExports, numSelectedMaps, "Map(s)"));
                            summaryBuilder.Append(Environment.NewLine);
                        }
                        summaryBuilder.Append(string.Format(
                                                  CultureInfo.InvariantCulture,
                                                  Resources.MapExportSummaryFormat,
                                                  numSelectedMaps - (numFailedMapExports + mapsAlreadyInIA),
                                                  numSelectedMaps));
                        summaryBuilder.Append(Environment.NewLine);
                    }
                    else
                    {
                        summaryBuilder.Append("Map(s) migration was not selected");
                        summaryBuilder.Append(Environment.NewLine);
                    }
                }
                else
                {
                    summaryBuilder.Append("No Maps to migrate");
                    summaryBuilder.Append(Environment.NewLine);
                }
            }

            if (selectedPartners != null)
            {
                summaryBuilder.AppendLine("Certificate(s):");
                var totalPartnerCertificates = selectedPartners.Count(item => item.CertificationRequired == true);
                var totalOtherCerts          = otherCerts != null?otherCerts.Count() : 0;

                var failedPartnerCertificateExports = selectedPartners.Count(item => item.CertificateExportStatus != MigrationStatus.Succeeded && item.CertificateExportStatus != MigrationStatus.Partial && item.CertificationRequired == true);
                var failedOtherCertificateExports   = otherCerts != null?otherCerts.Count(item => item.ExportStatus != MigrationStatus.Succeeded && item.ExportStatus != MigrationStatus.Partial) : 0;

                var failedOtherCertificateImports = otherCerts != null?otherCerts.Count(item => item.ImportStatus == MigrationStatus.Failed) : 0;

                var failedPartnerCertificateImports = selectedPartners.Count(item => item.CertificateImportStatus == MigrationStatus.Failed && item.CertificationRequired == true);
                int totalCerts             = totalPartnerCertificates + totalOtherCerts;
                int totalFailedCertImports = failedOtherCertificateImports + failedPartnerCertificateImports;
                int totalFailedCertExports = failedOtherCertificateExports + failedPartnerCertificateExports;
                if (totalCerts > 0)
                {
                    if (totalFailedCertImports != totalCerts)
                    {
                        if (exportedCerts)
                        {
                            if (totalFailedCertImports > 0)
                            {
                                summaryBuilder.Append(string.Format(Resources.UnSuccesfullImport, totalFailedCertImports, totalCerts, "Certificate(s)"));
                                summaryBuilder.Append(Environment.NewLine);
                            }
                            int partnercertsAlreadyInIA = selectedPartners.Count(item => item.CertificateExportStatusText != null && item.CertificateExportStatusText.Contains("already exists on IA"));
                            int otherCertsAlreadyInIA   = otherCerts != null?otherCerts.Count(item => item.ExportStatusText != null && item.ExportStatusText.Contains("already exists on IA")) : 0;

                            int certsAlreadyInIA = partnercertsAlreadyInIA + otherCertsAlreadyInIA;
                            if (!overwrite && certsAlreadyInIA != 0)
                            {
                                summaryBuilder.Append(string.Format(Resources.NoOverWriteArtfact, certsAlreadyInIA, totalCerts, "Certificate(s)"));
                                summaryBuilder.Append(Environment.NewLine);
                            }
                            if (failedPartnerCertificateImports == 0 && failedPartnerCertificateExports > 0)
                            {
                                summaryBuilder.Append(string.Format(Resources.UnSuccesfullExport, totalFailedCertExports, totalCerts, "Certificate(s)"));
                                summaryBuilder.Append(Environment.NewLine);
                            }
                            summaryBuilder.Append(string.Format(
                                                      CultureInfo.InvariantCulture,
                                                      Resources.CertificateExportSummaryFormat,
                                                      totalCerts - (totalFailedCertExports + certsAlreadyInIA),
                                                      totalCerts));
                            summaryBuilder.Append(Environment.NewLine);
                        }
                        else
                        {
                            summaryBuilder.Append("Certificate(s) migration was not selected");
                            summaryBuilder.Append(Environment.NewLine);
                        }
                    }
                    else
                    {
                        summaryBuilder.Append("No Certifiacte(s) to migrate");
                        summaryBuilder.Append(Environment.NewLine);
                    }
                }
                else
                {
                    summaryBuilder.Append(Resources.NoCertificatesRequiredSummary);
                    summaryBuilder.Append(Environment.NewLine);
                }

                summaryBuilder.AppendLine("Partner(s):");
                if (selectedPartners.Count() != 0)
                {
                    var numSelectedPartners     = selectedPartners.Count();
                    var numFailedPartnerExports = selectedPartners.Count(p => p.ExportStatus != MigrationStatus.Succeeded && p.ExportStatus != MigrationStatus.Partial);
                    var numFailedPartnerImports = selectedPartners.Count(p => p.ImportStatus == MigrationStatus.Failed);
                    if (exportedPartners)
                    {
                        if (numFailedPartnerImports > 0)
                        {
                            summaryBuilder.Append(string.Format(Resources.UnSuccesfullImport, numFailedPartnerImports, numSelectedPartners, "Partner(s)"));
                            summaryBuilder.Append(Environment.NewLine);
                        }
                        int partnersAlreadyInIA = selectedPartners.Count(item => item.ExportStatusText != null && item.ExportStatusText.Contains("already exists on IA"));
                        if (!overwrite && partnersAlreadyInIA != 0)
                        {
                            summaryBuilder.Append(string.Format(Resources.NoOverWriteArtfact, partnersAlreadyInIA, numSelectedPartners, "Partner(s)"));
                            summaryBuilder.Append(Environment.NewLine);
                        }
                        if (numFailedPartnerImports == 0 && numFailedPartnerExports > 0)
                        {
                            summaryBuilder.Append(string.Format(Resources.UnSuccesfullExport, numFailedPartnerExports, numSelectedPartners, "Partner(s)"));
                            summaryBuilder.Append(Environment.NewLine);
                        }
                        summaryBuilder.Append(string.Format(
                                                  CultureInfo.InvariantCulture,
                                                  Resources.PartnerExportSummaryFormat,
                                                  numSelectedPartners - (numFailedPartnerExports + partnersAlreadyInIA),
                                                  numSelectedPartners));
                        summaryBuilder.Append(Environment.NewLine);
                    }
                    else
                    {
                        summaryBuilder.Append("Partner(s) migration was not selected");
                        summaryBuilder.Append(Environment.NewLine);
                    }
                }
                else
                {
                    summaryBuilder.Append("No Partner(s) to Migrate");
                    summaryBuilder.Append(Environment.NewLine);
                }
            }


            if (selectedAgreements != null)
            {
                summaryBuilder.AppendLine("Agreement(s):");
                if (selectedAgreements.Count() != 0)
                {
                    var numSelectedAgreements     = selectedAgreements.Count();
                    var numFailedAgreementExports = selectedAgreements.Count(agr => agr.ExportStatus != MigrationStatus.Succeeded && agr.ExportStatus != MigrationStatus.Partial);
                    var numFailedAgreementImports = selectedAgreements.Count(agr => agr.ImportStatus == MigrationStatus.Failed);
                    if (exportedAgreements)
                    {
                        if (numFailedAgreementImports > 0)
                        {
                            summaryBuilder.Append(string.Format(Resources.UnSuccesfullImport, numFailedAgreementImports, numSelectedAgreements, "Agreement(s)"));
                            summaryBuilder.Append(Environment.NewLine);
                        }
                        int agreementsAlreadyInIA = selectedAgreements.Count(item => item.ExportStatusText != null && item.ExportStatusText.Contains("already exists on IA"));
                        if (!overwrite && agreementsAlreadyInIA != 0)
                        {
                            summaryBuilder.Append(string.Format(Resources.NoOverWriteArtfact, agreementsAlreadyInIA, numSelectedAgreements, "Agreement(s)"));
                            summaryBuilder.Append(Environment.NewLine);
                        }
                        if (numFailedAgreementImports == 0 && numFailedAgreementExports > 0)
                        {
                            summaryBuilder.Append(string.Format(Resources.UnSuccesfullExport, numFailedAgreementExports, numSelectedAgreements, "Agreement(s)"));
                            summaryBuilder.Append(Environment.NewLine);
                        }
                        summaryBuilder.Append(string.Format(
                                                  CultureInfo.InvariantCulture,
                                                  Resources.AgreementExportSummaryFormat,
                                                  numSelectedAgreements - (numFailedAgreementExports + agreementsAlreadyInIA),
                                                  numSelectedAgreements));
                    }
                    else
                    {
                        summaryBuilder.Append("Agreement(s) migration was not selected");
                        summaryBuilder.Append(Environment.NewLine);
                    }
                }
                else
                {
                    summaryBuilder.Append("No Agreement(s) to Migrate");
                    summaryBuilder.Append(Environment.NewLine);
                }
            }
            #endregion

            if (appException == null && selectedPartners == null && selectedAgreements == null && selectedSchemas == null)
            {
                summaryBuilder.Append(Resources.NoAgreementsOrPartnersSelectedErrorMessage);
            }

            this.SummaryText = summaryBuilder.ToString();
            TraceProvider.WriteLine(this.SummaryText, true);
        }