コード例 #1
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);
        }
コード例 #2
0
        private int SetEditionCohostedEventStatus(int editionId)
        {
            var cohosts = EditionCoHostServices.GetEditionCohosts(editionId);

            if (!cohosts.Any() || cohosts.Count == 1)
            {
                var edition        = EditionServices.GetEditionById(editionId);
                var currentEdition = (EditionEntity)edition.Clone();

                edition.CohostedEvent = cohosts.Any();
                EditionServices.UpdateEdition(editionId, edition, CurrentCedUser.CurrentUser.UserId);

                UpdateLogInMemory(currentEdition, edition, null, null);
            }

            return(cohosts.Count);
        }
コード例 #3
0
        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();
            }
        }