重构代码:移动缓存代码到Helper类中
This commit is contained in:
parent
018e1d1851
commit
32bd9d2aa3
|
@ -56,7 +56,7 @@ namespace Bootstrap.DataAccess.SQLite
|
|||
cmd.Parameters.Add(DbAccessManager.DBAccess.CreateParameter("@Message", ex.Message));
|
||||
cmd.Parameters.Add(DbAccessManager.DBAccess.CreateParameter("@StackTrace", DbAdapterManager.ToDBValue(ex.StackTrace)));
|
||||
DbAccessManager.DBAccess.ExecuteNonQuery(cmd);
|
||||
CacheManager.Clear(RetrieveExceptionsDataKey);
|
||||
CacheManager.Clear(ExceptionsHelper.RetrieveExceptionsDataKey);
|
||||
ClearExceptions();
|
||||
}
|
||||
}
|
||||
|
@ -66,31 +66,28 @@ namespace Bootstrap.DataAccess.SQLite
|
|||
/// <returns></returns>
|
||||
public override IEnumerable<DataAccess.Exceptions> RetrieveExceptions()
|
||||
{
|
||||
return CacheManager.GetOrAdd(RetrieveExceptionsDataKey, key =>
|
||||
string sql = "select * from Exceptions where LogTime > datetime('now', 'localtime', '-7 day') order by LogTime desc";
|
||||
List<Exceptions> exceptions = new List<Exceptions>();
|
||||
DbCommand cmd = DbAccessManager.DBAccess.CreateCommand(CommandType.Text, sql);
|
||||
using (DbDataReader reader = DbAccessManager.DBAccess.ExecuteReader(cmd))
|
||||
{
|
||||
string sql = "select * from Exceptions where LogTime > datetime('now', 'localtime', '-7 day') order by LogTime desc";
|
||||
List<Exceptions> exceptions = new List<Exceptions>();
|
||||
DbCommand cmd = DbAccessManager.DBAccess.CreateCommand(CommandType.Text, sql);
|
||||
using (DbDataReader reader = DbAccessManager.DBAccess.ExecuteReader(cmd))
|
||||
while (reader.Read())
|
||||
{
|
||||
while (reader.Read())
|
||||
exceptions.Add(new Exceptions()
|
||||
{
|
||||
exceptions.Add(new Exceptions()
|
||||
{
|
||||
Id = LgbConvert.ReadValue(reader[0], 0),
|
||||
AppDomainName = (string)reader[1],
|
||||
ErrorPage = reader.IsDBNull(2) ? string.Empty : (string)reader[2],
|
||||
UserId = reader.IsDBNull(3) ? string.Empty : (string)reader[3],
|
||||
UserIp = reader.IsDBNull(4) ? string.Empty : (string)reader[4],
|
||||
ExceptionType = (string)reader[5],
|
||||
Message = (string)reader[6],
|
||||
StackTrace = (string)reader[7],
|
||||
LogTime = LgbConvert.ReadValue(reader[8], DateTime.MinValue)
|
||||
});
|
||||
}
|
||||
Id = LgbConvert.ReadValue(reader[0], 0),
|
||||
AppDomainName = (string)reader[1],
|
||||
ErrorPage = reader.IsDBNull(2) ? string.Empty : (string)reader[2],
|
||||
UserId = reader.IsDBNull(3) ? string.Empty : (string)reader[3],
|
||||
UserIp = reader.IsDBNull(4) ? string.Empty : (string)reader[4],
|
||||
ExceptionType = (string)reader[5],
|
||||
Message = (string)reader[6],
|
||||
StackTrace = (string)reader[7],
|
||||
LogTime = LgbConvert.ReadValue(reader[8], DateTime.MinValue)
|
||||
});
|
||||
}
|
||||
return exceptions;
|
||||
});
|
||||
}
|
||||
return exceptions;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
using System.Linq;
|
||||
|
||||
namespace Bootstrap.DataAccess.SQLite
|
||||
{
|
||||
|
@ -21,30 +20,26 @@ namespace Bootstrap.DataAccess.SQLite
|
|||
/// <returns></returns>
|
||||
public override IEnumerable<DataAccess.Log> RetrieveLogs(string tId = null)
|
||||
{
|
||||
var ret = CacheManager.GetOrAdd(RetrieveLogsDataKey, key =>
|
||||
string sql = "select * from Logs where LogTime > datetime('now', 'localtime', '-7 day')";
|
||||
List<Log> logs = new List<Log>();
|
||||
DbCommand cmd = DbAccessManager.DBAccess.CreateCommand(CommandType.Text, sql);
|
||||
using (DbDataReader reader = DbAccessManager.DBAccess.ExecuteReader(cmd))
|
||||
{
|
||||
string sql = "select * from Logs where LogTime > datetime('now', 'localtime', '-7 day')";
|
||||
List<Log> logs = new List<Log>();
|
||||
DbCommand cmd = DbAccessManager.DBAccess.CreateCommand(CommandType.Text, sql);
|
||||
using (DbDataReader reader = DbAccessManager.DBAccess.ExecuteReader(cmd))
|
||||
while (reader.Read())
|
||||
{
|
||||
while (reader.Read())
|
||||
logs.Add(new Log()
|
||||
{
|
||||
logs.Add(new Log()
|
||||
{
|
||||
Id = LgbConvert.ReadValue(reader[0], 0),
|
||||
CRUD = (string)reader[1],
|
||||
UserName = (string)reader[2],
|
||||
LogTime = LgbConvert.ReadValue(reader[3], DateTime.MinValue),
|
||||
ClientIp = (string)reader[4],
|
||||
ClientAgent = (string)reader[5],
|
||||
RequestUrl = (string)reader[6]
|
||||
});
|
||||
}
|
||||
Id = LgbConvert.ReadValue(reader[0], 0),
|
||||
CRUD = (string)reader[1],
|
||||
UserName = (string)reader[2],
|
||||
LogTime = LgbConvert.ReadValue(reader[3], DateTime.MinValue),
|
||||
ClientIp = (string)reader[4],
|
||||
ClientAgent = (string)reader[5],
|
||||
RequestUrl = (string)reader[6]
|
||||
});
|
||||
}
|
||||
return logs;
|
||||
});
|
||||
return string.IsNullOrEmpty(tId) ? ret : ret.Where(t => tId.Equals(t.Id.ToString(), StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
return logs;
|
||||
}
|
||||
/// <summary>
|
||||
/// 删除日志信息
|
||||
|
@ -79,7 +74,7 @@ namespace Bootstrap.DataAccess.SQLite
|
|||
cmd.Parameters.Add(DbAccessManager.DBAccess.CreateParameter("@RequestUrl", p.RequestUrl));
|
||||
ret = DbAccessManager.DBAccess.ExecuteNonQuery(cmd) == 1;
|
||||
}
|
||||
CacheManager.Clear(RetrieveLogsDataKey);
|
||||
CacheManager.Clear(LogHelper.RetrieveLogsDataKey);
|
||||
DeleteLogAsync();
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
using Longbow;
|
||||
using Longbow.Cache;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
using System.Linq;
|
||||
|
||||
namespace Bootstrap.DataAccess.SQLite
|
||||
{
|
||||
|
@ -20,38 +18,33 @@ namespace Bootstrap.DataAccess.SQLite
|
|||
/// <returns></returns>
|
||||
protected override IEnumerable<DataAccess.Message> RetrieveMessages(string userName)
|
||||
{
|
||||
var messageRet = CacheManager.GetOrAdd(RetrieveMessageDataKey, key =>
|
||||
string sql = "select m.*, d.Name, ifnull(i.Code + u.Icon, '~/images/uploader/default.jpg'), u.DisplayName from [Messages] m left join Dicts d on m.Label = d.Code and d.Category = '消息标签' and d.Define = 0 left join Dicts i on i.Category = '头像地址' and i.Name = '头像路径' 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<Message> messages = new List<Message>();
|
||||
DbCommand cmd = DbAccessManager.DBAccess.CreateCommand(CommandType.Text, sql);
|
||||
cmd.Parameters.Add(DbAccessManager.DBAccess.CreateParameter("@UserName", userName));
|
||||
using (DbDataReader reader = DbAccessManager.DBAccess.ExecuteReader(cmd))
|
||||
{
|
||||
string sql = "select m.*, d.Name, ifnull(i.Code + u.Icon, '~/images/uploader/default.jpg'), u.DisplayName from [Messages] m left join Dicts d on m.Label = d.Code and d.Category = '消息标签' and d.Define = 0 left join Dicts i on i.Category = '头像地址' and i.Name = '头像路径' 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<Message> messages = new List<Message>();
|
||||
DbCommand cmd = DbAccessManager.DBAccess.CreateCommand(CommandType.Text, sql);
|
||||
cmd.Parameters.Add(DbAccessManager.DBAccess.CreateParameter("@UserName", userName));
|
||||
using (DbDataReader reader = DbAccessManager.DBAccess.ExecuteReader(cmd))
|
||||
while (reader.Read())
|
||||
{
|
||||
while (reader.Read())
|
||||
messages.Add(new Message()
|
||||
{
|
||||
messages.Add(new Message()
|
||||
{
|
||||
Id = LgbConvert.ReadValue(reader[0], 0),
|
||||
Title = (string)reader[1],
|
||||
Content = (string)reader[2],
|
||||
From = (string)reader[3],
|
||||
To = (string)reader[4],
|
||||
SendTime = LgbConvert.ReadValue(reader[5], DateTime.MinValue),
|
||||
Status = (string)reader[6],
|
||||
Mark = LgbConvert.ReadValue(reader[7], 0),
|
||||
IsDelete = LgbConvert.ReadValue(reader[8], 0),
|
||||
Label = (string)reader[9],
|
||||
LabelName = LgbConvert.ReadValue(reader[10], string.Empty),
|
||||
FromIcon = (string)reader[11],
|
||||
FromDisplayName = (string)reader[12]
|
||||
});
|
||||
}
|
||||
Id = LgbConvert.ReadValue(reader[0], 0),
|
||||
Title = (string)reader[1],
|
||||
Content = (string)reader[2],
|
||||
From = (string)reader[3],
|
||||
To = (string)reader[4],
|
||||
SendTime = LgbConvert.ReadValue(reader[5], DateTime.MinValue),
|
||||
Status = (string)reader[6],
|
||||
Mark = LgbConvert.ReadValue(reader[7], 0),
|
||||
IsDelete = LgbConvert.ReadValue(reader[8], 0),
|
||||
Label = (string)reader[9],
|
||||
LabelName = LgbConvert.ReadValue(reader[10], string.Empty),
|
||||
FromIcon = (string)reader[11],
|
||||
FromDisplayName = (string)reader[12]
|
||||
});
|
||||
}
|
||||
return messages;
|
||||
|
||||
});
|
||||
return messageRet.OrderByDescending(n => n.SendTime);
|
||||
}
|
||||
return messages;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
using Longbow;
|
||||
using Longbow.Cache;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
|
@ -15,30 +14,27 @@ namespace Bootstrap.DataAccess.SQLite
|
|||
/// <returns></returns>
|
||||
public override IEnumerable<DataAccess.Task> RetrieveTasks()
|
||||
{
|
||||
return CacheManager.GetOrAdd(RetrieveTasksDataKey, key =>
|
||||
string sql = "select t.*, u.DisplayName from Tasks t inner join Users u on t.UserName = u.UserName order by AssignTime desc limit 1000";
|
||||
List<Task> tasks = new List<Task>();
|
||||
DbCommand cmd = DbAccessManager.DBAccess.CreateCommand(CommandType.Text, sql);
|
||||
using (DbDataReader reader = DbAccessManager.DBAccess.ExecuteReader(cmd))
|
||||
{
|
||||
string sql = "select t.*, u.DisplayName from Tasks t inner join Users u on t.UserName = u.UserName order by AssignTime desc limit 1000";
|
||||
List<Task> tasks = new List<Task>();
|
||||
DbCommand cmd = DbAccessManager.DBAccess.CreateCommand(CommandType.Text, sql);
|
||||
using (DbDataReader reader = DbAccessManager.DBAccess.ExecuteReader(cmd))
|
||||
while (reader.Read())
|
||||
{
|
||||
while (reader.Read())
|
||||
tasks.Add(new Task()
|
||||
{
|
||||
tasks.Add(new Task()
|
||||
{
|
||||
Id = LgbConvert.ReadValue(reader[0], 0),
|
||||
TaskName = (string)reader[1],
|
||||
AssignName = (string)reader[2],
|
||||
UserName = (string)reader[3],
|
||||
TaskTime = LgbConvert.ReadValue(reader[4], 0),
|
||||
TaskProgress = (double)reader[5],
|
||||
AssignTime = LgbConvert.ReadValue(reader[6], DateTime.MinValue),
|
||||
AssignDisplayName = (string)reader[7]
|
||||
});
|
||||
}
|
||||
Id = LgbConvert.ReadValue(reader[0], 0),
|
||||
TaskName = (string)reader[1],
|
||||
AssignName = (string)reader[2],
|
||||
UserName = (string)reader[3],
|
||||
TaskTime = LgbConvert.ReadValue(reader[4], 0),
|
||||
TaskProgress = (double)reader[5],
|
||||
AssignTime = LgbConvert.ReadValue(reader[6], DateTime.MinValue),
|
||||
AssignDisplayName = (string)reader[7]
|
||||
});
|
||||
}
|
||||
return tasks;
|
||||
});
|
||||
}
|
||||
return tasks;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
using Bootstrap.Security;
|
||||
using Longbow.Cache;
|
||||
using Longbow.Data;
|
||||
using Longbow.Security.Cryptography;
|
||||
using System;
|
||||
|
@ -8,7 +7,6 @@ using System.Data;
|
|||
using System.Data.Common;
|
||||
using System.Linq;
|
||||
|
||||
|
||||
namespace Bootstrap.DataAccess.SQLite
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -245,29 +243,25 @@ namespace Bootstrap.DataAccess.SQLite
|
|||
/// <returns></returns>
|
||||
public override BootstrapUser RetrieveUserByUserName(string userName)
|
||||
{
|
||||
var key = string.Format("{0}-{1}", RetrieveUsersByNameDataKey, userName);
|
||||
return CacheManager.GetOrAdd(key, k =>
|
||||
BootstrapUser user = null;
|
||||
var sql = "select UserName, DisplayName, case ifnull(d.Code, '') when '' then '~/images/uploader/' else d.Code end || ifnull(Icon, 'default.jpg') Icon, u.Css from Users u left join Dicts d on d.Define = '0' and d.Category = '头像地址' and Name = '头像路径' where ApprovedTime is not null and UserName = @UserName";
|
||||
var db = DbAccessManager.DBAccess;
|
||||
var cmd = db.CreateCommand(CommandType.Text, sql);
|
||||
cmd.Parameters.Add(db.CreateParameter("@UserName", userName));
|
||||
using (DbDataReader reader = db.ExecuteReader(cmd))
|
||||
{
|
||||
BootstrapUser user = null;
|
||||
var sql = "select UserName, DisplayName, case ifnull(d.Code, '') when '' then '~/images/uploader/' else d.Code end || ifnull(Icon, 'default.jpg') Icon, u.Css from Users u left join Dicts d on d.Define = '0' and d.Category = '头像地址' and Name = '头像路径' where ApprovedTime is not null and UserName = @UserName";
|
||||
var db = DbAccessManager.DBAccess;
|
||||
var cmd = db.CreateCommand(CommandType.Text, sql);
|
||||
cmd.Parameters.Add(db.CreateParameter("@UserName", userName));
|
||||
using (DbDataReader reader = db.ExecuteReader(cmd))
|
||||
if (reader.Read())
|
||||
{
|
||||
if (reader.Read())
|
||||
user = new BootstrapUser
|
||||
{
|
||||
user = new BootstrapUser
|
||||
{
|
||||
UserName = (string)reader[0],
|
||||
DisplayName = (string)reader[1],
|
||||
Icon = (string)reader[2],
|
||||
Css = reader.IsDBNull(3) ? string.Empty : (string)reader[3]
|
||||
};
|
||||
}
|
||||
UserName = (string)reader[0],
|
||||
DisplayName = (string)reader[1],
|
||||
Icon = (string)reader[2],
|
||||
Css = reader.IsDBNull(3) ? string.Empty : (string)reader[3]
|
||||
};
|
||||
}
|
||||
return user;
|
||||
}, RetrieveUsersByNameDataKey);
|
||||
}
|
||||
return user;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,54 +27,54 @@ namespace Bootstrap.DataAccess
|
|||
{
|
||||
roleIds.ToList().ForEach(id =>
|
||||
{
|
||||
cacheKeys.Add(string.Format("{0}-{1}", User.RetrieveUsersByRoleIdDataKey, id));
|
||||
cacheKeys.Add(string.Format("{0}-{1}", Group.RetrieveGroupsByRoleIdDataKey, id));
|
||||
cacheKeys.Add(string.Format("{0}-{1}", Menu.RetrieveMenusByRoleIdDataKey, id));
|
||||
cacheKeys.Add(string.Format("{0}-{1}", UserHelper.RetrieveUsersByRoleIdDataKey, id));
|
||||
cacheKeys.Add(string.Format("{0}-{1}", GroupHelper.RetrieveGroupsByRoleIdDataKey, id));
|
||||
cacheKeys.Add(string.Format("{0}-{1}", MenuHelper.RetrieveMenusByRoleIdDataKey, id));
|
||||
});
|
||||
cacheKeys.Add(Role.RetrieveRolesDataKey + "*");
|
||||
cacheKeys.Add(Menu.RetrieveMenusDataKey + "*");
|
||||
cacheKeys.Add(RoleHelper.RetrieveRolesDataKey + "*");
|
||||
cacheKeys.Add(MenuHelper.RetrieveMenusDataKey + "*");
|
||||
cacheKeys.Add(RetrieveAllRolesDataKey + "*");
|
||||
corsKeys.Add(Menu.RetrieveMenusDataKey + "*");
|
||||
corsKeys.Add(MenuHelper.RetrieveMenusDataKey + "*");
|
||||
}
|
||||
if (userIds != null)
|
||||
{
|
||||
userIds.ToList().ForEach(id =>
|
||||
{
|
||||
cacheKeys.Add(string.Format("{0}-{1}", Role.RetrieveRolesByUserIdDataKey, id));
|
||||
cacheKeys.Add(string.Format("{0}-{1}", Group.RetrieveGroupsByUserIdDataKey, id));
|
||||
cacheKeys.Add(Menu.RetrieveMenusDataKey + "*");
|
||||
corsKeys.Add(Menu.RetrieveMenusDataKey + "*");
|
||||
cacheKeys.Add(string.Format("{0}-{1}", RoleHelper.RetrieveRolesByUserIdDataKey, id));
|
||||
cacheKeys.Add(string.Format("{0}-{1}", GroupHelper.RetrieveGroupsByUserIdDataKey, id));
|
||||
cacheKeys.Add(MenuHelper.RetrieveMenusDataKey + "*");
|
||||
corsKeys.Add(MenuHelper.RetrieveMenusDataKey + "*");
|
||||
});
|
||||
cacheKeys.Add(User.RetrieveNewUsersDataKey + "*");
|
||||
cacheKeys.Add(User.RetrieveUsersDataKey + "*");
|
||||
corsKeys.Add(User.RetrieveUsersDataKey + "*");
|
||||
cacheKeys.Add(UserHelper.RetrieveNewUsersDataKey + "*");
|
||||
cacheKeys.Add(UserHelper.RetrieveUsersDataKey + "*");
|
||||
corsKeys.Add(UserHelper.RetrieveUsersDataKey + "*");
|
||||
}
|
||||
if (groupIds != null)
|
||||
{
|
||||
groupIds.ToList().ForEach(id =>
|
||||
{
|
||||
cacheKeys.Add(string.Format("{0}-{1}", Role.RetrieveRolesByGroupIdDataKey, id));
|
||||
cacheKeys.Add(string.Format("{0}-{1}", User.RetrieveUsersByGroupIdDataKey, id));
|
||||
cacheKeys.Add(string.Format("{0}-{1}", RoleHelper.RetrieveRolesByGroupIdDataKey, id));
|
||||
cacheKeys.Add(string.Format("{0}-{1}", UserHelper.RetrieveUsersByGroupIdDataKey, id));
|
||||
});
|
||||
cacheKeys.Add(Group.RetrieveGroupsDataKey + "*");
|
||||
cacheKeys.Add(Menu.RetrieveMenusDataKey + "*");
|
||||
corsKeys.Add(Menu.RetrieveMenusDataKey + "*");
|
||||
cacheKeys.Add(GroupHelper.RetrieveGroupsDataKey + "*");
|
||||
cacheKeys.Add(MenuHelper.RetrieveMenusDataKey + "*");
|
||||
corsKeys.Add(MenuHelper.RetrieveMenusDataKey + "*");
|
||||
cacheKeys.Add(RetrieveAllRolesDataKey + "*");
|
||||
}
|
||||
if (menuIds != null)
|
||||
{
|
||||
menuIds.ToList().ForEach(id =>
|
||||
{
|
||||
cacheKeys.Add(string.Format("{0}-{1}", Role.RetrieveRolesByMenuIdDataKey, id));
|
||||
cacheKeys.Add(string.Format("{0}-{1}", RoleHelper.RetrieveRolesByMenuIdDataKey, id));
|
||||
});
|
||||
cacheKeys.Add(Menu.RetrieveMenusByRoleIdDataKey + "*");
|
||||
cacheKeys.Add(Menu.RetrieveMenusDataKey + "*");
|
||||
corsKeys.Add(Menu.RetrieveMenusDataKey + "*");
|
||||
cacheKeys.Add(MenuHelper.RetrieveMenusByRoleIdDataKey + "*");
|
||||
cacheKeys.Add(MenuHelper.RetrieveMenusDataKey + "*");
|
||||
corsKeys.Add(MenuHelper.RetrieveMenusDataKey + "*");
|
||||
}
|
||||
if (dictIds != null)
|
||||
{
|
||||
cacheKeys.Add(Dict.RetrieveDictsDataKey + "*");
|
||||
cacheKeys.Add(Dict.RetrieveCategoryDataKey);
|
||||
cacheKeys.Add(DictHelper.RetrieveCategoryDataKey);
|
||||
corsKeys.Add(Dict.RetrieveDictsDataKey + "*");
|
||||
}
|
||||
if (cacheKey != null)
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
using Bootstrap.Security;
|
||||
using Bootstrap.Security.SQLServer;
|
||||
using Longbow.Cache;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
|
@ -17,7 +16,6 @@ namespace Bootstrap.DataAccess
|
|||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public const string RetrieveCategoryDataKey = "DictHelper-RetrieveDictsCategory";
|
||||
/// <summary>
|
||||
/// 缓存索引,BootstrapAdmin后台清理缓存时使用
|
||||
/// </summary>
|
||||
|
@ -92,20 +90,17 @@ namespace Bootstrap.DataAccess
|
|||
/// <returns></returns>
|
||||
public virtual IEnumerable<string> RetrieveCategories()
|
||||
{
|
||||
return CacheManager.GetOrAdd(RetrieveCategoryDataKey, key =>
|
||||
var ret = new List<string>();
|
||||
string sql = "select distinct Category from Dicts";
|
||||
DbCommand cmd = DbAccessManager.DBAccess.CreateCommand(CommandType.Text, sql);
|
||||
using (DbDataReader reader = DbAccessManager.DBAccess.ExecuteReader(cmd))
|
||||
{
|
||||
var ret = new List<string>();
|
||||
string sql = "select distinct Category from Dicts";
|
||||
DbCommand cmd = DbAccessManager.DBAccess.CreateCommand(CommandType.Text, sql);
|
||||
using (DbDataReader reader = DbAccessManager.DBAccess.ExecuteReader(cmd))
|
||||
while (reader.Read())
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
ret.Add((string)reader[0]);
|
||||
}
|
||||
ret.Add((string)reader[0]);
|
||||
}
|
||||
return ret;
|
||||
});
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
|
|
|
@ -14,10 +14,6 @@ namespace Bootstrap.DataAccess
|
|||
/// </summary>
|
||||
public class Exceptions
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
protected const string RetrieveExceptionsDataKey = "ExceptionHelper-RetrieveExceptions";
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
|
@ -97,7 +93,7 @@ namespace Bootstrap.DataAccess
|
|||
cmd.Parameters.Add(DbAccessManager.DBAccess.CreateParameter("@Message", ex.Message));
|
||||
cmd.Parameters.Add(DbAccessManager.DBAccess.CreateParameter("@StackTrace", DbAdapterManager.ToDBValue(ex.StackTrace)));
|
||||
DbAccessManager.DBAccess.ExecuteNonQuery(cmd);
|
||||
CacheManager.Clear(RetrieveExceptionsDataKey);
|
||||
CacheManager.Clear(ExceptionsHelper.RetrieveExceptionsDataKey);
|
||||
ClearExceptions();
|
||||
}
|
||||
}
|
||||
|
@ -107,31 +103,28 @@ namespace Bootstrap.DataAccess
|
|||
/// <returns></returns>
|
||||
public virtual IEnumerable<Exceptions> RetrieveExceptions()
|
||||
{
|
||||
return CacheManager.GetOrAdd(RetrieveExceptionsDataKey, key =>
|
||||
string sql = "select * from Exceptions where DATEDIFF(Week, LogTime, GETDATE()) = 0 order by LogTime desc";
|
||||
List<Exceptions> exceptions = new List<Exceptions>();
|
||||
DbCommand cmd = DbAccessManager.DBAccess.CreateCommand(CommandType.Text, sql);
|
||||
using (DbDataReader reader = DbAccessManager.DBAccess.ExecuteReader(cmd))
|
||||
{
|
||||
string sql = "select * from Exceptions where DATEDIFF(Week, LogTime, GETDATE()) = 0 order by LogTime desc";
|
||||
List<Exceptions> exceptions = new List<Exceptions>();
|
||||
DbCommand cmd = DbAccessManager.DBAccess.CreateCommand(CommandType.Text, sql);
|
||||
using (DbDataReader reader = DbAccessManager.DBAccess.ExecuteReader(cmd))
|
||||
while (reader.Read())
|
||||
{
|
||||
while (reader.Read())
|
||||
exceptions.Add(new Exceptions()
|
||||
{
|
||||
exceptions.Add(new Exceptions()
|
||||
{
|
||||
Id = (int)reader[0],
|
||||
AppDomainName = (string)reader[1],
|
||||
ErrorPage = reader.IsDBNull(2) ? string.Empty : (string)reader[2],
|
||||
UserId = reader.IsDBNull(3) ? string.Empty : (string)reader[3],
|
||||
UserIp = reader.IsDBNull(4) ? string.Empty : (string)reader[4],
|
||||
ExceptionType = (string)reader[5],
|
||||
Message = (string)reader[6],
|
||||
StackTrace = (string)reader[7],
|
||||
LogTime = (DateTime)reader[8],
|
||||
});
|
||||
}
|
||||
Id = (int)reader[0],
|
||||
AppDomainName = (string)reader[1],
|
||||
ErrorPage = reader.IsDBNull(2) ? string.Empty : (string)reader[2],
|
||||
UserId = reader.IsDBNull(3) ? string.Empty : (string)reader[3],
|
||||
UserIp = reader.IsDBNull(4) ? string.Empty : (string)reader[4],
|
||||
ExceptionType = (string)reader[5],
|
||||
Message = (string)reader[6],
|
||||
StackTrace = (string)reader[7],
|
||||
LogTime = (DateTime)reader[8],
|
||||
});
|
||||
}
|
||||
return exceptions;
|
||||
});
|
||||
}
|
||||
return exceptions;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
using Longbow;
|
||||
using Longbow.Cache;
|
||||
using Longbow.Data;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
@ -15,10 +14,6 @@ namespace Bootstrap.DataAccess
|
|||
/// </summary>
|
||||
public class Group
|
||||
{
|
||||
public const string RetrieveGroupsDataKey = "GroupHelper-RetrieveGroups";
|
||||
public const string RetrieveGroupsByUserIdDataKey = "GroupHelper-RetrieveGroupsByUserId";
|
||||
public const string RetrieveGroupsByRoleIdDataKey = "GroupHelper-RetrieveGroupsByRoleId";
|
||||
public const string RetrieveGroupsByUserNameDataKey = "BootstrapAdminGroupMiddleware-RetrieveGroupsByUserName";
|
||||
/// <summary>
|
||||
/// 获得/设置 群组主键ID
|
||||
/// </summary>
|
||||
|
@ -45,26 +40,22 @@ namespace Bootstrap.DataAccess
|
|||
/// <returns></returns>
|
||||
public virtual IEnumerable<Group> RetrieveGroups(int id = 0)
|
||||
{
|
||||
var ret = CacheManager.GetOrAdd(RetrieveGroupsDataKey, key =>
|
||||
string sql = "select * from Groups";
|
||||
List<Group> groups = new List<Group>();
|
||||
DbCommand cmd = DbAccessManager.DBAccess.CreateCommand(CommandType.Text, sql);
|
||||
using (DbDataReader reader = DbAccessManager.DBAccess.ExecuteReader(cmd))
|
||||
{
|
||||
string sql = "select * from Groups";
|
||||
List<Group> groups = new List<Group>();
|
||||
DbCommand cmd = DbAccessManager.DBAccess.CreateCommand(CommandType.Text, sql);
|
||||
using (DbDataReader reader = DbAccessManager.DBAccess.ExecuteReader(cmd))
|
||||
while (reader.Read())
|
||||
{
|
||||
while (reader.Read())
|
||||
groups.Add(new Group()
|
||||
{
|
||||
groups.Add(new Group()
|
||||
{
|
||||
Id = LgbConvert.ReadValue(reader[0], 0),
|
||||
GroupName = (string)reader[1],
|
||||
Description = reader.IsDBNull(2) ? string.Empty : (string)reader[2]
|
||||
});
|
||||
}
|
||||
Id = LgbConvert.ReadValue(reader[0], 0),
|
||||
GroupName = (string)reader[1],
|
||||
Description = reader.IsDBNull(2) ? string.Empty : (string)reader[2]
|
||||
});
|
||||
}
|
||||
return groups;
|
||||
});
|
||||
return id == 0 ? ret : ret.Where(t => id == t.Id);
|
||||
}
|
||||
return groups;
|
||||
}
|
||||
/// <summary>
|
||||
/// 删除群组信息
|
||||
|
@ -112,29 +103,24 @@ namespace Bootstrap.DataAccess
|
|||
/// <returns></returns>
|
||||
public virtual IEnumerable<Group> RetrieveGroupsByUserId(int userId)
|
||||
{
|
||||
string key = string.Format("{0}-{1}", RetrieveGroupsByUserIdDataKey, userId);
|
||||
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<Group> groups = new List<Group>();
|
||||
DbCommand cmd = DbAccessManager.DBAccess.CreateCommand(CommandType.Text, sql);
|
||||
cmd.Parameters.Add(DbAccessManager.DBAccess.CreateParameter("@UserID", userId));
|
||||
using (DbDataReader reader = DbAccessManager.DBAccess.ExecuteReader(cmd))
|
||||
{
|
||||
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<Group> groups = new List<Group>();
|
||||
DbCommand cmd = DbAccessManager.DBAccess.CreateCommand(CommandType.Text, sql);
|
||||
cmd.Parameters.Add(DbAccessManager.DBAccess.CreateParameter("@UserID", userId));
|
||||
using (DbDataReader reader = DbAccessManager.DBAccess.ExecuteReader(cmd))
|
||||
while (reader.Read())
|
||||
{
|
||||
while (reader.Read())
|
||||
groups.Add(new Group()
|
||||
{
|
||||
groups.Add(new Group()
|
||||
{
|
||||
Id = LgbConvert.ReadValue(reader[0], 0),
|
||||
GroupName = (string)reader[1],
|
||||
Description = reader.IsDBNull(2) ? string.Empty : (string)reader[2],
|
||||
Checked = (string)reader[3]
|
||||
});
|
||||
}
|
||||
Id = LgbConvert.ReadValue(reader[0], 0),
|
||||
GroupName = (string)reader[1],
|
||||
Description = reader.IsDBNull(2) ? string.Empty : (string)reader[2],
|
||||
Checked = (string)reader[3]
|
||||
});
|
||||
}
|
||||
return groups;
|
||||
}, RetrieveGroupsByUserIdDataKey);
|
||||
return ret;
|
||||
}
|
||||
return groups;
|
||||
}
|
||||
/// <summary>
|
||||
/// 保存用户部门关系
|
||||
|
@ -189,28 +175,24 @@ namespace Bootstrap.DataAccess
|
|||
/// <returns></returns>
|
||||
public virtual IEnumerable<Group> RetrieveGroupsByRoleId(int roleId)
|
||||
{
|
||||
string k = string.Format("{0}-{1}", RetrieveGroupsByRoleIdDataKey, roleId);
|
||||
return CacheManager.GetOrAdd(k, key =>
|
||||
List<Group> groups = new List<Group>();
|
||||
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";
|
||||
DbCommand cmd = DbAccessManager.DBAccess.CreateCommand(CommandType.Text, sql);
|
||||
cmd.Parameters.Add(DbAccessManager.DBAccess.CreateParameter("@RoleID", roleId));
|
||||
using (DbDataReader reader = DbAccessManager.DBAccess.ExecuteReader(cmd))
|
||||
{
|
||||
List<Group> groups = new List<Group>();
|
||||
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";
|
||||
DbCommand cmd = DbAccessManager.DBAccess.CreateCommand(CommandType.Text, sql);
|
||||
cmd.Parameters.Add(DbAccessManager.DBAccess.CreateParameter("@RoleID", roleId));
|
||||
using (DbDataReader reader = DbAccessManager.DBAccess.ExecuteReader(cmd))
|
||||
while (reader.Read())
|
||||
{
|
||||
while (reader.Read())
|
||||
groups.Add(new Group()
|
||||
{
|
||||
groups.Add(new Group()
|
||||
{
|
||||
Id = LgbConvert.ReadValue(reader[0], 0),
|
||||
GroupName = (string)reader[1],
|
||||
Description = reader.IsDBNull(2) ? string.Empty : (string)reader[2],
|
||||
Checked = (string)reader[3]
|
||||
});
|
||||
}
|
||||
Id = LgbConvert.ReadValue(reader[0], 0),
|
||||
GroupName = (string)reader[1],
|
||||
Description = reader.IsDBNull(2) ? string.Empty : (string)reader[2],
|
||||
Checked = (string)reader[3]
|
||||
});
|
||||
}
|
||||
return groups;
|
||||
}, RetrieveGroupsByRoleIdDataKey);
|
||||
}
|
||||
return groups;
|
||||
}
|
||||
/// <summary>
|
||||
/// 根据角色ID以及选定的部门ID,保到角色部门表
|
||||
|
@ -260,27 +242,23 @@ namespace Bootstrap.DataAccess
|
|||
///
|
||||
/// </summary>
|
||||
/// <param name="userName"></param>
|
||||
/// <param name="connName"></param>
|
||||
/// <returns></returns>
|
||||
public virtual IEnumerable<string> RetrieveGroupsByUserName(string userName)
|
||||
{
|
||||
return CacheManager.GetOrAdd(string.Format("{0}-{1}", RetrieveGroupsByUserNameDataKey, userName), r =>
|
||||
var entities = new List<string>();
|
||||
var db = DbAccessManager.DBAccess;
|
||||
using (DbCommand cmd = db.CreateCommand(CommandType.Text, "select g.GroupName, g.[Description] from Groups g inner join UserGroup ug on g.ID = ug.GroupID inner join Users u on ug.UserID = u.ID where UserName = @UserName"))
|
||||
{
|
||||
var entities = new List<string>();
|
||||
var db = DbAccessManager.DBAccess;
|
||||
using (DbCommand cmd = db.CreateCommand(CommandType.Text, "select g.GroupName, g.[Description] from Groups g inner join UserGroup ug on g.ID = ug.GroupID inner join Users u on ug.UserID = u.ID where UserName = @UserName"))
|
||||
cmd.Parameters.Add(db.CreateParameter("@UserName", userName));
|
||||
using (DbDataReader reader = db.ExecuteReader(cmd))
|
||||
{
|
||||
cmd.Parameters.Add(db.CreateParameter("@UserName", userName));
|
||||
using (DbDataReader reader = db.ExecuteReader(cmd))
|
||||
while (reader.Read())
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
entities.Add((string)reader[0]);
|
||||
}
|
||||
entities.Add((string)reader[0]);
|
||||
}
|
||||
}
|
||||
return entities;
|
||||
}, RetrieveGroupsByUserNameDataKey);
|
||||
}
|
||||
return entities;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using Bootstrap.Security;
|
||||
using Longbow.Cache;
|
||||
using Longbow.Data;
|
||||
using System.Collections.Generic;
|
||||
|
||||
|
@ -9,6 +10,7 @@ namespace Bootstrap.DataAccess
|
|||
/// </summary>
|
||||
public static class DictHelper
|
||||
{
|
||||
public const string RetrieveCategoryDataKey = "DictHelper-RetrieveDictsCategory";
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
|
@ -38,7 +40,7 @@ namespace Bootstrap.DataAccess
|
|||
/// 获取字典分类名称
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static IEnumerable<string> RetrieveCategories() => DbAdapterManager.Create<Dict>().RetrieveCategories();
|
||||
public static IEnumerable<string> RetrieveCategories() => CacheManager.GetOrAdd(RetrieveCategoryDataKey, key => DbAdapterManager.Create<Dict>().RetrieveCategories());
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using Longbow.Data;
|
||||
using Longbow.Cache;
|
||||
using Longbow.Data;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
|
@ -10,6 +11,10 @@ namespace Bootstrap.DataAccess
|
|||
/// </summary>
|
||||
public static class ExceptionsHelper
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public const string RetrieveExceptionsDataKey = "ExceptionHelper-RetrieveExceptions";
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
|
@ -21,6 +26,6 @@ namespace Bootstrap.DataAccess
|
|||
/// 查询一周内所有异常
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static IEnumerable<Exceptions> RetrieveExceptions() => DbAdapterManager.Create<Exceptions>().RetrieveExceptions();
|
||||
public static IEnumerable<Exceptions> RetrieveExceptions() => CacheManager.GetOrAdd(RetrieveExceptionsDataKey, key => DbAdapterManager.Create<Exceptions>().RetrieveExceptions());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,20 +1,30 @@
|
|||
using Longbow.Data;
|
||||
using Longbow.Cache;
|
||||
using Longbow.Data;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Bootstrap.DataAccess
|
||||
{
|
||||
/// <summary>
|
||||
/// author:liuchun
|
||||
/// date:2016.10.22
|
||||
///
|
||||
/// </summary>
|
||||
public static class GroupHelper
|
||||
{
|
||||
public const string RetrieveGroupsDataKey = "GroupHelper-RetrieveGroups";
|
||||
public const string RetrieveGroupsByUserIdDataKey = "GroupHelper-RetrieveGroupsByUserId";
|
||||
public const string RetrieveGroupsByRoleIdDataKey = "GroupHelper-RetrieveGroupsByRoleId";
|
||||
public const string RetrieveGroupsByUserNameDataKey = "BootstrapAdminGroupMiddleware-RetrieveGroupsByUserName";
|
||||
/// <summary>
|
||||
/// 查询所有群组信息
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public static IEnumerable<Group> RetrieveGroups(int id = 0) => DbAdapterManager.Create<Group>().RetrieveGroups(id);
|
||||
public static IEnumerable<Group> RetrieveGroups(int id = 0)
|
||||
{
|
||||
var ret = CacheManager.GetOrAdd(RetrieveGroupsDataKey, key => DbAdapterManager.Create<Group>().RetrieveGroups(id));
|
||||
return id == 0 ? ret : ret.Where(t => id == t.Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除群组信息
|
||||
/// </summary>
|
||||
|
@ -31,7 +41,8 @@ namespace Bootstrap.DataAccess
|
|||
/// </summary>
|
||||
/// <param name="userId"></param>
|
||||
/// <returns></returns>
|
||||
public static IEnumerable<Group> RetrieveGroupsByUserId(int userId) => DbAdapterManager.Create<Group>().RetrieveGroupsByUserId(userId);
|
||||
public static IEnumerable<Group> RetrieveGroupsByUserId(int userId) => CacheManager.GetOrAdd(string.Format("{0}-{1}", RetrieveGroupsByUserIdDataKey, userId), k => DbAdapterManager.Create<Group>().RetrieveGroupsByUserId(userId), RetrieveGroupsByUserIdDataKey);
|
||||
|
||||
/// <summary>
|
||||
/// 保存用户部门关系
|
||||
/// </summary>
|
||||
|
@ -44,7 +55,7 @@ namespace Bootstrap.DataAccess
|
|||
/// </summary>
|
||||
/// <param name="roleId"></param>
|
||||
/// <returns></returns>
|
||||
public static IEnumerable<Group> RetrieveGroupsByRoleId(int roleId) => DbAdapterManager.Create<Group>().RetrieveGroupsByRoleId(roleId);
|
||||
public static IEnumerable<Group> RetrieveGroupsByRoleId(int roleId) => CacheManager.GetOrAdd(string.Format("{0}-{1}", RetrieveGroupsByRoleIdDataKey, roleId), key => DbAdapterManager.Create<Group>().RetrieveGroupsByRoleId(roleId), RetrieveGroupsByRoleIdDataKey);
|
||||
/// <summary>
|
||||
/// 根据角色ID以及选定的部门ID,保到角色部门表
|
||||
/// </summary>
|
||||
|
@ -52,5 +63,11 @@ namespace Bootstrap.DataAccess
|
|||
/// <param name="groupIds"></param>
|
||||
/// <returns></returns>
|
||||
public static bool SaveGroupsByRoleId(int id, IEnumerable<int> groupIds) => DbAdapterManager.Create<Group>().SaveGroupsByRoleId(id, groupIds);
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="userName"></param>
|
||||
/// <returns></returns>
|
||||
public static IEnumerable<string> RetrieveGroupsByUserName(string userName) => CacheManager.GetOrAdd(string.Format("{0}-{1}", RetrieveGroupsByUserNameDataKey, userName), r => DbAdapterManager.Create<Group>().RetrieveGroupsByUserName(userName), RetrieveGroupsByUserNameDataKey);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,16 +1,30 @@
|
|||
using Longbow.Data;
|
||||
using Longbow.Cache;
|
||||
using Longbow.Data;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Bootstrap.DataAccess
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public static class LogHelper
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public const string RetrieveLogsDataKey = "LogHelper-RetrieveLogs";
|
||||
/// <summary>
|
||||
/// 查询所有日志信息
|
||||
/// </summary>
|
||||
/// <param name="tId"></param>
|
||||
/// <returns></returns>
|
||||
public static IEnumerable<Log> RetrieveLogs(string tId = null) => DbAdapterManager.Create<Log>().RetrieveLogs(tId);
|
||||
public static IEnumerable<Log> RetrieveLogs(string tId = null)
|
||||
{
|
||||
var ret = CacheManager.GetOrAdd(RetrieveLogsDataKey, key => DbAdapterManager.Create<Log>().RetrieveLogs(tId));
|
||||
return string.IsNullOrEmpty(tId) ? ret : ret.Where(t => tId.Equals(t.Id.ToString(), StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
/// <summary>
|
||||
/// 保存新增的日志信息
|
||||
/// </summary>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using Bootstrap.Security;
|
||||
using Longbow.Cache;
|
||||
using Longbow.Data;
|
||||
using System.Collections.Generic;
|
||||
|
||||
|
@ -9,6 +10,18 @@ namespace Bootstrap.DataAccess
|
|||
/// </summary>
|
||||
public static class MenuHelper
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public const string RetrieveMenusByRoleIdDataKey = "MenuHelper-RetrieveMenusByRoleId";
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public const string RetrieveMenusDataKey = "BootstrapMenu-RetrieveMenusByUserName";
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public const string RetrieveMenusAll = "BootstrapMenu-RetrieveMenus";
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
|
@ -30,9 +43,12 @@ namespace Bootstrap.DataAccess
|
|||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="roleId"></param>
|
||||
/// <returns></returns>
|
||||
public static IEnumerable<BootstrapMenu> RetrieveMenusByRoleId(int id) => DbAdapterManager.Create<Menu>().RetrieveMenusByRoleId(id);
|
||||
public static IEnumerable<BootstrapMenu> RetrieveMenusByRoleId(int roleId)
|
||||
{
|
||||
return CacheManager.GetOrAdd($"{RetrieveMenusByRoleIdDataKey}-{roleId}", k => DbAdapterManager.Create<Menu>().RetrieveMenusByRoleId(roleId), RetrieveMenusByRoleIdDataKey);
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
using Longbow.Data;
|
||||
using Longbow.Cache;
|
||||
using Longbow.Data;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Bootstrap.DataAccess
|
||||
{
|
||||
|
@ -8,6 +10,10 @@ namespace Bootstrap.DataAccess
|
|||
/// </summary>
|
||||
public static class MessageHelper
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public const string RetrieveMessageDataKey = "MessageHelper-RetrieveMessages";
|
||||
/// <summary>
|
||||
/// 收件箱
|
||||
/// </summary>
|
||||
|
@ -36,6 +42,6 @@ namespace Bootstrap.DataAccess
|
|||
/// </summary>
|
||||
/// <param name="userName"></param>
|
||||
/// <returns></returns>
|
||||
public static IEnumerable<Message> RetrieveMessagesHeader(string userName) => DbAdapterManager.Create<Message>().RetrieveMessagesHeader(userName);
|
||||
public static IEnumerable<Message> RetrieveMessagesHeader(string userName) => CacheManager.GetOrAdd(RetrieveMessageDataKey, key => DbAdapterManager.Create<Message>().RetrieveMessagesHeader(userName).OrderByDescending(n => n.SendTime));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
using Longbow.Data;
|
||||
using Longbow.Cache;
|
||||
using Longbow.Data;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Bootstrap.DataAccess
|
||||
{
|
||||
|
@ -8,24 +10,34 @@ namespace Bootstrap.DataAccess
|
|||
/// </summary>
|
||||
public static class RoleHelper
|
||||
{
|
||||
public const string RetrieveRolesDataKey = "RoleHelper-RetrieveRoles";
|
||||
public const string RetrieveRolesByUserIdDataKey = "RoleHelper-RetrieveRolesByUserId";
|
||||
public const string RetrieveRolesByMenuIdDataKey = "RoleHelper-RetrieveRolesByMenuId";
|
||||
public const string RetrieveRolesByGroupIdDataKey = "RoleHelper-RetrieveRolesByGroupId";
|
||||
public const string RetrieveRolesByUserNameDataKey = "BootstrapAdminRoleMiddleware-RetrieveRolesByUserName";
|
||||
public const string RetrieveRolesByUrlDataKey = "BootstrapAdminAuthorizeFilter-RetrieveRolesByUrl";
|
||||
/// <summary>
|
||||
/// 查询所有角色
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public static IEnumerable<Role> RetrieveRoles(int id = 0) => DbAdapterManager.Create<Role>().RetrieveRoles(id);
|
||||
public static IEnumerable<Role> RetrieveRoles(int id = 0)
|
||||
{
|
||||
var ret = CacheManager.GetOrAdd(RetrieveRolesDataKey, key => DbAdapterManager.Create<Role>().RetrieveRoles(id));
|
||||
return id == 0 ? ret : ret.Where(t => id == t.Id);
|
||||
}
|
||||
/// <summary>
|
||||
/// 保存用户角色关系
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="userId"></param>
|
||||
/// <param name="roleIds"></param>
|
||||
/// <returns></returns>
|
||||
public static bool SaveRolesByUserId(int id, IEnumerable<int> roleIds) => DbAdapterManager.Create<Role>().SaveRolesByUserId(id, roleIds);
|
||||
public static bool SaveRolesByUserId(int userId, IEnumerable<int> roleIds) => DbAdapterManager.Create<Role>().SaveRolesByUserId(userId, roleIds);
|
||||
/// <summary>
|
||||
/// 查询某个用户所拥有的角色
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static IEnumerable<Role> RetrieveRolesByUserId(int userId) => DbAdapterManager.Create<Role>().RetrieveRolesByUserId(userId);
|
||||
public static IEnumerable<Role> RetrieveRolesByUserId(int userId) => CacheManager.GetOrAdd($"{RetrieveRolesByUserIdDataKey}-{userId}", key => DbAdapterManager.Create<Role>().RetrieveRolesByUserId(userId), RetrieveRolesByUserIdDataKey);
|
||||
/// <summary>
|
||||
/// 删除角色表
|
||||
/// </summary>
|
||||
|
@ -42,7 +54,7 @@ namespace Bootstrap.DataAccess
|
|||
/// </summary>
|
||||
/// <param name="menuId"></param>
|
||||
/// <returns></returns>
|
||||
public static IEnumerable<Role> RetrieveRolesByMenuId(int menuId) => DbAdapterManager.Create<Role>().RetrieveRolesByMenuId(menuId);
|
||||
public static IEnumerable<Role> RetrieveRolesByMenuId(int menuId) => CacheManager.GetOrAdd(string.Format("{0}-{1}", RetrieveRolesByMenuIdDataKey, menuId), key => DbAdapterManager.Create<Role>().RetrieveRolesByMenuId(menuId), RetrieveRolesByMenuIdDataKey);
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
|
@ -55,7 +67,7 @@ namespace Bootstrap.DataAccess
|
|||
/// </summary>
|
||||
/// <param name="groupId"></param>
|
||||
/// <returns></returns>
|
||||
public static IEnumerable<Role> RetrieveRolesByGroupId(int groupId) => DbAdapterManager.Create<Role>().RetrieveRolesByGroupId(groupId);
|
||||
public static IEnumerable<Role> RetrieveRolesByGroupId(int groupId) => CacheManager.GetOrAdd(string.Format("{0}-{1}", RetrieveRolesByGroupIdDataKey, groupId), key => DbAdapterManager.Create<Role>().RetrieveRolesByGroupId(groupId), RetrieveRolesByGroupIdDataKey);
|
||||
/// <summary>
|
||||
/// 根据GroupId更新Roles信息,删除旧的Roles信息,插入新的Roles信息
|
||||
/// </summary>
|
||||
|
@ -68,12 +80,12 @@ namespace Bootstrap.DataAccess
|
|||
/// </summary>
|
||||
/// <param name="userName"></param>
|
||||
/// <returns></returns>
|
||||
public static IEnumerable<string> RetrieveRolesByUserName(string userName) => DbAdapterManager.Create<Role>().RetrieveRolesByUserName(userName);
|
||||
public static IEnumerable<string> RetrieveRolesByUserName(string userName) => CacheManager.GetOrAdd(string.Format("{0}-{1}", RetrieveRolesByUserNameDataKey, userName), key => DbAdapterManager.Create<Role>().RetrieveRolesByUserName(userName), RetrieveRolesByUserNameDataKey);
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="url"></param>
|
||||
/// <returns></returns>
|
||||
public static IEnumerable<string> RetrieveRolesByUrl(string url) => DbAdapterManager.Create<Role>().RetrieveRolesByUrl(url);
|
||||
public static IEnumerable<string> RetrieveRolesByUrl(string url) => CacheManager.GetOrAdd(string.Format("{0}-{1}", RetrieveRolesByUrlDataKey, url), key => DbAdapterManager.Create<Role>().RetrieveRolesByUrl(url), RetrieveRolesByUrlDataKey);
|
||||
}
|
||||
}
|
|
@ -1,14 +1,22 @@
|
|||
using Longbow.Data;
|
||||
using Longbow.Cache;
|
||||
using Longbow.Data;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Bootstrap.DataAccess
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public static class TaskHelper
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public const string RetrieveTasksDataKey = "TaskHelper-RetrieveTasks";
|
||||
/// <summary>
|
||||
/// 查询所有任务
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static IEnumerable<Task> RetrieveTasks() => DbAdapterManager.Create<Task>().RetrieveTasks();
|
||||
public static IEnumerable<Task> RetrieveTasks() => CacheManager.GetOrAdd(RetrieveTasksDataKey, key => DbAdapterManager.Create<Task>().RetrieveTasks());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using Bootstrap.Security;
|
||||
using Longbow.Cache;
|
||||
using Longbow.Data;
|
||||
using System.Collections.Generic;
|
||||
|
||||
|
@ -9,12 +10,17 @@ namespace Bootstrap.DataAccess
|
|||
/// </summary>
|
||||
public static class UserHelper
|
||||
{
|
||||
public const string RetrieveUsersDataKey = "BootstrapUser-RetrieveUsers";
|
||||
public const string RetrieveUsersByRoleIdDataKey = "BootstrapUser-RetrieveUsersByRoleId";
|
||||
public const string RetrieveUsersByGroupIdDataKey = "BootstrapUser-RetrieveUsersByGroupId";
|
||||
public const string RetrieveNewUsersDataKey = "UserHelper-RetrieveNewUsers";
|
||||
public const string RetrieveUsersByNameDataKey = "BootstrapUser-RetrieveUsersByName";
|
||||
/// <summary>
|
||||
/// 查询所有用户
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public static IEnumerable<User> RetrieveUsers() => DbAdapterManager.Create<User>().RetrieveUsers();
|
||||
public static IEnumerable<User> RetrieveUsers() => CacheManager.GetOrAdd(RetrieveUsersDataKey, key => DbAdapterManager.Create<User>().RetrieveUsers());
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
|
@ -26,7 +32,7 @@ namespace Bootstrap.DataAccess
|
|||
/// 查询所有的新注册用户
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static IEnumerable<User> RetrieveNewUsers() => DbAdapterManager.Create<User>().RetrieveNewUsers();
|
||||
public static IEnumerable<User> RetrieveNewUsers() => CacheManager.GetOrAdd(RetrieveNewUsersDataKey, key => DbAdapterManager.Create<User>().RetrieveNewUsers());
|
||||
/// <summary>
|
||||
/// 删除用户
|
||||
/// </summary>
|
||||
|
@ -74,7 +80,7 @@ namespace Bootstrap.DataAccess
|
|||
/// </summary>
|
||||
/// <param name="roleId"></param>
|
||||
/// <returns></returns>
|
||||
public static IEnumerable<User> RetrieveUsersByRoleId(int roleId) => DbAdapterManager.Create<User>().RetrieveUsersByRoleId(roleId);
|
||||
public static IEnumerable<User> RetrieveUsersByRoleId(int roleId) => CacheManager.GetOrAdd(string.Format("{0}-{1}", RetrieveUsersByRoleIdDataKey, roleId), k => DbAdapterManager.Create<User>().RetrieveUsersByRoleId(roleId), RetrieveUsersByRoleIdDataKey);
|
||||
/// <summary>
|
||||
/// 通过角色ID保存当前授权用户(插入)
|
||||
/// </summary>
|
||||
|
@ -87,7 +93,7 @@ namespace Bootstrap.DataAccess
|
|||
/// </summary>
|
||||
/// <param name="groupId"></param>
|
||||
/// <returns></returns>
|
||||
public static IEnumerable<User> RetrieveUsersByGroupId(int groupId) => DbAdapterManager.Create<User>().RetrieveUsersByGroupId(groupId);
|
||||
public static IEnumerable<User> RetrieveUsersByGroupId(int groupId) => CacheManager.GetOrAdd(string.Format("{0}-{1}", RetrieveUsersByGroupIdDataKey, groupId), k => DbAdapterManager.Create<User>().RetrieveUsersByGroupId(groupId), RetrieveUsersByRoleIdDataKey);
|
||||
/// <summary>
|
||||
/// 通过部门ID保存当前授权用户(插入)
|
||||
/// </summary>
|
||||
|
@ -118,8 +124,8 @@ namespace Bootstrap.DataAccess
|
|||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <param name="userName"></param>
|
||||
/// <returns></returns>
|
||||
public static BootstrapUser RetrieveUserByUserName(string name) => DbAdapterManager.Create<User>().RetrieveUserByUserName(name);
|
||||
public static BootstrapUser RetrieveUserByUserName(string userName) => CacheManager.GetOrAdd(string.Format("{0}-{1}", RetrieveUsersByNameDataKey, userName), k => DbAdapterManager.Create<User>().RetrieveUserByUserName(userName), RetrieveUsersByNameDataKey);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
using System.Linq;
|
||||
|
||||
namespace Bootstrap.DataAccess
|
||||
{
|
||||
|
@ -13,10 +12,6 @@ namespace Bootstrap.DataAccess
|
|||
/// </summary>
|
||||
public class Log
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
protected const string RetrieveLogsDataKey = "LogHelper-RetrieveLogs";
|
||||
/// <summary>
|
||||
/// 获得/设置 操作日志主键ID
|
||||
/// </summary>
|
||||
|
@ -58,30 +53,26 @@ namespace Bootstrap.DataAccess
|
|||
/// <returns></returns>
|
||||
public virtual IEnumerable<Log> RetrieveLogs(string tId = null)
|
||||
{
|
||||
var ret = CacheManager.GetOrAdd(RetrieveLogsDataKey, key =>
|
||||
string sql = "select * from Logs where DATEDIFF(Week, LogTime, GETDATE()) = 0";
|
||||
List<Log> logs = new List<Log>();
|
||||
DbCommand cmd = DbAccessManager.DBAccess.CreateCommand(CommandType.Text, sql);
|
||||
using (DbDataReader reader = DbAccessManager.DBAccess.ExecuteReader(cmd))
|
||||
{
|
||||
string sql = "select * from Logs where DATEDIFF(Week, LogTime, GETDATE()) = 0";
|
||||
List<Log> logs = new List<Log>();
|
||||
DbCommand cmd = DbAccessManager.DBAccess.CreateCommand(CommandType.Text, sql);
|
||||
using (DbDataReader reader = DbAccessManager.DBAccess.ExecuteReader(cmd))
|
||||
while (reader.Read())
|
||||
{
|
||||
while (reader.Read())
|
||||
logs.Add(new Log()
|
||||
{
|
||||
logs.Add(new Log()
|
||||
{
|
||||
Id = (int)reader[0],
|
||||
CRUD = (string)reader[1],
|
||||
UserName = (string)reader[2],
|
||||
LogTime = (DateTime)reader[3],
|
||||
ClientIp = (string)reader[4],
|
||||
ClientAgent = (string)reader[5],
|
||||
RequestUrl = (string)reader[6]
|
||||
});
|
||||
}
|
||||
Id = (int)reader[0],
|
||||
CRUD = (string)reader[1],
|
||||
UserName = (string)reader[2],
|
||||
LogTime = (DateTime)reader[3],
|
||||
ClientIp = (string)reader[4],
|
||||
ClientAgent = (string)reader[5],
|
||||
RequestUrl = (string)reader[6]
|
||||
});
|
||||
}
|
||||
return logs;
|
||||
});
|
||||
return string.IsNullOrEmpty(tId) ? ret : ret.Where(t => tId.Equals(t.Id.ToString(), StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
return logs;
|
||||
}
|
||||
/// <summary>
|
||||
/// 删除日志信息
|
||||
|
@ -116,7 +107,7 @@ namespace Bootstrap.DataAccess
|
|||
cmd.Parameters.Add(DbAccessManager.DBAccess.CreateParameter("@RequestUrl", p.RequestUrl));
|
||||
ret = DbAccessManager.DBAccess.ExecuteNonQuery(cmd) == 1;
|
||||
}
|
||||
CacheManager.Clear(RetrieveLogsDataKey);
|
||||
CacheManager.Clear(LogHelper.RetrieveLogsDataKey);
|
||||
DeleteLogAsync();
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
using Bootstrap.Security;
|
||||
using Bootstrap.Security.SQLServer;
|
||||
using Longbow;
|
||||
using Longbow.Cache;
|
||||
using Longbow.Data;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
@ -17,18 +16,6 @@ namespace Bootstrap.DataAccess
|
|||
/// </summary>
|
||||
public class Menu : BootstrapMenu
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public const string RetrieveMenusByRoleIdDataKey = "MenuHelper-RetrieveMenusByRoleId";
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public const string RetrieveMenusDataKey = "BootstrapMenu-RetrieveMenusByUserName";
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public const string RetrieveMenusAll = "BootstrapMenu-RetrieveMenus";
|
||||
/// <summary>
|
||||
/// 删除菜单信息
|
||||
/// </summary>
|
||||
|
@ -84,27 +71,23 @@ namespace Bootstrap.DataAccess
|
|||
/// <returns></returns>
|
||||
public virtual IEnumerable<BootstrapMenu> RetrieveMenusByRoleId(int roleId)
|
||||
{
|
||||
string key = string.Format("{0}-{1}", RetrieveMenusByRoleIdDataKey, roleId);
|
||||
return CacheManager.GetOrAdd(key, k =>
|
||||
var menus = new List<BootstrapMenu>();
|
||||
string sql = "select NavigationID from NavigationRole where RoleID = @RoleID";
|
||||
using (DbCommand cmd = DbAccessManager.DBAccess.CreateCommand(CommandType.Text, sql))
|
||||
{
|
||||
var menus = new List<BootstrapMenu>();
|
||||
string sql = "select NavigationID from NavigationRole where RoleID = @RoleID";
|
||||
using (DbCommand cmd = DbAccessManager.DBAccess.CreateCommand(CommandType.Text, sql))
|
||||
cmd.Parameters.Add(DbAccessManager.DBAccess.CreateParameter("@RoleID", roleId));
|
||||
using (DbDataReader reader = DbAccessManager.DBAccess.ExecuteReader(cmd))
|
||||
{
|
||||
cmd.Parameters.Add(DbAccessManager.DBAccess.CreateParameter("@RoleID", roleId));
|
||||
using (DbDataReader reader = DbAccessManager.DBAccess.ExecuteReader(cmd))
|
||||
while (reader.Read())
|
||||
{
|
||||
while (reader.Read())
|
||||
menus.Add(new BootstrapMenu()
|
||||
{
|
||||
menus.Add(new BootstrapMenu()
|
||||
{
|
||||
Id = LgbConvert.ReadValue(reader[0], 0)
|
||||
});
|
||||
}
|
||||
Id = LgbConvert.ReadValue(reader[0], 0)
|
||||
});
|
||||
}
|
||||
}
|
||||
return menus;
|
||||
}, RetrieveMenusByRoleIdDataKey);
|
||||
}
|
||||
return menus;
|
||||
}
|
||||
/// <summary>
|
||||
/// 通过角色ID保存当前授权菜单
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
using Longbow;
|
||||
using Longbow.Cache;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
|
@ -13,7 +12,6 @@ namespace Bootstrap.DataAccess
|
|||
/// </summary>
|
||||
public class Message
|
||||
{
|
||||
protected const string RetrieveMessageDataKey = "MessageHelper-RetrieveMessages";
|
||||
/// <summary>
|
||||
/// 消息主键 数据库自增
|
||||
/// </summary>
|
||||
|
@ -77,38 +75,33 @@ namespace Bootstrap.DataAccess
|
|||
/// <returns></returns>
|
||||
protected virtual IEnumerable<Message> RetrieveMessages(string userName)
|
||||
{
|
||||
var messageRet = CacheManager.GetOrAdd(RetrieveMessageDataKey, key =>
|
||||
string sql = "select m.*, d.Name, isnull(i.Code + u.Icon, '~/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<Message> messages = new List<Message>();
|
||||
DbCommand cmd = DbAccessManager.DBAccess.CreateCommand(CommandType.Text, sql);
|
||||
cmd.Parameters.Add(DbAccessManager.DBAccess.CreateParameter("@UserName", userName));
|
||||
using (DbDataReader reader = DbAccessManager.DBAccess.ExecuteReader(cmd))
|
||||
{
|
||||
string sql = "select m.*, d.Name, isnull(i.Code + u.Icon, '~/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<Message> messages = new List<Message>();
|
||||
DbCommand cmd = DbAccessManager.DBAccess.CreateCommand(CommandType.Text, sql);
|
||||
cmd.Parameters.Add(DbAccessManager.DBAccess.CreateParameter("@UserName", userName));
|
||||
using (DbDataReader reader = DbAccessManager.DBAccess.ExecuteReader(cmd))
|
||||
while (reader.Read())
|
||||
{
|
||||
while (reader.Read())
|
||||
messages.Add(new Message()
|
||||
{
|
||||
messages.Add(new Message()
|
||||
{
|
||||
Id = (int)reader[0],
|
||||
Title = (string)reader[1],
|
||||
Content = (string)reader[2],
|
||||
From = (string)reader[3],
|
||||
To = (string)reader[4],
|
||||
SendTime = LgbConvert.ReadValue(reader[5], DateTime.MinValue),
|
||||
Status = (string)reader[6],
|
||||
Mark = (int)reader[7],
|
||||
IsDelete = (int)reader[8],
|
||||
Label = (string)reader[9],
|
||||
LabelName = LgbConvert.ReadValue(reader[10], string.Empty),
|
||||
FromIcon = (string)reader[11],
|
||||
FromDisplayName = (string)reader[12]
|
||||
});
|
||||
}
|
||||
Id = (int)reader[0],
|
||||
Title = (string)reader[1],
|
||||
Content = (string)reader[2],
|
||||
From = (string)reader[3],
|
||||
To = (string)reader[4],
|
||||
SendTime = LgbConvert.ReadValue(reader[5], DateTime.MinValue),
|
||||
Status = (string)reader[6],
|
||||
Mark = (int)reader[7],
|
||||
IsDelete = (int)reader[8],
|
||||
Label = (string)reader[9],
|
||||
LabelName = LgbConvert.ReadValue(reader[10], string.Empty),
|
||||
FromIcon = (string)reader[11],
|
||||
FromDisplayName = (string)reader[12]
|
||||
});
|
||||
}
|
||||
return messages;
|
||||
|
||||
});
|
||||
return messageRet.OrderByDescending(n => n.SendTime);
|
||||
}
|
||||
return messages;
|
||||
}
|
||||
/// <summary>
|
||||
/// 收件箱
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
using Bootstrap.Security.SQLServer;
|
||||
using Longbow;
|
||||
using Longbow.Cache;
|
||||
using Longbow.Data;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
@ -16,12 +15,6 @@ namespace Bootstrap.DataAccess
|
|||
/// </summary>
|
||||
public class Role
|
||||
{
|
||||
public const string RetrieveRolesDataKey = "RoleHelper-RetrieveRoles";
|
||||
public const string RetrieveRolesByUserIdDataKey = "RoleHelper-RetrieveRolesByUserId";
|
||||
public const string RetrieveRolesByMenuIdDataKey = "RoleHelper-RetrieveRolesByMenuId";
|
||||
public const string RetrieveRolesByGroupIdDataKey = "RoleHelper-RetrieveRolesByGroupId";
|
||||
public const string RetrieveRolesByUserNameDataKey = "BootstrapAdminRoleMiddleware-RetrieveRolesByUserName";
|
||||
public const string RetrieveRolesByUrlDataKey = "BootstrapAdminAuthorizeFilter-RetrieveRolesByUrl";
|
||||
/// <summary>
|
||||
/// 获得/设置 角色主键ID
|
||||
/// </summary>
|
||||
|
@ -45,26 +38,22 @@ namespace Bootstrap.DataAccess
|
|||
/// <returns></returns>
|
||||
public virtual IEnumerable<Role> RetrieveRoles(int id = 0)
|
||||
{
|
||||
var ret = CacheManager.GetOrAdd(RetrieveRolesDataKey, key =>
|
||||
string sql = "select * from Roles";
|
||||
var roles = new List<Role>();
|
||||
DbCommand cmd = DbAccessManager.DBAccess.CreateCommand(CommandType.Text, sql);
|
||||
using (DbDataReader reader = DbAccessManager.DBAccess.ExecuteReader(cmd))
|
||||
{
|
||||
string sql = "select * from Roles";
|
||||
var roles = new List<Role>();
|
||||
DbCommand cmd = DbAccessManager.DBAccess.CreateCommand(CommandType.Text, sql);
|
||||
using (DbDataReader reader = DbAccessManager.DBAccess.ExecuteReader(cmd))
|
||||
while (reader.Read())
|
||||
{
|
||||
while (reader.Read())
|
||||
roles.Add(new Role()
|
||||
{
|
||||
roles.Add(new Role()
|
||||
{
|
||||
Id = LgbConvert.ReadValue(reader[0], 0),
|
||||
RoleName = (string)reader[1],
|
||||
Description = reader.IsDBNull(2) ? string.Empty : (string)reader[2]
|
||||
});
|
||||
}
|
||||
Id = LgbConvert.ReadValue(reader[0], 0),
|
||||
RoleName = (string)reader[1],
|
||||
Description = reader.IsDBNull(2) ? string.Empty : (string)reader[2]
|
||||
});
|
||||
}
|
||||
return roles;
|
||||
});
|
||||
return id == 0 ? ret : ret.Where(t => id == t.Id);
|
||||
}
|
||||
return roles;
|
||||
}
|
||||
/// <summary>
|
||||
/// 保存用户角色关系
|
||||
|
@ -119,28 +108,24 @@ namespace Bootstrap.DataAccess
|
|||
/// <returns></returns>
|
||||
public virtual IEnumerable<Role> RetrieveRolesByUserId(int userId)
|
||||
{
|
||||
string key = string.Format("{0}-{1}", RetrieveRolesByUserIdDataKey, userId);
|
||||
return CacheManager.GetOrAdd(key, k =>
|
||||
List<Role> roles = new List<Role>();
|
||||
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";
|
||||
DbCommand cmd = DbAccessManager.DBAccess.CreateCommand(CommandType.Text, sql);
|
||||
cmd.Parameters.Add(DbAccessManager.DBAccess.CreateParameter("@UserID", userId));
|
||||
using (DbDataReader reader = DbAccessManager.DBAccess.ExecuteReader(cmd))
|
||||
{
|
||||
List<Role> roles = new List<Role>();
|
||||
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";
|
||||
DbCommand cmd = DbAccessManager.DBAccess.CreateCommand(CommandType.Text, sql);
|
||||
cmd.Parameters.Add(DbAccessManager.DBAccess.CreateParameter("@UserID", userId));
|
||||
using (DbDataReader reader = DbAccessManager.DBAccess.ExecuteReader(cmd))
|
||||
while (reader.Read())
|
||||
{
|
||||
while (reader.Read())
|
||||
roles.Add(new Role()
|
||||
{
|
||||
roles.Add(new Role()
|
||||
{
|
||||
Id = LgbConvert.ReadValue(reader[0], 0),
|
||||
RoleName = (string)reader[1],
|
||||
Description = reader.IsDBNull(2) ? string.Empty : (string)reader[2],
|
||||
Checked = (string)reader[3]
|
||||
});
|
||||
}
|
||||
Id = LgbConvert.ReadValue(reader[0], 0),
|
||||
RoleName = (string)reader[1],
|
||||
Description = reader.IsDBNull(2) ? string.Empty : (string)reader[2],
|
||||
Checked = (string)reader[3]
|
||||
});
|
||||
}
|
||||
return roles;
|
||||
}, RetrieveRolesByUserIdDataKey);
|
||||
}
|
||||
return roles;
|
||||
}
|
||||
/// <summary>
|
||||
/// 删除角色表
|
||||
|
@ -188,29 +173,24 @@ namespace Bootstrap.DataAccess
|
|||
/// <returns></returns>
|
||||
public virtual IEnumerable<Role> RetrieveRolesByMenuId(int menuId)
|
||||
{
|
||||
string key = string.Format("{0}-{1}", RetrieveRolesByMenuIdDataKey, menuId);
|
||||
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<Role> roles = new List<Role>();
|
||||
DbCommand cmd = DbAccessManager.DBAccess.CreateCommand(CommandType.Text, sql);
|
||||
cmd.Parameters.Add(DbAccessManager.DBAccess.CreateParameter("@NavigationID", menuId));
|
||||
using (DbDataReader reader = DbAccessManager.DBAccess.ExecuteReader(cmd))
|
||||
{
|
||||
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<Role> roles = new List<Role>();
|
||||
DbCommand cmd = DbAccessManager.DBAccess.CreateCommand(CommandType.Text, sql);
|
||||
cmd.Parameters.Add(DbAccessManager.DBAccess.CreateParameter("@NavigationID", menuId));
|
||||
using (DbDataReader reader = DbAccessManager.DBAccess.ExecuteReader(cmd))
|
||||
while (reader.Read())
|
||||
{
|
||||
while (reader.Read())
|
||||
roles.Add(new Role()
|
||||
{
|
||||
roles.Add(new Role()
|
||||
{
|
||||
Id = LgbConvert.ReadValue(reader[0], 0),
|
||||
RoleName = (string)reader[1],
|
||||
Description = reader.IsDBNull(2) ? string.Empty : (string)reader[2],
|
||||
Checked = (string)reader[3]
|
||||
});
|
||||
}
|
||||
Id = LgbConvert.ReadValue(reader[0], 0),
|
||||
RoleName = (string)reader[1],
|
||||
Description = reader.IsDBNull(2) ? string.Empty : (string)reader[2],
|
||||
Checked = (string)reader[3]
|
||||
});
|
||||
}
|
||||
return roles;
|
||||
}, RetrieveRolesByMenuIdDataKey);
|
||||
return ret;
|
||||
}
|
||||
return roles;
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
|
@ -265,28 +245,24 @@ namespace Bootstrap.DataAccess
|
|||
/// <returns></returns>
|
||||
public virtual IEnumerable<Role> RetrieveRolesByGroupId(int groupId)
|
||||
{
|
||||
string key = string.Format("{0}-{1}", RetrieveRolesByGroupIdDataKey, groupId);
|
||||
return CacheManager.GetOrAdd(key, k =>
|
||||
List<Role> roles = new List<Role>();
|
||||
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";
|
||||
DbCommand cmd = DbAccessManager.DBAccess.CreateCommand(CommandType.Text, sql);
|
||||
cmd.Parameters.Add(DbAccessManager.DBAccess.CreateParameter("@GroupID", groupId));
|
||||
using (DbDataReader reader = DbAccessManager.DBAccess.ExecuteReader(cmd))
|
||||
{
|
||||
List<Role> roles = new List<Role>();
|
||||
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";
|
||||
DbCommand cmd = DbAccessManager.DBAccess.CreateCommand(CommandType.Text, sql);
|
||||
cmd.Parameters.Add(DbAccessManager.DBAccess.CreateParameter("@GroupID", groupId));
|
||||
using (DbDataReader reader = DbAccessManager.DBAccess.ExecuteReader(cmd))
|
||||
while (reader.Read())
|
||||
{
|
||||
while (reader.Read())
|
||||
roles.Add(new Role()
|
||||
{
|
||||
roles.Add(new Role()
|
||||
{
|
||||
Id = LgbConvert.ReadValue(reader[0], 0),
|
||||
RoleName = (string)reader[1],
|
||||
Description = reader.IsDBNull(2) ? string.Empty : (string)reader[2],
|
||||
Checked = (string)reader[3]
|
||||
});
|
||||
}
|
||||
Id = LgbConvert.ReadValue(reader[0], 0),
|
||||
RoleName = (string)reader[1],
|
||||
Description = reader.IsDBNull(2) ? string.Empty : (string)reader[2],
|
||||
Checked = (string)reader[3]
|
||||
});
|
||||
}
|
||||
return roles;
|
||||
}, RetrieveRolesByGroupIdDataKey);
|
||||
}
|
||||
return roles;
|
||||
}
|
||||
/// <summary>
|
||||
/// 根据GroupId更新Roles信息,删除旧的Roles信息,插入新的Roles信息
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
using Longbow.Cache;
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
|
@ -8,7 +7,6 @@ namespace Bootstrap.DataAccess
|
|||
{
|
||||
public class Task
|
||||
{
|
||||
protected const string RetrieveTasksDataKey = "TaskHelper-RetrieveTasks";
|
||||
/// <summary>
|
||||
/// 获取/设置 任务ID
|
||||
/// </summary>
|
||||
|
@ -47,30 +45,27 @@ namespace Bootstrap.DataAccess
|
|||
/// <returns></returns>
|
||||
public virtual IEnumerable<Task> RetrieveTasks()
|
||||
{
|
||||
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<Task> tasks = new List<Task>();
|
||||
DbCommand cmd = DbAccessManager.DBAccess.CreateCommand(CommandType.Text, sql);
|
||||
using (DbDataReader reader = DbAccessManager.DBAccess.ExecuteReader(cmd))
|
||||
{
|
||||
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<Task> tasks = new List<Task>();
|
||||
DbCommand cmd = DbAccessManager.DBAccess.CreateCommand(CommandType.Text, sql);
|
||||
using (DbDataReader reader = DbAccessManager.DBAccess.ExecuteReader(cmd))
|
||||
while (reader.Read())
|
||||
{
|
||||
while (reader.Read())
|
||||
tasks.Add(new Task()
|
||||
{
|
||||
tasks.Add(new Task()
|
||||
{
|
||||
Id = (int)reader[0],
|
||||
TaskName = (string)reader[1],
|
||||
AssignName = (string)reader[2],
|
||||
UserName = (string)reader[3],
|
||||
TaskTime = (int)reader[4],
|
||||
TaskProgress = (double)reader[5],
|
||||
AssignTime = (DateTime)reader[6],
|
||||
AssignDisplayName = (string)reader[7]
|
||||
});
|
||||
}
|
||||
Id = (int)reader[0],
|
||||
TaskName = (string)reader[1],
|
||||
AssignName = (string)reader[2],
|
||||
UserName = (string)reader[3],
|
||||
TaskTime = (int)reader[4],
|
||||
TaskProgress = (double)reader[5],
|
||||
AssignTime = (DateTime)reader[6],
|
||||
AssignDisplayName = (string)reader[7]
|
||||
});
|
||||
}
|
||||
return tasks;
|
||||
});
|
||||
}
|
||||
return tasks;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
using Bootstrap.Security;
|
||||
using Bootstrap.Security.SQLServer;
|
||||
using Longbow;
|
||||
using Longbow.Cache;
|
||||
using Longbow.Data;
|
||||
using Longbow.Security.Cryptography;
|
||||
using System;
|
||||
|
@ -18,11 +17,6 @@ namespace Bootstrap.DataAccess
|
|||
/// </summary>
|
||||
public class User : BootstrapUser
|
||||
{
|
||||
public const string RetrieveUsersDataKey = "BootstrapUser-RetrieveUsers";
|
||||
public const string RetrieveUsersByRoleIdDataKey = "BootstrapUser-RetrieveUsersByRoleId";
|
||||
public const string RetrieveUsersByGroupIdDataKey = "BootstrapUser-RetrieveUsersByGroupId";
|
||||
public const string RetrieveNewUsersDataKey = "UserHelper-RetrieveNewUsers";
|
||||
protected const string RetrieveUsersByNameDataKey = "BootstrapUser-RetrieveUsersByName";
|
||||
/// <summary>
|
||||
/// 获得/设置 用户主键ID
|
||||
/// </summary>
|
||||
|
@ -126,29 +120,26 @@ namespace Bootstrap.DataAccess
|
|||
/// <returns></returns>
|
||||
public virtual IEnumerable<User> RetrieveUsers()
|
||||
{
|
||||
return CacheManager.GetOrAdd(RetrieveUsersDataKey, key =>
|
||||
{
|
||||
List<User> users = new List<User>();
|
||||
DbCommand cmd = DbAccessManager.DBAccess.CreateCommand(CommandType.Text, "select ID, UserName, DisplayName, RegisterTime, ApprovedTime, ApprovedBy, Description from Users Where ApprovedTime is not null");
|
||||
List<User> users = new List<User>();
|
||||
DbCommand cmd = DbAccessManager.DBAccess.CreateCommand(CommandType.Text, "select ID, UserName, DisplayName, RegisterTime, ApprovedTime, ApprovedBy, Description from Users Where ApprovedTime is not null");
|
||||
|
||||
using (DbDataReader reader = DbAccessManager.DBAccess.ExecuteReader(cmd))
|
||||
using (DbDataReader reader = DbAccessManager.DBAccess.ExecuteReader(cmd))
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
while (reader.Read())
|
||||
users.Add(new User()
|
||||
{
|
||||
users.Add(new User()
|
||||
{
|
||||
Id = LgbConvert.ReadValue(reader[0], 0),
|
||||
UserName = (string)reader[1],
|
||||
DisplayName = (string)reader[2],
|
||||
RegisterTime = LgbConvert.ReadValue(reader[3], DateTime.MinValue),
|
||||
ApprovedTime = LgbConvert.ReadValue(reader[4], DateTime.MinValue),
|
||||
ApprovedBy = reader.IsDBNull(5) ? string.Empty : (string)reader[5],
|
||||
Description = (string)reader[6]
|
||||
});
|
||||
}
|
||||
Id = LgbConvert.ReadValue(reader[0], 0),
|
||||
UserName = (string)reader[1],
|
||||
DisplayName = (string)reader[2],
|
||||
RegisterTime = LgbConvert.ReadValue(reader[3], DateTime.MinValue),
|
||||
ApprovedTime = LgbConvert.ReadValue(reader[4], DateTime.MinValue),
|
||||
ApprovedBy = reader.IsDBNull(5) ? string.Empty : (string)reader[5],
|
||||
Description = (string)reader[6]
|
||||
});
|
||||
}
|
||||
return users;
|
||||
});
|
||||
}
|
||||
return users;
|
||||
}
|
||||
/// <summary>
|
||||
/// 查询所有的新注册用户
|
||||
|
@ -156,27 +147,24 @@ namespace Bootstrap.DataAccess
|
|||
/// <returns></returns>
|
||||
public virtual IEnumerable<User> RetrieveNewUsers()
|
||||
{
|
||||
return CacheManager.GetOrAdd(RetrieveNewUsersDataKey, key =>
|
||||
string sql = "select ID, UserName, DisplayName, RegisterTime, [Description] from Users Where ApprovedTime is null order by RegisterTime desc";
|
||||
List<User> users = new List<User>();
|
||||
DbCommand cmd = DbAccessManager.DBAccess.CreateCommand(CommandType.Text, sql);
|
||||
using (DbDataReader reader = DbAccessManager.DBAccess.ExecuteReader(cmd))
|
||||
{
|
||||
string sql = "select ID, UserName, DisplayName, RegisterTime, [Description] from Users Where ApprovedTime is null order by RegisterTime desc";
|
||||
List<User> users = new List<User>();
|
||||
DbCommand cmd = DbAccessManager.DBAccess.CreateCommand(CommandType.Text, sql);
|
||||
using (DbDataReader reader = DbAccessManager.DBAccess.ExecuteReader(cmd))
|
||||
while (reader.Read())
|
||||
{
|
||||
while (reader.Read())
|
||||
users.Add(new User()
|
||||
{
|
||||
users.Add(new User()
|
||||
{
|
||||
Id = LgbConvert.ReadValue(reader[0], 0),
|
||||
UserName = (string)reader[1],
|
||||
DisplayName = (string)reader[2],
|
||||
RegisterTime = LgbConvert.ReadValue(reader[3], DateTime.MinValue),
|
||||
Description = (string)reader[4]
|
||||
});
|
||||
}
|
||||
Id = LgbConvert.ReadValue(reader[0], 0),
|
||||
UserName = (string)reader[1],
|
||||
DisplayName = (string)reader[2],
|
||||
RegisterTime = LgbConvert.ReadValue(reader[3], DateTime.MinValue),
|
||||
Description = (string)reader[4]
|
||||
});
|
||||
}
|
||||
return users;
|
||||
});
|
||||
}
|
||||
return users;
|
||||
}
|
||||
/// <summary>
|
||||
/// 删除用户
|
||||
|
@ -289,28 +277,24 @@ namespace Bootstrap.DataAccess
|
|||
/// <returns></returns>
|
||||
public virtual IEnumerable<User> RetrieveUsersByRoleId(int roleId)
|
||||
{
|
||||
string key = string.Format("{0}-{1}", RetrieveUsersByRoleIdDataKey, roleId);
|
||||
return CacheManager.GetOrAdd(key, k =>
|
||||
List<User> users = new List<User>();
|
||||
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";
|
||||
DbCommand cmd = DbAccessManager.DBAccess.CreateCommand(CommandType.Text, sql);
|
||||
cmd.Parameters.Add(DbAccessManager.DBAccess.CreateParameter("@RoleID", roleId));
|
||||
using (DbDataReader reader = DbAccessManager.DBAccess.ExecuteReader(cmd))
|
||||
{
|
||||
List<User> users = new List<User>();
|
||||
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";
|
||||
DbCommand cmd = DbAccessManager.DBAccess.CreateCommand(CommandType.Text, sql);
|
||||
cmd.Parameters.Add(DbAccessManager.DBAccess.CreateParameter("@RoleID", roleId));
|
||||
using (DbDataReader reader = DbAccessManager.DBAccess.ExecuteReader(cmd))
|
||||
while (reader.Read())
|
||||
{
|
||||
while (reader.Read())
|
||||
users.Add(new User()
|
||||
{
|
||||
users.Add(new User()
|
||||
{
|
||||
Id = LgbConvert.ReadValue(reader[0], 0),
|
||||
UserName = (string)reader[1],
|
||||
DisplayName = (string)reader[2],
|
||||
Checked = (string)reader[3]
|
||||
});
|
||||
}
|
||||
Id = LgbConvert.ReadValue(reader[0], 0),
|
||||
UserName = (string)reader[1],
|
||||
DisplayName = (string)reader[2],
|
||||
Checked = (string)reader[3]
|
||||
});
|
||||
}
|
||||
return users;
|
||||
}, RetrieveUsersByRoleIdDataKey);
|
||||
}
|
||||
return users;
|
||||
}
|
||||
/// <summary>
|
||||
/// 通过角色ID保存当前授权用户(插入)
|
||||
|
@ -362,28 +346,24 @@ namespace Bootstrap.DataAccess
|
|||
/// <returns></returns>
|
||||
public virtual IEnumerable<User> RetrieveUsersByGroupId(int groupId)
|
||||
{
|
||||
string key = string.Format("{0}-{1}", RetrieveUsersByGroupIdDataKey, groupId);
|
||||
return CacheManager.GetOrAdd(key, k =>
|
||||
List<User> users = new List<User>();
|
||||
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";
|
||||
DbCommand cmd = DbAccessManager.DBAccess.CreateCommand(CommandType.Text, sql);
|
||||
cmd.Parameters.Add(DbAccessManager.DBAccess.CreateParameter("@GroupID", groupId));
|
||||
using (DbDataReader reader = DbAccessManager.DBAccess.ExecuteReader(cmd))
|
||||
{
|
||||
List<User> users = new List<User>();
|
||||
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";
|
||||
DbCommand cmd = DbAccessManager.DBAccess.CreateCommand(CommandType.Text, sql);
|
||||
cmd.Parameters.Add(DbAccessManager.DBAccess.CreateParameter("@GroupID", groupId));
|
||||
using (DbDataReader reader = DbAccessManager.DBAccess.ExecuteReader(cmd))
|
||||
while (reader.Read())
|
||||
{
|
||||
while (reader.Read())
|
||||
users.Add(new User()
|
||||
{
|
||||
users.Add(new User()
|
||||
{
|
||||
Id = LgbConvert.ReadValue(reader[0], 0),
|
||||
UserName = (string)reader[1],
|
||||
DisplayName = (string)reader[2],
|
||||
Checked = (string)reader[3]
|
||||
});
|
||||
}
|
||||
Id = LgbConvert.ReadValue(reader[0], 0),
|
||||
UserName = (string)reader[1],
|
||||
DisplayName = (string)reader[2],
|
||||
Checked = (string)reader[3]
|
||||
});
|
||||
}
|
||||
return users;
|
||||
}, RetrieveUsersByRoleIdDataKey);
|
||||
}
|
||||
return users;
|
||||
}
|
||||
/// <summary>
|
||||
/// 通过部门ID保存当前授权用户(插入)
|
||||
|
@ -444,7 +424,7 @@ namespace Bootstrap.DataAccess
|
|||
cmd.Parameters.Add(DbAccessManager.DBAccess.CreateParameter("@iconName", iconName));
|
||||
cmd.Parameters.Add(DbAccessManager.DBAccess.CreateParameter("@userName", userName));
|
||||
ret = DbAccessManager.DBAccess.ExecuteNonQuery(cmd) == 1;
|
||||
if (ret) CacheCleanUtility.ClearCache(cacheKey: $"{RetrieveUsersDataKey}*");
|
||||
if (ret) CacheCleanUtility.ClearCache(cacheKey: $"{UserHelper.RetrieveUsersDataKey}*");
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -463,7 +443,7 @@ namespace Bootstrap.DataAccess
|
|||
cmd.Parameters.Add(DbAccessManager.DBAccess.CreateParameter("@DisplayName", displayName));
|
||||
cmd.Parameters.Add(DbAccessManager.DBAccess.CreateParameter("@userName", userName));
|
||||
ret = DbAccessManager.DBAccess.ExecuteNonQuery(cmd) == 1;
|
||||
if (ret) CacheCleanUtility.ClearCache(cacheKey: $"{RetrieveUsersDataKey}*");
|
||||
if (ret) CacheCleanUtility.ClearCache(cacheKey: $"{UserHelper.RetrieveUsersDataKey}*");
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -482,7 +462,7 @@ namespace Bootstrap.DataAccess
|
|||
cmd.Parameters.Add(DbAccessManager.DBAccess.CreateParameter("@cssName", DbAdapterManager.ToDBValue(cssName)));
|
||||
cmd.Parameters.Add(DbAccessManager.DBAccess.CreateParameter("@userName", userName));
|
||||
ret = DbAccessManager.DBAccess.ExecuteNonQuery(cmd) == 1;
|
||||
if (ret) CacheCleanUtility.ClearCache(cacheKey: $"{RetrieveUsersDataKey}*");
|
||||
if (ret) CacheCleanUtility.ClearCache(cacheKey: $"{UserHelper.RetrieveUsersDataKey}*");
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue