private void Page_Load_POST() { JObject Rep = new JObject(); Rep["ok"] = false; Rep["msg"] = ""; try { if (!_optuser.isAdmin && _optuser.xingshenUser.ExpiryDate < DateTime.Now && Request["a"] != "del") { Rep["msg"] = "操作时限已过 "; return; } string uid = Request["uid"]; if (string.IsNullOrEmpty(uid)) { Rep["msg"] = "参数错误:uid"; return; } user = XingshenUser.GetModel(uid); if (user.id == 0) { Rep["msg"] = "参数错误:uid"; return; } if (Request["a"] == "dct") { string dct; string errMsg = svrHelper.GetUserLastDCTime(user, out dct); if (!string.IsNullOrEmpty(errMsg)) { Rep["msg"] = errMsg; return; } Rep["lastDCTime"] = dct; Rep["ok"] = true; } else if (Request["a"] == "rdt") { ud = XingshenUserData.GetModel(uid); //刷新存档 string ErrData = svrHelper.system_user_info(user, ref ud); if (!string.IsNullOrEmpty(ErrData)) { Rep["msg"] = "下载数据存档失败!" + ErrData; return; } if (ud.id == 0) { ud.Add(); } else { ud.Update(); } user = XingshenUser.GetModel(uid); if (user.id > 0) { //检查是否被封 string dct; svrHelper.GetUserLastDCTime(user, out dct); user.isHold = false; user.Update(); } Rep["ok"] = true; } else if (Request["a"] == "delwarning") { //删除警告信息 int wid = MakRequest.GetInt("wid", 0); if (wid != 0 && XingshenUserDataWarning_BLL.Delete(uid, wid)) { Rep["ok"] = true; } else { Rep["msg"] = "无效id"; } } else if (Request["a"] == "downfirst") { ud = XingshenUserData.GetModel(uid); JObject jo = null; try { jo = (JObject)JsonConvert.DeserializeObject(ud.data); } catch (Exception exx) { Rep["msg"] = exx.Message; return; } string Data = Encoding.UTF8.GetString(HttpContext.Current.Request.BinaryRead(HttpContext.Current.Request.TotalBytes)); jo["data"]["player_data"] = Data; string errMsg = svrHelper.adjustmentData(jo, user); if (!string.IsNullOrEmpty(errMsg)) { Rep["msg"] = errMsg; return; } string data = jo.ToString(Formatting.None); ud.data = data; ud.Update(); Rep["data"] = svrHelper.Create_first_login(user, data); Rep["ok"] = true; } else if (Request["a"] == "save") { ud = XingshenUserData.GetModel(uid); JObject jo = null; try { jo = (JObject)JsonConvert.DeserializeObject(ud.data); } catch (Exception exx) { Rep["msg"] = exx.Message; return; } string Data = Encoding.UTF8.GetString(HttpContext.Current.Request.BinaryRead(HttpContext.Current.Request.TotalBytes)); jo["data"]["player_data"] = Data; string errMsg = svrHelper.adjustmentData(jo, user); string data = jo.ToString(Formatting.None); ud.data = data; ud.Update(); user = XingshenUser.GetModel(uid); if (user.id > 0) { user.isHold = true; user.Update(); } Rep["ok"] = true; } else if (Request["a"] == "refreshwarn") { //刷新警告信息 Rep["data"] = MakJsonHelper.DataTableToJsonArr_AllRow(XingshenUserDataWarning.GetWarningList(uid)); Rep["ok"] = true; } else if (Request["a"] == "sign") { string Data = Encoding.UTF8.GetString(HttpContext.Current.Request.BinaryRead(HttpContext.Current.Request.TotalBytes)); string dct = MakRequest.GetString("ts"); if (string.IsNullOrEmpty(dct)) { ((DateTime.Now.AddHours(8).ToUniversalTime().Ticks - 621355968000000000) / 10000000).ToString(); } Rep["ServerTime"] = dct; Rep["Sign"] = svrHelper.SignData(user, dct, Data); Rep["ok"] = true; Rep["Sign2"] = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(Data + "QAbxK1exZYrK6WIO" + dct, "MD5").ToLower(); } else if (Request["a"] == "upload") { ud = XingshenUserData.GetModel(uid); JObject jo = null; try { jo = (JObject)JsonConvert.DeserializeObject(ud.data); } catch (Exception exx) { Rep["msg"] = exx.Message; return; } string Data = Encoding.UTF8.GetString(HttpContext.Current.Request.BinaryRead(HttpContext.Current.Request.TotalBytes)); jo["data"]["player_data"] = Data; ud.data = jo.ToString(Formatting.None); ud.Update(); string errMsg = svrHelper.Create_save_user(user, ud); if (!string.IsNullOrEmpty(errMsg)) { Rep["msg"] = errMsg; } else { Rep["ok"] = true; } } else if (Request["a"] == "aed") { if (!_optuser.isAdmin) { return; } string Data = Encoding.UTF8.GetString(HttpContext.Current.Request.BinaryRead(HttpContext.Current.Request.TotalBytes)); JObject jo = null; try { jo = (JObject)JsonConvert.DeserializeObject(Data); } catch (Exception exx) { Rep["msg"] = exx.Message; return; } if (jo["timeval"] == null || jo["units"] == null) { Rep["msg"] = "参数错误"; return; } int timeval = Utils.StrToInt(jo["timeval"].ToString(), 0); int units = Utils.StrToInt(jo["units"].ToString(), 0); DateTime dtt; switch (units) { case 0: dtt = DateTime.Now.AddMinutes(timeval); break; case 1: dtt = DateTime.Now.AddHours(timeval); break; case 2: dtt = DateTime.Now.AddDays(timeval); break; default: dtt = DateTime.Now; break; } user.ExpiryDate = dtt; user.Update(); Rep["ok"] = true; } else if (Request["a"] == "del") { //从系统中删除账号 user.Delete(); Rep["ok"] = true; } else if (Request["a"] == "login") { //强制登录一波,刷新token string ErrData = svrHelper.first_login(user, ref ud); if (!string.IsNullOrEmpty(ErrData)) { Rep["msg"] = "登录失败!" + ErrData; return; } user.Update(); Rep["ok"] = true; Rep["uid"] = user.uuid; } } finally { if ((bool)Rep["ok"] == false && Rep["msg"].ToString() == "") { Rep["msg"] = "系统错误"; } Response.CacheControl = "no-cache"; Response.Write(Rep.ToString(Formatting.None)); Response.End(); } }
private void loadDefData() { pageidx = MakRequest.GetInt("page", 1); datalimit = MakRequest.GetInt("limit", 20); lang_src = MakRequest.GetString("lang1"); lang_dst = MakRequest.GetString("lang2"); includeSys = MakRequest.GetInt("isys", 0) == 1; if (string.IsNullOrEmpty(lang_dst) || !File.Exists(HttpContext.Current.Server.MapPath("/i18n/" + lang_dst + ".xml"))) { lang_dst = "en-us"; } List <lstItemModel> ll = new List <lstItemModel>(); XmlDocument xml_src = new XmlDocument(); xml_src.Load(HttpContext.Current.Server.MapPath("/i18n/" + lang_dst + ".xml")); XmlNode root = xml_src.SelectSingleNode("i18n"); RecordCount = root.ChildNodes.Count; if (!includeSys) { RecordCount = RecordCount - I18N.sysKey.Count; } foreach (XmlNode item in root.ChildNodes) { if (item.Name == "a" && item.Attributes["key"] != null) { string key = item.Attributes["key"].Value; bool isSyskey = I18N.sysKey.Exists(aa => aa == key); if (includeSys || !isSyskey) { int scr = item.Attributes["score"] == null ? 5 : Utils.StrToInt(item.Attributes["score"].Value, 5); if (scr > 5) { scr = 5; } else if (scr < 1) { scr = 1; } s1_5[scr - 1]++; } } } int startIdx = (pageidx - 1) * datalimit; while (startIdx < root.ChildNodes.Count) { XmlNode a = root.ChildNodes[startIdx++]; if (a.Name == "a" && a.Attributes["key"] != null) { string key = a.Attributes["key"].Value; bool isSyskey = I18N.sysKey.Exists(aa => aa == key); if (includeSys || !isSyskey) { lstItemModel llm = new lstItemModel(); ll.Add(llm); llm.isSyskey = isSyskey; llm.Original = key; llm.lang1 = key; llm.lang2 = a.Attributes["text"].Value; if (string.IsNullOrEmpty(llm.lang2)) { llm.Score = 1; } else { llm.Score = a.Attributes["score"] == null ? 5 : Utils.StrToInt(a.Attributes["score"].Value, 5); } if (ll.Count >= datalimit) { break; } } } } if ("o".Equals(lang_src)) { //lang_src = LI("原始字符串"); } else { if (string.IsNullOrEmpty(lang_src) || !File.Exists(HttpContext.Current.Server.MapPath("/i18n/" + lang_src + ".xml"))) { lang_src = "zh-cn"; } I18N i18 = new I18N(lang_src); foreach (var item in ll) { if (!item.isSyskey) { item.lang1 = i18.I(item.Original); } } } rptList.DataSource = ll; rptList.DataBind(); }
private void loadDefData2() { pageidx = MakRequest.GetInt("page", 1); datalimit = MakRequest.GetInt("limit", 20); lang_src = MakRequest.GetString("lang1"); lang_dst = MakRequest.GetString("lang2"); includeSys = MakRequest.GetInt("isys", 0) == 1; filterstar = Utils.StrToInt(MakRequest.GetString("filter_s"), 0); filterkw = MakRequest.GetString("filter_k"); if (!I18N.alllang.Contains(lang_dst)) { lang_dst = "en-us"; } I18N idst = new I18N(lang_dst); //过滤 List <I18N.LangItem> filteredData = new List <I18N.LangItem>(); foreach (var item in idst.lanStrs) { I18N.LangItem li = item.Value; bool isSyskey = I18N.sysKey.Contains(li.Key); if (includeSys || !isSyskey) { AllRecordCount++; s1_5[li.Score - 1]++; if (filterstar == 0 || filterstar == li.Score) { if (string.IsNullOrEmpty(filterkw) || li.Key.IndexOf(filterkw) > -1 || li.Text.IndexOf(filterkw) > -1) { filteredData.Add(li); } } } } //分页 List <lstItemModel> ll = new List <lstItemModel>(); int pageStartIdx = (pageidx - 1) * datalimit; for (int i = pageStartIdx; i < Math.Min(filteredData.Count, pageStartIdx + datalimit); i++) { I18N.LangItem item = filteredData[i]; lstItemModel llm = new lstItemModel(); ll.Add(llm); llm.isSyskey = I18N.sysKey.Contains(item.Key); llm.Original = item.Key; llm.lang1 = item.Key; llm.lang2 = item.Text; llm.Score = item.Score; } RecordCount = filteredData.Count; if ("o".Equals(lang_src)) { //lang_src = LI("原始字符串"); } else { if (!I18N.alllang.Contains(lang_src)) { lang_src = "zh-cn"; } I18N i18 = new I18N(lang_src); foreach (var item in ll) { if (!item.isSyskey) { item.lang1 = i18.I(item.Original); } } } rptList.DataSource = ll; rptList.DataBind(); baseurl = Request.Path + "?lang1=" + lang_src + "&lang2=" + lang_dst; if (includeSys) { baseurl += "&isys=1"; } if (datalimit != 20) { baseurl += "&limit=" + datalimit.ToString(); } }
/// <summary> /// 根据Form的数据填充当前模型 /// </summary> public void BindForm() { foreach (PropertyInfo pi in this.GetType().GetProperties()) { if (!MakRequest.Exists(pi.Name)) { continue; } var attrs = pi.GetCustomAttributes(typeof(AttrTableFieldInfo), false); if (attrs.Length > 0) { AttrTableFieldInfo item = attrs[0] as AttrTableFieldInfo; if (!item.IsPrimaryKey) { Type type = pi.PropertyType; if (pi.PropertyType.IsGenericType && pi.PropertyType.GetGenericTypeDefinition() == typeof(Nullable <>)) { //如果是带问号的类型 type = pi.PropertyType.GetGenericArguments()[0]; } if (type == typeof(int)) { pi.SetValue(this, MakRequest.GetInt(pi.Name, 0), null); } else if (type == typeof(long)) { pi.SetValue(this, MakRequest.GetInt64(pi.Name, 0), null); } else if (type == typeof(string)) { pi.SetValue(this, MakRequest.GetString(pi.Name), null); } else if (type == typeof(DateTime)) { pi.SetValue(this, Utils.StrToDateTime(MakRequest.GetString(pi.Name), DateTime.MinValue).Value, null); } else if (type == typeof(bool)) { string boolval = MakRequest.GetString(pi.Name).ToLower(); if (boolval == "1" || boolval == "yes" || boolval == "on") { pi.SetValue(this, true, null); } else { pi.SetValue(this, false, null); } } else if (type == typeof(decimal)) { pi.SetValue(this, (decimal)MakRequest.GetFloat(pi.Name, 0), null); } else if (type == typeof(float) || type == typeof(double) || type == typeof(decimal)) { pi.SetValue(this, MakRequest.GetFloat(pi.Name, 0), null); } else { throw new NotImplementedException("未完整定义的类型!" + pi.GetType().FullName); } } var value = pi.GetValue(this, null); } } }