protected List <ResfileInfo> GetServerXml(ref string verServer, string filename, string gamename, bool forceLoad = false) { List <ResfileInfo> ResList = (List <ResfileInfo>)Cache.Get("ResfileInfoList" + gamename); if (ResList == null || forceLoad) { try { XmlDocument docServer = new XmlDocument(); string path = HttpContext.Current.Server.MapPath("./"); docServer.Load(path + "\\download\\" + filename); XmlNode configServer = docServer.SelectSingleNode("Config"); ResList = new List <ResfileInfo>(); foreach (XmlNode node in configServer.ChildNodes) { if (node.Name == "File") { ResfileInfo ri = new ResfileInfo(); ri.Path = node.Attributes["path"].Value; ri.MD5 = node.Attributes["md5"].Value; ri.Ver = node.Attributes["ver"].Value; ri.Index = ConverVer(ri.Ver); ResList.Add(ri); } } ResList.Sort(CompareResfileInfo); verServer = configServer.Attributes["ver"].Value; } catch (Exception) { ResList.Clear(); verServer = ""; } if (verServer != "") { Cache["ResfileInfoList" + gamename] = ResList; Cache["ServerVer" + gamename] = verServer; } } else { verServer = (string)Cache.Get("ServerVer" + gamename); } return(ResList); }
protected static int CompareResfileInfo(ResfileInfo x, ResfileInfo y) { if (x.Index < y.Index) { return(1); } else if (x.Index == y.Index) { return(0); } else { return(-1); } }