Exemple #1
0
 public void UpdateQueryStatsAsync()
 {
     AsyncManager.OutstandingOperations.Increment();
     string host = Util.Host;
     var uid = Util.UserId;
     ThreadPool.QueueUserWorkItem((e) =>
     {
         Util.SessionId = Guid.NewGuid().ToString();
         var Db = new CMSDataContext(Util.GetConnectionString(host));
         var d = DateTime.Today.Subtract(DateTime.Parse("1/1/1900")).Days;
         var list = Db.QueryStats.Where(ss => ss.RunId == d);
         foreach (var a in Db.QueryStatClauses())
         {
             var st = list.SingleOrDefault(ss => ss.StatId == a[0]);
             if (st == null)
             {
                 st = new QueryStat { StatId = a[0], Description = a[1], RunId = d, Runtime = DateTime.Now };
                 Db.QueryStats.InsertOnSubmit(st);
             }
             st.Count = Db.PeopleQuery(a[0] + ":" + a[1]).Count();
             Db.SubmitChanges();
         }
         AsyncManager.OutstandingOperations.Decrement();
     });
 }