Exemplo n.º 1
0
        /// <summary>
        /// 星球战
        /// </summary>
        static void Rank(PlanConfig planConfig)
        {
            try
            {

            }
            catch (Exception ex)
            {

                TraceLog.WriteError("星球战异常:{0}", ex);
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// 增加定时任务计划
 /// </summary>
 /// <param name="planConfig"></param>
 public static void Append(PlanConfig planConfig)
 {
     CheckDisposed();
     if (planConfig == null)
     {
         throw new ArgumentNullException("planConfig");
     }
     Initialize();
     _lockStrategy.TryEnterLock(() =>
     {
         planConfig.SetDiffInterval(_msInterval / 1000);
         _listenerQueue.Add(planConfig);
     });
 }
Exemplo n.º 3
0
 private static void DoNotify(PlanConfig planConfig)
 {
     try
     {
         if (planConfig != null && planConfig.Callback != null)
         {
             //Console.WriteLine("{0}-{1}>>listener begin callback", DateTime.Now.ToLongTimeString(), planConfig.Name);
             planConfig.Callback.BeginInvoke(planConfig, EndPlanAsync, planConfig);
         }
     }
     catch (Exception ex)
     {
         TraceLog.WriteError("TimeListener notify error:{0}", ex);
     }
 }
Exemplo n.º 4
0
 private static void DoNotify(PlanConfig planConfig)
 {
     if (planConfig != null && planConfig.Callback != null)
     {
         ThreadPool.QueueUserWorkItem(obj =>
         {
             try
             {
                 planConfig.Callback((PlanConfig)obj);
             }
             catch (Exception ex)
             {
                 TraceLog.WriteError("TimeListener notify error:{0}", ex);
             }
         }, planConfig);
     }
 }
Exemplo n.º 5
0
        private static void TimerCallback(object state)
        {
            if (_isRunning == 1)
            {
                TraceLog.ReleaseWrite("TimerCallback is busy, The other timer is running.");
                return;
            }
            Interlocked.Exchange(ref _isRunning, 1);
            var tempList = new PlanConfig[0];

            _lockStrategy.TryEnterLock(() =>
            {
                tempList = new PlanConfig[_listenerQueue.Count];
                _listenerQueue.CopyTo(tempList, 0);
            });
            var expiredList = new Queue <PlanConfig>();

            foreach (var planConfig in tempList)
            {
                if (planConfig == null || planConfig.IsExpired)
                {
                    if (planConfig != null)
                    {
                        expiredList.Enqueue(planConfig);
                    }
                    continue;
                }
                if (planConfig.AutoStart())
                {
                    DoNotify(planConfig);
                }
            }
            _lockStrategy.TryEnterLock(() =>
            {
                while (expiredList.Count > 0)
                {
                    var p = expiredList.Dequeue();
                    _listenerQueue.Remove(p);

                    TraceLog.ReleaseWrite("{0}-{1}>>listener is remove ({2}).", DateTime.Now.ToLongTimeString(), p.Name, _listenerQueue.Count);
                }
            });
            Interlocked.Exchange(ref _isRunning, 0);
        }
Exemplo n.º 6
0
 private static void DoNotify(PlanConfig planConfig)
 {
     if (planConfig != null && planConfig.Callback != null)
     {
         ThreadPool.QueueUserWorkItem(obj =>
         {
             Interlocked.Increment(ref planConfig._isExcuting);
             try
             {
                 planConfig.Callback((PlanConfig)obj);
             }
             catch (Exception ex)
             {
                 TraceLog.WriteError("TimeListener notify error:{0}", ex);
             }
             finally
             {
                 Interlocked.Decrement(ref planConfig._isExcuting);
             }
         }, planConfig);
     }
 }
Exemplo n.º 7
0
 public void Reset(PlanConfig config)
 {
     StartDate = config.BeginTime.ToDateTime();
     StopDate  = config.EndTime.ToDateTime(DateTime.MinValue);
     IsEnd     = false;
 }
Exemplo n.º 8
0
 public static void Init()
 {
     PlanConfig planConfig = new PlanConfig(Rank, true, ConfigEnvSet.GetInt("Rank.SJT"), "");
     TimeListener.Append(planConfig);
 }
Exemplo n.º 9
0
 public PlanState(PlanConfig config)
 {
     _config = config;
 }
Exemplo n.º 10
0
 public void Reset(PlanConfig config)
 {
     StartDate = (string.IsNullOrEmpty(config.BeginTime) ? "00:00:00" : config.BeginTime).ToDateTime();
     StopDate  = config.EndTime.ToDateTime(DateTime.MinValue);
     IsEnd     = false;
 }
Exemplo n.º 11
0
 public void Reset(PlanConfig config)
 {
     PreExcuteDate = DateTime.MinValue;
     StartDate = (string.IsNullOrEmpty(config.BeginTime) ? "00:00:00" : config.BeginTime).ToDateTime();
     StopDate = string.IsNullOrEmpty(config.EndTime) || "00:00:00".Equals(config.EndTime) ? DateTime.Now.Date.AddDays(1) : config.EndTime.ToDateTime(DateTime.MinValue);
     IsEnd = false;
 }
Exemplo n.º 12
0
        private static void TimerCallback(object state)
        {
            if (_isRunning == 1)
            {
                TraceLog.ReleaseWrite("TimerCallback is busy, The other timer is running.");
                return;
            }
            Interlocked.Exchange(ref _isRunning, 1);
            var tempList = new PlanConfig[0];
            _lockStrategy.TryEnterLock(() =>
            {
                tempList = new PlanConfig[_listenerQueue.Count];
                _listenerQueue.CopyTo(tempList, 0);
            });
            var expiredList = new Queue<PlanConfig>();
            foreach (var planConfig in tempList)
            {
                if (planConfig == null || planConfig.IsExpired)
                {
                    if (planConfig != null)
                    {
                        expiredList.Enqueue(planConfig);
                    }
                    continue;
                }
                if (planConfig.AutoStart())
                {
                    DoNotify(planConfig);
                }
            }
            _lockStrategy.TryEnterLock(() =>
            {
                while (expiredList.Count > 0)
                {
                    var p = expiredList.Dequeue();
                    _listenerQueue.Remove(p);

                    TraceLog.ReleaseWrite("{0}-{1}>>listener is remove ({2}).", DateTime.Now.ToLongTimeString(), p.Name, _listenerQueue.Count);
                }
            });
            Interlocked.Exchange(ref _isRunning, 0);
        }
Exemplo n.º 13
0
 private static void DoNotify(PlanConfig planConfig)
 {
     try
     {
         if (planConfig != null && planConfig.Callback != null)
         {
             //Console.WriteLine("{0}-{1}>>listener begin callback", DateTime.Now.ToLongTimeString(), planConfig.Name);
             planConfig.Callback.BeginInvoke(planConfig, EndPlanAsync, planConfig);
         }
     }
     catch (Exception ex)
     {
         TraceLog.WriteError("TimeListener notify error:{0}", ex);
     }
 }
Exemplo n.º 14
0
 private static void DoNotify(PlanConfig planConfig)
 {
     if (planConfig != null && planConfig.Callback != null)
     {
         ThreadPool.QueueUserWorkItem(obj =>
         {
             Interlocked.Increment(ref planConfig._isExcuting);
             try
             {
                 planConfig.Callback((PlanConfig)obj);
             }
             catch (Exception ex)
             {
                 TraceLog.WriteError("TimeListener notify error:{0}", ex);
             }
             finally
             {
                 Interlocked.Decrement(ref planConfig._isExcuting);
             }
         }, planConfig);
     }
 }
Exemplo n.º 15
0
        /// <summary>
        /// 增加定时任务计划
        /// </summary>
        /// <param name="planConfig"></param>
        public static void Append(PlanConfig planConfig)
        {
            lock (asyncRoot)
            {
                _listenerQueue.Add(planConfig);
            }

        }
Exemplo n.º 16
0
 private static void DoEveryWeekExecute(PlanConfig planconfig)
 {
     RankingClear.Instance().doIt();
 }
Exemplo n.º 17
0
 public void Reset(PlanConfig config)
 {
     StartDate = (string.IsNullOrEmpty(config.BeginTime) ? "00:00:00" : config.BeginTime).ToDateTime();
     StopDate = config.EndTime.ToDateTime(DateTime.MinValue);
     IsEnd = false;
 }
Exemplo n.º 18
0
        private void DoPushRanking(PlanConfig planconfig)
        {
            try
            {

                Console.WriteLine("{0}>>The server push ranking", DateTime.Now.ToString("HH:mm:ss"));
                var sessionList = _sessions.Values.ToList();
                int actionId = 1001;
                StringBuilder shareParam = new StringBuilder();
                shareParam.AppendFormat("&{0}={1}", "PageIndex", "1");
                shareParam.AppendFormat("&{0}={1}", "PageSize", "50");
                HttpGet httpGet;
                byte[] sendData = ActionFactory.GetActionResponse(actionId, new GuestUser(), shareParam.ToString(), out httpGet);
                foreach (var user in sessionList)
                {
                    if (!SendAsync(user.UserId, sendData))
                    {
                        UnLine(user.UserId);
                    }
                }
            }
            catch (Exception ex)
            {
                TraceLog.WriteError("PushRanking error:{0}", ex);
            }
        }
Exemplo n.º 19
0
 public static void DoEveryDayExecute(PlanConfig planconfig)
 {
     RealItemCntUpdate.Instance().action_HappyModeData_enterNum(null);
 }
Exemplo n.º 20
0
        /// <summary>
        /// 增加定时任务计划
        /// </summary>
        /// <param name="planConfig"></param>
        public static void Append(PlanConfig planConfig)
        {
            CheckDisposed();
            if (planConfig == null)
            {
                throw new ArgumentNullException("planConfig");
            }
            Initialize();
            lock (asyncRoot)
            {
                planConfig.SetDiffInterval((double)_msInterval / 1000);
                _listenerQueue.Add(planConfig);
            }

        }
Exemplo n.º 21
0
 private static void DoNotify(PlanConfig planConfig)
 {
     if (planConfig != null && planConfig.Callback != null)
     {
         ThreadPool.QueueUserWorkItem(obj =>
         {
             try
             {
                 planConfig.Callback((PlanConfig)obj);
             }
             catch (Exception ex)
             {
                 TraceLog.WriteError("TimeListener notify error:{0}", ex);
             }
         }, planConfig);
     }
 }
Exemplo n.º 22
0
 private void DoBroadcast(PlanConfig planConfig)
 {
     if (_isRunning == 1) return;
     Interlocked.Exchange(ref _isRunning, 1);
     //TraceLog.ReleaseWrite("{0}>>Broadcast listener start...", DateTime.Now.ToLongTimeString());
     if (planConfig.Target is NoticeMessage)
     {
         NoticeMessage message = planConfig.Target as NoticeMessage;
         if (_callback != null)
         {
             _callback(message);
         }
     }
     Interlocked.Exchange(ref _isRunning, 0);
 }
Exemplo n.º 23
0
 public PlanState(PlanConfig config)
 {
     _config = config;
 }