Пример #1
0
        /// <summary>
        /// 保存异步消息,并设置初始处理状态
        /// </summary>
        /// <param name="valueArgs">参数</param>
        /// <returns>是否成功</returns>
        public static bool SetMessage(SetBackGroudMessageArgs valueArgs)
        {
            var msg      = new MQProtocol <SetBackGroudMessageArgs>("SetBackGroudMessage", valueArgs, valueArgs.Args.rid);
            var routeKey = GetRouter(valueArgs.BussinessType);
            var mq       = MQManager <SetBackGroudMessageArgs> .Publish(msg, routeKey);

            if (!mq)
            {
                logger.LogError($"BackGroundMessageMgr.SetMessage.MQ.Error.rid = {valueArgs.Args.rid}");
                return(false);
            }

            logger.LogInformation($"BackGroundMessageMgr.SetMessage.MQ.Success.rid = {valueArgs.Args.rid}");

            var processMsg = new BackGroundMessageProcessResult() // 初始化一个未开始状态,所有值都为-1,表示还在队列中,未开始
            {
                ProcessNum = -1,
                SuccessNum = -1,
                TotalNum   = -1,
                Data       = string.Empty,
                Rid        = valueArgs.Args.rid,
            };

            return(SetProcessStatus(processMsg));
        }
Пример #2
0
 /// <summary>
 /// 设置进度
 /// </summary>
 /// <param name="processMsg">信息</param>
 /// <returns>是否成功</returns>
 public static bool SetProcessStatus(BackGroundMessageProcessResult processMsg)
 {
     return(ResourceCache.Instance.Set(processMsg.Rid, processMsg));
 }