public async Task<IHttpActionResult> ClearAlert([FromBody] ClearAlertMessage entity, string alertId = null, string statusId = null, bool? isAlert = null, bool? isOnlineMode = null) { return await this.DeleteAsync(async operationResult => { var clearAlertMessage = new ClearAlertMessage(); bool isAlertFlag; string id; if (isAlert.HasValue) { isAlertFlag = isAlert.Value; id = alertId; clearAlertMessage.StatusId = statusId; if (isAlertFlag) { clearAlertMessage.PersonAlertId = alertId; } else { clearAlertMessage.PersonMessageId = alertId; } } else { isAlertFlag = !string.IsNullOrEmpty(entity.PersonAlertId); id = isAlertFlag ? entity.PersonAlertId : entity.PersonMessageId; clearAlertMessage = entity; } await this.personManager.ClearAlertMessageAsync(clearAlertMessage, id, isAlertFlag, isOnlineMode.HasValue ? isOnlineMode.Value : true); }); }
/// <summary> /// Creates the event. /// </summary> /// <param name="person">The person.</param> /// <param name="gangwayEventType">Type of the gangway event.</param> /// <param name="personEvent">The person event.</param> /// <param name="boardingDetail">The boarding detail.</param> /// <param name="clearAlertMessage">The clear alert message.</param> public static async void CreateEvent(PersonBase person, GangwayEventType gangwayEventType, PersonEvent personEvent, BoardingDetail boardingDetail, ClearAlertMessage clearAlertMessage) { if (personEvent != null) { await GangwayRepositoryFactory.Retrieve().CreateEventAsync(personEvent, boardingDetail, clearAlertMessage); } else { var eventDetail = new EventDetail(); eventDetail.GangwayEventProcessType = person.GangwayEventProcessType.HasValue ? person.GangwayEventProcessType.Value : GangwayEventProcessType.Manual; await GangwayRepositoryFactory.Retrieve().CreateEventAsync(MapPersonEvent(person, gangwayEventType, null, null, null, null, eventDetail), null, null); } }
/// <summary> /// Creates the event. /// </summary> /// <param name="person">The person.</param> /// <param name="alertId">The alert identifier.</param> /// <param name="gangwayEventType">Type of the gangway event.</param> /// <param name="boardingDetail">The boarding detail.</param> /// <param name="clearAlertMessage">The clear alert message.</param> /// <param name="photoAddress">The photo address.</param> /// <param name="mediaItemId">The media item identifier.</param> /// <returns>Return instance of Person Event.</returns> public static PersonEvent MapPersonEvent(PersonBase person, string alertId, GangwayEventType gangwayEventType, BoardingDetail boardingDetail, ClearAlertMessage clearAlertMessage, string photoAddress, string mediaItemId) { // Fills event detail. var eventDetail = new EventDetail(); if (person != null) { eventDetail.GangwayEventProcessType = person.GangwayEventProcessType.HasValue ? person.GangwayEventProcessType.Value : GangwayEventProcessType.Manual; eventDetail.AlertCode = alertId; var alertData = person.Alerts.FirstOrDefault(alert => alert.IsParentalAuthorizationAlert || alert.IsFolioAlert || alert.IsNotCheckedIn || alert.IsPortManningAlert); if (string.IsNullOrEmpty(alertId) && alertData != null) { if (alertData != null && alertData.Message != null) { eventDetail.AlertDescription = alertData.Message.Description; } } else if (gangwayEventType == GangwayEventType.AlertRemoved && !string.IsNullOrEmpty(alertId)) { eventDetail.AlertDescription = person.Alerts.Where(alert => alert.AlertId.Equals(alertId)).Select(a => a.Message.Description).FirstOrDefault(); } else if (gangwayEventType == GangwayEventType.MessageRemoved && !string.IsNullOrEmpty(alertId)) { eventDetail.AlertDescription = person.Messages.Where(alert => alert.AlertId.Equals(alertId)).Select(a => a.Message.Description).FirstOrDefault(); } if (person.CruiseDetail != null) { eventDetail.ReservationNumber = person.CruiseDetail.ReservationNumber; } return MapPersonEvent(person, gangwayEventType, boardingDetail, clearAlertMessage, photoAddress, mediaItemId, eventDetail); } return null; }
/// <summary> /// Creates the person event. /// </summary> /// <param name="person">The person.</param> /// <param name="gangwayEventType">Type of the gangway event.</param> /// <param name="boardingDetail">The boarding detail.</param> /// <param name="clearAlertMessage">The clear alert message.</param> /// <param name="photoAddress">The photo address.</param> /// <param name="mediaItemId">The media item identifier.</param> /// <param name="eventDetail">The event detail.</param> /// <returns>Return instance of Person Event.</returns> private static PersonEvent MapPersonEvent(PersonBase person, GangwayEventType gangwayEventType, BoardingDetail boardingDetail, ClearAlertMessage clearAlertMessage, string photoAddress, string mediaItemId, EventDetail eventDetail) { var workstation = DIContainer.Instance.Resolve<Workstation>(); string eventTypeId = gangwayEventType.RetrieveEventTypeId(); return new PersonEvent() { EventTypeId = eventTypeId, AlternateId = Guid.NewGuid().ToString(), PersonId = person.PersonId, PersonTypeId = person.PersonTypeId, ShipId = workstation.Ship != null ? workstation.Ship.ShipId : null, MachineName = workstation.MachineName, Location = workstation.GangwayLocation != null ? workstation.GangwayLocation.Name : null, Port = workstation.Port != null ? workstation.Port.Name : null, AddedBy = workstation.User != null ? workstation.User.UserFullName : null, EventDetails = eventDetail != null ? eventDetail.RetrieveXml() : null, EventDate = workstation.CurrentDateTime, EventDateGMT = DateTime.UtcNow, ApplicationId = CommonConstants.ApplicationId, VoyageId = person.CruiseDetail != null ? person.CruiseDetail.VoyageId : null, LinkId = person.LinkId, PersonStatusDetail = workstation.ConnectionMode == ConnectionMode.Offline ? boardingDetail : null, PersonNotificationDetail = workstation.ConnectionMode == ConnectionMode.Offline ? clearAlertMessage : null, PhotoAddress = photoAddress, MediaItemId = mediaItemId, MediaTypeId = CommonConstants.MediaItemTypeId }; }
public async Task OfflineModeClearPersonMessageAsync() { try { var clearAlertMessage = new ClearAlertMessage { PersonId = "1", PersonTypeId = "21", PersonMessageId = "1", ShipId = "1", StatusId = "2", StatusUpdateDate = DateTime.Now, StatusUpdatedBy = "test", VoyageId = "1", PersonEvent = new PersonEvent { AddedBy = "Test" } }; await this.repository.ClearAlertMessageAsync(clearAlertMessage, clearAlertMessage.PersonMessageId, false, false); } finally { this.Dispose(); } }
public async Task ClearPersonMessageAsync() { try { CommonDependencies(); var clearAlertMessage = new ClearAlertMessage { PersonId = "1", PersonTypeId = "21", PersonMessageId = "1", ShipId = "1", StatusId = "2", StatusUpdateDate = DateTime.Now, StatusUpdatedBy = "test", VoyageId = "1" }; await this.manager.ClearAlertMessageAsync(clearAlertMessage, "1", false, false); } finally { this.Dispose(); } }
/// <summary> /// Function to acknowledge person messages. /// </summary> /// <param name="message">The message.</param> /// <param name="person">Instance of PersonBase</param> /// <returns> /// IObservable of list of Alert /// </returns> public static async Task<PersonMessage> AcknowledgePersonMessages(PersonMessage message, PersonBase person) { var workstation = DIContainer.Instance.Resolve<Workstation>(); var clearAlertMessage = new ClearAlertMessage() { PersonMessageId = message.AlertId, PersonId = person.PersonId, PersonTypeId = person.PersonTypeId, StatusId = AlertMessageStatusType.ClearAlert.RetrieveStatusId(), ShipId = workstation.Ship.ShipId, StatusUpdateDate = workstation.CurrentDateTime, StatusUpdatedBy = workstation.User.UserId, VoyageId = workstation.Voyage.VoyageId }; var personEvent = CreateEventService.MapPersonEvent(person, message.AlertId, GangwayEventType.MessageRemoved, null, clearAlertMessage, null, null); if (workstation.ConnectionMode != ConnectionMode.Offline) { clearAlertMessage.PersonEvent = personEvent; } await GangwayRepositoryFactory.Retrieve().ClearPersonAlertAndMessageAsync(clearAlertMessage, AlertMessageStatusType.AcknowledgeMessage, personEvent); return await Task.FromResult(message); }
/// <summary> /// Creates the event. /// </summary> /// <param name="personEvent">The person event.</param> /// <param name="boardingDetail">The boarding detail.</param> /// <param name="clearAlertMessage">The clear alert message.</param> /// <returns> /// Task Containing string. /// </returns> public async Task<string> CreateEventAsync(PersonEvent personEvent, BoardingDetail boardingDetail, ClearAlertMessage clearAlertMessage) { var command = this.Database.GetStoredProcCommand(InsertPersonEventDetailStoredProcedure) .AddParameter(MediaItemIdField, DbType.Int32, Convert.ToInt32(personEvent.MediaItemId)) .AddParameter(MediaItemTypeIdField, DbType.Int32, Convert.ToInt32(personEvent.MediaTypeId)) .AddParameter(PhotoURLField, DbType.String, personEvent.PhotoAddress) .AddParameter(() => boardingDetail != null, PersonStatusJSONField, DbType.String, JsonConvert.SerializeObject(boardingDetail)) .AddParameter(PersonEventJSONField, DbType.String, JsonConvert.SerializeObject(personEvent)) .AddParameter(() => clearAlertMessage != null, PersonNotificationJSONField, DbType.String, JsonConvert.SerializeObject(clearAlertMessage)) .AddParameter(PersonEventDetailField, DbType.Xml, personEvent.RetrieveXml()) .AddParameter(EventDetailsField, DbType.Xml, personEvent.EventDetails) .AddParameter(LinkIdField, DbType.String, string.IsNullOrEmpty(personEvent.LinkId) ? Guid.NewGuid().ToString() : personEvent.LinkId) .AddParameter(AlternateIdField, DbType.String, personEvent.AlternateId); return await this.ExecuteReaderAsync(command, GangwayEventDataMapper.MapGangwayEventStatusAsync); }
public async Task ClearMessageTest() { try { var clearAlertMessage = new ClearAlertMessage { PersonId = "1", PersonTypeId = "21", PersonMessageId = "1", ShipId = "1", StatusId = "2", StatusUpdateDate = DateTime.Now, StatusUpdatedBy = "test", VoyageId = "1" }; var actionResult = await this.controller.ClearAlert(clearAlertMessage); Assert.IsNotNull(actionResult); } finally { this.Dispose(); } }
/// <summary> /// Function to remove person alerts. /// </summary> /// <param name="alert">List of alerts to remove</param> /// <param name="person">Instance of PersonBase</param> /// <returns>IObservable of list of Alert</returns> public static async Task<Alert> RemovePersonAlerts(Alert alert, PersonBase person) { var workstation = DIContainer.Instance.Resolve<Workstation>(); ClearAlertMessage clearAlertMessage = null; PersonEvent personEvent = null; if (!alert.IsParentalAuthorizationAlert && !alert.IsFolioAlert && !alert.IsNotCheckedIn && !alert.IsPortManningAlert) { clearAlertMessage = new ClearAlertMessage() { PersonAlertId = alert.AlertId, PersonId = person.PersonId, PersonTypeId = person.PersonTypeId, StatusId = AlertMessageStatusType.ClearAlert.RetrieveStatusId(), ShipId = workstation.Ship.ShipId, StatusUpdateDate = workstation.CurrentDateTime, StatusUpdatedBy = workstation.User.UserId, VoyageId = workstation.Voyage.VoyageId }; } personEvent = CreateEventService.MapPersonEvent(person, alert.AlertId, GangwayEventType.AlertRemoved, null, clearAlertMessage, null, null); if (clearAlertMessage != null && workstation.ConnectionMode != ConnectionMode.Offline) { clearAlertMessage.PersonEvent = personEvent; } if (clearAlertMessage != null) { await GangwayRepositoryFactory.Retrieve().ClearPersonAlertAndMessageAsync(clearAlertMessage, AlertMessageStatusType.ClearAlert, personEvent); } else { CreateEventService.CreateEvent(person, GangwayEventType.AlertRemoved, personEvent, null, null); } return await Task.FromResult(alert); }
/// <summary> /// removes person alert message /// </summary> /// <param name="entity">The entity.</param> /// <param name="clearAlertMessageId">The clear alert message identifier.</param> /// <returns> /// the Task /// </returns> public async Task ClearPersonAlert(ClearAlertMessage entity, string clearAlertMessageId) { await this.personAlertClient.UpdatePersonAlertAsync(clearAlertMessageId, JsonConvert.SerializeObject(new Entities.PersonAlert { PersonAlertId = entity.PersonAlertId, ShipId = entity.ShipId, VoyageId = entity.VoyageId, StatusId = entity.StatusId, PersonId = entity.PersonId, PersonTypeId = entity.PersonTypeId, StatusUpdatedBy = entity.StatusUpdatedBy, StatusUpdatedDate = entity.StatusUpdateDate, MachineName = entity.PersonEvent.MachineName })); }
/// <summary> /// Clears the alert message asynchronous. /// </summary> /// <param name="entity">The entity.</param> /// <param name="clearAlertMessageId">The clear alert message identifier.</param> /// <param name="isAlert">if set to <c>true</c> [is alert].</param> /// <returns>Return nothing</returns> private async Task ClearAlertMessageAsync(ClearAlertMessage entity, string clearAlertMessageId, bool isAlert) { if (isAlert) { await this.personAlertClientRepository.ClearPersonAlert(entity, clearAlertMessageId); } else { await this.personAlertClientRepository.AcknowledgePersonMessage(entity, clearAlertMessageId); } }
/// <summary> /// removes person alert by alert id /// </summary> /// <param name="entity">The entity.</param> /// <param name="clearAlertMessageId">The clear alert message identifier.</param> /// <param name="isAlert">if set to <c>true</c> [is alert].</param> /// <param name="isOnlineMode">if set to <c>true</c> [is on line mode].</param> /// <returns> /// returns nothing /// </returns> public async Task ClearAlertMessageAsync(ClearAlertMessage entity, string clearAlertMessageId, bool isAlert, bool isOnlineMode) { if (!isOnlineMode) { //// Code for handle BT Sync duplicate records var response = await this.personEventClientRepository.CreateAsync(entity.PersonEvent); var result = response != null ? JsonConvert.DeserializeObject<bool>(response) : default(bool); if (result) { await this.ClearAlertMessageAsync(entity, clearAlertMessageId, isAlert); } } else { await this.ClearAlertMessageAsync(entity, clearAlertMessageId, isAlert); if (entity.PersonEvent != null) { await this.personEventClientRepository.CreateAsync(entity.PersonEvent); } } }
/// <summary> /// Clears the person alert. /// </summary> /// <param name="clearAlertMessage">Instance of ClearAlertMessage</param> /// <param name="alertMessageStatusType">The alert and message status type.</param> /// <param name="personEvent">The person event.</param> /// <returns> /// Task Instance. /// </returns> public async Task ClearPersonAlertAndMessageAsync(ClearAlertMessage clearAlertMessage, AlertMessageStatusType alertMessageStatusType, PersonEvent personEvent) { await this.personServiceRepository.ClearPersonAlertAndMessageAsync(clearAlertMessage, alertMessageStatusType); }
/// <summary> /// Clears the person alert. /// </summary> /// <param name="clearAlertMessage">Instance of ClearAlertMessage</param> /// <param name="alertMessageStatusType">The alert and message status type.</param> /// <returns> /// Task Instance. /// </returns> public async Task ClearPersonAlertAndMessageAsync(ClearAlertMessage clearAlertMessage, AlertMessageStatusType alertMessageStatusType) { var command = this.Database.GetStoredProcCommand(UpdatePersonNotificationStoredProcedure) .AddParameter(PersonNotificationDetail, DbType.String, clearAlertMessage.RetrieveXml()); await this.ExecuteNonQueryAsync(command); }
/// <summary> /// Creates the event. /// </summary> /// <param name="personEvent">The person event.</param> /// <param name="boardingDetail">The boarding detail.</param> /// <param name="clearAlertMessage">The clear alert message.</param> /// <returns> /// Task Containing string. /// </returns> public async Task<string> CreateEventAsync(PersonEvent personEvent, BoardingDetail boardingDetail, ClearAlertMessage clearAlertMessage) { return await this.gangwayEventRepository.CreateEventAsync(personEvent); }
/// <summary> /// removes person alert by alert id /// </summary> /// <param name="entity">The entity.</param> /// <param name="clearAlertMessageId">The clear alert message identifier.</param> /// <param name="isAlert">if set to <c>true</c> [is alert].</param> /// <param name="isOnlineMode">if set to <c>true</c> [is on line mode].</param> /// <returns> /// returns nothing /// </returns> public async Task ClearAlertMessageAsync(ClearAlertMessage entity, string clearAlertMessageId, bool isAlert, bool isOnlineMode) { await this.personRepository.ClearAlertMessageAsync(entity, clearAlertMessageId, isAlert, isOnlineMode); }
/// <summary> /// Clears the person alert. /// </summary> /// <param name="clearAlertMessage">Instance of ClearAlertMessage</param> /// <param name="alertMessageStatusType">The alert and message status type.</param> /// <returns> /// Task Instance. /// </returns> public async Task ClearPersonAlertAndMessageAsync(ClearAlertMessage clearAlertMessage, AlertMessageStatusType alertMessageStatusType) { await this.personsClient.ClearPersonAlert(JsonConvert.SerializeObject(clearAlertMessage), null, null, null, isOnlineMode: true); }
public async Task ClearPersonAlertAsync() { try { var clearAlertMessage = new ClearAlertMessage { PersonId = "1", PersonTypeId = "21", PersonAlertId = "1", ShipId = "1", StatusId = "2", StatusUpdateDate = DateTime.Now, StatusUpdatedBy = "test", VoyageId = "1", PersonEvent = new PersonEvent { } }; await this.repository.ClearAlertMessageAsync(clearAlertMessage, clearAlertMessage.PersonAlertId, true, true); } finally { this.Dispose(); } }