internal bool LogEmail(int?editionId, string recipients, string body, string actorUserEmail, string actionName, ActionType?actionType = ActionType.NotificationEmailSend)
        {
            if (string.IsNullOrWhiteSpace(recipients))
            {
                return(false);
            }

            EditionEntity edition = null;

            if (editionId.HasValue)
            {
                edition = EditionServices.GetEditionById(editionId.Value);
            }

            foreach (var recipient in recipients.Split(','))
            {
                var additionalInfo = "Recipient: " + recipient + " | Body: " + body;
                additionalInfo = additionalInfo.StripHtml().Substr(500);

                var emailLog = CreateEmailLogFunc(edition, actionType.GetValueOrDefault(), actorUserEmail, actionName, additionalInfo);
                LogServices.CreateLog(emailLog);
            }

            return(true);
        }
Exemplo n.º 2
0
        public static bool IsClonable(this EditionEntity edition, CedUser user)
        {
            if (!WebConfigHelper.CloningAllowed)
            {
                return(false);
            }

            if (!Constants.ValidEventActivitiesToClone.Select(x => x.ToLower()).ToArray().Contains(edition.EventActivity.ToLower()))
            {
                return(false);
            }

            if (!Constants.ValidEditionStatusesToClone.Contains(edition.Status.GetHashCode()))
            {
                return(false);
            }

            if (user.IsSuperAdmin)
            {
                return(true);
            }

            if (edition.DirectorEmails.Contains(user.CurrentUser.Email.ToLower()))
            {
                return(true);
            }

            return(false);
        }
 protected void UpdateLogInMemory(EditionEntity edition, string updatedFields = null)
 {
     if (TempData["Log"] is LogEntity log)
     {
         LogControllerHelper.UpdateLogInMemory(log, edition, updatedFields);
     }
 }
Exemplo n.º 4
0
        //public IList<EditionVenue> SearchVenues(int eventId, string searchTerm, int pageSize, int pageNum)
        public IList <EditionVenue> SearchVenues(EditionEntity edition, string searchTerm, int pageSize, int pageNum)
        {
            //_eventServices = new EventServices(_unitOfWork);

            //var @event = _eventServices.GetEventById(eventId);

            //var query = _unitOfWork.EditionTranslationRepository.GetManyQueryableProjected<EditionVenue>(x =>
            //        x.VenueName.ToLower().Contains(searchTerm.ToLower())
            //        && x.Edition.Event.Country.ToLower() == @event.Country.ToLower())
            //    .Distinct();

            var query = _unitOfWork.EditionTranslationRepository.GetManyQueryableProjected <EditionVenue>(x =>
                                                                                                          x.VenueName.ToLower().Contains(searchTerm.ToLower())
                                                                                                          //&& x.Edition.Event.Country.ToLower() == @event.Country.ToLower())
                                                                                                          && x.Edition.Country.ToLower() == edition.Country.ToLower())
                        .Distinct();

            query = query.OrderBy(x => x.VenueName);
            query = query.Skip(pageSize * (pageNum - 1));
            query = query.Take(pageSize);

            var venues = query.ToList();

            return(venues);
        }
Exemplo n.º 5
0
        public static IList <NotificationEntity> CreateInAppNotifications(EditionEntity edition, NotificationType notificationType, string recipients, string actorUserEmail)
        {
            if (WebConfigHelper.RemoveActorUserFromNotificationRecipients)
            {
                recipients = NotificationControllerHelper.RemoveCurrentUserFromRecipients(recipients, actorUserEmail);
            }

            if (string.IsNullOrWhiteSpace(recipients))
            {
                return(null);
            }

            var recipientList = recipients.Split(Utility.Constants.EmailAddressSeparator).ToList();
            var notifications = new List <NotificationEntity>();

            foreach (var recipient in recipientList)
            {
                var notification = new NotificationEntity
                {
                    NotificationType = notificationType,
                    ReceiverEmail    = recipient,
                    EventId          = edition.EventId,
                    EditionId        = edition.EditionId,
                    CreatedOn        = DateTime.Now,
                    Displayed        = false,
                    SentByEmail      = false
                };

                notifications.Add(notification);
            }

            return(notifications);
        }
Exemplo n.º 6
0
        // Current: 2017
        // Previous: 2016
        // StartDate'i değişmiş bir edition'ın StartDateDiff değerlerini güncelle.
        public void SetEditionStartDateDiff(EditionEntity edition)
        {
            var startDateDiff = GetStartDateDifferencesByPreviousEdition(edition);

            edition.StartWeekOfYearDiff = startDateDiff[0];
            edition.StartDayOfYearDiff  = startDateDiff[1];
        }
        public static EditionEditImagesModel ComposeEditionEditImagesModel(
            CedUser currentUser,
            EditionEntity edition,
            EditionTranslationEntity editionTranslation,
            bool isEditableForImages)
        {
            var model = new EditionEditImagesModel
            {
                EditionTranslationId = editionTranslation.EditionTranslationId,
                EditionId            = edition.EditionId,
                EditionName          = edition.EditionName,
                ProductImageFileName = editionTranslation.ProductImageFileName,
                MasterLogoFileName   = editionTranslation.MasterLogoFileName,
                CrmLogoFileName      = editionTranslation.CrmLogoFileName,
                IconFileName         = editionTranslation.IconFileName,
                PromotedLogoFileName = editionTranslation.PromotedLogoFileName,
                DetailsImageFileName = editionTranslation.DetailsImageFileName,
                LanguageCode         = editionTranslation.LanguageCode,
                IsAlive             = edition.IsAlive(),
                IsCancelled         = edition.IsCancelled(),
                IsEditableForImages = isEditableForImages,
                CurrentUser         = currentUser
            };

            return(model);
        }
        public string GetEditionName(EditionEntity edition, bool isHtml)
        {
            var name = isHtml
                ? "<b>" + edition.EditionName + "</b>"
                : edition.EditionName;

            return(name);
        }
Exemplo n.º 9
0
        private void UpdateApprovedEdition(Edition stagingEdition, EditionEntity approvedEdition)
        {
            approvedEdition.AxEventId = Convert.ToInt32(stagingEdition.EventBEID);
            approvedEdition.DwEventId = stagingEdition.DWEventID;
            approvedEdition.Status    = EditionStatusType.Published;

            EditionServices.UpdateEdition(approvedEdition.EditionId, approvedEdition, BusinessServices.Helpers.Constants.AutoIntegrationUserId, true);
        }
Exemplo n.º 10
0
        private LogEntity NotificationEmailSent(EditionEntity edition, NotificationType notificationType, DateTime notificationDate)
        {
            var logs = LogServices.GetLogsByEdition(edition.EditionId, EntityType.Email.ToString(), notificationType.ToString(), notificationDate);

            logs = ExtractSentNotificationEmailLogs(logs);

            return(logs.Any() ? logs.OrderByDescending(x => x.CreatedOn).First() : null);
        }
        public static string GetUpdatedContent(EditionEntity current, EditionEntity updated)
        {
            var diff = current.Compare(updated);

            diff = PrepareDiff(diff);
            var updateInfo     = new HtmlUpdateInfo("Edition", diff, true);
            var updatedContent = updateInfo.ComposeContent();

            return(updatedContent);
        }
        protected void CreateInAppNotification(EditionEntity edition, NotificationType notificationType, string recipients, string actorUserEmail)
        {
            var notifications = InAppNotificationHelper.CreateInAppNotifications(edition, notificationType, recipients, actorUserEmail);

            if (notifications == null)
            {
                return;
            }

            NotificationServices.CreateNotifications(notifications, 0);
        }
        protected void UpdateLogInMemory(EditionEntity currentEdition, EditionEntity edition, EditionTranslationEntity currentEditionTranslation, EditionTranslationEntity editionTranslation)
        {
            var updatedFields = LogControllerHelper.GetUpdatedFields(currentEdition, edition, currentEditionTranslation, editionTranslation, UpdateDisplayType.Json);

            if (string.IsNullOrWhiteSpace(updatedFields))
            {
                return;
            }

            UpdateLogInMemory(edition, updatedFields);
        }
Exemplo n.º 14
0
 private void StartNotificationProcessForEditionLocationUpdate(EditionEntity edition, EditionTranslationEntity editionTranslation, List <Variance> diffOnEdition)
 {
     if (IsLocationChanged(diffOnEdition))
     {
         if (WebConfigHelper.TrackEditionLocationUpdate)
         {
             var emailTemplate = GetEmailTemplateForEditionUpdateNotification(edition);
             SendNotificationEmailForEditionLocationUpdate(edition, editionTranslation, emailTemplate);
         }
     }
 }
Exemplo n.º 15
0
        public string GetDescription(EditionEntity edition, NotificationType notificationType)
        {
            var url = notificationType == NotificationType.EditionExistence
                ? _editionHelper.GetEditionListUrl(edition.Event, notificationType.GetAttribute <NotificationAttribute>().Fragment)
                : _editionHelper.GetEditionUrl(edition, notificationType.GetAttribute <NotificationAttribute>().Fragment);
            var name = _editionHelper.GetNameWithEditionNo(edition);
            var link = $"<a href=\"{url}\" target=\"_blank\"><b>{name}</b></a>";
            var desc = notificationType.GetDescription();

            return(string.Format(desc, link));
        }
        public string GetTitle(EditionEntity edition, NotificationType notificationType, bool isHtml)
        {
            var description    = notificationType.GetDescription();
            var name           = GetEditionName(edition, isHtml);
            var nameWithNumber = _editionHelper.GetNameWithEditionNo(edition.EditionNo, edition.EditionName);

            var title = edition.EditionNo > 0
                ? string.Format(description, nameWithNumber)
                : string.Format(description, name);

            return(title);
        }
        public string GetEditionUrl(EditionEntity edition, string fragment = null)
        {
            // For integration testing purposes
            if (HttpContext.Current == null || HttpContext.Current.Request.RequestContext == null)
            {
                return("");
            }

            var requestContext = HttpContext.Current.Request.RequestContext;
            var urlHelper      = new UrlHelper(requestContext);

            return(GetEditionUrl(urlHelper, edition, fragment));
        }
        /* 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 = ""
            });
        }
Exemplo n.º 19
0
        public static bool IsEditable(this EditionEntity edition, CedUser user)
        {
            if (!Constants.ValidEventActivitiesToEdit.Select(x => x.ToLower()).ToArray().Contains(edition.EventActivity.ToLower()))
            {
                return(false);
            }

            if (!Constants.ValidEditionStatusesToEdit.Contains(edition.Status.GetHashCode()))
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 20
0
 public static void UpdateLogInMemory(LogEntity log, EditionEntity edition, string updatedFields = null)
 {
     if (log != null)
     {
         if (log.EntityId == null || log.EntityId == 0)
         {
             log.EntityId   = edition.EditionId;
             log.EntityName = edition.EditionName;
             log.EventId    = edition.EventId;
             log.EventName  = edition.Event.MasterName;
         }
         log.AdditionalInfo = updatedFields != null ? "{" + updatedFields + "}" : null;
     }
 }
Exemplo n.º 21
0
        // Current: 2017
        // Next: 2018
        // StartDate'i değişmiş bir edition'dan sonraki edition'ın StartDateDiff değerlerini güncelle.
        public void UpdateNextEditionStartDateDiff(EditionEntity edition)
        {
            // UPDATE FOR NEXT EDITION
            var nextEdition = _editionServices.GetNextEdition(edition, Utility.Constants.ValidEventTypesForCed);

            if (nextEdition != null)
            {
                var startDateDiffsByNextEdition = GetNextEditionStartDateDifferences(edition);

                nextEdition.StartWeekOfYearDiff = startDateDiffsByNextEdition[0];
                nextEdition.StartDayOfYearDiff  = startDateDiffsByNextEdition[1];
                _editionServices.UpdateEdition(nextEdition.EditionId, nextEdition, Helpers.Constants.AutoIntegrationUserId, true);
            }
        }
        public static void ResetEdition(EditionEntity targetEdition)
        {
            targetEdition.Status           = EditionStatusType.PreDraft;
            targetEdition.StatusUpdateTime = DateTime.Now;

            targetEdition.EditionId = 0;
            targetEdition.Event     = null;

            targetEdition.UpdateTime = null;
            targetEdition.UpdateUser = 0;

            targetEdition.EditionNo = 0;
            targetEdition.StartDate = null;
            targetEdition.EndDate   = null;
            //targetEdition.LocalSqmSold = 0;
            //targetEdition.InternationalSqmSold = 0;
            targetEdition.SqmSold      = 0;
            targetEdition.SponsorCount = 0;

            //targetEdition.LocalExhibitorCount = 0;
            //targetEdition.InternationalExhibitorCount = 0;
            targetEdition.ExhibitorCount        = 0;
            targetEdition.ExhibitorCountryCount = 0;
            targetEdition.NationalGroupCount    = 0;

            targetEdition.InternationalVisitorCount = 0;
            targetEdition.VisitorCountryCount       = 0;
            targetEdition.LocalVisitorCount         = 0;

            targetEdition.NPSAverageExhibitor      = 0;
            targetEdition.NPSAverageVisitor        = 0;
            targetEdition.NPSSatisfactionExhibitor = 0;
            targetEdition.NPSSatisfactionVisitor   = 0;
            targetEdition.NPSScoreExhibitor        = 0;
            targetEdition.NPSScoreVisitor          = 0;
            targetEdition.NetEasyScoreVisitor      = 0;
            targetEdition.NetEasyScoreExhibitor    = 0;

            targetEdition.OnlineRegistrationCount           = 0;
            targetEdition.OnlineRegisteredVisitorCount      = 0;
            targetEdition.OnlineRegisteredBuyerVisitorCount = 0;

            //targetEdition.InternationalExhibitorRetentionRate = 0;
            //targetEdition.LocalExhibitorRetentionRate = 0;
            targetEdition.ExhibitorRetentionRate = 0;

            targetEdition.NPSSatisfactionExhibitor = 0;
            targetEdition.NPSSatisfactionVisitor   = 0;
        }
        // TODO: Should be moved to a more appropriate class.
        public string GetRecipientFullName(EditionEntity edition)
        {
            string recipientFullName;

            switch (edition.Status)
            {
            case EditionStatusType.WaitingForApproval:
                recipientFullName = "";
                break;

            default:
                var eventDirectorFullName = GetEventDirectorFullName(edition) ?? "";
                recipientFullName = eventDirectorFullName;
                break;
            }
            return(recipientFullName);
        }
Exemplo n.º 24
0
        private EditionMailTemplate GetEmailTemplateForEditionCreation(EditionEntity edition)
        {
            var recipients        = WebConfigHelper.NewEventNotificationRecipients;
            var recipientFullName = "";
            var notificationAttr  = NotificationType.EditionCreated.GetAttribute <NotificationAttribute>();
            var buttonUrl         = _editionHelper.GetEditionUrl(edition, notificationAttr.Fragment);
            var unsubscriptionUrl = notificationAttr.Unsubscribable ? EmailNotificationHelper.GetUnsubscriptionUrl(edition) : string.Empty;
            var emailTemplate     = new EditionMailTemplate
            {
                Recipients        = recipients,
                RecipientFullName = recipientFullName,
                ButtonUrl         = buttonUrl,
                UnsubscriptionUrl = unsubscriptionUrl
            };

            return(emailTemplate);
        }
Exemplo n.º 25
0
        private EditionMailTemplate GetEmailTemplateForEditionUpdateNotification(EditionEntity edition)
        {
            var recipients        = _eventDirectorServices.GetRecipientEmails(edition);
            var recipientFullName = _editionHelper.GetEventDirectorFullName(edition);
            var notificationAttr  = NotificationType.EditionLocationUpdated.GetAttribute <NotificationAttribute>();
            var buttonUrl         = _editionHelper.GetEditionUrl(edition, notificationAttr.Fragment);
            var unsubscriptionUrl = notificationAttr.Unsubscribable ? EmailNotificationHelper.GetUnsubscriptionUrl(edition) : string.Empty;
            var emailTemplate     = new EditionMailTemplate
            {
                Recipients        = recipients,
                RecipientFullName = recipientFullName,
                ButtonUrl         = buttonUrl,
                UnsubscriptionUrl = unsubscriptionUrl
            };

            return(emailTemplate);
        }
Exemplo n.º 26
0
        private void StartNotificationProcessForEditionNameUpdate(EditionEntity edition, EditionTranslationEntity editionTranslation, List <Variance> diffOnEdition)
        {
            if (IsEditionNameChanged(diffOnEdition))
            {
                if (WebConfigHelper.TrackEditionNameUpdate)
                {
                    var emailTemplate = GetEmailTemplateForEditionUpdateNotification(edition);

                    var recipients = WebConfigHelper.PrimaryDirectorNotificationsUseMockRecipients
                            ? WebConfigHelper.AdminEmails
                            : _eventDirectorServices.GetRecipientEmails(edition);

                    emailTemplate.Recipients = recipients;

                    SendNotificationEmailForEditionNameUpdate(edition, editionTranslation, emailTemplate);
                }
            }
        }
        public string GetRecipientEmails(EditionEntity edition)
        {
            var assistantDirectors = GetAssistantDirectors(edition.EventId, WebConfigHelper.ApplicationIdCed);

            var allDirectors = new List <EventDirectorEntity>();

            var primaryDirectors = GetPrimaryDirectors(edition.EventId, WebConfigHelper.ApplicationIdCed);

            allDirectors.AddRange(primaryDirectors);

            allDirectors.AddRange(assistantDirectors);

            var recipientEmails = allDirectors.Any()
                ? string.Join(",", allDirectors.Select(x => x.DirectorEmail.ToLower()).ToList())
                : null;

            return(recipientEmails);
        }
Exemplo n.º 28
0
        private List <int?> GetNextEditionStartDateDifferences(EditionEntity edition)
        {
            var nextEdition = _editionServices.GetNextEdition(edition, Utility.Constants.ValidEventTypesForCed);

            if (nextEdition == null)
            {
                return new List <int?> {
                           null, null
                }
            }
            ;
            var weekDiff = edition.StartDate.GetValueOrDefault().WeekOfYearDiff(nextEdition.StartDate.GetValueOrDefault());
            var dayDiff  = edition.StartDate.GetValueOrDefault().DayOfYearDiff(nextEdition.StartDate.GetValueOrDefault());

            return(new List <int?> {
                weekDiff, dayDiff
            });
        }
Exemplo n.º 29
0
        public static bool ImagesEditable(this EditionEntity edition, CedUser user)
        {
            if (user.IsViewer)
            {
                return(false);
            }

            if (user.IsAdmin || user.IsSuperAdmin)
            {
                return(true);
            }

            if (edition.EventActivity == EventActivity.ShowCancelled.GetDescription())
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 30
0
        private EmailResult SendNotificationEmailForEditionLocationUpdate(EditionEntity edition, EditionTranslationEntity editionTranslation, EditionMailTemplate emailTemplate)
        {
            if (!WebConfigHelper.TrackEditionLocationUpdate)
            {
                return new EmailResult {
                           Sent = false, ErrorMessage = "Tracking disabled."
                }
            }
            ;

            // IF EDITION START DATE IS LATER THAN NOW
            if (edition.HasNotStartedYet() && edition.HasCityOrCountry())
            {
                // SEND NOTIFICATION EMAIL
                var recipients = emailTemplate.Recipients;

                if (!string.IsNullOrWhiteSpace(recipients))
                {
                    const NotificationType notificationType = NotificationType.EditionLocationUpdated;

                    var recipientFullName = emailTemplate.RecipientFullName;
                    var body = $"Dear {recipientFullName} ," +
                               "<br/><br/>" +
                               $"This is to inform you that there have been some changes to the city and/or country information for {edition.EditionName}." +
                               @"<br/><br/>
                    You may want to log in and double check whether this information affects the address / map location of the existing Venue location information.
                    <br/><br/>
                    To do so please click the button below to go to event edition's page and make the changes in Event Venue section of General Info tab shown below if needed.
                    <br/><br/>" +
                               $"<img src='{AzureStorageHelper.AzureStorageContainerUri}event-venue-map.png' />";

                    var buttonUrl = _editionHelper.GetEditionUrl(edition);

                    return(_emailNotificationHelper.Send(edition, editionTranslation, notificationType, recipientFullName, body, recipients,
                                                         buttonUrl, emailTemplate.UnsubscriptionUrl));
                }
            }

            return(new EmailResult {
                Sent = false, ErrorMessage = "Event doesn't fit the necessary criteria for emailing."
            });
        }