Esempio n. 1
0
        /// <summary>
        /// 加载插件,之后必须重启中间件
        /// </summary>
        /// <param name="plugfile"></param>
        public static void AddPlugin(string pluginfile)
        {
            string filepath = AppGlobal.AppRootPath + pluginfile;//转为绝对路径

            ModulePlugin mp = new ModulePlugin();

            mp.appType = AppGlobal.appType;
            mp.LoadPlugin(filepath);

            PluginSysManage.AddPlugin(mp.plugin.name, mp.plugin.title, pluginfile, mp.plugin.version);
        }
Esempio n. 2
0
        //添加现有插件项目
        private void AddProject_Click(object sender, EventArgs e)
        {
            openPlugin.InitialDirectory = CommonHelper.PathCombine(CommonHelper.AppRootPath, "..\\");
            if (openPlugin.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                string file = openPlugin.FileName;
                PluginXmlManage.pluginfile = file;
                pluginxmlClass plugin = PluginXmlManage.getpluginclass();

                string pluginsyspath = null;
                string plugintype    = "";
                if (plugin.plugintype == "Web")
                {
                    plugintype    = "WebModulePlugin";
                    pluginsyspath = CommonHelper.WebPlatformPath + "\\Config\\pluginsys.xml";
                }
                else if (plugin.plugintype == "Winform")
                {
                    plugintype    = "WinformModulePlugin";
                    pluginsyspath = CommonHelper.WinformPlatformPath + "\\Config\\pluginsys.xml";
                }
                else if (plugin.plugintype == "Wcf")
                {
                    plugintype    = "WcfModulePlugin";
                    pluginsyspath = CommonHelper.WinformPlatformPath + "\\Config\\pluginsys.xml";
                }

                if (PluginSysManage.ContainsPlugin(plugintype, plugin.name) == false)
                {
                    PluginSysManage.pluginsysFile = pluginsyspath;
                    PluginSysManage.AddPlugin(plugintype, plugin.name, "ModulePlugin/" + plugin.name + "/plugin.xml", plugin.title, "1");

                    MessageBoxEx.Show("插件添加成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    LoadPluginData("-1");
                }
                else
                {
                    MessageBoxEx.Show("你选择的插件已添加!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
Esempio n. 3
0
        private void StartIssue(object sender, EventArgs e)
        {
            string mppath       = null;
            string moduleplugin = null;
            string pluginxml    = null;

            if (_plugintype == "WinformModulePlugin")
            {
                mppath       = CommonHelper.WinformPlatformPath + "\\ModulePlugin";
                moduleplugin = tbIssuePath.Text + "\\WinformPlatform\\ModulePlugin";
                pluginxml    = CommonHelper.WinformPlatformPath;
                CommonHelper.CopyFolder(CommonHelper.WinformPlatformPath, tbIssuePath.Text + "\\WinformPlatform", "ModulePlugin|WebPlugin");

                PluginSysManage.pluginsysFile = tbIssuePath.Text + "\\WinformPlatform\\Config\\pluginsys.xml";
            }
            else if (_plugintype == "WcfModulePlugin")
            {
                mppath       = CommonHelper.WinformPlatformPath + "\\ModulePlugin";
                moduleplugin = tbIssuePath.Text + "\\WinformPlatform\\ModulePlugin";
                pluginxml    = CommonHelper.WinformPlatformPath;
                CommonHelper.CopyFolder(CommonHelper.WinformPlatformPath, tbIssuePath.Text + "\\WinformPlatform", "ModulePlugin|WebPlugin");
                PluginSysManage.pluginsysFile = tbIssuePath.Text + "\\WinformPlatform\\Config\\pluginsys.xml";
            }
            else if (_plugintype == "WebModulePlugin")
            {
                mppath       = CommonHelper.WebPlatformPath + "\\ModulePlugin";
                moduleplugin = tbIssuePath.Text + "\\WebPlatform\\ModulePlugin";
                pluginxml    = CommonHelper.WebPlatformPath;
                CommonHelper.CopyFolder(CommonHelper.WebPlatformPath, tbIssuePath.Text + "\\WebPlatform", "ModulePlugin|WebPlugin");
                PluginSysManage.pluginsysFile = tbIssuePath.Text + "\\WebPlatform\\Config\\pluginsys.xml";
            }

            PluginSysManage.DeletePlugin("WebModulePlugin");
            PluginSysManage.DeletePlugin("WinformModulePlugin");
            PluginSysManage.DeletePlugin("WcfModulePlugin");

            for (int i = 0; i < list.Count; i++)
            {
                if (list[i].isdevelopment == "0")//插件包
                {
                    CommonHelper.CopyFolder(mppath + "\\" + list[i].name, moduleplugin + "\\" + list[i].name);
                }
                else
                {
                    //开发插件
                    string _mppath       = mppath + "\\" + list[i].name;
                    string _moduleplugin = moduleplugin + "\\" + list[i].name;
                    string _pluginxml    = pluginxml + "\\" + list[i].path;
                    PluginXmlManage.pluginfile = _pluginxml;
                    pluginxmlClass plugin = PluginXmlManage.getpluginclass();

                    foreach (issueClass ic in plugin.issue)
                    {
                        if (ic.type == "dir")
                        {
                            if (ic.source != "")
                            {
                                CommonHelper.CopyFolder(_mppath + "\\" + ic.source, _moduleplugin + "\\" + ic.path);
                            }
                            else
                            {
                                if (Directory.Exists(_mppath + "\\" + ic.path))
                                {
                                    CommonHelper.CopyFolder(_mppath + "\\" + ic.path, _moduleplugin + "\\" + ic.path);
                                }
                                else
                                {
                                    Directory.CreateDirectory(_moduleplugin + "\\" + ic.path);
                                }
                            }
                        }
                        else if (ic.type == "file")
                        {
                            if (ic.source != "")
                            {
                                new FileInfo(_mppath + "\\" + ic.source).CopyTo(_moduleplugin + "\\" + ic.path, true);
                            }
                            else
                            {
                                new FileInfo(_mppath + "\\" + ic.path).CopyTo(_moduleplugin + "\\" + ic.path, true);
                            }
                        }
                    }
                }

                PluginSysManage.AddPlugin(list[i].plugintype, list[i].name, list[i].path, list[i].title, list[i].isdevelopment);
            }

            MessageBoxEx.Show("发布程序包成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Esempio n. 4
0
        //安装插件升级包
        public static void SetUpPluginUpgrade()
        {
            string pufile = System.Windows.Forms.Application.StartupPath + "\\pluginupgrade.txt";

            if (File.Exists(pufile) == true)
            {
                List <string> addplugin    = new List <string>(); //新增插件
                List <string> updateplugin = new List <string>(); //更新插件
                List <string> deleteplugin = new List <string>(); //删除插件

                using (StreamReader sr = new StreamReader(pufile))
                {
                    string addrow = sr.ReadLine();
                    addplugin = addrow.Split(':')[1].Split(',').ToList();

                    string updaterow = sr.ReadLine();
                    updateplugin = updaterow.Split(':')[1].Split(',').ToList();

                    string deleterow = sr.ReadLine();
                    deleteplugin = deleterow.Split(':')[1].Split(',').ToList();
                }

                //删除
                File.Delete(pufile);

                foreach (string p in addplugin)
                {
                    if (p.Trim() != "")
                    {
                        string path = rootpath + "ModulePlugin\\" + p;
                        //删除本地插件
                        if (Directory.Exists(path))
                        {
                            Directory.Delete(path, true);
                        }
                        //解压插件包
                        string zipfile = rootpath + @"FileStore\PluginUpgrade\" + p + ".zip";
                        FastZipHelper.decompress(rootpath + "ModulePlugin\\", zipfile);
                        //修改pluginsys.xml配置文件
                        string pluginfile = "ModulePlugin\\" + p + "\\plugin.xml";
                        PluginSysManage.AddPlugin(pluginfile);
                    }
                }

                foreach (string p in updateplugin)
                {
                    if (p.Trim() != "")
                    {
                        string path = rootpath + "ModulePlugin\\" + p;
                        //删除本地插件
                        if (Directory.Exists(path))
                        {
                            Directory.Delete(path, true);
                        }
                        //解压插件包
                        string zipfile = rootpath + @"FileStore\PluginUpgrade\" + p + ".zip";
                        FastZipHelper.decompress(rootpath + "ModulePlugin\\", zipfile);
                        //修改pluginsys.xml配置文件
                        string pluginfile = "ModulePlugin\\" + p + "\\plugin.xml";
                        PluginSysManage.RemovePlugin(p);
                        PluginSysManage.AddPlugin(pluginfile);
                    }
                }

                foreach (string p in deleteplugin)
                {
                    if (p.Trim() != "")
                    {
                        string path = rootpath + "ModulePlugin\\" + p;
                        //修改pluginsys.xml配置文件
                        PluginSysManage.RemovePlugin(p);
                        //删除本地插件
                        if (Directory.Exists(path))
                        {
                            Directory.Delete(path, true);
                        }
                    }
                }
            }
        }