private void Search() { try { BizLog bizLog = new BizLog(); BmLogPagingRq bmLogRq = new BmLogPagingRq(); bmLogRq.Paging.CurPage = ucPaging.CurPage; bmLogRq.Paging.PageSize = ucPaging.PageSize; if (!string.IsNullOrEmpty(tbxStartDate.Text) && !string.IsNullOrEmpty(tbxEndDate.Text)) { bmLogRq.StartDate = Convert.ToDateTime(tbxStartDate.Text + " 00:00:00"); bmLogRq.EndDate = Convert.ToDateTime(tbxEndDate.Text + " 23:59:59"); } if (ddlResult.SelectedValue != "-1") bmLogRq.Log.Result = ddlResult.SelectedValue; if (ddlCallerMethod.SelectedValue != "-1") bmLogRq.Log.CallerMethod = ddlCallerMethod.SelectedValue; if (ddlCalleeMethod.SelectedValue != "-1") bmLogRq.Log.CalleeMethod = ddlCalleeMethod.SelectedValue; var result = bizLog.GetLogPagingList(bmLogRq); ucPaging.TotalRowCount = result.TotalCount; rptLogList.DataSource = result.List; rptLogList.DataBind(); } catch (Exception ex) { cLib.WriteLog("Exception", ex.Message); } }
/// <summary>로그 Paging 조회</summary> public BmLogPagingRs GetLogPagingList(BmLogPagingRq pDataRq) { try { using (SqlConn = new SqlConnection(ConnectionString)) { using (TransactionScope scope = new TransactionScope()) { try { SqlConn.Open(); var result = dac.GetLogPagingList(pDataRq); scope.Complete(); return result; } catch (Exception ex) { throw ex; } finally { SqlConn.Dispose(); } } } } catch (Exception ex) { WriteLog("Exception", ex.Message); throw; } }
/// <summary>로그 Paging 조회</summary> public BmLogPagingRs GetLogPagingList(BmLogPagingRq pDataRq) { try { #region SetQuery StringBuilder sbQuery = new StringBuilder(@"SELECT COUNT(Seq) AS 'TotalRowCnt' FROM tbResultLog WHERE 1=1 --@@Result --@@CallerMethod --@@CalleeMethod --@@RegDt SELECT * FROM ( SELECT ROW_NUMBER() OVER(ORDER BY RegDt DESC) AS 'RowNum' , * FROM tbResultLog WHERE 1=1 --@@Result --@@CallerMethod --@@CalleeMethod --@@RegDt ) A WHERE 1=1"); if (string.IsNullOrEmpty(pDataRq.Log.Result) == false) sbQuery = sbQuery.Replace("--@@Result", " AND Result = @Result"); if (string.IsNullOrEmpty(pDataRq.Log.CallerMethod) == false) sbQuery = sbQuery.Replace("--@@CallerMethod", " AND CallerMethod = @CallerMethod"); if (string.IsNullOrEmpty(pDataRq.Log.CalleeMethod) == false) sbQuery = sbQuery.Replace("--@@CalleeMethod", " AND CalleeMethod = @CalleeMethod"); if (pDataRq.StartDate != null && pDataRq.EndDate != null) sbQuery = sbQuery.Replace("--@@RegDt", " AND RegDt BETWEEN @StartDate AND @EndDate"); sbQuery.AppendLine(" AND RowNum BETWEEN (@PageSize * @CurPage) + 1 AND ((@PageSize * @CurPage) + @PageSize)"); #endregion SetQuery BmLogPagingRs result = new BmLogPagingRs(); SqlCommand cmd = new SqlCommand(); cmd.Connection = SqlConn; cmd.CommandType = System.Data.CommandType.Text; cmd.CommandText = sbQuery.ToString(); #region Set Parameters cmd.Parameters.Add("@PageSize", SqlDbType.Int, 0).Value = pDataRq.Paging.PageSize; cmd.Parameters.Add("@CurPage", SqlDbType.Int, 0).Value = pDataRq.Paging.CurPage; if (string.IsNullOrEmpty(pDataRq.Log.Result) == false) cmd.Parameters.Add("@Result", SqlDbType.VarChar, 50).Value = pDataRq.Log.Result; if (string.IsNullOrEmpty(pDataRq.Log.CallerMethod) == false) cmd.Parameters.Add("@CallerMethod", SqlDbType.VarChar, 100).Value = pDataRq.Log.CallerMethod; if (string.IsNullOrEmpty(pDataRq.Log.CalleeMethod) == false) cmd.Parameters.Add("@CalleeMethod", SqlDbType.VarChar, 100).Value = pDataRq.Log.CalleeMethod; if (pDataRq.StartDate != null && pDataRq.EndDate != null) { cmd.Parameters.Add("@StartDate", SqlDbType.DateTime).Value = pDataRq.StartDate; cmd.Parameters.Add("@EndDate", SqlDbType.DateTime).Value = pDataRq.EndDate; } #endregion Set Parameters SqlDataAdapter da = new SqlDataAdapter(cmd); DataSet ds = new DataSet(); da.Fill(ds); if (ds.Tables[0].Rows.Count == 1) { result.TotalCount = Convert.ToInt32(ds.Tables[0].Rows[0]["TotalRowCnt"].ToString()); if (result.TotalCount > 0 && ds.Tables[1].Rows.Count > 0) { result.List = ConvertToBmLog(ds.Tables[1]); } } da.Dispose(); cmd.Dispose(); return result; } catch (Exception ex) { throw ex; } }