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);
        }
        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;
            }
        }
Exemple #3
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);
        }