/// <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> public static async void CreateEvent(PersonBase person, string alertId, GangwayEventType gangwayEventType) { var workstation = DIContainer.Instance.Resolve<Workstation>(); // Fills event detail. var eventDetail = new EventDetail(); string eventTypeId = gangwayEventType.RetrieveEventTypeId(); eventDetail.GangwayEventProcessType = person.GangwayEventProcessType.HasValue ? person.GangwayEventProcessType.Value : GangwayEventProcessType.Manual; eventDetail.AlertCode = alertId; if (string.IsNullOrEmpty(alertId) && person.Alerts.Any(alert => alert.IsParentalAuthorizationAlert || alert.IsFolioAlert)) { var alertData = person.Alerts.FirstOrDefault(alert => alert.IsParentalAuthorizationAlert || alert.IsFolioAlert); 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; } var personEvent = new PersonEvent() { EventTypeId = eventTypeId, 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.RetrieveXml(), EventDate = workstation.CurrentDateTime, ApplicationId = CommonConstants.ApplicationId, VoyageId = person.CruiseDetail != null ? person.CruiseDetail.VoyageId : null }; await GangwayRepositoryFactory.Retrieve().CreateEventAsync(personEvent); }
/// <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 }; }