/// <summary>
        /// Factory method to create new administration service clients for the deployment service.
        /// Sets the connection string and user credentials from values provided in settings.
        /// HeuristicLab.PluginInfrastructure.Properties.Settings.Default.UpdateLocationUserName
        /// HeuristicLab.PluginInfrastructure.Properties.Settings.Default.UpdateLocationPassword
        /// HeuristicLab.PluginInfrastructure.Properties.Settings.Default.UpdateLocationnAdministrationAddress
        ///
        /// </summary>
        /// <returns>A new instance of an adimistration service client</returns>
        public static AdminServiceClient CreateClient()
        {
            var client = new AdminServiceClient();

            client.ClientCredentials.UserName.UserName = HeuristicLab.PluginInfrastructure.Properties.Settings.Default.UpdateLocationUserName;
            client.ClientCredentials.UserName.Password = HeuristicLab.PluginInfrastructure.Properties.Settings.Default.UpdateLocationPassword;
            client.Endpoint.Address = new EndpointAddress(HeuristicLab.PluginInfrastructure.Properties.Settings.Default.UpdateLocationAdministrationAddress);
            client.ClientCredentials.ServiceCertificate.Authentication.CertificateValidationMode  = System.ServiceModel.Security.X509CertificateValidationMode.Custom;
            client.ClientCredentials.ServiceCertificate.Authentication.CustomCertificateValidator =
                new DeploymentServerCertificateValidator(new X509Certificate2(serverCrtData));

            return(client);
        }
Пример #2
0
        void pluginUploadWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            // upload plugins
            var selectedPlugins = (IEnumerable <IPluginDescription>)e.Argument;

            DeploymentService.AdminServiceClient adminClient = DeploymentService.AdminServiceClientFactory.CreateClient();
            Dictionary <IPluginDescription, DeploymentService.PluginDescription> cachedPluginDescriptions =
                new Dictionary <IPluginDescription, DeploymentService.PluginDescription>();

            try {
                foreach (var plugin in IteratePlugins(selectedPlugins))
                {
                    adminClient.DeployPlugin(MakePluginDescription(plugin, cachedPluginDescriptions), CreateZipPackage(plugin));
                }
                adminClient.Close();
            }
            catch (TimeoutException) {
                adminClient.Abort();
                throw;
            }
            catch (FaultException) {
                adminClient.Abort();
                throw;
            }
            catch (CommunicationException) {
                adminClient.Abort();
                throw;
            }
            // refresh available plugins
            var client = DeploymentService.UpdateServiceClientFactory.CreateClient();

            try {
                e.Result = client.GetPlugins();
                client.Close();
            }
            catch (TimeoutException) {
                client.Abort();
                throw;
            }
            catch (FaultException) {
                client.Abort();
                throw;
            }
            catch (CommunicationException) {
                client.Abort();
                throw;
            }
        }