/// <summary> /// 列表頁 /// </summary> /// <returns></returns> public HttpResponseBase GetUserLoginList() { string json = string.Empty; try { UserLoginAttempts query = new UserLoginAttempts(); query.Start = Convert.ToInt32(Request.Params["start"] ?? "0"); query.Limit = Convert.ToInt32(Request.Params["limit"] ?? "25"); query.login_mail = Request.Params["login_mail"]; query.login_ipfrom = Request.Params["login_ipfrom"]; if (!string.IsNullOrEmpty(Request.Params["start_date"])) { query.slogin_createdate = (int)CommonFunction.GetPHPTime(Convert.ToDateTime(Request.Params["start_date"]).ToString("yyyy-MM-dd HH:mm:ss")); } if (!string.IsNullOrEmpty(Request.Params["end"])) { query.elogin_createdate = (int)CommonFunction.GetPHPTime(Convert.ToDateTime(Request.Params["end"]).ToString("yyyy-MM-dd HH:mm:ss")); } if (!string.IsNullOrEmpty(Request.Params["sumtotal"])) { query.sumtotal = int.Parse(Request.Params["sumtotal"]); } if (!string.IsNullOrEmpty(Request.Params["ismail"])) { query.ismail = int.Parse(Request.Params["ismail"]); } if (!string.IsNullOrEmpty(Request.Params["login_type"])) { query.login_type = int.Parse(Request.Params["login_type"]); } int totalCount = 0; ulaMgr = new UserLoginAttemptsMgr(mySqlConnectionString); DataTable dt = ulaMgr.GetUserLoginAttemptsList(query, out totalCount); IsoDateTimeConverter timeConverter = new IsoDateTimeConverter(); //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式 timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss"; //listUser是准备转换的对象 json = "{success:true,totalCount:" + totalCount + ",data:" + JsonConvert.SerializeObject(dt, Formatting.Indented, timeConverter) + "}";//返回json數據 } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); json = "{success:false,totalCount:0,data:[]}"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }