public void DisablePlugin(string pluginId, Version version)
        {
            PluginDto plugin = this.pluginDataService.GetPlugin(pluginId, version);

            if (plugin == null)
            {
                throw new DexterPluginException("Unable to find the specified plugin", pluginId);
            }

            this.pluginDataService.DisablePlugin(plugin);
        }
        public void EnablePlugin(string pluginId, Version version)
        {
            PluginDto plugin = this.pluginDataService.GetPlugin(pluginId, version);

            if (plugin == null)
            {
                throw new DexterException("Unable to find the specified plugin");
            }

            string pluginPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"App_Data\Extensions\Plugins", plugin.Title, @"\Assemblies");

            if (!Directory.Exists(pluginPath))
            {
                throw new DirectoryNotFoundException(string.Format("Unable to find the specified path '{0}'.", pluginPath));
            }

            string[] files = Directory.GetFiles(pluginPath, "*.dll", SearchOption.TopDirectoryOnly);

            if (files.Length < 1)
            {
                this.logger.WarnFormat("Unable to find the assemblies for the plugin '{0}'", plugin.Title);
                return;
            }

            foreach (var file in files)
            {
                var pluginAssemblies = Assembly.LoadFrom(file);

                Type pluginType = pluginAssemblies.GetTypes().FirstOrDefault(t => !t.IsInterface && !t.IsAbstract && typeof(IPlugin).IsAssignableFrom(t));

                if (pluginType == null)
                {
                    logger.DebugFormat("The is not an IPlugin for the assemly '{0}' for the plugin '{1}'.", Path.GetFileName(file), plugin.Title);
                    continue;
                }

                container.Register(pluginType, pluginType, LifeCycle.Singleton);
                var pluginInstance = (IPlugin)DexterContainer.Resolve(pluginType);

                if (!plugin.IsInstalled)
                {
                    logger.DebugFormat("Calling Setup method for '{0}' for the plugin '{1}'.", pluginType, plugin.Title);
                    pluginInstance.Setup();
                    plugin.IsInstalled = true;
                }

                logger.DebugFormat("Calling Initialize method for '{0}' for the plugin '{1}'.", pluginType, plugin.Title);
                pluginInstance.Initialize();
                plugin.Enabled = true;
            }

            this.pluginDataService.UpdatePlugin(plugin);
        }
        public void Execute(IJobExecutionContext context)
        {
            IPagedResult <PluginDto> plugins = this.pluginService.GetInstalledPlugin(1, 1000);

            foreach (PluginDto plugin in plugins.Result)
            {
                PackageDto package = this.packageInstaller.Get(plugin.PackageId, plugin.Version);

                PluginDto p = package.MapPropertiesToInstance(plugin);

                this.pluginService.UpdatePlugin(p);
            }
        }
Example #4
0
        public static PluginModel ToModel(this PluginDto plugin)
        {
            if (plugin == null)
            {
                return(null);
            }

            return(new PluginModel
            {
                Id = plugin.Id,
                DisplayName = plugin.DisplayName
            });
        }
Example #5
0
        public void EnablePlugin(PluginDto item)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item", "The package cannot be null");
            }

            Plugin plugin = this.Session.Load <Plugin>(item.Id);

            if (plugin == null)
            {
                throw new DexterPluginException("Unable to find the specified package", item.Title);
            }

            plugin.Enabled = true;

            this.Session.Store(plugin);
        }
Example #6
0
 public void UpdatePlugin(PluginDto item)
 {
     this.Session.Store(item);
 }