Ejemplo n.º 1
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;
        }
Ejemplo n.º 2
0
        public static void savepluginclass(pluginxmlClass pluginclass)
        {
            if (pluginclass == null)
            {
                return;
            }

            if (xmlDoc == null)
            {
                InitConfig();
            }

            XmlNode pluginN = xmlDoc.DocumentElement.SelectSingleNode("plugin");

            pluginN.Attributes["name"].Value            = pluginclass.name;
            pluginN.Attributes["title"].Value           = pluginclass.title;
            pluginN.Attributes["version"].Value         = pluginclass.version;
            pluginN.Attributes["author"].Value          = pluginclass.author;
            pluginN.Attributes["plugintype"].Value      = pluginclass.plugintype;
            pluginN.Attributes["defaultdbkey"].Value    = pluginclass.defaultdbkey;
            pluginN.Attributes["defaultcachekey"].Value = pluginclass.defaultcachekey;
            pluginN.Attributes["isentry"].Value         = pluginclass.isentry;
            XmlNode dataN = pluginN.SelectSingleNode("baseinfo");

            if (dataN != null)
            {
                pluginN.RemoveChild(dataN);
            }

            XmlNode dllN = pluginN.SelectSingleNode("businessinfo");

            if (dllN != null)
            {
                pluginN.RemoveChild(dllN);
            }

            XmlNode issueN = pluginN.SelectSingleNode("issue");

            if (issueN != null)
            {
                pluginN.RemoveChild(issueN);
            }

            XmlNode setupN = pluginN.SelectSingleNode("setup");

            if (setupN != null)
            {
                pluginN.RemoveChild(setupN);
            }

            XmlNode menuN = pluginN.SelectSingleNode("menus");

            if (menuN != null)
            {
                pluginN.RemoveChild(menuN);
            }

            if (pluginclass.data.Count > 0)
            {
                XmlElement xe1 = xmlDoc.CreateElement("baseinfo");//创建一个节点
                pluginN.AppendChild(xe1);
            }
            if (pluginclass.dll.Count > 0)
            {
                XmlElement xe1 = xmlDoc.CreateElement("businessinfo");//创建一个节点
                pluginN.AppendChild(xe1);
            }
            if (pluginclass.issue.Count > 0)
            {
                XmlElement xe1 = xmlDoc.CreateElement("issue");//创建一个节点
                pluginN.AppendChild(xe1);
            }
            if (pluginclass.setup.Count > 0)
            {
                XmlElement xe1 = xmlDoc.CreateElement("setup");//创建一个节点
                pluginN.AppendChild(xe1);
            }
            if (pluginclass.menu.Count > 0)
            {
                XmlElement xe1 = xmlDoc.CreateElement("menus");//创建一个节点
                pluginN.AppendChild(xe1);
            }

            for (int i = 0; i < pluginclass.data.Count; i++)
            {
                XmlElement xe1 = xmlDoc.CreateElement("data");//创建一个节点
                xe1.SetAttribute("key", pluginclass.data[i].key);
                xe1.SetAttribute("value", pluginclass.data[i].value);
                pluginN.SelectSingleNode("baseinfo").AppendChild(xe1);
            }

            for (int i = 0; i < pluginclass.dll.Count; i++)
            {
                XmlElement xe1 = xmlDoc.CreateElement("dll");//创建一个节点
                xe1.SetAttribute("name", pluginclass.dll[i].name);
                xe1.SetAttribute("version", pluginclass.dll[i].version);
                pluginN.SelectSingleNode("businessinfo").AppendChild(xe1);
            }

            for (int i = 0; i < pluginclass.issue.Count; i++)
            {
                XmlElement xe1 = xmlDoc.CreateElement("add");//创建一个节点
                xe1.SetAttribute("type", pluginclass.issue[i].type);
                xe1.SetAttribute("path", pluginclass.issue[i].path);
                xe1.SetAttribute("source", pluginclass.issue[i].source);
                pluginN.SelectSingleNode("issue").AppendChild(xe1);
            }

            for (int i = 0; i < pluginclass.setup.Count; i++)
            {
                XmlElement xe1 = xmlDoc.CreateElement("add");//创建一个节点
                xe1.SetAttribute("type", pluginclass.setup[i].type);
                xe1.SetAttribute("path", pluginclass.setup[i].path);
                xe1.SetAttribute("copyto", pluginclass.setup[i].copyto);
                pluginN.SelectSingleNode("setup").AppendChild(xe1);
            }

            for (int i = 0; i < pluginclass.menu.Count; i++)
            {
                XmlElement xe1 = xmlDoc.CreateElement("add");//创建一个节点
                xe1.SetAttribute("menuname", pluginclass.menu[i].menuname);
                xe1.SetAttribute("pluginname", pluginclass.menu[i].pluginname);
                xe1.SetAttribute("controllername", pluginclass.menu[i].controllername);
                xe1.SetAttribute("viewname", pluginclass.menu[i].viewname);
                xe1.SetAttribute("menupath", pluginclass.menu[i].menupath);
                xe1.SetAttribute("memo", pluginclass.menu[i].memo);
                pluginN.SelectSingleNode("menus").AppendChild(xe1);
            }
            xmlDoc.Save(pluginfile);
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
0
        public static pluginxmlClass getpluginclass()
        {
            if (xmlDoc == null)
            {
                InitConfig();
            }


            pluginxmlClass plugin = new pluginxmlClass();

            plugin.data  = new List <baseinfodataClass>();
            plugin.dll   = new List <businessinfodllClass>();
            plugin.issue = new List <issueClass>();
            plugin.setup = new List <setupClass>();
            plugin.menu  = new List <menuClass>();

            XmlNode node = xmlDoc.DocumentElement.SelectSingleNode("plugin");

            plugin.name            = node.Attributes["name"].Value;
            plugin.title           = node.Attributes["title"].Value;
            plugin.version         = node.Attributes["version"].Value;
            plugin.author          = node.Attributes["author"].Value;
            plugin.plugintype      = node.Attributes["plugintype"].Value;
            plugin.defaultdbkey    = node.Attributes["defaultdbkey"].Value;
            plugin.defaultcachekey = node.Attributes["defaultcachekey"].Value;
            plugin.isentry         = node.Attributes["isentry"].Value;

            //node = xmlDoc.DocumentElement.SelectSingleNode("plugin/baseinfo/data[@key='introduction']");
            //plugin.introduction = node == null ? "" : node.Attributes["value"].Value;
            //node = xmlDoc.DocumentElement.SelectSingleNode("plugin/baseinfo/data[@key='updaterecord']");
            //plugin.updaterecord = node == null ? "" : node.Attributes["value"].Value;
            //node = xmlDoc.DocumentElement.SelectSingleNode("plugin/baseinfo/data[@key='headpic']");
            //plugin.headpic = node == null ? "" : node.Attributes["value"].Value;
            //node = xmlDoc.DocumentElement.SelectSingleNode("plugin/baseinfo/data[@key='StartItem']");
            //plugin.StartItem = node == null ? "" : node.Attributes["value"].Value;
            XmlNodeList nlist = null;

            if (xmlDoc.DocumentElement.SelectSingleNode("plugin/baseinfo") != null)
            {
                nlist = xmlDoc.DocumentElement.SelectSingleNode("plugin/baseinfo").ChildNodes;
                foreach (XmlNode n in nlist)
                {
                    baseinfodataClass data = new baseinfodataClass();
                    data.key   = n.Attributes["key"].Value;
                    data.value = n.Attributes["value"].Value;

                    plugin.data.Add(data);
                }
            }
            if (xmlDoc.DocumentElement.SelectSingleNode("plugin/businessinfo") != null)
            {
                nlist = xmlDoc.DocumentElement.SelectSingleNode("plugin/businessinfo").ChildNodes;
                foreach (XmlNode n in nlist)
                {
                    businessinfodllClass dll = new businessinfodllClass();
                    dll.name    = n.Attributes["name"].Value;
                    dll.version = n.Attributes["version"].Value;

                    plugin.dll.Add(dll);
                }
            }

            if (xmlDoc.DocumentElement.SelectSingleNode("plugin/issue") != null)
            {
                nlist = xmlDoc.DocumentElement.SelectSingleNode("plugin/issue").ChildNodes;
                foreach (XmlNode n in nlist)
                {
                    issueClass ic = new issueClass();
                    ic.type   = n.Attributes["type"].Value;
                    ic.path   = n.Attributes["path"].Value;
                    ic.source = n.Attributes["source"] == null ? "" : n.Attributes["source"].Value;

                    plugin.issue.Add(ic);
                }
            }

            if (xmlDoc.DocumentElement.SelectSingleNode("plugin/setup") != null)
            {
                nlist = xmlDoc.DocumentElement.SelectSingleNode("plugin/setup").ChildNodes;
                foreach (XmlNode n in nlist)
                {
                    setupClass sc = new setupClass();
                    sc.type   = n.Attributes["type"].Value;
                    sc.path   = n.Attributes["path"].Value;
                    sc.copyto = n.Attributes["copyto"] == null ? "" : n.Attributes["copyto"].Value;
                    plugin.setup.Add(sc);
                }
            }

            if (xmlDoc.DocumentElement.SelectSingleNode("plugin/menus") != null)
            {
                nlist = xmlDoc.DocumentElement.SelectSingleNode("plugin/menus").ChildNodes;
                foreach (XmlNode n in nlist)
                {
                    menuClass mc = new menuClass();
                    mc.menuname       = n.Attributes["menuname"].Value;
                    mc.pluginname     = n.Attributes["pluginname"].Value;
                    mc.controllername = n.Attributes["controllername"].Value;
                    mc.viewname       = n.Attributes["viewname"].Value;
                    mc.menupath       = n.Attributes["menupath"].Value;
                    mc.memo           = n.Attributes["memo"].Value;
                    plugin.menu.Add(mc);
                }
            }

            return(plugin);
        }