public static VersionGroup Load(string name, string path) { System.Xml.Serialization.XmlSerializer xmls = new System.Xml.Serialization.XmlSerializer(typeof(VersionGroup)); VersionGroup group = null; try { using (var s = System.IO.File.OpenRead(path + "/vergroup.xml")) { group = xmls.Deserialize(s) as VersionGroup; } } catch { } if (group == null) { group = new VersionGroup(); group.path = path; group.Save(); } group.name = name; group.path = path; return(group); }
string _http_cmd_login(System.Net.HttpListenerContext req) { MyJson.JsonNode_Object map = new MyJson.JsonNode_Object(); string game = req.Request.QueryString["g"]; string username = req.Request.QueryString["u"]; string password = req.Request.QueryString["p"]; var _user = config.getArtist(username); var _game = config.getGame(game); if (_user == null) { map.SetDictValue("status", -1001); map.SetDictValue("msg", "user not exist."); return(map.ToString()); } if (_user.code != password) { map.SetDictValue("status", -1002); map.SetDictValue("msg", "user password is error."); return(map.ToString()); } if (_game == null) { if (_user.level > 10) { if (System.IO.Directory.Exists("games/" + game) == false) { System.IO.Directory.CreateDirectory("games/" + game); } if (System.IO.Directory.Exists("games/" + game)) { _game = new ServerConfig.Game(); _game.name = game; _game.desc = ""; _game.admin = username; _game.users.Add(username); config.games.Add(_game); config.Save(); } } if (_game == null) { map.SetDictValue("status", -1003); map.SetDictValue("msg", "game not exist.when superadmin Login to a empty game will create one."); return(map.ToString()); } } if (_game.users.Contains(username) == false) { map.SetDictValue("status", -1004); map.SetDictValue("msg", "you can not edit this game."); return(map.ToString()); } LoginInfo info = new LoginInfo(); info.game = game; info.username = username; info.token = Guid.NewGuid().ToString(); tokens[info.token] = info; map.SetDictValue("status", 0); map.SetDictValue("token", info.token); if (versions.ContainsKey(game) == false) { versions[game] = VersionGroup.Load(game, "games/" + game); } return(map.ToString()); }