Пример #1
0
        public async Task Consume(ConsumeContext <BizSystemNotifyMsg> context)
        {
            if (string.IsNullOrEmpty(context.Message.SystemId))
            {
                throw new ArgumentNullException(nameof(context.Message.SystemId));
            }

            msg = context.Message;

            bizSystem = await _bizSystemAppService.GetByIdForNotifyMsgAsync(msg.SystemId);

            if (bizSystem == null)
            {
                _logger.Warning("BizSystem is not found: {BizSystemId}", msg.SystemId);
                return;
            }

            if (bizSystem.Approachs == null || bizSystem.Approachs.Length == 0)
            {
                return;
            }

            if (bizSystem.UseAllApproachs)
            {
                foreach (var approach in bizSystem.Approachs)
                {
                    await ProcessApproachAsync(context, approach);
                }
            }
            else
            {
                var approach = bizSystem.Approachs[0];
                await ProcessApproachAsync(context, approach);
            }

            /* 1 get bizsystem
             * 2 approach is APP:
             * 2.1 get userid for receiver
             * 2.2 get session actor for user
             * 2.3 pushnotify into actor
             * 3 approach is SMS:
             * 3.1 get mobile for receiver
             * 3.2 send sms msg into CEF queue
             * 4 user is online
             * 4.1 send notify into notify queue
             * 5 user is offline
             * 5.1 get device
             * 5.1 send push into push queue
             * 6 notify queue get msg
             * 6.1 send via SignalR
             * 7 push queue get msg
             * 7.1 send via Azure Notification Hubs
             */
        }
Пример #2
0
        public async Task <bool> AddOrUpdateForMsgNotifyAsync(MsgNotifyBizSystem input)
        {
            if (input == null)
            {
                throw new ArgumentNullException(nameof(input));
            }

            var dict = await StateManager.GetOrAddAsync <IReliableDictionary2 <string, MsgNotifyBizSystem> >(Service.DictionaryName_MsgNotifyBizSystem);

            using (var tx = StateManager.CreateTransaction())
            {
                await dict.AddOrUpdateAsync(tx, input.Id, input, (k, v) => input);

                await tx.CommitAsync();

                return(true);
            }
        }
        public async Task <IActionResult> AddOrUpdateMsgNotifyBizSystemAsync(MsgNotifyBizSystem model)
        {
            try
            {
                if (model == null)
                {
                    throw new ArgumentNullException(nameof(model));
                }
                if (string.IsNullOrEmpty(model.Id))
                {
                    throw new ArgumentOutOfRangeException(nameof(model.Id));
                }

                return(Ok(await _bizSystemAppService.AddOrUpdateForMsgNotifyAsync(model)));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }