Example #1
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);
        }
        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;
            }
        }