/// <summary>
        /// 指令清理缓存
        /// </summary>
        /// <param name="task"></param>
        private static void ClearCache(TaskMessage task)
        {
            if (task == null)
            {
                return;
            }
            string key = task.TaskParam;

            if (!string.IsNullOrEmpty(key))
            {
                if (DataCache.KeyExists(key) != null)     //HttpRuntime缓存
                {
                    DataCache.Delete(key);
                }
                if (DistributedCache.KeyExists(key) != null)    //分布式缓存
                {
                    DistributedCache.Delete(key);
                }
            }
        }
Esempio n. 2
0
        private void CallbackInternal(PushMessageResult result)
        {
            Check.IsNull(result, "CallbackInternal的参数Obj");
            PushMessageModel model = new PushMessageModel();

            Check.IsNull(result.PushId, "PushMessageResult.PushId");
            PushMessage pushMsg = result.ReferObject as PushMessage;

            Check.IsNull(pushMsg, "PushId查找到的PushMessageModel对象");
            model.PushCount           = pushMsg.PushCount;
            model.SettingId           = pushMsg.SettingId;
            RequestProfile.RequestKey = result.PushId + "_" + pushMsg.PushCount.ToString();
            RequestProfile.MessageKey = result.PushId;

            switch (result.PushStatus)
            {
            case PushResultEnum.Abort:
                model.PushId     = result.PushId;
                model.PushStatus = PushStatusEnum.Abort;
                model.PushCount++;
                model.Memo = string.Format("Abort:{0},{1:yyyy-MM-dd HH:mm:ss};{2}", result.ErrMsg, DateTime.Now, Environment.NewLine);
                break;

            case PushResultEnum.Success:
                model.PushId     = result.PushId;
                model.PushStatus = PushStatusEnum.Pushed;
                model.PushCount++;
                model.Memo = string.Format("Success:{0},{1:yyyy-MM-dd HH:mm:ss};{2}", result.ErrMsg, DateTime.Now, Environment.NewLine);
                break;

            case PushResultEnum.Failed:
                model.PushId     = result.PushId;
                model.PushStatus = PushStatusEnum.Failed;
                bool isPushNext = false;
                //model.PushCount == 3
                //第四次推送的返回
                model.PushCount++;
                model.NextPushTime = ComputePushTimeBusiness.ComputeNextPushTime(model, out isPushNext);
                if (isPushNext)
                {
                    model.PushStatus = PushStatusEnum.UnPush;
                }
                model.Memo = string.Format("Failed:{0},B-{1:yyyy-MM-dd HH:mm:ss},N-{2:yyyy-MM-dd HH:mm:ss};{3}", result.ErrMsg, DateTime.Now, model.NextPushTime, Environment.NewLine);
                break;

            case PushResultEnum.Pushing:
                model.PushId     = result.PushId;
                model.PushStatus = PushStatusEnum.Pushing;
                model.Memo       = string.Format("Pushing:{0},{1:yyyy-MM-dd HH:mm:ss};{2}", result.ErrMsg, DateTime.Now, Environment.NewLine);
                break;

            default:
                break;
            }
            if (!string.IsNullOrWhiteSpace(model.PushId) &&
                (model.PushStatus &
                 (PushStatusEnum.Abort |
                  PushStatusEnum.Pushed |
                  PushStatusEnum.Failed |
                  PushStatusEnum.UnPush |
                  PushStatusEnum.Pushing)) == model.PushStatus)
            {
                model.LastModifyTime = DateTime.Now;
                bool ret = _pushMessageBus.Edit(model);
                if (!ret)
                {
                    lock (m_repeatUpdateTimesLockObj)
                    {
                        //进入补偿更新队列
                        m_repeatUpdateTimes[model.PushId] = 1;
                    }
                    _repeatUpdatePool.Write(model);
                }
                else
                {
                    if (model.PushStatus == PushStatusEnum.UnPush)
                    {
                        string cacheKey = string.Format(CacheKeys.SendToMessageHandler_Arg2, model.PushId, model.PushCount - 1);
                        DistributedCache.Delete(cacheKey);
                    }
                }
                Process.Debug(result.PushId, "消息推送记录", "Callback", result.PushId, string.Format("推送状态:【{0}】,推送结果:【{1}】,更新结果:【{2}】", result.PushStatus.ToString(), result.ErrMsg, ret), "");
            }
        }