public async Task Handle(string projectId, string pageId, CancellationToken cancellationToken = default(CancellationToken))
        {
            var page = await _pageQueries.GetPage(projectId, pageId, cancellationToken);

            var url = await _pageUrlResolver.ResolvePageUrl(page);

            var message = new PushMessageModel()
            {
                MessageType = "contentdelete",
                Body        = "Content deleted",
                Data        = url
            };

            if (page.Slug == "home")
            {
                message.Data = "/";
            }

            var queueItem = new PushQueueItem(
                message,
                BuiltInRecipientProviderNames.AllButCurrentUserPushNotificationRecipientProvider);

            queueItem.TenantId = page.ProjectId;
            queueItem.RecipientProviderCustom1 = _userIdResolver.GetCurrentUserId();

            _pushNotificationsQueue.Enqueue(queueItem);
        }
예제 #2
0
        public async Task Handle(
            string projectId,
            IPage page,
            CancellationToken cancellationToken = default(CancellationToken)
            )
        {
            var url = await _pageUrlResolver.ResolvePageUrl(page);

            var message = new PushMessageModel()
            {
                MessageType = "contentupdate",
                Body        = "Content updated",
                Data        = url
            };

            if (page.Slug == "home")
            {
                message.Data = "/";
            }

            var queueItem = new PushQueueItem(
                message,
                BuiltInRecipientProviderNames.AllButCurrentUserPushNotificationRecipientProvider);

            queueItem.TenantId = page.ProjectId;
            queueItem.RecipientProviderCustom1 = _userIdResolver.GetCurrentUserId();

            _pushNotificationsQueue.Enqueue(queueItem);

            //TODO: need to extract all image urls and sned message to sw to add to cache if not in there already
            // or maybe need an event for file system when files added or deleted
        }
예제 #3
0
        public static DateTime ComputeNextPushTime(PushMessageModel message, NotifyInterfaceSettingModel setting, out bool isPushNext)
        {
            DateTime pushNextTime = Null.NullDate;

            isPushNext = false;
            int    pushCount  = message.PushCount;
            int    limitCount = setting.PushLimitCount;
            string rule       = setting.PushInternalRule;

            if (pushCount < limitCount)
            {
                if (string.IsNullOrWhiteSpace(rule))
                {
                    Process.Info("推送配置", "", string.Format("{0}的推送规则为空", setting.SettingId), "");
                }
                int second = 0;
                isPushNext = true;
                if (pushCount < setting.PushInternalRuleList.Count)
                {
                    second = setting.PushInternalRuleList[pushCount];
                }
                else
                {
                    second = setting.PushInternalRuleList[setting.PushInternalRuleList.Count - 1];
                }
                pushNextTime = DateTime.Now.AddSeconds(second);
            }
            return(pushNextTime);
        }
예제 #4
0
        public void Process(PushModel model)
        {
            if (model == null)
            {
                throw new ArgumentNullException("PushModel");
            }

            this.sourceType    = model.SourceType;
            this.userId        = model.PositionModel?.UserId ?? 0;
            this.messageType   = model.PushMessageType;
            this.messageModel  = model.MessageModel;
            this.positionModel = model.PositionModel;

            if (this.userId <= 0)
            {
                throw new ArgumentNullException("UserId");
            }

            if (this.positionModel == null)
            {
                throw new ArgumentNullException("PushPositionModel");
            }

            this.CheckMessageModel();

            this.AddNearCircle();
        }
예제 #5
0
        public PushMessageModel Get(string pushId)
        {
            PushMessageEntity entity = JinRiNotifyFacade.Instance.GetPushMessageByID(pushId);
            PushMessageModel  model  = MappingHelper.From <PushMessageModel, PushMessageEntity>(entity);

            return(model);
        }
        public async Task Handle(string projectId, IPost post, CancellationToken cancellationToken = default(CancellationToken))
        {
            var project = await _projectSettingsResolver.GetCurrentProjectSettings(cancellationToken);

            var url = await _blogUrlResolver.ResolvePostUrl(post, project);

            var message = new PushMessageModel()
            {
                MessageType = "newcontent",
                Body        = "New content",
                Data        = url
            };

            var queueItem = new PushQueueItem(
                message,
                BuiltInRecipientProviderNames.AllButCurrentUserPushNotificationRecipientProvider);

            queueItem.TenantId = post.BlogId;
            queueItem.RecipientProviderCustom1 = _userIdResolver.GetCurrentUserId();

            _pushNotificationsQueue.Enqueue(queueItem);



            //TODO: need to extract all image urls and sned message to sw to add to cache if not in there already
            // or maybe need an event for file system when files added or deleted
        }
예제 #7
0
        /// <summary>
        /// 保存请求信息
        /// </summary>
        /// <returns></returns>
        public Result <bool> SavePushMessage(PushMessageModel model)
        {
            var result = new Result <bool>()
            {
                HasError = false
            };

            try
            {
                string sql = @"delete [EPC_PushMessage] where Number= @number and taskId=@taskId and PushTable=@table;
                              insert into [EPC_PushMessage] ([Number],[TaskId],[Message],[PushTable],[RequestJson],[ResponseJson],[Node])
                              values(@number,@TaskId,@msg,@table,@rjson,@ResponseJson,@Node)";
                //if (type == 1)
                //{
                //    sql = " delete [EPC_PushMessage] where Number= @number and PushTable=@table;";
                //}

                using (var conn = OpenConnection("Yanwen_EPC"))
                {
                    result.Data = conn.Execute(sql, new { model.Number, TaskId = model.TaskId, model.Msg, model.Table, model.Rjson, ResponseJson = model.Fjson, Node = model.Node }) > 0;
                }
            }
            catch (Exception r)
            {
                return(result);
            }
            return(result);
        }
        /// <summary>
        /// 推送訊息
        /// </summary>
        /// <param name="pushMessageBody">推送訊息body資料</param>
        public async Task PushMessageAsync(PushMessageModel pushMessageBody)
        {
            string jsonString = JsonConvert.SerializeObject(pushMessageBody, new JsonSerializerSettings {
                NullValueHandling = NullValueHandling.Ignore, Formatting = Formatting.None
            });

            await Utility.DoLineHttpPostAsync(MessagingApiUrl.PushUrl, jsonString, accessToken);
        }
예제 #9
0
        //[Fact]
        public void ShouldSendMessagesToMQ()
        {
            //assume
            var activemq  = new ActiveMQAdapter <PushMessageModel>(mq_Ip_address, QUEUE_DESTINATION);
            var msg       = CreateNewTestMessage();
            var modellist = new PushMessageModel[] { msg, msg };
            int flag      = activemq.SendMessages <PushMessageModel>(modellist);

            //assert
            Assert.Equal(1, flag);
        }
예제 #10
0
        public IActionResult BroadcastNotification([FromBody] PushMessageModel message)
        {
            var queueItem = new PushQueueItem(
                message,
                BuiltInRecipientProviderNames.AllSubscribersPushNotificationRecipientProvider);

            queueItem.TenantId = _tenantIdResolver.GetTenantId();

            _pushNotificationsQueue.Enqueue(queueItem);

            return(NoContent());
        }
예제 #11
0
        public IActionResult SendNotificationToSelf([FromBody] PushMessageModel message)
        {
            var queueItem = new PushQueueItem(
                message,
                BuiltInRecipientProviderNames.SingleUserPushNotificationRecipientProvider);

            queueItem.TenantId = _tenantIdResolver.GetTenantId();
            queueItem.RecipientProviderCustom1 = _userIdResolver.GetCurrentUserId();

            _pushNotificationsQueue.Enqueue(queueItem);

            return(NoContent());
        }
예제 #12
0
        public ActionResult Save(PushMessageModel model, string pushIds)
        {
            var message = new ReturnMessage {
                Success = false, Msg = "操作失败!"
            };

            try
            {
                PushMessageBusiness business = new PushMessageBusiness();
                if (string.IsNullOrEmpty(pushIds))       //单条编辑
                {
                    var pushMessage = business.GetFromCache(model.PushId);
                    if (pushMessage == null)
                    {
                        message.Msg = "推送消息不存在!";
                        return(Content(JsonConvert.SerializeObject(message)));
                    }
                    pushMessage.MessagePriority = model.MessagePriority;
                    pushMessage.MessageType     = model.MessageType;
                    pushMessage.PushData        = model.PushData;
                    pushMessage.PushStatus      = model.PushStatus;
                    pushMessage.NextPushTime    = model.NextPushTime;
                    pushMessage.PushCount       = model.PushCount;
                    pushMessage.Memo            = string.Empty;
                    message.Success             = business.Edit(pushMessage);
                }
                else
                {
                    //批量编辑
                    PushMessageCondition condition = new PushMessageCondition();
                    condition.PushIds = new List <string>(pushIds.Split(','));
                    var data = business.GetPushMessageList(condition);
                    data.ForEach(t =>
                    {
                        t.NextPushTime   = model.NextPushTime;
                        t.PushCount      = model.PushCount;
                        t.LastModifyTime = DateTime.Now;
                        t.PushStatus     = PushStatusEnum.UnPush;
                    });
                    if (data.Count > 0)
                    {
                        message.Success = business.EditPushMessage(data);
                    }
                }
            }
            catch (Exception)
            {
            }
            return(Content(JsonConvert.SerializeObject(message)));
        }
예제 #13
0
        public bool Edit(PushMessageModel message)
        {
            PushMessageEntity entity = MappingHelper.From <PushMessageEntity, PushMessageModel>(message);

            if (message.MessagePriority == MessagePriorityEnum.None)
            {
                entity.MessagePriority = Null.NullString;
            }
            if (Null.IsNull(message.MessageType))
            {
                entity.MessageType = Null.NullString;
            }
            return(JinRiNotifyFacade.Instance.EditPushMessage(entity) > 0);
        }
예제 #14
0
        public PushMessageModel GetFromCache(string pushId)
        {
            string           cacheKey = string.Format(CacheKeys.GetPushMessage_Arg1, pushId);
            PushMessageModel model    = DataCache.Get(cacheKey) as PushMessageModel;

            if (model == null)
            {
                model = Get(pushId);
                if (model != null)
                {
                    DataCache.Set(cacheKey, model, DateTime.Now.AddSeconds(CacheKeys.GetPushMessage_TimeOut));
                }
            }
            return(model);
        }
예제 #15
0
        public void InsertMessageToDatabase(ADPPushSDK.BaseModel.PushMessageBaseModel pushMessageReceive)
        {
            try
            {
                var json = JsonConvert.SerializeObject(pushMessageReceive);

                var message = new PushMessageModel(json);

                InsertIntoTable(message, false);
            }
            catch (Exception exception)
            {
                Debug.WriteLine(exception);
            }
        }
예제 #16
0
        /// <summary>
        /// 给不同的用户推送同一条消息
        /// </summary>
        /// <param name="message"></param>
        /// <param name="tokens"></param>
        private void SendUniformMessage(PushPluginMessage message, IEnumerable <TokenModel> tokens)
        {
            try
            {
                _log.Info($"MiPush插件开始执行一对多推送,数量: {tokens.Count()}");

                var pushMessage = new PushMessageModel()
                {
                    title   = message.Title,
                    content = message.Message,
                    url     = message.ClientActionUrl,
                    action  = message.ClientAction
                };
                var sendData = new PushSendRegidModel()
                {
                    registration_id         = string.Join(",", tokens.Select(p => p.Token)),
                    payload                 = JsonConvert.SerializeObject(pushMessage),
                    restricted_package_name = RestrictedPackageName,
                    pass_through            = message.PassThrough,
                    title       = message.Title,
                    description = message.Message,
                    notify_type = -1
                };
                var sentResult = Send(sendData);

                if (sentResult.result.Equals("ok"))
                {
                    foreach (var tokenModel in tokens)
                    {
                        PushSucess(tokenModel.BatchNo);
                    }
                }
                else
                {
                    foreach (var tokenModel in tokens)
                    {
                        PushFail(tokenModel.BatchNo);
                    }
                }

                _log.Info($"MiPush插件一对多推送发送完毕,数量: {tokens.Count()}");
            }
            catch (Exception ex)
            {
                _log.Error($"Android插件消息推送异常{ex},数量:{tokens.Count()}");
            }
        }
        private void SendNewContentNotification(string url)
        {
            var message = new PushMessageModel()
            {
                MessageType = "newcontent",
                Body        = "New content",
                Data        = url
            };

            var queueItem = new PushQueueItem(
                message,
                BuiltInRecipientProviderNames.AllButCurrentUserPushNotificationRecipientProvider);

            queueItem.TenantId = _tenantIdResolver.GetTenantId();
            queueItem.RecipientProviderCustom1 = _userIdResolver.GetCurrentUserId();

            _pushNotificationsQueue.Enqueue(queueItem);
        }
예제 #18
0
        private List <PushMessageModel> BuildMessage(NotifyMessage message)
        {
            List <PushMessageModel> pmlist = new List <PushMessageModel>();

            try
            {
                List <NotifyInterfaceSettingModel> nslist = _notifySettingBus.GetListFromCache();
                if (nslist == null || nslist.Count == 0 || message == null)
                {
                    return(null);
                }
                bool isPushNext = false;
                foreach (NotifyInterfaceSettingModel setting in nslist.FindAll(x => x.Status == 2 && x.MessageType.ToString().Equals(message.MessageType, StringComparison.OrdinalIgnoreCase)))
                {
                    PushMessageModel pushMod = new PushMessageModel();
                    pushMod.PushId            = IdentityGenerator.New();
                    pushMod.MessageId         = message.MessageId;
                    pushMod.SettingId         = setting.SettingId;
                    pushMod.MessageKey        = message.MessageKey;
                    pushMod.MessagePriority   = message.MessagePriority;
                    pushMod.MessageType       = message.MessageType;
                    pushMod.PushData          = string.Format("msgid={0}&msgkey={1}&msgtype={2}&data={3}", pushMod.PushId, message.MessageKey, message.MessageType, HttpUtility.UrlEncode(message.NotifyData));
                    pushMod.PushStatus        = PushStatusEnum.UnPush;
                    pushMod.MessageCreateTime = message.CreateTime;
                    pushMod.CreateTime        = DateTime.Now;
                    pushMod.LastModifyTime    = pushMod.CreateTime;
                    pushMod.PushCount         = 0;
                    pushMod.Memo         = string.Format("Add:{0:yyyy-MM-dd HH:mm:ss};{1}", message.CreateTime, Environment.NewLine);
                    pushMod.NextPushTime = ComputePushTimeBusiness.ComputeNextPushTime(pushMod, out isPushNext);

                    pmlist.Add(pushMod);
                }
            }
            catch (Exception ex)
            {
                MetricsKeys.BuilderService_Build.MeterMark("Error");
                Process.Error(message.MessageId, "消息生成中心", "Exception", message.MessageId, "生成推送消息,发生异常:" + ex.GetString(), "");
            }
            finally
            {
                Process.Debug(message.MessageId, "消息生成中心", "finally", message.MessageId, "生成推送消息,条数:" + pmlist.Count, "");
            }
            return(pmlist);
        }
예제 #19
0
        /// <summary>
        /// 给不同的用户推送不同的消息
        /// </summary>
        /// <param name="messages"></param>
        /// <returns></returns>
        private void SendDiffMessage(IEnumerable <PushPluginMessage> messages)
        {
            try
            {
                _log.Info($"MiPush插件开始执行多对多推送,数量: {messages.Count()}");

                foreach (var pushPluginMessage in messages)
                {
                    var pushMessage = new PushMessageModel()
                    {
                        title   = pushPluginMessage.Title,
                        content = pushPluginMessage.Message,
                        url     = pushPluginMessage.ClientActionUrl,
                        action  = pushPluginMessage.ClientAction
                    };
                    var sendData = new PushSendRegidModel()
                    {
                        registration_id         = string.Join(",", pushPluginMessage.Token),
                        payload                 = JsonConvert.SerializeObject(pushMessage),
                        restricted_package_name = RestrictedPackageName,
                        pass_through            = pushPluginMessage.PassThrough,
                        title       = pushPluginMessage.Title,
                        description = pushPluginMessage.Message,
                        notify_type = -1
                    };
                    var sentResult = Send(sendData);

                    if (sentResult.result.Equals("ok"))
                    {
                        PushSucess(pushPluginMessage.BatchNo);
                    }
                    else
                    {
                        PushFail(pushPluginMessage.BatchNo);
                    }
                }

                _log.Info($"MiPush插件多对多推送发送完毕,数量: {messages.Count()}");
            }
            catch (Exception ex)
            {
                _log.Error($"Android插件消息推送异常{ex},数量:{messages.Count()}");
            }
        }
        private static void SendPushNotification(string subscriptionEndpoint, string p256dh, string auth,
                                                 string title, string body,
                                                 bool result)
        {
            var webPushClient = new WebPushClient();
            var vapidDetails  = new VapidDetails("mailto:[email protected]", PushPublicKey, PushPrivateKey);

            var message = new PushMessageModel()
            {
                notification = new NotificationModel()
                {
                    title  = title,
                    body   = body,
                    Result = result
                }
            };

            webPushClient.SendNotification(new PushSubscription(subscriptionEndpoint, p256dh, auth), JsonConvert.SerializeObject(message), vapidDetails);
        }
예제 #21
0
        public void Process(PushModel model)
        {
            if (model == null)
            {
                throw new ArgumentNullException("PushModel");
            }

            this.sourceType   = model.SourceType;
            this.userId       = model.PositionModel?.UserId ?? 0;
            this.messageType  = model.PushMessageType;
            this.messageModel = model.MessageModel;

            if (this.userId <= 0)
            {
                throw new ArgumentNullException("UserId");
            }

            this.CheckMessageModel();

            //save to db for current user id
        }
        private PushMessage FromModel(PushMessageModel model)
        {
            var contractResolver = new DefaultContractResolver
            {
                NamingStrategy = new CamelCaseNamingStrategy()
            };
            var serializationSettings = new JsonSerializerSettings()
            {
                ContractResolver  = contractResolver,
                NullValueHandling = NullValueHandling.Ignore
            };

            var serialized = JsonConvert.SerializeObject(model, serializationSettings);
            var content    = new StringContent(serialized, Encoding.UTF8, "application/json");

            var pushMessage = new PushMessage(content)
            {
                //Topic = message.Topic,
                //Urgency = message.Urgency
            };

            return(pushMessage);
        }
        public async Task Handle(string projectId, string postId, CancellationToken cancellationToken = default(CancellationToken))
        {
            var post = await _postQueries.GetPost(projectId, postId, cancellationToken);

            var project = await _projectSettingsResolver.GetCurrentProjectSettings(cancellationToken);

            var url = await _blogUrlResolver.ResolvePostUrl(post, project);

            var message = new PushMessageModel()
            {
                MessageType = "contentdelete",
                Body        = "Content deleted",
                Data        = url
            };

            var queueItem = new PushQueueItem(
                message,
                BuiltInRecipientProviderNames.AllButCurrentUserPushNotificationRecipientProvider);

            queueItem.TenantId = post.BlogId;
            queueItem.RecipientProviderCustom1 = _userIdResolver.GetCurrentUserId();

            _pushNotificationsQueue.Enqueue(queueItem);
        }
예제 #24
0
        private static PushMessageModel ConverToMessageModel(PushMessageViewModel message)
        {
            PushMessageModel pushMessage = new PushMessageModel();

            if (message != null)
            {
                pushMessage.Description   = message.Description;
                pushMessage.Title         = message.Title;
                pushMessage.Content       = message.Content;
                pushMessage.BeginSendTime = message.SendTime.HasValue ? message.SendTime : DateTime.Now;
                pushMessage.ExpireTime    = message.ExpireTime.HasValue
                    ? message.ExpireTime
                    : pushMessage.BeginSendTime.Value.AddDays(2);
                pushMessage.AppExpireTime = message.APPExpireTime.HasValue
                    ? message.APPExpireTime
                    : pushMessage.BeginSendTime.Value.AddDays(7);
                pushMessage.RichTextImage = message.RichTextImage?.Replace("http://image.tuhu.cn", "https://img1.tuhu.org");
                pushMessage.AndriodModel  = new AndriodModel
                {
                    AfterOpen = message.AfterOpen == "0"
                        ? AfterOpenEnum.GoApp
                        : AfterOpenEnum.GoActivity,
                    AppActivity = message.AppActivity,
                    ExKey1      = message.AndriodKey1,
                    ExValue1    = message.AndriodValue1,
                    ExKey2      = message.AndriodKey2,
                    ExValue2    = message.AndriodValue2
                };
                switch (message.AppMsgType)
                {
                case "activity":
                    pushMessage.CenterMsgType = Constants.MessageType_Broadcast;
                    pushMessage.HeadImageUrl  = "http://image.tuhu.cn/news/activity.png";
                    break;

                case "discovery":
                    pushMessage.CenterMsgType = Constants.MessageType_Message;
                    pushMessage.HeadImageUrl  = "http://image.tuhu.cn/news/faxian.png";
                    break;

                case "system":
                    pushMessage.CenterMsgType = Constants.MessageType_Common;
                    pushMessage.HeadImageUrl  = "http://image.tuhu.cn/news/wuliu.png";
                    break;

                case "logistics":
                    pushMessage.CenterMsgType = Constants.MessageType_Logistics;
                    pushMessage.HeadImageUrl  = "http://image.tuhu.cn/news/logistics.png";
                    break;

                default:
                    pushMessage.CenterMsgType = Constants.MessageType_Broadcast;
                    pushMessage.HeadImageUrl  = "http://image.tuhu.cn/news/activity.png";
                    break;
                }

                pushMessage.BigImagePath = message.BigImagePath;
                pushMessage.IOSModel     = new IOSModel()
                {
                    ExKey1       = message.IOSKey1,
                    ExValue1     = message.IOSValue1,
                    ExKey2       = message.IOSKey2,
                    ExValue2     = message.IOSValue2,
                    ExKey3       = message.IOSKey3,
                    ExValue3     = message.IOSValue3,
                    ShowBadge    = message.IOSShowBadge,
                    IOSMainTitle = message.IOSMainTitle,
                    IOSTitle     = message.IOSTitle
                };

                pushMessage.SourceName = PushSourceName;
                pushMessage.OperUser   = message.OperUser;
            }

            return(pushMessage);
        }
예제 #25
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), "");
            }
        }
예제 #26
0
 public bool Save(PushMessageModel message)
 {
     return(Save(new List <PushMessageModel>(new PushMessageModel[] { message })));
 }
예제 #27
0
 public static DateTime ComputeNextPushTime(PushMessageModel message, out bool isPushNext)
 {
     return(ComputeNextPushTime(message, _settingBus.Get(message.SettingId), out isPushNext));
 }
예제 #28
0
        public void Execute(IJobExecutionContext context)
        {
            Logger.Info("启动任务");
            List <InsureCarModel> Cars = null;

            using (var cmd = new SqlCommand(@"DECLARE @Date DATE= GETDATE();
                                                SELECT  DATEDIFF(DAY , GETDATE() , C_u_InsureExpireDate) AS ExpireDay ,
                                                        CO.UserID ,
                                                        CO.C_u_InsureExpireDate ,
                                                        CO.u_carno ,
                                                        UO.u_mobile_number
                                                FROM    Tuhu_profiles..CarObject AS CO ( NOLOCK )
                                                JOIN    Tuhu_profiles..UserObject AS UO ( NOLOCK )
                                                        ON CO.UserID = UO.UserID
                                                WHERE   C_u_InsureExpireDate IS NOT NULL
                                                        AND CO.C_u_InsureExpireDate >= DATEADD(MONTH , 2 , @Date)
                                                        AND CO.C_u_InsureExpireDate < DATEADD(DAY , 1 ,
                                                                                                DATEADD(MONTH , 2 , @Date)) "))
            {
                Cars = DbHelper.ExecuteSelect <InsureCarModel>(true, cmd).ToList();
                foreach (var i in Cars)
                {
                    //插入通知消息
                    using (var pushClient = new PushClient())
                    {
                        var pushMessage = new PushMessageModel()
                        {
                            Type          = MessageType.AppNotification,
                            CenterMsgType = "1普通",
                            PhoneNumbers  = new List <string> {
                                i.u_mobile_number
                            },
                            Content            = "您的爱车" + i.u_carno + "保险还有" + i.ExpireDay + "天就要到期了哦,请及时购买新的保险;不然爱车就要开启裸奔模式了哦",
                            HeadImageUrl       = "http://image.tuhu.cn/news/wuliu.png",
                            InsertAppCenterMsg = true,
                            Title      = "爱车保险快到期啦",
                            SourceName = "Job.tuhu.cn"
                        };

                        pushMessage.AndriodModel = new AndriodModel
                        {
                            AfterOpen   = AfterOpenEnum.GoActivity,
                            AppActivity = "cn.TuHu.Activity.LoveCar.MyLoveCarActivity",
                        };

                        pushMessage.IOSModel = new IOSModel
                        {
                            ExKey1   = "appoperateval",
                            ExValue1 = "Tuhu.THCarDetailsVC",
                            ExKey2   = "keyvaluelenth",
                            ExValue2 = "{\"orderNumber\":\"\"}"
                        };
                        var a = pushClient.PushMessages(pushMessage);
                    }
                }
            }
            using (var cmd = new SqlCommand(@"DECLARE @Date DATE=GETDATE()
                                                SELECT  DATEDIFF(DAY , GETDATE() , C_u_InsureExpireDate) AS ExpireDay ,
                                                        CO.UserID ,
                                                        CO.C_u_InsureExpireDate ,
                                                        CO.u_carno ,
                                                        UO.u_mobile_number
                                                FROM    Tuhu_profiles..CarObject AS CO ( NOLOCK )
                                                JOIN    Tuhu_profiles..UserObject AS UO ( NOLOCK )
                                                        ON CO.UserID = UO.UserID
                                                WHERE   C_u_InsureExpireDate IS NOT NULL
                                                        AND CO.C_u_InsureExpireDate >= @Date
                                                        AND CO.C_u_InsureExpireDate < DATEADD(DAY , 1 , @Date)"))
            {
                Cars = DbHelper.ExecuteSelect <InsureCarModel>(true, cmd).ToList();
                if (Cars != null)
                {
                    foreach (var i in Cars)
                    {
                        //插入通知消息
                        using (var pushClient = new PushClient())
                        {
                            var pushMessage = new PushMessageModel()
                            {
                                Type          = MessageType.AppNotification,
                                CenterMsgType = "1普通",
                                PhoneNumbers  = new List <string> {
                                    i.u_mobile_number
                                },
                                Content            = "您的爱车" + i.u_carno + "保险已过期,目前处于裸奔模式,请及时购买新的保险!",
                                HeadImageUrl       = "http://image.tuhu.cn/news/wuliu.png",
                                InsertAppCenterMsg = true,
                                Title      = "爱车保险已过期,请及时续保",
                                SourceName = "Job.tuhu.cn"
                            };

                            pushMessage.AndriodModel = new AndriodModel
                            {
                                AfterOpen   = AfterOpenEnum.GoActivity,
                                AppActivity = "cn.TuHu.Activity.LoveCar.MyLoveCarActivity",
                            };

                            pushMessage.IOSModel = new IOSModel
                            {
                                ExKey1   = "appoperateval",
                                ExValue1 = "Tuhu.THCarDetailsVC",
                                ExKey2   = "keyvaluelenth",
                                ExValue2 = "{\"orderNumber\":\"\"}"
                            };
                            var a = pushClient.PushMessages(pushMessage);
                        }
                    }
                }
            }
            //这个是每周六提醒块到期的
            if (DateTime.Now.Date.DayOfWeek == DayOfWeek.Saturday)
            {
                using (var cmd = new SqlCommand(@"DECLARE @Date DATE= GETDATE();
                                                    SELECT  DATEDIFF(DAY , GETDATE() , C_u_InsureExpireDate) AS ExpireDay ,
                                                            CO.UserID ,
                                                            CO.C_u_InsureExpireDate ,
                                                            CO.u_carno ,
                                                            UO.u_mobile_number
                                                    FROM    Tuhu_profiles..CarObject AS CO ( NOLOCK )
                                                    JOIN    Tuhu_profiles..UserObject AS UO ( NOLOCK )
                                                            ON CO.UserID = UO.UserID
                                                    WHERE   C_u_InsureExpireDate IS NOT NULL
                                                            AND C_u_InsureExpireDate >= @Date
                                                            AND C_u_InsureExpireDate < DATEADD(MONTH , 2 , GETDATE());"))
                {
                    Cars = DbHelper.ExecuteSelect <InsureCarModel>(true, cmd).ToList();
                }
                if (Cars != null)
                {
                    foreach (var i in Cars)
                    {
                        //插入通知消息
                        using (var pushClient = new PushClient())
                        {
                            var pushMessage = new PushMessageModel()
                            {
                                Type          = MessageType.AppNotification,
                                CenterMsgType = "1普通",
                                PhoneNumbers  = new List <string> {
                                    i.u_mobile_number
                                },
                                Content            = "您的爱车" + i.u_carno + "保险还有" + i.ExpireDay + "天就要到期了哦,请及时购买新的保险;不然爱车就要开启裸奔模式了哦",
                                HeadImageUrl       = "http://image.tuhu.cn/news/wuliu.png",
                                InsertAppCenterMsg = true,
                                Title      = "爱车保险快到期啦",
                                SourceName = "Job.tuhu.cn"
                            };

                            pushMessage.AndriodModel = new AndriodModel
                            {
                                AfterOpen   = AfterOpenEnum.GoActivity,
                                AppActivity = "cn.TuHu.Activity.LoveCar.MyLoveCarActivity",
                            };

                            pushMessage.IOSModel = new IOSModel
                            {
                                ExKey1   = "appoperateval",
                                ExValue1 = "Tuhu.THCarDetailsVC",
                                ExKey2   = "keyvaluelenth",
                                ExValue2 = "{\"orderNumber\":\"\"}"
                            };
                            var a = pushClient.PushMessages(pushMessage);
                        }
                    }
                }
                Logger.Info("结束任务");
            }
        }