Exemple #1
0
        public void RegisterPlugin()
        {
            var crmConnectionString = ConfigurationManager.ConnectionStrings["CrmOrganisationService"];
            var deployer            = DeploymentBuilder.CreateDeployment()
                                      .ForTheAssemblyContainingThisPlugin <TestPlugin>("Test plugin assembly")
                                      .RunsInSandboxMode()
                                      .RegisterInDatabase()
                                      .HasPlugin <TestPlugin>()
                                      .WhichExecutesOn(SdkMessageNames.Create, "contact")
                                      .Synchronously()
                                      .PostOperation()
                                      .OnlyOnCrmServer()
                                      .AndExecutesOn(SdkMessageNames.Update, "contact")
                                      .Synchronously()
                                      .PostOperation()
                                      .OnCrmServerAndOffline()
                                      .DeployTo(crmConnectionString.ConnectionString);

            RegistrationInfo = deployer.Deploy();
            if (!RegistrationInfo.Success)
            {
                var reason = RegistrationInfo.Error.Message;
                Assert.Fail("Registration failed because: {0}.", reason);
                // registrationInfo.Undeploy();
                // Console.WriteLine("Deployment was rolled back..");
            }

            //.AndExecutesOn(SdkMessageNames.Delete, "contact")
            //                                       .Synchronously()
            //                                       .PostOperation()
            //                                       .OnlyOffline()
        }
        private void RegisterSyncPlugin()
        {
            var orgConnectionString = this._CrmOrgConnectionString;
            var deployer            = DeploymentBuilder.CreateDeployment()
                                      .ForTheAssemblyContainingThisPlugin <CrmSyncChangeTrackerPlugin>("Test plugin assembly")
                                      .RunsInSandboxMode()
                                      .RegisterInDatabase()
                                      .HasPlugin <CrmSyncChangeTrackerPlugin>()
                                      .WhichExecutesOn(SdkMessageNames.Create, TestDynamicsCrmServerSyncProvider.TestEntityName)
                                      .Synchronously()
                                      .PostOperation()
                                      .OnlyOnCrmServer()
                                      .DeployTo(orgConnectionString);

            PluginRegistrationInfo = deployer.Deploy();
            if (!PluginRegistrationInfo.Success)
            {
                Console.WriteLine("Plugin registration failed.. rolling back..");
                try
                {
                    PluginRegistrationInfo.Undeploy();
                }
                catch (Exception e)
                {
                    Console.WriteLine("Rollback failed. " + e.Message);
                }
                Assert.Fail("Could not register plugin.");
            }
        }
Exemple #3
0
        public void Can_Register_Crm_Plugin()
        {
            var serviceProvider = new CrmServiceProvider(new ExplicitConnectionStringProviderWithFallbackToConfig(), new CrmClientCredentialsProvider());
            //PluginAssembly, PluginType, SdkMessageProcessingStep, and SdkMessageProcessingStepImage.

            var crmOrgConnectionString = ConfigurationManager.ConnectionStrings["CrmOrganisation"];

            var deployer = DeploymentBuilder.CreateDeployment()
                           .ForTheAssemblyContainingThisPlugin <CrmSyncChangeTrackerPlugin>("Test plugin assembly")
                           .RunsInSandboxMode()
                           .RegisterInDatabase()
                           .HasPlugin <CrmSyncChangeTrackerPlugin>()
                           .WhichExecutesOn(SdkMessageNames.Create, "contact")
                           .Synchronously()
                           .PostOperation()
                           .OnlyOnCrmServer()
                           .DeployTo(crmOrgConnectionString.ConnectionString);

            RegistrationInfo = deployer.Deploy();
            if (!RegistrationInfo.Success)
            {
                Assert.Fail("Registration failed..");
                //deployer.Undeploy(updateInfo);
                //Console.WriteLine("Registration was rolled back..");
            }
        }