diff --git a/Bootstrap.Admin/Content/css/tasks.css b/Bootstrap.Admin/Content/css/tasks.css index 3b8d0edb..1786d032 100644 --- a/Bootstrap.Admin/Content/css/tasks.css +++ b/Bootstrap.Admin/Content/css/tasks.css @@ -53,27 +53,21 @@ height: 46px; } - .tasks-widget .task-list li > .task-title .task-wrapper { + .tasks-widget .task-list li > .task-title .task-value { position: absolute; left: 190px; right: 40px; - top: 16px; + top: 17px; display: inline-block; - padding-left: 16px; } - .tasks-widget .task-list li > .task-title .task-wrapper.notifi { - right: 70px; - left: 90px; - } - - .tasks-widget .task-list li > .task-title .task-wrapper span { - display: inline-block; - white-space: nowrap; - overflow: hidden; - text-overflow: ellipsis; - max-width: 100%; - } + .tasks-widget .task-list li > .task-title span { + display: inline-block; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + max-width: 100%; + } .tasks-widget .task-list li > .task-title .badge { position: relative; @@ -101,13 +95,26 @@ right: 10px; } + .tasks-widget .task-list li .task-title.notifi .task-title-sp { + max-width: 80px; + } + + .tasks-widget .task-list li .task-title.notifi .task-value { + left: 120px; + right: 190px; + } + + .tasks-widget .task-list li .task-title.notifi .task-time { + position: absolute; + right: 66px; + top: 17px; + display: inline-block; + color: #3c763d; + } + .tasks-widget .task-list li .task-title .task-title-sp { margin-right: 5px; max-width: 170px; - overflow: hidden; - white-space: nowrap; - text-overflow: ellipsis; - display: inline-block; padding-top: 17px; } @@ -182,6 +189,16 @@ border-left: 3px solid #BEC3C7; } +@media (max-width: 548px) { + .tasks-widget .task-list li .task-title.notifi .task-value { + right: 66px; + } + + .tasks-widget .task-list li .task-title.notifi .task-time { + display: none; + } +} + @media only screen and (max-width: 320px) { .tasks-widget .task-config-btn { diff --git a/Bootstrap.Admin/Models/HeaderBarModel.cs b/Bootstrap.Admin/Models/HeaderBarModel.cs index 87e478df..99f582a1 100644 --- a/Bootstrap.Admin/Models/HeaderBarModel.cs +++ b/Bootstrap.Admin/Models/HeaderBarModel.cs @@ -17,7 +17,7 @@ namespace Bootstrap.Admin.Models UserID = user.ID; HomeUrl = "~/"; Menus = MenuHelper.RetrieveLinksByUserName(UserName); - Notifications = NotificationHelper.RetrieveUser(); + Notifications = NotificationHelper.RetrieveNotifications(); } public string UserName { get; protected set; } /// @@ -43,6 +43,6 @@ namespace Bootstrap.Admin.Models /// /// /// - public IEnumerable Notifications { get; set; } + public IEnumerable Notifications { get; set; } } } \ No newline at end of file diff --git a/Bootstrap.Admin/Scripts/Profiles.js b/Bootstrap.Admin/Scripts/Profiles.js index efbdbc74..96df0826 100644 --- a/Bootstrap.Admin/Scripts/Profiles.js +++ b/Bootstrap.Admin/Scripts/Profiles.js @@ -33,7 +33,7 @@ } }); - var html = '
  • {2}{0}
    {3}
  • '; + var html = '
  • {2}{0}{3}
  • '; function listCache(options) { $.ajax({ diff --git a/Bootstrap.Admin/Views/Admin/Notifications.cshtml b/Bootstrap.Admin/Views/Admin/Notifications.cshtml index 7fd18687..62b98bc7 100644 --- a/Bootstrap.Admin/Views/Admin/Notifications.cshtml +++ b/Bootstrap.Admin/Views/Admin/Notifications.cshtml @@ -20,16 +20,15 @@
    用户注册
    -
      - @foreach (var u in Model.Notifications) +
        + @foreach (var noti in Model.Notifications.Where(n => n.Category == "0")) {
      • -
        - @u.DisplayName -
        - @u.Description -
        +
        + @noti.Title + @noti.Content + @noti.RegisterTime.ToString("yyyy-MM-dd HH:mm:ss")
        @@ -45,16 +44,15 @@
        程序错误
        -
          - @foreach (var nofi in Model.Notifications) +
            + @foreach (var nofi in Model.Notifications.Where(n => n.Category == "1")) {
          • -
            - @nofi.DisplayName -
            - @nofi.Description -
            +
            + @nofi.Title + @nofi.Content + @nofi.RegisterTime.ToString("yyyy-MM-dd HH:mm:ss")
            @@ -70,16 +68,15 @@
            数据库报警
            -
              - @foreach (var nofi in Model.Notifications) +
                + @foreach (var nofi in Model.Notifications.Where(n => n.Category == "2")) {
              • -
                - @nofi.DisplayName -
                - @nofi.Description -
                +
                + @nofi.Title + @nofi.RegisterTime.ToString("yyyy-MM-dd HH:mm:ss") + @nofi.Content
                diff --git a/Bootstrap.Admin/Views/Shared/Header.cshtml b/Bootstrap.Admin/Views/Shared/Header.cshtml index a13f540c..345b23a9 100644 --- a/Bootstrap.Admin/Views/Shared/Header.cshtml +++ b/Bootstrap.Admin/Views/Shared/Header.cshtml @@ -177,11 +177,22 @@
              • 您有 @Model.Notifications.Count() 条新通知

              • - @foreach (var u in Model.Notifications.Take(6)) + @foreach (var noti in Model.Notifications.Take(6)) {
              • - -
                @u.DisplayName
                @u.Period +
                + @if (noti.Category == "0") + { +
                @noti.Content
                @noti.Period + } + else if (noti.Category == "1") + { +
                @noti.Content
                @noti.Period + } + else + { +
                @noti.Content
                @noti.Period + }
              • } diff --git a/Bootstrap.Admin/Web.config b/Bootstrap.Admin/Web.config index a7ff5fde..51bb6954 100644 --- a/Bootstrap.Admin/Web.config +++ b/Bootstrap.Admin/Web.config @@ -43,7 +43,7 @@ - + diff --git a/Bootstrap.DataAccess/CacheCleanUtility.cs b/Bootstrap.DataAccess/CacheCleanUtility.cs index 4cd9aa6b..0cc9e8d7 100644 --- a/Bootstrap.DataAccess/CacheCleanUtility.cs +++ b/Bootstrap.DataAccess/CacheCleanUtility.cs @@ -40,6 +40,7 @@ namespace Bootstrap.DataAccess cacheKeys.Add(string.Format("{0}-{1}", GroupHelper.RetrieveGroupsByUserIDDataKey, id)); cacheKeys.Add(MenuHelper.RetrieveMenusDataKey); }); + cacheKeys.Add(UserHelper.RetrieveNewUsersDataKey); // final cleanup CacheManager.Clear(key => cacheKeys.Any(k => k == key) || key.Contains(UserHelper.RetrieveUsersDataKey) || key.Contains(RoleHelper.RetrieveRolesByUserNameDataKey)); cacheKeys.Clear(); @@ -80,7 +81,7 @@ namespace Bootstrap.DataAccess if (notifyIds != null) { // final cleanup - CacheManager.Clear(key => key.Contains(NotificationHelper.RetrieveNotifyDataKey)); + CacheManager.Clear(key => key.Contains(NotificationHelper.RetrieveNotificationsDataKey)); cacheKeys.Clear(); } } diff --git a/Bootstrap.DataAccess/NotificationHelper.cs b/Bootstrap.DataAccess/NotificationHelper.cs index be11fad5..fd5198ed 100644 --- a/Bootstrap.DataAccess/NotificationHelper.cs +++ b/Bootstrap.DataAccess/NotificationHelper.cs @@ -12,31 +12,8 @@ namespace Bootstrap.DataAccess { public class NotificationHelper { - internal const string RetrieveNotifyDataKey = "NotificationHelper-RetrieveNotifications"; - - /// - /// 查询新注册用户 - /// - /// - public static IEnumerable RetrieveUser() - { - var ret = UserHelper.RetrieveUsersForNotify(); - if (ret != null) - { - ret.AsParallel().ForAll(n => - { - var ts = DateTime.Now - n.RegisterTime; - if (ts.TotalMinutes < 5) n.Period = "刚刚"; - else if (ts.Days > 0) n.Period = string.Format("{0}天", ts.Days); - else if (ts.Hours > 0) n.Period = string.Format("{0}小时", ts.Hours); - else if (ts.Minutes > 0) n.Period = string.Format("{0}分钟", ts.Minutes); - }); - return ret; - } - List users = new List(); - return users; - } - + // UNDOEN: 此处需要继续完善,增强异常的通知管理 + internal const string RetrieveNotificationsDataKey = "NotificationHelper-RetrieveNotifications"; /// /// 新用户注册的通知的面板显示 /// @@ -44,7 +21,7 @@ namespace Bootstrap.DataAccess /// public static IEnumerable RetrieveNotifications() { - var ret = CacheManager.GetOrAdd(RetrieveNotifyDataKey, CacheSection.RetrieveIntervalByKey(RetrieveNotifyDataKey), key => + var notifies = CacheManager.GetOrAdd(RetrieveNotificationsDataKey, CacheSection.RetrieveIntervalByKey(RetrieveNotificationsDataKey), key => { string sql = "select * from Notifications"; List notifications = new List(); @@ -73,7 +50,9 @@ namespace Bootstrap.DataAccess catch (Exception ex) { ExceptionManager.Publish(ex); } return notifications; - }, CacheSection.RetrieveDescByKey(RetrieveNotifyDataKey)); + }, CacheSection.RetrieveDescByKey(RetrieveNotificationsDataKey)); + var users = UserHelper.RetrieveNewUsers().Select(u => new Notification() { ID = u.ID, Category = "0", Content = u.Description, Title = u.DisplayName, RegisterTime = u.RegisterTime }).ToList(); + var ret = users.Union(notifies); ret.AsParallel().ForAll(n => { var ts = DateTime.Now - n.RegisterTime; @@ -82,7 +61,7 @@ namespace Bootstrap.DataAccess else if (ts.Hours > 0) n.Period = string.Format("{0}小时", ts.Hours); else if (ts.Minutes > 0) n.Period = string.Format("{0}分钟", ts.Minutes); }); - return ret; + return ret.OrderByDescending(n => n.RegisterTime); } /// diff --git a/Bootstrap.DataAccess/UserHelper.cs b/Bootstrap.DataAccess/UserHelper.cs index 2753ddf1..6abc3ace 100644 --- a/Bootstrap.DataAccess/UserHelper.cs +++ b/Bootstrap.DataAccess/UserHelper.cs @@ -23,7 +23,7 @@ namespace Bootstrap.DataAccess private const string RetrieveUsersByNameDataKey = "UserHelper-RetrieveUsersByName"; internal const string RetrieveUsersByRoleIDDataKey = "UserHelper-RetrieveUsersByRoleId"; internal const string RetrieveUsersByGroupIDDataKey = "UserHelper-RetrieveUsersByGroupId"; - internal const string RetrieveUsersForNotifyDataKey = "UserHelper-RetrieveUsersForNotify"; + internal const string RetrieveNewUsersDataKey = "UserHelper-RetrieveNewUsers"; /// /// 查询所有用户 /// @@ -100,11 +100,11 @@ namespace Bootstrap.DataAccess /// 查询所有的新注册用户 /// /// - public static IEnumerable RetrieveUsersForNotify() + public static IEnumerable RetrieveNewUsers() { - string sql = "select ID, UserName, DisplayName, RegisterTime, [Description] from Users Where ApprovedTime is null"; - var ret = CacheManager.GetOrAdd(RetrieveUsersForNotifyDataKey, CacheSection.RetrieveIntervalByKey(RetrieveUsersForNotifyDataKey), key => + var ret = CacheManager.GetOrAdd(RetrieveNewUsersDataKey, CacheSection.RetrieveIntervalByKey(RetrieveNewUsersDataKey), key => { + string sql = "select ID, UserName, DisplayName, RegisterTime, [Description] from Users Where ApprovedTime is null"; List Users = new List(); DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql); try @@ -126,7 +126,7 @@ namespace Bootstrap.DataAccess } catch (Exception ex) { ExceptionManager.Publish(ex); } return Users; - }, CacheSection.RetrieveDescByKey(RetrieveUsersForNotifyDataKey)); + }, CacheSection.RetrieveDescByKey(RetrieveNewUsersDataKey)); return ret; }