diff --git a/Bootstrap.Admin/Bootstrap.Admin.csproj b/Bootstrap.Admin/Bootstrap.Admin.csproj
index d2f07f4e..b03f96ad 100644
--- a/Bootstrap.Admin/Bootstrap.Admin.csproj
+++ b/Bootstrap.Admin/Bootstrap.Admin.csproj
@@ -14,8 +14,8 @@
-
-
+
+
diff --git a/Bootstrap.Admin/Controllers/Api/DictsController.cs b/Bootstrap.Admin/Controllers/Api/DictsController.cs
index a88f89e1..f047226c 100644
--- a/Bootstrap.Admin/Controllers/Api/DictsController.cs
+++ b/Bootstrap.Admin/Controllers/Api/DictsController.cs
@@ -32,7 +32,7 @@ namespace Bootstrap.Admin.Controllers.Api
[HttpPost]
public bool Post([FromBody]BootstrapDict value)
{
- return DictHelper.SaveDict(value);
+ return DictHelper.Save(value);
}
///
///
@@ -42,7 +42,7 @@ namespace Bootstrap.Admin.Controllers.Api
[Authorize(Roles = "Administrators")]
public bool Delete([FromBody]IEnumerable value)
{
- return DictHelper.DeleteDict(value);
+ return DictHelper.Delete(value);
}
}
}
\ No newline at end of file
diff --git a/Bootstrap.Admin/Controllers/Api/ExceptionsController.cs b/Bootstrap.Admin/Controllers/Api/ExceptionsController.cs
index aeb509ce..582617ad 100644
--- a/Bootstrap.Admin/Controllers/Api/ExceptionsController.cs
+++ b/Bootstrap.Admin/Controllers/Api/ExceptionsController.cs
@@ -24,8 +24,9 @@ namespace Bootstrap.Admin.Controllers.Api
[HttpGet]
public QueryData
///
///
- public override IEnumerable RetrieveGroupsByRoleId(string roleId)
+ public override IEnumerable RetrievesByRoleId(string roleId)
{
- var groups = GroupHelper.RetrieveGroups().Cast().ToList();
+ var groups = GroupHelper.Retrieves().Cast().ToList();
groups.ForEach(p => p.Checked = (p.Roles != null && p.Roles.Contains(roleId)) ? "checked" : "");
return groups;
}
@@ -106,7 +106,7 @@ namespace Bootstrap.DataAccess.MongoDB
///
///
///
- public override bool SaveGroupsByRoleId(string roleId, IEnumerable groupIds)
+ public override bool SaveByRoleId(string roleId, IEnumerable groupIds)
{
var groups = MongoDbAccessManager.Groups.Find(md => md.Roles != null && md.Roles.Contains(roleId)).ToList();
@@ -134,11 +134,11 @@ namespace Bootstrap.DataAccess.MongoDB
///
///
///
- public override IEnumerable RetrieveGroupsByUserName(string userName)
+ public override IEnumerable RetrievesByUserName(string userName)
{
var groups = new List();
- var user = UserHelper.RetrieveUsers().Cast().FirstOrDefault(u => u.UserName == userName);
- var group = GroupHelper.RetrieveGroups();
+ var user = UserHelper.Retrieves().Cast().FirstOrDefault(u => u.UserName == userName);
+ var group = GroupHelper.Retrieves();
groups.AddRange(user.Groups.Select(r => group.FirstOrDefault(rl => rl.Id == r).GroupName));
if (groups.Count == 0) groups.Add("Default");
diff --git a/Bootstrap.DataAccess.MongoDB/Log.cs b/Bootstrap.DataAccess.MongoDB/Log.cs
index e3324603..af8b8974 100644
--- a/Bootstrap.DataAccess.MongoDB/Log.cs
+++ b/Bootstrap.DataAccess.MongoDB/Log.cs
@@ -13,7 +13,7 @@ namespace Bootstrap.DataAccess.MongoDB
///
///
///
- public override IEnumerable RetrieveLogs() => MongoDbAccessManager.Logs.Find(l => l.LogTime >= DateTime.Now.AddDays(-7)).ToList();
+ public override IEnumerable Retrieves() => MongoDbAccessManager.Logs.Find(l => l.LogTime >= DateTime.Now.AddDays(-7)).ToList();
///
/// 删除日志信息
///
@@ -25,7 +25,7 @@ namespace Bootstrap.DataAccess.MongoDB
///
///
///
- public override bool SaveLog(DataAccess.Log log)
+ public override bool Save(DataAccess.Log log)
{
log.LogTime = DateTime.Now;
MongoDbAccessManager.Logs.InsertOne(log);
diff --git a/Bootstrap.DataAccess.MongoDB/Menu.cs b/Bootstrap.DataAccess.MongoDB/Menu.cs
index 86d4ede7..b793eb6f 100644
--- a/Bootstrap.DataAccess.MongoDB/Menu.cs
+++ b/Bootstrap.DataAccess.MongoDB/Menu.cs
@@ -33,7 +33,7 @@ namespace Bootstrap.DataAccess.MongoDB
///
///
///
- public override bool SaveMenu(BootstrapMenu p)
+ public override bool Save(BootstrapMenu p)
{
if (p.Id == "0")
{
@@ -51,7 +51,7 @@ namespace Bootstrap.DataAccess.MongoDB
.Set(md => md.Category, p.Category)
.Set(md => md.Target, p.Target)
.Set(md => md.IsResource, p.IsResource)
- .Set(md => md.ApplicationCode, p.ApplicationCode);
+ .Set(md => md.Application, p.Application);
MongoDbAccessManager.Menus.UpdateOne(md => md.Id == p.Id, update);
return true;
}
@@ -62,7 +62,7 @@ namespace Bootstrap.DataAccess.MongoDB
///
///
///
- public override bool DeleteMenu(IEnumerable value)
+ public override bool Delete(IEnumerable value)
{
var list = new List>();
foreach (var id in value)
diff --git a/Bootstrap.DataAccess.MongoDB/Message.cs b/Bootstrap.DataAccess.MongoDB/Message.cs
index 6ff7e50b..6d22b8a1 100644
--- a/Bootstrap.DataAccess.MongoDB/Message.cs
+++ b/Bootstrap.DataAccess.MongoDB/Message.cs
@@ -13,7 +13,7 @@ namespace Bootstrap.DataAccess.MongoDB
///
///
///
- protected override IEnumerable RetrieveMessages(string userName)
+ protected override IEnumerable Retrieves(string userName)
{
var msg = MongoDbAccessManager.DBAccess.GetCollection("Messages");
return msg.Find(message => message.To == userName || message.From == userName).ToList();
diff --git a/Bootstrap.DataAccess.MongoDB/MongoDbAccessManager.cs b/Bootstrap.DataAccess.MongoDB/MongoDbAccessManager.cs
index 04de0224..99684f3e 100644
--- a/Bootstrap.DataAccess.MongoDB/MongoDbAccessManager.cs
+++ b/Bootstrap.DataAccess.MongoDB/MongoDbAccessManager.cs
@@ -1,6 +1,5 @@
using Bootstrap.Security;
using Longbow.Configuration;
-using Longbow.Data;
using Microsoft.Extensions.Primitives;
using MongoDB.Bson;
using MongoDB.Bson.Serialization;
diff --git a/Bootstrap.DataAccess.MongoDB/Role.cs b/Bootstrap.DataAccess.MongoDB/Role.cs
index 8b8473a9..02fce094 100644
--- a/Bootstrap.DataAccess.MongoDB/Role.cs
+++ b/Bootstrap.DataAccess.MongoDB/Role.cs
@@ -19,7 +19,7 @@ namespace Bootstrap.DataAccess.MongoDB
///
///
///
- public override IEnumerable RetrieveRoles()
+ public override IEnumerable Retrieves()
{
return MongoDbAccessManager.Roles.Find(FilterDefinition.Empty).ToList();
}
@@ -29,7 +29,7 @@ namespace Bootstrap.DataAccess.MongoDB
///
///
///
- public override bool SaveRole(DataAccess.Role p)
+ public override bool Save(DataAccess.Role p)
{
if (p.Id == "0")
{
@@ -54,7 +54,7 @@ namespace Bootstrap.DataAccess.MongoDB
///
///
///
- public override bool DeleteRole(IEnumerable value)
+ public override bool Delete(IEnumerable value)
{
var list = new List>();
foreach (var id in value)
@@ -73,8 +73,8 @@ namespace Bootstrap.DataAccess.MongoDB
public override IEnumerable RetrieveRolesByUserName(string userName)
{
var roles = new List();
- var user = UserHelper.RetrieveUsers().Cast().FirstOrDefault(u => u.UserName == userName);
- var role = RoleHelper.RetrieveRoles();
+ var user = UserHelper.Retrieves().Cast().FirstOrDefault(u => u.UserName == userName);
+ var role = RoleHelper.Retrieves();
roles.AddRange(user.Roles.Select(r => role.FirstOrDefault(rl => rl.Id == r).RoleName));
if (roles.Count == 0) roles.Add("Default");
@@ -86,10 +86,10 @@ namespace Bootstrap.DataAccess.MongoDB
///
///
///
- public override IEnumerable RetrieveRolesByUserId(string userId)
+ public override IEnumerable RetrievesByUserId(string userId)
{
- var roles = RoleHelper.RetrieveRoles();
- var user = UserHelper.RetrieveUsers().Cast().FirstOrDefault(u => u.Id == userId);
+ var roles = RoleHelper.Retrieves();
+ var user = UserHelper.Retrieves().Cast().FirstOrDefault(u => u.Id == userId);
roles.ToList().ForEach(r => r.Checked = user.Roles.Any(id => id == r.Id) ? "checked" : "");
return roles;
}
@@ -100,7 +100,7 @@ namespace Bootstrap.DataAccess.MongoDB
///
///
///
- public override bool SaveRolesByUserId(string userId, IEnumerable roleIds)
+ public override bool SaveByUserId(string userId, IEnumerable roleIds)
{
MongoDbAccessManager.Users.FindOneAndUpdate(u => u.Id == userId, Builders.Update.Set(u => u.Roles, roleIds));
return true;
@@ -111,9 +111,9 @@ namespace Bootstrap.DataAccess.MongoDB
///
///
///
- public override IEnumerable RetrieveRolesByMenuId(string menuId)
+ public override IEnumerable RetrievesByMenuId(string menuId)
{
- var roles = RoleHelper.RetrieveRoles().Cast().ToList();
+ var roles = RoleHelper.Retrieves().Cast().ToList();
roles.ForEach(r => r.Checked = (r.Menus != null && r.Menus.Contains(menuId)) ? "checked" : "");
roles.ForEach(r => r.Menus = null);
return roles;
@@ -125,7 +125,7 @@ namespace Bootstrap.DataAccess.MongoDB
///
///
///
- public override bool SavaRolesByMenuId(string menuId, IEnumerable roleIds)
+ public override bool SavaByMenuId(string menuId, IEnumerable roleIds)
{
var roles = MongoDbAccessManager.Roles.Find(md => md.Menus != null && md.Menus.Contains(menuId)).ToList();
@@ -155,10 +155,10 @@ namespace Bootstrap.DataAccess.MongoDB
///
///
///
- public override IEnumerable RetrieveRolesByGroupId(string groupId)
+ public override IEnumerable RetrievesByGroupId(string groupId)
{
- var roles = RoleHelper.RetrieveRoles();
- var group = GroupHelper.RetrieveGroups().Cast().FirstOrDefault(u => u.Id == groupId);
+ var roles = RoleHelper.Retrieves();
+ var group = GroupHelper.Retrieves().Cast().FirstOrDefault(u => u.Id == groupId);
roles.ToList().ForEach(r => r.Checked = group.Roles.Any(id => id == r.Id) ? "checked" : "");
return roles;
}
@@ -169,7 +169,7 @@ namespace Bootstrap.DataAccess.MongoDB
///
///
///
- public override bool SaveRolesByGroupId(string groupId, IEnumerable roleIds)
+ public override bool SaveByGroupId(string groupId, IEnumerable roleIds)
{
MongoDbAccessManager.Groups.FindOneAndUpdate(u => u.Id == groupId, Builders.Update.Set(u => u.Roles, roleIds));
return true;
@@ -183,7 +183,7 @@ namespace Bootstrap.DataAccess.MongoDB
public override IEnumerable RetrieveRolesByUrl(string url)
{
var menu = MongoDbAccessManager.Menus.Find(md => md.Url.StartsWith(url)).FirstOrDefault();
- var ret = RoleHelper.RetrieveRoles().Cast().Where(md => md.Menus != null && md.Menus.Contains(menu.Id)).Select(m => m.RoleName).ToList();
+ var ret = RoleHelper.Retrieves().Cast().Where(md => md.Menus != null && md.Menus.Contains(menu.Id)).Select(m => m.RoleName).ToList();
if (!ret.Contains("Administrators")) ret.Add("Administrators");
return ret;
}
diff --git a/Bootstrap.DataAccess.MongoDB/Task.cs b/Bootstrap.DataAccess.MongoDB/Task.cs
index de6b0083..7a42dd05 100644
--- a/Bootstrap.DataAccess.MongoDB/Task.cs
+++ b/Bootstrap.DataAccess.MongoDB/Task.cs
@@ -12,7 +12,7 @@ namespace Bootstrap.DataAccess.MongoDB
///
///
///
- public override IEnumerable RetrieveTasks()
+ public override IEnumerable Retrieves()
{
var users = MongoDbAccessManager.DBAccess.GetCollection("Tasks");
return users.Find(FilterDefinition.Empty).SortByDescending(task => task.AssignTime).ToList();
diff --git a/Bootstrap.DataAccess.MongoDB/User.cs b/Bootstrap.DataAccess.MongoDB/User.cs
index bc961f0e..6e0288b8 100644
--- a/Bootstrap.DataAccess.MongoDB/User.cs
+++ b/Bootstrap.DataAccess.MongoDB/User.cs
@@ -61,7 +61,7 @@ namespace Bootstrap.DataAccess.MongoDB
///
///
///
- public override IEnumerable RetrieveUsers()
+ public override IEnumerable Retrieves()
{
var project = Builders.Projection.Include(u => u.Id)
.Include(u => u.UserName)
@@ -80,7 +80,7 @@ namespace Bootstrap.DataAccess.MongoDB
///
///
///
- public override bool SaveUser(DataAccess.User user)
+ public override bool Save(DataAccess.User user)
{
// 已经存在或者已经在新用户中了
if (UserHelper.RetrieveUserByUserName(user.UserName) != null || UserHelper.RetrieveNewUsers().Any(u => u.UserName == user.UserName)) return false;
@@ -98,7 +98,7 @@ namespace Bootstrap.DataAccess.MongoDB
ApprovedBy = user.ApprovedBy,
Roles = new List(),
Groups = new List(),
- Icon = $"{DictHelper.RetrieveIconFolderPath().Code}default.jpg",
+ Icon = $"{DictHelper.RetrieveIconFolderPath()}default.jpg",
Description = user.Description
});
return true;
@@ -111,7 +111,7 @@ namespace Bootstrap.DataAccess.MongoDB
///
///
///
- public override bool UpdateUser(string id, string password, string displayName)
+ public override bool Update(string id, string password, string displayName)
{
var passSalt = LgbCryptography.GenerateSalt();
var newPassword = LgbCryptography.ComputeHash(password, passSalt);
@@ -145,7 +145,7 @@ namespace Bootstrap.DataAccess.MongoDB
///
///
///
- public override bool DeleteUser(IEnumerable value)
+ public override bool Delete(IEnumerable value)
{
var list = new List>();
foreach (var id in value)
@@ -161,9 +161,9 @@ namespace Bootstrap.DataAccess.MongoDB
///
///
///
- public override IEnumerable RetrieveUsersByRoleId(string roleId)
+ public override IEnumerable RetrievesByRoleId(string roleId)
{
- var users = UserHelper.RetrieveUsers().Cast().ToList();
+ var users = UserHelper.Retrieves().Cast().ToList();
users.ForEach(p => p.Checked = (p.Roles != null && p.Roles.Contains(roleId)) ? "checked" : "");
return users;
}
@@ -174,7 +174,7 @@ namespace Bootstrap.DataAccess.MongoDB
///
///
///
- public override bool SaveUsersByRoleId(string roleId, IEnumerable userIds)
+ public override bool SaveByRoleId(string roleId, IEnumerable userIds)
{
var users = MongoDbAccessManager.Users.Find(md => md.Roles != null && md.Roles.Contains(roleId)).ToList();
@@ -202,9 +202,9 @@ namespace Bootstrap.DataAccess.MongoDB
///
///
///
- public override IEnumerable RetrieveUsersByGroupId(string groupId)
+ public override IEnumerable RetrievesByGroupId(string groupId)
{
- var users = UserHelper.RetrieveUsers().Cast().ToList();
+ var users = UserHelper.Retrieves().Cast().ToList();
users.ForEach(p => p.Checked = (p.Groups != null && p.Groups.Contains(groupId)) ? "checked" : "");
return users;
}
@@ -215,7 +215,7 @@ namespace Bootstrap.DataAccess.MongoDB
///
///
///
- public override bool SaveUsersByGroupId(string groupId, IEnumerable userIds)
+ public override bool SaveByGroupId(string groupId, IEnumerable userIds)
{
var users = MongoDbAccessManager.Users.Find(md => md.Groups != null && md.Groups.Contains(groupId)).ToList();
diff --git a/Bootstrap.DataAccess.MySQL/Bootstrap.DataAccess.MySQL.csproj b/Bootstrap.DataAccess.MySQL/Bootstrap.DataAccess.MySQL.csproj
deleted file mode 100644
index 31fad426..00000000
--- a/Bootstrap.DataAccess.MySQL/Bootstrap.DataAccess.MySQL.csproj
+++ /dev/null
@@ -1,21 +0,0 @@
-
-
-
- netstandard2.0
- true
- ..\Keys\Longbow.Utility.snk
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/Bootstrap.DataAccess.MySQL/Dict.cs b/Bootstrap.DataAccess.MySQL/Dict.cs
deleted file mode 100644
index 563d03d9..00000000
--- a/Bootstrap.DataAccess.MySQL/Dict.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace Bootstrap.DataAccess.MySQL
-{
- ///
- ///
- ///
- public class Dict : DataAccess.Dict
- {
-
- }
-}
diff --git a/Bootstrap.DataAccess.MySQL/Exceptions.cs b/Bootstrap.DataAccess.MySQL/Exceptions.cs
deleted file mode 100644
index 140d6b5b..00000000
--- a/Bootstrap.DataAccess.MySQL/Exceptions.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace Bootstrap.DataAccess.MySQL
-{
- ///
- ///
- ///
- public class Exceptions : DataAccess.Exceptions
- {
-
- }
-}
diff --git a/Bootstrap.DataAccess.MySQL/Group.cs b/Bootstrap.DataAccess.MySQL/Group.cs
deleted file mode 100644
index f6571f38..00000000
--- a/Bootstrap.DataAccess.MySQL/Group.cs
+++ /dev/null
@@ -1,228 +0,0 @@
-using Longbow.Data;
-using System;
-using System.Collections.Generic;
-using System.Data;
-using System.Data.Common;
-using System.Linq;
-
-namespace Bootstrap.DataAccess.MySQL
-{
- ///
- ///
- ///
- public class Group : DataAccess.Group
- {
- ///
- ///
- ///
- ///
- public override IEnumerable RetrieveGroups()
- {
- string sql = "select * from `Groups`";
- List groups = new List();
- DbCommand cmd = DbAccessManager.DBAccess.CreateCommand(CommandType.Text, sql);
- using (DbDataReader reader = DbAccessManager.DBAccess.ExecuteReader(cmd))
- {
- while (reader.Read())
- {
- groups.Add(new Group()
- {
- Id = reader[0].ToString(),
- GroupName = (string)reader[1],
- Description = reader.IsDBNull(2) ? string.Empty : (string)reader[2]
- });
- }
- }
- return groups;
- }
-
- ///
- ///
- ///
- ///
- ///
- public override bool SaveGroup(DataAccess.Group p)
- {
- bool ret = false;
- if (p.GroupName.Length > 50) p.GroupName = p.GroupName.Substring(0, 50);
- if (!string.IsNullOrEmpty(p.Description) && p.Description.Length > 500) p.Description = p.Description.Substring(0, 500);
- string sql = string.IsNullOrEmpty(p.Id) ?
- "Insert Into `Groups` (GroupName, Description) Values (@GroupName, @Description)" :
- "Update `Groups` set GroupName = @GroupName, Description = @Description where ID = @ID";
- using (DbCommand cmd = DbAccessManager.DBAccess.CreateCommand(CommandType.Text, sql))
- {
- cmd.Parameters.Add(DbAccessManager.DBAccess.CreateParameter("@ID", p.Id));
- cmd.Parameters.Add(DbAccessManager.DBAccess.CreateParameter("@GroupName", p.GroupName));
- cmd.Parameters.Add(DbAccessManager.DBAccess.CreateParameter("@Description", DbAdapterManager.ToDBValue(p.Description)));
- ret = DbAccessManager.DBAccess.ExecuteNonQuery(cmd) == 1;
- }
- return ret;
- }
-
- ///
- ///
- /// 删除群组信息
- ///
- ///
- public override bool DeleteGroup(IEnumerable value)
- {
- bool ret = false;
- var ids = string.Join(",", value);
- using (TransactionPackage transaction = DbAccessManager.DBAccess.BeginTransaction())
- {
- using (DbCommand cmd = DbAccessManager.DBAccess.CreateCommand(CommandType.Text, $"delete from UserGroup where GroupID in ({ids})"))
- {
- try
- {
- DbAccessManager.DBAccess.ExecuteNonQuery(cmd, transaction);
-
- cmd.CommandText = $"delete from RoleGroup where GroupID in ({ids})";
- DbAccessManager.DBAccess.ExecuteNonQuery(cmd, transaction);
-
- cmd.CommandText = $"delete from `Groups` where ID in ({ids})";
- DbAccessManager.DBAccess.ExecuteNonQuery(cmd, transaction);
-
- transaction.CommitTransaction();
- ret = true;
- }
- catch (Exception ex)
- {
- transaction.RollbackTransaction();
- throw ex;
- }
- }
- }
- return ret;
- }
-
- ///
- ///
- ///
- ///
- ///
- public override IEnumerable RetrieveGroupsByUserId(string userId)
- {
- 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();
- 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())
- {
- groups.Add(new Group()
- {
- Id = reader[0].ToString(),
- GroupName = (string)reader[1],
- Description = reader.IsDBNull(2) ? string.Empty : (string)reader[2],
- Checked = (string)reader[3]
- });
- }
- }
- return groups;
- }
-
- ///
- /// 保存用户部门关系
- ///
- ///
- ///
- ///
- public override bool SaveGroupsByUserId(string userId, IEnumerable groupIds)
- {
- var ret = false;
-
- //判断用户是否选定角色
- using (TransactionPackage transaction = DbAccessManager.DBAccess.BeginTransaction())
- {
- try
- {
- //删除用户部门表中该用户所有的部门关系
- string sql = $"delete from UserGroup where UserID = {userId}";
- using (DbCommand cmd = DbAccessManager.DBAccess.CreateCommand(CommandType.Text, sql))
- {
- DbAccessManager.DBAccess.ExecuteNonQuery(cmd, transaction);
-
- groupIds.ToList().ForEach(gId =>
- {
- cmd.CommandText = $"Insert Into UserGroup (UserID, GroupID) Values ({userId}, {gId})";
- DbAccessManager.DBAccess.ExecuteNonQuery(cmd, transaction);
- });
- transaction.CommitTransaction();
- }
- ret = true;
- }
- catch (Exception ex)
- {
- transaction.RollbackTransaction();
- throw ex;
- }
- }
- return ret;
- }
-
- ///
- ///
- ///
- ///
- ///
- public override IEnumerable RetrieveGroupsByRoleId(string roleId)
- {
- 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";
- 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())
- {
- groups.Add(new Group()
- {
- Id = reader[0].ToString(),
- GroupName = (string)reader[1],
- Description = reader.IsDBNull(2) ? string.Empty : (string)reader[2],
- Checked = (string)reader[3]
- });
- }
- }
- return groups;
- }
-
- ///
- /// 根据角色ID以及选定的部门ID,保到角色部门表
- ///
- ///
- ///
- ///
- public override bool SaveGroupsByRoleId(string roleId, IEnumerable groupIds)
- {
- bool ret = false;
- using (TransactionPackage transaction = DbAccessManager.DBAccess.BeginTransaction())
- {
- try
- {
- //删除角色部门表该角色所有的部门
- string sql = $"delete from RoleGroup where RoleID = {roleId}";
- using (DbCommand cmd = DbAccessManager.DBAccess.CreateCommand(CommandType.Text, sql))
- {
- DbAccessManager.DBAccess.ExecuteNonQuery(cmd, transaction);
- //批插入角色部门表
- groupIds.ToList().ForEach(gId =>
- {
- cmd.CommandText = $"Insert Into RoleGroup (RoleID, GroupID) Values ({roleId}, {gId})";
- DbAccessManager.DBAccess.ExecuteNonQuery(cmd, transaction);
- });
- transaction.CommitTransaction();
- }
- ret = true;
- }
- catch (Exception ex)
- {
- transaction.RollbackTransaction();
- throw ex;
- }
- }
- return ret;
- }
- }
-}
diff --git a/Bootstrap.DataAccess.MySQL/Log.cs b/Bootstrap.DataAccess.MySQL/Log.cs
deleted file mode 100644
index 1b313ab0..00000000
--- a/Bootstrap.DataAccess.MySQL/Log.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace Bootstrap.DataAccess.MySQL
-{
- ///
- ///
- ///
- public class Log : DataAccess.Log
- {
-
- }
-}
diff --git a/Bootstrap.DataAccess.MySQL/Menu.cs b/Bootstrap.DataAccess.MySQL/Menu.cs
deleted file mode 100644
index 78a2068b..00000000
--- a/Bootstrap.DataAccess.MySQL/Menu.cs
+++ /dev/null
@@ -1,124 +0,0 @@
-using Bootstrap.Security;
-using Longbow.Data;
-using System;
-using System.Collections.Generic;
-using System.Data;
-using System.Data.Common;
-using System.Linq;
-
-namespace Bootstrap.DataAccess.MySQL
-{
- ///
- ///
- ///
- public class Menu : DataAccess.Menu
- {
- ///
- ///
- ///
- ///
- ///
- public override IEnumerable RetrieveAllMenus(string userName)
- {
- var menus = new List();
- using (DbCommand cmd = DbAccessManager.DBAccess.CreateCommand(CommandType.Text, "select n.ID, n.ParentId, n.Name, n.Order, n.Icon, n.Url, n.Category, n.Target, n.IsResource, n.Application, d.Name as CategoryName, ln.Name as ParentName from Navigations n inner join Dicts d on n.Category = d.Code and d.Category = @Category and d.Define = 0 left join Navigations ln on n.ParentId = ln.ID inner join (select nr.NavigationID from Users u inner join UserRole ur on ur.UserID = u.ID inner join NavigationRole nr on nr.RoleID = ur.RoleID where u.UserName = @UserName union select nr.NavigationID from Users u inner join UserGroup ug on u.ID = ug.UserID inner join RoleGroup rg on rg.GroupID = ug.GroupID inner join NavigationRole nr on nr.RoleID = rg.RoleID where u.UserName = @UserName union select n.ID from Navigations n where EXISTS (select UserName from Users u inner join UserRole ur on u.ID = ur.UserID inner join Roles r on ur.RoleID = r.ID where u.UserName = @UserName and r.RoleName = @RoleName)) nav on n.ID = nav.NavigationID"))
- {
- cmd.Parameters.Add(DbAccessManager.DBAccess.CreateParameter("@UserName", userName));
- cmd.Parameters.Add(DbAccessManager.DBAccess.CreateParameter("@Category", "菜单"));
- cmd.Parameters.Add(DbAccessManager.DBAccess.CreateParameter("@RoleName", "Administrators"));
- using (DbDataReader reader = DbAccessManager.DBAccess.ExecuteReader(cmd))
- {
- while (reader.Read())
- {
- menus.Add(new BootstrapMenu
- {
- Id = reader[0].ToString(),
- ParentId = reader[1].ToString(),
- Name = (string)reader[2],
- Order = reader.IsDBNull(3) ? 0 : (int)reader[3],
- Icon = reader.IsDBNull(4) ? string.Empty : (string)reader[4],
- Url = reader.IsDBNull(5) ? string.Empty : (string)reader[5],
- Category = (string)reader[6],
- Target = (string)reader[7],
- IsResource = reader.IsDBNull(8) ? 0 : (int)reader[8] > 0 ? 1 : 0,
- ApplicationCode = reader.IsDBNull(9) ? string.Empty : (string)reader[9],
- CategoryName = (string)reader[10],
- ParentName = reader.IsDBNull(11) ? string.Empty : (string)reader[11],
- });
- }
- }
- }
- return menus;
- }
-
- ///
- /// Saves the menu.
- ///
- /// true, if menu was saved, false otherwise.
- /// P.
- public override bool SaveMenu(BootstrapMenu p)
- {
- if (string.IsNullOrEmpty(p.Name)) return false;
- bool ret = false;
- if (p.Name.Length > 50) p.Name = p.Name.Substring(0, 50);
- if (p.Icon != null && p.Icon.Length > 50) p.Icon = p.Icon.Substring(0, 50);
- if (p.Url != null && p.Url.Length > 4000) p.Url = p.Url.Substring(0, 4000);
- string sql = string.IsNullOrEmpty(p.Id) ?
- "Insert Into Navigations (ParentId, Name, `Order`, Icon, Url, Category, Target, IsResource, Application) Values (@ParentId, @Name, @Order, @Icon, @Url, @Category, @Target, @IsResource, @ApplicationCode)" :
- "Update Navigations set ParentId = @ParentId, Name = @Name, `Order` = @Order, Icon = @Icon, Url = @Url, Category = @Category, Target = @Target, IsResource = @IsResource, Application = @ApplicationCode where ID = @ID";
- using (DbCommand cmd = DbAccessManager.DBAccess.CreateCommand(CommandType.Text, sql))
- {
- cmd.Parameters.Add(DbAccessManager.DBAccess.CreateParameter("@ID", p.Id));
- cmd.Parameters.Add(DbAccessManager.DBAccess.CreateParameter("@ParentId", p.ParentId));
- cmd.Parameters.Add(DbAccessManager.DBAccess.CreateParameter("@Name", p.Name));
- cmd.Parameters.Add(DbAccessManager.DBAccess.CreateParameter("@Order", p.Order));
- cmd.Parameters.Add(DbAccessManager.DBAccess.CreateParameter("@Icon", DbAdapterManager.ToDBValue(p.Icon)));
- cmd.Parameters.Add(DbAccessManager.DBAccess.CreateParameter("@Url", DbAdapterManager.ToDBValue(p.Url)));
- cmd.Parameters.Add(DbAccessManager.DBAccess.CreateParameter("@Category", p.Category));
- cmd.Parameters.Add(DbAccessManager.DBAccess.CreateParameter("@Target", p.Target));
- cmd.Parameters.Add(DbAccessManager.DBAccess.CreateParameter("@IsResource", p.IsResource));
- cmd.Parameters.Add(DbAccessManager.DBAccess.CreateParameter("@ApplicationCode", p.ApplicationCode));
- ret = DbAccessManager.DBAccess.ExecuteNonQuery(cmd) == 1;
- }
- return ret;
- }
-
- ///
- ///
- /// 通过角色ID保存当前授权菜单
- ///
- ///
- ///
- ///
- public override bool SaveMenusByRoleId(string roleId, IEnumerable menuIds)
- {
- bool ret = false;
- using (TransactionPackage transaction = DbAccessManager.DBAccess.BeginTransaction())
- {
- try
- {
- //删除菜单角色表该角色所有的菜单
- string sql = $"delete from NavigationRole where RoleID = {roleId}";
- using (DbCommand cmd = DbAccessManager.DBAccess.CreateCommand(CommandType.Text, sql))
- {
- DbAccessManager.DBAccess.ExecuteNonQuery(cmd, transaction);
- //批插入菜单角色表
- menuIds.ToList().ForEach(mId =>
- {
- cmd.CommandText = $"Insert Into NavigationRole (NavigationID, RoleID) Values ( {mId}, {roleId})";
- DbAccessManager.DBAccess.ExecuteNonQuery(cmd, transaction);
- });
- transaction.CommitTransaction();
- }
- ret = true;
- }
- catch (Exception ex)
- {
- transaction.RollbackTransaction();
- throw ex;
- }
- }
- return ret;
- }
- }
-}
diff --git a/Bootstrap.DataAccess.MySQL/Message.cs b/Bootstrap.DataAccess.MySQL/Message.cs
deleted file mode 100644
index 9621fce6..00000000
--- a/Bootstrap.DataAccess.MySQL/Message.cs
+++ /dev/null
@@ -1,50 +0,0 @@
-using Longbow;
-using System;
-using System.Collections.Generic;
-using System.Data;
-using System.Data.Common;
-
-namespace Bootstrap.DataAccess.MySQL
-{
- ///
- ///
- ///
- public class Message : DataAccess.Message
- {
- ///
- /// 所有有关userName所有消息列表
- ///
- ///
- ///
- protected override IEnumerable RetrieveMessages(string userName)
- {
- 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 messages = new List();
- 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())
- {
- messages.Add(new DataAccess.Message()
- {
- Id = reader[0].ToString(),
- 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;
- }
- }
-}
diff --git a/Bootstrap.DataAccess.MySQL/Role.cs b/Bootstrap.DataAccess.MySQL/Role.cs
deleted file mode 100644
index bc146056..00000000
--- a/Bootstrap.DataAccess.MySQL/Role.cs
+++ /dev/null
@@ -1,174 +0,0 @@
-using Longbow.Data;
-using System;
-using System.Collections.Generic;
-using System.Data;
-using System.Data.Common;
-using System.Linq;
-
-namespace Bootstrap.DataAccess.MySQL
-{
- ///
- ///
- ///
- public class Role : DataAccess.Role
- {
- ///
- ///
- ///
- ///
- ///
- public override IEnumerable RetrieveRolesByUserName(string userName)
- {
- var entities = new List();
- using (DbCommand cmd = DbAccessManager.DBAccess.CreateCommand(CommandType.Text, "select r.RoleName from Roles r inner join UserRole ur on r.ID=ur.RoleID inner join Users u on ur.UserID = u.ID and u.UserName = @UserName union select r.RoleName from Roles r inner join RoleGroup rg on r.ID = rg.RoleID inner join `Groups` g on rg.GroupID = g.ID inner join UserGroup ug on ug.GroupID = g.ID inner join Users u on ug.UserID = u.ID and u.UserName=@UserName"))
- {
- cmd.Parameters.Add(DbAccessManager.DBAccess.CreateParameter("@UserName", userName));
- using (DbDataReader reader = DbAccessManager.DBAccess.ExecuteReader(cmd))
- {
- while (reader.Read())
- {
- entities.Add((string)reader[0]);
- }
- }
- }
- return entities;
- }
-
- ///
- ///
- ///
- ///
- ///
- public override IEnumerable RetrieveRolesByUrl(string url)
- {
- string sql = "select distinct r.RoleName, r.Description from Roles r inner join NavigationRole nr on r.ID = nr.RoleID inner join Navigations n on nr.NavigationID = n.ID and n.Application = '0' and n.Url like @Url";
- var ret = new List();
- var cmd = DbAccessManager.DBAccess.CreateCommand(CommandType.Text, sql);
- cmd.Parameters.Add(DbAccessManager.DBAccess.CreateParameter("@Url", $"{url}%"));
- using (DbDataReader reader = DbAccessManager.DBAccess.ExecuteReader(cmd))
- {
- while (reader.Read())
- {
- ret.Add((string)reader[0]);
- }
- }
- if (ret.Count == 0) ret.Add("Administrators");
- return ret;
- }
-
- ///
- ///
- /// 保存用户角色关系
- ///
- ///
- ///
- ///
- public override bool SaveRolesByUserId(string userId, IEnumerable roleIds)
- {
- var ret = false;
- //判断用户是否选定角色
- using (TransactionPackage transaction = DbAccessManager.DBAccess.BeginTransaction())
- {
- try
- {
- // delete user from config table
- string sql = $"delete from UserRole where UserID = {userId}";
- using (DbCommand cmd = DbAccessManager.DBAccess.CreateCommand(CommandType.Text, sql))
- {
- DbAccessManager.DBAccess.ExecuteNonQuery(cmd, transaction);
- roleIds.ToList().ForEach(rId =>
- {
- cmd.CommandText = $"Insert Into UserRole (UserID, RoleID) Values ( {userId}, {rId})";
- DbAccessManager.DBAccess.ExecuteNonQuery(cmd, transaction);
- });
- transaction.CommitTransaction();
- }
- ret = true;
- }
- catch (Exception ex)
- {
- transaction.RollbackTransaction();
- throw ex;
- }
- }
- return ret;
- }
-
- ///
- ///
- ///
- ///
- ///
- ///
- public override bool SavaRolesByMenuId(string menuId, IEnumerable roleIds)
- {
- var ret = false;
- //判断用户是否选定角色
- using (TransactionPackage transaction = DbAccessManager.DBAccess.BeginTransaction())
- {
- try
- {
- // delete role from config table
- string sql = $"delete from NavigationRole where NavigationID = {menuId}";
- using (DbCommand cmd = DbAccessManager.DBAccess.CreateCommand(CommandType.Text, sql))
- {
- DbAccessManager.DBAccess.ExecuteNonQuery(cmd, transaction);
- // insert batch data into config table
- roleIds.ToList().ForEach(rId =>
- {
- cmd.CommandText = $"Insert Into NavigationRole (NavigationID, RoleID) Values ( {menuId}, {rId})";
- DbAccessManager.DBAccess.ExecuteNonQuery(cmd, transaction);
- });
- transaction.CommitTransaction();
- }
- ret = true;
- }
- catch (Exception ex)
- {
- transaction.RollbackTransaction();
- throw ex;
- }
- }
- return ret;
- }
-
- ///
- /// 根据GroupId更新Roles信息,删除旧的Roles信息,插入新的Roles信息
- ///
- ///
- ///
- ///
- public override bool SaveRolesByGroupId(string groupId, IEnumerable roleIds)
- {
- var ret = false;
- //构造表格
- using (TransactionPackage transaction = DbAccessManager.DBAccess.BeginTransaction())
- {
- try
- {
- // delete user from config table
- string sql = $"delete from RoleGroup where GroupID = {groupId}";
- using (DbCommand cmd = DbAccessManager.DBAccess.CreateCommand(CommandType.Text, sql))
- {
- DbAccessManager.DBAccess.ExecuteNonQuery(cmd, transaction);
-
- // insert batch data into config table
- roleIds.ToList().ForEach(rId =>
- {
- cmd.CommandText = $"Insert Into RoleGroup (GroupID, RoleID) Values ( {groupId}, {rId})";
- DbAccessManager.DBAccess.ExecuteNonQuery(cmd, transaction);
- });
- transaction.CommitTransaction();
- }
- ret = true;
- }
- catch (Exception ex)
- {
- transaction.RollbackTransaction();
- throw ex;
- }
- }
- return ret;
- }
- }
-}
\ No newline at end of file
diff --git a/Bootstrap.DataAccess.MySQL/Task.cs b/Bootstrap.DataAccess.MySQL/Task.cs
deleted file mode 100644
index abc4cd42..00000000
--- a/Bootstrap.DataAccess.MySQL/Task.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-using Longbow;
-using System;
-using System.Collections.Generic;
-using System.Data;
-using System.Data.Common;
-
-namespace Bootstrap.DataAccess.MySQL
-{
- public class Task : DataAccess.Task
- {
- ///
- /// 查询所有任务
- ///
- ///
- public override IEnumerable RetrieveTasks()
- {
- 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 tasks = new List();
- DbCommand cmd = DbAccessManager.DBAccess.CreateCommand(CommandType.Text, sql);
- using (DbDataReader reader = DbAccessManager.DBAccess.ExecuteReader(cmd))
- {
- while (reader.Read())
- {
- tasks.Add(new DataAccess.Task()
- {
- Id = reader[0].ToString(),
- 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;
- }
- }
-}
diff --git a/Bootstrap.DataAccess.MySQL/User.cs b/Bootstrap.DataAccess.MySQL/User.cs
deleted file mode 100644
index 338458ea..00000000
--- a/Bootstrap.DataAccess.MySQL/User.cs
+++ /dev/null
@@ -1,116 +0,0 @@
-using Bootstrap.Security;
-using Longbow.Data;
-using System;
-using System.Collections.Generic;
-using System.Data;
-using System.Data.Common;
-using System.Linq;
-
-namespace Bootstrap.DataAccess.MySQL
-{
- ///
- /// 用户表实体类
- ///
- public class User : DataAccess.User
- {
- ///
- /// 通过角色ID保存当前授权用户(插入)
- ///
- /// 角色ID
- /// 用户ID数组
- ///
- public override bool SaveUsersByRoleId(string roleId, IEnumerable userIds)
- {
- bool ret = false;
- using (TransactionPackage transaction = DbAccessManager.DBAccess.BeginTransaction())
- {
- try
- {
- //删除用户角色表该角色所有的用户
- string sql = $"delete from UserRole where RoleID = {roleId}";
- using (DbCommand cmd = DbAccessManager.DBAccess.CreateCommand(CommandType.Text, sql))
- {
- DbAccessManager.DBAccess.ExecuteNonQuery(cmd, transaction);
- //批插入用户角色表
- userIds.ToList().ForEach(uId =>
- {
- cmd.CommandText = $"Insert Into UserRole (UserID, RoleID) Values ( {uId}, {roleId})";
- DbAccessManager.DBAccess.ExecuteNonQuery(cmd, transaction);
- });
- transaction.CommitTransaction();
- }
- ret = true;
- }
- catch (Exception ex)
- {
- transaction.RollbackTransaction();
- throw ex;
- }
- }
- return ret;
- }
- ///
- /// 通过部门ID保存当前授权用户(插入)
- ///
- /// GroupID
- /// 用户ID数组
- ///
- public override bool SaveUsersByGroupId(string groupId, IEnumerable userIds)
- {
- bool ret = false;
- using (TransactionPackage transaction = DbAccessManager.DBAccess.BeginTransaction())
- {
- try
- {
- //删除用户角色表该角色所有的用户
- string sql = $"delete from UserGroup where GroupID = {groupId}";
- using (DbCommand cmd = DbAccessManager.DBAccess.CreateCommand(CommandType.Text, sql))
- {
- DbAccessManager.DBAccess.ExecuteNonQuery(cmd, transaction);
- //批插入用户角色表
- userIds.ToList().ForEach(uId =>
- {
- cmd.CommandText = $"Insert Into UserGroup (UserID, GroupID) Values ( {uId}, {groupId})";
- DbAccessManager.DBAccess.ExecuteNonQuery(cmd, transaction);
- });
- transaction.CommitTransaction();
- }
- ret = true;
- }
- catch (Exception ex)
- {
- transaction.RollbackTransaction();
- throw ex;
- }
- }
- return ret;
- }
- ///
- ///
- ///
- ///
- ///
- public override BootstrapUser RetrieveUserByUserName(string userName)
- {
- BootstrapUser user = null;
- var sql = "select UserName, DisplayName, CONCAT(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())
- {
- user = new BootstrapUser
- {
- UserName = (string)reader[0],
- DisplayName = (string)reader[1],
- Icon = (string)reader[2],
- Css = reader.IsDBNull(3) ? string.Empty : (string)reader[3]
- };
- }
- }
- return user;
- }
- }
-}
diff --git a/Bootstrap.DataAccess.SQLite/Bootstrap.DataAccess.SQLite.csproj b/Bootstrap.DataAccess.SQLite/Bootstrap.DataAccess.SQLite.csproj
deleted file mode 100644
index 7dc06d48..00000000
--- a/Bootstrap.DataAccess.SQLite/Bootstrap.DataAccess.SQLite.csproj
+++ /dev/null
@@ -1,25 +0,0 @@
-
-
-
- netstandard2.0
- true
- ..\Keys\Longbow.Utility.snk
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/Bootstrap.DataAccess.SQLite/Dict.cs b/Bootstrap.DataAccess.SQLite/Dict.cs
deleted file mode 100644
index 5a52557b..00000000
--- a/Bootstrap.DataAccess.SQLite/Dict.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace Bootstrap.DataAccess.SQLite
-{
- ///
- ///
- ///
- public class Dict : DataAccess.Dict
- {
-
- }
-}
diff --git a/Bootstrap.DataAccess.SQLite/Exceptions.cs b/Bootstrap.DataAccess.SQLite/Exceptions.cs
deleted file mode 100644
index 896aed3f..00000000
--- a/Bootstrap.DataAccess.SQLite/Exceptions.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace Bootstrap.DataAccess.SQLite
-{
- ///
- ///
- ///
- public class Exceptions : DataAccess.Exceptions
- {
-
- }
-}
diff --git a/Bootstrap.DataAccess.SQLite/Group.cs b/Bootstrap.DataAccess.SQLite/Group.cs
deleted file mode 100644
index adb3374d..00000000
--- a/Bootstrap.DataAccess.SQLite/Group.cs
+++ /dev/null
@@ -1,90 +0,0 @@
-using Longbow.Data;
-using System;
-using System.Collections.Generic;
-using System.Data;
-using System.Data.Common;
-using System.Linq;
-
-namespace Bootstrap.DataAccess.SQLite
-{
- ///
- ///
- ///
- public class Group : DataAccess.Group
- {
- ///
- /// 保存用户部门关系
- ///
- ///
- ///
- ///
- public override bool SaveGroupsByUserId(string userId, IEnumerable groupIds)
- {
- var ret = false;
-
- //判断用户是否选定角色
- using (TransactionPackage transaction = DbAccessManager.DBAccess.BeginTransaction())
- {
- try
- {
- //删除用户部门表中该用户所有的部门关系
- string sql = $"delete from UserGroup where UserID = {userId}";
- using (DbCommand cmd = DbAccessManager.DBAccess.CreateCommand(CommandType.Text, sql))
- {
- DbAccessManager.DBAccess.ExecuteNonQuery(cmd, transaction);
-
- groupIds.ToList().ForEach(gId =>
- {
- cmd.CommandText = $"Insert Into UserGroup (UserID, GroupID) Values ({userId}, {gId})";
- DbAccessManager.DBAccess.ExecuteNonQuery(cmd, transaction);
- });
- transaction.CommitTransaction();
- }
- ret = true;
- }
- catch (Exception ex)
- {
- transaction.RollbackTransaction();
- throw ex;
- }
- }
- return ret;
- }
- ///
- /// 根据角色ID以及选定的部门ID,保到角色部门表
- ///
- ///
- ///
- ///
- public override bool SaveGroupsByRoleId(string roleId, IEnumerable groupIds)
- {
- bool ret = false;
- using (TransactionPackage transaction = DbAccessManager.DBAccess.BeginTransaction())
- {
- try
- {
- //删除角色部门表该角色所有的部门
- string sql = $"delete from RoleGroup where RoleID = {roleId}";
- using (DbCommand cmd = DbAccessManager.DBAccess.CreateCommand(CommandType.Text, sql))
- {
- DbAccessManager.DBAccess.ExecuteNonQuery(cmd, transaction);
- //批插入角色部门表
- groupIds.ToList().ForEach(gId =>
- {
- cmd.CommandText = $"Insert Into RoleGroup (RoleID, GroupID) Values ({roleId}, {gId})";
- DbAccessManager.DBAccess.ExecuteNonQuery(cmd, transaction);
- });
- transaction.CommitTransaction();
- }
- ret = true;
- }
- catch (Exception ex)
- {
- transaction.RollbackTransaction();
- throw ex;
- }
- }
- return ret;
- }
- }
-}
diff --git a/Bootstrap.DataAccess.SQLite/Log.cs b/Bootstrap.DataAccess.SQLite/Log.cs
deleted file mode 100644
index 315d353d..00000000
--- a/Bootstrap.DataAccess.SQLite/Log.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace Bootstrap.DataAccess.SQLite
-{
- ///
- ///
- ///
- public class Log : DataAccess.Log
- {
-
- }
-}
diff --git a/Bootstrap.DataAccess.SQLite/Menu.cs b/Bootstrap.DataAccess.SQLite/Menu.cs
deleted file mode 100644
index abbf093b..00000000
--- a/Bootstrap.DataAccess.SQLite/Menu.cs
+++ /dev/null
@@ -1,53 +0,0 @@
-using Longbow.Data;
-using System;
-using System.Collections.Generic;
-using System.Data;
-using System.Data.Common;
-using System.Linq;
-
-namespace Bootstrap.DataAccess.SQLite
-{
- ///
- ///
- ///
- public class Menu : DataAccess.Menu
- {
- ///
- ///
- /// 通过角色ID保存当前授权菜单
- ///
- ///
- ///
- ///
- public override bool SaveMenusByRoleId(string roleId, IEnumerable menuIds)
- {
- bool ret = false;
- using (TransactionPackage transaction = DbAccessManager.DBAccess.BeginTransaction())
- {
- try
- {
- //删除菜单角色表该角色所有的菜单
- string sql = $"delete from NavigationRole where RoleID = {roleId}";
- using (DbCommand cmd = DbAccessManager.DBAccess.CreateCommand(CommandType.Text, sql))
- {
- DbAccessManager.DBAccess.ExecuteNonQuery(cmd, transaction);
- //批插入菜单角色表
- menuIds.ToList().ForEach(mId =>
- {
- cmd.CommandText = $"Insert Into NavigationRole (NavigationID, RoleID) Values ({mId}, {roleId})";
- DbAccessManager.DBAccess.ExecuteNonQuery(cmd, transaction);
- });
- transaction.CommitTransaction();
- }
- ret = true;
- }
- catch (Exception ex)
- {
- transaction.RollbackTransaction();
- throw ex;
- }
- }
- return ret;
- }
- }
-}
diff --git a/Bootstrap.DataAccess.SQLite/Message.cs b/Bootstrap.DataAccess.SQLite/Message.cs
deleted file mode 100644
index 43bde2fb..00000000
--- a/Bootstrap.DataAccess.SQLite/Message.cs
+++ /dev/null
@@ -1,50 +0,0 @@
-using Longbow;
-using System;
-using System.Collections.Generic;
-using System.Data;
-using System.Data.Common;
-
-namespace Bootstrap.DataAccess.SQLite
-{
- ///
- ///
- ///
- public class Message : DataAccess.Message
- {
- ///
- /// 所有有关userName所有消息列表
- ///
- ///
- ///
- protected override IEnumerable RetrieveMessages(string userName)
- {
- 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 messages = new List();
- 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())
- {
- messages.Add(new DataAccess.Message()
- {
- Id = reader[0].ToString(),
- 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;
- }
- }
-}
diff --git a/Bootstrap.DataAccess.SQLite/Role.cs b/Bootstrap.DataAccess.SQLite/Role.cs
deleted file mode 100644
index 109fb23c..00000000
--- a/Bootstrap.DataAccess.SQLite/Role.cs
+++ /dev/null
@@ -1,130 +0,0 @@
-using Longbow.Data;
-using System;
-using System.Collections.Generic;
-using System.Data;
-using System.Data.Common;
-using System.Linq;
-
-namespace Bootstrap.DataAccess.SQLite
-{
- ///
- ///
- ///
- public class Role : DataAccess.Role
- {
- ///
- ///
- /// 保存用户角色关系
- ///
- ///
- ///
- ///
- public override bool SaveRolesByUserId(string userId, IEnumerable roleIds)
- {
- var ret = false;
- //判断用户是否选定角色
- using (TransactionPackage transaction = DbAccessManager.DBAccess.BeginTransaction())
- {
- try
- {
- // delete user from config table
- string sql = $"delete from UserRole where UserID = {userId}";
- using (DbCommand cmd = DbAccessManager.DBAccess.CreateCommand(CommandType.Text, sql))
- {
- DbAccessManager.DBAccess.ExecuteNonQuery(cmd, transaction);
- roleIds.ToList().ForEach(rId =>
- {
- cmd.CommandText = $"Insert Into UserRole (UserID, RoleID) Values ( {userId}, {rId})";
- DbAccessManager.DBAccess.ExecuteNonQuery(cmd, transaction);
- });
- transaction.CommitTransaction();
- }
- ret = true;
- }
- catch (Exception ex)
- {
- transaction.RollbackTransaction();
- throw ex;
- }
- }
- return ret;
- }
-
- ///
- ///
- ///
- ///
- ///
- ///
- public override bool SavaRolesByMenuId(string menuId, IEnumerable roleIds)
- {
- var ret = false;
- //判断用户是否选定角色
- using (TransactionPackage transaction = DbAccessManager.DBAccess.BeginTransaction())
- {
- try
- {
- // delete role from config table
- string sql = $"delete from NavigationRole where NavigationID = {menuId}";
- using (DbCommand cmd = DbAccessManager.DBAccess.CreateCommand(CommandType.Text, sql))
- {
- DbAccessManager.DBAccess.ExecuteNonQuery(cmd, transaction);
- // insert batch data into config table
- roleIds.ToList().ForEach(rId =>
- {
- cmd.CommandText = $"Insert Into NavigationRole (NavigationID, RoleID) Values ( {menuId}, {rId})";
- DbAccessManager.DBAccess.ExecuteNonQuery(cmd, transaction);
- });
- transaction.CommitTransaction();
- }
- ret = true;
- }
- catch (Exception ex)
- {
- transaction.RollbackTransaction();
- throw ex;
- }
- }
- return ret;
- }
-
- ///
- /// 根据GroupId更新Roles信息,删除旧的Roles信息,插入新的Roles信息
- ///
- ///
- ///
- ///
- public override bool SaveRolesByGroupId(string groupId, IEnumerable roleIds)
- {
- var ret = false;
- //构造表格
- using (TransactionPackage transaction = DbAccessManager.DBAccess.BeginTransaction())
- {
- try
- {
- // delete user from config table
- string sql = $"delete from RoleGroup where GroupID = {groupId}";
- using (DbCommand cmd = DbAccessManager.DBAccess.CreateCommand(CommandType.Text, sql))
- {
- DbAccessManager.DBAccess.ExecuteNonQuery(cmd, transaction);
-
- // insert batch data into config table
- roleIds.ToList().ForEach(rId =>
- {
- cmd.CommandText = $"Insert Into RoleGroup (GroupID, RoleID) Values ( {groupId}, {rId})";
- DbAccessManager.DBAccess.ExecuteNonQuery(cmd, transaction);
- });
- transaction.CommitTransaction();
- }
- ret = true;
- }
- catch (Exception ex)
- {
- transaction.RollbackTransaction();
- throw ex;
- }
- }
- return ret;
- }
- }
-}
\ No newline at end of file
diff --git a/Bootstrap.DataAccess.SQLite/Task.cs b/Bootstrap.DataAccess.SQLite/Task.cs
deleted file mode 100644
index c269ac36..00000000
--- a/Bootstrap.DataAccess.SQLite/Task.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-using Longbow;
-using System;
-using System.Collections.Generic;
-using System.Data;
-using System.Data.Common;
-
-namespace Bootstrap.DataAccess.SQLite
-{
- public class Task : DataAccess.Task
- {
- ///
- /// 查询所有任务
- ///
- ///
- public override IEnumerable RetrieveTasks()
- {
- 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 tasks = new List();
- DbCommand cmd = DbAccessManager.DBAccess.CreateCommand(CommandType.Text, sql);
- using (DbDataReader reader = DbAccessManager.DBAccess.ExecuteReader(cmd))
- {
- while (reader.Read())
- {
- tasks.Add(new DataAccess.Task()
- {
- Id = reader[0].ToString(),
- 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;
- }
- }
-}
diff --git a/Bootstrap.DataAccess.SQLite/User.cs b/Bootstrap.DataAccess.SQLite/User.cs
deleted file mode 100644
index 7f1cee07..00000000
--- a/Bootstrap.DataAccess.SQLite/User.cs
+++ /dev/null
@@ -1,116 +0,0 @@
-using Bootstrap.Security;
-using Longbow.Data;
-using System;
-using System.Collections.Generic;
-using System.Data;
-using System.Data.Common;
-using System.Linq;
-
-namespace Bootstrap.DataAccess.SQLite
-{
- ///
- /// 用户表实体类
- ///
- public class User : DataAccess.User
- {
- ///
- /// 通过角色ID保存当前授权用户(插入)
- ///
- /// 角色ID
- /// 用户ID数组
- ///
- public override bool SaveUsersByRoleId(string roleId, IEnumerable userIds)
- {
- bool ret = false;
- using (TransactionPackage transaction = DbAccessManager.DBAccess.BeginTransaction())
- {
- try
- {
- //删除用户角色表该角色所有的用户
- string sql = $"delete from UserRole where RoleID = {roleId}";
- using (DbCommand cmd = DbAccessManager.DBAccess.CreateCommand(CommandType.Text, sql))
- {
- DbAccessManager.DBAccess.ExecuteNonQuery(cmd, transaction);
- //批插入用户角色表
- userIds.ToList().ForEach(uId =>
- {
- cmd.CommandText = $"Insert Into UserRole (UserID, RoleID) Values ( {uId}, {roleId})";
- DbAccessManager.DBAccess.ExecuteNonQuery(cmd, transaction);
- });
- transaction.CommitTransaction();
- }
- ret = true;
- }
- catch (Exception ex)
- {
- transaction.RollbackTransaction();
- throw ex;
- }
- }
- return ret;
- }
- ///
- /// 通过部门ID保存当前授权用户(插入)
- ///
- /// GroupID
- /// 用户ID数组
- ///
- public override bool SaveUsersByGroupId(string groupId, IEnumerable userIds)
- {
- bool ret = false;
- using (TransactionPackage transaction = DbAccessManager.DBAccess.BeginTransaction())
- {
- try
- {
- //删除用户角色表该角色所有的用户
- string sql = $"delete from UserGroup where GroupID = {groupId}";
- using (DbCommand cmd = DbAccessManager.DBAccess.CreateCommand(CommandType.Text, sql))
- {
- DbAccessManager.DBAccess.ExecuteNonQuery(cmd, transaction);
- //批插入用户角色表
- userIds.ToList().ForEach(uId =>
- {
- cmd.CommandText = $"Insert Into UserGroup (UserID, GroupID) Values ( {uId}, {groupId})";
- DbAccessManager.DBAccess.ExecuteNonQuery(cmd, transaction);
- });
- transaction.CommitTransaction();
- }
- ret = true;
- }
- catch (Exception ex)
- {
- transaction.RollbackTransaction();
- throw ex;
- }
- }
- return ret;
- }
- ///
- ///
- ///
- ///
- ///
- public override BootstrapUser RetrieveUserByUserName(string userName)
- {
- 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())
- {
- user = new BootstrapUser
- {
- UserName = (string)reader[0],
- DisplayName = (string)reader[1],
- Icon = (string)reader[2],
- Css = reader.IsDBNull(3) ? string.Empty : (string)reader[3]
- };
- }
- }
- return user;
- }
- }
-}
diff --git a/Bootstrap.DataAccess/Bootstrap.DataAccess.csproj b/Bootstrap.DataAccess/Bootstrap.DataAccess.csproj
index 7c4c9d7e..cafabf1f 100644
--- a/Bootstrap.DataAccess/Bootstrap.DataAccess.csproj
+++ b/Bootstrap.DataAccess/Bootstrap.DataAccess.csproj
@@ -11,11 +11,13 @@
-
-
-
-
-
+
+
+
+
+
+
+
diff --git a/Bootstrap.DataAccess/DbAccessManager.cs b/Bootstrap.DataAccess/DbAccessManager.cs
deleted file mode 100644
index 61cb11f7..00000000
--- a/Bootstrap.DataAccess/DbAccessManager.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-using Longbow.Data;
-
-namespace Bootstrap.DataAccess
-{
- ///
- ///
- ///
- public static class DbAccessManager
- {
- ///
- ///
- ///
- public static IDbAccess DBAccess
- {
- get { return DbAdapterManager.CreateDB("ba"); }
- }
- }
-}
diff --git a/Bootstrap.DataAccess/DbManager.cs b/Bootstrap.DataAccess/DbManager.cs
new file mode 100644
index 00000000..87a07614
--- /dev/null
+++ b/Bootstrap.DataAccess/DbManager.cs
@@ -0,0 +1,39 @@
+using PetaPoco;
+
+namespace Bootstrap.DataAccess
+{
+ ///
+ ///
+ ///
+ public static class DbManager
+ {
+ ///
+ ///
+ ///
+ public static IDatabase Db { get { return Create(); } }
+
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static IDatabase Create(string connectionName = null, bool keepAlive = false)
+ {
+ var db = Longbow.Data.DbManager.Create(connectionName, keepAlive);
+ return db.AddMaps();
+ }
+
+ private static IDatabase AddMaps(this IDatabase database)
+ {
+ database.AddMap("Dicts");
+ database.AddMap("Users", new string[] { "Checked", "Period", "NewPassword", "UserStatus" });
+ database.AddMap("Exceptions", new string[] { "Period" });
+ database.AddMap("Groups", new string[] { "Checked" });
+ database.AddMap("Logs");
+ database.AddMap