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