Пример #1
0
 /// <summary>
 /// 清除队列,并保存队列中已有数据
 /// </summary>
 /// <param name="save"></param>
 /// <returns></returns>
 public static bool ClearQueue(bool save)
 {
     lock (queuedStatsList.SyncRoot)
     {
         if (save)
         {
             TopicView[] eva = new TopicView[queuedStatsList.Count];
             queuedStatsList.CopyTo(eva, 0);
             ClearTrackTopicQueue(new TopicViewCollection <TopicView>(eva));
         }
         queuedStatsList.Clear();
     }
     return(true);
 }
Пример #2
0
        //public static bool ClearQueue(bool save)
        //{
        //	lock (queuedStatsList)
        //	{
        //		if (save)
        //		{
        //			TopicView[] array = new TopicView[queuedStatsList.Count];
        //			queuedStatsList.CopyTo(array, 0);
        //			ClearTrackTopicQueue(new TopicViewCollection<TopicView>(array));
        //		}
        //		queuedStatsList.Clear();
        //	}
        //	return true;
        //}

        static bool AddQuedStats(TopicView tv)
        {
            if (tv == null)
            {
                return(false);
            }

            if (queuedAllowCount != GeneralConfigInfo.Current.TopicQueueStatsCount || queuedStatsList == null)
            {
                SetQueueCount();
            }
            lock (queuedStatsList)
            {
                if ((queuedStatsList.ViewCount >= queuedAllowCount || queuedStatsList.Count >= 5) && (queuedStatsList.ViewCount >= queuedAllowCount || queuedStatsList.Count >= 5))
                {
                    var array = new TopicView[queuedStatsList.Count];
                    queuedStatsList.CopyTo(array, 0);
                    ClearTrackTopicQueue(new TopicViewCollection <TopicView>(array));
                    queuedStatsList.Clear();
                    queuedStatsList.ViewCount = 0;
                }
                bool flag = false;
                foreach (TopicView current in queuedStatsList)
                {
                    if (current.TopicID == tv.TopicID)
                    {
                        current.ViewCount += tv.ViewCount;
                        flag = true;
                        break;
                    }
                }
                if (!flag)
                {
                    queuedStatsList.Add(tv);
                }
            }
            queuedStatsList.ViewCount = queuedStatsList.ViewCount + 1;
            return(true);
        }