Esempio n. 1
0
        public async Task <bool> EnqueueMessageBroadcastAsync(MessageQueueItem mqi, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (Config.SystemBehaviorConfig.IsAzure)
            {
                if (!String.IsNullOrWhiteSpace(mqi.Message.ReceivingUserId))
                {
                    var dm = await _departmentsService.GetDepartmentMemberAsync(mqi.Message.ReceivingUserId, mqi.DepartmentId);

                    string departmentNumber = await _departmentSettingsService.GetTextToCallNumberForDepartmentAsync(dm.DepartmentId);

                    mqi.DepartmentTextNumber = departmentNumber;

                    if (mqi.Message.ReceivingUser == null)
                    {
                        var user = mqi.Profiles.FirstOrDefault(x => x.UserId == mqi.Message.ReceivingUserId);

                        if (user != null && user.User != null)
                        {
                            mqi.Message.ReceivingUser = user.User;
                        }
                    }
                }
                else if (!String.IsNullOrWhiteSpace(mqi.Message.SendingUserId))
                {
                    var dm = await _departmentsService.GetDepartmentMemberAsync(mqi.Message.SendingUserId, mqi.DepartmentId);

                    string departmentNumber = await _departmentSettingsService.GetTextToCallNumberForDepartmentAsync(dm.DepartmentId);

                    mqi.DepartmentTextNumber = departmentNumber;
                }

                return(await _outboundQueueProvider.EnqueueMessage(mqi));
            }
            else
            {
                QueueItem item = new QueueItem();
                item.QueueType = (int)QueueTypes.MessageBroadcast;
                item.SourceId  = mqi.Message.MessageId.ToString();
                item.QueuedOn  = DateTime.UtcNow;

                await _queueItemsRepository.SaveOrUpdateAsync(item, cancellationToken);
            }

            return(true);
        }
Esempio n. 2
0
        public void EnqueueMessageBroadcast(MessageQueueItem mqi)
        {
            if (Config.SystemBehaviorConfig.IsAzure)
            {
                if (!String.IsNullOrWhiteSpace(mqi.Message.ReceivingUserId))
                {
                    var    dm = _departmentsService.GetDepartmentMember(mqi.Message.ReceivingUserId, mqi.DepartmentId);
                    string departmentNumber = _departmentSettingsService.GetTextToCallNumberForDepartment(dm.DepartmentId);
                    mqi.DepartmentTextNumber = departmentNumber;

                    if (mqi.Message.ReceivingUser == null)
                    {
                        var user = mqi.Profiles.FirstOrDefault(x => x.UserId == mqi.Message.ReceivingUserId);

                        if (user != null && user.User != null)
                        {
                            mqi.Message.ReceivingUser = user.User;
                        }
                    }
                }
                else if (!String.IsNullOrWhiteSpace(mqi.Message.SendingUserId))
                {
                    var    dm = _departmentsService.GetDepartmentMember(mqi.Message.SendingUserId, mqi.DepartmentId);
                    string departmentNumber = _departmentSettingsService.GetTextToCallNumberForDepartment(dm.DepartmentId);
                    mqi.DepartmentTextNumber = departmentNumber;
                }

                _outboundQueueProvider.EnqueueMessage(mqi);
            }
            else
            {
                QueueItem item = new QueueItem();
                item.QueueType = (int)QueueTypes.MessageBroadcast;
                item.SourceId  = mqi.Message.MessageId.ToString();
                item.QueuedOn  = DateTime.UtcNow;

                _queueItemsRepository.SaveOrUpdate(item);
            }
        }