Exemplo n.º 1
0
        /// <summary>
        /// 添加操作日志
        /// </summary>
        /// <param name="title">操作类型</param>
        /// <param name="actionDetails">详细描述</param>
        public bool AddSysLog(string title, string actionDetails)
        {
            Sys_Log SysLog = new Sys_Log();
            Manager manager = this.GetAdminInfo(); //获得当前管理员信息

            SysLog.UserId = manager.RoleId;
            SysLog.UserName = manager.UserName;
            SysLog.UserIp = DTRequest.GetIP();
            SysLog.ActionType = title;
            SysLog.ActionDetails = actionDetails;
            if (BLL_SysLog.AddLog(SysLog) > 0)  //添加操作日志
                return true;
            return false;
        }
Exemplo n.º 2
0
        /// <summary>
        /// 添加操作日志
        /// </summary>
        /// <param name="sysLog">
        /// </param>
        /// <returns>
        ///     添加成功: >0
        ///     失败    :  =0
        /// </returns>
        public int AddLog(Sys_Log sysLog)
        {
            var result = 0;
            try
            {
                StringBuilder strSql = new StringBuilder();
                strSql.Append(" insert into T_Sys_Log (");
                strSql.Append(" userId,userName,actionType,actionDetails,userIp)");
                strSql.Append(" values(");
                strSql.Append(" @userId,@userName,@actionType,@actionDetails,@userIp)");
                strSql.Append(" ;select @@IDENTITY");

                SqlParameter[] para =
                {
                    new SqlParameter("@userId",SqlDbType.Int),
                    new SqlParameter("@userName",SqlDbType.NVarChar,100),
                    new SqlParameter("@actionType",SqlDbType.NVarChar,100),
                    new SqlParameter("@actionDetails",SqlDbType.NVarChar,200),
                    new SqlParameter("@userIp",SqlDbType.NVarChar,30)
                };
                para[0].Value = sysLog.UserId;
                para[1].Value = sysLog.UserName;
                para[2].Value = sysLog.ActionType;
                para[3].Value = sysLog.ActionDetails;
                para[4].Value = sysLog.UserIp;

                object obj = SqlHelper.ExecuteScalar(SqlHelper.connString, CommandType.Text, strSql.ToString(), para);
                if (obj != null)
                {
                    result = Convert.ToInt32(obj);
                }
            }
            catch (Exception e)
            {
                Log4Net.LogWrite("err", "Med_DAL:DAL_SysLog//AddLog" + e.Message);  //发生异常,记录
            }
            return result;
        }
Exemplo n.º 3
0
        private static readonly DAL_SysLog dalSysLog = new DAL_SysLog(); //实例化

        #endregion Fields

        #region Methods

        /// <summary>
        /// 增加日志
        /// </summary>
        /// <param name="sysLog"></param>
        /// <returns>刚刚插入记录的主键编号</returns>
        public static int AddLog(Sys_Log sysLog)
        {
            return dalSysLog.AddLog(sysLog);
        }