Ejemplo n.º 1
0
        /// <summary>
        /// 新增稽核軌跡
        /// </summary>
        /// <param name="codeUserDao"></param>
        /// <param name="codeUser"></param>
        /// <param name="conn"></param>
        /// <param name="transaction"></param>
        public void procTrackLog(string type, CodeUserDao codeUserDao, CODE_USER codeUser, SqlConnection conn, SqlTransaction transaction)
        {
            PIA_LOG_MAIN piaLog = new PIA_LOG_MAIN();

            piaLog.TRACKING_TYPE     = "A";
            piaLog.ACCESS_ACCOUNT    = Session["UserID"].ToString();
            piaLog.ACCOUNT_NAME      = Session["UserName"].ToString();
            piaLog.PROGFUN_NAME      = "UserReview";
            piaLog.ACCESSOBJ_NAME    = "CodeUser";
            piaLog.EXECUTION_TYPE    = type;
            piaLog.EXECUTION_CONTENT = codeUserDao.userLogContent(codeUser);
            piaLog.AFFECT_ROWS       = 1;
            piaLog.PIA_OWNER1        = codeUser.USER_ID;
            piaLog.PIA_OWNER2        = "";
            piaLog.PIA_TYPE          = "0100000000";


            PiaLogMainDao piaLogMainDao = new PiaLogMainDao();

            piaLogMainDao.Insert(piaLog, conn, transaction);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 主頁面查詢紀錄至稽核軌跡
        /// </summary>
        /// <param name="userMgrModel"></param>
        /// <param name="codeUserDao"></param>
        /// <param name="cnt"></param>
        public void procTrackLog(UserMgrModel userMgrModel, CodeUserDao codeUserDao, int cnt)
        {
            string strConn = DbUtil.GetDBTreasuryConnStr();

            using (SqlConnection conn = new SqlConnection(strConn))
            {
                conn.Open();

                SqlTransaction transaction = conn.BeginTransaction("Transaction");

                try
                {
                    PIA_LOG_MAIN piaLog = new PIA_LOG_MAIN();
                    piaLog.TRACKING_TYPE  = "A";
                    piaLog.ACCESS_ACCOUNT = Session["UserID"].ToString();
                    //piaLog.ACCOUNT_NAME = Session["UserName"].ToString();
                    piaLog.PROGFUN_NAME      = "UserMgrController";
                    piaLog.ACCESSOBJ_NAME    = "CodeUser";
                    piaLog.EXECUTION_TYPE    = "Q";
                    piaLog.EXECUTION_CONTENT = codeUserDao.trackLogContent(userMgrModel);
                    piaLog.AFFECT_ROWS       = cnt;
                    piaLog.PIA_OWNER1        = "";
                    piaLog.PIA_OWNER2        = "";
                    piaLog.PIA_TYPE          = "0100000000";


                    PiaLogMainDao piaLogMainDao = new PiaLogMainDao();
                    piaLogMainDao.Insert(piaLog, conn, transaction);

                    transaction.Commit();
                }
                catch (Exception e)
                {
                    transaction.Rollback();
                    logger.Error("[procTrackLog]其它錯誤:" + e.ToString());
                }
            }
        }
Ejemplo n.º 3
0
        private void writeLog(String type, bool bSuccess, String userId, CODE_USER codeUser)
        {
            CommonUtil commonUtil = new CommonUtil();
            //logModel
            Log log = new Log();

            log.CFUNCTION = "I".Equals(type) ? "登入作業" : "登出作業";
            log.CACTION   = "L";
            log.CCONTENT  = "UserId:" + userId + "| UserName:" + commonUtil.GetIPAddress() + "|" + ("I".Equals(type) ? "登入成功" : "登出成功");

            //PiaLogMainModel

            PIA_LOG_MAIN piaLogMain = new PIA_LOG_MAIN();

            piaLogMain.TRACKING_TYPE     = "B";
            piaLogMain.ACCESS_ACCOUNT    = userId;
            piaLogMain.ACCOUNT_NAME      = "";
            piaLogMain.PROGFUN_NAME      = "AccountController";
            piaLogMain.EXECUTION_CONTENT = userId;
            piaLogMain.AFFECT_ROWS       = 0;
            piaLogMain.PIA_TYPE          = "0000000000";



            if (bSuccess)
            {
                CodeUserDao codeUserDao = new CodeUserDao();
                //更新login/logout日期時間
                if ("I".Equals(type))
                {
                    codeUserDao.updateLogInOut(userId, "I");
                }
                //codeUser.cLoginDateTime = DateTime.Now;
                else
                {
                    codeUserDao.updateLogInOut(userId, "O");
                }
                //codeUser.cLogoutDateTime = DateTime.Now;



                //寫入系統LOG

                LogDao.Insert(log, userId);

                //寫入稽核軌跡
                //piaLogMain.ACCOUNT_NAME = codeUser.CUSERNAME;
                piaLogMain.EXECUTION_TYPE = "I".Equals(type) ? "LS" : "LO";
                piaLogMain.ACCESSOBJ_NAME = "CodeUser";
                PiaLogMainDao piaLogMainDao = new PiaLogMainDao();
                piaLogMainDao.Insert(piaLogMain);
            }
            else
            {
                //寫入系統LOG
                log.CCONTENT = "UserId:" + userId + "| UserName:" + commonUtil.GetIPAddress() + "|" + "登入失敗";
                LogDao.Insert(log, userId);

                //寫入稽核軌跡
                piaLogMain.EXECUTION_TYPE = "LF";
                piaLogMain.ACCESSOBJ_NAME = "AD";
                PiaLogMainDao piaLogMainDao = new PiaLogMainDao();
                piaLogMainDao.Insert(piaLogMain);
            }
        }