예제 #1
0
 public static void WriteLogFromCache()
 {
     lock (lockObj)
     {
         //累加上次记录的日志
         if (logCaches.Count > 0)
         {
             var list       = new Dictionary <string, LogItem>(logCaches);
             var group      = list.Values.GroupBy(b => b.Path);
             var removeKeys = new List <string>();
             foreach (var g in group)
             {
                 var logs = new LogItemArry()
                 {
                     logs = g.ToList()
                 };
                 try
                 {
                     WriteLine(logs.ToString(), g.Key);
                     removeKeys.AddRange(g.Select(b => b.Id));
                 }
                 catch (Exception ero)
                 {
                     LastError = ero.ToString();
                 }
             }
             foreach (var key in removeKeys)
             {
                 logCaches.Remove(key);
             }
         }
     }
 }
예제 #2
0
 public static void WriteLogFromCache()
 {
     lock (lockObj)
     {
         Writing = true;
         //累加上次记录的日志
         if (logCaches.Count > 0)
         {
             Dictionary <string, LogItemArry> list = new Dictionary <string, LogItemArry>(logCaches);
             foreach (KeyValuePair <string, LogItemArry> entry in list)
             {
                 LogItemArry logitemArry = entry.Value;
                 LastError = null;
                 try
                 {
                     WriteLine(logitemArry.ToString(), entry.Key);
                 }
                 catch (Exception ero)
                 {
                     LastError = ero.ToString();
                 }
                 logCaches.Remove(entry.Key);
             }
         }
         //System.Threading.Thread.Sleep(6000);
         Writing = false;
     }
 }