示例#1
0
        public async Task <IHttpActionResult> PostSystemNotificationAsync([NakedBody] string message)
        {
            if (String.IsNullOrWhiteSpace(message))
            {
                return(NotFound());
            }

            var notification = new SystemNotification {
                Date = SystemClock.UtcNow, Message = message
            };
            await _cacheClient.SetAsync("system-notification", notification);

            await _messagePublisher.PublishAsync(notification);

            return(Ok(notification));
        }
        public async Task <ActionResult <SystemNotification> > PostSystemNotificationAsync(ValueFromBody <string> message)
        {
            if (String.IsNullOrWhiteSpace(message?.Value))
            {
                return(NotFound());
            }

            var notification = new SystemNotification {
                Date = SystemClock.UtcNow, Message = message.Value
            };
            await _cacheClient.SetAsync("system-notification", notification);

            await _messagePublisher.PublishAsync(notification);

            return(Ok(notification));
        }
 public bool Update(SystemNotification entity)
 {
     try
     {
         var model = db.SystemNotification.Find(entity.ID);
         model.Pattern      = entity.Pattern;
         model.Content      = entity.Content;
         model.EmailTitle   = entity.EmailTitle;
         model.EmailContent = entity.EmailContent;
         db.SaveChanges();
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
        public async Task <ActionResult <SystemNotification> > PostSystemNotificationAsync(object body)
        {
            string message = body as string;

            if (String.IsNullOrWhiteSpace(message))
            {
                return(NotFound());
            }

            var notification = new SystemNotification {
                Date = SystemClock.UtcNow, Message = message
            };
            await _cacheClient.SetAsync("system-notification", notification);

            await _messagePublisher.PublishAsync(notification);

            return(Ok(notification));
        }
 public void CreateNewSystemNotification(SystemNotification notification)
 {
     connection.Execute(
         @"SET IDENTITY_INSERT dbo.SANotifications ON
             INSERT INTO SANotifications (SANotificationID, SubjectLine, BodyHtml, ExpiryDate, DateAdded, TargetUserRoleID)
             VALUES (@systemNotificationId, @subjectLine, @bodyHtml, @expiryDate, @dateAdded, @targetUserRoleId)
             SET IDENTITY_INSERT dbo.SANotifications OFF",
         new
     {
         notification.SystemNotificationId,
         notification.SubjectLine,
         notification.BodyHtml,
         notification.ExpiryDate,
         notification.DateAdded,
         notification.TargetUserRoleId
     }
         );
 }
        public static void SendChangePasswordMail(string email, string username, string domain, string vcode)
        {
            if (!email.IsValidEmail())
            {
                throw new ArgumentException("无效的Email地址'{0}'".FormatInvariantCulture(email));
            }
            var parameters = new Dictionary <string, string>();

            parameters.Add(ConstantsManager.UserNameParamName, username);
            parameters.Add(ConstantsManager.DomainParamName, domain);
            parameters.Add(ConstantsManager.VCodeParamName, vcode);
            var emailNotification = new SystemNotification(ConstantsManager.ChangePasswordEmailContentName, ConstantsManager.EmailContentXmlPath, parameters)
            {
                To = new string[] { email }
            };

            emailNotification.SendNotification(false);
        }
        public JsonResult Update(string entity)
        {
            GetViewBag_Session();
            var dao = new SystemNotificationDAO();
            JavaScriptSerializer js    = new JavaScriptSerializer();
            SystemNotification   model = js.Deserialize <SystemNotification>(entity);
            var result = new SystemNotificationDAO().Update(model);

            // Written log
            var logEntity = new Log_Admin();

            logEntity.createBy    = ViewBag.Name_Session;
            logEntity.time        = DateTime.Now;
            logEntity.action      = "Cập nhật nội dung thông báo" + "<a href = \"/Admin/Notification\">Xem chi tiết</a>";
            logEntity.description = ViewBag.Name_Session + " cập nhật nội dung thông báo trong hệ thống";
            var wlog = new Log_AdminDAO().InsertLog(logEntity);

            return(Json(new
            {
                status = result
            }));
        }
        public async Task <bool> Transaction(SystemNotification data, char action)
        {
            var val = await _adapterPattern.SingleTransaction <SystemNotification, bool>(data, "usp_SystemNotification_Transaction", action, DataConfiguration.instanceCore);

            return(val);
        }
示例#9
0
        public void GetUnacknowledgedSystemNotifications_returns_correct_notifications()
        {
            // Given
            const int adminId     = 5;
            var       currentTime = DateTime.UtcNow.Date;
            var       neverExpiresNotification = new SystemNotification(
                100,
                "Never expires test",
                "body",
                null,
                currentTime,
                1
                );
            var expiredYesterdayNotification = new SystemNotification(
                102,
                "Expired yesterday test",
                "body",
                currentTime.AddDays(-1),
                currentTime,
                1
                );
            var expiresTomorrowNotification = new SystemNotification(
                103,
                "Expires tomorrow test",
                "body",
                currentTime.AddDays(1),
                currentTime,
                1
                );
            var alreadyAcknowledgedNotification = new SystemNotification(
                104,
                "Already acknowledged test",
                "body",
                null,
                currentTime,
                1
                );

            using var transaction = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled);
            try
            {
                systemNotificationTestHelper.CreateNewSystemNotification(neverExpiresNotification);
                systemNotificationTestHelper.CreateNewSystemNotification(expiredYesterdayNotification);
                systemNotificationTestHelper.CreateNewSystemNotification(expiresTomorrowNotification);
                systemNotificationTestHelper.CreateNewSystemNotification(alreadyAcknowledgedNotification);
                systemNotificationsDataService.AcknowledgeNotification(104, adminId);

                // When
                var systemNotificationsToShow =
                    systemNotificationsDataService.GetUnacknowledgedSystemNotifications(adminId).ToList();

                // Then
                using (new AssertionScope())
                {
                    systemNotificationsToShow.Should().HaveCount(2);
                    systemNotificationsToShow.Should().ContainEquivalentOf(neverExpiresNotification);
                    systemNotificationsToShow.Should().ContainEquivalentOf(expiresTomorrowNotification);
                }
            }
            finally
            {
                transaction.Dispose();
            }
        }
示例#10
0
 private Task OnSystemNotificationAsync(SystemNotification notification, CancellationToken cancellationToken = default)
 {
     _logger.LogTrace("Sending system notification message: {Message}", notification.Message);
     return(TypedBroadcastAsync(notification));
 }
示例#11
0
 private Task OnSystemNotificationAsync(SystemNotification notification, CancellationToken cancellationToken = default(CancellationToken))
 {
     _logger.Trace(() => $"Sending system notification message: {notification.Message})");
     return(Context.Connection.TypedBroadcastAsync(notification));
 }
示例#12
0
 private Task OnSystemNotificationAsync(SystemNotification notification, CancellationToken cancellationToken = default(CancellationToken))
 {
     return(Context.Connection.TypedBroadcastAsync(notification));
 }
示例#13
0
 private void OnSystemNotification(SystemNotification notification)
 {
     try {
         Clients.All.systemNotification(notification);
     } catch (NullReferenceException) {} // TODO: Remove this when SignalR bug is fixed.
 }
 public Task <bool> Transaction(SystemNotification data, char action)
 {
     return(_iSystemNotification.Transaction(data, action));
 }
示例#15
0
 public GameProcessService(IGameService gameService, IAuthService authService, DataContext context, SystemNotification systemNotification, IOptions <RoundConfig> roundOptions)
 {
     this.gameService        = gameService;
     this.authService        = authService;
     this.context            = context;
     this.systemNotification = systemNotification;
     this.roundOptions       = roundOptions;
 }