예제 #1
0
        protected override async Task ReceiveMessageImplAsync(
            BrokeredMessage message,
            MessageSession session,
            CancellationToken cancellationToken)
        {
            var postUserRoleMessage = message.GetBody <PostUserRoleMessage>();

            foreach (var role in (RoleType[])Enum.GetValues(typeof(RoleType)))
            {
                await _roleRepository.DeleteUserRole(postUserRoleMessage.UserId,
                                                     role);
            }

            foreach (var role in postUserRoleMessage.Roles)
            {
                await _roleRepository.AddUserRole(postUserRoleMessage.UserId,
                                                  (RoleType)Enum.Parse(typeof(RoleType), role));
            }

            WriteLog($"Handling queue message {message.MessageId}");
            var payload = new PostUserRoleResultMessage();

            await _serviceBusCommunicationService.SendBrokeredMessage(new BrokeredMessage(payload)
            {
                SessionId = message.SessionId
            }, "Processed-Post-User-Roles-Queue");
        }
        protected override async Task ReceiveMessageImplAsync(
            BrokeredMessage message,
            MessageSession session,
            CancellationToken cancellationToken)
        {
            var userId         = message.GetBody <Guid>();
            var transportation = new Transportation
            {
                TransportationId = Guid.NewGuid(),
                IsActive         = true,
                CreatedAt        = DateTime.UtcNow.Subtract(DateTime.MinValue.AddYears(1969)).TotalSeconds
            };
            await _transportationRepository.SaveTransportation(transportation, userId);

            WriteLog($"Handling queue message {message.MessageId}");

            var payload = new PostTransporationResultMessage
            {
                TransportationId = transportation.TransportationId
            };
            await _serviceBusCommunicationService.SendBrokeredMessage(new BrokeredMessage(payload)
            {
                SessionId = message.SessionId
            }, "Processed-Post-Transportation-Queue");
        }
예제 #3
0
        protected override async Task ReceiveMessageImplAsync(
            BrokeredMessage message,
            MessageSession session,
            CancellationToken cancellationToken)
        {
            var incomingMessage = message.GetBody <PatchAlertSeverityMessage>();
            await _alertRepository.UpdateAlertSeverityLevel(incomingMessage.AlertId, incomingMessage.SeverityLevel);

            var payload = new PatchAlertSeverityResultMessage();

            await _serviceBusCommunicationService.SendBrokeredMessage(new BrokeredMessage(payload)
            {
                SessionId = message.SessionId
            }, "Processed-Patch-Alert-Severity-Queue");
        }
        protected override async Task ReceiveMessageImplAsync(
            BrokeredMessage message,
            MessageSession session,
            CancellationToken cancellationToken)
        {
            var transportationId = message.GetBody <Guid>();
            var payload          = await _transportationService.GetTransportationDetails(transportationId);

            WriteLog($"Handling queue message {message.MessageId}");

            await _serviceBusCommunicationService.SendBrokeredMessage(new BrokeredMessage(payload)
            {
                SessionId = message.SessionId
            }, "Processed-Get-Transportation-Details-Queue");
        }
예제 #5
0
        protected override async Task ReceiveMessageImplAsync(
            BrokeredMessage message,
            MessageSession session,
            CancellationToken cancellationToken)
        {
            var incomingMessage = message.GetBody <PostAlertMessage>();
            var alert           = _autoMapperService.MapObject <Alert>(incomingMessage.AlertDto);
            await _alertRepository.SaveAlert(alert, incomingMessage.TransportationId);

            var payload = new PostAlertResultMessage();

            await _serviceBusCommunicationService.SendBrokeredMessage(new BrokeredMessage(payload)
            {
                SessionId = message.SessionId
            }, "Processed-Post-Alert-Queue");
        }
        protected override async Task ReceiveMessageImplAsync(
            BrokeredMessage message,
            MessageSession session,
            CancellationToken cancellationToken)
        {
            var userId = message.GetBody <Guid>();
            await _userRepository.DeleteUser(userId);

            WriteLog($"Handling queue message {message.MessageId}");
            var payload = new DeleteUserResultMessage();

            await _serviceBusCommunicationService.SendBrokeredMessage(new BrokeredMessage(payload)
            {
                SessionId = message.SessionId
            }, "Processed-Delete-User-Queue");
        }
        protected override async Task ReceiveMessageImplAsync(
            BrokeredMessage message,
            MessageSession session,
            CancellationToken cancellationToken)
        {
            var alertId     = message.GetBody <Guid>();
            var alertSasUri = await _alertService.GetAlertSasUri(alertId);

            var payload = new GetAlertResultMessage {
                AlertSasUri = alertSasUri
            };

            await _serviceBusCommunicationService.SendBrokeredMessage(new BrokeredMessage(payload)
            {
                SessionId = message.SessionId
            }, "Processed-Get-Alert-Queue");
        }
예제 #8
0
        protected override async Task ReceiveMessageImplAsync(
            BrokeredMessage message,
            MessageSession session,
            CancellationToken cancellationToken)
        {
            var userDto = message.GetBody <UserDto>();
            var user    = _autoMapperService.MapObject <User>(userDto);
            await _userRepository.AddUser(user);

            WriteLog($"Handling queue message {message.MessageId}");
            var payload = new AddUserResultMessage();

            await _serviceBusCommunicationService.SendBrokeredMessage(new BrokeredMessage(payload)
            {
                SessionId = message.SessionId
            }, "Processed-Post-User-Queue");
        }
예제 #9
0
        protected override async Task ReceiveMessageImplAsync(
            BrokeredMessage message,
            MessageSession session,
            CancellationToken cancellationToken)
        {
            var userId         = message.GetBody <Guid>();
            var userViolations = await _violationService.GetUserViolations(userId);

            var violationDtos = _autoMapperService.MapObject <List <ViolationDto> >(userViolations.ToList());
            var payload       = new GetUserViolationListResultMessage
            {
                Violations = violationDtos
            };
            await _serviceBusCommunicationService.SendBrokeredMessage(new BrokeredMessage(payload)
            {
                SessionId = message.SessionId
            }, "Processed-Get-User-Violation-List-Queue");
        }
예제 #10
0
        protected override async Task ReceiveMessageImplAsync(
            BrokeredMessage message,
            MessageSession session,
            CancellationToken cancellationToken)
        {
            var alertListSasUri = await _alertService.GetAlertListSasUri();

            //var alerts =  await _alertRepository.GetAlerts();
            //var alertResultDtos = _autoMapperService.MapObject<IEnumerable<AlertResultDto>>(alerts);
            var payload = new GetAlertListResultMessage {
                AlertListSasUri = alertListSasUri
            };

            await _serviceBusCommunicationService.SendBrokeredMessage(new BrokeredMessage(payload)
            {
                SessionId = message.SessionId
            }, "Processed-Get-Alert-List-Queue");
        }
예제 #11
0
        protected override async Task ReceiveMessageImplAsync(
            BrokeredMessage message,
            MessageSession session,
            CancellationToken cancellationToken)
        {
            var userId   = message.GetBody <Guid>();
            var userRole = await _roleRepository.GetUserRoles(userId);

            WriteLog($"Handling queue message {message.MessageId}");
            var payload = new GetUserRolesResultMessage
            {
                Roles = userRole.Select(role => role.RoleType.ToString()).ToArray()
            };

            await _serviceBusCommunicationService.SendBrokeredMessage(new BrokeredMessage(payload)
            {
                SessionId = message.SessionId
            }, "Processed-Get-User-Roles-Queue");
        }
        protected override async Task ReceiveMessageImplAsync(
            BrokeredMessage message,
            MessageSession session,
            CancellationToken cancellationToken)
        {
            var users = await _userRepository.GetUsers();

            var userDtoList = _autoMapperService.MapObject <List <UserDto> >(users);

            WriteLog($"Handling queue message {message.MessageId}");
            var payload = new GetUsersResultMessage
            {
                UserDtos = userDtoList
            };

            await _serviceBusCommunicationService.SendBrokeredMessage(new BrokeredMessage(payload)
            {
                SessionId = message.SessionId
            }, "Processed-Get-Users-Queue");
        }
        protected override async Task ReceiveMessageImplAsync(
            BrokeredMessage message,
            MessageSession session,
            CancellationToken cancellationToken)
        {
            var incomingMessage          = message.GetBody <GetTransportationListMessage>();
            var transportationListSasUri = await _transportationService.GetTransportationListSasUri(
                incomingMessage.PeriodStart,
                incomingMessage.PeriodEnd);

            WriteLog($"Handling queue message {message.MessageId}");

            var payload = new GetTransportationListResultMessage
            {
                PayloadSasUri = transportationListSasUri
            };
            await _serviceBusCommunicationService.SendBrokeredMessage(new BrokeredMessage(payload)
            {
                SessionId = message.SessionId
            }, "Processed-Get-Transportation-List-Queue");
        }
예제 #14
0
        protected override async Task ReceiveMessageImplAsync(
            BrokeredMessage message,
            MessageSession session,
            CancellationToken cancellationToken)
        {
            var incomingMessage = message.GetBody <PatchTransportationMessage>();
            var transportation  = new Transportation
            {
                TransportationId = incomingMessage.TransportationId,
                IsActive         = incomingMessage.IsActive
            };
            await _transportationRepository.PatchTransportationStatus(transportation);

            WriteLog($"Handling queue message {message.MessageId}");

            var payload = new PatchTransportationResultMessage();

            await _serviceBusCommunicationService.SendBrokeredMessage(new BrokeredMessage(payload)
            {
                SessionId = message.SessionId
            }, "Processed-Patch-Transportation-Queue");
        }
        protected override async Task ReceiveMessageImplAsync(
            BrokeredMessage message,
            MessageSession session,
            CancellationToken cancellationToken)
        {
            var incomingMessage   = message.GetBody <GetUserDrivingTimeMessage>();
            var calculationResult =
                await _violationCalculationService.CalculateDrivingLimit(incomingMessage.TransportationListSasUri,
                                                                         incomingMessage.UserId);

            var payload = new GetUserDrivingTimeResultMessage
            {
                DrivingTimePastWeek = calculationResult.DrivingTimePastWeek,
                DrivingTimePastDay  = calculationResult.DrivingTimePastDay,
                DrivingTimeLeftTillNextRestRequired            = calculationResult.DrivingTimeLeftTillNextRestRequired,
                RestTimeLeftTillNextTransportationCanBeStarted =
                    calculationResult.RestTimeLeftTillNextTransportationCanBeStarted
            };

            await _serviceBusCommunicationService.SendBrokeredMessage(new BrokeredMessage(payload)
            {
                SessionId = message.SessionId
            }, "Processed-Get-User-Driving-Time-Queue");
        }
예제 #16
0
 private async Task SendSignalrProcessedLocationsMessage(IEnumerable <string> sasUrilist)
 {
     await _serviceBusCommunicationService.SendBrokeredMessage(new BrokeredMessage(sasUrilist),
                                                               "Processed-Post-Captured-Locations-Queue");
 }