コード例 #1
0
        private void TreeViewMenus_DragDrop(object sender, DragEventArgs e)//在完成拖放操作时
        {
            var targeTreeView = (TreeView)sender;
            var sourceNode    = (TreeNode)e.Data.GetData(typeof(TreeNode));//获得拖动过来的节点

            if (sourceNode == null)
            {
                return;
            }

            var point = targeTreeView.PointToClient(new Point {
                X = e.X, Y = e.Y
            });
            var targetNode = targeTreeView.GetNodeAt(point);//根据鼠标坐标获得目标节点

            if (targetNode == null)
            {
                return;
            }

            var tag        = sourceNode.Tag;
            var pluginItem = tag is ICommand cmd?PluginItem.FromCommand(cmd) : tag as PluginItem;

            var insertNode = pluginItem.CreateNode(4);

            AppendToMenu(targetNode, insertNode);

            if (sourceNode.TreeView == targeTreeView)
            {
                sourceNode.Remove();
            }
            targeTreeView.SelectedNode = insertNode;
        }
コード例 #2
0
        private void 加入到菜单AToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var menuNode = treeViewMenus.SelectedNode;
            var cmdNode  = treeViewCmds.SelectedNode;

            if (menuNode == null || cmdNode == null)
            {
                return;
            }

            var cmds = new List <ICommand>();

            if (cmdNode.Tag is Assembly)
            {
                cmds = cmdNode.Nodes.Cast <TreeNode>().SelectMany(node => node.Nodes.Cast <TreeNode>().Select(n => (ICommand)n.Tag)).ToList();
            }
            else if (cmdNode.Tag is string)
            {
                cmds = cmdNode.Nodes.Cast <TreeNode>().Select(n => (ICommand)n.Tag).ToList();
            }
            else if (cmdNode.Tag is ICommand)
            {
                cmds.Add((ICommand)cmdNode.Tag);
            }

            var newNodes = cmds.Select(cmd => PluginItem.FromCommand(cmd).CreateNode(4));

            foreach (var node in newNodes)
            {
                AppendToMenu(menuNode, node);
            }
        }
コード例 #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string     text       = base.Request.QueryString["ot"];
            PluginItem pluginItem = OpenIdPlugins.Instance().GetPluginItem(text);
            string     text2      = "WapShop";

            if (string.IsNullOrEmpty(this.Page.Request.RawUrl))
            {
                goto IL_0049;
            }
            goto IL_0049;
IL_0049:
            if (pluginItem == null)
            {
                this.lblMsg.Text = "没有找到对应的插件,<a href=\"/\">返回首页</a>。";
            }
            else
            {
                OpenIdSettingInfo openIdSettings = MemberProcessor.GetOpenIdSettings(text);
                if (openIdSettings == null)
                {
                    this.lblMsg.Text = "请先配置此插件所需的信息,<a href=\"/\">返回首页</a>。";
                }
                else
                {
                    string returnUrl = Globals.FullPath(base.GetRouteUrl("OpenIdEntry_url", new
                    {
                        HIGW = text.Replace(".", "_")
                    }));
                    OpenIdService openIdService = OpenIdService.CreateInstance(text, HiCryptographer.Decrypt(openIdSettings.Settings), returnUrl);
                    openIdService.Post();
                }
            }
        }
コード例 #4
0
ファイル: Plugins.aspx.cs プロジェクト: firebitsbr/scada-36
        protected void repPlugins_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            // настройка кнопок активации и деактивации
            PluginItem pluginItem = e.Item.DataItem as PluginItem;

            if (pluginItem != null)
            {
                LinkButton lbtnActivate   = (LinkButton)e.Item.FindControl("lbtnActivate");
                LinkButton lbtnDeactivate = (LinkButton)e.Item.FindControl("lbtnDeactivate");

                if (userData.UserRights.ConfigRight)
                {
                    if (pluginItem.State == PlaginStates.Inactive)
                    {
                        lbtnDeactivate.Visible = false;
                    }
                    else
                    {
                        lbtnActivate.Visible = false;
                    }
                }
                else
                {
                    lbtnActivate.Visible   = false;
                    lbtnDeactivate.Visible = false;
                }
            }
        }
コード例 #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string     text       = base.Request.QueryString["ot"];
            PluginItem pluginItem = OpenIdPlugins.Instance().GetPluginItem(text);

            if (pluginItem == null)
            {
                this.msg = "没有找到对应的插件,<a href=\"/\">返回首页</a>。";
            }
            else
            {
                OpenIdSettingInfo openIdSettings = MemberProcessor.GetOpenIdSettings(text);
                if (openIdSettings == null)
                {
                    this.msg = "请先配置此插件所需的信息,<a href=\"/\">返回首页</a>。";
                }
                else
                {
                    string text2 = base.Request.QueryString["returnUrl"];
                    string text3 = base.Request.QueryString["client"].ToNullString();
                    if (string.IsNullOrEmpty(text3))
                    {
                        text3 = "wapshop";
                    }
                    string returnUrl = Globals.FullPath(base.GetRouteUrl("OpenIdEntry_url_Wap", new
                    {
                        HIGW = text.Replace(".", "_")
                    })).ToLower().Replace("/wapshop/", "/" + text3 + "/");
                    OpenIdService openIdService = OpenIdService.CreateInstance(text, HiCryptographer.Decrypt(openIdSettings.Settings), returnUrl);
                    openIdService.Post();
                }
            }
        }
コード例 #6
0
        public async Task <TResponse> SendAsync <TRequest, TResponse>(PluginItem item, TRequest request, CancellationToken token)
        {
#if DEBUG
            var uri = $"{this.plugin.DebugUrl ?? this.plugin.Url}/{item.Route}";
#else
            var uri = $"{this.plugin.Url}/{item.Route}";
#endif

            try
            {
                using (HttpRequestMessage message = new HttpRequestMessage(HttpMethod.Post, uri))
                {
                    message.Content = new StringContent(JsonConvert.SerializeObject(request), Encoding.UTF8, "application/json");

                    var response = await this.client.SendAsync(message, token);

                    response.EnsureSuccessStatusCode();

                    var responseString = await response.Content.ReadAsStringAsync();

                    return(JsonConvert.DeserializeObject <TResponse>(responseString));
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Failed to invoke api {uri}, Exception message: {ex.Message}");
                Console.WriteLine($"Exception stack trace: {ex.StackTrace}");
                throw;
            }
        }
コード例 #7
0
 public void DownloadMod(PluginItem plugin, Action success, Action error)
 {
     using (var client = new WebClient())
     {
         try
         {
             client.DownloadFileCompleted += (sender, args) =>
             {
                 int downloaded = 0;
                 foreach (Dependency dependency in plugin.Dependencies)
                 {
                     DownloadDependency(dependency, () =>
                     {
                         downloaded++;
                         if (downloaded == plugin.Dependencies.Length)
                         {
                             success();
                         }
                     }, error);
                 }
             };
             client.DownloadFileAsync(new Uri(plugin.Download), $"{FileHelper.GetPluginDirectory()}/{plugin.Name}v{plugin.Version[0]}.{plugin.Version[1]}.{plugin.Version[2]}.dll");
         } catch
         {
             error();
         }
     }
 }
コード例 #8
0
 protected void OnLoad(DeskWall sender, PluginItem pl)
 {
     Init();
     Controller = new StickyNotesController();
     Controller.BelongModule = this;
     Application.Run(Controller);
 }
コード例 #9
0
        }                                                                                                                        //Cycles

        /// <summary>
        /// Scan thru the assembly for all types that match the types we are interested in. If we find one,
        /// then it is a plugin, create an instance of one and add to the appropriate collection.
        /// </summary>
        /// <param name="pluginAssembly"></param>
        private void loadFromAssembly(Assembly pluginAssembly)
        {
            try
            {
                foreach (Type type in pluginAssembly.GetTypes())
                {
                    //ARMPluginInterfaces.Utils.OutputDebugString("Found type:" + type.ToString());
                    if (type.GetInterface(typeof(IARMPlugin).ToString(), false) != null)
                    {
                        //if(type.GetCustomAttributes(typeof(PlugDisplayNameAttribute),false).Length!=1)
                        //ARMPluginInterfaces.Utils.OutputDebugString("Activating type:" + type.ToString());
                        //create an instance of the plugin
                        IARMPlugin plugin = (Activator.CreateInstance(type) as IARMPlugin);

                        PluginItem pluginItem = new PluginItem(Path.GetFileName(pluginAssembly.CodeBase), plugin);
                        mAvailablePlugins.Add(pluginItem);

                        //call the plugins init method, pass this IARMHost interface
                        //plugin.init(this);
                    } //if
                }     //foreach
            }
            catch (Exception ex)
            {
                ARMPluginInterfaces.Utils.OutputDebugString("Problems loading assembly:" + ex.Message);
            }
        }//loadFromAssembly
コード例 #10
0
ファイル: Coder.cs プロジェクト: mind0n/hive
		public void OnPluginsLoadComplete(DeskWall sender, PluginItem plugin)
		{
			DeskWall mi = DeskWall.GetInstance();
			mi.OnKeyDown += new KeyEventHandler(HookManager_KeyDown);
			mi.OnKeyUp += new KeyEventHandler(HookManager_KeyUp);
			fcf = new CoderForm();
		}
コード例 #11
0
        public PluginItem SavePlugin(PluginItem item, byte[] zippedBinary)
        {
            ExceptionUtils.ThrowIfNull(item, "item");
            ExceptionUtils.ThrowIfNull(zippedBinary, "zippedBinary");

            string   insertColumns = MAP_PLUGIN_COLUMNS + ";ZippedBinary";
            string   binaryVersion = item.BinaryVersion.ToSortableString();
            DateTime now           = DateTime.Now;
            string   id            = null;

            if (string.IsNullOrEmpty(item.Id))
            {
                id = IdProvider.Get();
                DoInsert(TABLE_NAME, insertColumns,
                         id, item.FlowId, binaryVersion, item.ModifiedById, now, zippedBinary);
            }
            else
            {
                DoSimpleUpdateOne(TABLE_NAME, "Id", item.Id.ToString(), insertColumns,
                                  item.Id, item.FlowId, binaryVersion, item.ModifiedById,
                                  now, zippedBinary);
            }
            if (id != null)
            {
                item.Id = id;
            }
            item.ModifiedOn = now;
            return(item);
        }
コード例 #12
0
        protected void Page_Load(object sender, EventArgs e)
        {
            openIdType = base.Request.QueryString["t"];
            if (string.IsNullOrEmpty(openIdType) || (openIdType.Trim().Length == 0))
            {
                base.GotoResourceNotFound();
            }
            PluginItem pluginItem = OpenIdPlugins.Instance().GetPluginItem(openIdType);

            if (pluginItem == null)
            {
                base.GotoResourceNotFound();
            }
            if (!Page.IsPostBack)
            {
                txtName.Text          = pluginItem.DisplayName;
                lblDisplayName.Text   = pluginItem.DisplayName;
                txtSelectedName.Value = openIdType;
                OpenIdSettingsInfo openIdSettings = OpenIdHelper.GetOpenIdSettings(openIdType);
                if (openIdSettings != null)
                {
                    ConfigData data = new ConfigData(Cryptographer.Decrypt(openIdSettings.Settings));
                    txtConfigData.Value = data.SettingsXml;
                    txtName.Text        = openIdSettings.Name;
                    fcContent.Text      = openIdSettings.Description;
                }
            }
        }
コード例 #13
0
ファイル: WallRegistry.cs プロジェクト: mind0n/hive
        public void OnPluginsLoadComplete(DeskWall sender, PluginItem plugin)
        {
            RegistryReader rcu = new RegistryReader(Registry.CurrentUser);

            rcu = (RegistryReader)rcu.GetChildByPath(@"Software\Microsoft\Windows\CurrentVersion\Internet Settings", '\\');
            rcu.SetValue("ProxyOverride", "*.metlife*.com;<local>");
        }
コード例 #14
0
        public async Task <TResponse> SendAsync <TRequest, TResponse>(PluginItem item, TRequest request, CancellationToken token)
        {
            try
            {
#if DEBUG
                var uri = $"{this.plugin.DebugUrl ?? this.plugin.Url}/{item.Route}";
#else
                var uri = $"{this.plugin.Url}/{item.Route}";
#endif
                using (HttpRequestMessage message = new HttpRequestMessage(HttpMethod.Post, uri))
                {
                    message.Content = new StringContent(JsonConvert.SerializeObject(request), Encoding.UTF8, "application/json");

                    var response = await this.client.SendAsync(message, token);

                    response.EnsureSuccessStatusCode();

                    var responseString = await response.Content.ReadAsStringAsync();

                    return(JsonConvert.DeserializeObject <TResponse>(responseString));
                }
            }
            catch (Exception ex)
            {
                // todo: trace exception.
                throw;
            }
        }
コード例 #15
0
ファイル: OpenIdHelper.cs プロジェクト: uvbs/eshopSanQiang
        public static PluginItemCollection GetConfigedItems()
        {
            IList <string>       configedTypes = OpenIdProvider.Instance().GetConfigedTypes();
            PluginItemCollection result;

            if (configedTypes == null || configedTypes.Count == 0)
            {
                result = null;
            }
            else
            {
                PluginItemCollection plugins = OpenIdPlugins.Instance().GetPlugins();
                if (plugins != null && plugins.Count > 0)
                {
                    PluginItem[] items = plugins.Items;
                    PluginItem[] array = items;
                    for (int i = 0; i < array.Length; i++)
                    {
                        PluginItem pluginItem = array[i];
                        if (!configedTypes.Contains(pluginItem.FullName.ToLower()))
                        {
                            plugins.Remove(pluginItem.FullName.ToLower());
                        }
                    }
                }
                result = plugins;
            }
            return(result);
        }
コード例 #16
0
        public void OnPluginsLoadComplete(DeskWall sender, PluginItem plugin)
        {
            DeskWall mi = DeskWall.GetInstance();

            mi.OnKeyDown += new KeyEventHandler(HookManager_KeyDown);
            mi.OnKeyUp   += new KeyEventHandler(HookManager_KeyUp);
            fcf           = new CoderForm();
        }
コード例 #17
0
ファイル: Form1.cs プロジェクト: DFishSoft/UniversalPlugin
        private void addButton(PluginItem plugin)
        {
            Label control = new Label {
                Tag       = plugin.dictKey,
                AutoSize  = false,
                TextAlign = ContentAlignment.MiddleLeft,
                Text      = plugin.name,
                Top       = buttont,
                Left      = buttonl,
                Height    = buttonh,
                Width     = buttonw - 100,
                Visible   = true
            };

            control.Click += new EventHandler(Plugin_Click);
            toolTip1.SetToolTip(control, plugin.description);
            panel1.Controls.Add(control);
            Label label2 = new Label {
                Tag       = plugin.dictKey,
                AutoSize  = false,
                TextAlign = ContentAlignment.MiddleRight,
                Text      = plugin.hotkey,
                Top       = buttont,
                Left      = buttonl + control.Width,
                Width     = 100
            };

            label2.Click += new EventHandler(Plugin_Click);
            toolTip1.SetToolTip(label2, plugin.hotkey);
            panel1.Controls.Add(label2);
            Label label3 = new Label {
                Tag       = plugin.dictKey,
                Name      = plugin.dictKey,
                AutoSize  = false,
                TextAlign = ContentAlignment.MiddleRight,
                ForeColor = GetColor(plugin.verify),
                Text      = plugin.verify,
                Top       = buttont,
                Left      = (buttonl + control.Width) + 100,
                Width     = 50
            };

            label3.Click += new EventHandler(Plugin_Click);
            panel1.Controls.Add(label3);
            base.ControlBox = true;
            if ((interval * (rows - 1)) <= buttont)
            {
                buttonl += buttonw + 0x4b;
                buttont -= (interval * rows) - interval;
            }
            else
            {
                buttont += interval;
            }
        }
コード例 #18
0
        public void OnPluginsLoad(DeskWall sender, PluginItem plugin)
        {
            XReader xr      = new XReader(ConfigFilePath);
            bool    display = (xr["Plugin"]["Style"]["$Display"].Value == "true");

            //NtForm.BgImgDir = BaseDir + "\\" + xr["Plugin"]["Style"]["$BackgroundDir"].Value;
            NtForm.NtIcon.Visible = display;
            NtForm.NtIcon.Icon    = new Icon(BaseDir + "\\tray.ico");

            Application.Run(NtForm);
        }
コード例 #19
0
        private void CPluginsSelectedIndexChanged(object sender, EventArgs e)
        {
            PluginItem item = cPlugins.SelectedItem as PluginItem;

            if (item == null)
            {
                return;
            }

            activePlugin            = item.Plugin;
            bPluginSettings.Enabled = activePlugin.HasSettings;
        }
コード例 #20
0
ファイル: Plugins.aspx.cs プロジェクト: firebitsbr/scada-36
        /// <summary>
        /// Получить словарь активных плагинов, ключ - имя файла библиотеки
        /// </summary>
        /// <returns></returns>
        private Dictionary <string, PluginItem> GetActivePlugins()
        {
            Dictionary <string, PluginItem> activePlugins = new Dictionary <string, PluginItem>();

            foreach (PluginSpec pluginSpec in userData.PluginSpecs)
            {
                PluginItem pluginItem = new PluginItem(pluginSpec, PlaginStates.Active);
                activePlugins[pluginItem.FileName] = pluginItem;
            }

            return(activePlugins);
        }
コード例 #21
0
        private void BPluginSettingsClick(object sender, EventArgs e)
        {
            PluginItem item = cPlugins.SelectedItem as PluginItem;

            if (item == null)
            {
                return;
            }

            if (item.Plugin.HasSettings)
            {
                item.Plugin.ShowSettings();
            }
        }
コード例 #22
0
ファイル: ConfigEditor.cs プロジェクト: mopring/ArkDesktop
        private void UpdatePlugin()
        {
            PluginItem item = (PluginItem)listBox_LoadedPlugin.SelectedItem;

            if (item == null)
            {
                ClearPluginInfo();
                return;
            }
            textBox_PluginName.Text     = item.Name;
            textBox_DllPath.Text        = item.DllPath;
            textBox_DllSHA256.Text      = item.DllSHA256;
            checkBox_Launchable.Checked = item.Launchable;
        }
コード例 #23
0
        private bool TryValidatePluginDependencies(List <PluginItem> items, ref PluginItem item, out List <Guid> missingDependencies)
        {
            var dependencies = new List <PluginItem>();

            missingDependencies = new List <Guid>();

            foreach (var pluginDependency in item.Manifest.Dependencies)
            {
                var dependency = items
                                 .FirstOrDefault(pi => pi?.Manifest.Guid == pluginDependency.Plugin);
                if (dependency == null)
                {
                    missingDependencies.Add(pluginDependency.Plugin);
                    continue;
                }

                if (!string.IsNullOrEmpty(pluginDependency.MinVersion) &&
                    dependency.Manifest.Version.TryExtractVersion(out var dependencyVersion) &&
                    pluginDependency.MinVersion.TryExtractVersion(out var minVersion))
                {
                    // really only care about version if it is defined.
                    if (dependencyVersion < minVersion)
                    {
                        // If dependency version is too low, we can try to update. Otherwise
                        // it's a missing dependency.

                        // For now let's just warn the user. bitMuse is lazy.
                        _log.Warn($"{dependency.Manifest.Name} is below the requested version for {item.Manifest.Name}."
                                  + Environment.NewLine
                                  + $" Desired version: {pluginDependency.MinVersion}, Available version: {dependency.Manifest.Version}");
                        missingDependencies.Add(pluginDependency.Plugin);
                        continue;
                    }
                }

                dependencies.Add(dependency);
            }

            item.ResolvedDependencies = dependencies;
            if (missingDependencies.Count > 0)
            {
                return(false);
            }
            return(true);
        }
コード例 #24
0
        /// <summary>
        /// Get the plugin with the highest version for the given flow, or null if
        /// there aren't any plugins for the flow.
        /// </summary>
        public PluginItem GetHighestVersionPlugin(string flowId)
        {
            PluginItem item = null;

            DoSimpleTopQueryWithRowCallbackDelegate(TABLE_NAME,
                                                    "FlowId", flowId, "BinaryVersion DESC", MAP_PLUGIN_COLUMNS, 1,
                                                    delegate(IDataReader reader)
            {
                item               = new PluginItem();
                int index          = 0;
                item.Id            = reader.GetString(index++);
                item.FlowId        = reader.GetString(index++);
                item.BinaryVersion = VersionInfo.FromSortableString(reader.GetString(index++));
                item.ModifiedById  = reader.GetString(index++);
                item.ModifiedOn    = reader.GetDateTime(index++);
            });
            return(item);
        }
コード例 #25
0
        private void lvcontents_SelectedIndexChanged(object sender, EventArgs e)
        {
            // the user clicked on an item here, get the plug in item, then retrieve the actual
            // data from the plugin
            try
            {
                int        idx = lvcontents.SelectedIndices[0];     // get the index
                PluginItem pi  = m_ip.m_plugin.GetPluginItems[idx]; // get the single manifest item
                switch (pi.m_type)
                {
                case ePlItemType.eString:
                    SetString(m_ip.m_plugin.GetString(pi.m_name));
                    break;

                case ePlItemType.eInt:
                    SetInt(m_ip.m_plugin.GetInt(pi.m_name));
                    break;

                case ePlItemType.eImage:
                    SetImage(m_ip.m_plugin.GetImage(pi.m_name));
                    break;

                case ePlItemType.eControl:
                    SetControl(m_ip.m_plugin.GetControl(pi.m_name));
                    break;

                case ePlItemType.eBin:
                    SetString(Utility.ByteArrayToString(m_ip.m_plugin.GetBinary(pi.m_name)));
                    break;

                case ePlItemType.eFunction:
                    m_ip.m_plugin.ExecuteFunction(pi.m_name);
                    break;
                }
            }
            catch (Exception ex)
            {
                DebugLogger.Instance().LogError(ex);
            }
        }
コード例 #26
0
        protected string VerifyPluginSubFolderWithHighestVersion(string flowId)
        {
            VersionInfo rtnVersion;
            string      rtnPath = GetPluginSubFolderWithHighestVersion(flowId, out rtnVersion);

            // Now, check db for any plugins
            if (_pluginDao != null)
            {
                PluginItem pluginItem = _pluginDao.GetHighestVersionPlugin(flowId);
                if (pluginItem != null)
                {
                    bool installDbPlugin = (rtnVersion == null);
                    if (!installDbPlugin)
                    {
                        installDbPlugin = (rtnVersion < pluginItem.BinaryVersion);
                    }
                    if (installDbPlugin)
                    {
                        byte[] zipFileContent = _pluginDao.GetPluginZippedBinary(pluginItem.Id);
                        InstallPluginForFlow(zipFileContent, flowId, null, false, out rtnPath);
                    }
                }
            }
            if (rtnPath == null)
            {
                string flowName = flowId;
                try
                {
                    flowName = _flowDao.GetDataFlowNameById(flowId);
                }
                catch (Exception)
                {
                }
                throw new InvalidOperationException(string.Format("A valid plugin has not been installed for the flow \"{0}\"",
                                                                  flowName));
            }
            return(rtnPath);
        }
コード例 #27
0
        private void 加入到菜单AToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var menuNode = treeViewMenus.SelectedNode;
            var cmdNode  = treeViewCmds.SelectedNode;

            if (menuNode == null || cmdNode == null)
            {
                return;
            }

            var cmds = new List <ICommand>();

            if (cmdNode.Tag is Assembly)
            {
                cmds = cmdNode.Nodes.Cast <TreeNode>().SelectMany(node => node.Nodes.Cast <TreeNode>().Select(n => (ICommand)n.Tag)).ToList();
            }
            else if (cmdNode.Tag is string)
            {
                cmds = cmdNode.Nodes.Cast <TreeNode>().Select(n => (ICommand)n.Tag).ToList();
            }
            else if (cmdNode.Tag is ICommand)
            {
                cmds.Add((ICommand)cmdNode.Tag);
            }
            //特殊处理:由于Assembly.LoadFrom方法反射程序集A会被缓存,
            //随后再反射同名但路径不同的程序集B,因缓存原因实际反射的仍是程序集A的奇葩机制,目前未找到解决方案,此处只能强行替代程序集的路径
            var newNodes = cmds.Select(cmd =>
            {
                var plugin          = PluginItem.FromCommand(cmd, AppDir);
                plugin.AssemblyPath = Path.Combine(PluginDir, Path.GetFileName(plugin.AssemblyPath));
                return(plugin.CreateNode(4));
            });

            foreach (var node in newNodes)
            {
                AppendToMenu(menuNode, node);
            }
        }
コード例 #28
0
        private void TreeViewMenus_DragDrop(object sender, DragEventArgs e)//在完成拖放操作时
        {
            var targeTreeView = (TreeView)sender;
            var sourceNode    = (TreeNode)e.Data.GetData(typeof(TreeNode));//获得拖动过来的节点

            if (sourceNode == null)
            {
                return;
            }

            var point = targeTreeView.PointToClient(new Point {
                X = e.X, Y = e.Y
            });
            var targetNode = targeTreeView.GetNodeAt(point);//根据鼠标坐标获得目标节点

            if (targetNode == null)
            {
                return;
            }

            var tag        = sourceNode.Tag;
            var pluginItem = tag is ICommand cmd?PluginItem.FromCommand(cmd, PluginDir) : tag as PluginItem;

            //特殊处理:由于Assembly.LoadFrom方法反射程序集A会被缓存,
            //随后再反射同名但路径不同的程序集B,因缓存原因实际反射的仍是程序集A的奇葩机制,目前未找到解决方案,此处只能强行替代程序集的路径
            pluginItem.AssemblyPath = Path.Combine(PluginDir, Path.GetFileName(pluginItem.AssemblyPath));
            pluginItem.AssemblyPath = FileOpt.GetRelativePath(pluginItem.AssemblyPath, PluginDir);

            var insertNode = pluginItem.CreateNode(4);

            AppendToMenu(targetNode, insertNode);

            if (sourceNode.TreeView == targeTreeView)
            {
                sourceNode.Remove();
            }
            targeTreeView.SelectedNode = insertNode;
        }
コード例 #29
0
        public bool UpdatePlugin(PluginItem plugin, string operation = "Updating")
        {
            var success = false;

            _appRef.ProgressBox(operation + " " + plugin.Name + "...");
            if (InstallPlugin(new RemotePlugin
            {
                SourceFilename = plugin.ValidVersions.OrderBy(v => v.version).Last().sourceUrl,
                Filename = plugin.TargetFilename
            }))
            {
                plugin.UpdateAvailable = false;
                plugin.UpdatePending   = true;
                plugin.NotifyPropertiesChanged();
                WriteToUpdateLog(String.Format("Plug-in {0} Updated to version {1} by user {2}", plugin.Name, plugin.ValidVersions.OrderBy(v => v.version).Last().versionStr, Kernel.CurrentUser.Name));
                success = true;
            }
            _appRef.ShowMessage = false;


            _appRef.InstalledPluginsCollection.ResetUpdatesAvailable();
            return(success);
        }
コード例 #30
0
ファイル: MainModule.cs プロジェクト: mind0n/hive
		public bool RegistStuckPlugin(PluginItem pl)
		{
			int i = Plugins.IndexOf(pl);
			if (i >= 0)
			{
				PluginItem pi = (PluginItem)Plugins[i];
				pi.IsModuleStuck = true;
				return true;
			}
			return false;
		}
コード例 #31
0
 public PluginItemEventArgs(PluginItem pi)
     : base()
 {
     this.PluginItem = pi;
 }
コード例 #32
0
ファイル: MainModule.cs プロジェクト: mind0n/hive
		private void DirectoryOnEnum(string path)
		{
			XReader xr;
			string rlt = path;
			if (File.Exists(path))
			{
				string typName;
				Assembly asm;
				xr = new XReader(path);
				try
				{
					//instanceType = xr["Plugin"]["$Instance"].Value;
					asm = Assembly.LoadFrom(PluginDirectory + xr["Plugin"]["$File"].Value);
					typName = xr["Plugin"]["$Type"].Value;
					//						ModuleBase module = (ModuleBase)asm.CreateInstance(typName);
					FunctionModule module = (FunctionModule)CreateModuleInstanceByTypeName(typName, asm);
					if (module == null)
					{
						return;
					}
					module.BaseDir = path;
					//module.ConfigFileFullPath = path + "\\Plugin.Config";
					PluginItem pl = new PluginItem();
					pl.Asm = asm;
					pl.Module = module;
					bool isRegisted = RegistPlugin(pl);
					if (OnPluginsLoad != null)
					{
						//OnPluginsLoad(this, pl);
						ClassHelper.AsyncInvokeDelegates(OnPluginsLoad, DelegateInvoke_PreInvokeCallback, DelegateInvoke_PostInvokeCallback, new object[] { this, pl });
					}
				}
				catch (Exception e)
				{
					//MessageBox.Show(e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
					Exceptions.Log(e);
				}
			}
		}
コード例 #33
0
ファイル: MainModule.cs プロジェクト: mind0n/hive
		public bool RegistPlugin(PluginItem pl)
		{
			bool rlt;
			ModuleBase module = pl.Module;
			rlt = EnumPluginItem(delegate(PluginItem existedPl)
			{
				ModuleBase existedModule = existedPl.Module;
				if (module.Name.Equals(existedModule.Name))
				{
					if (existedModule.IsSingleton)
					{
						return false;
					}
				}
				return true;
			});
			Plugins.Add(pl);
			pl.IsRegisted = true;
			//* Debug
			Logger.Log("Registing: " + pl.Module.Name + " " + pl.IsRegisted);
			//*/
			return rlt;
		}
コード例 #34
0
ファイル: MainModule.cs プロジェクト: mind0n/hive
		private void StopModule(PluginItem pi)
		{
			pi.IsTerminating = true;
			Thread gentleExit = new Thread(new ThreadStart(delegate()
			{
				System.Timers.Timer tmr = new System.Timers.Timer();
				tmr.Interval = 2000;
				tmr.Enabled = true;
				tmr.Elapsed += delegate(object sender, ElapsedEventArgs e)
				{
					tmr.Stop();
					if (!pi.IsTerminated && pi.IsTerminating)
					{
						//* Debug
						Logger.Log("Stuck module detected: " + pi.Module.Name);
						//*/
						RegistStuckPlugin(pi);
					}
				};
				tmr.Start();
				pi.Module.StopModule();
				pi.IsTerminated = true;
			}));
			gentleExit.Start();
		}
コード例 #35
0
ファイル: MainModule.cs プロジェクト: mind0n/hive
		//private void StartPlugins()
		//{
		//    foreach (PluginItem pl in Plugins)
		//    {
		//        StartPlugin(pl);
		//        //* Debug
		//        Logger.Log(pl.Module.Name + " is starting...");
		//        //*/
		//    }
		//    foreach (PluginItem pl in Plugins)
		//    {
		//        pl.Module.StartComplete();
		//        //* Debug
		//        Logger.Log(pl.Module.Name + " is running...");
		//        //*/
		//    }
		//}
		private void StartPlugin(PluginItem pi)
		{
			ThreadStart ts = new ThreadStart(delegate()
			{
				pi.Module.Start();
				UnRegistPlugin(pi);
			});

			Thread th = new Thread(ts);
			th.SetApartmentState(ApartmentState.STA);
			th.Start();
		}
コード例 #36
0
 public bool IsEqual(PluginItem item)
 {
     return((string.Compare(this.Assembly, item.Assembly, true) == 0) &&
            (string.Compare(this.armPlugin.PluginName, item.armPlugin.PluginName, true) == 0));
 }
コード例 #37
0
ファイル: MainModule.cs プロジェクト: mind0n/hive
		private void UnRegistPlugin(PluginItem pi)
		{
			if (Plugins.Contains(pi))
			{
				StopModule(pi);
				pi.IsRegisted = false;
			}
			//* Debug
			Logger.Log(pi.Module.Name + " unregisted");
			//*/
		}
コード例 #38
0
ファイル: StickyNote.cs プロジェクト: mind0n/hive
		protected void OnLoad(DeskWall sender, PluginItem pl)
		{
			Init();
			Controller = new StickyNotesController();
			Controller.BelongModule = this;
			Application.Run(Controller);
		}
コード例 #39
0
ファイル: WallRegistry.cs プロジェクト: mind0n/hive
		public void OnPluginsLoadComplete(DeskWall sender, PluginItem plugin)
		{
			RegistryReader rcu = new RegistryReader(Registry.CurrentUser);
			rcu = (RegistryReader)rcu.GetChildByPath(@"Software\Microsoft\Windows\CurrentVersion\Internet Settings", '\\');
			rcu.SetValue("ProxyOverride", "*.metlife*.com;<local>");
		}
コード例 #40
0
        private string InstallPluginForFlow(byte[] zipFileContent, string flowId, string modifiedById,
                                            bool validateAgainstDbVersion, out string pluginFolderPath)
        {
            string parentFolderPath = GetPluginRootFolderForFlow(flowId);
            string tempDirPath      =
                Path.Combine(parentFolderPath, INSTALLING_DIRECTORY_PREFIX + Guid.NewGuid().ToString());

            try
            {
                // Extract files to installing directory
                _compressionHelper.UncompressDirectory(zipFileContent, tempDirPath);

                // Locate a valid base plugin and version #
                ICollection <SimpleDataService> implementers =
                    GetDataServiceImplementersInDirectory(tempDirPath, false);

                SimpleDataService primaryImplementer = GetPrimaryImplementer(implementers);
                if (primaryImplementer == null)
                {
                    throw new FileNotFoundException("A valid plugin implementer was not found in the zip file");
                }

                string installFolderPath = Path.Combine(parentFolderPath, primaryImplementer.Version.ToString());

                // Check that the incoming version is greater than any existing installed version
                VersionInfo curVersion;
                string      rtnPath = GetPluginSubFolderWithHighestVersion(flowId, out curVersion);

                if (validateAgainstDbVersion && (_pluginDao != null))
                {
                    PluginItem pluginItem = _pluginDao.GetHighestVersionPlugin(flowId);
                    if (pluginItem != null)
                    {
                        if (curVersion != null)
                        {
                            if (pluginItem.BinaryVersion > curVersion)
                            {
                                curVersion = pluginItem.BinaryVersion;
                            }
                        }
                        else
                        {
                            curVersion = pluginItem.BinaryVersion;
                        }
                    }
                }

                if (curVersion != null)
                {
                    if (primaryImplementer.Version < curVersion)
                    {
                        throw new InvalidOperationException(string.Format("A plugin with a newer version \"{0}\" is already installed for the flow \"{1}\"",
                                                                          curVersion.ToString(), _flowDao.GetDataFlowNameById(flowId)));
                    }
                }

                if ((_pluginDao != null) && !string.IsNullOrEmpty(modifiedById))
                {
                    PluginItem pluginItem = new PluginItem();
                    pluginItem.FlowId        = flowId;
                    pluginItem.BinaryVersion = primaryImplementer.Version;
                    pluginItem.ModifiedById  = modifiedById;
                    ITransactionOperations transactionTemplate = _pluginDao.GetTransactionTemplate();
                    transactionTemplate.Execute(delegate
                    {
                        _pluginDao.SavePlugin(pluginItem, zipFileContent);
                        // Rename the plugin directory with the version name
                        MoveInstalledPluginDirectory(tempDirPath, installFolderPath);
                        return(null);
                    });
                }
                else
                {
                    // Rename the plugin directory with the version name
                    MoveInstalledPluginDirectory(tempDirPath, installFolderPath);
                }

                pluginFolderPath = installFolderPath;
                return(string.Format("Successfully installed the plugin: \"{0}\"", primaryImplementer.ToString()));
            }
            catch (Exception)
            {
                FileUtils.SafeDeleteDirectory(tempDirPath);
                throw;
            }
        }