Пример #1
0
        private static void Run()
        {
            while (bRun)
            {
                try
                {
                    while (LogDataQueue.Count > 0)
                    {
                        LogData objLogData;
                        lock (LogDataQueue)
                        {
                            objLogData = LogDataQueue.Dequeue();
                        }

                        if (objLogData.Ex != null)
                        {
                            TextLog.Write(objLogData.Ex, "");
                        }
                        else if (objLogData.MessageData != null && objLogData.MessageData.Length > 0)
                        {
                            TextLog.WriteLog(objLogData.MessageData);
                        }
                        else
                        {
                            TextLog.WriteQuery(objLogData.QueryData);
                        }
                    }
                }
                catch (Exception ex)
                {
                    TextLog.Write(ex, "Run");
                }
                objAre.WaitOne(5000, false);
            }
        }
Пример #2
0
 private static void Stop()
 {
     try
     {
         bRun = false;
         objAre.Set();
         System.Threading.Thread.Sleep(1000);
         objMainThread = null;
         LogDataQueue  = null;
     }
     catch (Exception ex)
     {
         TextLog.Write(ex, "Stop");
     }
 }
Пример #3
0
        public static void Write(Exception ex)
        {
            try
            {
                if (LogDataQueue == null)
                {
                    Start();
                }

                LogData objLogData = new LogData();

                objLogData.Ex = ex;
                lock (LogDataQueue)
                {
                    LogDataQueue.Enqueue(objLogData);
                }
                objAre.Set();
            }
            catch (Exception)
            {
                TextLog.Write(ex, "Write(ex, strfname , userid)");
            }
        }
Пример #4
0
        public static void WriteQuery(string strQuery)
        {
            try
            {
                bool isWriteLog = true;
                System.Configuration.Configuration myConfiguration = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("~");

                if (myConfiguration.AppSettings.Settings["IsWriteLog"] != null)
                {
                    if (!string.IsNullOrEmpty(myConfiguration.AppSettings.Settings["IsWriteLog"].Value))
                    {
                        isWriteLog = Convert.ToBoolean(myConfiguration.AppSettings.Settings["IsWriteLog"].Value);
                    }
                }


                if (isWriteLog)
                {
                    if (LogDataQueue == null)
                    {
                        Start();
                    }

                    LogData objLogData = new LogData();
                    objLogData.QueryData = strQuery;
                    lock (LogDataQueue)
                    {
                        LogDataQueue.Enqueue(objLogData);
                    }
                    objAre.Set();
                }
            }
            catch (Exception ex)
            {
                TextLog.Write(ex, "WriteQuery(strMessage , userid)");
            }
        }