diff --git a/Bootstrap.Admin/Controllers/LoginController.cs b/Bootstrap.Admin/Controllers/LoginController.cs
index 742b4749..265a2642 100644
--- a/Bootstrap.Admin/Controllers/LoginController.cs
+++ b/Bootstrap.Admin/Controllers/LoginController.cs
@@ -36,9 +36,8 @@ namespace Bootstrap.Admin.Controllers
string password = user.password;
if (LgbPrincipal.Authenticate(userName, password) || BootstrapUser.Authenticate(userName, password))
{
- var interval = int.Parse(Math.Round(FormsAuthentication.Timeout.TotalSeconds).ToString(CultureInfo.InvariantCulture));
- var token = CacheManager.AddOrUpdate(string.Format("WebApi-{0}", userName), interval, k => new LoginInfo() { UserName = userName, Token = Guid.NewGuid().ToString() }, (k, info) => info, "WebApi 数据缓存");
- CacheManager.AddOrUpdate(token.Token, interval, k => token, (k, info) => info, "Token 数据缓存");
+ var token = CacheManager.AddOrUpdate(string.Format("WebApi-{0}", userName), k => new LoginInfo() { UserName = userName, Token = Guid.NewGuid().ToString() }, (k, info) => info, "WebApi");
+ CacheManager.AddOrUpdate(token.Token, k => token, (k, info) => info, "Token");
return token;
}
return new LoginInfo() { UserName = userName };
diff --git a/Bootstrap.DataAccess/DictHelper.cs b/Bootstrap.DataAccess/DictHelper.cs
index 61557ae6..152f6d42 100644
--- a/Bootstrap.DataAccess/DictHelper.cs
+++ b/Bootstrap.DataAccess/DictHelper.cs
@@ -1,6 +1,5 @@
using Bootstrap.Security;
using Longbow.Caching;
-using Longbow.Caching.Configuration;
using Longbow.ExceptionManagement;
using System;
using System.Collections.Generic;
@@ -123,7 +122,7 @@ namespace Bootstrap.DataAccess
///
public static IEnumerable RetrieveCategories()
{
- return CacheManager.GetOrAdd(RetrieveCategoryDataKey, CacheSection.RetrieveIntervalByKey(RetrieveCategoryDataKey), key =>
+ return CacheManager.GetOrAdd(RetrieveCategoryDataKey, key =>
{
var ret = new List();
string sql = "select distinct Category from Dicts";
@@ -140,7 +139,7 @@ namespace Bootstrap.DataAccess
}
catch (Exception ex) { ExceptionManager.Publish(ex); }
return ret;
- }, CacheSection.RetrieveDescByKey(RetrieveCategoryDataKey));
+ });
}
///
///
diff --git a/Bootstrap.DataAccess/ExceptionHelper.cs b/Bootstrap.DataAccess/ExceptionHelper.cs
index 1e9c4d81..44389332 100644
--- a/Bootstrap.DataAccess/ExceptionHelper.cs
+++ b/Bootstrap.DataAccess/ExceptionHelper.cs
@@ -1,5 +1,4 @@
using Longbow.Caching;
-using Longbow.Caching.Configuration;
using Longbow.Data;
using Longbow.ExceptionManagement;
using System;
@@ -53,7 +52,7 @@ namespace Bootstrap.DataAccess
///
public static IEnumerable RetrieveExceptions()
{
- return CacheManager.GetOrAdd(RetrieveExceptionsDataKey, CacheSection.RetrieveIntervalByKey(RetrieveExceptionsDataKey), key =>
+ return CacheManager.GetOrAdd(RetrieveExceptionsDataKey, key =>
{
string sql = "select top 1000 * from Exceptions order by LogTime desc";
List exceptions = new List();
@@ -81,7 +80,7 @@ namespace Bootstrap.DataAccess
}
catch (Exception ex) { ExceptionManager.Publish(ex); }
return exceptions;
- }, CacheSection.RetrieveDescByKey(RetrieveExceptionsDataKey));
+ });
}
}
}
diff --git a/Bootstrap.DataAccess/GroupHelper.cs b/Bootstrap.DataAccess/GroupHelper.cs
index 7bcf38e0..6fb31320 100644
--- a/Bootstrap.DataAccess/GroupHelper.cs
+++ b/Bootstrap.DataAccess/GroupHelper.cs
@@ -1,5 +1,4 @@
using Longbow.Caching;
-using Longbow.Caching.Configuration;
using Longbow.Data;
using Longbow.ExceptionManagement;
using System;
@@ -27,7 +26,7 @@ namespace Bootstrap.DataAccess
///
public static IEnumerable RetrieveGroups(int id = 0)
{
- var ret = CacheManager.GetOrAdd(RetrieveGroupsDataKey, CacheSection.RetrieveIntervalByKey(RetrieveGroupsDataKey), key =>
+ var ret = CacheManager.GetOrAdd(RetrieveGroupsDataKey, key =>
{
string sql = "select * from Groups";
List groups = new List();
@@ -49,7 +48,7 @@ namespace Bootstrap.DataAccess
}
catch (Exception ex) { ExceptionManager.Publish(ex); }
return groups;
- }, CacheSection.RetrieveDescByKey(RetrieveGroupsDataKey));
+ });
return id == 0 ? ret : ret.Where(t => id == t.Id);
}
///
@@ -115,7 +114,7 @@ namespace Bootstrap.DataAccess
public static IEnumerable RetrieveGroupsByUserId(int userId)
{
string key = string.Format("{0}-{1}", RetrieveGroupsByUserIdDataKey, userId);
- var ret = CacheManager.GetOrAdd(key, CacheSection.RetrieveIntervalByKey(RetrieveGroupsByUserIdDataKey), k =>
+ var ret = CacheManager.GetOrAdd(key, k =>
{
string sql = "select g.ID,g.GroupName,g.[Description],case ug.GroupID when g.ID then 'checked' else '' end [status] from Groups g left join UserGroup ug on g.ID=ug.GroupID and UserID=@UserID";
List groups = new List();
@@ -139,7 +138,7 @@ namespace Bootstrap.DataAccess
}
catch (Exception ex) { ExceptionManager.Publish(ex); }
return groups;
- }, CacheSection.RetrieveDescByKey(RetrieveGroupsByUserIdDataKey));
+ }, RetrieveGroupsByUserIdDataKey);
return ret;
}
///
@@ -197,7 +196,7 @@ namespace Bootstrap.DataAccess
public static IEnumerable RetrieveGroupsByRoleId(int roleId)
{
string k = string.Format("{0}-{1}", RetrieveGroupsByRoleIdDataKey, roleId);
- return CacheManager.GetOrAdd(k, CacheSection.RetrieveIntervalByKey(RetrieveGroupsByRoleIdDataKey), key =>
+ return CacheManager.GetOrAdd(k, key =>
{
List groups = new List();
string sql = "select g.ID,g.GroupName,g.[Description],case rg.GroupID when g.ID then 'checked' else '' end [status] from Groups g left join RoleGroup rg on g.ID=rg.GroupID and RoleID=@RoleID";
@@ -221,7 +220,7 @@ namespace Bootstrap.DataAccess
}
catch (Exception ex) { ExceptionManager.Publish(ex); }
return groups;
- }, CacheSection.RetrieveDescByKey(RetrieveGroupsByRoleIdDataKey));
+ }, RetrieveGroupsByRoleIdDataKey);
}
///
/// 根据角色ID以及选定的部门ID,保到角色部门表
diff --git a/Bootstrap.DataAccess/LogHelper.cs b/Bootstrap.DataAccess/LogHelper.cs
index 4b01a46a..f76d93cc 100644
--- a/Bootstrap.DataAccess/LogHelper.cs
+++ b/Bootstrap.DataAccess/LogHelper.cs
@@ -1,5 +1,4 @@
using Longbow.Caching;
-using Longbow.Caching.Configuration;
using Longbow.ExceptionManagement;
using System;
using System.Collections.Generic;
@@ -20,7 +19,7 @@ namespace Bootstrap.DataAccess
///
public static IEnumerable RetrieveLogs(string tId = null)
{
- var ret = CacheManager.GetOrAdd(RetrieveLogsDataKey, CacheSection.RetrieveIntervalByKey(RetrieveLogsDataKey), key =>
+ var ret = CacheManager.GetOrAdd(RetrieveLogsDataKey, key =>
{
string sql = "select top 1000 * from Logs";
List logs = new List();
@@ -46,7 +45,7 @@ namespace Bootstrap.DataAccess
}
catch (Exception ex) { ExceptionManager.Publish(ex); }
return logs;
- }, CacheSection.RetrieveDescByKey(RetrieveLogsDataKey));
+ });
return string.IsNullOrEmpty(tId) ? ret : ret.Where(t => tId.Equals(t.Id.ToString(), StringComparison.OrdinalIgnoreCase));
}
///
diff --git a/Bootstrap.DataAccess/MenuHelper.cs b/Bootstrap.DataAccess/MenuHelper.cs
index 93390a9b..8f3adbac 100644
--- a/Bootstrap.DataAccess/MenuHelper.cs
+++ b/Bootstrap.DataAccess/MenuHelper.cs
@@ -1,6 +1,5 @@
using Bootstrap.Security;
using Longbow.Caching;
-using Longbow.Caching.Configuration;
using Longbow.Data;
using Longbow.ExceptionManagement;
using System;
@@ -91,7 +90,7 @@ namespace Bootstrap.DataAccess
public static IEnumerable RetrieveMenusByRoleId(int roleId)
{
string key = string.Format("{0}-{1}", RetrieveMenusByRoleIdDataKey, roleId);
- return CacheManager.GetOrAdd(key, CacheSection.RetrieveIntervalByKey(RetrieveMenusByRoleIdDataKey), k =>
+ return CacheManager.GetOrAdd(key, k =>
{
var menus = new List();
try
@@ -114,7 +113,7 @@ namespace Bootstrap.DataAccess
}
catch (Exception ex) { ExceptionManager.Publish(ex); }
return menus;
- }, CacheSection.RetrieveDescByKey(RetrieveMenusByRoleIdDataKey));
+ }, RetrieveMenusByRoleIdDataKey);
}
///
/// 通过角色ID保存当前授权菜单
diff --git a/Bootstrap.DataAccess/MessageHelper.cs b/Bootstrap.DataAccess/MessageHelper.cs
index a7a51033..150b1e59 100644
--- a/Bootstrap.DataAccess/MessageHelper.cs
+++ b/Bootstrap.DataAccess/MessageHelper.cs
@@ -1,6 +1,5 @@
using Longbow;
using Longbow.Caching;
-using Longbow.Caching.Configuration;
using Longbow.ExceptionManagement;
using System;
using System.Collections.Generic;
@@ -23,7 +22,7 @@ namespace Bootstrap.DataAccess
///
private static IEnumerable RetrieveMessages(string userName)
{
- var messageRet = CacheManager.GetOrAdd(RetrieveMessageDataKey, CacheSection.RetrieveIntervalByKey(RetrieveMessageDataKey), key =>
+ var messageRet = CacheManager.GetOrAdd(RetrieveMessageDataKey, key =>
{
string sql = "select m.*, d.Name, isnull(i.Code + u.Icon, '~/Content/images/uploader/default.jpg'), u.DisplayName from [Messages] m left join Dicts d on m.Label = d.Code and d.Category = N'消息标签' and d.Define = 0 left join Dicts i on i.Category = N'头像地址' and i.Name = N'头像路径' and i.Define = 0 inner join Users u on m.[From] = u.UserName where [To] = @UserName or [From] = @UserName order by m.SendTime desc";
List messages = new List();
@@ -57,7 +56,7 @@ namespace Bootstrap.DataAccess
catch (Exception ex) { ExceptionManager.Publish(ex); }
return messages;
- }, CacheSection.RetrieveDescByKey(RetrieveMessageDataKey));
+ });
return messageRet.OrderByDescending(n => n.SendTime);
}
///
diff --git a/Bootstrap.DataAccess/NotificationHelper.cs b/Bootstrap.DataAccess/NotificationHelper.cs
index 86676529..ea7be805 100644
--- a/Bootstrap.DataAccess/NotificationHelper.cs
+++ b/Bootstrap.DataAccess/NotificationHelper.cs
@@ -1,6 +1,5 @@
using Longbow;
using Longbow.Caching;
-using Longbow.Caching.Configuration;
using Longbow.ExceptionManagement;
using System;
using System.Collections.Generic;
@@ -22,7 +21,7 @@ namespace Bootstrap.DataAccess
///
public static IEnumerable RetrieveNotifications()
{
- var notifies = CacheManager.GetOrAdd(RetrieveNotificationsDataKey, CacheSection.RetrieveIntervalByKey(RetrieveNotificationsDataKey), key =>
+ var notifies = CacheManager.GetOrAdd(RetrieveNotificationsDataKey, key =>
{
string sql = "select * from Notifications";
List notifications = new List();
@@ -51,7 +50,7 @@ namespace Bootstrap.DataAccess
catch (Exception ex) { ExceptionManager.Publish(ex); }
return notifications;
- }, CacheSection.RetrieveDescByKey(RetrieveNotificationsDataKey));
+ });
notifies.AsParallel().ForAll(n =>
{
var ts = DateTime.Now - n.RegisterTime;
diff --git a/Bootstrap.DataAccess/RoleHelper.cs b/Bootstrap.DataAccess/RoleHelper.cs
index 9cc33402..c217598b 100644
--- a/Bootstrap.DataAccess/RoleHelper.cs
+++ b/Bootstrap.DataAccess/RoleHelper.cs
@@ -27,7 +27,7 @@ namespace Bootstrap.DataAccess
///
public static IEnumerable RetrieveRoles(int id = 0)
{
- var ret = CacheManager.GetOrAdd(RetrieveRolesDataKey, CacheSection.RetrieveIntervalByKey(RetrieveRolesDataKey), key =>
+ var ret = CacheManager.GetOrAdd(RetrieveRolesDataKey, key =>
{
string sql = "select * from Roles";
List roles = new List();
@@ -49,7 +49,7 @@ namespace Bootstrap.DataAccess
}
catch (Exception ex) { ExceptionManager.Publish(ex); }
return roles;
- }, CacheSection.RetrieveDescByKey(RetrieveRolesDataKey));
+ });
return id == 0 ? ret : ret.Where(t => id == t.Id);
}
///
@@ -107,7 +107,7 @@ namespace Bootstrap.DataAccess
public static IEnumerable RetrieveRolesByUserId(int userId)
{
string key = string.Format("{0}-{1}", RetrieveRolesByUserIdDataKey, userId);
- return CacheManager.GetOrAdd(key, CacheSection.RetrieveIntervalByKey(RetrieveRolesByUserIdDataKey), k =>
+ return CacheManager.GetOrAdd(key, k =>
{
List roles = new List();
string sql = "select r.ID, r.RoleName, r.[Description], case ur.RoleID when r.ID then 'checked' else '' end [status] from Roles r left join UserRole ur on r.ID = ur.RoleID and UserID = @UserID";
@@ -131,7 +131,7 @@ namespace Bootstrap.DataAccess
}
catch (Exception ex) { ExceptionManager.Publish(ex); }
return roles;
- }, CacheSection.RetrieveDescByKey(RetrieveRolesByUserIdDataKey));
+ }, RetrieveRolesByUserIdDataKey);
}
///
/// 删除角色表
@@ -196,7 +196,7 @@ namespace Bootstrap.DataAccess
public static IEnumerable RetrieveRolesByMenuId(int menuId)
{
string key = string.Format("{0}-{1}", RetrieveRolesByMenuIdDataKey, menuId);
- var ret = CacheManager.GetOrAdd(key, CacheSection.RetrieveIntervalByKey(RetrieveRolesByMenuIdDataKey), k =>
+ var ret = CacheManager.GetOrAdd(key, k =>
{
string sql = "select r.ID, r.RoleName, r.[Description], case ur.RoleID when r.ID then 'checked' else '' end [status] from Roles r left join NavigationRole ur on r.ID = ur.RoleID and NavigationID = @NavigationID";
List roles = new List();
@@ -220,7 +220,7 @@ namespace Bootstrap.DataAccess
}
catch (Exception ex) { ExceptionManager.Publish(ex); }
return roles;
- }, CacheSection.RetrieveDescByKey(RetrieveRolesByMenuIdDataKey));
+ }, RetrieveRolesByMenuIdDataKey);
return ret;
}
public static bool SavaRolesByMenuId(int id, string roleIds)
@@ -272,7 +272,7 @@ namespace Bootstrap.DataAccess
public static IEnumerable RetrieveRolesByGroupId(int groupId)
{
string key = string.Format("{0}-{1}", RetrieveRolesByGroupIdDataKey, groupId);
- return CacheManager.GetOrAdd(key, CacheSection.RetrieveIntervalByKey(RetrieveRolesByGroupIdDataKey), k =>
+ return CacheManager.GetOrAdd(key, k =>
{
List roles = new List();
string sql = "select r.ID, r.RoleName, r.[Description], case ur.RoleID when r.ID then 'checked' else '' end [status] from Roles r left join RoleGroup ur on r.ID = ur.RoleID and GroupID = @GroupID";
@@ -296,7 +296,7 @@ namespace Bootstrap.DataAccess
}
catch (Exception ex) { ExceptionManager.Publish(ex); }
return roles;
- }, CacheSection.RetrieveDescByKey(RetrieveRolesByGroupIdDataKey));
+ }, RetrieveRolesByGroupIdDataKey);
}
///
diff --git a/Bootstrap.DataAccess/TaskHelper.cs b/Bootstrap.DataAccess/TaskHelper.cs
index f5904345..c009c1d3 100644
--- a/Bootstrap.DataAccess/TaskHelper.cs
+++ b/Bootstrap.DataAccess/TaskHelper.cs
@@ -1,5 +1,4 @@
using Longbow.Caching;
-using Longbow.Caching.Configuration;
using Longbow.ExceptionManagement;
using System;
using System.Collections.Generic;
@@ -17,7 +16,7 @@ namespace Bootstrap.DataAccess
///
public static IEnumerable RetrieveTasks()
{
- return CacheManager.GetOrAdd(RetrieveTasksDataKey, CacheSection.RetrieveIntervalByKey(RetrieveTasksDataKey), key =>
+ return CacheManager.GetOrAdd(RetrieveTasksDataKey, key =>
{
string sql = "select top 1000 t.*, u.DisplayName from Tasks t inner join Users u on t.UserName = u.UserName order by AssignTime desc";
List tasks = new List();
@@ -44,7 +43,7 @@ namespace Bootstrap.DataAccess
}
catch (Exception ex) { ExceptionManager.Publish(ex); }
return tasks;
- }, CacheSection.RetrieveDescByKey(RetrieveTasksDataKey));
+ });
}
}
}
diff --git a/Bootstrap.DataAccess/UserHelper.cs b/Bootstrap.DataAccess/UserHelper.cs
index 1bb51d11..faed5f4d 100644
--- a/Bootstrap.DataAccess/UserHelper.cs
+++ b/Bootstrap.DataAccess/UserHelper.cs
@@ -1,7 +1,6 @@
using Bootstrap.Security;
using Longbow;
using Longbow.Caching;
-using Longbow.Caching.Configuration;
using Longbow.Data;
using Longbow.ExceptionManagement;
using Longbow.Security;
@@ -30,7 +29,7 @@ namespace Bootstrap.DataAccess
///
public static IEnumerable RetrieveUsers()
{
- return CacheManager.GetOrAdd(BootstrapUser.RetrieveUsersDataKey, CacheSection.RetrieveIntervalByKey(BootstrapUser.RetrieveUsersDataKey), key =>
+ return CacheManager.GetOrAdd(BootstrapUser.RetrieveUsersDataKey, key =>
{
List users = new List();
DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, "select ID, UserName, DisplayName, RegisterTime, ApprovedTime, ApprovedBy, Description from Users Where ApprovedTime is not null");
@@ -55,7 +54,7 @@ namespace Bootstrap.DataAccess
}
catch (Exception ex) { ExceptionManager.Publish(ex); }
return users;
- }, CacheSection.RetrieveDescByKey(BootstrapUser.RetrieveUsersDataKey));
+ });
}
///
/// 查询所有的新注册用户
@@ -63,7 +62,7 @@ namespace Bootstrap.DataAccess
///
public static IEnumerable RetrieveNewUsers()
{
- return CacheManager.GetOrAdd(RetrieveNewUsersDataKey, CacheSection.RetrieveIntervalByKey(RetrieveNewUsersDataKey), key =>
+ return CacheManager.GetOrAdd(RetrieveNewUsersDataKey, key =>
{
string sql = "select ID, UserName, DisplayName, RegisterTime, [Description] from Users Where ApprovedTime is null and RejectedTime is null order by RegisterTime desc";
List users = new List();
@@ -87,7 +86,7 @@ namespace Bootstrap.DataAccess
}
catch (Exception ex) { ExceptionManager.Publish(ex); }
return users;
- }, CacheSection.RetrieveDescByKey(RetrieveNewUsersDataKey));
+ });
}
///
/// 删除用户
@@ -161,7 +160,7 @@ namespace Bootstrap.DataAccess
public static IEnumerable RetrieveUsersByRoleId(int roleId)
{
string key = string.Format("{0}-{1}", RetrieveUsersByRoleIdDataKey, roleId);
- return CacheManager.GetOrAdd(key, CacheSection.RetrieveIntervalByKey(RetrieveUsersByNameDataKey), k =>
+ return CacheManager.GetOrAdd(key, k =>
{
List users = new List();
string sql = "select u.ID, u.UserName, u.DisplayName, case ur.UserID when u.ID then 'checked' else '' end [status] from Users u left join UserRole ur on u.ID = ur.UserID and RoleID = @RoleID where u.ApprovedTime is not null";
@@ -185,7 +184,7 @@ namespace Bootstrap.DataAccess
}
catch (Exception ex) { ExceptionManager.Publish(ex); }
return users;
- }, CacheSection.RetrieveDescByKey(RetrieveUsersByRoleIdDataKey));
+ }, RetrieveUsersByRoleIdDataKey);
}
///
/// 通过角色ID保存当前授权用户(插入)
@@ -239,7 +238,7 @@ namespace Bootstrap.DataAccess
public static IEnumerable RetrieveUsersByGroupId(int groupId)
{
string key = string.Format("{0}-{1}", RetrieveUsersByGroupIdDataKey, groupId);
- return CacheManager.GetOrAdd(key, CacheSection.RetrieveIntervalByKey(RetrieveUsersByGroupIdDataKey), k =>
+ return CacheManager.GetOrAdd(key, k =>
{
List users = new List();
string sql = "select u.ID, u.UserName, u.DisplayName, case ur.UserID when u.ID then 'checked' else '' end [status] from Users u left join UserGroup ur on u.ID = ur.UserID and GroupID =@groupId where u.ApprovedTime is not null";
@@ -263,7 +262,7 @@ namespace Bootstrap.DataAccess
}
catch (Exception ex) { ExceptionManager.Publish(ex); }
return users;
- }, CacheSection.RetrieveDescByKey(RetrieveUsersByRoleIdDataKey));
+ }, RetrieveUsersByRoleIdDataKey);
}
///
/// 通过部门ID保存当前授权用户(插入)