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); }
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 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); }
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); }
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); }