public IList <EventEditionCustomType> GetEventEditions(int[] editionIds, int?count) { var langCode = LanguageHelper.GetBaseLanguageCultureName(); var context = _unitOfWork.EventRepository.Context; var events = (from ev in context.Events join e in context.Editions on ev.EventId equals e.EventId join edt in context.EditionTranslations on e.EditionId equals edt.EditionId where editionIds.Contains(e.EditionId) && edt.LanguageCode == langCode select new { EventId = ev.EventId, MasterName = ev.MasterName, //EditionId = edt.EditionId, //EditionName = edt.EditionName, Logo = edt.WebLogoFileName }) .Take(count ?? int.MaxValue).Distinct() .AsEnumerable() .Select(x => new EventEditionCustomType { EventId = x.EventId, MasterName = x.MasterName, //EditionId = x.EditionId, //EditionName = x.EditionName, Logo = x.Logo }) .ToList(); return(events); }
public static EditionTranslationEntity PrepareNewEditionTranslation(Edition newEdition, DWStaging.Edition stagingEdition, EditionTranslationEntity lastEditionTranslation) { if (lastEditionTranslation == null) { lastEditionTranslation = new EditionTranslationEntity { LanguageCode = LanguageHelper.GetBaseLanguageCultureName() }; } var venueName = lastEditionTranslation.LanguageCode == LanguageHelper.GetBaseLanguageCultureName() ? stagingEdition.EventVenue : lastEditionTranslation.VenueName; var newEditionTranslation = new EditionTranslationEntity { EditionId = newEdition.EditionId, LanguageCode = lastEditionTranslation.LanguageCode, Summary = lastEditionTranslation.Summary, Description = lastEditionTranslation.Description, ExhibitorProfile = lastEditionTranslation.ExhibitorProfile, VisitorProfile = lastEditionTranslation.VisitorProfile, VenueName = venueName, MapVenueFullAddress = lastEditionTranslation.MapVenueFullAddress, WebLogoFileName = lastEditionTranslation.WebLogoFileName, PeopleImageFileName = lastEditionTranslation.PeopleImageFileName, ProductImageFileName = lastEditionTranslation.ProductImageFileName, MasterLogoFileName = lastEditionTranslation.MasterLogoFileName, CrmLogoFileName = lastEditionTranslation.CrmLogoFileName, IconFileName = lastEditionTranslation.IconFileName, BookStandUrl = lastEditionTranslation.BookStandUrl, OnlineInvitationUrl = lastEditionTranslation.OnlineInvitationUrl, CreateTime = DateTime.Now, CreateUser = Constants.AutoIntegrationUserId }; //EditionName = stagingEdition.EventName, //ReportingName = !string.IsNullOrWhiteSpace(stagingEdition.EventNameReporting) ? stagingEdition.EventNameReporting : stagingEdition.EventName, //LocalName = !string.IsNullOrWhiteSpace(stagingEdition.EventLongNameLocal) ? stagingEdition.EventLongNameLocal : stagingEdition.EventName, //InternationalName = !string.IsNullOrWhiteSpace(stagingEdition.EventLongNameInternational) ? stagingEdition.EventLongNameInternational : stagingEdition.EventName, return(newEditionTranslation); }
public ActionResult Index(int?id = null) { var anyEventSelected = id.HasValue; if (id.HasValue) { if (!IsDirectorAuthorizedOnEvent(id.Value)) { return(View("Unauthorized")); } } var pastEvents = EventServices.GetPastEventsByDirector( CurrentCedUser.CurrentUser.Email, WebConfigHelper.MinFinancialYear, Constants.DefaultValidEditionStatusesForCed, Constants.ValidEventTypesForCed, 3, 20) .OrderBy(x => x.MasterName).ToList(); foreach (var @event in pastEvents) { @event.DisplayDate = DateHelper.GetDisplayDate(@event.StartDate, @event.EndDate); } if (!pastEvents.Any()) { var allEvents = EventServices.GetEventLightsByDirector( CurrentCedUser.CurrentUser.Email, Constants.ValidEventTypesForCed, WebConfigHelper.MinFinancialYear) .ToList(); if (allEvents.Any()) { id = allEvents.First().EventId; } else { return(View("Unauthorized")); } } if (id == null) { id = pastEvents.First().EventId; } var selectedEvent = EventServices.GetEventById(id.Value); if (selectedEvent == null) { return(View("NotFound")); } var lastEdition = EditionServices.GetLastFinishedEdition(selectedEvent.EventId); if (lastEdition == null) { var nextEdition = EditionServices.GetClosestEdition(selectedEvent.EventId, Constants.ValidEventTypesForCed); if (nextEdition == null) { return(View("Error", new ErrorModel { Message = $"Next edition not found for {selectedEvent.EventId} | {selectedEvent.MasterName}!" })); } return(View(new IndexModel { EventId = selectedEvent.EventId, EventName = selectedEvent.MasterName, EventType = selectedEvent.EventTypeCode.ToEnumFromDescription <EventType>(), EventDisplayDate = selectedEvent.DisplayDate, SelectedEditionId = nextEdition.EditionId, SelectedEditionName = nextEdition.EditionName, NextEditionStartDate = nextEdition.StartDate, EventEditionList = pastEvents })); } selectedEvent.DisplayDate = DateHelper.GetDisplayDate(lastEdition.StartDate, lastEdition.EndDate); var lastEditionTranslation = EditionTranslationServices.GetEditionTranslationLight(lastEdition.EditionId, LanguageHelper.GetBaseLanguageCultureName()); var internationalExhibitorPavilionCounts = StatisticServices.GetInternationalExhibitorPavilionCounts(selectedEvent.EventId, 3); var exhibitorCountryCounts = StatisticServices.GetExhibitorCountryCounts(selectedEvent.EventId, 3); var visitorCountryCounts = StatisticServices.GetVisitorCountryCounts(selectedEvent.EventId, 3); var localExhibitorRetentionRates = StatisticServices.GetExhibitorRetentionRatesLocal(selectedEvent.EventId, 3); var internationalExhibitorRetentionRates = StatisticServices.GetExhibitorRetentionRatesInternational(selectedEvent.EventId, 3); var editionCountriesExhibitor = EditionCountryServices.GetEditionCountriesByEdition(lastEdition.EditionId, EditionCountryRelationType.Exhibitor); var editionCountriesVisitor = EditionCountryServices.GetEditionCountriesByEdition(lastEdition.EditionId, EditionCountryRelationType.Visitor); var exhibitorCountryNames = Countries.Where(c => editionCountriesExhibitor.Any(ec => ec.CountryCode == c.CountryCode)) .Select(c => c.CountryName) .ToList(); var visitorCountryNames = Countries.Where(c => editionCountriesVisitor.Any(ec => ec.CountryCode == c.CountryCode)) .Select(c => c.CountryName) .ToList(); var delegateCountryNames = new List <string>(); var lastEditionEvent = lastEdition.Event ?? EventServices.GetEventById(lastEdition.EventId); if (Constants.ConferenceEventTypes.Contains(lastEditionEvent.EventTypeCode)) { var editionCountriesDelegate = EditionCountryServices.GetEditionCountriesByEdition(lastEdition.EditionId, EditionCountryRelationType.Delegate); delegateCountryNames = editionCountriesDelegate.Any() ? Countries.Where(c => editionCountriesExhibitor.Any(ec => ec.CountryCode == c.CountryCode)) .Select(c => c.CountryName) .ToList() : new List <string>(); } var model = new IndexModel { EventId = selectedEvent.EventId, EventName = selectedEvent.MasterName, EventType = selectedEvent.EventTypeCode.ToEnumFromDescription <EventType>(), EventDisplayDate = selectedEvent.DisplayDate, SelectedEditionId = lastEdition.EditionId, SelectedEditionName = lastEdition.EditionName, EventEditionList = pastEvents, EditionStatModel = new EditionStatModel { ExhibitorCountries = exhibitorCountryNames, VisitorCountries = visitorCountryNames, DelegateCountries = delegateCountryNames, LocalExhibitorRetentionRates = localExhibitorRetentionRates, InternationalExhibitorRetentionRates = internationalExhibitorRetentionRates, NumberOfInternationalPavilions = internationalExhibitorPavilionCounts, NumberOfExhibitorCountries = exhibitorCountryCounts, NumberOfVisitorCountries = visitorCountryCounts, BookAStandUrl = lastEditionTranslation.BookStandUrl, VisitorETicketUrl = lastEditionTranslation.OnlineInvitationUrl } }; // Additions to LOG object if (TempData["Log"] is LogEntity log) { if (log.EntityId == null || log.EntityId == 0) { log.EntityId = selectedEvent.EventId; log.EntityName = selectedEvent.MasterName; log.EventId = selectedEvent.EventId; log.EventName = selectedEvent.MasterName; } if (anyEventSelected) // If an event selected intentionally. { log.AdditionalInfo = "{ 'WebLogoFileName': '" + lastEditionTranslation.WebLogoFileName + "' }"; } } return(View(model)); }
public void UpdateEventEditionFromStagingDb(EditionEntity existingEdition, DWStaging.Edition stagingEdition, DateTime eventStartDate, DateTime eventEndDate) { using (var scope = new TransactionScope()) { var existingEvent = existingEdition.Event; var eventFromStaging = EditionServiceHelper.PreUpdateExistingEvent((EventEntity)existingEvent.Clone(), stagingEdition); // IF MASTERCODE HAS CHANGED: if (existingEvent.MasterCode != eventFromStaging.MasterCode) { // DELETE THIS WRONGLY UPDATED EDITION FROM CED _editionServices.DeleteEdition(existingEdition.EditionId); } else { var diffOnEvent = GetDiffOnEvent(existingEvent, eventFromStaging); var editionFromStaging = EditionServiceHelper.PreUpdateExistingEdition((EditionEntity)existingEdition.Clone(), stagingEdition, eventStartDate, eventEndDate); var diffOnEdition = existingEdition.Compare <EditionEntity, StagingDbComparableAttribute>(editionFromStaging); var existingEditionTranslation = existingEdition.EditionTranslations.Single(x => x.EditionId == existingEdition.EditionId && x.LanguageCode.ToLower() == LanguageHelper.GetBaseLanguageCultureName()); var editionTranslationFromStaging = EditionServiceHelper.PreUpdateExistingEditionTranslation((EditionTranslationEntity)existingEditionTranslation.Clone(), stagingEdition); var diffOnEditionTranslation = existingEditionTranslation.Compare <EditionTranslationEntity, StagingDbComparableAttribute>(editionTranslationFromStaging); if (diffOnEvent.Any()) { try { _eventServices.UpdateEvent(existingEvent.EventId, eventFromStaging, Constants.AutoIntegrationUserId, true); } catch (Exception exc) { var extraInfo = "Error on UpdateEvent() | EventId=" + existingEvent.EventId + " | StagingEditionEventBEID=" + stagingEdition.EventBEID; var log = CreateInternalLog(exc, extraInfo); ExternalLogHelper.Log(log, LoggingEventType.Error); return; } } if (diffOnEditionTranslation.Any() || diffOnEdition.Any() || diffOnEvent.Any()) { try { var startDateChanged = diffOnEdition.SingleOrDefault(x => x.Prop.ToLower().Contains("startdate")) != null; if (startDateChanged) { // UPDATE STARTDATE DIFF for CURRENT EDITION SetEditionStartDateDiff(editionFromStaging); } _editionServices.UpdateEdition(existingEdition.EditionId, editionFromStaging, Constants.AutoIntegrationUserId, true); if (startDateChanged) { // UPDATE STARTDATE DIFF for NEXT EDITION UpdateNextEditionStartDateDiff(existingEdition); } var eventTypeChanged = diffOnEdition.SingleOrDefault(x => x.Prop.ToLower().Contains("eventtype")) != null; if (eventTypeChanged) { if (!Utility.Constants.ValidEventTypesForCed.Contains(existingEdition.EventTypeCode) && Utility.Constants.ValidEventTypesForCed.Contains(editionFromStaging.EventTypeCode) && editionFromStaging.StartDate > DateTime.Now) { SendNotificationEmailForEditionCreation(editionFromStaging, editionTranslationFromStaging, GetEmailTemplateForEditionCreation(editionFromStaging)); } } StartNotificationProcessForEditionNameUpdate(existingEdition, existingEditionTranslation, diffOnEdition); StartNotificationProcessForEditionLocationUpdate(existingEdition, existingEditionTranslation, diffOnEdition); } catch (Exception exc) { var extraInfo = "Error on editionServices.UpdateEdition() | EditionId=" + existingEdition.EditionId + " | StagingEditionEventBEID=" + stagingEdition.EventBEID; var log = CreateInternalLog(exc, extraInfo); ExternalLogHelper.Log(log, LoggingEventType.Error); return; } } if (diffOnEditionTranslation.Any()) { try { _editionTranslationServices.UpdateEditionTranslation(editionTranslationFromStaging, Constants.AutoIntegrationUserId, true); } catch (Exception exc) { var extraInfo = "EditionTranslationId=" + existingEditionTranslation.EditionTranslationId + " | StagingEditionEventBEID=" + stagingEdition.EventBEID; var log = CreateInternalLog(exc, extraInfo); ExternalLogHelper.Log(log, LoggingEventType.Error); return; } } } scope.Complete(); } }
private void UpdateSingleCedEventFromKentico(Edition cedEdition, Clnd_KenticoEvents kenticoEdition, ref bool logoFound) { try { var cedEditionTranslations = _unitOfWork.EditionTranslationRepository.GetManyQueryable(x => x.EditionId == cedEdition.EditionId && x.LanguageCode == LanguageHelper.GetBaseLanguageCultureName()).ToList(); if (cedEditionTranslations.Any() && cedEditionTranslations.Count == 1) { var cedEditionTranslation = cedEditionTranslations.First(); cedEdition.InternationalName = kenticoEdition.EventName; cedEdition.ManagingOfficeName = kenticoEdition.Organiser; cedEdition.ManagingOfficeEmail = kenticoEdition.EmailAddress; cedEdition.ManagingOfficePhone = "+" + kenticoEdition.InternationalDial + " " + kenticoEdition.Telephone; cedEdition.ManagingOfficeWebsite = kenticoEdition.Website; cedEdition.EventWebSite = kenticoEdition.Website; cedEdition.AllDayEvent = Convert.ToBoolean(kenticoEdition.EventAllDay); cedEdition.DisplayOnIteI = Convert.ToBoolean(kenticoEdition.ITEI); cedEdition.DisplayOnIteGermany = Convert.ToBoolean(kenticoEdition.GiMA); cedEdition.DisplayOnIteAsia = Convert.ToBoolean(kenticoEdition.ASIA); cedEdition.DisplayOnIteTurkey = Convert.ToBoolean(kenticoEdition.Turkey); cedEdition.DisplayOnTradeLink = Convert.ToBoolean(kenticoEdition.TradeLink); cedEdition.DisplayOnIteModa = Convert.ToBoolean(kenticoEdition.MODA); cedEdition.UpdateTimeByAutoIntegration = DateTime.Now; cedEditionTranslation.Summary = kenticoEdition.EventSummary.ReplaceBrWithNewLine().StripHtml(); cedEditionTranslation.Description = kenticoEdition.EventDetails.ReplaceBrWithNewLine().StripHtml(); cedEditionTranslation.BookStandUrl = kenticoEdition.BookTicketLink; // Get venue coordinates if (kenticoEdition.VenueLocation.HasValue) { var venue = _unitOfWork.EditionRepository.Context.Clnd_customtable_Venue.SingleOrDefault(x => x.ItemID == kenticoEdition.VenueLocation); if (venue != null) { cedEdition.VenueCoordinates = venue.VenueLocation.Replace(",", ", "); cedEditionTranslation.VenueName = venue.VenueName; } } if (logoFound) { cedEditionTranslation.WebLogoFileName = UploadEventImage(cedEditionTranslation, kenticoEdition.EventImage, true); } logoFound = cedEditionTranslation.WebLogoFileName != null; cedEditionTranslation.PeopleImageFileName = UploadEventImage(cedEditionTranslation, kenticoEdition.EventBackGroundImage, false); cedEditionTranslation.UpdateTimeByAutoIntegration = DateTime.Now; _unitOfWork.Save(); } } catch (Exception exc) { var extraInfo = "Error on UpdateSingleCedEventFromKentico() | EditionId=" + cedEdition + " | KenticoEventBEID=" + kenticoEdition.EventBEID; var log = CreateInternalLog(exc, extraInfo); ExternalLogHelper.Log(log, LoggingEventType.Error); } }
/* EMAIL NOTIFICATION */ public EmailResult SendEmailNotification(EditionEntity edition, NotificationType notificationType, string recipients, UserEntity actor, string body, string buttonUrl, string unsubscribingUrl = null) { //if (string.IsNullOrWhiteSpace(recipients)) //{ // var message = $"{notificationType} type of notification email could not be sent since edition {edition.EditionId} - {edition.EditionName} has no recipients."; // var log = CreateInternalLog(message, actor); // ExternalLogHelper.Log(log, LoggingEventType.Warning); // return new EmailResult { Sent = false, ErrorMessage = message }; //} if (WebConfigHelper.RemoveActorUserFromNotificationRecipients) { recipients = NotificationControllerHelper.RemoveCurrentUserFromRecipients(recipients, actor?.Email); } //if (string.IsNullOrWhiteSpace(recipients)) // return false; try { var recipientFullName = _editionHelper.GetRecipientFullName(edition); var sendEmailAttr = notificationType.GetAttribute <NotificationAttribute>().SendEmail; if (sendEmailAttr) { var editionTranslation = edition.EditionTranslations.SingleOrDefault(x => string.Equals(x.LanguageCode, LanguageHelper.GetBaseLanguageCultureName(), StringComparison.CurrentCultureIgnoreCase)); var emailResult = _emailNotificationHelper.Send(edition, editionTranslation, notificationType, recipientFullName, body, recipients, buttonUrl, unsubscribingUrl); //// EMAIL LOGGING //if (sent) //LogEmail(edition.EditionId, recipients, body, actor?.Email, notificationType.ToString()); return(emailResult); } } catch (Exception exc) { var log = CreateInternalLog(exc, actor); ExternalLogHelper.Log(log, LoggingEventType.Error); } return(new EmailResult { Sent = false, ErrorMessage = "" }); }
public static EditionTranslationEntity PreUpdateExistingEditionTranslation(EditionTranslationEntity existingEditionTranslation, DWStaging.Edition stagingEdition) { existingEditionTranslation.LanguageCode = LanguageHelper.GetBaseLanguageCultureName(); existingEditionTranslation.VenueName = stagingEdition.EventVenue; return(existingEditionTranslation); }