130 lines
		
	
	
		
			4.7 KiB
		
	
	
	
		
			C#
		
	
	
	
		
		
			
		
	
	
			130 lines
		
	
	
		
			4.7 KiB
		
	
	
	
		
			C#
		
	
	
	
| 
								 | 
							
								using System;
							 | 
						|||
| 
								 | 
							
								using System.Collections.Generic;
							 | 
						|||
| 
								 | 
							
								using System.Linq;
							 | 
						|||
| 
								 | 
							
								using System.Web;
							 | 
						|||
| 
								 | 
							
								using System.Web.UI;
							 | 
						|||
| 
								 | 
							
								using System.Web.UI.WebControls;
							 | 
						|||
| 
								 | 
							
								using System.Data.SqlClient;
							 | 
						|||
| 
								 | 
							
								using BLL;
							 | 
						|||
| 
								 | 
							
								using System.Data;
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								namespace FineUIPro.Web.common.SysManage
							 | 
						|||
| 
								 | 
							
								{
							 | 
						|||
| 
								 | 
							
								    public partial class LogList : PageBase
							 | 
						|||
| 
								 | 
							
								    {
							 | 
						|||
| 
								 | 
							
								        protected void Page_Load(object sender, EventArgs e)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            if (!IsPostBack)
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                BLL.Base_ProjectService.InitProjectDropDownList(drpProject, true, CurrUser.UserId, null, CurrUser.LoginProjectArea, Resources.Lan.PleaseSelect);
							 | 
						|||
| 
								 | 
							
								                BindGrid();
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        #region BindGrid
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        private void BindGrid()
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            string projectIds = BLL.Base_ProjectService.GetStrProjectIds(this.CurrUser.UserId, null);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								            string strSql = @"select o.LogId, o.OperationTime,o.Ip,o.HostName,u.UserName,p.ProjectName,
							 | 
						|||
| 
								 | 
							
								                                    (o.ButtonName+menu.MenuName) AS OperationLog
							 | 
						|||
| 
								 | 
							
								                                from dbo.Sys_Log o 
							 | 
						|||
| 
								 | 
							
								                                     left join Sys_User u on u.UserId=o.UserId
							 | 
						|||
| 
								 | 
							
								                                     left join Base_Project p on p.ProjectId=o.ProjectId
							 | 
						|||
| 
								 | 
							
								                                     LEFT JOIN dbo.Sys_Menu menu ON menu.MenuId=o.MenuId
							 | 
						|||
| 
								 | 
							
								                                 where 1=1";
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								            if (this.GetLanguage == "en-US")
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                strSql = @"select o.LogId, o.OperationTime,o.Ip,o.HostName,u.UserName,p.ProjectName,
							 | 
						|||
| 
								 | 
							
								                                 ((SELECT TOP 1 b.ButtonEnName FROM dbo.Sys_ButtonToMenu b WHERE b.MenuId=o.MenuId AND b.ButtonName=o.ButtonName)
							 | 
						|||
| 
								 | 
							
								                                    +menu.MenuEnName) AS OperationLog
							 | 
						|||
| 
								 | 
							
								                            from dbo.Sys_Log o 
							 | 
						|||
| 
								 | 
							
								                            left join Sys_User u on u.UserId=o.UserId
							 | 
						|||
| 
								 | 
							
								                            left join Base_Project p on p.ProjectId=o.ProjectId
							 | 
						|||
| 
								 | 
							
								                            LEFT JOIN dbo.Sys_Menu menu ON menu.MenuId=o.MenuId
							 | 
						|||
| 
								 | 
							
								                            where 1=1";
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								            List<SqlParameter> listStr = new List<SqlParameter>();
							 | 
						|||
| 
								 | 
							
								            if (drpProject.SelectedValue != BLL.Const._Null)
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                strSql += " AND o.ProjectId = @ProjectId";
							 | 
						|||
| 
								 | 
							
								                listStr.Add(new SqlParameter("@ProjectId", this.drpProject.SelectedValue));
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            else
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                strSql += " AND (CHARINDEX(o.ProjectId,@ProjectId)>0 OR o.ProjectId is null) ";
							 | 
						|||
| 
								 | 
							
								                listStr.Add(new SqlParameter("@ProjectId", projectIds));
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								            if (!string.IsNullOrEmpty(this.txtUserName.Text.Trim()))
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                strSql += " AND u.UserName LIKE @UserName";
							 | 
						|||
| 
								 | 
							
								                listStr.Add(new SqlParameter("@UserName", "%" + this.txtUserName.Text.Trim() + "%"));
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								            if (!string.IsNullOrEmpty(this.txtStartDate.Text.Trim()))
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                strSql += " AND o.OperationTime >= @OperationTime";
							 | 
						|||
| 
								 | 
							
								                listStr.Add(new SqlParameter("@OperationTime", Convert.ToDateTime(txtStartDate.Text.Trim())));
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								            if (!string.IsNullOrEmpty(this.txtEndDate.Text.Trim()))
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                strSql += " AND o.OperationTime <= @OperationTime";
							 | 
						|||
| 
								 | 
							
								                listStr.Add(new SqlParameter("@OperationTime", Convert.ToDateTime(txtEndDate.Text.Trim())));
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								            strSql += " order by o.OperationTime desc ,o.ProjectId";
							 | 
						|||
| 
								 | 
							
								            SqlParameter[] parameter = listStr.ToArray();
							 | 
						|||
| 
								 | 
							
								            DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								            Grid1.RecordCount = tb.Rows.Count;
							 | 
						|||
| 
								 | 
							
								            var table = this.GetPagedDataTable(Grid1, tb);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								            Grid1.DataSource = table;
							 | 
						|||
| 
								 | 
							
								            Grid1.DataBind();
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        /// <summary>
							 | 
						|||
| 
								 | 
							
								        /// 查询
							 | 
						|||
| 
								 | 
							
								        /// </summary>
							 | 
						|||
| 
								 | 
							
								        /// <param name="sender"></param>
							 | 
						|||
| 
								 | 
							
								        /// <param name="e"></param>
							 | 
						|||
| 
								 | 
							
								        protected void btnQuery_Click(object sender, EventArgs e)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            this.BindGrid();
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								        #endregion
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        /// <summary>
							 | 
						|||
| 
								 | 
							
								        /// 分页下拉选择
							 | 
						|||
| 
								 | 
							
								        /// </summary>
							 | 
						|||
| 
								 | 
							
								        /// <param name="sender"></param>
							 | 
						|||
| 
								 | 
							
								        /// <param name="e"></param>
							 | 
						|||
| 
								 | 
							
								        protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue);
							 | 
						|||
| 
								 | 
							
								            BindGrid();
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            Grid1.PageIndex = e.NewPageIndex;
							 | 
						|||
| 
								 | 
							
								            BindGrid();
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        protected void Grid1_Sort(object sender, FineUIPro.GridSortEventArgs e)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            Grid1.SortDirection = e.SortDirection;
							 | 
						|||
| 
								 | 
							
								            Grid1.SortField = e.SortField;
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								            BindGrid();
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    }
							 | 
						|||
| 
								 | 
							
								}
							 |