Esempio n. 1
0
        /// <summary>
        /// 添加系统日志
        /// </summary>
        /// <returns></returns>
        protected void AddSysLog(string optType, string optContent, string system, string module, string otherMsg = "")
        {
            Type             t       = this.GetType();
            FuncMsgAttribute funcMsg = (FuncMsgAttribute)Attribute.GetCustomAttribute(t, typeof(FuncMsgAttribute));

            BaseSysLogModel sysLogModel = new BaseSysLogModel();

            sysLogModel.F_OptType    = optType;
            sysLogModel.F_OptContent = optContent;
            sysLogModel.F_OtherMsg   = otherMsg;

            try
            {
                sysLogModel.F_System = string.IsNullOrEmpty(system) ? Configs.GetSetting("systemFlag") : system;
                if (string.IsNullOrEmpty(module) && funcMsg != null)
                {
                    sysLogModel.F_Module = funcMsg.GetModuleFuncStr();
                }
                else
                {
                    sysLogModel.F_Module = module;
                }

                SysLogProvider.GetInstance().WirteSysLog(sysLogModel);
            }
            catch (Exception e)
            {
                MyLog.Error("批量写入日志出现错误", e);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 添加系统日志
        /// </summary>
        /// <returns></returns>
        protected void AddSysLog(string optType, string optContent, string otherMsg = "")
        {
            Type             t       = this.GetType();
            FuncMsgAttribute funcMsg = (FuncMsgAttribute)Attribute.GetCustomAttribute(t, typeof(FuncMsgAttribute));

            BaseSysLogModel sysLogModel = new BaseSysLogModel();

            sysLogModel.F_OptType    = optType;
            sysLogModel.F_OptContent = optContent;
            sysLogModel.F_OtherMsg   = otherMsg;

            try
            {
                sysLogModel.F_System = Configs.GetSetting("systemFlag");
                if (funcMsg == null)
                {
                    sysLogModel.F_Module = "";
                    MyLog.Error("未配置该方法的FuncMsg信息:" + t.FullName);
                }
                else
                {
                    sysLogModel.F_Module = funcMsg.GetModuleFuncStr();
                }

                SysLogProvider.GetInstance().WirteSysLog(sysLogModel);
            }
            catch (Exception e)
            {
                MyLog.Error("写入日志出现错误", e);
            }
        }
Esempio n. 3
0
 /// <summary>
 /// 对外开放的获取单例的方法,双重验证锁,以防止高并发
 /// </summary>
 /// <returns></returns>
 public static SysLogProvider GetInstance()
 {
     if (null == _instance)
     {
         lock (LockHelper)
         {
             if (null == _instance)
             {
                 _instance = new SysLogProvider();
             }
         }
     }
     return(_instance);
 }