Exemple #1
0
        private void btnDel_Click(object sender, EventArgs e)
        {
            if (gridlocal.CurrentCell == null)
            {
                return;
            }

            if (MessageBox.Show("是否卸载此插件?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.No)
            {
                return;
            }

            List <PluginClass> plist = gridlocal.DataSource as List <PluginClass>;
            PluginClass        pc    = plist[gridlocal.CurrentCell.RowIndex];
            FileInfo           finfo = null;

            if (pc.plugintype == "WcfModulePlugin")
            {
                //1.卸载插件
                EFWCoreLib.CoreFrame.Init.AppPluginManage.RemovePlugin(pc.name);
                //2.删除插件的相关文件
                finfo = new FileInfo(PluginSysManage.localpath + "\\" + pc.path);
                if (finfo.Exists)
                {
                    PluginSysManage.DeletePlugin(pc.plugintype, pc.name);
                    if (finfo.Directory.Exists)
                    {
                        finfo.Directory.Delete(true);
                    }
                    //MessageBox.Show("此插件卸载成功,必须重启WCF服务主机!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
                }
            }

            InitPlugin();
        }
Exemple #2
0
        static void setprivatepath()
        {
            //AppDomain.CurrentDomain.SetupInformation.PrivateBinPath = @"Component;ModulePlugin\Books_Wcf\dll;ModulePlugin\WcfMainUIFrame\dll";
            string privatepath = @"Component";

            foreach (var p in PluginSysManage.GetAllPlugin())
            {
                privatepath += ";" + p.path.Replace("plugin.xml", "dll");
            }

            AppDomain.CurrentDomain.SetData("PRIVATE_BINPATH", privatepath);
            AppDomain.CurrentDomain.SetData("BINPATH_PROBE_ONLY", privatepath);
            var m       = typeof(AppDomainSetup).GetMethod("UpdateContextProperty", BindingFlags.NonPublic | BindingFlags.Static);
            var funsion = typeof(AppDomain).GetMethod("GetFusionContext", BindingFlags.NonPublic | BindingFlags.Instance);

            m.Invoke(null, new object[] { funsion.Invoke(AppDomain.CurrentDomain, null), "PRIVATE_BINPATH", privatepath });
        }
Exemple #3
0
        private void InitPlugin()
        {
            List <PluginClass> plist  = new List <PluginClass>();
            List <PluginClass> plist2 = PluginSysManage.GetAllPlugin();

            plist.AddRange(plist2.FindAll(x => (x.plugintype == "WcfModulePlugin")));

            for (int i = 0; i < plist.Count; i++)
            {
                FileInfo finfo = new FileInfo(PluginSysManage.localpath + "\\" + plist[i].path);
                PluginXmlManage.pluginfile = finfo.FullName;
                pluginxmlClass plugin = PluginXmlManage.getpluginclass();
                plist[i].version = plugin.version;
                plist[i].author  = plugin.author;
            }
            gridlocal.DataSource = plist;
        }
Exemple #4
0
        private bool PluginSetup(string localzippath, out string pluginfile)
        {
            pluginfile = "";
            FileInfo fileinfo = new FileInfo(localzippath);

            if (fileinfo.Exists == false)
            {
                throw new Exception("插件包不存在!");
            }

            string temp_pluginpath = fileinfo.Directory.FullName + "\\" + fileinfo.Name.Replace(fileinfo.Extension, "");

            FastZipHelper.decompress(temp_pluginpath, localzippath);
            PluginXmlManage.pluginfile = temp_pluginpath + "\\plugin.xml";
            pluginxmlClass plugin = PluginXmlManage.getpluginclass();

            string pluginpath = "";
            //string pluginsyspath = "";
            //string dbconfig = "";
            string plugintype = "";
            string ptype      = plugin.plugintype.ToLower();

            bool ishave = false;

            switch (ptype)
            {
            case "wcf":
                //pluginsyspath = PluginSysManage.localpath + "\\Config\\pluginsys.xml";
                //dbconfig = PluginSysManage.localpath + "\\Config\\EntLib.config";
                plugintype = "WcfModulePlugin";
                pluginpath = PluginSysManage.localpath + "\\ModulePlugin\\" + plugin.name;
                //PluginSysManage.pluginsysFile = CommonHelper.WinformPlatformPath + "\\Config\\pluginsys.xml";
                if (PluginSysManage.ContainsPlugin("WcfModulePlugin", plugin.name))
                {
                    ishave = true;
                }
                break;
            }

            //先判断此插件本地是否存在
            if (ishave == true)
            {
                MessageBox.Show("你选择的插件本地已安装!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return(false);
            }



            //移动到插件目录
            if (temp_pluginpath != pluginpath)
            {
                new DirectoryInfo(temp_pluginpath).MoveTo(pluginpath);
            }

            pluginfile = pluginpath + "\\plugin.xml";
            //pluginsys.xml
            //PluginSysManage.pluginsysFile = pluginsyspath;
            PluginSysManage.AddPlugin(plugintype, plugin.name, "ModulePlugin/" + plugin.name + "/plugin.xml", plugin.title, "0");

            return(true);
        }