Ejemplo n.º 1
0
 /// <summary>변경내역 등록</summary>
 public void WriteUpdateHistory(BmUpdateHistory pDataRq)
 {
     try
     {
         dac.WriteUpdateHistory(pDataRq);
     }
     catch (Exception ex)
     {
         WriteLog("Exception", ex.Message);
         throw ex;
     }
 }
Ejemplo n.º 2
0
 public BmUpdateHistoryPagingRq()
 {
     UpdateHistory = new BmUpdateHistory();
     Paging = new BmPaging();
 }
Ejemplo n.º 3
0
        /// <summary>변경내역 조회</summary>
        public List<BmUpdateHistory> GetUpdateHistoryList(BmUpdateHistory pDataRq)
        {
            try
            {
                using (SqlConn = new SqlConnection(ConnectionString))
                {
                    using (TransactionScope scope = new TransactionScope())
                    {
                        try
                        {
                            SqlConn.Open();

                            var result = dac.GetUpdateHistoryList(pDataRq);

                            scope.Complete();

                            return result;

                        }
                        catch (Exception ex)
                        {
                            throw ex;
                        }
                        finally
                        {
                            SqlConn.Dispose();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                WriteLog("Exception", ex.Message);
                throw;
            }
        }
Ejemplo n.º 4
0
        /// <summary>변경내역 Convert DataTable -> BmUpdateHistory</summary>
        private List<BmUpdateHistory> ConvertToBmUpdateHistory(DataTable dt)
        {
            List<BmUpdateHistory> list = new List<BmUpdateHistory>();

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

                data.Seq = (int)dr["Seq"];
                data.CmdCode = (int)dr["CmdCode"];
                data.ObjectType = dr["ObjectType"].ToString();
                data.ObjectSeq = (int)dr["ObjectSeq"];
                data.ObjectData = dr["ObjectData"].ToString();
                data.PageUrl = dr["PageUrl"].ToString();
                data.PageMethod = dr["PageMethod"].ToString();
                data.Registrant = dr["Registrant"].ToString();
                data.RegDt = (DateTime)dr["RegDt"];

                if (data.CmdCode == Convert.ToInt32(HistoryCommandType.INSERT))
                {
                    data.CmdText = HistoryCommandType.INSERT.ToString();
                }
                else if (data.CmdCode == Convert.ToInt32(HistoryCommandType.UPDATE))
                {
                    data.CmdText = HistoryCommandType.UPDATE.ToString();
                }
                else if (data.CmdCode == Convert.ToInt32(HistoryCommandType.DELETE))
                {
                    data.CmdText = HistoryCommandType.DELETE.ToString();
                }

                list.Add(data);
            }

            return list;
        }
Ejemplo n.º 5
0
        /// <summary>변경내역 등록</summary>
        public void WriteUpdateHistory(BmUpdateHistory pDataRq)
        {
            try
            {
                #region SetQuery

                string strQuery = @"INSERT INTO tbUpdateHistory
                                        (ObjectType
                                        , ObjectSeq
                                        , CmdCode
                                        , ObjectData
                                        , PageUrl
                                        , PageMethod
                                        , Registrant)
                                    Values
                                        (@ObjectType
                                        , @ObjectSeq
                                        , @CmdCode
                                        , @ObjectData
                                        , @PageUrl
                                        , @PageMethod
                                        , @Registrant)";

                #endregion SetQuery

                int result = 0;
                SqlCommand cmd = new SqlCommand();

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

                #region Set Parameters

                cmd.Parameters.Add("@ObjectType", SqlDbType.VarChar, 50).Value = pDataRq.ObjectType;
                cmd.Parameters.Add("@ObjectSeq", SqlDbType.Int, 0).Value = pDataRq.ObjectSeq;
                cmd.Parameters.Add("@CmdCode", SqlDbType.Int, 0).Value = pDataRq.CmdCode;
                cmd.Parameters.Add("@ObjectData", SqlDbType.VarChar).Value = pDataRq.ObjectData;
                cmd.Parameters.Add("@PageUrl", SqlDbType.VarChar, 200).Value = pDataRq.PageUrl;
                cmd.Parameters.Add("@PageMethod", SqlDbType.VarChar, 100).Value = pDataRq.PageMethod;
                cmd.Parameters.Add("@Registrant", SqlDbType.VarChar, 20).Value = pDataRq.Registrant;

                #endregion Set Parameters

                result = cmd.ExecuteNonQuery();

                cmd.Dispose();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 6
0
        /// <summary>변경내역 조회</summary>
        public List<BmUpdateHistory> GetUpdateHistoryList(BmUpdateHistory pDataRq)
        {
            try
            {
                #region SetQuery

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

                if (pDataRq.CmdCode > 0)
                    sbQuery.AppendLine(" AND CmdCode = @CmdCode");
                if (!string.IsNullOrEmpty(pDataRq.ObjectType))
                    sbQuery.AppendLine(" AND ObjectType = @ObjectType");
                if (pDataRq.ObjectSeq > 0)
                    sbQuery.AppendLine(" AND ObjectSeq = @ObjectSeq");
                if (!string.IsNullOrEmpty(pDataRq.PageMethod))
                    sbQuery.AppendLine(" AND PageMethod = @PageMethod");
                if (!string.IsNullOrEmpty(pDataRq.Registrant))
                    sbQuery.AppendLine(" AND Registrant = @Registrant");

                sbQuery.AppendLine(" ORDER BY RegDt");

                #endregion SetQuery

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

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

                #region Set Parameters

                if (pDataRq.CmdCode > 0)
                    cmd.Parameters.Add("@CmdCode", SqlDbType.Int, 0).Value = pDataRq.CmdCode;
                if (string.IsNullOrEmpty(pDataRq.ObjectType) == false)
                    cmd.Parameters.Add("@ObjectType", SqlDbType.VarChar, 100).Value = pDataRq.ObjectType;
                if (pDataRq.ObjectSeq > 0)
                    cmd.Parameters.Add("@ObjectSeq", SqlDbType.Int, 0).Value = pDataRq.ObjectSeq;
                if (string.IsNullOrEmpty(pDataRq.PageMethod) == false)
                    cmd.Parameters.Add("@PageMethod", SqlDbType.VarChar, 100).Value = pDataRq.PageMethod;
                if (string.IsNullOrEmpty(pDataRq.Registrant) == false)
                    cmd.Parameters.Add("@Registrant", SqlDbType.VarChar, 20).Value = pDataRq.Registrant;

                #endregion Set Parameters

                SqlDataReader reader = cmd.ExecuteReader();

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

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

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

                return result;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 7
0
        /// <summary>변경이력 작성</summary>
        public void WriteHistory(object pObj, HistoryCommandType pCmdCode)
        {
            try
            {
                BmUpdateHistory bmUpdateHistory = new BmUpdateHistory();

                StackTrace st = new StackTrace();
                Type t = pObj.GetType();

                bmUpdateHistory.CmdCode = Convert.ToInt32(pCmdCode);
                bmUpdateHistory.PageMethod = st.GetFrame(3).GetMethod().Name;
                bmUpdateHistory.PageUrl = HttpContext.Current.Request.Url.AbsoluteUri;
                bmUpdateHistory.ObjectType = t.Name;
                bmUpdateHistory.ObjectSeq = (int)t.GetProperties().FirstOrDefault(o => o.Name.Equals("Seq")).GetValue(pObj);

                if (pCmdCode == HistoryCommandType.INSERT)
                {
                    bmUpdateHistory.Registrant = (string)t.GetProperties().FirstOrDefault(o => o.Name.Equals("Registrant")).GetValue(pObj);
                }
                else
                {
                    bmUpdateHistory.Registrant = (string)t.GetProperties().FirstOrDefault(o => o.Name.Equals("Modifyer")).GetValue(pObj);
                }

                foreach (System.Reflection.PropertyInfo prop in t.GetProperties())
                {
                    var hs = prop.GetCustomAttributesData().FirstOrDefault(o => o.AttributeType.Name.Equals("HistoryAttribute"));

                    if (hs != null)
                    {
                        var Record = hs.NamedArguments.FirstOrDefault(o => o.MemberName.Equals("Record"));

                        if (Record != null && (bool)Record.TypedValue.Value == true)
                        {
                            var DpName = hs.NamedArguments.FirstOrDefault(o => o.MemberName.Equals("Name"));

                            bmUpdateHistory.ObjectData += string.Format("[{0} = {1}]", DpName.TypedValue.Value, prop.GetValue(pObj));
                        }
                    }
                }
                BizLog bizLog = new BizLog();
                bizLog.WriteUpdateHistory(bmUpdateHistory);
            }
            catch (Exception ex)
            {
                throw;
            }
        }