Esempio n. 1
0
        /// <summary>
        /// 联网获取插件的最新版本
        /// </summary>
        /// <param name="pm"></param>
        /// <returns></returns>
        public static VersionModel GetPluginNewVersion(PluginModel pm)
        {
            VersionModel rs = HttpTool.Get <VersionModel>(R.Settings.Url.WebService + string.Format("getPluginsConfig?name={0}&version={1}", pm.Name, pm.Version));

            //VersionModel rs = JsonTool.ToObjFromFile<VersionModel>(@"D:\CoCo\GitHub\Fork\Fork.Net\Oreo.VersionBuilder\bin\Debug\VersionFile\0602104746.version");
            return(rs);
        }
Esempio n. 2
0
        void InitLeft()
        {
            MenuService       leftMenuService = new MenuService();
            PluginService     pgService       = new PluginService();
            IList <ArrayList> leftMenus       = leftMenuService.GetMenus("all");

            for (int i = 0; i < leftMenus.Count; i++)
            {
                TreeNode tn = new TreeNode();
                tn.Name = "root_" + leftMenus[i][0];
                tn.Text = (leftMenus[i][1] as string).Split(';')[0];
                tn.Tag  = leftMenus[i][1] as string;
                treeMenu.Nodes.Add(tn);

                foreach (string item in (leftMenus[i][2] as IList <String>))
                {
                    PluginModel pm = pgService.GetPluginItem(item, "0");
                    if (pm == null)
                    {
                        continue;
                    }
                    TreeNode subTn = new TreeNode();
                    subTn.Name = pm.GUID;
                    subTn.Text = pm.Text;
                    subTn.Tag  = pm;
                    tn.Nodes.Add(subTn);
                }
            }
        }
Esempio n. 3
0
        private async Task <IActionResult> Edit(int id, [Bind("NomePlugin,AutorPlugin,VersaoPlugin,TipoPlugin,PrecoPlugin,DescricaoPlugin,ImagemPadraoPersonalizada,Id")] PluginModel pluginModel)
        {
            if (id != pluginModel.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(pluginModel);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PluginModelExists(pluginModel.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(pluginModel));
        }
Esempio n. 4
0
        public Plugin(PluginModel pModel, bool threadStart)
        {
            if (pModel == null)
            {
                throw new NullReferenceException("null reference");
            }

            this.pModel  = pModel;
            status       = 1;
            statistics   = 0;
            enabled      = pModel.Enabled;
            debugEnabled = false;
            pro          = new Protocol();
            string s = "Data Source=" + pModel.DesIP + "," + pModel.DesPort + "\\" + pModel.DesInstance + ";Initial Catalog=" + pModel.DesCatalog + ";uid=" + pModel.DesUser + ";pwd=" + pModel.DesPwd;

            helper = new SqlHelper(s);

            if (enabled)
            {
                if (CheckTable() <= 0)
                {
                    status = 0;
                }
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Prepare plugin model properties of the installed plugin
        /// </summary>
        /// <param name="model">Plugin model</param>
        /// <param name="plugin">Plugin</param>
        protected virtual void PrepareInstalledPluginModel(PluginModel model, IPlugin plugin)
        {
            if (model == null)
            {
                throw new ArgumentNullException(nameof(model));
            }

            if (plugin == null)
            {
                throw new ArgumentNullException(nameof(plugin));
            }

            //prepare configuration URL
            model.ConfigurationUrl = plugin.GetConfigurationPageUrl();

            //prepare enabled/disabled (only for some plugin types)
            model.CanChangeEnabled = true;
            switch (plugin)
            {
            case IExternalAuthenticationMethod externalAuthenticationMethod:
                model.IsEnabled = _externalAuthenticationService.IsExternalAuthenticationMethodActive(externalAuthenticationMethod);
                break;

            case IWidgetPlugin widgetPlugin:
                model.IsEnabled = _widgetService.IsWidgetActive(widgetPlugin);
                break;

            default:
                model.CanChangeEnabled = false;
                break;
            }
        }
 public PostprocessorsFactory(
     Postprocessing.IModel postprocessing,
     PluginModel pluginModel)
 {
     this.postprocessing = postprocessing;
     this.pluginModel    = pluginModel;
 }
Esempio n. 7
0
        public Task Initialize()
        {
            var namingOptions  = _options.PluginNameOptions;
            var version        = namingOptions.PluginVersionGenerator(namingOptions, _pluginType);
            var pluginName     = namingOptions.PluginNameGenerator(namingOptions, _pluginType);
            var description    = namingOptions.PluginDescriptionGenerator(namingOptions, _pluginType);
            var productVersion = namingOptions.PluginProductVersionGenerator(namingOptions, _pluginType);

            var tags   = new List <string>();
            var finder = new TypeFinder();

            foreach (var typeFinderCriteria in _options.TypeFinderOptions.TypeFinderCriterias)
            {
                var isMatch = finder.IsMatch(typeFinderCriteria, _pluginType, _options.TypeFindingContext);

                if (isMatch)
                {
                    if (typeFinderCriteria.Tags?.Any() == true)
                    {
                        tags.AddRange(typeFinderCriteria.Tags);
                    }
                }
            }

            _plugin       = new PluginModel(_pluginType.Assembly, _pluginType, pluginName, version, this, description, productVersion, string.Empty, tags);
            IsInitialized = true;
            return(Task.CompletedTask);
        }
Esempio n. 8
0
 public void Monster()
 {
     if (PluginModel.PluginStatus("5"))
     {
         MonsterPluginModel.AddMonster();
     }
 }
Esempio n. 9
0
        public static bool CheckMacro(Macro m)
        {
            if (m == null)
            {
                return(false);
            }

            foreach (ModelBase item in m.WorkItems)
            {
                if (item is PluginModel)
                {
                    PluginModel pluginItem = (PluginModel)item;
                    string      plugin     = pluginItem.Plugin;

                    IPhotoTagStudioTaggingPlugin p = PluginView.GetPlugin(plugin);
                    if (p == null)
                    {
                        if (MessageBox.Show("The macro uses a plugin that cannot be found by PhotoTagStudio: " + plugin + "\n\nUse the macro anyway?", "Plugin for macro not found", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == System.Windows.Forms.DialogResult.No)
                        {
                            return(false);
                        }
                    }
                }
            }

            return(true);
        }
Esempio n. 10
0
        public Plugin(PluginModel pModel, bool threadStart)
        {
            if (pModel == null)
            {
                throw new NullReferenceException("null reference");
            }
            Pro          = new Protocol();
            TranLimit    = 1000;
            this.pModel  = pModel;
            status       = 1;
            isSlow       = 0;
            isStop       = false;
            statistics   = 0;
            enabled      = pModel.Enabled;
            debugEnabled = false;
            string s = string.Format("Data Source={0},{1}\\{2};Initial Catalog={3};uid={4};pwd={5}", pModel.DesIP, pModel.DesPort, pModel.DesInstance, pModel.DesCatalog, pModel.DesUser, pModel.DesPwd);

            sqlHelper = new SqlHelper(s);

            if (threadStart)
            {
                this.dealDataThread = new Thread(new ThreadStart(Run));
                this.dealDataThread.Start();
            }
        }
Esempio n. 11
0
        /// <summary>
        /// Prepare plugin model
        /// </summary>
        /// <param name="model">Plugin model</param>
        /// <param name="pluginDescriptor">Plugin descriptor</param>
        /// <param name="excludeProperties">Whether to exclude populating of some properties of model</param>
        /// <returns>Plugin model</returns>
        public virtual PluginModel PreparePluginModel(PluginModel model, PluginDescriptor pluginDescriptor, bool excludeProperties = false)
        {
            Action <PluginLocalizedModel, int> localizedModelConfiguration = null;

            if (pluginDescriptor != null)
            {
                //fill in model values from the entity
                model = model ?? pluginDescriptor.ToPluginModel(model);

                model.LogoUrl             = PluginManager.GetLogoUrl(pluginDescriptor);
                model.SelectedUserRoleIds = pluginDescriptor.LimitedToUserRoles;
                if (pluginDescriptor.Installed)
                {
                    PrepareInstalledPluginModel(model, pluginDescriptor.Instance());
                }

                //define localized model configuration action
                localizedModelConfiguration = (locale, languageId) =>
                {
                    var plugin = pluginDescriptor.Instance();
                    locale.FriendlyName = _localizationService.GetLocalizedFriendlyName(plugin, languageId, false);
                };
            }

            //prepare localized models
            if (!excludeProperties)
            {
                model.Locales = _localizedModelFactory.PrepareLocalizedModels(localizedModelConfiguration);
            }

            //prepare model user roles
            _aclSupportedModelFactory.PrepareModelUserRoles(model);

            return(model);
        }
Esempio n. 12
0
        public static ModelObjects Create(LogJoint.IModel appModel)
        {
            appModel.Postprocessing.TimeSeries.RegisterTimeSeriesTypesAssembly(typeof(TimeSeries.PostprocessorsFactory).Assembly);

            var pluginModel = new PluginModel();

            appModel.PluginsManager.Register <IPluginModel>(pluginModel);

            IPostprocessorsRegistry postprocessorsRegistry = new PostprocessorsInitializer(
                appModel.Postprocessing.Manager,
                appModel.UserDefinedFormatsManager,
                new StateInspector.PostprocessorsFactory(appModel.Postprocessing, pluginModel),
                new TimeSeries.PostprocessorsFactory(appModel.Postprocessing, pluginModel),
                new Correlator.PostprocessorsFactory(appModel, pluginModel),
                new Timeline.PostprocessorsFactory(appModel.Postprocessing, pluginModel),
                new SequenceDiagram.PostprocessorsFactory(appModel.Postprocessing, pluginModel)
                );

            appModel.Preprocessing.ExtensionsRegistry.Register(
                new WebrtcInternalsDump.PreprocessingManagerExtension(appModel.Preprocessing.StepsFactory)
                );
            appModel.Preprocessing.ExtensionsRegistry.Register(
                new ChromeDriver.PreprocessingManagerExtension(appModel.Preprocessing.StepsFactory, postprocessorsRegistry.ChromeDriver.LogProviderFactory, appModel.Postprocessing.TextLogParser)
                );
            appModel.Preprocessing.ExtensionsRegistry.Register(
                new HttpArchive.PreprocessingManagerExtension(appModel.Preprocessing.StepsFactory, postprocessorsRegistry.HttpArchive.LogProviderFactory)
                );

            return(new ModelObjects
            {
                PostprocessorsRegistry = postprocessorsRegistry
            });
        }
Esempio n. 13
0
        public Plugin(PluginModel pModel, bool threadStart)
        {
            if (pModel == null)
            {
                throw new NullReferenceException("null reference");
            }
            Pro          = new Protocol();
            TranLimit    = 1000;
            this.pModel  = pModel;
            status       = 1;
            isSlow       = 0;
            isStop       = false;
            statistics   = 0;
            enabled      = pModel.Enabled;
            debugEnabled = false;
            pro          = new Protocol();
            string s = "Data Source=" + pModel.DesIP + "," + pModel.DesPort + "\\" + pModel.DesInstance + ";Initial Catalog=" + pModel.DesCatalog + ";uid=" + pModel.DesUser + ";pwd=" + pModel.DesPwd;

            sqlHelper = new SqlHelper(s);

            if (threadStart)
            {
                this.dealDataThread = new Thread(new ThreadStart(Run));
                this.dealDataThread.Start();
            }
        }
Esempio n. 14
0
        public async Task InitializeAsync(Stream zipStream)
        {
            var archive = new ZipArchive(this.zipStream = zipStream, ZipArchiveMode.Read);

            zipStream.Position = 0;
            tempFolderName     = Path.Combine(Environment.CurrentDirectory, "host_plugins", Guid.NewGuid().ToString());
            archive.ExtractToDirectory(tempFolderName, true);

            var folder     = new DirectoryInfo(tempFolderName);
            var files      = folder.GetFiles();
            var configFile = files.SingleOrDefault(p => p.Name == "plugin.json");

            if (configFile == null)
            {
                throw new MissingConfigurationFileException();
            }

            using var stream = configFile.OpenRead();
            using var sr     = new StreamReader(stream);
            var content = await sr.ReadToEndAsync();

            Configuration = JsonConvert.DeserializeObject <PluginModel>(content);

            if (Configuration == null)
            {
                throw new WrongFormatConfigurationException();
            }
        }
Esempio n. 15
0
        public Plugin(PluginModel pModel, bool threadStart)
        {
            if (pModel == null)
            {
                throw new NullReferenceException("null reference");
            }
            liaoninggps = new LiaoNinGps();
            liaoninggps.shuzizengtou = 0x2929;
            liaoninggps.cmdFlag      = 0x80;
            liaoninggps.dataLength   = 0x2800;
            liaoninggps.shujuWeiZhen = 0x0D;
            TranLimit    = 1000;
            this.pModel  = pModel;
            status       = 1;
            isSlow       = 0;
            isStop       = false;
            statistics   = 0;
            enabled      = pModel.Enabled;
            debugEnabled = false;
            liaoNinpro   = new Protocol();

            if (threadStart)
            {
                dealDataThread = new Thread(Run);
                dealDataThread.Start();
            }
        }
Esempio n. 16
0
            private static void loadPluginAssembly(string assemblyFile, MainWindowViewModel windowViewModel)
            {
                Assembly assembly;

                try
                {
                    // Load the plugin assembly.
                    assembly = Assembly.LoadFrom(assemblyFile);

                    // Add an instance of each PluginModel found in the assembly to the plugin collection
                    // and merge its resources into the plugin resource dictionary.
                    foreach (Type type in assembly.GetTypes())
                    {
                        if (!type.IsAbstract && typeof(PluginModel).IsAssignableFrom(type))
                        {
                            try
                            {
                                // Create PluginModel instance.
                                PluginModel pluginModel = Activator.CreateInstance(type, windowViewModel) as PluginModel;

                                // Plugin names must be unique
                                foreach (PluginModel p in PluginManager.PluginModels)
                                {
                                    if (p.Name == pluginModel.Name)
                                    {
                                        throw new Exception("A plugin with the specified name has already been loaded.");
                                    }
                                }

                                // Get the shared resources from the plugin.
                                ResourceDictionary sharedResources = pluginModel.Resources;

                                // If we got any resources, merge them into our plugin resource dictionary.
                                if (sharedResources != null)
                                {
                                    PluginManager.PluginResources.MergedDictionaries.Add(sharedResources);
                                }

                                // Add the plugin to our plugin collection.
                                PluginManager.PluginModels.Add(pluginModel);
                            }
                            catch (Exception ex)
                            {
                                ExceptionManager.Register(ex,
                                                          "Plugin not loaded.",
                                                          "An error occured while initializing a plugin found in assembly " + assemblyFile + ".");
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    ExceptionManager.Register(ex,
                                              "Plugins from the assembly was not loaded.",
                                              "An error occured while loading plugin assembly " + assemblyFile + ".");

                    return;
                }
            }
        public PostprocessorsFactory(IModel ljModel, PluginModel pluginModel)
        {
            this.postprocessorsManager = ljModel.Postprocessing.Manager;
            this.postprocessing        = ljModel.Postprocessing;
            this.pluginModel           = pluginModel;

            postprocessorsManager.Register(Correlation.NodeDetectionToken.Factory.Instance);
        }
Esempio n. 18
0
 /// <summary>
 /// Called by double clicking on a plugin symbol of CrypTool
 /// Adds a new PluginModel wrapping an instance of the selected plugin
 /// </summary>
 /// <param name="type"></param>
 public void Add(Type type)
 {
     if (!executing)
     {
         PluginModel pluginModel = (PluginModel)WorkspaceSpaceEditorView.Model.ModifyModel(new NewPluginModelOperation(new Point(0, 0), 0, 0, type));
         WorkspaceSpaceEditorView.AddComponentVisual(pluginModel, 1);
     }
 }
Esempio n. 19
0
 public void SetPluginModel(PluginModel pModel)
 {
     lock (lckPModel)
     {
         this.pModel = pModel;
         enabled     = pModel.Enabled;
     }
 }
Esempio n. 20
0
 public DeletePluginModelOperation(PluginModel model)
     : base(model)
 {
     Position   = model.GetPosition();
     Width      = model.GetWidth();
     Height     = model.GetHeight();
     PluginType = model.PluginType;
     Identifier = model.GetHashCode();
 }
Esempio n. 21
0
        public ActionResult MediaUpload()
        {
            // Redirect if the user isn't logged in
            if (!IdentityModel.CurrentUserLoggedIn || !PluginModel.PluginStatus("4"))
            {
                return(RedirectToAction("Login", "Admin"));
            }

            return(View(new UploadImageModel()));
        }
Esempio n. 22
0
        //
        // GET: /Admin/AllPosts/
        public ActionResult AllPosts()
        {
            // Redirect if the user isn't logged in
            if (!IdentityModel.CurrentUserLoggedIn || !PluginModel.PluginStatus("3"))
            {
                return(RedirectToAction("Login", "Admin"));
            }

            return(View());
        }
Esempio n. 23
0
 public void SetPluginModel(PluginModel pModel)
 {
     lock (this.lckPModel)
     {
         this.pModel = pModel;
         lock (this.lckHelper)
         {
             this.sqlfc.ChangConn(pModel.DesIP, pModel.DesPort, pModel.DesCatalog, pModel.DesUser, pModel.DesPwd);
         }
     }
 }
Esempio n. 24
0
        /// <summary>
        /// Returns the inputs, outputs, and settings as a json string
        /// </summary>
        /// <param name="globalProgress"></param>
        /// <returns></returns>
        public static string GetPluginDiscoveryString(PluginModel pluginModel, ReadOnlyCollection <ConnectorModel> inputs, ReadOnlyCollection <ConnectorModel> outputs, TaskPaneAttribute[] taskPaneAttributes)
        {
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.AppendFormat("{{\"name\":\"{0}\", \"type\":\"{1}\"", pluginModel.GetName(), pluginModel.Plugin.GetType().FullName);

            if (inputs.Count > 0)
            {
                stringBuilder.AppendFormat(",\"inputs\":[");
                int counter = 0;
                foreach (var input in inputs)
                {
                    counter++;
                    stringBuilder.AppendFormat("{{\"name\":\"{0}\",\"type\":\"{1}\"}}", input.GetName(), input.ConnectorType.FullName);
                    if (counter < inputs.Count)
                    {
                        stringBuilder.Append(",");
                    }
                }
                stringBuilder.AppendFormat("]");
            }
            if (outputs.Count > 0)
            {
                stringBuilder.AppendFormat(",\"outputs\":[");
                int counter = 0;
                foreach (var output in outputs)
                {
                    counter++;
                    stringBuilder.AppendFormat("{{\"name\":\"{0}\",\"type\":\"{1}\"}}", output.GetName(), output.ConnectorType.FullName);
                    if (counter < outputs.Count)
                    {
                        stringBuilder.Append(",");
                    }
                }
                stringBuilder.AppendFormat("]");
            }
            if (taskPaneAttributes != null && taskPaneAttributes.Length > 0)
            {
                stringBuilder.AppendFormat(",\"settings\":[");
                int counter = 0;
                foreach (var taskPaneAttribute in taskPaneAttributes)
                {
                    counter++;
                    stringBuilder.AppendFormat("{{\"name\":\"{0}\",\"type\":\"{1}\"}}", taskPaneAttribute.PropertyName, taskPaneAttribute.PropertyInfo.PropertyType.FullName);
                    if (counter < taskPaneAttributes.Length)
                    {
                        stringBuilder.Append(",");
                    }
                }
                stringBuilder.AppendFormat("]");
            }
            stringBuilder.Append("}");
            return(stringBuilder.ToString());
        }
Esempio n. 25
0
        private async Task <IActionResult> Create([Bind("NomePlugin,AutorPlugin,VersaoPlugin,TipoPlugin,PrecoPlugin,DescricaoPlugin,ImagemPadraoPersonalizada,Id")] PluginModel pluginModel)
        {
            if (ModelState.IsValid)
            {
                _context.Add(pluginModel);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(pluginModel));
        }
        /// <summary>
        /// Prepare plugin model properties of the installed plugin
        /// </summary>
        /// <param name="model">Plugin model</param>
        /// <param name="plugin">Plugin</param>
        protected virtual void PrepareInstalledPluginModel(PluginModel model, IPlugin plugin)
        {
            if (model == null)
            {
                throw new ArgumentNullException(nameof(model));
            }

            if (plugin == null)
            {
                throw new ArgumentNullException(nameof(plugin));
            }

            //prepare configuration URL
            model.ConfigurationUrl = plugin.GetConfigurationPageUrl();

            //prepare enabled/disabled (only for some plugin types)
            model.CanChangeEnabled = true;
            switch (plugin)
            {
            case IPaymentMethod paymentMethod:
                model.IsEnabled = _paymentPluginManager.IsPluginActive(paymentMethod);
                break;

            case IShippingRateComputationMethod shippingRateComputationMethod:
                model.IsEnabled = _shippingPluginManager.IsPluginActive(shippingRateComputationMethod);
                break;

            case IPickupPointProvider pickupPointProvider:
                model.IsEnabled = _pickupPluginManager.IsPluginActive(pickupPointProvider);
                break;

            case ITaxProvider taxProvider:
                model.IsEnabled = _taxPluginManager.IsPluginActive(taxProvider);
                break;

            case IExternalAuthenticationMethod externalAuthenticationMethod:
                model.IsEnabled = _authenticationPluginManager.IsPluginActive(externalAuthenticationMethod);
                break;

            case IMultiFactorAuthenticationMethod multiFactorAuthenticationMethod:
                model.IsEnabled = _multiFactorAuthenticationPluginManager.IsPluginActive(multiFactorAuthenticationMethod);
                break;

            case IWidgetPlugin widgetPlugin:
                model.IsEnabled = _widgetPluginManager.IsPluginActive(widgetPlugin);
                break;

            default:
                model.CanChangeEnabled = false;
                break;
            }
        }
Esempio n. 27
0
        public ActionResult Edit(string systemName, PluginModel model)
        {
            PluginInfo pluginInfo = AdminPlugins.GetPluginBySystemName(systemName);

            if (pluginInfo == null)
            {
                return(PromptView("插件不存在"));
            }

            AdminPlugins.Edit(systemName, model.FriendlyName, model.Description, model.DisplayOrder);
            AddMallAdminLog("编辑插件", "编辑插件,插件为:" + systemName);
            return(PromptView("插件编辑成功"));
        }
Esempio n. 28
0
        /// <summary>
        /// 下载xml文件
        /// </summary>
        private void DownloadUpdateXml()
        {
            var tip = new PluginModel("Downloading update xml...");

            _gridViewAvailable.DataStore = new List <PluginModel> {
                tip
            };

            var client = new WebClient();

            client.DownloadFileCompleted += client_DownloadFileCompleted;
            client.DownloadFileAsync(new Uri(_updateXmlUrl), _updateXmlPath);
        }
Esempio n. 29
0
        public void SetPluginModel(PluginModel pModel)
        {
            lock (lckPModel)
            {
                this.pModel = pModel;
                enabled     = pModel.Enabled;

                lock (lckHelper)
                {
                    string s = "Data Source=" + pModel.DesIP + "," + pModel.DesPort + "\\" + pModel.DesInstance + ";Initial Catalog=" + pModel.DesCatalog + ";uid=" + pModel.DesUser + ";pwd=" + pModel.DesPwd;
                    sqlHelper = new SqlHelper(s);
                }
            }
        }
Esempio n. 30
0
        public void SetPluginModel(PluginModel pModel)
        {
            lock (lckPModel)
            {
                this.pModel = pModel;
                enabled     = pModel.Enabled;

                lock (lckHelper)
                {
                    string s = string.Format("Data Source={0},{1}\\{2};Initial Catalog={3};uid={4};pwd={5}", pModel.DesIP, pModel.DesPort, pModel.DesInstance, pModel.DesCatalog, pModel.DesUser, pModel.DesPwd);
                    sqlHelper = new SqlHelper(s);
                }
            }
        }
Esempio n. 31
0
        public ActionResult EditPopup(string btnId, string formId, PluginModel model) {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManagePlugins))
                return AccessDeniedView();

            var pluginDescriptor = _pluginFinder.GetPluginDescriptorBySystemName(model.SystemName, LoadPluginsMode.All);
            if (pluginDescriptor == null)
                //No plugin found with the specified id
                return RedirectToAction("List");

            if (ModelState.IsValid) {
                //we allow editing of 'friendly name', 'display order', store mappings
                pluginDescriptor.FriendlyName = model.FriendlyName;
                pluginDescriptor.DisplayOrder = model.DisplayOrder;
                pluginDescriptor.LimitedToStores.Clear();
                if (model.LimitedToStores && model.SelectedStoreIds != null) {
                    pluginDescriptor.LimitedToStores = model.SelectedStoreIds.ToList();
                }
                PluginFileParser.SavePluginDescriptionFile(pluginDescriptor);
                //reset plugin cache
                _pluginFinder.ReloadPlugins();
                //locales
                foreach (var localized in model.Locales) {
                    pluginDescriptor.Instance().SaveLocalizedFriendlyName(_localizationService, localized.LanguageId, localized.FriendlyName);
                }
                //enabled/disabled
                if (pluginDescriptor.Installed) {

                }

                ViewBag.RefreshPage = true;
                ViewBag.btnId = btnId;
                ViewBag.formId = formId;
                return View(model);
            }

            //If we got this far, something failed, redisplay form
            return View(model);
        }
        public ActionResult EditPopup(string btnId, string formId, PluginModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManagePlugins))
                return AccessDeniedView();

            var pluginDescriptor = _pluginFinder.GetPluginDescriptorBySystemName(model.SystemName, false);
            if (pluginDescriptor == null)
                return RedirectToAction("List");

            if (ModelState.IsValid)
            {
                pluginDescriptor.FriendlyName = model.FriendlyName;
				pluginDescriptor.Description = model.Description;
                pluginDescriptor.DisplayOrder = model.DisplayOrder;

                PluginFileParser.SavePluginDescriptionFile(pluginDescriptor);

				string settingKey = pluginDescriptor.GetSettingKey("LimitedToStores");
				if (model.LimitedToStores && model.SelectedStoreIds != null && model.SelectedStoreIds.Count() > 0)
					_settingService.SetSetting<string>(settingKey, string.Join(",", model.SelectedStoreIds));
				else
					_settingService.DeleteSetting(settingKey);

                // reset plugin and string resources cache
                _pluginFinder.ReloadPlugins();
				_localizationService.ClearCache();

				var pluginInstance = pluginDescriptor.Instance();

				foreach (var localized in model.Locales)
				{
					pluginInstance.SaveLocalizedValue(_localizationService, localized.LanguageId, "FriendlyName", localized.FriendlyName);
					pluginInstance.SaveLocalizedValue(_localizationService, localized.LanguageId, "Description", localized.Description);
				}

                //enabled/disabled
                if (pluginDescriptor.Installed)
                {
                    if (pluginInstance is IPaymentMethod)
                    {
                        //payment plugin
                        var pm = (IPaymentMethod)pluginInstance;
                        if (pm.IsPaymentMethodActive(_paymentSettings))
                        {
                            if (!model.IsEnabled)
                            {
                                //mark as disabled
                                _paymentSettings.ActivePaymentMethodSystemNames.Remove(pm.PluginDescriptor.SystemName);
                                _settingService.SaveSetting(_paymentSettings);
                            }
                        }
                        else
                        {
                            if (model.IsEnabled)
                            {
                                //mark as active
                                _paymentSettings.ActivePaymentMethodSystemNames.Add(pm.PluginDescriptor.SystemName);
                                _settingService.SaveSetting(_paymentSettings);
                            }
                        }
                    }
                    else if (pluginInstance is IShippingRateComputationMethod)
                    {
                        //shipping rate computation method
                        var srcm = (IShippingRateComputationMethod)pluginInstance;
                        if (srcm.IsShippingRateComputationMethodActive(_shippingSettings))
                        {
                            if (!model.IsEnabled)
                            {
                                //mark as disabled
                                _shippingSettings.ActiveShippingRateComputationMethodSystemNames.Remove(srcm.PluginDescriptor.SystemName);
                                _settingService.SaveSetting(_shippingSettings);
                            }
                        }
                        else
                        {
                            if (model.IsEnabled)
                            {
                                //mark as active
                                _shippingSettings.ActiveShippingRateComputationMethodSystemNames.Add(srcm.PluginDescriptor.SystemName);
                                _settingService.SaveSetting(_shippingSettings);
                            }
                        }
                    }
                    else if (pluginInstance is ITaxProvider)
                    {
                        //tax provider
                        if (model.IsEnabled)
                        {
                            _taxSettings.ActiveTaxProviderSystemName = model.SystemName;
                            _settingService.SaveSetting(_taxSettings);
                        }
                        else
                        {
                            _taxSettings.ActiveTaxProviderSystemName = "";
                            _settingService.SaveSetting(_taxSettings);
                        }
                    }
                    else if (pluginInstance is IExternalAuthenticationMethod)
                    {
                        //external auth method
                        var eam = (IExternalAuthenticationMethod)pluginInstance;
                        if (eam.IsMethodActive(_externalAuthenticationSettings))
                        {
                            if (!model.IsEnabled)
                            {
                                //mark as disabled
                                _externalAuthenticationSettings.ActiveAuthenticationMethodSystemNames.Remove(eam.PluginDescriptor.SystemName);
                                _settingService.SaveSetting(_externalAuthenticationSettings);
                            }
                        }
                        else
                        {
                            if (model.IsEnabled)
                            {
                                //mark as active
                                _externalAuthenticationSettings.ActiveAuthenticationMethodSystemNames.Add(eam.PluginDescriptor.SystemName);
                                _settingService.SaveSetting(_externalAuthenticationSettings);
                            }
                        }
                    }
                    else if (pluginInstance is IWidgetPlugin)
                    {
                        //Misc plugins
                        var widget = (IWidgetPlugin)pluginInstance;
                        if (widget.IsWidgetActive(_widgetSettings))
                        {
                            if (!model.IsEnabled)
                            {
                                //mark as disabled
                                _widgetSettings.ActiveWidgetSystemNames.Remove(widget.PluginDescriptor.SystemName);
                                _settingService.SaveSetting(_widgetSettings);
                            }
                        }
                        else
                        {
                            if (model.IsEnabled)
                            {
                                //mark as active
                                _widgetSettings.ActiveWidgetSystemNames.Add(widget.PluginDescriptor.SystemName);
                                _settingService.SaveSetting(_widgetSettings);
                            }
                        }
                    }
                }

                ViewBag.RefreshPage = true;
                ViewBag.btnId = btnId;
                ViewBag.formId = formId;
                return View(model);
            }

            //If we got this far, something failed, redisplay form
            return View(model);
        }
Esempio n. 33
0
        protected PluginModel PreparePluginModel(PluginDescriptor pluginDescriptor)
        {
            var pluginModel = new PluginModel
            {
                Author = pluginDescriptor.Author,
                DisplayOrder = pluginDescriptor.DisplayOrder,
                FriendlyName = pluginDescriptor.FriendlyName,
                Group = pluginDescriptor.Group,
                Installed = pluginDescriptor.Installed,
                SystemName = pluginDescriptor.SystemName,
                Version = pluginDescriptor.Version
            };

            //locales
            AddLocales(_languageService, pluginModel.Locales, (locale, languageId) =>
            {
                locale.FriendlyName = pluginDescriptor.Instance().GetLocalizedFriendlyName(_localizationService, languageId, false);
            });

            if (pluginDescriptor.Installed)
            {
                //specify configuration URL only when a plugin is already installed

                //plugins do not provide a general URL for configuration
                //because some of them have some custom URLs for configuration
                //for example, discount requirement plugins require additional parameters and attached to a certain discount
                var pluginInstance = pluginDescriptor.Instance();
                string configurationUrl = null;
                if (pluginInstance is IExternalAuthenticationMethod)
                {
                    //external auth method
                    configurationUrl = Url.Action("ConfigureMethod", "ExternalAuthentication", new { systemName = pluginDescriptor.SystemName });
                }
                else if (pluginInstance is IWidgetPlugin)
                {
                    //Misc plugins
                    configurationUrl = Url.Action("ConfigureWidget", "Widget", new { systemName = pluginDescriptor.SystemName });
                }
                else if (pluginInstance is IMiscPlugin)
                {
                    //Misc plugins
                    configurationUrl = Url.Action("ConfigureMiscPlugin", "Plugin", new { systemName = pluginDescriptor.SystemName });
                }
                pluginModel.ConfigurationUrl = configurationUrl;

                //enabled/disabled (only for some plugin types)
                if (pluginInstance is IExternalAuthenticationMethod)
                {
                    //external auth method
                    pluginModel.CanChangeEnabled = true;
                    pluginModel.IsEnabled = ((IExternalAuthenticationMethod)pluginInstance).IsMethodActive(_externalAuthenticationSettings);
                }
                else if (pluginInstance is IWidgetPlugin)
                {
                    //Misc plugins
                    pluginModel.CanChangeEnabled = true;
                    pluginModel.IsEnabled = ((IWidgetPlugin)pluginInstance).IsWidgetActive(_widgetSettings);
                }

            }
            return pluginModel;
        }
Esempio n. 34
0
        public ActionResult EditPopup(string btnId, string formId, PluginModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManagePlugins))
                return AccessDeniedView();

            var pluginDescriptor = _pluginFinder.GetPluginDescriptorBySystemName(model.SystemName, false);
            if (pluginDescriptor == null)
                //No plugin found with the specified id
                return RedirectToAction("List");

            if (ModelState.IsValid)
            {
                //we allow editing of 'friendly name' and 'display order'
                pluginDescriptor.FriendlyName = model.FriendlyName;
                pluginDescriptor.DisplayOrder = model.DisplayOrder;
                PluginFileParser.SavePluginDescriptionFile(pluginDescriptor);
                //reset plugin cache
                _pluginFinder.ReloadPlugins();
                //locales
                foreach (var localized in model.Locales)
                {
                    pluginDescriptor.Instance().SaveLocalizedFriendlyName(_localizationService, localized.LanguageId, localized.FriendlyName);
                }
                //enabled/disabled
                if (pluginDescriptor.Installed)
                {
                    var pluginInstance = pluginDescriptor.Instance();

                    if (pluginInstance is IExternalAuthenticationMethod)
                    {
                        //external auth method
                        var eam = (IExternalAuthenticationMethod)pluginInstance;
                        if (eam.IsMethodActive(_externalAuthenticationSettings))
                        {
                            if (!model.IsEnabled)
                            {
                                //mark as disabled
                                _externalAuthenticationSettings.ActiveAuthenticationMethodSystemNames.Remove(eam.PluginDescriptor.SystemName);
                                _settingService.SaveSetting(_externalAuthenticationSettings);
                            }
                        }
                        else
                        {
                            if (model.IsEnabled)
                            {
                                //mark as active
                                _externalAuthenticationSettings.ActiveAuthenticationMethodSystemNames.Add(eam.PluginDescriptor.SystemName);
                                _settingService.SaveSetting(_externalAuthenticationSettings);
                            }
                        }
                    }
                    else if (pluginInstance is IWidgetPlugin)
                    {
                        //Misc plugins
                        var widget = (IWidgetPlugin)pluginInstance;
                        if (widget.IsWidgetActive(_widgetSettings))
                        {
                            if (!model.IsEnabled)
                            {
                                //mark as disabled
                                _widgetSettings.ActiveWidgetSystemNames.Remove(widget.PluginDescriptor.SystemName);
                                _settingService.SaveSetting(_widgetSettings);
                            }
                        }
                        else
                        {
                            if (model.IsEnabled)
                            {
                                //mark as active
                                _widgetSettings.ActiveWidgetSystemNames.Add(widget.PluginDescriptor.SystemName);
                                _settingService.SaveSetting(_widgetSettings);
                            }
                        }
                    }
                }

                ViewBag.RefreshPage = true;
                ViewBag.btnId = btnId;
                ViewBag.formId = formId;
                return View(model);
            }

            //If we got this far, something failed, redisplay form
            return View(model);
        }