예제 #1
0
파일: BizLog.cs 프로젝트: chae87/First
        /// <summary>로그 등록</summary>
        public void WriteLog(BmLog pDataRq)
        {
            try
            {
                using (SqlConn = new SqlConnection(ConnectionString))
                {
                    using (TransactionScope scope = new TransactionScope())
                    {
                        try
                        {
                            SqlConn.Open();

                            dac.WriteLog(pDataRq);

                            scope.Complete();
                        }
                        catch (Exception ex)
                        {
                            throw ex;
                        }
                        finally
                        {
                            SqlConn.Dispose();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #2
0
파일: BmLog.cs 프로젝트: chae87/First
 public BmLogPagingRq()
 {
     Log = new BmLog();
     Paging = new BmPaging();
 }
예제 #3
0
파일: BizLog.cs 프로젝트: chae87/First
        /// <summary>로그 조회</summary>
        public List<BmLog> GetLogList(BmLog pDataRq)
        {
            try
            {
                using (SqlConn = new SqlConnection(ConnectionString))
                {
                    using (TransactionScope scope = new TransactionScope())
                    {
                        try
                        {
                            SqlConn.Open();

                            var result = dac.GetLogList(pDataRq);

                            scope.Complete();

                            return result;

                        }
                        catch (Exception ex)
                        {
                            throw ex;
                        }
                        finally
                        {
                            SqlConn.Dispose();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                WriteLog("Exception", ex.Message);
                throw;
            }
        }
예제 #4
0
파일: DacLog.cs 프로젝트: chae87/First
        /// <summary>로그정보 Convert DataTable -> BmLog</summary>
        private List<BmLog> ConvertToBmLog(DataTable dt)
        {
            List<BmLog> list = new List<BmLog>();

            foreach (DataRow dr in dt.Rows)
            {
                BmLog data = new BmLog();

                data.Seq = (int)dr["Seq"];
                data.PageUrl = dr["PageUrl"].ToString();
                data.CallerMethod = dr["CallerMethod"].ToString();
                data.CalleeMethod = dr["CalleeMethod"].ToString();
                data.Result = dr["Result"].ToString();
                data.Msg = dr["Msg"].ToString();
                data.RegDt = (DateTime)dr["RegDt"];

                list.Add(data);
            }

            return list;
        }
예제 #5
0
파일: DacLog.cs 프로젝트: chae87/First
        /// <summary>로그 등록</summary>
        public void WriteLog(BmLog pDataRq)
        {
            try
            {
                #region SetQuery

                string strQuery = @"INSERT INTO tbResultLog
                                        (PageUrl
                                        , CallerMethod
                                        , CalleeMethod
                                        , Result
                                        , Msg
                                        )
                                    Values
                                        (@PageUrl
                                        , @CallerMethod
                                        , @CalleeMethod
                                        , @Result
                                        , @Msg)";

                #endregion SetQuery

                SqlCommand cmd = new SqlCommand();

                cmd.Connection = SqlConn;
                cmd.CommandType = System.Data.CommandType.Text;
                cmd.CommandText = strQuery.ToString();

                #region Set Parameters

                cmd.Parameters.Add("@PageUrl", SqlDbType.VarChar, 200).Value = pDataRq.PageUrl;
                cmd.Parameters.Add("@CallerMethod", SqlDbType.VarChar, 100).Value = pDataRq.CallerMethod;
                cmd.Parameters.Add("@CalleeMethod", SqlDbType.VarChar, 100).Value = pDataRq.CalleeMethod;
                cmd.Parameters.Add("@Result", SqlDbType.VarChar, 50).Value = pDataRq.Result;
                cmd.Parameters.Add("@Msg", SqlDbType.VarChar, 0).Value = pDataRq.Msg;

                #endregion Set Parameters

                cmd.ExecuteNonQuery();
                cmd.Dispose();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #6
0
파일: DacLog.cs 프로젝트: chae87/First
        /// <summary>로그 조회</summary>
        public List<BmLog> GetLogList(BmLog pDataRq)
        {
            try
            {
                #region SetQuery

                StringBuilder sbQuery = new StringBuilder(@"SELECT *
                                                            FROM tbResultLog
                                                            WHERE 1=1");

                if (pDataRq.Seq > 0)
                    sbQuery.AppendLine(" AND Seq = @Seq");
                if (!string.IsNullOrEmpty(pDataRq.CallerMethod))
                    sbQuery.AppendLine(" AND CallerMethod = @CallerMethod");
                if (!string.IsNullOrEmpty(pDataRq.CalleeMethod))
                    sbQuery.AppendLine(" AND CalleeMethod = @CalleeMethod");
                if (!string.IsNullOrEmpty(pDataRq.Result))
                    sbQuery.AppendLine(" AND Result = @Result");

                sbQuery.AppendLine(" ORDER BY RegDt");

                #endregion SetQuery

                List<BmLog> result = new List<BmLog>();
                SqlCommand cmd = new SqlCommand();

                cmd.Connection = SqlConn;
                cmd.CommandType = System.Data.CommandType.Text;
                cmd.CommandText = sbQuery.ToString();

                #region Set Parameters

                if (pDataRq.Seq > 0)
                    cmd.Parameters.Add("@Seq", SqlDbType.Int, 0).Value = pDataRq.Seq;
                if (string.IsNullOrEmpty(pDataRq.CallerMethod) == false)
                    cmd.Parameters.Add("@CallerMethod", SqlDbType.VarChar, 100).Value = pDataRq.CallerMethod;
                if (string.IsNullOrEmpty(pDataRq.CalleeMethod) == false)
                    cmd.Parameters.Add("@CalleeMethod", SqlDbType.VarChar, 100).Value = pDataRq.CalleeMethod;
                if (string.IsNullOrEmpty(pDataRq.Result) == false)
                    cmd.Parameters.Add("@Result", SqlDbType.VarChar, 50).Value = pDataRq.Result;

                #endregion Set Parameters

                SqlDataReader reader = cmd.ExecuteReader();

                if (reader.HasRows)
                {
                    DataTable dt = new DataTable();

                    dt.Load(reader);
                    result = ConvertToBmLog(dt);
                }

                reader.Dispose();
                cmd.Dispose();

                return result;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #7
0
파일: CommonLib.cs 프로젝트: chae87/First
        /// <summary>로그 작성</summary>
        public void WriteLog(string pResult, string pMsg)
        {
            try
            {
                BmLog bmLog = new BmLog();
                StackTrace st = new StackTrace();

                bmLog.CallerMethod = st.GetFrame(2).GetMethod().Name != null ? st.GetFrame(2).GetMethod().Name : "";
                bmLog.CalleeMethod = st.GetFrame(1).GetMethod().Name != null ? st.GetFrame(1).GetMethod().Name : "";
                bmLog.PageUrl = HttpContext.Current != null ? HttpContext.Current.Request.Url.AbsoluteUri : "";
                bmLog.Result = pResult;
                bmLog.Msg = pMsg;

                BizLog bizLog = new BizLog();
                bizLog.WriteLog(bmLog);
            }
            catch (Exception ex)
            {
                if (pResult != "WriteLog")
                    WriteLog("WriteLog", ex.Message);
            }
        }