Пример #1
0
        public static bool PushTaskMessage(PushMessageViewModel message)
        {
            var result      = false;
            var pushMessage = ConverToMessageModel(message);

            pushMessage.Type = message.PushType == Push_Groupcast ? MessageType.AppGroupcast : MessageType.AppBroadcast;
            if (message.PushType == Push_Groupcast)
            // 组播,添加tag的逻辑
            {
                pushMessage.Tags = message.Tags?.Split(';').ToList();
            }

            try
            {
                using (var client = new PushClient())
                {
                    var pushResult = client.PushTaskMessage(pushMessage);
                    if (pushResult != null)
                    {
                        if (!string.IsNullOrEmpty(pushResult.ErrorMessage))
                        {
                            logger.Log(Level.Error, pushResult.ErrorMessage, "Error occurred in PushTaskMessage");
                        }
                        else
                        {
                            result = pushResult.Result;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Log(Level.Error, ex, "Error occurred in PushTaskMessage");
            }

            return(result);
        }