protected override void Context()
 {
     _settingsToUse = NotificationType.Error | NotificationType.Info;
     base.Context();
     _visibleNotification = new NotificationMessageDTO(new NotificationMessage(A.Fake <IObjectBase>(), MessageOrigin.Simulation, A.Fake <IBuildingBlock>(), NotificationType.Error));
     _hiddenNotification  = new NotificationMessageDTO(new NotificationMessage(A.Fake <IObjectBase>(), MessageOrigin.Simulation, A.Fake <IBuildingBlock>(), NotificationType.Warning));;
 }
Esempio n. 2
0
        public void should_return_true_if_the_presenter_is_a_notification_presenter_and_the_object_is_a_notification_item_dto()
        {
            var notificationItemDTO  = new NotificationMessageDTO(A.Fake <NotificationMessage>());
            var notifcationPresenter = A.Fake <INotificationPresenter>();

            sut.IsSatisfiedBy(notificationItemDTO, notifcationPresenter).ShouldBeTrue();
        }
Esempio n. 3
0
        public bool SaveEmailNotificationRecord(NotificationMessageDTO token)
        {
            try
            {
                var html = NotificationDto2Html(token);

                if (String.IsNullOrEmpty(html))
                {
                    return(false);
                }

                var entity = token.NotificationDto2EmailMessage(FROM, DISCUSSION_SUBJECT, html);

                EmailMessageRepository.Add(entity);

                EmailMessageRepository.UnitOfWork.CommitAndRefreshChanges();

                return(true);
            }
            catch (Exception ex)
            {
                Logger.Error("Save email record", token.UserId, ex, CommonEnums.LoggerObjectTypes.Email);
                return(false);
            }
        }
Esempio n. 4
0
        public void should_return_false_otherwise()
        {
            var notificationItemDTO  = new NotificationMessageDTO(A.Fake <NotificationMessage>());
            var notifcationPresenter = A.Fake <INotificationPresenter>();

            sut.IsSatisfiedBy(A.Fake <IViewItem>(), notifcationPresenter).ShouldBeFalse();
            sut.IsSatisfiedBy(notificationItemDTO, A.Fake <IPresenterWithContextMenu <IViewItem> >()).ShouldBeFalse();
        }
Esempio n. 5
0
 public void NotifyUser(NotificationMessageDTO notificationMessage, string userId)
 {
     if (!string.IsNullOrWhiteSpace(userId))
     {
         var pusherChannel = BuildChannelName(userId);
         _pusher?.Trigger(pusherChannel, notificationMessage.NotificationType.ToString(), notificationMessage);
     }
 }
 protected override void Context()
 {
     base.Context();
     _obectBase     = A.Fake <IObjectBase>();
     _buildingBlock = A.Fake <IBuildingBlock>();
     A.CallTo(() => _context.HistoryManager).Returns(A.Fake <IMoBiHistoryManager>());
     _notificationMessage = new NotificationMessageDTO(new NotificationMessage(_obectBase, MessageOrigin.Simulation, _buildingBlock, NotificationType.Error));
 }
Esempio n. 7
0
 public static EMAIL_Messages NotificationDto2EmailMessage(this NotificationMessageDTO token, string from, string subject, string htmlBody)
 {
     return(new EMAIL_Messages
     {
         MessageFrom = from
         , UserId = token.UserId
         , NotificationId = token.NotificationId
         , Subject = subject
         , ToEmail = token.Email
         , ToName = token.FullName
         , AddOn = DateTime.Now
         , MessageBoby = htmlBody
         , Status = EmailEnums.eSendInterfaceStatus.Waiting.ToString()
     });
 }
        public async Task PushUserNotification(ActivityTemplateDTO activityTemplate, string subject, string message)
        {
            var notificationMsg = new NotificationMessageDTO
            {
                NotificationType = NotificationType.TerminalEvent,
                Subject          = subject,
                Message          = message,
                ActivityName     = activityTemplate.Name,
                ActivityVersion  = activityTemplate.Version,
                TerminalName     = activityTemplate.Terminal.Name,
                TerminalVersion  = activityTemplate.Terminal.Version,
                Collapsed        = false
            };

            await _hubCommunicator.NotifyUser(notificationMsg);
        }
Esempio n. 9
0
        private string NotificationDto2Html(NotificationMessageDTO dto)
        {
            var html = GetTemplateHtml(EmailEnums.eTemplateKinds.USER_NOT);

            if (string.IsNullOrEmpty(html))
            {
                return(string.Empty);
            }

            html = html.Replace(EmailEnums.eTemplateFields.FULL_NAME.ToString().Field2Template(), dto.FullName.String2Html(null, NAME_HTML_STYLE, null))
                   .Replace(EmailEnums.eTemplateFields.POST_AUTHOR.ToString().Field2Template(), dto.PosterName.String2Html(USER_PROFILE_URL_TEMPLATE, NAME_HTML_STYLE_UNDERLINE, dto.PosterId))
                   .Replace(EmailEnums.eTemplateFields.POST_DATE.ToString().Field2Template(), dto.AddOn.DateFormat())
                   .Replace(EmailEnums.eTemplateFields.HTML_BODY.ToString().Field2Template(), dto.MessageHTML);

            return(html);
        }
Esempio n. 10
0
        public IHttpActionResult Post(NotificationMessageDTO notificationMessage)
        {
            string userId;

            if (IsThisTerminalCall())
            {
                var user = GetUserTerminalOperatesOn();
                userId = user?.Id;
            }
            else
            {
                userId = _security.GetCurrentUser();
            }

            // These notifications are evaulated as terminal event without exception
            notificationMessage.NotificationType = NotificationType.TerminalEvent;
            _pusherNotifier.NotifyUser(notificationMessage, userId);
            return(Ok());
        }
        public async Task <IHttpActionResult> RunMonitoring()
        {
            //We don't need to wait for the result as the purpose of this method is just to initiate a start (as a double-check measure)
            var currentUser = _securityServices.GetCurrentUser();

            _pusher.NotifyUser(new NotificationMessageDTO
            {
                NotificationType = NotificationType.GenericInfo,
                Subject          = "Manifest Registry Monitoring",
                Message          = "Preparing to launch manifest registry monitoring...",
                Collapsed        = false
            }, currentUser);
            var resultNotification = new NotificationMessageDTO
            {
                NotificationType = NotificationType.GenericSuccess,
                Subject          = "Manifest Registry Monitoring",
                Collapsed        = true
            };
            ManifestRegistryMonitorResult result;

            try
            {
                result = await _manifestRegistryMonitor.StartMonitoringManifestRegistrySubmissions();

                resultNotification.Message = result.IsNewPlan
                    ? $"New plan with Id {result.PlanId} was created and started to monitor manifest registry"
                    : $"An existing plan with Id {result.PlanId} was used to monitor manifest registry";
            }
            catch (Exception ex)
            {
                resultNotification.NotificationType = NotificationType.GenericFailure;
                resultNotification.Message          = $"Failed to manually start manifest registry monitoring. Reason - {ex.Message}. See incidents and error logs for more details";
                Logger.GetLogger().Error("Failed to manually start manifest registry monitoring", ex);
                throw;
            }
            finally
            {
                _pusher.NotifyUser(resultNotification, currentUser);
            }
            return(Ok());
        }
 public void NotifyUser(NotificationMessageDTO notificationMessage, string userId)
 {
     Notifications.Add(notificationMessage);
 }
 public Task NotifyUser(NotificationMessageDTO notificationMessage)
 {
     return(Task.FromResult(0));
 }
Esempio n. 14
0
 public ContextMenuForNotification(NotificationMessageDTO notificationMessage, INotificationPresenter presenter)
 {
     _notificationMessage = notificationMessage;
     _presenter           = presenter;
 }
Esempio n. 15
0
 public async Task NotifyUser(NotificationMessageDTO notificationMessage)
 {
     var hubUrl = $"{GetHubUrlWithApiVersion()}/notifications";
     var uri    = new Uri(hubUrl);
     await _restfulServiceClient.PostAsync(uri, notificationMessage);
 }
 protected override void Because()
 {
     _result = sut.MapFrom(_formula, _buildingBlock);
 }
 protected override void Because()
 {
     _result = sut.MapFrom(_validationMessage);
 }
 public Task NotifyUser(NotificationMessageDTO notificationMessage)
 {
     throw new NotImplementedException("Terminals can't communicate with an unknown hub");
 }