拆分通知管理功能,页头分为5块通知,改由jQuery调用,减少服务器响应时间
This commit is contained in:
parent
ad4408f9e3
commit
04f778b322
|
@ -441,7 +441,7 @@
|
||||||
padding-top: 2px;
|
padding-top: 2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.notify-row .dropdown-menu.notification > li > a > div {
|
.notify-row .dropdown-menu.notification li a div {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
left: 36px;
|
left: 36px;
|
||||||
right: 44px;
|
right: 44px;
|
||||||
|
|
|
@ -45,4 +45,19 @@
|
||||||
|
|
||||||
// custom scrollbar
|
// custom scrollbar
|
||||||
if (!$.browser.versions.ios) $("#sidebar").niceScroll({ styler: "fb", cursorcolor: "#e8403f", cursorwidth: '3', cursorborderradius: '10px', background: '#404040', spacebarenabled: false, cursorborder: '', scrollspeed: 60 });
|
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 = '<li><a href="../Admin/Notifications"><span class="label label-success"><i class="fa fa-plus"></i></span><div title="{1}">{0}({1})</div><span class="small italic">{2}</span></a></li>';
|
||||||
|
var html = result.Users.map(function (u) {
|
||||||
|
return $.format(htmlUserTemplate, u.UserName, u.DisplayName, u.Period);
|
||||||
|
}).join('');
|
||||||
|
$(html).insertAfter($('#msgHeaderUserContent'));
|
||||||
|
console.log(result);
|
||||||
|
});
|
||||||
});
|
});
|
|
@ -255,7 +255,7 @@
|
||||||
var htmlTemplate = '<div class="form-group checkbox col-lg-3 col-xs-4"><label class="tooltips" data-placement="top" data-original-title="{3}" title="{3}"><input type="checkbox" value="{0}" {2}/>{1}</label></div>';
|
var htmlTemplate = '<div class="form-group checkbox col-lg-3 col-xs-4"><label class="tooltips" data-placement="top" data-original-title="{3}" title="{3}"><input type="checkbox" value="{0}" {2}/>{1}</label></div>';
|
||||||
|
|
||||||
var processData = function (options) {
|
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) {
|
if (data.remote) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
|
@ -288,7 +288,7 @@
|
||||||
else { swal("失败", data.title, "error"); }
|
else { swal("失败", data.title, "error"); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
// Roles
|
// Roles
|
||||||
Role = {
|
Role = {
|
||||||
url: '../api/Roles/',
|
url: '../api/Roles/',
|
||||||
|
@ -310,10 +310,10 @@
|
||||||
};
|
};
|
||||||
Role.saveRolesByUserId = function (userId, roleIds, callback) {
|
Role.saveRolesByUserId = function (userId, roleIds, callback) {
|
||||||
processData.call(this, { Id: userId, callback: callback, method: "PUT", data: { type: "user", roleIds: roleIds } });
|
processData.call(this, { Id: userId, callback: callback, method: "PUT", data: { type: "user", roleIds: roleIds } });
|
||||||
}
|
};
|
||||||
Role.saveRolesByGroupId = function (groupId, roleIds, callback) {
|
Role.saveRolesByGroupId = function (groupId, roleIds, callback) {
|
||||||
processData.call(this, { Id: groupId, callback: callback, method: "PUT", data: { type: "group", roleIds: roleIds } });
|
processData.call(this, { Id: groupId, callback: callback, method: "PUT", data: { type: "group", roleIds: roleIds } });
|
||||||
}
|
};
|
||||||
Role.saveRolesByMenuId = function (menuId, roleIds, callback) {
|
Role.saveRolesByMenuId = function (menuId, roleIds, callback) {
|
||||||
processData.call(this, { Id: menuId, callback: callback, method: "PUT", data: { type: "menu", roleIds: roleIds } });
|
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);
|
return $.format(htmlTemplate, element.ID, element.DisplayName, element.Checked, element.UserName);
|
||||||
}).join('');
|
}).join('');
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
User.getUsersByRoleId = function (roleId, callback) {
|
User.getUsersByRoleId = function (roleId, callback) {
|
||||||
processData.call(this, { Id: roleId, callback: callback, data: { type: "role" } });
|
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 } });
|
processData.call(this, { Id: groupId, callback: callback, method: "PUT", data: { type: "group", userIds: userIds } });
|
||||||
};
|
};
|
||||||
User.saveUserDisplayName = function (user, callback) {
|
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) {
|
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
|
// Groups
|
||||||
Group = {
|
Group = {
|
||||||
url: '../api/Groups/',
|
url: '../api/Groups/',
|
||||||
|
@ -380,7 +382,7 @@
|
||||||
}
|
}
|
||||||
return htmlString;
|
return htmlString;
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
Menu.cascadeMenu = function (menus) {
|
Menu.cascadeMenu = function (menus) {
|
||||||
var html = "";
|
var html = "";
|
||||||
$.each(menus, function (index, menu) {
|
$.each(menus, function (index, menu) {
|
||||||
|
@ -392,7 +394,7 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return html;
|
return html;
|
||||||
}
|
};
|
||||||
Menu.getMenus = function (callback) {
|
Menu.getMenus = function (callback) {
|
||||||
processData.call(this, { Id: 0, callback: callback, data: { type: "user" } });
|
processData.call(this, { Id: 0, callback: callback, data: { type: "user" } });
|
||||||
};
|
};
|
||||||
|
@ -407,10 +409,10 @@
|
||||||
Profiles = {
|
Profiles = {
|
||||||
url: '../api/Profiles/',
|
url: '../api/Profiles/',
|
||||||
title: "个性化维护"
|
title: "个性化维护"
|
||||||
}
|
};
|
||||||
Profiles.saveWebSite = function (options) {
|
Profiles.saveWebSite = function (options) {
|
||||||
processData.call(this, { data: options });
|
processData.call(this, { data: options });
|
||||||
}
|
};
|
||||||
|
|
||||||
// Exceptions
|
// Exceptions
|
||||||
Exceptions = {
|
Exceptions = {
|
||||||
|
@ -421,19 +423,30 @@
|
||||||
return $.format('<div class="form-group col-lg-3 col-md-3 col-sm-4 col-xs-6"><a class="logfile" href="#"><i class="fa fa-file-text-o"></i><span>{0}</span></a></div>', ele);
|
return $.format('<div class="form-group col-lg-3 col-md-3 col-sm-4 col-xs-6"><a class="logfile" href="#"><i class="fa fa-file-text-o"></i><span>{0}</span></a></div>', ele);
|
||||||
}).join('');
|
}).join('');
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
Exceptions.getFiles = function (callback) {
|
Exceptions.getFiles = function (callback) {
|
||||||
processData.call(this, { Id: "", callback: callback, swal: false });
|
processData.call(this, { Id: "", callback: callback, swal: false });
|
||||||
}
|
}
|
||||||
Exceptions.getFileByName = function (fileName, callback) {
|
Exceptions.getFileByName = function (fileName, callback) {
|
||||||
processData.call(this, { Id: "", callback: callback, method: "PUT", swal: false, data: { "": fileName } });
|
processData.call(this, { Id: "", callback: callback, method: "PUT", swal: false, data: { "": fileName } });
|
||||||
}
|
};
|
||||||
|
|
||||||
// Dicts
|
// Dicts
|
||||||
Dicts = {
|
Dicts = {
|
||||||
url: '../api/Dicts/'
|
url: '../api/Dicts/'
|
||||||
}
|
};
|
||||||
Dicts.retrieveCategories = function (callback) {
|
Dicts.retrieveCategories = function (callback) {
|
||||||
processData.call(this, { Id: 1, callback: callback, swal: false, data: { type: 'category' } });
|
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);
|
})(jQuery);
|
|
@ -2,6 +2,7 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Web.Http;
|
using System.Web.Http;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace Bootstrap.Admin.Controllers
|
namespace Bootstrap.Admin.Controllers
|
||||||
{
|
{
|
||||||
|
@ -15,12 +16,20 @@ namespace Bootstrap.Admin.Controllers
|
||||||
public Notifications Get()
|
public Notifications Get()
|
||||||
{
|
{
|
||||||
var ret = new Notifications();
|
var ret = new Notifications();
|
||||||
NotificationHelper.RetrieveNotifications().AsParallel().ForAll(n =>
|
// New Users
|
||||||
{
|
var user = UserHelper.RetrieveNewUsers();
|
||||||
if (n.Category == "0") ret.Users.Add(n);
|
ret.Users = user.Take(6).OrderByDescending(u => u.RegisterTime).ToList();
|
||||||
else if (n.Category == "1") ret.Apps.Add(n);
|
ret.Users.AsParallel().ForAll(n =>
|
||||||
else if (n.Category == "2") ret.Dbs.Add(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;
|
return ret;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -32,13 +41,9 @@ namespace Bootstrap.Admin.Controllers
|
||||||
public Notifications Get(string id)
|
public Notifications Get(string id)
|
||||||
{
|
{
|
||||||
var ret = new Notifications();
|
var ret = new Notifications();
|
||||||
NotificationHelper.RetrieveNotifications().AsParallel().ForAll(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<Exceptions>();
|
||||||
if (id != n.Category) return;
|
else if (id == "dbs" || id == "all") ret.Dbs = new List<Exceptions>();
|
||||||
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);
|
|
||||||
});
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,15 +51,52 @@ namespace Bootstrap.Admin.Controllers
|
||||||
{
|
{
|
||||||
public Notifications()
|
public Notifications()
|
||||||
{
|
{
|
||||||
Users = new List<Notification>();
|
Users = new List<User>();
|
||||||
Apps = new List<Notification>();
|
Apps = new List<Exceptions>();
|
||||||
Dbs = new List<Notification>();
|
Dbs = new List<Exceptions>();
|
||||||
|
Tasks = new List<Task>();
|
||||||
|
Messages = new List<Message>();
|
||||||
}
|
}
|
||||||
public List<Notification> Users { get; set; }
|
/// <summary>
|
||||||
|
///
|
||||||
public List<Notification> Apps { get; set; }
|
/// </summary>
|
||||||
|
public List<User> Users { get; set; }
|
||||||
public List<Notification> Dbs { get; set; }
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public List<Exceptions> Apps { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public List<Exceptions> Dbs { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public List<Task> Tasks { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public List<Message> Messages { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 获得/设置 消息数量
|
||||||
|
/// </summary>
|
||||||
|
public int MessagesCount { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 获得/设置 新用户数量
|
||||||
|
/// </summary>
|
||||||
|
public int NewUsersCount { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 获取/设置 任务数量
|
||||||
|
/// </summary>
|
||||||
|
public int TasksCount { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 获取/设置 应用程序错误数量
|
||||||
|
/// </summary>
|
||||||
|
public int AppExceptionsCount { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 获取/设置 数据库错误数量
|
||||||
|
/// </summary>
|
||||||
|
public int DbExceptionsCount { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -2,7 +2,6 @@
|
||||||
using Bootstrap.DataAccess;
|
using Bootstrap.DataAccess;
|
||||||
using Longbow.Security.Principal;
|
using Longbow.Security.Principal;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Web.Http;
|
using System.Web.Http;
|
||||||
|
@ -66,7 +65,6 @@ namespace Bootstrap.Admin.Controllers
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -88,7 +86,12 @@ namespace Bootstrap.Admin.Controllers
|
||||||
value.ApprovedBy = User.Identity.Name;
|
value.ApprovedBy = User.Identity.Name;
|
||||||
return UserHelper.SaveUser(value);
|
return UserHelper.SaveUser(value);
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id"></param>
|
||||||
|
/// <param name="value"></param>
|
||||||
|
/// <returns></returns>
|
||||||
[HttpPut]
|
[HttpPut]
|
||||||
public bool Put(int id, [FromBody]JObject value)
|
public bool Put(int id, [FromBody]JObject value)
|
||||||
{
|
{
|
||||||
|
@ -122,7 +125,6 @@ namespace Bootstrap.Admin.Controllers
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
using Bootstrap.DataAccess;
|
using Bootstrap.DataAccess;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using System.Web;
|
using System.Web;
|
||||||
|
|
||||||
namespace Bootstrap.Admin.Models
|
namespace Bootstrap.Admin.Models
|
||||||
|
@ -19,16 +18,6 @@ namespace Bootstrap.Admin.Models
|
||||||
UserID = user.ID;
|
UserID = user.ID;
|
||||||
HomeUrl = "~/";
|
HomeUrl = "~/";
|
||||||
Menus = MenuHelper.RetrieveLinksByUserName(UserName);
|
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; }
|
public string UserName { get; protected set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -52,37 +41,12 @@ namespace Bootstrap.Admin.Models
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public IEnumerable<Menu> Menus { get; private set; }
|
public IEnumerable<Menu> Menus { get; private set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获得/设置 通知内容集合
|
|
||||||
/// </summary>
|
|
||||||
public IEnumerable<Notification> Notifications { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 获得/设置 通知数量
|
|
||||||
/// </summary>
|
|
||||||
public int NotifiCount { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 获得/设置 消息列表
|
|
||||||
/// </summary>
|
|
||||||
public IEnumerable<Message> Messages { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 获得/设置 消息数量
|
|
||||||
/// </summary>
|
|
||||||
public int MessageCount { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 获得/设置 消息列表
|
/// 获得/设置 消息列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public IEnumerable<Message> MessageList { get; set; }
|
public IEnumerable<Message> MessageList { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
/// 获得/设置 用户头像地址
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string Icon { get; set; }
|
public string Icon { get; set; }
|
||||||
/// <summary>
|
|
||||||
/// 获取/设置 任务数量
|
|
||||||
/// </summary>
|
|
||||||
public int TaskCount { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 获取/设置 任务内容集合
|
|
||||||
/// </summary>
|
|
||||||
public IEnumerable<Task> Tasks { get; set; }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,43 +1,34 @@
|
||||||
$(function () {
|
$(function () {
|
||||||
var url = '../api/Notifications/';
|
|
||||||
|
|
||||||
var htmlNewUsers = '<li class="list-primary"><i class="fa fa-ellipsis-v"></i><div class="task-title notifi"><span class="task-title-sp">{0}</span><span class="task-value">{1}</span><span class="task-time">{2}</span><div class="pull-right hidden-phone"><button class="btn btn-success btn-xs fa fa-check" data-id="{3}" data-result="1"></button><button class="btn btn-danger btn-xs fa fa-remove" data-id="{3}" data-result="0" data-placement="left" data-original-title="拒绝授权"></button></div></div></li>';
|
var htmlNewUsers = '<li class="list-primary"><i class="fa fa-ellipsis-v"></i><div class="task-title notifi"><span class="task-title-sp">{0}</span><span class="task-value">{1}</span><span class="task-time">{2}</span><div class="pull-right hidden-phone"><button class="btn btn-success btn-xs fa fa-check" data-id="{3}" data-result="1"></button><button class="btn btn-danger btn-xs fa fa-remove" data-id="{3}" data-result="0" data-placement="left" data-original-title="拒绝授权"></button></div></div></li>';
|
||||||
var htmlApp = '<li class="list-warning"><i class="fa fa-ellipsis-v"></i><div class="task-title notifi"><span class="task-title-sp">{0}</span><span class="task-value">{1}</span><span class="task-time">{2}</span><div class="pull-right hidden-phone"><a href="../Admin/Exceptions?id={3}" class="btn btn-warning btn-xs fa fa-bug"></a></div></div></li>';
|
var htmlApp = '<li class="list-warning"><i class="fa fa-ellipsis-v"></i><div class="task-title notifi"><span class="task-title-sp">{0}</span><span class="task-value">{1}</span><span class="task-time">{2}</span><div class="pull-right hidden-phone"><a href="../Admin/Exceptions?id={3}" class="btn btn-warning btn-xs fa fa-bug"></a></div></div></li>';
|
||||||
var htmlDb = '<li class="list-danger"><i class="fa fa-ellipsis-v"></i><div class="task-title notifi"><span class="task-title-sp">{0}</span><span class="task-value">{1}</span><span class="task-time">{2}</span><div class="pull-right hidden-phone"><a href="../Admin/Exceptions?id={3}" class="btn btn-danger btn-xs fa fa-database"></a></div></div></li>';
|
var htmlDb = '<li class="list-danger"><i class="fa fa-ellipsis-v"></i><div class="task-title notifi"><span class="task-title-sp">{0}</span><span class="task-value">{1}</span><span class="task-time">{2}</span><div class="pull-right hidden-phone"><a href="../Admin/Exceptions?id={3}" class="btn btn-danger btn-xs fa fa-database"></a></div></div></li>';
|
||||||
|
|
||||||
function listData(options) {
|
function listData(options) {
|
||||||
options = $.extend({ url: url, animation: true, ctl: $('a.fa-refresh') }, options);
|
options = $.extend({ animation: true, ctl: $('a.fa-refresh') }, options);
|
||||||
var category = options.ctl.length == 1 ? options.ctl.attr('data-category') : "";
|
var category = options.ctl.length == 1 ? options.ctl.attr('data-category') : "all";
|
||||||
if (options.animation) options.ctl.toggleClass('fa-spin');
|
if (options.animation) options.ctl.toggleClass('fa-spin');
|
||||||
$.ajax({
|
Notifications.retrieveNotifies(category, function (result) {
|
||||||
url: options.url + category,
|
if (result) {
|
||||||
type: 'GET',
|
if (category == 'newusers' || category == 'all') {
|
||||||
success: function (result) {
|
var content = result.Users.map(function (noti) {
|
||||||
if (result) {
|
return $.format(htmlNewUsers, noti.UserName, noti.Description, noti.RegisterTime, noti.ID);
|
||||||
if (category == '0' || category == '') {
|
}).join('');
|
||||||
var content = result.Users.map(function (noti) {
|
$('#tasks-users').html(content);
|
||||||
return $.format(htmlNewUsers, noti.Title, noti.Content, noti.RegisterTime, noti.ID);
|
}
|
||||||
}).join('');
|
if (category == 'apps' || category == 'all') {
|
||||||
$('#tasks-users').html(content);
|
var content = result.Apps.map(function (noti) {
|
||||||
}
|
return $.format(htmlApp, noti.Title, noti.Content, noti.RegisterTime, noti.ID);
|
||||||
if (category == '1' || category == '') {
|
}).join('');
|
||||||
var content = result.Apps.map(function (noti) {
|
$('#tasks-app').html(content);
|
||||||
return $.format(htmlApp, noti.Title, noti.Content, noti.RegisterTime, noti.ID);
|
}
|
||||||
}).join('');
|
if (category == 'dbs' || category == 'all') {
|
||||||
$('#tasks-app').html(content);
|
var content = result.Dbs.map(function (noti) {
|
||||||
}
|
return $.format(htmlDb, noti.Title, noti.Content, noti.RegisterTime, noti.ID);
|
||||||
if (category == '2' || category == '') {
|
}).join('');
|
||||||
var content = result.Dbs.map(function (noti) {
|
$('#tasks-db').html(content);
|
||||||
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();
|
listData();
|
||||||
|
@ -49,21 +40,9 @@
|
||||||
$('#tasks-users').on('click', 'button', function () {
|
$('#tasks-users').on('click', 'button', function () {
|
||||||
var id = $(this).attr('data-id');
|
var id = $(this).attr('data-id');
|
||||||
var result = $(this).attr('data-result');
|
var result = $(this).attr('data-result');
|
||||||
var data = { type: "user", userIds: result };
|
User.processUser(id, result, function (result) {
|
||||||
var title = result == "1" ? "授权用户" : "拒绝用户";
|
var refresh = $('#tasks-users').parentsUntil('div.panel').last().prev().find('a.fa-refresh');
|
||||||
$.ajax({
|
listData(refresh);
|
||||||
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");
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
|
@ -18,7 +18,7 @@
|
||||||
@Html.Partial("Navigator", Model)
|
@Html.Partial("Navigator", Model)
|
||||||
}
|
}
|
||||||
<div class="panel panel-default">
|
<div class="panel panel-default">
|
||||||
<div class="panel-heading">用户注册<span class="pull-right"><a href="javascript:;" class="fa fa-refresh" data-category="0"></a></span></div>
|
<div class="panel-heading">用户注册<span class="pull-right"><a href="javascript:;" class="fa fa-refresh" data-category="newusers"></a></span></div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<div class="tasks-widget">
|
<div class="tasks-widget">
|
||||||
<ul id="tasks-users" class="task-list ui-sortable">
|
<ul id="tasks-users" class="task-list ui-sortable">
|
||||||
|
@ -27,7 +27,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="panel panel-default">
|
<div class="panel panel-default">
|
||||||
<div class="panel-heading">程序错误<a href="javascript:;" class="pull-right fa fa-refresh" data-category="1"></a></div>
|
<div class="panel-heading">程序错误<a href="javascript:;" class="pull-right fa fa-refresh" data-category="apps"></a></div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<div class="tasks-widget">
|
<div class="tasks-widget">
|
||||||
<ul id="tasks-app" class="task-list ui-sortable">
|
<ul id="tasks-app" class="task-list ui-sortable">
|
||||||
|
@ -36,7 +36,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="panel panel-default">
|
<div class="panel panel-default">
|
||||||
<div class="panel-heading">数据库错误<span class="pull-right"><a href="javascript:;" class="fa fa-refresh" data-category="2"></a></span></div>
|
<div class="panel-heading">数据库错误<span class="pull-right"><a href="javascript:;" class="fa fa-refresh" data-category="dbs"></a></span></div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<div class="tasks-widget">
|
<div class="tasks-widget">
|
||||||
<ul id="tasks-db" class="task-list ui-sortable">
|
<ul id="tasks-db" class="task-list ui-sortable">
|
||||||
|
|
|
@ -23,119 +23,95 @@
|
||||||
}
|
}
|
||||||
@if (!Model.ShowMenu)
|
@if (!Model.ShowMenu)
|
||||||
{
|
{
|
||||||
<!-- notification start -->
|
<!-- notification start -->
|
||||||
<ul class="notify-row">
|
<ul class="notify-row">
|
||||||
<!-- settings start -->
|
<!-- tasks start -->
|
||||||
@if (Model.TaskCount > 0)
|
<li class="dropdown">
|
||||||
{
|
<a data-toggle="dropdown" class="dropdown-toggle" href="#">
|
||||||
<li class="dropdown">
|
<i class="fa fa-tasks"></i>
|
||||||
<a data-toggle="dropdown" class="dropdown-toggle" href="#">
|
<span class="badge bg-success"></span>
|
||||||
<i class="fa fa-tasks"></i>
|
</a>
|
||||||
<span class="badge bg-success">@Model.TaskCount</span>
|
<ul class="dropdown-menu tasks-bar">
|
||||||
</a>
|
<div class="notify-arrow notify-arrow-green"></div>
|
||||||
<ul class="dropdown-menu tasks-bar">
|
<li>
|
||||||
<div class="notify-arrow notify-arrow-green"></div>
|
<p>您有 0 个未读的消息</p>
|
||||||
<li>
|
</li>
|
||||||
<p>您有 @Model.TaskCount 个未读的消息</p>
|
<li>
|
||||||
</li>
|
<a href="~/Admin/Tasks">查看所有消息</a>
|
||||||
@foreach (var task in Model.Tasks)
|
</li>
|
||||||
{
|
</ul>
|
||||||
var TaskProgress = task.TaskProgress * 100;
|
</li>
|
||||||
<li>
|
<!-- tasks end -->
|
||||||
<a href="~/Admin/Tasks?id=@task.ID">
|
|
||||||
<div>
|
|
||||||
<div class="desc">@task.TaskName</div>
|
|
||||||
<div class="percent">@TaskProgress%</div>
|
|
||||||
</div>
|
|
||||||
<div class="progress progress-striped">
|
|
||||||
<div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="@TaskProgress" aria-valuemin="0" aria-valuemax="100" style="width: @TaskProgress%">
|
|
||||||
<span class="sr-only">@TaskProgress% Complete</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
}
|
|
||||||
<li>
|
|
||||||
<a href="~/Admin/Tasks">查看所有消息</a>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</li>
|
|
||||||
}
|
|
||||||
<!-- settings end -->
|
|
||||||
<!-- message dropdown start-->
|
<!-- message dropdown start-->
|
||||||
@if (Model.MessageCount > 0)
|
<li class="dropdown">
|
||||||
{
|
<a data-toggle="dropdown" class="dropdown-toggle" href="#">
|
||||||
<li class="dropdown">
|
<i class="fa fa-envelope"></i>
|
||||||
<a data-toggle="dropdown" class="dropdown-toggle" href="#">
|
<span class="badge bg-important"></span>
|
||||||
<i class="fa fa-envelope-o"></i>
|
</a>
|
||||||
<span class="badge bg-important">@Model.MessageCount</span>
|
<ul class="dropdown-menu inbox">
|
||||||
</a>
|
<div class="notify-arrow notify-arrow-red"></div>
|
||||||
<ul class="dropdown-menu inbox">
|
<li>
|
||||||
<div class="notify-arrow notify-arrow-red"></div>
|
<p>您有 0 个未读的消息</p>
|
||||||
<li>
|
</li>
|
||||||
<p>您有 @Model.MessageCount 个未读的消息</p>
|
<li>
|
||||||
</li>
|
<a href="~/Admin/Messages">查看所有消息</a>
|
||||||
@foreach (var mess in Model.Messages)
|
</li>
|
||||||
{
|
</ul>
|
||||||
<li>
|
</li>
|
||||||
<a href="~/Admin/Messages?id=@mess.ID">
|
|
||||||
<span class="photo"><img alt="avatar" src="~/content/images/logo6.jpg"></span>
|
|
||||||
<span class="subject">
|
|
||||||
<span class="from">@mess.From</span>
|
|
||||||
<span class="time">@mess.Period</span>
|
|
||||||
</span>
|
|
||||||
<span class="message">@mess.Title</span>
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
}
|
|
||||||
<li>
|
|
||||||
<a href="~/Admin/Messages">查看所有消息</a>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</li>
|
|
||||||
}
|
|
||||||
<!-- message dropdown end -->
|
<!-- message dropdown end -->
|
||||||
<!-- notification dropdown start-->
|
<!-- users dropdown start-->
|
||||||
@if (Model.NotifiCount > 0)
|
<li class="dropdown">
|
||||||
{
|
<a data-toggle="dropdown" class="dropdown-toggle" href="#">
|
||||||
<li class="dropdown">
|
<i class="fa fa-user-plus"></i>
|
||||||
<a data-toggle="dropdown" class="dropdown-toggle" href="#">
|
<span id="msgHeaderUserBadge" class="badge bg-warning"></span>
|
||||||
<i class="fa fa-bell-o"></i>
|
</a>
|
||||||
<span class="badge bg-warning">@Model.NotifiCount</span>
|
<ul class="dropdown-menu notification">
|
||||||
</a>
|
<div class="notify-arrow notify-arrow-yellow"></div>
|
||||||
<ul class="dropdown-menu notification">
|
<li id="msgHeaderUserContent">
|
||||||
<div class="notify-arrow notify-arrow-yellow"></div>
|
<p>您有 <span id="msgHeaderUser">0</span> 条新通知</p>
|
||||||
<li>
|
</li>
|
||||||
<p>您有 @Model.NotifiCount 条新通知</p>
|
<li id="msgHeaderUserFooter">
|
||||||
</li>
|
<a href="~/Admin/Notifications">查看所有通知</a>
|
||||||
@foreach (var noti in Model.Notifications)
|
</li>
|
||||||
{
|
</ul>
|
||||||
<li>
|
</li>
|
||||||
<a href="~/Admin/Notifications?id=@noti.ID&category=@noti.Category">
|
<!-- users dropdown end -->
|
||||||
@if (noti.Category == "0")
|
<!-- apps dropdown start-->
|
||||||
{
|
<li class="dropdown">
|
||||||
<span class="label label-success"><i class="fa fa-plus"></i></span><div>@noti.Content</div><span class="small italic">@noti.Period</span>
|
<a data-toggle="dropdown" class="dropdown-toggle" href="#">
|
||||||
}
|
<i class="fa fa-bug"></i>
|
||||||
else if (noti.Category == "1")
|
<span class="badge bg-warning"></span>
|
||||||
{
|
</a>
|
||||||
<span class="label label-warning"><i class="fa fa-bell"></i></span><div>@noti.Content</div><span class="small italic">@noti.Period</span>
|
<ul class="dropdown-menu notification">
|
||||||
}
|
<div class="notify-arrow notify-arrow-yellow"></div>
|
||||||
else
|
<li>
|
||||||
{
|
<p>您有 0 条新通知</p>
|
||||||
<span class="label label-danger"><i class="fa fa-bolt"></i></span><div>@noti.Content</div><span class="small italic">@noti.Period</span>
|
</li>
|
||||||
}
|
<li>
|
||||||
</a>
|
<a href="~/Admin/Notifications">查看所有通知</a>
|
||||||
</li>
|
</li>
|
||||||
}
|
</ul>
|
||||||
<li>
|
</li>
|
||||||
<a href="~/Admin/Notifications">查看所有通知</a>
|
<!-- apps dropdown end -->
|
||||||
</li>
|
<!-- db dropdown start-->
|
||||||
</ul>
|
<li class="dropdown">
|
||||||
</li>
|
<a data-toggle="dropdown" class="dropdown-toggle" href="#">
|
||||||
}
|
<i class="fa fa-database"></i>
|
||||||
<!-- notification dropdown end -->
|
<span class="badge bg-warning"></span>
|
||||||
|
</a>
|
||||||
|
<ul class="dropdown-menu notification">
|
||||||
|
<div class="notify-arrow notify-arrow-yellow"></div>
|
||||||
|
<li>
|
||||||
|
<p>您有 0 条新通知</p>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<a href="~/Admin/Notifications">查看所有通知</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
<!-- db dropdown end -->
|
||||||
</ul>
|
</ul>
|
||||||
<!-- notification end -->
|
<!-- notification end -->
|
||||||
}
|
}
|
||||||
<!--search & user info start-->
|
<!--search & user info start-->
|
||||||
<ul class="pull-right top-menu">
|
<ul class="pull-right top-menu">
|
||||||
|
@ -154,7 +130,7 @@
|
||||||
<div class="arrow-up"></div>
|
<div class="arrow-up"></div>
|
||||||
<li><a href="~/Admin/Infos"><i class=" fa fa-suitcase"></i>个人中心</a></li>
|
<li><a href="~/Admin/Infos"><i class=" fa fa-suitcase"></i>个人中心</a></li>
|
||||||
<li><a href="~/Admin/Index"><i class="fa fa-cog"></i>设置</a></li>
|
<li><a href="~/Admin/Index"><i class="fa fa-cog"></i>设置</a></li>
|
||||||
<li><a href="~/Admin/Notifications"><i class="fa fa-bell"></i>通知<span class="badge bg-success">@Model.NotifiCount</span></a></li>
|
<li><a href="~/Admin/Notifications"><i class="fa fa-bell"></i>通知<span id="logoutNoti" class="badge bg-success"></span></a></li>
|
||||||
<li><a href="~/Home/Logout"><i class="fa fa-key"></i>注销</a></li>
|
<li><a href="~/Home/Logout"><i class="fa fa-key"></i>注销</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
@ -18,22 +18,23 @@ namespace Bootstrap.DataAccess
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
try
|
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))
|
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("@AppDomainName", AppDomain.CurrentDomain.FriendlyName, ParameterDirection.Input));
|
||||||
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@ErrorPage", additionalInfo["ErrorPage"], 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("@UserID", DBAccess.ToDBValue(additionalInfo["UserId"]), ParameterDirection.Input));
|
||||||
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@UserIp", additionalInfo["UserIp"], 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("@Message", ex.Message, ParameterDirection.Input));
|
||||||
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@StackTrace", DBAccess.ToDBValue(ex.StackTrace), ParameterDirection.Input));
|
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@StackTrace", DBAccess.ToDBValue(ex.StackTrace), ParameterDirection.Input));
|
||||||
DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd);
|
DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd);
|
||||||
}
|
}
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
}
|
||||||
catch
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
throw new Exception("Excetion Log Error");
|
throw new Exception("Excetion Log Error", e);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,46 @@
|
||||||
using System;
|
using System;
|
||||||
namespace Bootstrap.DataAccess
|
namespace Bootstrap.DataAccess
|
||||||
{
|
{
|
||||||
public class Exceptions
|
/// <summary>
|
||||||
{
|
///
|
||||||
public int ID { get; set; }
|
/// </summary>
|
||||||
public string AppDomainName { get; set; }
|
public class Exceptions
|
||||||
public string ErrorPage { get; set; }
|
{
|
||||||
public string UserID { get; set; }
|
/// <summary>
|
||||||
public string UserIp { get; set; }
|
///
|
||||||
public string Message { get; set; }
|
/// </summary>
|
||||||
public string StackTrace { get; set; }
|
public int ID { get; set; }
|
||||||
public DateTime LogTime { get; set; }
|
/// <summary>
|
||||||
}
|
///
|
||||||
}
|
/// </summary>
|
||||||
|
public string AppDomainName { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public string ErrorPage { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public string UserID { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public string UserIp { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public string Message { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public string StackTrace { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public DateTime LogTime { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public string ExceptionType { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -51,9 +51,7 @@ namespace Bootstrap.DataAccess
|
||||||
return notifications;
|
return notifications;
|
||||||
|
|
||||||
}, CacheSection.RetrieveDescByKey(RetrieveNotificationsDataKey));
|
}, 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();
|
notifies.AsParallel().ForAll(n =>
|
||||||
var ret = users.Union(notifies);
|
|
||||||
ret.AsParallel().ForAll(n =>
|
|
||||||
{
|
{
|
||||||
var ts = DateTime.Now - n.RegisterTime;
|
var ts = DateTime.Now - n.RegisterTime;
|
||||||
if (ts.TotalMinutes < 5) n.Period = "刚刚";
|
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.Hours > 0) n.Period = string.Format("{0}小时", ts.Hours);
|
||||||
else if (ts.Minutes > 0) n.Period = string.Format("{0}分钟", ts.Minutes);
|
else if (ts.Minutes > 0) n.Period = string.Format("{0}分钟", ts.Minutes);
|
||||||
});
|
});
|
||||||
return ret.OrderByDescending(n => n.RegisterTime);
|
return notifies.OrderByDescending(n => n.RegisterTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 点击某一行用户注册通知的处理成功操作
|
/// 点击某一行用户注册通知的处理成功操作
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -89,5 +86,31 @@ namespace Bootstrap.DataAccess
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="noti"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,7 +103,7 @@ namespace Bootstrap.DataAccess
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static IEnumerable<User> RetrieveNewUsers()
|
public static IEnumerable<User> 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";
|
string sql = "select ID, UserName, DisplayName, RegisterTime, [Description] from Users Where ApprovedTime is null and RejectedTime is null";
|
||||||
List<User> Users = new List<User>();
|
List<User> Users = new List<User>();
|
||||||
|
@ -128,7 +128,6 @@ namespace Bootstrap.DataAccess
|
||||||
catch (Exception ex) { ExceptionManager.Publish(ex); }
|
catch (Exception ex) { ExceptionManager.Publish(ex); }
|
||||||
return Users;
|
return Users;
|
||||||
}, CacheSection.RetrieveDescByKey(RetrieveNewUsersDataKey));
|
}, CacheSection.RetrieveDescByKey(RetrieveNewUsersDataKey));
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -257,6 +257,7 @@ CREATE TABLE [dbo].[Exceptions](
|
||||||
[ErrorPage] [varchar](50) NOT NULL,
|
[ErrorPage] [varchar](50) NOT NULL,
|
||||||
[UserID] [varchar](50) NOT NULL,
|
[UserID] [varchar](50) NOT NULL,
|
||||||
[UserIp] [varchar](15) NOT NULL,
|
[UserIp] [varchar](15) NOT NULL,
|
||||||
|
[ExceptionType] [nvarchar](max) NOT NULL,
|
||||||
[Message] [nvarchar](max) NOT NULL,
|
[Message] [nvarchar](max) NOT NULL,
|
||||||
[StackTrace] [nvarchar](max) NOT NULL,
|
[StackTrace] [nvarchar](max) NOT NULL,
|
||||||
[LogTime] [datetime] NOT NULL,
|
[LogTime] [datetime] NOT NULL,
|
||||||
|
|
Loading…
Reference in New Issue