コード例 #1
0
ファイル: PluginController.cs プロジェクト: wzh9801/src
        public virtual IActionResult ListSelect(PluginSearchModel searchModel)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManagePlugins))
            {
                return(AccessDeniedKendoGridJson());
            }

            //prepare model
            var model = _pluginModelFactory.PreparePluginListModel(searchModel);

            return(Json(model));
        }
コード例 #2
0
        /// <returns>A task that represents the asynchronous operation</returns>
        public virtual async Task <IActionResult> ListSelect(PluginSearchModel searchModel)
        {
            if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManagePlugins))
            {
                return(await AccessDeniedDataTablesJson());
            }

            //prepare model
            var model = await _pluginModelFactory.PreparePluginListModelAsync(searchModel);

            return(Json(model));
        }
コード例 #3
0
ファイル: PluginModelFactory.cs プロジェクト: joenilan/nop
        /// <summary>
        /// Prepare plugin search model
        /// </summary>
        /// <param name="searchModel">Plugin search model</param>
        /// <returns>Plugin search model</returns>
        public virtual PluginSearchModel PreparePluginSearchModel(PluginSearchModel searchModel)
        {
            if (searchModel == null)
            {
                throw new ArgumentNullException(nameof(searchModel));
            }

            //prepare available load plugin modes
            _baseAdminModelFactory.PrepareLoadPluginModes(searchModel.AvailableLoadModes, false);

            //prepare available groups
            _baseAdminModelFactory.PreparePluginGroups(searchModel.AvailableGroups);

            //prepare page parameters
            searchModel.SetGridPageSize();

            return(searchModel);
        }
コード例 #4
0
        /// <summary>
        /// Prepare paged plugin list model
        /// </summary>
        /// <param name="searchModel">Plugin search model</param>
        /// <returns>Plugin list model</returns>
        public virtual PluginListModel PreparePluginListModel(PluginSearchModel searchModel)
        {
            if (searchModel == null)
            {
                throw new ArgumentNullException(nameof(searchModel));
            }

            //get parameters to filter plugins
            var group    = string.IsNullOrEmpty(searchModel.SearchGroup) || searchModel.SearchGroup.Equals("0") ? null : searchModel.SearchGroup;
            var loadMode = (LoadPluginsMode)searchModel.SearchLoadModeId;

            //filter visible plugins
            var plugins1 = _pluginService.GetPluginDescriptors <IPlugin>(group: group, loadMode: loadMode)
                           //.Where(p => p.ShowInPluginsList)
                           .OrderBy(plugin => plugin.Group).ToList()
                           .ToPagedList(searchModel);

            var plugins = _pluginService.GetPluginDescriptors <IPlugin>(group: group, loadMode: loadMode)
                          .Where(p => p.ShowInPluginsList)
                          .OrderBy(plugin => plugin.Group).ToList()
                          .ToPagedList(searchModel);

            //prepare list model
            var model = new PluginListModel().PrepareToGrid(searchModel, plugins, () =>
            {
                return(plugins.Select(pluginDescriptor =>
                {
                    //fill in model values from the entity
                    var pluginModel = pluginDescriptor.ToPluginModel <PluginModel>();

                    //fill in additional values (not existing in the entity)
                    pluginModel.LogoUrl = _pluginService.GetPluginLogoUrl(pluginDescriptor);
                    if (pluginDescriptor.Installed)
                    {
                        PrepareInstalledPluginModel(pluginModel, pluginDescriptor.Instance <IPlugin>());
                    }

                    return pluginModel;
                }));
            });

            return(model);
        }
コード例 #5
0
        /// <summary>
        /// Prepare plugin search model
        /// </summary>
        /// <param name="searchModel">Plugin search model</param>
        /// <returns>
        /// A task that represents the asynchronous operation
        /// The task result contains the plugin search model
        /// </returns>
        public virtual async Task <PluginSearchModel> PreparePluginSearchModelAsync(PluginSearchModel searchModel)
        {
            if (searchModel == null)
            {
                throw new ArgumentNullException(nameof(searchModel));
            }

            //prepare available load plugin modes
            await _baseAdminModelFactory.PrepareLoadPluginModesAsync(searchModel.AvailableLoadModes, false);

            //prepare available groups
            await _baseAdminModelFactory.PreparePluginGroupsAsync(searchModel.AvailableGroups);

            //prepare page parameters
            searchModel.SetGridPageSize();

            searchModel.NeedToRestart = _pluginService.IsRestartRequired();

            return(searchModel);
        }
コード例 #6
0
        /// <summary>
        /// Prepare paged plugin list model
        /// </summary>
        /// <param name="searchModel">Plugin search model</param>
        /// <returns>
        /// A task that represents the asynchronous operation
        /// The task result contains the plugin list model
        /// </returns>
        public virtual async Task <PluginListModel> PreparePluginListModelAsync(PluginSearchModel searchModel)
        {
            if (searchModel == null)
            {
                throw new ArgumentNullException(nameof(searchModel));
            }

            //get parameters to filter plugins
            var group        = string.IsNullOrEmpty(searchModel.SearchGroup) || searchModel.SearchGroup.Equals("0") ? null : searchModel.SearchGroup;
            var loadMode     = (LoadPluginsMode)searchModel.SearchLoadModeId;
            var friendlyName = string.IsNullOrEmpty(searchModel.SearchFriendlyName) ? null : searchModel.SearchFriendlyName;
            var author       = string.IsNullOrEmpty(searchModel.SearchAuthor) ? null : searchModel.SearchAuthor;

            //filter visible plugins
            var plugins = (await _pluginService.GetPluginDescriptorsAsync <IPlugin>(group: group, loadMode: loadMode, friendlyName: friendlyName, author: author))
                          .Where(p => p.ShowInPluginsList)
                          .OrderBy(plugin => plugin.Group).ToList()
                          .ToPagedList(searchModel);

            //prepare list model
            var model = await new PluginListModel().PrepareToGridAsync(searchModel, plugins, () =>
            {
                return(plugins.SelectAwait(async pluginDescriptor =>
                {
                    //fill in model values from the entity
                    var pluginModel = pluginDescriptor.ToPluginModel <PluginModel>();

                    //fill in additional values (not existing in the entity)
                    pluginModel.LogoUrl = await _pluginService.GetPluginLogoUrlAsync(pluginDescriptor);

                    if (pluginDescriptor.Installed)
                    {
                        PrepareInstalledPluginModel(pluginModel, pluginDescriptor.Instance <IPlugin>());
                    }

                    return pluginModel;
                }));
            });

            return(model);
        }
コード例 #7
0
ファイル: PluginModelFactory.cs プロジェクト: joenilan/nop
        /// <summary>
        /// Prepare paged plugin list model
        /// </summary>
        /// <param name="searchModel">Plugin search model</param>
        /// <returns>Plugin list model</returns>
        public virtual PluginListModel PreparePluginListModel(PluginSearchModel searchModel)
        {
            if (searchModel == null)
            {
                throw new ArgumentNullException(nameof(searchModel));
            }

            //get parameters to filter plugins
            var group    = string.IsNullOrEmpty(searchModel.SearchGroup) || searchModel.SearchGroup.Equals("0") ? null : searchModel.SearchGroup;
            var loadMode = (LoadPluginsMode)searchModel.SearchLoadModeId;

            //get plugins
            var plugins = _pluginFinder.GetPluginDescriptors(group: group, loadMode: loadMode)
                          .OrderBy(plugin => plugin.Group).ToList();

            //prepare list model
            var model = new PluginListModel
            {
                Data = plugins.PaginationByRequestModel(searchModel).Select(pluginDescriptor =>
                {
                    //fill in model values from the entity
                    var pluginModel = pluginDescriptor.ToPluginModel <PluginModel>();

                    //fill in additional values (not existing in the entity)
                    pluginModel.LogoUrl = PluginManager.GetLogoUrl(pluginDescriptor);
                    if (pluginDescriptor.Installed)
                    {
                        PrepareInstalledPluginModel(pluginModel, pluginDescriptor.Instance());
                    }

                    return(pluginModel);
                }),
                Total = plugins.Count
            };

            return(model);
        }