コード例 #1
0
 public void MigrateBusinessIdentities(Services.TpmContext cloudContext, Server.BusinessProfile serverBusinessProfile, Services.BusinessProfile cloudBusinessProfile)
 {
     foreach (Server.BusinessIdentity businessIdentity in serverBusinessProfile.GetBusinessIdentities())
     {
         this.MigrateBusinessIdentity(cloudContext, (Server.QualifierIdentity)businessIdentity, cloudBusinessProfile);
     }
 }
コード例 #2
0
 public void MigrateBusinessProfiles(Services.TpmContext cloudContext, Server.Partner serverPartner, Services.Partner cloudPartner)
 {
     foreach (Server.BusinessProfile businessProfile in serverPartner.GetBusinessProfiles())
     {
         this.MigrateBusinessProfile(cloudContext, businessProfile, cloudPartner);
     }
 }
コード例 #3
0
        private static Services.TpmContext GetCloudTpmContext(IntegrationServiceDetails integrationServiceDetails)
        {
            var partnerManagementDataServiceUrl =
                new Uri(new Uri(integrationServiceDetails.DeploymentURL), PartnerManagementDataServicePath);

            Services.TpmContext context = new Services.TpmContext(partnerManagementDataServiceUrl);
            context.SaveChangesDefaultOptions = SaveChangesOptions.Batch;
            context.SendingRequest           += (sender, args) => OnSendingRequest(args, AcsHelper.GetAcsToken(integrationServiceDetails));
            return(context);
        }
コード例 #4
0
        public void MigrateProtocolSettings(Services.TpmContext cloudContext, Services.OnewayAgreement cloudOnewayAgreement, Server.ProtocolSettings serverProtocolSettings, Services.BusinessProfile senderProfile, string agreementName, out MigrationStatus migrationStatus)
        {
            this.envelopeOverridesMigrator   = new EnvelopeOverridesMigrator(cloudContext);
            this.validationOverridesMigrator = new ValidationOverridesMigrator(cloudContext);
            Services.ProtocolSettings cloudProtocolSettings;
            switch (serverProtocolSettings.ProtocolName)
            {
            case AppConstants.X12ProtocolName:
                cloudProtocolSettings = CreateX12ProtocolSettings((Server.X12ProtocolSettings)serverProtocolSettings);
                migrationStatus       = MigrationStatus.Succeeded;
                break;

            case AppConstants.AS2ProtocolName:
                cloudProtocolSettings = CreateAS2ProtocolSettings((Server.AS2ProtocolSettings)serverProtocolSettings);
                CleanAs2ProtocolSettings((Services.AS2ProtocolSettings)cloudProtocolSettings, senderProfile);
                this.UpdateStatus(agreementName, out migrationStatus);
                break;

            case AppConstants.EdifactProtocolName:
                cloudProtocolSettings = CreateEdifactProtocolSettings((Server.EDIFACTProtocolSettings)serverProtocolSettings);
                migrationStatus       = MigrationStatus.Succeeded;
                break;

            default:
                throw new NotSupportedException();
            }

            cloudContext.AddToProtocolSettings(cloudProtocolSettings);
            cloudProtocolSettings.OnewayAgreement = cloudOnewayAgreement;
            cloudContext.SetLink(cloudProtocolSettings, "OnewayAgreement", cloudOnewayAgreement);
            cloudOnewayAgreement.ProtocolSettings = cloudProtocolSettings;
            cloudContext.SetLink(cloudOnewayAgreement, "ProtocolSettings", cloudProtocolSettings);

            var serverX12ProtocolSettings = serverProtocolSettings as Server.X12ProtocolSettings;
            var cloudX12ProtocolSettings  = cloudProtocolSettings as Services.X12ProtocolSettings;

            if (serverX12ProtocolSettings != null)
            {
                this.envelopeOverridesMigrator.MigrateAllX12EnvelopeOverrides(serverX12ProtocolSettings, cloudX12ProtocolSettings);
                this.validationOverridesMigrator.MigrateAllX12ValidationOverrides(serverX12ProtocolSettings, cloudX12ProtocolSettings);
            }

            var serverEdifactProtocolSettings = serverProtocolSettings as Server.EDIFACTProtocolSettings;
            var cloudEdifactProtocolSettings  = cloudProtocolSettings as Services.EDIFACTProtocolSettings;

            if (serverEdifactProtocolSettings != null)
            {
                this.envelopeOverridesMigrator.MigrateAllEdifactEnvelopeOverrides(serverEdifactProtocolSettings, cloudEdifactProtocolSettings);
                this.validationOverridesMigrator.MigrateAllEdifactValidationOverrides(serverEdifactProtocolSettings, cloudEdifactProtocolSettings);
            }
        }
コード例 #5
0
        public bool MigrateBusinessIdentity(Services.TpmContext cloudContext, Server.QualifierIdentity serverBusinessIdentity, Services.BusinessProfile cloudBusinessProfile)
        {
            var cloudBusinessIdentity = new Services.QualifierIdentity
            {
                Name      = serverBusinessIdentity.Name,
                Qualifier = serverBusinessIdentity.Qualifier,
                Value     = serverBusinessIdentity.Value,
            };

            cloudContext.AddToBusinessIdentities(cloudBusinessIdentity);
            cloudContext.AddLink(cloudBusinessProfile, "BusinessIdentities", cloudBusinessIdentity);
            cloudContext.SetLink(cloudBusinessIdentity, "BusinessProfile", cloudBusinessProfile);
            return(true);
        }
コード例 #6
0
        public void MigrateOnewayAgreement(
            Services.TpmContext cloudContext,
            Server.OnewayAgreement serverOnewayAgreement,
            Server.QualifierIdentity serverSenderBusinessIdentity,
            Server.QualifierIdentity serverReceiverBusinessIdentity,
            Services.Agreement cloudAgreement,
            string onewayAgreementType,
            out MigrationStatus migrationStatus)
        {
            Services.OnewayAgreement cloudOnewayAgreement = new Services.OnewayAgreement();
            cloudContext.AddToOnewayAgreements(cloudOnewayAgreement);
            cloudContext.RelateEntities(
                cloudOnewayAgreement,
                cloudAgreement,
                onewayAgreementType == "OnewayAgreementAToB" ? "AgreementAsAToB" : "AgreementAsBToA",
                onewayAgreementType,
                Services.RelationshipCardinality.OneToOne);

            this.LinkBusinessProfilesToOnewayAgreement(
                cloudContext,
                cloudOnewayAgreement,
                cloudAgreement.BusinessProfileA,
                cloudAgreement.BusinessProfileB,
                serverSenderBusinessIdentity,
                serverReceiverBusinessIdentity,
                onewayAgreementType);

            // Migrate send and receive protocol settings
            Server.ProtocolSettings serverProtocolSettings;
            switch (cloudAgreement.ProtocolName)
            {
            case AppConstants.X12ProtocolName:
                serverProtocolSettings = serverOnewayAgreement.GetProtocolSettings <Server.X12ProtocolSettings>();
                break;

            case AppConstants.AS2ProtocolName:
                serverProtocolSettings = serverOnewayAgreement.GetProtocolSettings <Server.AS2ProtocolSettings>();
                break;

            case AppConstants.EdifactProtocolName:
                serverProtocolSettings = serverOnewayAgreement.GetProtocolSettings <Server.EDIFACTProtocolSettings>();
                break;

            default:
                throw new NotSupportedException("Migration of  X12, AS2, EDIFACT agreements only is supported");
            }

            this.protocolSettingsMigrator.MigrateProtocolSettings(cloudContext, cloudOnewayAgreement, serverProtocolSettings, onewayAgreementType == "OnewayAgreementAToB" ? cloudAgreement.BusinessProfileA : cloudAgreement.BusinessProfileB, cloudAgreement.Name, out migrationStatus);
        }
コード例 #7
0
        public void MigrateBusinessProfile(Services.TpmContext cloudContext, Server.BusinessProfile serverBusinessProfile, Services.Partner cloudPartner)
        {
            Services.BusinessProfile cloudBusinessProfile = new Services.BusinessProfile()
            {
                Name        = serverBusinessProfile.Name,
                Description = serverBusinessProfile.Description,
                Partner     = cloudPartner
            };
            cloudContext.AddToBusinessProfiles(cloudBusinessProfile);
            cloudContext.RelateEntities(cloudBusinessProfile, cloudPartner, "Partner", "BusinessProfiles", Services.RelationshipCardinality.ManyToOne);

            // Migrating the CustomSettings and business identities
            this.customSettingsMigrator.MigrateProfileCustomSettings(cloudContext, serverBusinessProfile, cloudBusinessProfile);
            this.businessIdentityMigrator.MigrateBusinessIdentities(cloudContext, serverBusinessProfile, cloudBusinessProfile);
        }
コード例 #8
0
        public void MigrateProfileCustomSettings(Services.TpmContext cloudContext, Server.BusinessProfile serverBusinessProfile, Services.BusinessProfile cloudBusinessProfile)
        {
            Dictionary <string, string> dict = new Dictionary <string, string>();

            Server.CustomSettings serverCustomSettings = serverBusinessProfile.GetCustomSettings();
            foreach (string key in serverCustomSettings.Keys)
            {
                dict[key] = serverCustomSettings[key];
            }

            Services.CustomSetting cloudCustomSetting = new Services.CustomSetting()
            {
                Name = cloudBusinessProfile.Name
            };
            cloudCustomSetting.Blob = ByteArrayFormatter <Dictionary <string, string> > .Serialize(dict);

            cloudContext.AddToCustomSettings(cloudCustomSetting);
            cloudContext.RelateEntities(cloudCustomSetting, cloudBusinessProfile, "BusinessProfile", "CustomSettings", Services.RelationshipCardinality.ManyToOne);
        }
コード例 #9
0
        public void MigrateAgreementCustomSettings(Services.TpmContext cloudContext, Server.Agreement serverAgreement, Services.Agreement cloudAgreement)
        {
            Dictionary <string, string> dict = new Dictionary <string, string>();

            Server.CustomSettings serverCustomSettings = serverAgreement.GetCustomSettings();
            foreach (string key in serverCustomSettings.Keys)
            {
                dict[key] = serverCustomSettings[key];
            }

            Services.CustomSetting cloudCustomSetting = new Services.CustomSetting()
            {
                Name = cloudAgreement.Name
            };
            cloudCustomSetting.Blob = ByteArrayFormatter <Dictionary <string, string> > .Serialize(dict);

            cloudContext.AddToCustomSettings(cloudCustomSetting);
            cloudContext.RelateEntities(cloudCustomSetting, cloudAgreement, "Agreement", "CustomSettings", Services.RelationshipCardinality.ManyToOne);
        }
コード例 #10
0
        public void MigrateOnewayAgreements(Services.TpmContext cloudContext, Server.Agreement serverAgreement, string serverAgreementSenderPartnerName, string serverAgreementReceiverPartnername, Services.Agreement cloudAgreement, out MigrationStatus migrationStatus)
        {
            migrationStatus = MigrationStatus.Succeeded;
            Server.OnewayAgreement serverSendOnewayAgreement    = serverAgreement.GetOnewayAgreement(serverAgreementSenderPartnerName, serverAgreementReceiverPartnername);
            Server.OnewayAgreement serverReceiveOnewayAgreement = serverAgreement.GetOnewayAgreement(serverAgreementReceiverPartnername, serverAgreementSenderPartnerName);

            var             serverSenderBusinessIdentity       = serverSendOnewayAgreement.SenderIdentity as Server.QualifierIdentity;
            var             serverReceiverBusinessIdentity     = serverSendOnewayAgreement.ReceiverIdentity as Server.QualifierIdentity;
            MigrationStatus onewayAgreementAToBMigrationStatus = MigrationStatus.Succeeded;

            this.MigrateOnewayAgreement(cloudContext, serverSendOnewayAgreement, serverSenderBusinessIdentity, serverReceiverBusinessIdentity, cloudAgreement, "OnewayAgreementAToB", out onewayAgreementAToBMigrationStatus);
            MigrationStatus onewayAgreementBToAMigrationStatus = MigrationStatus.Succeeded;

            this.MigrateOnewayAgreement(cloudContext, serverReceiveOnewayAgreement, serverReceiverBusinessIdentity, serverSenderBusinessIdentity, cloudAgreement, "OnewayAgreementBToA", out onewayAgreementBToAMigrationStatus);

            if (onewayAgreementAToBMigrationStatus == MigrationStatus.Partial || onewayAgreementBToAMigrationStatus == MigrationStatus.Partial)
            {
                migrationStatus = MigrationStatus.Partial;
            }
        }
コード例 #11
0
        private void LinkBusinessProfilesToOnewayAgreement(
            Services.TpmContext cloudContext,
            Services.OnewayAgreement cloudOnewayAgreement,
            Services.BusinessProfile agreementBusinessProfileA,
            Services.BusinessProfile agreementBusinessProfileB,
            Server.QualifierIdentity serverAgreementProfileAIdentity,
            Server.QualifierIdentity serverAgreementProfileBIdentity,
            string onewayAgreementType)
        {
            Services.BusinessProfile senderProfile, receiverProfile;
            if (onewayAgreementType == "OnewayAgreementAToB")
            {
                senderProfile   = agreementBusinessProfileA;
                receiverProfile = agreementBusinessProfileB;
            }
            else
            {
                senderProfile   = agreementBusinessProfileB;
                receiverProfile = agreementBusinessProfileA;
            }

            Services.BusinessIdentity cloudSenderBusinessIdentity, cloudReceiverBusinessIdentity;
            if (!TryGetCloudBusinessIdentity(senderProfile, serverAgreementProfileAIdentity, out cloudSenderBusinessIdentity) ||
                !TryGetCloudBusinessIdentity(receiverProfile, serverAgreementProfileBIdentity, out cloudReceiverBusinessIdentity))
            {
                throw new TpmMigrationException(string.Format(
                                                    CultureInfo.InvariantCulture,
                                                    "Business identities do not exist: {0}, {1}; {2}, {3}",
                                                    serverAgreementProfileAIdentity.Qualifier,
                                                    serverAgreementProfileAIdentity.Value,
                                                    serverAgreementProfileBIdentity.Qualifier,
                                                    serverAgreementProfileBIdentity.Value));
            }

            cloudContext.RelateEntities(cloudOnewayAgreement, cloudSenderBusinessIdentity, "SenderBusinessIdentity", "OnewayAgreementSender", Services.RelationshipCardinality.ManyToOne);
            cloudContext.RelateEntities(cloudOnewayAgreement, cloudReceiverBusinessIdentity, "ReceiverBusinessIdentity", "OnewayAgreementReceiver", Services.RelationshipCardinality.ManyToOne);
        }
コード例 #12
0
 public EnvelopeOverridesMigrator(Services.TpmContext cloudContext)
 {
     this.cloudContext = cloudContext;
 }
コード例 #13
0
 public ValidationOverridesMigrator(Services.TpmContext cloudContext)
 {
     this.cloudContext = cloudContext;
 }
コード例 #14
0
 // The cloud context is refereshed each time an exception occurs if the entity is not able to migrate, as it tries to save the previous context too in the database.
 public void RefreshContext()
 {
     this.cloudContext = null;
 }