예제 #1
0
        private void _ok_Click(object sender, EventArgs e)
        {
            if(string.IsNullOrEmpty(_destinationName.Text)) {
                MessageBox.Show(this, "Please enter a destination name.", "Destination name missing", MessageBoxButtons.OK, MessageBoxIcon.Information);
                _destinationName.Focus();
                return;
            }
            else if (_project.ActiveDeployConfig.Destinations.Contains(_destinationName.Text)) {
                MessageBox.Show(this, "The destination name is already in use. Please enter a different name.", "Destination name exists", MessageBoxButtons.OK, MessageBoxIcon.Information);
                _destinationName.Focus();
                return;
            }

            DeployDestination dest = new DeployDestination(_destinationName.Text, _destinationName.Text);
            PluginDescriptor plugin = (PluginDescriptor)_plugin.SelectedItem;
            dest.PluginSettings = new PluginSettings(plugin);
            _project.ActiveDeployConfig.Destinations.Add(dest);

            this.DialogResult = DialogResult.OK;
        }
예제 #2
0
        private void NewProjectWizard_Load(object sender, EventArgs e)
        {
            _wizard.NextEnabled = false;

            // Add an empty destination
            string id = _project.ActiveDeployConfig.Destinations.GetNextIdentifier();
            DeployDestination dest = new DeployDestination(id);
            _project.ActiveDeployConfig.Destinations.Add(dest);

            // Get only plugins that can be used to deploy
            var pluginDescriptors = new List<PluginDescriptor>(PluginManager.GetPluginDescriptors(x => x.SupportsFileDeploy));

            // Default to use the first available plugin
            if(pluginDescriptors.Count > 0)
                dest.ChangePlugin(pluginDescriptors[0]);

            // Populate plugin list
            _plugin.ValueMember = "PluginTypeFullName";
            _plugin.DisplayMember = "PluginName";
            _plugin.DataSource = pluginDescriptors;

            _filtersView.Project = _project;
        }
예제 #3
0
        /// <summary>
        /// Checks if the project file needs to be migrated.
        /// This is performed automatically while loading a project.
        /// </summary>
        private void MigrateProject()
        {
            if (_fileFormatVersion >= CurrentFileFormatVersion)
                return;

            bool migrated = false;

            // Verify and migrate plugins
            if(_pluginsettings != null && _pluginsettings.Count > 0) {
                // Ensure there is a default config
                if (_deployconfigs.Count == 0) {
                    _deployconfigs.Add(new DeployConfig(DefaultConfigName));
                }

                // Update and move plugins to the correct destination
                DeployConfig config = _deployconfigs[0];
                foreach(PluginSettings pluginsettings in _pluginsettings) {
                    PluginDescriptor descriptor = PluginManager.GetPluginDescriptorForIdentifier(pluginsettings.Identifier);
                    pluginsettings.Type = descriptor.PluginTypeFullName;

                    DeployDestination destination = new DeployDestination(pluginsettings.Identifier, pluginsettings.Identifier);
                    pluginsettings.Identifier = null;

                    destination.PluginSettings = pluginsettings;
                    config.Destinations.Add(destination);
                }
                _pluginsettings = null;
                migrated = true;
            }

            // Migrate plugin types automatically
            if (_fileFormatVersion < 2) {
                foreach (DeployConfig deployconfig in _deployconfigs) {
                    foreach (DeployDestination destination in deployconfig.Destinations) {
                        // Ensure that the plugin type is ok
                        PluginSettings settings = destination.PluginSettings;
                        switch (settings.Type) {
                            case "DeployerPlugins.Wcm.WcmDeployer":
                                settings.Type = "Stendahls.DeployerPlugins.Wcm.WcmDeployer";
                                migrated = true;
                                break;
                            case "DeployerPlugins.GwsDeployer":
                                settings.Type = "Stendahls.DeployerPlugins.Gws.GwsDeployer";
                                migrated = true;
                                break;
                        }
                    }
                }
                migrated = true;
            }

            // Move database settings
            if (_databasesettings != null) {
                // Ensure there is a default config
                if (_deployconfigs.Count == 0) {
                    _deployconfigs.Add(new DeployConfig(DefaultConfigName));
                }

                DeployConfig config = _deployconfigs[0];
                config.DatabaseSettings = _databasesettings;
                _databasesettings = null;

                migrated = true;
            }

            // Verify and migrate filters
            if (_filters != null) {
                // Ensure there is a default config
                if (_deployconfigs.Count == 0) {
                    _deployconfigs.Add(new DeployConfig(DefaultConfigName));
                }

                // Upgrade filters and move them to default target
                DeployConfig config = _deployconfigs[0];
                //_filters.ExcludeDirectories.Migrate(config);
                //_filters.ExcludeFiles.Migrate(config);
                //_filters.ExcludeProcedures.Migrate(config);
                //_filters.IncludeFiles.Migrate(config);
                config.FilterSettings.Add(_filters);

                // Move database filter
                if (_filters.ExcludeProcedures != null) {
                    config.DatabaseSettings.ExcludeProcedures = _filters.ExcludeProcedures;
                    _filters.ExcludeProcedures = null;
                }

                // Move use project flag, and clear it from the old place
                if(!string.IsNullOrEmpty(_filters.UseProjectFilter)) {
                    bool useProjectFilter;
                    if (bool.TryParse(_filters.UseProjectFilter, out useProjectFilter))
                        config.UseProjectFilter = useProjectFilter;
                    _filters.UseProjectFilter = null;
                }

                _filters = null;
                migrated = true;
            }

            if (migrated) {
                _fileFormatVersion = CurrentFileFormatVersion;

                // Project has been upgraded
                EventManager.OnNotificationMessage("Project has been successfully migrated to the new file format.");
            }
        }
예제 #4
0
        /// <summary>
        /// Loads a plugin for the specified deploy destination.
        /// </summary>
        private static IDeployerPlugin LoadPlugin(DeployDestination destination)
        {
            string pluginType = destination.PluginSettings.Type;
            //if(string.IsNullOrEmpty(pluginType)) {
            //    // Plugin type not found. Look up plugin type using the identifier instead
            //    // TODO: Remove this when no old deploy files remain
            //    PluginDescriptor descriptor = GetPluginDescriptorForIdentifier(destination.PluginSettings.Identifier);
            //    if(descriptor == null) {
            //        throw new FileLoadException(
            //            string.Format("Unable to load plugin for destination '{0}'. Plugin type not found.", destination.Name));
            //    }
            //    pluginType = descriptor.PluginTypeFullName;
            //}

            // Load plugin
            EventManager.OnNotificationMessage(string.Format("Loading plugin for destination '{0}'...", destination.Name));
            return LoadPlugin(destination.Identifier, pluginType, destination.PluginSettings.Settings.OuterXml);
        }
예제 #5
0
 /// <summary>
 /// Unloads the plugin for a specified destination.
 /// </summary>
 public static void UnloadPluginForDestination(DeployDestination destination)
 {
     _plugins.Remove(destination.Identifier);
 }
예제 #6
0
        /// <summary>
        /// Retrieves the plugin for the specified destination. It will be automatically
        /// loaded if required.
        /// </summary>
        public static IDeployerPlugin GetPluginForDestination(DeployDestination destination)
        {
            IDeployerPlugin plugin;
            if (!_plugins.TryGetValue(destination.Identifier, out plugin))
            {
                // We need to load the plugin
                plugin = LoadPlugin(destination);
            }

            return plugin;
        }