public PluginViewModel GetPlugin(string pluginName)
        {
            var sql = "SELECT * from Plugins where Name = @pluginName";

            var table = _dbHelper.ExecuteDataTable(sql, new SqlParameter
            {
                ParameterName = "@pluginName",
                Value         = pluginName,
                SqlDbType     = SqlDbType.NVarChar
            });

            if (table.Rows.Cast <DataRow>().Count() == 0)
            {
                return(null);
            }

            var row = table.Rows.Cast <DataRow>().First();

            var plugin = new PluginViewModel();

            plugin.PluginId    = Guid.Parse(row["PluginId"].ToString());
            plugin.Name        = row["Name"].ToString();
            plugin.UniqueKey   = row["UniqueKey"].ToString();
            plugin.Version     = row["Version"].ToString();
            plugin.DisplayName = row["DisplayName"].ToString();
            plugin.IsEnable    = Convert.ToBoolean(row["Enable"]);

            return(plugin);
        }
示例#2
0
        public void DisablePlugin(Guid pluginId)
        {
            PluginViewModel module = _unitOfWork.PluginRepository.GetPlugin(pluginId);

            _unitOfWork.PluginRepository.SetPluginStatus(pluginId, false);
            _mvcModuleSetup.DisableModule(module.Name);
        }
示例#3
0
        private bool InstallPlugin(Plugin plugin, PluginViewModel pluginViewModel)
        {
            foreach (InstalledPlugin iPlugin in pluginViewModel.InstalledPlugins)
            {
                if (iPlugin.Plugin == null)
                {
                    continue;
                }
                if (iPlugin.Plugin.id == plugin.id)
                {
                    Console.WriteLine("Error installing plugin: Plugin " + plugin.name + " is already installed.");
                    return(false);
                }
            }

            PluginWebRequester webRequester    = new PluginWebRequester();
            InstalledPlugin    installedPlugin = new InstalledPlugin
            {
                Name             = StringUtils.BeautifyPluginName(plugin.name),
                IsSpigetPlugin   = true,
                SpigetId         = plugin.id,
                InstalledVersion = webRequester.RequestLatestVersion(plugin.id)
            };

            Application.Current.Dispatcher?.Invoke(() => pluginViewModel.InstalledPlugins.Add(installedPlugin));
            installedPlugin.AfterInit(new StreamingContext());
            //TODO attach something to update event
            Console.WriteLine("Installed Plugin " + installedPlugin.Name);

            return(DownloadPlugin(installedPlugin, pluginViewModel.EntityViewModel).Result);
        }
        public void Edit_GET_Should_Load_Settings_From_Repository()
        {
            // Arrange
            TextPluginStub plugin = new TextPluginStub();

            plugin.Repository  = _repository;
            plugin.PluginCache = _siteCache;
            plugin.Settings.SetValue("name1", "default-value1");
            plugin.Settings.SetValue("name2", "default-value2");

            RepositoryMock repositoryMock = new RepositoryMock();

            repositoryMock.SaveTextPluginSettings(plugin);
            repositoryMock.TextPlugins[0].Settings.SetValue("name1", "value1");
            repositoryMock.TextPlugins[0].Settings.SetValue("name2", "value2");

            _pluginFactory.RegisterTextPlugin(plugin);

            // Act
            ViewResult result = _controller.Edit(plugin.Id) as ViewResult;

            // Assert
            PluginViewModel model = result.ModelFromActionResult <PluginViewModel>();

            Assert.That(model.SettingValues[0].Value, Is.EqualTo("value1"));
            Assert.That(model.SettingValues[1].Value, Is.EqualTo("value2"));
        }
示例#5
0
 private bool DeletePlugin(InstalledPlugin plugin, PluginViewModel viewModel)
 {
     try
     {
         string   folder  = plugin.IsEnabled ? "plugins" : "plugins_disabled";
         FileInfo jarFile = new FileInfo(Path.Combine(App.ServerPath,
                                                      viewModel.EntityViewModel.Name, folder, StringUtils.PluginNameToJarName(plugin.Name) + ".jar"));
         if (!jarFile.Exists)
         {
             ErrorLogger.Append(new ArgumentException(
                                    ".jar for plugin " + plugin.Name + " was not found. Removing it from the list..."));
         }
         else
         {
             jarFile.Delete();
         }
         Application.Current.Dispatcher?.Invoke(() => viewModel.InstalledPlugins.Remove(plugin));
         //Check if plugin is in loaded list currently (in that case change it to downlaodable)
         viewModel.CheckForDeletedPlugin(plugin.Plugin);
         Console.WriteLine("Deleted Plugin " + plugin.Name);
         return(true);
     }
     catch (Exception e)
     {
         ErrorLogger.Append(e);
         Console.WriteLine("Error while deleting Plugin " + plugin.Name);
         return(false);
     }
 }
        private void GetValue(Project project)
        {
            var foundPlugin = this.model.InputPlugins.Single(it => it.Id == project.InputPlugin.PluginId);

            model.Name = project.Name;

            foundPlugin.Source.SetConfiguration(project.InputPlugin.Configuration);
            var pluginModel = new PluginViewModel
                { Id = foundPlugin.Id, Name = foundPlugin.Name, Configuration = foundPlugin.Source.GetConfigControl() };

            this.model.SelectedInputPlugin = pluginModel;
            InputPluginsComboBox.SelectedItem = pluginModel;

            foreach (var outputPlugin1 in project.OutputPlugins)
            {
                var foundOutputPlugin = this.model.OutputPlugins.Single(it => it.Id == outputPlugin1.PluginId);

                foundOutputPlugin.Source.SetConfiguration(outputPlugin1.Configuration);
                var outputPlugin = new PluginViewModel
                    {
                        Id = foundOutputPlugin.Id,
                        Name = foundOutputPlugin.Name,
                        Configuration = foundOutputPlugin.Source.GetConfigControl()
                    };

                this.model.SelectedOutputPlugins.Add(outputPlugin);
            }
        }
        public ActionResult Edit(string id)
        {
            // Guards
            if (string.IsNullOrEmpty(id))
            {
                return(RedirectToAction("Index"));
            }

            TextPlugin plugin = _pluginFactory.GetTextPlugin(id);

            if (plugin == null)
            {
                return(RedirectToAction("Index"));
            }

            PluginViewModel model = new PluginViewModel()
            {
                Id          = plugin.Id,
                DatabaseId  = plugin.DatabaseId,
                Name        = plugin.Name,
                Description = plugin.Description,
            };

            // Try to load the settings from the database, fall back to defaults
            model.SettingValues = new List <SettingValue>(plugin.Settings.Values);
            model.IsEnabled     = plugin.Settings.IsEnabled;

            return(View(model));
        }
示例#8
0
        public virtual ActionResult Update(long id, PluginViewModel pluginView)
        {
            var plugin = pluginService.Find(id);

            if (plugin == null)
            {
                throw new HttpException((int)HttpStatusCode.NotFound, Translate("Messages.CouldNotFoundEntity"));
            }

            if (ModelState.IsValid)
            {
                var          localeService = ServiceLocator.Current.GetInstance <IPluginLocaleService>();
                PluginLocale pluginLocale  = localeService.GetLocale(id, pluginView.SelectedCulture) ??
                                             new PluginLocale {
                    Plugin = plugin, Culture = pluginView.SelectedCulture
                };
                pluginLocale.Title       = pluginView.Title;
                pluginLocale.Description = pluginView.Description;
                localeService.Save(pluginLocale);
                Success(Translate("Messages.PluginUpdated"));
                return(RedirectToAction(MVC.Admin.Module.Index()));
            }

            Error(Translate("Messages.ValidationError"));
            return(View("Edit", pluginView));
        }
示例#9
0
        public DataTreeView(PluginViewModel viewModel)
        {
            InitializeComponent();
            this.viewModel = viewModel;

            this.viewModel.PropertyChanged += OnViewModelPropertyChanged;
        }
示例#10
0
        /// <summary>
        /// Create a command viewmodel that has the command functionality
        /// to create a corresponding shape viewmodel.
        /// </summary>
        /// <param name="viewModel"></param>
        /// <param name="umlType"></param>
        /// <returns></returns>
        public CommandModelBase GetShapeCreateCommand(PluginViewModel viewModel, UmlTypes umlType)
        {
            DataDef item;

            if (UmlElementDataDef.mUmlElements.TryGetValue(umlType, out item) == true)
            {
                switch (item.ImplementingViewModel)
                {
                case ShapeViewModelKey.SquareShape:
                case ShapeViewModelKey.DecisionShape:
                case ShapeViewModelKey.PackageShape:
                case ShapeViewModelKey.BoundaryShape:
                case ShapeViewModelKey.NoteShape:
                case ShapeViewModelKey.NodeShape:
                case ShapeViewModelKey.UseCaseShape:
                case ShapeViewModelKey.CanvasShape:
                    return(new CreateShapeCommandModel(viewModel, umlType,
                                                       item.ToolBoxDescription, item.ToolboxName, item.ToolboxImageUrl));

                // Create connector command viewmodels
                case ShapeViewModelKey.AssocationShape:
                    return(new CreateAssociationCommandModel(viewModel,
                                                             item.ToolboxImageUrl,
                                                             umlType,
                                                             item.ToolboxName,
                                                             item.ToolBoxDescription));

                case ShapeViewModelKey.Undefined:
                default:
                    throw new NotImplementedException(umlType.ToString());
                }
            }

            throw new NotImplementedException(string.Format("System error: '{0}' not supported in CreateCommand.", umlType));
        }
示例#11
0
        public PluginViewModel GetPlugin(string pluginName)
        {
            string sql = "SELECT * from Plugins where Name = @pluginName";

            DataTable table = _dbHelper.ExecuteDataTable(sql, new MySqlParameter
            {
                ParameterName = "@pluginName",
                Value         = pluginName,
                MySqlDbType   = MySqlDbType.VarChar
            });

            if (table.Rows.Cast <DataRow>().Count() == 0)
            {
                return(null);
            }

            DataRow row = table.Rows.Cast <DataRow>().First();

            PluginViewModel plugin = new PluginViewModel
            {
                PluginId    = Guid.Parse(row["PluginId"].ToString()),
                Name        = row["Name"].ToString(),
                UniqueKey   = row["UniqueKey"].ToString(),
                Version     = row["Version"].ToString(),
                DisplayName = row["DisplayName"].ToString(),
                IsEnable    = Convert.ToBoolean(row["Enable"])
            };

            return(plugin);
        }
示例#12
0
        public PluginViewModel GetPlugin(Guid pluginId)
        {
            string sql = "SELECT * from Plugins where PluginId = @pluginId";

            DataTable table = _dbHelper.ExecuteDataTable(sql, new MySqlParameter
            {
                ParameterName = "@pluginId",
                Value         = pluginId,
                MySqlDbType   = MySqlDbType.Guid
            });

            if (table.Rows.Cast <DataRow>().Count() == 0)
            {
                throw new Exception("The plugin is missing in the system.");
            }

            DataRow row = table.Rows.Cast <DataRow>().First();

            PluginViewModel plugin = new PluginViewModel
            {
                PluginId    = Guid.Parse(row["PluginId"].ToString()),
                Name        = row["Name"].ToString(),
                UniqueKey   = row["UniqueKey"].ToString(),
                Version     = row["Version"].ToString(),
                DisplayName = row["DisplayName"].ToString(),
                IsEnable    = Convert.ToBoolean(row["Enable"])
            };

            return(plugin);
        }
 public PluginView(double zoom)
 {
     DataContext = new PluginViewModel {
         ZoomFactor = zoom
     };
     InitializeComponent();
 }
        public PluginViewModel GetPlugin(Guid pluginId)
        {
            var sql = "SELECT * from Plugins where PluginId = @pluginId";

            var table = _dbHelper.ExecuteDataTable(sql, new SqlParameter
            {
                ParameterName = "@pluginId",
                Value         = pluginId,
                SqlDbType     = SqlDbType.UniqueIdentifier
            });

            if (table.Rows.Cast <DataRow>().Count() == 0)
            {
                throw new Exception("The plugin is missing in the system.");
            }

            var row = table.Rows.Cast <DataRow>().First();

            var plugin = new PluginViewModel();

            plugin.PluginId    = Guid.Parse(row["PluginId"].ToString());
            plugin.Name        = row["Name"].ToString();
            plugin.UniqueKey   = row["UniqueKey"].ToString();
            plugin.Version     = row["Version"].ToString();
            plugin.DisplayName = row["DisplayName"].ToString();
            plugin.IsEnable    = Convert.ToBoolean(row["Enable"]);

            return(plugin);
        }
示例#15
0
        public void constructor_should_create_settingvalues()
        {
            // Arrange + Act
            PluginViewModel model = new PluginViewModel();

            // Assert
            Assert.That(model.SettingValues, Is.Not.Null);
        }
示例#16
0
        /// <summary>
        /// Get a collection of <seealso cref="CommandModelBase"/> elements that represents all commands
        /// necessary to create a toolbox entry that represents the elements for a new uml diagram.
        /// </summary>
        /// <param name="viewModel"></param>
        /// <param name="umlDiagram"></param>
        /// <returns></returns>
        public IEnumerable <CommandModelBase> GetUmlDiagramElements(PluginViewModel viewModel, UmlDiagrams umlDiagram)
        {
            if (this.mUmlDiagramFactory == null)
            {
                this.mUmlDiagramFactory = new UmlDiagramsDataDef();
            }

            return(this.mUmlDiagramFactory.GetUmlDiagramDataDef(viewModel, umlDiagram));
        }
示例#17
0
        /// <summary>
        /// Get a create commandmodel instance for the matching <seealso cref="UmlTypes"/> parameter.
        /// </summary>
        /// <param name="viewModel"></param>
        /// <param name="umlType"></param>
        /// <returns></returns>
        public CommandModelBase GetCreateUmlShapeCommandModel(PluginViewModel viewModel, UmlTypes umlType)
        {
            if (this.mUmlElementFactory == null)
            {
                this.mUmlElementFactory = new UmlElementDataDef();
            }

            return(this.mUmlElementFactory.GetShapeCreateCommand(viewModel, umlType));
        }
示例#18
0
        public async Task <bool> EnablePluginAsync(InstalledPlugin plugin, PluginViewModel pluginViewModel)
        {
            Task <bool> t = new Task <bool>(() => EnablePlugin(plugin, pluginViewModel));

            t.Start();
            bool r = await t;

            return(r);
        }
示例#19
0
        public ActionResult Plugins()
        {
            var list = RouteTable.Routes.ToList();

            PluginViewModel pluginViewModel = new PluginViewModel();

            pluginViewModel.PluginList = _pluginList;

            return(View(pluginViewModel));
        }
示例#20
0
        public void TestConstructionWithError()
        {
            var description = new PluginDescription
            {
                Error = "Someone screwed up"
            };
            var viewModel = new PluginViewModel(description);

            viewModel.HasError.Should().BeTrue();
            viewModel.Error.Should().Be("Someone screwed up");
        }
示例#21
0
        public void TestConstructionWithoutName([Values(null, "")] string emptyName)
        {
            var description = new PluginDescription
            {
                Id   = new PluginId("SomeOrg.SomePlugin"),
                Name = emptyName
            };
            var viewModel = new PluginViewModel(description);

            viewModel.Name.Should().Be("SomeOrg.SomePlugin",
                                       "because absent of a name, the id should be presented to the user as the plugin's name");
        }
示例#22
0
        public PluginOverviewViewModel(List <PluginManifestPlugin> plugins)
        {
            Plugins         = new ObservableCollection <PluginViewModel>();
            SelectedPlugins = new ObservableCollection <PluginViewModel>();

            plugins.ForEach(plugin =>
            {
                var pluginViewModel = new PluginViewModel(plugin);
                pluginViewModel.ConfiguringPluginEvent += (sender, args) => ConfiguringPluginEvent((PluginViewModel)sender, args);
                Plugins.Add(pluginViewModel);
            });
        }
 public PriorityChangeWindow(string pluginId, Settings settings, PluginViewModel pluginViewModel)
 {
     InitializeComponent();
     plugin               = PluginManager.GetPluginForId(pluginId);
     this.settings        = settings;
     this.pluginViewModel = pluginViewModel;
     if (plugin == null)
     {
         MessageBox.Show(translater.GetTranslation("cannotFindSpecifiedPlugin"));
         Close();
     }
 }
    /// <summary>
    /// Standard cosntructor
    /// </summary>
    public CreateAssociationCommandModel(PluginViewModel viewModel,
                                         string toolboxImageUrl,
                                         UmlTypes umlType,
                                         string toolBoxName,
                                         string toolBoxDescription)
    {
      this.mViewModel = viewModel;

      this.ToolBoxImageUrl = toolboxImageUrl;
      this.mUmlType = umlType;
      this.mToolBoxName = toolBoxName;
      this.mToolBoxDescription = toolBoxDescription;
    }
示例#25
0
        public SolutionProgressView(
            IAsyncJobScheduler scheduler,
            IImportJobRepository importJobRepository,
            PluginViewModel viewModel,
            TimelineView timeline)
        {
            InitializeComponent();

            this.scheduler           = scheduler ?? throw new System.ArgumentNullException(nameof(scheduler));
            this.importJobRepository = importJobRepository ?? throw new System.ArgumentNullException(nameof(importJobRepository));
            this.viewModel           = viewModel;
            this.timeline            = timeline;
        }
示例#26
0
        /// <summary>
        /// Standard constructor
        /// </summary>
        /// <param name="viewModel"></param>
        public CreateShapeCommandModel(PluginViewModel viewModel,
                                       UmlTypes umlType,
                                       string description,
                                       string displayName,
                                       string toolboxImageUrl)
        {
            this.mViewModel = viewModel;
            this.mUmlType   = umlType;

            this.mDescription    = description;
            this.mDisplayName    = displayName;
            this.ToolBoxImageUrl = toolboxImageUrl;
        }
示例#27
0
        public void DeletePlugin(Guid pluginId)
        {
            PluginViewModel plugin = _unitOfWork.PluginRepository.GetPlugin(pluginId);

            if (plugin.IsEnable)
            {
                DisablePlugin(pluginId);
            }

            _unitOfWork.PluginRepository.RunDownMigrations(pluginId);
            _unitOfWork.PluginRepository.DeletePlugin(pluginId);
            _unitOfWork.Commit();

            _mvcModuleSetup.DeleteModule(plugin.Name);
        }
示例#28
0
            public IEnumerable <CommandModelBase> GetUmlDiagramDataDef(PluginViewModel viewModel, UmlDiagrams umlDiagram)
            {
                List <CommandModelBase> ret = new List <CommandModelBase>();

                UmlTypes[] list = null;

                this.mDiagrams.TryGetValue(umlDiagram, out list);

                foreach (var item in list)
                {
                    ret.Add(UmlElementsManager.Instance.GetCreateUmlShapeCommandModel(viewModel, item));
                }

                return(ret);
            }
        private void InputPluginSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (InputPluginsComboBox.SelectedItem == null)
                return;

            var pluginPreview = (PluginPreviewItem)InputPluginsComboBox.SelectedItem;
            var pluginModel = new PluginViewModel
            {
                Id = pluginPreview.Id,
                Name = pluginPreview.Name,
                Configuration = pluginPreview.Source.GetConfigControl()
            };

            model.SelectedInputPlugin = pluginModel;
        }
示例#30
0
        public void UpgradePlugin(PluginPackage pluginPackage, PluginViewModel oldPlugin)
        {
            _unitOfWork.PluginRepository.UpdatePluginVersion(oldPlugin.PluginId, pluginPackage.Configuration.Version);
            _unitOfWork.Commit();

            List <IMigration> migrations = pluginPackage.GetAllMigrations(_connectionString);

            IEnumerable <IMigration> pendingMigrations = migrations.Where(p => p.Version > oldPlugin.Version);

            foreach (IMigration migration in pendingMigrations)
            {
                migration.MigrateUp(oldPlugin.PluginId);
            }

            pluginPackage.SetupFolder();
        }
示例#31
0
        private void btnDone_OnClick(object sender, RoutedEventArgs _)
        {
            var oldActionKeyword = plugin.Metadata.ActionKeywords[0];
            var newActionKeyword = tbAction.Text.Trim();

            newActionKeyword = newActionKeyword.Length > 0 ? newActionKeyword : "*";
            if (!PluginViewModel.IsActionKeywordRegistered(newActionKeyword))
            {
                pluginViewModel.ChangeActionKeyword(newActionKeyword, oldActionKeyword);
                Close();
            }
            else
            {
                string msg = translater.GetTranslation("newActionKeywordsHasBeenAssigned");
                MessageBox.Show(msg);
            }
        }
示例#32
0
        /// <summary>
        /// Class constructor to create all shapes that belong to one
        /// UML type of diagram plus common diagram items.
        /// </summary>
        /// <param name="pluginViewModel"></param>
        public ToolBoxControlViewModel(PluginViewModel pluginViewModel, UmlDiagrams umlDiagram)
        {
            var shapeCommandModels = UmlElementsManager.Instance.GetUmlDiagramElements(pluginViewModel, umlDiagram);

            foreach (var item in shapeCommandModels)
            {
                this.toolBoxItems.Add(new ToolBoxData(item.ToolBoxImageUrl, item));
            }

            if (umlDiagram != UmlDiagrams.Connector)
            {
                shapeCommandModels = UmlElementsManager.Instance.GetUmlDiagramElements(pluginViewModel, UmlDiagrams.Common);

                foreach (var item in shapeCommandModels)
                {
                    this.toolBoxItems.Add(new ToolBoxData(item.ToolBoxImageUrl, item));
                }
            }
        }
        public virtual ActionResult ChangeLanguage(long pluginId, String culture)
        {
            var plugin = pluginService.Find(pluginId);
            if (plugin == null)
            {
                throw new HttpException((int)HttpStatusCode.NotFound, Translate("Messages.PluginNotFound"));
            }
            PluginViewModel model = new PluginViewModel().MapFrom(plugin);
            model.SelectedCulture = culture;
            var localeService = ServiceLocator.Current.GetInstance<IPluginLocaleService>();
            PluginLocale locale = localeService.GetLocale(pluginId, culture);
            if (locale != null)
            {
                model.Title = locale.Title;
                model.Description = locale.Description;
            }

            return PartialView("EditForm", model);
        }
        public virtual ActionResult Update(long id, PluginViewModel pluginView)
        {
            var plugin = pluginService.Find(id);
            if (plugin == null)
            {
                throw new HttpException((int)HttpStatusCode.NotFound, Translate("Messages.CouldNotFoundEntity"));
            }

            if (ModelState.IsValid)
            {
                var localeService = ServiceLocator.Current.GetInstance<IPluginLocaleService>();
                PluginLocale pluginLocale = localeService.GetLocale(id, pluginView.SelectedCulture) ??
                                            new PluginLocale { Plugin = plugin, Culture = pluginView.SelectedCulture };
                pluginLocale.Title = pluginView.Title;
                pluginLocale.Description = pluginView.Description;
                localeService.Save(pluginLocale);
                Success(Translate("Messages.PluginUpdated"));
                return RedirectToAction(MVC.Admin.Module.Index());
            }

            Error(Translate("Messages.ValidationError"));
            return View("Edit", pluginView);
        }