private static bool TryGetCloudBusinessIdentity(
     Services.BusinessProfile cloudBusinessProfile,
     Server.QualifierIdentity serverBusinessIdentity,
     out Services.BusinessIdentity cloudBusinessIdentity)
 {
     TraceProvider.WriteLine("Profile={0}, Identity:({1}, {2})",
                             cloudBusinessProfile.Name,
                             serverBusinessIdentity.Qualifier,
                             serverBusinessIdentity.Value);
     cloudBusinessIdentity = cloudBusinessProfile.BusinessIdentities.SingleOrDefault(id => AreBusinessIdentitiesEquivalent(id, serverBusinessIdentity));
     return(cloudBusinessIdentity != null);
 }
Exemplo n.º 2
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);
        }
        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);
        }
Exemplo n.º 4
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);
     }
 }
Exemplo n.º 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);
        }
        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);
            }
        }
        /*
         * Function verifies if the AS2 message is signed and the required certificate is present in the Sender's profile in Services world.
         * If the certificate is present, it will assign the certificate ID to the Services certificateId field.
         * If the certificate is not present, the migration will still succeed showing a warning message displaying the Agreement name and missing thumbprint.
         */
        private void CleanAs2ProtocolSettings(Services.AS2ProtocolSettings cloudProtocolSettings, Services.BusinessProfile senderProfile)
        {
            if (cloudProtocolSettings.MessageSigned == true && cloudProtocolSettings.SigningCertificateId == null)
            {
                var certificateReference = senderProfile.CertificateReferences.Where(cert => cert.Thumbprint == cloudProtocolSettings.SigningCertificateThumbprint).FirstOrDefault();
                if (certificateReference == null)
                {
                    cloudProtocolSettings.OverrideGroupSigningCertificate = false;
                    cloudProtocolSettings.MessageSigned = false;
                    signingThumbprintMissing            = cloudProtocolSettings.SigningCertificateThumbprint;
                    cloudProtocolSettings.SigningCertificateThumbprint = null;
                }
                else
                {
                    cloudProtocolSettings.SigningCertificateId = certificateReference.Id;
                }
            }

            senderProfileName = senderProfile.Name;
        }
Exemplo n.º 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);
        }