From 04f778b3220d25de1f64ff3e1216ed5cafeda04b Mon Sep 17 00:00:00 2001 From: Argo-Lenovo Date: Fri, 18 Nov 2016 10:18:41 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8B=86=E5=88=86=E9=80=9A=E7=9F=A5=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E5=8A=9F=E8=83=BD=EF=BC=8C=E9=A1=B5=E5=A4=B4=E5=88=86?= =?UTF-8?q?=E4=B8=BA5=E5=9D=97=E9=80=9A=E7=9F=A5=EF=BC=8C=E6=94=B9?= =?UTF-8?q?=E7=94=B1jQuery=E8=B0=83=E7=94=A8=EF=BC=8C=E5=87=8F=E5=B0=91?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E5=99=A8=E5=93=8D=E5=BA=94=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Bootstrap.Admin/Content/css/site.css | 2 +- Bootstrap.Admin/Content/js/common-scripts.js | 15 ++ Bootstrap.Admin/Content/js/framework.js | 45 ++-- .../Controllers/NotificationsController.cs | 84 ++++++-- .../Controllers/UsersController.cs | 10 +- Bootstrap.Admin/Models/HeaderBarModel.cs | 38 +--- Bootstrap.Admin/Scripts/noti.js | 71 +++---- .../Views/Admin/Notifications.cshtml | 6 +- Bootstrap.Admin/Views/Shared/Header.cshtml | 196 ++++++++---------- Bootstrap.DataAccess/ExceptionHelper.cs | 7 +- Bootstrap.DataAccess/Exceptions.cs | 61 ++++-- Bootstrap.DataAccess/NotificationHelper.cs | 33 ++- Bootstrap.DataAccess/UserHelper.cs | 3 +- DatabaseScripts/Install.sql | 1 + 14 files changed, 309 insertions(+), 263 deletions(-) diff --git a/Bootstrap.Admin/Content/css/site.css b/Bootstrap.Admin/Content/css/site.css index 25c01320..204930ab 100644 --- a/Bootstrap.Admin/Content/css/site.css +++ b/Bootstrap.Admin/Content/css/site.css @@ -441,7 +441,7 @@ padding-top: 2px; } - .notify-row .dropdown-menu.notification > li > a > div { + .notify-row .dropdown-menu.notification li a div { position: absolute; left: 36px; right: 44px; diff --git a/Bootstrap.Admin/Content/js/common-scripts.js b/Bootstrap.Admin/Content/js/common-scripts.js index 95649804..3992ff74 100644 --- a/Bootstrap.Admin/Content/js/common-scripts.js +++ b/Bootstrap.Admin/Content/js/common-scripts.js @@ -45,4 +45,19 @@ // custom scrollbar if (!$.browser.versions.ios) $("#sidebar").niceScroll({ styler: "fb", cursorcolor: "#e8403f", cursorwidth: '3', cursorborderradius: '10px', background: '#404040', spacebarenabled: false, cursorborder: '', scrollspeed: 60 }); + + // load widget data + Notifications.retrieveAllNotifies(function (result) { + $('#logoutNoti').text(result.NewUsersCount); + + // new users + $('#msgHeaderUser').text(result.NewUsersCount); + $('#msgHeaderUserBadge').text(result.NewUsersCount); + var htmlUserTemplate = '
  • {0}({1})
    {2}
  • '; + var html = result.Users.map(function (u) { + return $.format(htmlUserTemplate, u.UserName, u.DisplayName, u.Period); + }).join(''); + $(html).insertAfter($('#msgHeaderUserContent')); + console.log(result); + }); }); \ No newline at end of file diff --git a/Bootstrap.Admin/Content/js/framework.js b/Bootstrap.Admin/Content/js/framework.js index 76c7bb29..3c4e43b7 100644 --- a/Bootstrap.Admin/Content/js/framework.js +++ b/Bootstrap.Admin/Content/js/framework.js @@ -255,7 +255,7 @@ var htmlTemplate = '
    '; var processData = function (options) { - var data = $.extend({ data: { type: "" }, remote: true, method: "POST", Id: "", url: this.url, title: this.title, html: this.html, swal: true }, options); + var data = $.extend({ data: {}, remote: true, method: "POST", Id: "", url: this.url, title: this.title, html: this.html, swal: true }, options); if (data.remote) { $.ajax({ @@ -288,7 +288,7 @@ else { swal("失败", data.title, "error"); } } } - } + }; // Roles Role = { url: '../api/Roles/', @@ -310,10 +310,10 @@ }; Role.saveRolesByUserId = function (userId, roleIds, callback) { processData.call(this, { Id: userId, callback: callback, method: "PUT", data: { type: "user", roleIds: roleIds } }); - } + }; Role.saveRolesByGroupId = function (groupId, roleIds, callback) { processData.call(this, { Id: groupId, callback: callback, method: "PUT", data: { type: "group", roleIds: roleIds } }); - } + }; Role.saveRolesByMenuId = function (menuId, roleIds, callback) { processData.call(this, { Id: menuId, callback: callback, method: "PUT", data: { type: "menu", roleIds: roleIds } }); }; @@ -326,7 +326,7 @@ return $.format(htmlTemplate, element.ID, element.DisplayName, element.Checked, element.UserName); }).join(''); } - } + }; User.getUsersByRoleId = function (roleId, callback) { processData.call(this, { Id: roleId, callback: callback, data: { type: "role" } }); }; @@ -340,12 +340,14 @@ processData.call(this, { Id: groupId, callback: callback, method: "PUT", data: { type: "group", userIds: userIds } }); }; User.saveUserDisplayName = function (user, callback) { - processData.call(this, { Id: '', callback: callback, method: "PUT", data: user,title:"修改用户显示名称" }); + processData.call(this, { Id: '', callback: callback, method: "PUT", data: user, title: "修改用户显示名称" }); }; User.changePassword = function (user) { - processData.call(this, { Id: '', method: "PUT", data: user, title: "修改密码" }); - } - + processData.call(this, { Id: '', method: "PUT", data: user }); + }; + User.processUser = function (id, result, callback) { + processData.call(this, { Id: id, callback: callback, method: "PUT", data: { type: "user", userIds: result }, title: result == "1" ? "授权用户" : "拒绝用户" }); + }; // Groups Group = { url: '../api/Groups/', @@ -380,7 +382,7 @@ } return htmlString; } - } + }; Menu.cascadeMenu = function (menus) { var html = ""; $.each(menus, function (index, menu) { @@ -392,7 +394,7 @@ } }); return html; - } + }; Menu.getMenus = function (callback) { processData.call(this, { Id: 0, callback: callback, data: { type: "user" } }); }; @@ -407,10 +409,10 @@ Profiles = { url: '../api/Profiles/', title: "个性化维护" - } + }; Profiles.saveWebSite = function (options) { processData.call(this, { data: options }); - } + }; // Exceptions Exceptions = { @@ -421,19 +423,30 @@ return $.format('
    {0}
    ', ele); }).join(''); } - } + }; Exceptions.getFiles = function (callback) { processData.call(this, { Id: "", callback: callback, swal: false }); } Exceptions.getFileByName = function (fileName, callback) { processData.call(this, { Id: "", callback: callback, method: "PUT", swal: false, data: { "": fileName } }); - } + }; // Dicts Dicts = { url: '../api/Dicts/' - } + }; Dicts.retrieveCategories = function (callback) { processData.call(this, { Id: 1, callback: callback, swal: false, data: { type: 'category' } }); + }; + + // Notifi + Notifications = { + url: '../api/Notifications/' + }; + Notifications.retrieveNotifies = function (category, callback) { + processData.call(this, { Id: category, callback: callback, method: "GET", swal: false }); + }; + Notifications.retrieveAllNotifies = function (callback) { + processData.call(this, { Id: "", callback: callback, method: "GET", swal: false }); } })(jQuery); \ No newline at end of file diff --git a/Bootstrap.Admin/Controllers/NotificationsController.cs b/Bootstrap.Admin/Controllers/NotificationsController.cs index 55ff7274..9984e8c5 100644 --- a/Bootstrap.Admin/Controllers/NotificationsController.cs +++ b/Bootstrap.Admin/Controllers/NotificationsController.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Web.Http; using System.Linq; +using System; namespace Bootstrap.Admin.Controllers { @@ -15,12 +16,20 @@ namespace Bootstrap.Admin.Controllers public Notifications Get() { var ret = new Notifications(); - NotificationHelper.RetrieveNotifications().AsParallel().ForAll(n => - { - if (n.Category == "0") ret.Users.Add(n); - else if (n.Category == "1") ret.Apps.Add(n); - else if (n.Category == "2") ret.Dbs.Add(n); - }); + // New Users + var user = UserHelper.RetrieveNewUsers(); + ret.Users = user.Take(6).OrderByDescending(u => u.RegisterTime).ToList(); + ret.Users.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); + }); + ret.NewUsersCount = user.Count(); + + // Tasks return ret; } /// @@ -32,13 +41,9 @@ namespace Bootstrap.Admin.Controllers public Notifications Get(string id) { var ret = new Notifications(); - NotificationHelper.RetrieveNotifications().AsParallel().ForAll(n => - { - if (id != n.Category) return; - if (n.Category == "0") ret.Users.Add(n); - else if (n.Category == "1") ret.Apps.Add(n); - else if (n.Category == "2") ret.Dbs.Add(n); - }); + if (id == "newusers" || id == "all") ret.Users = UserHelper.RetrieveNewUsers().OrderByDescending(u => u.RegisterTime).ToList(); + else if (id == "apps" || id == "all") ret.Apps = new List(); + else if (id == "dbs" || id == "all") ret.Dbs = new List(); return ret; } @@ -46,15 +51,52 @@ namespace Bootstrap.Admin.Controllers { public Notifications() { - Users = new List(); - Apps = new List(); - Dbs = new List(); + Users = new List(); + Apps = new List(); + Dbs = new List(); + Tasks = new List(); + Messages = new List(); } - public List Users { get; set; } - - public List Apps { get; set; } - - public List Dbs { get; set; } + /// + /// + /// + public List Users { get; set; } + /// + /// + /// + public List Apps { get; set; } + /// + /// + /// + public List Dbs { get; set; } + /// + /// + /// + public List Tasks { get; set; } + /// + /// + /// + public List Messages { get; set; } + /// + /// 获得/设置 消息数量 + /// + public int MessagesCount { get; set; } + /// + /// 获得/设置 新用户数量 + /// + public int NewUsersCount { get; set; } + /// + /// 获取/设置 任务数量 + /// + public int TasksCount { get; set; } + /// + /// 获取/设置 应用程序错误数量 + /// + public int AppExceptionsCount { get; set; } + /// + /// 获取/设置 数据库错误数量 + /// + public int DbExceptionsCount { get; set; } } } } \ No newline at end of file diff --git a/Bootstrap.Admin/Controllers/UsersController.cs b/Bootstrap.Admin/Controllers/UsersController.cs index 2a2f8539..0ec0a38d 100644 --- a/Bootstrap.Admin/Controllers/UsersController.cs +++ b/Bootstrap.Admin/Controllers/UsersController.cs @@ -2,7 +2,6 @@ using Bootstrap.DataAccess; using Longbow.Security.Principal; using Newtonsoft.Json.Linq; -using System; using System.Collections.Generic; using System.Linq; using System.Web.Http; @@ -66,7 +65,6 @@ namespace Bootstrap.Admin.Controllers } return ret; } - /// /// /// @@ -88,7 +86,12 @@ namespace Bootstrap.Admin.Controllers value.ApprovedBy = User.Identity.Name; return UserHelper.SaveUser(value); } - + /// + /// + /// + /// + /// + /// [HttpPut] public bool Put(int id, [FromBody]JObject value) { @@ -122,7 +125,6 @@ namespace Bootstrap.Admin.Controllers } return ret; } - /// /// /// diff --git a/Bootstrap.Admin/Models/HeaderBarModel.cs b/Bootstrap.Admin/Models/HeaderBarModel.cs index 5815c799..520fc7f3 100644 --- a/Bootstrap.Admin/Models/HeaderBarModel.cs +++ b/Bootstrap.Admin/Models/HeaderBarModel.cs @@ -1,6 +1,5 @@ using Bootstrap.DataAccess; using System.Collections.Generic; -using System.Linq; using System.Web; namespace Bootstrap.Admin.Models @@ -19,16 +18,6 @@ namespace Bootstrap.Admin.Models UserID = user.ID; HomeUrl = "~/"; Menus = MenuHelper.RetrieveLinksByUserName(UserName); - var notis = NotificationHelper.RetrieveNotifications(); - NotifiCount = notis.Count(); - Notifications = notis.Take(6); - var msgs = MessageHelper.RetrieveMessagesHeader(UserName); - MessageCount = msgs.Count(); - Messages = msgs.Take(6); - MessageList = MessageHelper.RetrieveMessages(UserName); - var tasks = TaskHelper.RetrieveTasks(); - TaskCount = tasks.Count(); - Tasks = tasks.Take(6); } public string UserName { get; protected set; } /// @@ -52,37 +41,12 @@ namespace Bootstrap.Admin.Models /// public IEnumerable Menus { get; private set; } /// - /// 获得/设置 通知内容集合 - /// - public IEnumerable Notifications { get; set; } - /// - /// 获得/设置 通知数量 - /// - public int NotifiCount { get; set; } - /// - /// 获得/设置 消息列表 - /// - public IEnumerable Messages { get; set; } - /// - /// 获得/设置 消息数量 - /// - public int MessageCount { get; set; } - /// /// 获得/设置 消息列表 /// public IEnumerable MessageList { get; set; } /// - /// + /// 获得/设置 用户头像地址 /// public string Icon { get; set; } - /// - /// 获取/设置 任务数量 - /// - public int TaskCount { get; set; } - /// - /// 获取/设置 任务内容集合 - /// - public IEnumerable Tasks { get; set; } - } } \ No newline at end of file diff --git a/Bootstrap.Admin/Scripts/noti.js b/Bootstrap.Admin/Scripts/noti.js index 33482aad..f68ba1d8 100644 --- a/Bootstrap.Admin/Scripts/noti.js +++ b/Bootstrap.Admin/Scripts/noti.js @@ -1,43 +1,34 @@ $(function () { - var url = '../api/Notifications/'; - var htmlNewUsers = '
  • {0}{1}{2}
  • '; var htmlApp = '
  • {0}{1}{2}
  • '; var htmlDb = '
  • {0}{1}{2}
  • '; function listData(options) { - options = $.extend({ url: url, animation: true, ctl: $('a.fa-refresh') }, options); - var category = options.ctl.length == 1 ? options.ctl.attr('data-category') : ""; + options = $.extend({ animation: true, ctl: $('a.fa-refresh') }, options); + var category = options.ctl.length == 1 ? options.ctl.attr('data-category') : "all"; if (options.animation) options.ctl.toggleClass('fa-spin'); - $.ajax({ - url: options.url + category, - type: 'GET', - success: function (result) { - if (result) { - if (category == '0' || category == '') { - var content = result.Users.map(function (noti) { - return $.format(htmlNewUsers, noti.Title, noti.Content, noti.RegisterTime, noti.ID); - }).join(''); - $('#tasks-users').html(content); - } - if (category == '1' || category == '') { - var content = result.Apps.map(function (noti) { - return $.format(htmlApp, noti.Title, noti.Content, noti.RegisterTime, noti.ID); - }).join(''); - $('#tasks-app').html(content); - } - if (category == '2' || category == '') { - var content = result.Dbs.map(function (noti) { - return $.format(htmlDb, noti.Title, noti.Content, noti.RegisterTime, noti.ID); - }).join(''); - $('#tasks-db').html(content); - } + Notifications.retrieveNotifies(category, function (result) { + if (result) { + if (category == 'newusers' || category == 'all') { + var content = result.Users.map(function (noti) { + return $.format(htmlNewUsers, noti.UserName, noti.Description, noti.RegisterTime, noti.ID); + }).join(''); + $('#tasks-users').html(content); + } + if (category == 'apps' || category == 'all') { + var content = result.Apps.map(function (noti) { + return $.format(htmlApp, noti.Title, noti.Content, noti.RegisterTime, noti.ID); + }).join(''); + $('#tasks-app').html(content); + } + if (category == 'dbs' || category == 'all') { + var content = result.Dbs.map(function (noti) { + return $.format(htmlDb, noti.Title, noti.Content, noti.RegisterTime, noti.ID); + }).join(''); + $('#tasks-db').html(content); } - if (options.animation) options.ctl.toggleClass('fa-spin'); - }, - error: function (XMLHttpRequest, textStatus, errorThrown) { - if (options.animation) options.ctl.toggleClass('fa-spin'); } + if (options.animation) options.ctl.toggleClass('fa-spin'); }); } listData(); @@ -49,21 +40,9 @@ $('#tasks-users').on('click', 'button', function () { var id = $(this).attr('data-id'); var result = $(this).attr('data-result'); - var data = { type: "user", userIds: result }; - var title = result == "1" ? "授权用户" : "拒绝用户"; - $.ajax({ - url: '../api/Users/' + id, - data: data, - type: 'PUT', - success: function (result) { - if (result) swal("成功!", title, "success"); - else swal("失败", title, "error"); - var refresh = $('#tasks-users').parentsUntil('div.panel').last().prev().find('a.fa-refresh'); - listData(refresh); - }, - error: function (XMLHttpRequest, textStatus, errorThrown) { - swal("失败", title, "error"); - } + User.processUser(id, result, function (result) { + var refresh = $('#tasks-users').parentsUntil('div.panel').last().prev().find('a.fa-refresh'); + listData(refresh); }); }); }); \ No newline at end of file diff --git a/Bootstrap.Admin/Views/Admin/Notifications.cshtml b/Bootstrap.Admin/Views/Admin/Notifications.cshtml index f2dd2bf3..21b85b09 100644 --- a/Bootstrap.Admin/Views/Admin/Notifications.cshtml +++ b/Bootstrap.Admin/Views/Admin/Notifications.cshtml @@ -18,7 +18,7 @@ @Html.Partial("Navigator", Model) }
    -
    用户注册
    +
    用户注册
      @@ -27,7 +27,7 @@
    -
    程序错误
    +
    程序错误
      @@ -36,7 +36,7 @@
    -
    数据库错误
    +
    数据库错误
      diff --git a/Bootstrap.Admin/Views/Shared/Header.cshtml b/Bootstrap.Admin/Views/Shared/Header.cshtml index c5ae358a..02225305 100644 --- a/Bootstrap.Admin/Views/Shared/Header.cshtml +++ b/Bootstrap.Admin/Views/Shared/Header.cshtml @@ -23,119 +23,95 @@ } @if (!Model.ShowMenu) { - + - + } diff --git a/Bootstrap.DataAccess/ExceptionHelper.cs b/Bootstrap.DataAccess/ExceptionHelper.cs index 2387d1ec..f31c7929 100644 --- a/Bootstrap.DataAccess/ExceptionHelper.cs +++ b/Bootstrap.DataAccess/ExceptionHelper.cs @@ -18,22 +18,23 @@ namespace Bootstrap.DataAccess bool ret = false; try { - var sql = "insert into Exceptions (AppDomainName, ErrorPage, UserID, UserIp, Message, StackTrace, LogTime) values (@AppDomainName, @ErrorPage, @UserID, @UserIp, @Message, @StackTrace, GetDate())"; + var sql = "insert into Exceptions (AppDomainName, ErrorPage, UserID, UserIp, ExceptionType, Message, StackTrace, LogTime) values (@AppDomainName, @ErrorPage, @UserID, @UserIp, @ExceptionType, @Message, @StackTrace, GetDate())"; using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql)) { cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@AppDomainName", AppDomain.CurrentDomain.FriendlyName, ParameterDirection.Input)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@ErrorPage", additionalInfo["ErrorPage"], ParameterDirection.Input)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@UserID", DBAccess.ToDBValue(additionalInfo["UserId"]), ParameterDirection.Input)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@UserIp", additionalInfo["UserIp"], ParameterDirection.Input)); + cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@ExceptionType", ex.GetType().FullName, ParameterDirection.Input)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@Message", ex.Message, ParameterDirection.Input)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@StackTrace", DBAccess.ToDBValue(ex.StackTrace), ParameterDirection.Input)); DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd); } ret = true; } - catch + catch (Exception e) { - throw new Exception("Excetion Log Error"); + throw new Exception("Excetion Log Error", e); } return ret; } diff --git a/Bootstrap.DataAccess/Exceptions.cs b/Bootstrap.DataAccess/Exceptions.cs index bb9b56d6..ae7aaae6 100644 --- a/Bootstrap.DataAccess/Exceptions.cs +++ b/Bootstrap.DataAccess/Exceptions.cs @@ -1,15 +1,46 @@ -using System; -namespace Bootstrap.DataAccess -{ - public class Exceptions - { - public int ID { get; set; } - public string AppDomainName { get; set; } - public string ErrorPage { get; set; } - public string UserID { get; set; } - public string UserIp { get; set; } - public string Message { get; set; } - public string StackTrace { get; set; } - public DateTime LogTime { get; set; } - } -} +using System; +namespace Bootstrap.DataAccess +{ + /// + /// + /// + public class Exceptions + { + /// + /// + /// + public int ID { get; set; } + /// + /// + /// + public string AppDomainName { get; set; } + /// + /// + /// + public string ErrorPage { get; set; } + /// + /// + /// + public string UserID { get; set; } + /// + /// + /// + public string UserIp { get; set; } + /// + /// + /// + public string Message { get; set; } + /// + /// + /// + public string StackTrace { get; set; } + /// + /// + /// + public DateTime LogTime { get; set; } + /// + /// + /// + public string ExceptionType { get; set; } + } +} diff --git a/Bootstrap.DataAccess/NotificationHelper.cs b/Bootstrap.DataAccess/NotificationHelper.cs index fd5198ed..660908a2 100644 --- a/Bootstrap.DataAccess/NotificationHelper.cs +++ b/Bootstrap.DataAccess/NotificationHelper.cs @@ -51,9 +51,7 @@ namespace Bootstrap.DataAccess return notifications; }, 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 => + notifies.AsParallel().ForAll(n => { var ts = DateTime.Now - n.RegisterTime; if (ts.TotalMinutes < 5) n.Period = "刚刚"; @@ -61,9 +59,8 @@ 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.OrderByDescending(n => n.RegisterTime); + return notifies.OrderByDescending(n => n.RegisterTime); } - /// /// 点击某一行用户注册通知的处理成功操作 /// @@ -89,5 +86,31 @@ namespace Bootstrap.DataAccess } return ret; } + /// + /// + /// + /// + /// + public static bool SaveNotification(Notification noti) + { + bool ret = false; + if (string.IsNullOrEmpty(noti.Title) || string.IsNullOrEmpty(noti.Content)) return ret; + try + { + using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, "Insert into Notifications (Category, Title, Content, RegisterTime) values (N'2', @Title, @Content, GetDate())")) + { + cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@Title", noti.Title, ParameterDirection.Input)); + cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@Content", noti.Content, ParameterDirection.Input)); + DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd); + } + CacheCleanUtility.ClearCache(notifyIds: string.Empty); + ret = true; + } + catch (Exception ex) + { + ExceptionManager.Publish(ex); + } + return ret; + } } } diff --git a/Bootstrap.DataAccess/UserHelper.cs b/Bootstrap.DataAccess/UserHelper.cs index 2e15e26b..fff40cee 100644 --- a/Bootstrap.DataAccess/UserHelper.cs +++ b/Bootstrap.DataAccess/UserHelper.cs @@ -103,7 +103,7 @@ namespace Bootstrap.DataAccess /// public static IEnumerable RetrieveNewUsers() { - var ret = CacheManager.GetOrAdd(RetrieveNewUsersDataKey, CacheSection.RetrieveIntervalByKey(RetrieveNewUsersDataKey), key => + return CacheManager.GetOrAdd(RetrieveNewUsersDataKey, CacheSection.RetrieveIntervalByKey(RetrieveNewUsersDataKey), key => { string sql = "select ID, UserName, DisplayName, RegisterTime, [Description] from Users Where ApprovedTime is null and RejectedTime is null"; List Users = new List(); @@ -128,7 +128,6 @@ namespace Bootstrap.DataAccess catch (Exception ex) { ExceptionManager.Publish(ex); } return Users; }, CacheSection.RetrieveDescByKey(RetrieveNewUsersDataKey)); - return ret; } /// diff --git a/DatabaseScripts/Install.sql b/DatabaseScripts/Install.sql index 2072bd54..e88d6295 100644 --- a/DatabaseScripts/Install.sql +++ b/DatabaseScripts/Install.sql @@ -257,6 +257,7 @@ CREATE TABLE [dbo].[Exceptions]( [ErrorPage] [varchar](50) NOT NULL, [UserID] [varchar](50) NOT NULL, [UserIp] [varchar](15) NOT NULL, + [ExceptionType] [nvarchar](max) NOT NULL, [Message] [nvarchar](max) NOT NULL, [StackTrace] [nvarchar](max) NOT NULL, [LogTime] [datetime] NOT NULL,