コード例 #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;
        }
コード例 #2
0
        private void btnPack_Click(object sender, EventArgs e)
        {
            if (gridlocal.CurrentCell == null)
            {
                return;
            }
            List <PluginClass> plist = gridlocal.DataSource as List <PluginClass>;
            PluginClass        pc    = plist[gridlocal.CurrentCell.RowIndex];


            saveFileDialog.FileName = pc.name;
            if (saveFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                string bagpath = saveFileDialog.FileName;
                if (File.Exists(bagpath))
                {
                    File.Delete(bagpath);
                }

                string   path    = PluginSysManage.localpath + "\\" + pc.path;
                string   prjname = null;
                string   prjpath = null;
                FileInfo finfo   = new FileInfo(path);
                if (finfo.Exists)
                {
                    prjpath = finfo.Directory.FullName;
                    prjname = finfo.Directory.Name;
                }
                PluginXmlManage.pluginfile = path;
                pluginxmlClass plugin = PluginXmlManage.getpluginclass();

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


                FastZipHelper.compress(temp, bagpath);
                Directory.Delete(temp, true);
            }
        }
コード例 #3
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);
        }
コード例 #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);
        }