Пример #1
0
        private async Task<(bool success, string message)> SaveNotification(LottoLionContext ltctx, TbLionMember member, string message)
        {
            var _result = (success: false, message: "ok");

            try
            {
                var _notify = new TbLionNotify()
                {
                    LoginId = member.LoginId,
                    NotifyTime = DateTime.Now,

                    Message = message,
                    IsRead = false
                };

                ltctx.TbLionNotify.Add(_notify);

                _result.success = await ltctx.SaveChangesAsync() > 0;
            }
            catch (Exception ex)
            {
                _result.message = ex.Message;
            }

            return _result;
        }
Пример #2
0
        private async Task<(bool success, string message)> SendNotification(LottoLionContext ltctx, TbLionMember member, string title, string message)
        {
            var _result = (success: false, message: "ok");

            try
            {
                var _notify_count = ltctx.TbLionNotify
                                            .Where(n => n.LoginId == member.LoginId && n.IsRead == false)
                                            .Count();

                _notify_count++;

                if (member.DeviceType == "I")
                {
                    _result = await IosPushNotifyAPNs
                                    .JwtAPNsPush(member.DeviceId, message, _notify_count, IosApnsSound);
                }
                else if (member.DeviceType == "A")
                {
                    _result = await DroidPushNotifyFCM
                                    .SendNotification(member.DeviceId, "high", title, "PUSH_EVENT_ALARM", message, _notify_count, "alarm", "#d32121");
                }
                else if (member.DeviceType == "W")
                {
                }

                if (_result.success == false)
                {
                    member.DeviceType = "U";
                    member.DeviceId = "";

                    await ltctx.SaveChangesAsync();
                }
            }
            catch (Exception ex)
            {
                _result.message = ex.Message;
            }

            return _result;
        }