コード例 #1
0
ファイル: ConnectLogList.aspx.cs プロジェクト: chae87/First
    private void Search()
    {
        try
        {
            BizLog bizLog = new BizLog();

            BmConnectLogPagingRq bmLogRq = new BmConnectLogPagingRq();

            bmLogRq.Paging.CurPage = ucPaging.CurPage;
            bmLogRq.Paging.PageSize = ucPaging.PageSize;

            if (!string.IsNullOrEmpty(tbxStartDate.Text) && !string.IsNullOrEmpty(tbxEndDate.Text))
            {
                bmLogRq.SearchDateType = ddlDateType.SelectedValue;
                bmLogRq.StartDate = Convert.ToDateTime(tbxStartDate.Text + " 00:00:00");
                bmLogRq.EndDate = Convert.ToDateTime(tbxEndDate.Text + " 23:59:59");
            }

            if (string.IsNullOrEmpty(tbxSearch.Text) == false)
            {
                switch (ddlSearchType.SelectedValue)
                {
                    case "IP":
                        bmLogRq.ConnectLog.Ip = tbxSearch.Text;
                        break;
                    case "LINK":
                        bmLogRq.ConnectLog.LinkUrl = tbxSearch.Text;
                        break;
                    case "ID":
                        bmLogRq.ConnectLog.Id = tbxSearch.Text;
                        break;
                }
            }

            var result = bizLog.GetConnectLogPagingList(bmLogRq);

            ucPaging.TotalRowCount = result.TotalCount;

            rptConnectLogList.DataSource = result.List;
            rptConnectLogList.DataBind();
        }
        catch (Exception ex)
        {
            cLib.WriteLog("Exception", ex.Message);
        }
    }
コード例 #2
0
ファイル: BizLog.cs プロジェクト: chae87/First
        /// <summary>접속내역 Paging 조회</summary>
        public BmConnectLogPagingRs GetConnectLogPagingList(BmConnectLogPagingRq pDataRq)
        {
            try
            {
                using (SqlConn = new SqlConnection(ConnectionString))
                {
                    using (TransactionScope scope = new TransactionScope())
                    {
                        try
                        {
                            SqlConn.Open();

                            var result = dac.GetConnectLogPagingList(pDataRq);

                            scope.Complete();

                            return result;

                        }
                        catch (Exception ex)
                        {
                            throw ex;
                        }
                        finally
                        {
                            SqlConn.Dispose();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                WriteLog("Exception", ex.Message);
                throw;
            }
        }
コード例 #3
0
ファイル: DacLog.cs プロジェクト: chae87/First
        /// <summary>접속내역 Paging 조회</summary>
        public BmConnectLogPagingRs GetConnectLogPagingList(BmConnectLogPagingRq pDataRq)
        {
            try
            {
                #region SetQuery

                StringBuilder sbQuery = new StringBuilder(@"SELECT COUNT(Seq) AS 'TotalRowCnt' FROM tbConnectLog
                                                            WHERE 1=1
                                                                --@@SessionId
                                                                --@@Ip
                                                                --@@LinkUrl
                                                                --@@Id
                                                                --@@LoginDate
                                                                --@@ConnectDate
                                                                --@@DisconnectDate
                                                            SELECT
                                                                *
                                                            FROM
                                                                (
                                                                SELECT
                                                                    ROW_NUMBER() OVER(ORDER BY ConnectDate DESC) AS 'RowNum'
                                                                    , *
                                                                FROM
                                                                    tbConnectLog
                                                                WHERE 1=1
                                                                    --@@SessionId
                                                                    --@@Ip
                                                                    --@@LinkUrl
                                                                    --@@Id
                                                                    --@@LoginDate
                                                                    --@@ConnectDate
                                                                    --@@DisconnectDate
                                                                ) A
                                                            WHERE 1=1");

                if (string.IsNullOrEmpty(pDataRq.ConnectLog.SessionId) == false)
                    sbQuery = sbQuery.Replace("--@@SessionId", " AND SessionId LIKE '%' + @SessionId + '%'");
                if (string.IsNullOrEmpty(pDataRq.ConnectLog.Ip) == false)
                    sbQuery = sbQuery.Replace("--@@Ip", " AND Ip LIKE '%' + @Ip + '%'");
                if (string.IsNullOrEmpty(pDataRq.ConnectLog.LinkUrl) == false)
                    sbQuery = sbQuery.Replace("--@@LinkUrl", " AND LinkUrl LIKE '%' + @LinkUrl + '%'");
                if (string.IsNullOrEmpty(pDataRq.ConnectLog.Id) == false)
                    sbQuery = sbQuery.Replace("--@@Id", " AND Id LIKE '%' + @Id + '%'");
                if (pDataRq.StartDate != null && pDataRq.EndDate != null && string.IsNullOrEmpty(pDataRq.SearchDateType) == false)
                {
                    switch (pDataRq.SearchDateType)
                    {
                        case "LD":
                            sbQuery = sbQuery.Replace("--@@LoginDate", " AND LoginDate BETWEEN @StartDate AND @EndDate");
                            break;
                        case "CD":
                            sbQuery = sbQuery.Replace("--@@ConnectDate", " AND ConnectDate BETWEEN @StartDate AND @EndDate");
                            break;
                        case "DD":
                            sbQuery = sbQuery.Replace("--@@DisconnectDate", " AND DisConnectDate BETWEEN @StartDate AND @EndDate");
                            break;
                    }
                }

                sbQuery.AppendLine(" AND RowNum BETWEEN (@PageSize * @CurPage) + 1 AND ((@PageSize * @CurPage) + @PageSize)");

                #endregion SetQuery

                BmConnectLogPagingRs result = new BmConnectLogPagingRs();
                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.ConnectLog.SessionId) == false)
                    cmd.Parameters.Add("@SessionId", SqlDbType.VarChar).Value = pDataRq.ConnectLog.SessionId;
                if (string.IsNullOrEmpty(pDataRq.ConnectLog.Ip) == false)
                    cmd.Parameters.Add("@Ip", SqlDbType.VarChar, 15).Value = pDataRq.ConnectLog.Ip;
                if (string.IsNullOrEmpty(pDataRq.ConnectLog.LinkUrl) == false)
                    cmd.Parameters.Add("@LinkUrl", SqlDbType.VarChar).Value = pDataRq.ConnectLog.LinkUrl;
                if (string.IsNullOrEmpty(pDataRq.ConnectLog.Id) == false)
                    cmd.Parameters.Add("@Id", SqlDbType.VarChar, 20).Value = pDataRq.ConnectLog.Id;
                if (pDataRq.StartDate != null && pDataRq.EndDate != null && string.IsNullOrEmpty(pDataRq.SearchDateType) == false)
                {
                    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 = ConvertToBmConnectLog(ds.Tables[1]);
                    }
                }

                da.Dispose();
                cmd.Dispose();

                return result;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }