protected void PageInit() { pageIndex = Utils.GetInt(Utils.GetQueryStringValue("page"), 1); EyouSoft.Model.SysStructure.MSysLogLoginSearchInfo search = new EyouSoft.Model.SysStructure.MSysLogLoginSearchInfo(); search.Name = Utils.GetQueryStringValue("txtName"); search.STime = string.IsNullOrEmpty(Utils.GetQueryStringValue("txtLoginTimeS")) ? null : (DateTime?)Utils.GetDateTime(Utils.GetQueryStringValue("txtLoginTimeS")); search.ETime = string.IsNullOrEmpty(Utils.GetQueryStringValue("txtLoginTimeE")) ? null : (DateTime?)Utils.GetDateTime(Utils.GetQueryStringValue("txtLoginTimeE")); var list = new EyouSoft.BLL.SysStructure.BSysLogHandle().GetLoginLogs(SiteUserInfo.CompanyId, pageSize, pageIndex, ref recordCount, search); if (list != null && list.Count > 0) { this.repList.DataSource = list; this.repList.DataBind(); BindPage(); } else { this.repList.EmptyText = "<tr><td colspan=\"4\" align=\"center\">未找到相关记录!</td></tr>"; } }
/// <summary> /// 获取登录日志信息集合 /// </summary> /// <param name="companyId">公司编号</param> /// <param name="pageSize">页记录数</param> /// <param name="pageIndex">页索引</param> /// <param name="recordCount">总记录数</param> /// <param name="searchInfo">查询信息</param> /// <returns></returns> public IList <EyouSoft.Model.SysStructure.MSysLogLoginInfo> GetLoginLogs(string companyId, int pageSize, int pageIndex, ref int recordCount, EyouSoft.Model.SysStructure.MSysLogLoginSearchInfo searchInfo) { IList <EyouSoft.Model.SysStructure.MSysLogLoginInfo> items = new List <EyouSoft.Model.SysStructure.MSysLogLoginInfo>(); string tableName = "view_SysLogLogin"; string fields = "*"; string orderByString = "IssueTime DESC"; StringBuilder query = new StringBuilder(); #region SQL query.AppendFormat(" CompanyId='{0}' AND LoginType={1} ", companyId, (int)EyouSoft.Model.EnumType.ComStructure.UserLoginType.用户登录); query.AppendFormat(" AND UserType IN({0},{1}) ", (int)EyouSoft.Model.EnumType.ComStructure.UserType.内部员工, (int)EyouSoft.Model.EnumType.ComStructure.UserType.导游); if (searchInfo != null) { if (searchInfo.STime.HasValue) { query.AppendFormat(" AND datediff(day,'{0}',IssueTime)>=0 ", searchInfo.STime.Value); } if (!string.IsNullOrEmpty(searchInfo.Name)) { query.AppendFormat(" AND ContactName LIKE '%{0}%' ", searchInfo.Name); } if (searchInfo.ETime.HasValue) { query.AppendFormat(" AND datediff(day,'{0}',IssueTime)<=0 ", searchInfo.ETime.Value); } if (!string.IsNullOrEmpty(searchInfo.UserId)) { query.AppendFormat(" AND OperatorId='{0}' ", searchInfo.UserId); } } #endregion using (IDataReader rdr = DbHelper.ExecuteReader(this._db, pageSize, pageIndex, ref recordCount, tableName, string.Empty, fields, query.ToString(), orderByString)) { while (rdr.Read()) { var item = new EyouSoft.Model.SysStructure.MSysLogLoginInfo(); item.IP = rdr["IP"].ToString(); item.LoginTime = rdr.GetDateTime(rdr.GetOrdinal("IssueTime")); item.Name = rdr["ContactName"].ToString(); item.Username = rdr["UserName"].ToString(); items.Add(item); } } return(items); }