/// <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> 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> /// Uploads photo asynchronous. /// </summary> /// <param name="swapPhoto">The swap photo.</param> /// <param name="personBase">The person base.</param> /// <param name="photo">The byte array of photo.</param> /// <param name="gangwayEventType">Type of the gangway event.</param> /// <returns> /// Upload media Items. /// </returns> public async Task UploadPhotosAsync(SwapPhoto swapPhoto, PersonBase personBase, byte[] photo, GangwayEventType gangwayEventType) { var person = personBase != null ? personBase : new PersonBase { PersonId = swapPhoto.PersonId, PersonType = swapPhoto.PersonType, PersonTypeId = swapPhoto.PersonTypeId, CruiseDetail = new GuestCruiseDetail { VoyageId = swapPhoto.VoyageId }, LinkId = swapPhoto.LinkId }; var personEvent = CreateEventService.MapPersonEvent(person, null, gangwayEventType, null, null, null, null); await GangwayRepositoryFactory.Retrieve().UploadPhotosAsync(person, photo, personEvent); }
/// <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 }; }