Example #1
0
        /// <summary>
        /// 读取渠道property文件返回 游戏对象
        /// </summary>
        /// <param name="fileName"></param>
        /// <returns></returns>
        public gameItem getItem(string gid)
        {
            string fileName = envConfig.games + gid + @"\" + gid + envConfig.configExt;

            GC.Collect();
            gameItem item = new gameItem();

            if (FileUtil.checkFile(fileName))
            {
                // 读取游戏信息
                PpHelper helper = new PpHelper(fileName);
                item.name    = helper.GetPropertiesText("name");
                item.gid     = helper.GetPropertiesText("gid");
                item.package = helper.GetPropertiesText("package");
                item.version = helper.GetPropertiesText("version");
                item.icon    = helper.GetPropertiesText("icon");
                item.des     = helper.GetPropertiesText("des");
                //          item.apk = helper.GetPropertiesText("apk");
                item.key         = helper.GetPropertiesText("key");
                item.orientation = helper.GetPropertiesText("orientation");
                item.flag        = helper.GetPropertiesText("flag");
                item.alias       = helper.GetPropertiesText("alias");
                item.keyPwd      = helper.GetPropertiesText("keyPwd");
                item.keyPath     = helper.GetPropertiesText("keyPath");
                item.signPwd     = helper.GetPropertiesText("signPwd");
            }

            return(item);
        }
Example #2
0
        /// <summary>
        /// 添加game节点 属性占一个节点
        /// </summary>
        /// <param name="item">游戏Item</param>
        public void reCreatGameXml(string xxx)
        {
            List <string>   folders = FileUtil.getFolders(envConfig.games);
            List <gameItem> lst     = new List <gameItem>();

            foreach (string folder in folders)
            {
                string game = new DirectoryInfo(folder).Name;
                if (game == ".svn")
                {
                    continue;
                }
                string   gameProperties = envConfig.games + game + @"\" + game + envConfig.configExt;
                gameItem item           = getItem(game);
                lst.Add(item);
            }

            itemlist.Clear();


            XmlDocument xd = new XmlDocument();

            using (StringWriter sw = new StringWriter())
            {
                XmlSerializer xz = new XmlSerializer(lst.GetType());
                xz.Serialize(sw, lst);
                Console.WriteLine(sw.ToString());
                xd.LoadXml(sw.ToString());
                xd.Save("E:\\1.xml");
            }
        }
Example #3
0
        /// <summary>
        /// 读取渠道xml文件返回对象
        /// </summary>
        /// <param name="fileName"></param>
        /// <returns></returns>
        public gameItem getItemByXml(string gid)
        {
            XmlNode  root  = GetRootNode();
            XmlNode  xFind = xmlDoc.SelectSingleNode("Root/Item[@gid='" + gid + "']");
            gameItem item  = null;

            if (xFind != null)
            {
                item = new gameItem();
                XmlElement element = (XmlElement)xFind;
                item.name        = element.GetAttribute("name");
                item.gid         = element.GetAttribute("gid");
                item.version     = element.GetAttribute("version");
                item.package     = element.GetAttribute("package");
                item.icon        = element.GetAttribute("icon");
                item.key         = element.GetAttribute("key");
                item.orientation = element.GetAttribute("orientation");
                //           item.apk = element.GetAttribute("apk");
                item.des     = element.GetAttribute("des");
                item.signPwd = element.GetAttribute("signPwd");
                item.alias   = element.GetAttribute("alias");
                item.keyPwd  = element.GetAttribute("keyPwd");
                item.keyPath = element.GetAttribute("keyPath");
                return(item);
            }
            return(item);
        }
Example #4
0
        /// <summary>
        /// 添加game节点 index 0 递增
        /// </summary>
        /// <param name="item">游戏Item</param>
        public int AddXmlNode(gameItem item)
        {
            if (item == null)
            {
                return(-2);
            }
            XmlNode    root        = GetRootNode();
            XmlElement lastElement = (XmlElement)root.LastChild;

            int index = 0;

            if (lastElement != null)
            {
                string strIndex = lastElement.GetAttribute("index");
                index = Convert.ToInt32(strIndex) + 1;
            }
            //创建节点
            XmlElement element = xmlDoc.CreateElement("Item");

            //添加属性
            setElement(element, item);
            element.SetAttribute("index", "" + index);
            item.index = index;
            //将节点加入到指定的节点下
            XmlNode xml = root.AppendChild(element);

            xmlSave();
            return(index);
        }
Example #5
0
        /// <summary>
        /// 新增更新列表
        /// </summary>
        /// <param name="fileName"></param>
        /// <param name="item"></param>
        public int saveUpdateToXml(gameItem item)
        {
            if (item == null)
            {
                return(-2);
            }
            XmlNode root  = GetRootNode();
            XmlNode xFind = xmlDoc.SelectSingleNode("Root/Item[@index='" + item.index + "']");

            if (xFind == null)
            {
                //新增
                xFind = xmlDoc.SelectSingleNode("Root/Item[@gid='" + item.gid + "']");
                if (xFind != null)
                {
                    DialogResult dr = MessageBox.Show("已经存在标识为:" + item.gid + "的游戏", "确认是否覆盖", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
                    if (dr == DialogResult.OK)
                    {
                        XmlElement element = (XmlElement)xFind;
                        item.index = Convert.ToInt32(element.GetAttribute("index"));
                        return(UpdateXmlNode(item));
                    }
                    else
                    {
                        return(-1000);
                    }
                }

                return(AddXmlNode(item));
            }
            else
            {
                return(UpdateXmlNode(item));
            }
        }
Example #6
0
        /// <summary>
        /// 新增/更新游戏信息
        /// </summary>
        /// <param name="item"></param>
        public int saveUpdate(gameItem item)
        {
            int index = saveUpdateToXml(item);

            if (index < 0)
            {
                return(-1);
            }

            saveItem(item);
            itemlist = GetItems();
            return(index);
        }
Example #7
0
        /// <summary>
        /// 修改item节点
        /// </summary>
        /// <param name="item">渠道Item</param>
        public int UpdateXmlNode(gameItem item)
        {
            if (item == null)
            {
                return(-2);
            }
            XmlNode    root    = GetRootNode();
            XmlNode    xFind   = xmlDoc.SelectSingleNode("Root/Item[@index='" + item.index + "']");
            XmlElement element = (XmlElement)xFind;

            setElement(element, item);
            //  element.SetAttribute("index", index);
            xmlSave();

            return(item.index);
        }
Example #8
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="element"></param>
 /// <param name="item"></param>
 public void setElement(XmlElement element, gameItem item)
 {
     element.SetAttribute("index", "" + item.index);
     element.SetAttribute("name", item.name);
     element.SetAttribute("version", item.version);
     element.SetAttribute("orientation", item.orientation);
     element.SetAttribute("gid", item.gid);
     element.SetAttribute("icon", item.icon);
     element.SetAttribute("key", item.key);
     //    element.SetAttribute("apk", item.apk);
     element.SetAttribute("flag", item.flag);
     element.SetAttribute("package", item.package);
     element.SetAttribute("des", item.des);
     element.SetAttribute("keyPwd", item.keyPwd);
     element.SetAttribute("signPwd", item.signPwd);
     element.SetAttribute("alias", item.alias);
     element.SetAttribute("keyPath", item.keyPath);
     //     element.SetAttribute("apktool", item.apktool);
 }
Example #9
0
        /// <summary>
        /// 重新生成 gamexml
        /// </summary>
        public void reCreatGameXml()
        {
            FileUtil.deleteFile(envConfig.gamesXml);
            List <string> folders = FileUtil.getFolders(envConfig.games);

            foreach (string folder in folders)
            {
                string game = new DirectoryInfo(folder).Name;
                if (game == ".svn")
                {
                    continue;
                }
                string   gameProperties = envConfig.games + game + @"\" + game + envConfig.configExt;
                gameItem item           = getItem(game);
                AddXmlNode(item);
            }

            itemlist.Clear();
            xmlSave();
        }
Example #10
0
        /// <summary>
        /// 获取Items
        /// </summary>
        /// <param name="item">游戏Item</param>
        public List <gameItem> GetItems()
        {
            XmlNode         root     = xmlDoc.DocumentElement;
            XmlNodeList     list     = root.ChildNodes;
            List <gameItem> itemlist = new List <gameItem>();

            foreach (XmlElement element in list)
            {
                gameItem item = new gameItem();
                item.name    = element.GetAttribute("name");
                item.gid     = element.GetAttribute("gid");
                item.package = element.GetAttribute("package");
                item.version = element.GetAttribute("version");
                item.icon    = element.GetAttribute("icon");
                item.des     = element.GetAttribute("des");
                //    item.apk = element.GetAttribute("apk");
                item.orientation = element.GetAttribute("orientation");
                item.key         = element.GetAttribute("key");
                item.flag        = element.GetAttribute("flag");
                item.alias       = element.GetAttribute("alias");
                item.keyPwd      = element.GetAttribute("keyPwd");
                item.keyPath     = element.GetAttribute("keyPath");
                item.signPwd     = element.GetAttribute("signPwd");
                //       item.apktool = element.GetAttribute("apktool");

                try
                {
                    item.index = Convert.ToInt32(element.GetAttribute("index"));
                }
                catch (Exception)
                {
                    continue;
                }

                itemlist.Add(item);
            }
            return(itemlist);
        }
Example #11
0
        /// <summary>
        /// 保存游戏信息
        /// </summary>
        /// <param name="item"></param>
        public void saveItem(gameItem item)
        {
            string lineStr = "";

            //     lineStr = "index=" + item.index + "\r\n";
            lineStr  = "name=" + item.name + "\r\n";
            lineStr += "gid=" + item.gid + "\r\n";
            lineStr += "package=" + item.package + "\r\n";
            lineStr += "version=" + item.version + "\r\n";
            lineStr += "icon=" + item.icon + "\r\n";

            //  lineStr += "apk=" + item.apk + "\r\n";
            lineStr += "orientation=" + item.orientation + "\r\n";
            lineStr += "key=" + item.key + "\r\n";
            lineStr += "alias=" + item.alias + "\r\n";
            lineStr += "keyPwd=" + item.keyPwd + "\r\n";
            lineStr += "keyPath=" + item.keyPath + "\r\n";
            lineStr += "signPwd=" + item.signPwd + "\r\n";
            //       lineStr += "apktool=" + item.apktool + "\r\n";
            lineStr += "flag=" + item.flag + "\r\n";
            lineStr += "des=" + item.des.Replace("\n", "").Replace(" ", "").Replace("\t", "").Replace("\r", "") + "\r\n";
            FileUtil.writeContent(envConfig.games + item.gid + @"\" + item.gid + envConfig.configExt, lineStr);
        }