Beispiel #1
0
 public void Add(UserOPLog item)
 {
     UserOPLogQueue.Enqueue(item);
     Interlocked.Increment(ref queueLength);
     lock (SynObject)
     {
         if (queueLength > 10 && !runFlag)
         {
             ThreadPool.QueueUserWorkItem(new WaitCallback(NewThreadFunc));
         }
     }
 }
Beispiel #2
0
        /// <summary> 添加日志
        /// </summary>
        /// <param name="item"></param>
        /// <param name="currAccDbName"></param>
        /// <returns></returns>
        public static bool Add(UserOPLog item, string currAccDbName)
        {
            Dictionary <string, string> DicParam = new Dictionary <string, string>();

            DicParam.Add("ClientUserID", item.userOP.UserID);
            DicParam.Add("OPName", item.userOP.OPName);
            DicParam.Add("LogID", System.Guid.NewGuid().ToString());
            DicParam.Add("SQLStr", item.sqlStr.Replace('\'', '"'));
            DicParam.Add("paramsStr", item.sqlParams.Replace('\'', '"'));
            DicParam.Add("OPTime", item.timeTicks.ToString());
            DicParam.Add("exeResult", item.exeResult ? "1" : "0");
            return(DBHelper.Submit_AddLog("添加日志", currAccDbName, "tl_ClientUser", "", "", DicParam));
        }
Beispiel #3
0
        private void NewThreadFunc(object state)
        {
            runFlag = true;
            UserOPLog item = null;

            while (UserOPLogQueue.TryDequeue(out item))
            {
                //将item送往用户操作日志表
                //访问数据库的操作写在这里
                BLL.OPLog.Add(item, GlobalStaticObj_Server.DbPrefix + GlobalStaticObj_Server.CommAccCode);
                Interlocked.Decrement(ref queueLength);
            }
            runFlag = false;
        }