增加功能:增加MongoDB支持
This commit is contained in:
parent
f3a77f2671
commit
55bb4b5f98
|
@ -27,6 +27,7 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\Bootstrap.DataAccess.MongoDB\Bootstrap.DataAccess.MongoDB.csproj" />
|
||||||
<ProjectReference Include="..\Bootstrap.DataAccess.SQLite\Bootstrap.DataAccess.SQLite.csproj" />
|
<ProjectReference Include="..\Bootstrap.DataAccess.SQLite\Bootstrap.DataAccess.SQLite.csproj" />
|
||||||
<ProjectReference Include="..\Bootstrap.DataAccess\Bootstrap.DataAccess.csproj" />
|
<ProjectReference Include="..\Bootstrap.DataAccess\Bootstrap.DataAccess.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
|
@ -39,7 +39,7 @@ namespace Bootstrap.Admin.Controllers.Api
|
||||||
/// <param name="value"></param>
|
/// <param name="value"></param>
|
||||||
[HttpDelete]
|
[HttpDelete]
|
||||||
[Authorize(Roles = "Administrators")]
|
[Authorize(Roles = "Administrators")]
|
||||||
public bool Delete([FromBody]IEnumerable<int> value)
|
public bool Delete([FromBody]IEnumerable<string> value)
|
||||||
{
|
{
|
||||||
return DictHelper.DeleteDict(value);
|
return DictHelper.DeleteDict(value);
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ namespace Bootstrap.Admin.Controllers.Api
|
||||||
/// <param name="value"></param>
|
/// <param name="value"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public QueryData<Exceptions> Get(QueryExceptionOption value)
|
public QueryData<Object> Get(QueryExceptionOption value)
|
||||||
{
|
{
|
||||||
return value.RetrieveData();
|
return value.RetrieveData();
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ namespace Bootstrap.Admin.Controllers.Api
|
||||||
/// <param name="id"></param>
|
/// <param name="id"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpGet("{id}")]
|
[HttpGet("{id}")]
|
||||||
public Group Get(int id)
|
public Group Get(string id)
|
||||||
{
|
{
|
||||||
return GroupHelper.RetrieveGroups().FirstOrDefault(t => t.Id == id);
|
return GroupHelper.RetrieveGroups().FirstOrDefault(t => t.Id == id);
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ namespace Bootstrap.Admin.Controllers.Api
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="value"></param>
|
/// <param name="value"></param>
|
||||||
[HttpDelete]
|
[HttpDelete]
|
||||||
public bool Delete([FromBody]IEnumerable<int> value)
|
public bool Delete([FromBody]IEnumerable<string> value)
|
||||||
{
|
{
|
||||||
return GroupHelper.DeleteGroup(value);
|
return GroupHelper.DeleteGroup(value);
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,7 @@ namespace Bootstrap.Admin.Controllers.Api
|
||||||
/// <param name="type"></param>
|
/// <param name="type"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpPost("{id}")]
|
[HttpPost("{id}")]
|
||||||
public IEnumerable<Group> Post(int id, [FromQuery]string type)
|
public IEnumerable<Group> Post(string id, [FromQuery]string type)
|
||||||
{
|
{
|
||||||
var ret = new List<Group>();
|
var ret = new List<Group>();
|
||||||
switch (type)
|
switch (type)
|
||||||
|
@ -82,7 +82,7 @@ namespace Bootstrap.Admin.Controllers.Api
|
||||||
/// <param name="type"></param>
|
/// <param name="type"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpPut("{id}")]
|
[HttpPut("{id}")]
|
||||||
public bool Put(int id, [FromBody]IEnumerable<int> groupIds, [FromQuery]string type)
|
public bool Put(string id, [FromBody]IEnumerable<string> groupIds, [FromQuery]string type)
|
||||||
{
|
{
|
||||||
var ret = false;
|
var ret = false;
|
||||||
switch (type)
|
switch (type)
|
||||||
|
|
|
@ -28,7 +28,7 @@ namespace Bootstrap.Admin.Controllers.Api
|
||||||
/// <param name="id"></param>
|
/// <param name="id"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpGet("{id}")]
|
[HttpGet("{id}")]
|
||||||
public Log Get(int id)
|
public Log Get(string id)
|
||||||
{
|
{
|
||||||
return LogHelper.RetrieveLogs().FirstOrDefault(t => t.Id == id);
|
return LogHelper.RetrieveLogs().FirstOrDefault(t => t.Id == id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ namespace Bootstrap.Admin.Controllers.Api
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="value"></param>
|
/// <param name="value"></param>
|
||||||
[HttpDelete]
|
[HttpDelete]
|
||||||
public bool Delete([FromBody]IEnumerable<int> value)
|
public bool Delete([FromBody]IEnumerable<string> value)
|
||||||
{
|
{
|
||||||
return MenuHelper.DeleteMenu(value);
|
return MenuHelper.DeleteMenu(value);
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ namespace Bootstrap.Admin.Controllers.Api
|
||||||
/// <param name="type"></param>
|
/// <param name="type"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpPost("{id}")]
|
[HttpPost("{id}")]
|
||||||
public IEnumerable<BootstrapMenu> Post(int id, [FromQuery]string type)
|
public IEnumerable<BootstrapMenu> Post(string id, [FromQuery]string type)
|
||||||
{
|
{
|
||||||
var ret = new List<BootstrapMenu>();
|
var ret = new List<BootstrapMenu>();
|
||||||
switch (type)
|
switch (type)
|
||||||
|
@ -72,7 +72,7 @@ namespace Bootstrap.Admin.Controllers.Api
|
||||||
/// <param name="value">菜单ID集合</param>
|
/// <param name="value">菜单ID集合</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpPut("{id}")]
|
[HttpPut("{id}")]
|
||||||
public bool Put(int id, [FromBody]IEnumerable<int> value)
|
public bool Put(string id, [FromBody]IEnumerable<string> value)
|
||||||
{
|
{
|
||||||
return MenuHelper.SaveMenusByRoleId(id, value);
|
return MenuHelper.SaveMenusByRoleId(id, value);
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ namespace Bootstrap.Admin.Controllers.Api
|
||||||
/// <param name="type">类型</param>
|
/// <param name="type">类型</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpPost("{id}")]
|
[HttpPost("{id}")]
|
||||||
public IEnumerable<Role> Post(int id, [FromQuery]string type)
|
public IEnumerable<Role> Post(string id, [FromQuery]string type)
|
||||||
{
|
{
|
||||||
var ret = new List<Role>();
|
var ret = new List<Role>();
|
||||||
switch (type)
|
switch (type)
|
||||||
|
@ -58,7 +58,7 @@ namespace Bootstrap.Admin.Controllers.Api
|
||||||
/// <param name="type"></param>
|
/// <param name="type"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpPut("{id}")]
|
[HttpPut("{id}")]
|
||||||
public bool Put(int id, [FromBody]IEnumerable<int> roleIds, [FromQuery]string type)
|
public bool Put(string id, [FromBody]IEnumerable<string> roleIds, [FromQuery]string type)
|
||||||
{
|
{
|
||||||
var ret = false;
|
var ret = false;
|
||||||
switch (type)
|
switch (type)
|
||||||
|
@ -91,7 +91,7 @@ namespace Bootstrap.Admin.Controllers.Api
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="value"></param>
|
/// <param name="value"></param>
|
||||||
[HttpDelete]
|
[HttpDelete]
|
||||||
public bool Delete([FromBody]IEnumerable<int> value)
|
public bool Delete([FromBody]IEnumerable<string> value)
|
||||||
{
|
{
|
||||||
return RoleHelper.DeleteRole(value);
|
return RoleHelper.DeleteRole(value);
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,7 @@ namespace Bootstrap.Admin.Controllers.Api
|
||||||
/// <param name="type"></param>
|
/// <param name="type"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpPost("{id}")]
|
[HttpPost("{id}")]
|
||||||
public IEnumerable<User> Post(int id, [FromQuery]string type)
|
public IEnumerable<User> Post(string id, [FromQuery]string type)
|
||||||
{
|
{
|
||||||
var ret = new List<User>();
|
var ret = new List<User>();
|
||||||
switch (type)
|
switch (type)
|
||||||
|
@ -78,7 +78,7 @@ namespace Bootstrap.Admin.Controllers.Api
|
||||||
public bool Post([FromBody]User value)
|
public bool Post([FromBody]User value)
|
||||||
{
|
{
|
||||||
var ret = false;
|
var ret = false;
|
||||||
if (value.Id == 0)
|
if (string.IsNullOrEmpty(value.Id))
|
||||||
{
|
{
|
||||||
value.Description = string.Format("管理员{0}创建用户", User.Identity.Name);
|
value.Description = string.Format("管理员{0}创建用户", User.Identity.Name);
|
||||||
value.ApprovedBy = User.Identity.Name;
|
value.ApprovedBy = User.Identity.Name;
|
||||||
|
@ -98,7 +98,7 @@ namespace Bootstrap.Admin.Controllers.Api
|
||||||
/// <param name="type"></param>
|
/// <param name="type"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpPut("{id}")]
|
[HttpPut("{id}")]
|
||||||
public bool Put(int id, [FromBody]IEnumerable<int> userIds, [FromQuery]string type)
|
public bool Put(string id, [FromBody]IEnumerable<string> userIds, [FromQuery]string type)
|
||||||
{
|
{
|
||||||
var ret = false;
|
var ret = false;
|
||||||
switch (type)
|
switch (type)
|
||||||
|
@ -119,7 +119,7 @@ namespace Bootstrap.Admin.Controllers.Api
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="value"></param>
|
/// <param name="value"></param>
|
||||||
[HttpDelete]
|
[HttpDelete]
|
||||||
public bool Delete([FromBody]IEnumerable<int> value)
|
public bool Delete([FromBody]IEnumerable<string> value)
|
||||||
{
|
{
|
||||||
return UserHelper.DeleteUser(value);
|
return UserHelper.DeleteUser(value);
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ namespace Bootstrap.Admin.Query
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public QueryData<Exceptions> RetrieveData()
|
public QueryData<object> RetrieveData()
|
||||||
{
|
{
|
||||||
var data = ExceptionsHelper.RetrieveExceptions();
|
var data = ExceptionsHelper.RetrieveExceptions();
|
||||||
if (StartTime > DateTime.MinValue)
|
if (StartTime > DateTime.MinValue)
|
||||||
|
@ -33,7 +33,7 @@ namespace Bootstrap.Admin.Query
|
||||||
{
|
{
|
||||||
data = data.Where(t => t.LogTime < EndTime.AddDays(1));
|
data = data.Where(t => t.LogTime < EndTime.AddDays(1));
|
||||||
}
|
}
|
||||||
var ret = new QueryData<Exceptions>();
|
var ret = new QueryData<object>();
|
||||||
ret.total = data.Count();
|
ret.total = data.Count();
|
||||||
switch (Sort)
|
switch (Sort)
|
||||||
{
|
{
|
||||||
|
@ -52,7 +52,7 @@ namespace Bootstrap.Admin.Query
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ret.rows = data.Skip(Offset).Take(Limit);
|
ret.rows = data.Skip(Offset).Take(Limit).Select(ex => new { ex.UserId, ex.UserIp, ex.LogTime, ex.Message, ex.ErrorPage, ex.ExceptionType });
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,12 +21,19 @@
|
||||||
"Widget": "Bootstrap.DataAccess"
|
"Widget": "Bootstrap.DataAccess"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Enabled": true,
|
"Enabled": false,
|
||||||
"Widget": "Bootstrap.DataAccess.SQLite",
|
"Widget": "Bootstrap.DataAccess.SQLite",
|
||||||
"DBProviderFactory": "Microsoft.Data.Sqlite.SqliteFactory, Microsoft.Data.Sqlite",
|
"DBProviderFactory": "Microsoft.Data.Sqlite.SqliteFactory, Microsoft.Data.Sqlite",
|
||||||
"ConnectionStrings": {
|
"ConnectionStrings": {
|
||||||
"ba": "Data Source=BootstrapAdmin.db;"
|
"ba": "Data Source=BootstrapAdmin.db;"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Enabled": true,
|
||||||
|
"Widget": "Bootstrap.DataAccess.MongoDB",
|
||||||
|
"ConnectionStrings": {
|
||||||
|
"ba": "mongodb://10.211.55.2:27017;Data Source=BootstrapAdmin"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"SwaggerPathBase": "/BA",
|
"SwaggerPathBase": "/BA",
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
var $errorDetail = $('#errorDetail');
|
var $errorDetail = $('#errorDetail');
|
||||||
var $errorDetailTitle = $('#myDetailModalLabel');
|
var $errorDetailTitle = $('#myDetailModalLabel');
|
||||||
|
|
||||||
$('table').smartTable({
|
$('.card-body table').smartTable({
|
||||||
url: Exceptions.url,
|
url: Exceptions.url,
|
||||||
sortName: 'LogTime',
|
sortName: 'LogTime',
|
||||||
sortOrder: 'desc',
|
sortOrder: 'desc',
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
$(function () {
|
$(function () {
|
||||||
var url = 'api/Logs/';
|
var url = 'api/Logs/';
|
||||||
|
|
||||||
$('table').smartTable({
|
$('.card-body table').smartTable({
|
||||||
url: url,
|
url: url,
|
||||||
sortName: 'LogTime',
|
sortName: 'LogTime',
|
||||||
sortOrder: 'desc',
|
sortOrder: 'desc',
|
||||||
|
|
|
@ -26,7 +26,7 @@ namespace Bootstrap.Client.DataAccess
|
||||||
{
|
{
|
||||||
var menus = RetrieveAllMenus(userName).Where(m => m.Category == "1" && m.IsResource == 0 && m.ApplicationCode == ConfigurationManager.AppSettings["AppId"]);
|
var menus = RetrieveAllMenus(userName).Where(m => m.Category == "1" && m.IsResource == 0 && m.ApplicationCode == ConfigurationManager.AppSettings["AppId"]);
|
||||||
DbHelper.ActiveMenu(null, menus, activeUrl);
|
DbHelper.ActiveMenu(null, menus, activeUrl);
|
||||||
var root = menus.Where(m => m.ParentId == 0).OrderBy(m => m.ApplicationCode).ThenBy(m => m.Order);
|
var root = menus.Where(m => m.ParentId == "0").OrderBy(m => m.ApplicationCode).ThenBy(m => m.Order);
|
||||||
DbHelper.CascadeMenus(menus, root);
|
DbHelper.CascadeMenus(menus, root);
|
||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>netcoreapp2.1</TargetFramework>
|
||||||
|
<SignAssembly>true</SignAssembly>
|
||||||
|
<AssemblyOriginatorKeyFile>..\Keys\Longbow.Utility.snk</AssemblyOriginatorKeyFile>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="..\Keys\Longbow.Utility.snk" Link="Longbow.Utility.snk" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="MongoDB.Driver" Version="2.7.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\Bootstrap.DataAccess\Bootstrap.DataAccess.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
|
@ -0,0 +1,23 @@
|
||||||
|
using Bootstrap.Security;
|
||||||
|
using MongoDB.Driver;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace Bootstrap.DataAccess.MongoDB
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public class Dict : DataAccess.Dict
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public override IEnumerable<BootstrapDict> RetrieveDicts()
|
||||||
|
{
|
||||||
|
var dicts = MongoDbAccessManager.DBAccess.GetCollection<Dict>("Dicts");
|
||||||
|
return dicts.Find(FilterDefinition<Dict>.Empty).ToList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
using MongoDB.Driver;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace Bootstrap.DataAccess.MongoDB
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public class Exceptions : DataAccess.Exceptions
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public override IEnumerable<DataAccess.Exceptions> RetrieveExceptions()
|
||||||
|
{
|
||||||
|
var msg = MongoDbAccessManager.DBAccess.GetCollection<DataAccess.Exceptions>("Exceptions");
|
||||||
|
return msg.Find(ex => ex.LogTime >= DateTime.Now.AddDays(-7)).ToList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
using MongoDB.Driver;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace Bootstrap.DataAccess.MongoDB
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public class Group : DataAccess.Group
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public override IEnumerable<DataAccess.Group> RetrieveGroups()
|
||||||
|
{
|
||||||
|
var groups = MongoDbAccessManager.DBAccess.GetCollection<DataAccess.Group>("Groups");
|
||||||
|
return groups.Find(FilterDefinition<DataAccess.Group>.Empty).ToList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
using MongoDB.Driver;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace Bootstrap.DataAccess.MongoDB
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public class Log : DataAccess.Log
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public override IEnumerable<DataAccess.Log> RetrieveLogs()
|
||||||
|
{
|
||||||
|
var log = MongoDbAccessManager.DBAccess.GetCollection<DataAccess.Log>("Logs");
|
||||||
|
return log.Find(l => l.LogTime >= DateTime.Now.AddDays(-7)).ToList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
using Bootstrap.Security;
|
||||||
|
using MongoDB.Driver;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace Bootstrap.DataAccess.MongoDB
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public class Menu : DataAccess.Menu
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="userName"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public override IEnumerable<BootstrapMenu> RetrieveAllMenus(string userName)
|
||||||
|
{
|
||||||
|
var menus = MongoDbAccessManager.DBAccess.GetCollection<BootstrapMenu>("Navigations");
|
||||||
|
return menus.Find(FilterDefinition<BootstrapMenu>.Empty).ToList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
using MongoDB.Driver;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace Bootstrap.DataAccess.MongoDB
|
||||||
|
{
|
||||||
|
public class Message : DataAccess.Message
|
||||||
|
{
|
||||||
|
protected override IEnumerable<DataAccess.Message> RetrieveMessages(string userName)
|
||||||
|
{
|
||||||
|
//TODO: 完善其他字段信息
|
||||||
|
var msg = MongoDbAccessManager.DBAccess.GetCollection<DataAccess.Message>("Messages");
|
||||||
|
return msg.Find(message => message.To == userName || message.From == userName).ToList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,143 @@
|
||||||
|
using Bootstrap.Security;
|
||||||
|
using Longbow.Data;
|
||||||
|
using MongoDB.Bson;
|
||||||
|
using MongoDB.Bson.Serialization;
|
||||||
|
using MongoDB.Bson.Serialization.Serializers;
|
||||||
|
using MongoDB.Driver;
|
||||||
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace Bootstrap.DataAccess.MongoDB
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public static class MongoDbAccessManager
|
||||||
|
{
|
||||||
|
private static IMongoDatabase _db = null;
|
||||||
|
private static bool _register = false;
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public static IMongoDatabase DBAccess
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_db == null)
|
||||||
|
{
|
||||||
|
if (!_register)
|
||||||
|
{
|
||||||
|
_register = true;
|
||||||
|
DbAdapterManager.RegisterConfigChangeCallback(InitDb);
|
||||||
|
}
|
||||||
|
InitDb();
|
||||||
|
}
|
||||||
|
return _db;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void InitDb()
|
||||||
|
{
|
||||||
|
var connectString = DbAdapterManager.GetConnectionString("ba");
|
||||||
|
if (string.IsNullOrEmpty(connectString)) throw new InvalidOperationException("Please set the BA default value in configuration file.");
|
||||||
|
|
||||||
|
var seq = connectString.Split(";", StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
if (seq.Length != 2) throw new InvalidOperationException("");
|
||||||
|
var client = new MongoClient(seq[0]);
|
||||||
|
_db = client.GetDatabase(seq[1].Split("=", StringSplitOptions.RemoveEmptyEntries).LastOrDefault());
|
||||||
|
|
||||||
|
BsonSerializer.RegisterSerializer(new DateTimeSerializer(DateTimeKind.Local));
|
||||||
|
if (!BsonClassMap.IsClassMapRegistered(typeof(BootstrapDict)))
|
||||||
|
{
|
||||||
|
BsonClassMap.RegisterClassMap<BootstrapDict>(md =>
|
||||||
|
{
|
||||||
|
md.AutoMap();
|
||||||
|
md.IdMemberMap.SetSerializer(new StringSerializer(BsonType.ObjectId));
|
||||||
|
md.IdMemberMap.SetIgnoreIfDefault(true);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (!BsonClassMap.IsClassMapRegistered(typeof(BootstrapUser)))
|
||||||
|
{
|
||||||
|
BsonClassMap.RegisterClassMap<BootstrapUser>(md =>
|
||||||
|
{
|
||||||
|
md.AutoMap();
|
||||||
|
md.SetIgnoreExtraElements(true);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (!BsonClassMap.IsClassMapRegistered(typeof(DataAccess.User)))
|
||||||
|
{
|
||||||
|
BsonClassMap.RegisterClassMap<DataAccess.User>(md =>
|
||||||
|
{
|
||||||
|
md.AutoMap();
|
||||||
|
md.IdMemberMap.SetSerializer(new StringSerializer(BsonType.ObjectId));
|
||||||
|
md.IdMemberMap.SetIgnoreIfDefault(true);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (!BsonClassMap.IsClassMapRegistered(typeof(BootstrapMenu)))
|
||||||
|
{
|
||||||
|
BsonClassMap.RegisterClassMap<BootstrapMenu>(md =>
|
||||||
|
{
|
||||||
|
md.AutoMap();
|
||||||
|
md.IdMemberMap.SetSerializer(new StringSerializer(BsonType.ObjectId));
|
||||||
|
md.IdMemberMap.SetIgnoreIfDefault(true);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (!BsonClassMap.IsClassMapRegistered(typeof(DataAccess.Group)))
|
||||||
|
{
|
||||||
|
BsonClassMap.RegisterClassMap<DataAccess.Group>(md =>
|
||||||
|
{
|
||||||
|
md.AutoMap();
|
||||||
|
md.IdMemberMap.SetSerializer(new StringSerializer(BsonType.ObjectId));
|
||||||
|
md.IdMemberMap.SetIgnoreIfDefault(true);
|
||||||
|
md.UnmapMember(group => group.Checked);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (!BsonClassMap.IsClassMapRegistered(typeof(DataAccess.Role)))
|
||||||
|
{
|
||||||
|
BsonClassMap.RegisterClassMap<DataAccess.Role>(md =>
|
||||||
|
{
|
||||||
|
md.AutoMap();
|
||||||
|
md.IdMemberMap.SetSerializer(new StringSerializer(BsonType.ObjectId));
|
||||||
|
md.IdMemberMap.SetIgnoreIfDefault(true);
|
||||||
|
md.UnmapMember(role => role.Checked);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (!BsonClassMap.IsClassMapRegistered(typeof(DataAccess.Task)))
|
||||||
|
{
|
||||||
|
BsonClassMap.RegisterClassMap<DataAccess.Task>(md =>
|
||||||
|
{
|
||||||
|
md.AutoMap();
|
||||||
|
md.IdMemberMap.SetSerializer(new StringSerializer(BsonType.ObjectId));
|
||||||
|
md.IdMemberMap.SetIgnoreIfDefault(true);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (!BsonClassMap.IsClassMapRegistered(typeof(DataAccess.Message)))
|
||||||
|
{
|
||||||
|
BsonClassMap.RegisterClassMap<DataAccess.Message>(md =>
|
||||||
|
{
|
||||||
|
md.AutoMap();
|
||||||
|
md.IdMemberMap.SetSerializer(new StringSerializer(BsonType.ObjectId));
|
||||||
|
md.IdMemberMap.SetIgnoreIfDefault(true);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (!BsonClassMap.IsClassMapRegistered(typeof(DataAccess.Exceptions)))
|
||||||
|
{
|
||||||
|
BsonClassMap.RegisterClassMap<DataAccess.Exceptions>(md =>
|
||||||
|
{
|
||||||
|
md.AutoMap();
|
||||||
|
md.IdMemberMap.SetSerializer(new StringSerializer(BsonType.ObjectId));
|
||||||
|
md.IdMemberMap.SetIgnoreIfDefault(true);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (!BsonClassMap.IsClassMapRegistered(typeof(DataAccess.Log)))
|
||||||
|
{
|
||||||
|
BsonClassMap.RegisterClassMap<DataAccess.Log>(md =>
|
||||||
|
{
|
||||||
|
md.AutoMap();
|
||||||
|
md.IdMemberMap.SetSerializer(new StringSerializer(BsonType.ObjectId));
|
||||||
|
md.IdMemberMap.SetIgnoreIfDefault(true);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
using MongoDB.Driver;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace Bootstrap.DataAccess.MongoDB
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public class Role : DataAccess.Role
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="userName"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public override IEnumerable<string> RetrieveRolesByUserName(string userName)
|
||||||
|
{
|
||||||
|
return new List<string>() { "Administrators" };
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="url"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public override IEnumerable<string> RetrieveRolesByUrl(string url) => new List<string>() { "Administrators" };
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public override IEnumerable<DataAccess.Role> RetrieveRoles()
|
||||||
|
{
|
||||||
|
var roles = MongoDbAccessManager.DBAccess.GetCollection<DataAccess.Role>("Roles");
|
||||||
|
return roles.Find(FilterDefinition<DataAccess.Role>.Empty).ToList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
using MongoDB.Driver;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace Bootstrap.DataAccess.MongoDB
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public class Task : DataAccess.Task
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public override IEnumerable<DataAccess.Task> RetrieveTasks()
|
||||||
|
{
|
||||||
|
var users = MongoDbAccessManager.DBAccess.GetCollection<DataAccess.Task>("Tasks");
|
||||||
|
return users.Find(FilterDefinition<DataAccess.Task>.Empty).SortByDescending(task => task.AssignTime).ToList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,48 @@
|
||||||
|
using Bootstrap.Security;
|
||||||
|
using Longbow.Security.Cryptography;
|
||||||
|
using MongoDB.Driver;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace Bootstrap.DataAccess.MongoDB
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public class User : DataAccess.User
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="userName"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public override BootstrapUser RetrieveUserByUserName(string userName)
|
||||||
|
{
|
||||||
|
var users = MongoDbAccessManager.DBAccess.GetCollection<BootstrapUser>("Users");
|
||||||
|
return users.Find(user => user.UserName == userName).FirstOrDefault();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="userName"></param>
|
||||||
|
/// <param name="password"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public override bool Authenticate(string userName, string password)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(userName) && string.IsNullOrEmpty(password)) return false;
|
||||||
|
|
||||||
|
var users = MongoDbAccessManager.DBAccess.GetCollection<DataAccess.User>("Users");
|
||||||
|
var u = users.Find(user => user.UserName == userName).FirstOrDefault();
|
||||||
|
return !string.IsNullOrEmpty(u.PassSalt) && u.Password == LgbCryptography.ComputeHash(password, u.PassSalt);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public override IEnumerable<DataAccess.User> RetrieveNewUsers()
|
||||||
|
{
|
||||||
|
var users = MongoDbAccessManager.DBAccess.GetCollection<DataAccess.User>("Users");
|
||||||
|
return users.Find(user => user.ApprovedTime == DateTime.MinValue).SortByDescending(user => user.RegisterTime).ToList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -75,7 +75,7 @@ namespace Bootstrap.DataAccess.SQLite
|
||||||
{
|
{
|
||||||
exceptions.Add(new DataAccess.Exceptions()
|
exceptions.Add(new DataAccess.Exceptions()
|
||||||
{
|
{
|
||||||
Id = LgbConvert.ReadValue(reader[0], 0),
|
Id = reader[0].ToString(),
|
||||||
AppDomainName = (string)reader[1],
|
AppDomainName = (string)reader[1],
|
||||||
ErrorPage = reader.IsDBNull(2) ? string.Empty : (string)reader[2],
|
ErrorPage = reader.IsDBNull(2) ? string.Empty : (string)reader[2],
|
||||||
UserId = reader.IsDBNull(3) ? string.Empty : (string)reader[3],
|
UserId = reader.IsDBNull(3) ? string.Empty : (string)reader[3],
|
||||||
|
|
|
@ -17,7 +17,7 @@ namespace Bootstrap.DataAccess.SQLite
|
||||||
/// 删除群组信息
|
/// 删除群组信息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="ids"></param>
|
/// <param name="ids"></param>
|
||||||
public override bool DeleteGroup(IEnumerable<int> value)
|
public override bool DeleteGroup(IEnumerable<string> value)
|
||||||
{
|
{
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
var ids = string.Join(",", value);
|
var ids = string.Join(",", value);
|
||||||
|
@ -54,7 +54,7 @@ namespace Bootstrap.DataAccess.SQLite
|
||||||
/// <param name="userId"></param>
|
/// <param name="userId"></param>
|
||||||
/// <param name="groupIds"></param>
|
/// <param name="groupIds"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public override bool SaveGroupsByUserId(int userId, IEnumerable<int> groupIds)
|
public override bool SaveGroupsByUserId(string userId, IEnumerable<string> groupIds)
|
||||||
{
|
{
|
||||||
var ret = false;
|
var ret = false;
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ namespace Bootstrap.DataAccess.SQLite
|
||||||
});
|
});
|
||||||
transaction.CommitTransaction();
|
transaction.CommitTransaction();
|
||||||
}
|
}
|
||||||
CacheCleanUtility.ClearCache(groupIds: groupIds, userIds: new List<int>() { userId });
|
CacheCleanUtility.ClearCache(groupIds: groupIds, userIds: new List<string>() { userId });
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
@ -93,7 +93,7 @@ namespace Bootstrap.DataAccess.SQLite
|
||||||
/// <param name="roleId"></param>
|
/// <param name="roleId"></param>
|
||||||
/// <param name="groupIds"></param>
|
/// <param name="groupIds"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public override bool SaveGroupsByRoleId(int roleId, IEnumerable<int> groupIds)
|
public override bool SaveGroupsByRoleId(string roleId, IEnumerable<string> groupIds)
|
||||||
{
|
{
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
using (TransactionPackage transaction = DbAccessManager.DBAccess.BeginTransaction())
|
using (TransactionPackage transaction = DbAccessManager.DBAccess.BeginTransaction())
|
||||||
|
@ -113,7 +113,7 @@ namespace Bootstrap.DataAccess.SQLite
|
||||||
});
|
});
|
||||||
transaction.CommitTransaction();
|
transaction.CommitTransaction();
|
||||||
}
|
}
|
||||||
CacheCleanUtility.ClearCache(groupIds: groupIds, roleIds: new List<int>() { roleId });
|
CacheCleanUtility.ClearCache(groupIds: groupIds, roleIds: new List<string>() { roleId });
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|
|
@ -18,7 +18,7 @@ namespace Bootstrap.DataAccess.SQLite
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="tId"></param>
|
/// <param name="tId"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public override IEnumerable<DataAccess.Log> RetrieveLogs(string tId = null)
|
public override IEnumerable<DataAccess.Log> RetrieveLogs()
|
||||||
{
|
{
|
||||||
string sql = "select * from Logs where LogTime > datetime('now', 'localtime', '-7 day')";
|
string sql = "select * from Logs where LogTime > datetime('now', 'localtime', '-7 day')";
|
||||||
List<DataAccess.Log> logs = new List<DataAccess.Log>();
|
List<DataAccess.Log> logs = new List<DataAccess.Log>();
|
||||||
|
@ -29,7 +29,7 @@ namespace Bootstrap.DataAccess.SQLite
|
||||||
{
|
{
|
||||||
logs.Add(new DataAccess.Log()
|
logs.Add(new DataAccess.Log()
|
||||||
{
|
{
|
||||||
Id = LgbConvert.ReadValue(reader[0], 0),
|
Id = reader[0].ToString(),
|
||||||
CRUD = (string)reader[1],
|
CRUD = (string)reader[1],
|
||||||
UserName = (string)reader[2],
|
UserName = (string)reader[2],
|
||||||
LogTime = LgbConvert.ReadValue(reader[3], DateTime.MinValue),
|
LogTime = LgbConvert.ReadValue(reader[3], DateTime.MinValue),
|
||||||
|
|
|
@ -16,7 +16,7 @@ namespace Bootstrap.DataAccess.SQLite
|
||||||
/// 删除菜单信息
|
/// 删除菜单信息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="value"></param>
|
/// <param name="value"></param>
|
||||||
public override bool DeleteMenu(IEnumerable<int> value)
|
public override bool DeleteMenu(IEnumerable<string> value)
|
||||||
{
|
{
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
var ids = string.Join(",", value);
|
var ids = string.Join(",", value);
|
||||||
|
@ -51,7 +51,7 @@ namespace Bootstrap.DataAccess.SQLite
|
||||||
/// <param name="roleId"></param>
|
/// <param name="roleId"></param>
|
||||||
/// <param name="menuIds"></param>
|
/// <param name="menuIds"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public override bool SaveMenusByRoleId(int roleId, IEnumerable<int> menuIds)
|
public override bool SaveMenusByRoleId(string roleId, IEnumerable<string> menuIds)
|
||||||
{
|
{
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
using (TransactionPackage transaction = DbAccessManager.DBAccess.BeginTransaction())
|
using (TransactionPackage transaction = DbAccessManager.DBAccess.BeginTransaction())
|
||||||
|
@ -71,7 +71,7 @@ namespace Bootstrap.DataAccess.SQLite
|
||||||
});
|
});
|
||||||
transaction.CommitTransaction();
|
transaction.CommitTransaction();
|
||||||
}
|
}
|
||||||
CacheCleanUtility.ClearCache(menuIds: menuIds, roleIds: new List<int>() { roleId });
|
CacheCleanUtility.ClearCache(menuIds: menuIds, roleIds: new List<string>() { roleId });
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|
|
@ -28,7 +28,7 @@ namespace Bootstrap.DataAccess.SQLite
|
||||||
{
|
{
|
||||||
messages.Add(new DataAccess.Message()
|
messages.Add(new DataAccess.Message()
|
||||||
{
|
{
|
||||||
Id = LgbConvert.ReadValue(reader[0], 0),
|
Id = reader[0].ToString(),
|
||||||
Title = (string)reader[1],
|
Title = (string)reader[1],
|
||||||
Content = (string)reader[2],
|
Content = (string)reader[2],
|
||||||
From = (string)reader[3],
|
From = (string)reader[3],
|
||||||
|
|
|
@ -19,7 +19,7 @@ namespace Bootstrap.DataAccess.SQLite
|
||||||
/// <param name="userId"></param>
|
/// <param name="userId"></param>
|
||||||
/// <param name="roleIds"></param>
|
/// <param name="roleIds"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public override bool SaveRolesByUserId(int userId, IEnumerable<int> roleIds)
|
public override bool SaveRolesByUserId(string userId, IEnumerable<string> roleIds)
|
||||||
{
|
{
|
||||||
var ret = false;
|
var ret = false;
|
||||||
//判断用户是否选定角色
|
//判断用户是否选定角色
|
||||||
|
@ -39,7 +39,7 @@ namespace Bootstrap.DataAccess.SQLite
|
||||||
});
|
});
|
||||||
transaction.CommitTransaction();
|
transaction.CommitTransaction();
|
||||||
}
|
}
|
||||||
CacheCleanUtility.ClearCache(userIds: new List<int>() { userId }, roleIds: roleIds);
|
CacheCleanUtility.ClearCache(userIds: new List<string>() { userId }, roleIds: roleIds);
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
@ -54,7 +54,7 @@ namespace Bootstrap.DataAccess.SQLite
|
||||||
/// 删除角色表
|
/// 删除角色表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="value"></param>
|
/// <param name="value"></param>
|
||||||
public override bool DeleteRole(IEnumerable<int> value)
|
public override bool DeleteRole(IEnumerable<string> value)
|
||||||
{
|
{
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
var ids = string.Join(",", value);
|
var ids = string.Join(",", value);
|
||||||
|
@ -94,7 +94,7 @@ namespace Bootstrap.DataAccess.SQLite
|
||||||
/// <param name="menuId"></param>
|
/// <param name="menuId"></param>
|
||||||
/// <param name="roleIds"></param>
|
/// <param name="roleIds"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public override bool SavaRolesByMenuId(int menuId, IEnumerable<int> roleIds)
|
public override bool SavaRolesByMenuId(string menuId, IEnumerable<string> roleIds)
|
||||||
{
|
{
|
||||||
var ret = false;
|
var ret = false;
|
||||||
//判断用户是否选定角色
|
//判断用户是否选定角色
|
||||||
|
@ -115,7 +115,7 @@ namespace Bootstrap.DataAccess.SQLite
|
||||||
});
|
});
|
||||||
transaction.CommitTransaction();
|
transaction.CommitTransaction();
|
||||||
}
|
}
|
||||||
CacheCleanUtility.ClearCache(roleIds: roleIds, menuIds: new List<int>() { menuId });
|
CacheCleanUtility.ClearCache(roleIds: roleIds, menuIds: new List<string>() { menuId });
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
@ -132,7 +132,7 @@ namespace Bootstrap.DataAccess.SQLite
|
||||||
/// <param name="groupId"></param>
|
/// <param name="groupId"></param>
|
||||||
/// <param name="roleIds"></param>
|
/// <param name="roleIds"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public override bool SaveRolesByGroupId(int groupId, IEnumerable<int> roleIds)
|
public override bool SaveRolesByGroupId(string groupId, IEnumerable<string> roleIds)
|
||||||
{
|
{
|
||||||
var ret = false;
|
var ret = false;
|
||||||
//构造表格
|
//构造表格
|
||||||
|
@ -154,7 +154,7 @@ namespace Bootstrap.DataAccess.SQLite
|
||||||
});
|
});
|
||||||
transaction.CommitTransaction();
|
transaction.CommitTransaction();
|
||||||
}
|
}
|
||||||
CacheCleanUtility.ClearCache(roleIds: roleIds, groupIds: new List<int>() { groupId });
|
CacheCleanUtility.ClearCache(roleIds: roleIds, groupIds: new List<string>() { groupId });
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|
|
@ -23,7 +23,7 @@ namespace Bootstrap.DataAccess.SQLite
|
||||||
{
|
{
|
||||||
tasks.Add(new DataAccess.Task()
|
tasks.Add(new DataAccess.Task()
|
||||||
{
|
{
|
||||||
Id = LgbConvert.ReadValue(reader[0], 0),
|
Id = reader[0].ToString(),
|
||||||
TaskName = (string)reader[1],
|
TaskName = (string)reader[1],
|
||||||
AssignName = (string)reader[2],
|
AssignName = (string)reader[2],
|
||||||
UserName = (string)reader[3],
|
UserName = (string)reader[3],
|
||||||
|
|
|
@ -19,7 +19,7 @@ namespace Bootstrap.DataAccess.SQLite
|
||||||
/// 删除用户
|
/// 删除用户
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="value"></param>
|
/// <param name="value"></param>
|
||||||
public override bool DeleteUser(IEnumerable<int> value)
|
public override bool DeleteUser(IEnumerable<string> value)
|
||||||
{
|
{
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
var ids = string.Join(",", value);
|
var ids = string.Join(",", value);
|
||||||
|
@ -58,7 +58,7 @@ namespace Bootstrap.DataAccess.SQLite
|
||||||
public override bool SaveUser(DataAccess.User p)
|
public override bool SaveUser(DataAccess.User p)
|
||||||
{
|
{
|
||||||
var ret = false;
|
var ret = false;
|
||||||
if (p.Id == 0 && p.Description.Length > 500) p.Description = p.Description.Substring(0, 500);
|
if (string.IsNullOrEmpty(p.Id) && p.Description.Length > 500) p.Description = p.Description.Substring(0, 500);
|
||||||
if (p.UserName.Length > 50) p.UserName = p.UserName.Substring(0, 50);
|
if (p.UserName.Length > 50) p.UserName = p.UserName.Substring(0, 50);
|
||||||
p.PassSalt = LgbCryptography.GenerateSalt();
|
p.PassSalt = LgbCryptography.GenerateSalt();
|
||||||
p.Password = LgbCryptography.ComputeHash(p.Password, p.PassSalt);
|
p.Password = LgbCryptography.ComputeHash(p.Password, p.PassSalt);
|
||||||
|
@ -86,7 +86,7 @@ namespace Bootstrap.DataAccess.SQLite
|
||||||
DbAccessManager.DBAccess.ExecuteNonQuery(cmd, transaction);
|
DbAccessManager.DBAccess.ExecuteNonQuery(cmd, transaction);
|
||||||
|
|
||||||
transaction.CommitTransaction();
|
transaction.CommitTransaction();
|
||||||
CacheCleanUtility.ClearCache(userIds: p.Id == 0 ? new List<int>() : new List<int>() { p.Id });
|
CacheCleanUtility.ClearCache(userIds: string.IsNullOrEmpty(p.Id) ? new List<string>() : new List<string>() { p.Id });
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -105,7 +105,7 @@ namespace Bootstrap.DataAccess.SQLite
|
||||||
/// <param name="id"></param>
|
/// <param name="id"></param>
|
||||||
/// <param name="approvedBy"></param>
|
/// <param name="approvedBy"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public override bool ApproveUser(int id, string approvedBy)
|
public override bool ApproveUser(string id, string approvedBy)
|
||||||
{
|
{
|
||||||
var ret = false;
|
var ret = false;
|
||||||
var sql = "update Users set ApprovedTime = datetime('now', 'localtime'), ApprovedBy = @approvedBy where ID = @id";
|
var sql = "update Users set ApprovedTime = datetime('now', 'localtime'), ApprovedBy = @approvedBy where ID = @id";
|
||||||
|
@ -114,7 +114,7 @@ namespace Bootstrap.DataAccess.SQLite
|
||||||
cmd.Parameters.Add(DbAccessManager.DBAccess.CreateParameter("@id", id));
|
cmd.Parameters.Add(DbAccessManager.DBAccess.CreateParameter("@id", id));
|
||||||
cmd.Parameters.Add(DbAccessManager.DBAccess.CreateParameter("@approvedBy", approvedBy));
|
cmd.Parameters.Add(DbAccessManager.DBAccess.CreateParameter("@approvedBy", approvedBy));
|
||||||
ret = DbAccessManager.DBAccess.ExecuteNonQuery(cmd) == 1;
|
ret = DbAccessManager.DBAccess.ExecuteNonQuery(cmd) == 1;
|
||||||
if (ret) CacheCleanUtility.ClearCache(userIds: new List<int>() { id });
|
if (ret) CacheCleanUtility.ClearCache(userIds: new List<string>() { id });
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -125,7 +125,7 @@ namespace Bootstrap.DataAccess.SQLite
|
||||||
/// <param name="rejectBy"></param>
|
/// <param name="rejectBy"></param>
|
||||||
/// <param name="reason"></param>
|
/// <param name="reason"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public override bool RejectUser(int id, string rejectBy)
|
public override bool RejectUser(string id, string rejectBy)
|
||||||
{
|
{
|
||||||
var ret = false;
|
var ret = false;
|
||||||
using (TransactionPackage transaction = DbAccessManager.DBAccess.BeginTransaction())
|
using (TransactionPackage transaction = DbAccessManager.DBAccess.BeginTransaction())
|
||||||
|
@ -146,7 +146,7 @@ namespace Bootstrap.DataAccess.SQLite
|
||||||
DbAccessManager.DBAccess.ExecuteNonQuery(cmd, transaction);
|
DbAccessManager.DBAccess.ExecuteNonQuery(cmd, transaction);
|
||||||
|
|
||||||
transaction.CommitTransaction();
|
transaction.CommitTransaction();
|
||||||
CacheCleanUtility.ClearCache(userIds: new List<int>() { id });
|
CacheCleanUtility.ClearCache(userIds: new List<string>() { id });
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -164,7 +164,7 @@ namespace Bootstrap.DataAccess.SQLite
|
||||||
/// <param name="roleId">角色ID</param>
|
/// <param name="roleId">角色ID</param>
|
||||||
/// <param name="userIds">用户ID数组</param>
|
/// <param name="userIds">用户ID数组</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public override bool SaveUsersByRoleId(int roleId, IEnumerable<int> userIds)
|
public override bool SaveUsersByRoleId(string roleId, IEnumerable<string> userIds)
|
||||||
{
|
{
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
DataTable dt = new DataTable();
|
DataTable dt = new DataTable();
|
||||||
|
@ -188,7 +188,7 @@ namespace Bootstrap.DataAccess.SQLite
|
||||||
});
|
});
|
||||||
transaction.CommitTransaction();
|
transaction.CommitTransaction();
|
||||||
}
|
}
|
||||||
CacheCleanUtility.ClearCache(userIds: userIds, roleIds: new List<int>() { roleId });
|
CacheCleanUtility.ClearCache(userIds: userIds, roleIds: new List<string>() { roleId });
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
@ -205,7 +205,7 @@ namespace Bootstrap.DataAccess.SQLite
|
||||||
/// <param name="groupId">GroupID</param>
|
/// <param name="groupId">GroupID</param>
|
||||||
/// <param name="userIds">用户ID数组</param>
|
/// <param name="userIds">用户ID数组</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public override bool SaveUsersByGroupId(int groupId, IEnumerable<int> userIds)
|
public override bool SaveUsersByGroupId(string groupId, IEnumerable<string> userIds)
|
||||||
{
|
{
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
using (TransactionPackage transaction = DbAccessManager.DBAccess.BeginTransaction())
|
using (TransactionPackage transaction = DbAccessManager.DBAccess.BeginTransaction())
|
||||||
|
@ -225,7 +225,7 @@ namespace Bootstrap.DataAccess.SQLite
|
||||||
});
|
});
|
||||||
transaction.CommitTransaction();
|
transaction.CommitTransaction();
|
||||||
}
|
}
|
||||||
CacheCleanUtility.ClearCache(userIds: userIds, groupIds: new List<int>() { groupId });
|
CacheCleanUtility.ClearCache(userIds: userIds, groupIds: new List<string>() { groupId });
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|
|
@ -19,7 +19,7 @@ namespace Bootstrap.DataAccess
|
||||||
/// <param name="menuIds"></param>
|
/// <param name="menuIds"></param>
|
||||||
/// <param name="dictIds"></param>
|
/// <param name="dictIds"></param>
|
||||||
/// <param name="cacheKey"></param>
|
/// <param name="cacheKey"></param>
|
||||||
public static void ClearCache(IEnumerable<int> roleIds = null, IEnumerable<int> userIds = null, IEnumerable<int> groupIds = null, IEnumerable<int> menuIds = null, string dictIds = null, string cacheKey = null)
|
public static void ClearCache(IEnumerable<string> roleIds = null, IEnumerable<string> userIds = null, IEnumerable<string> groupIds = null, IEnumerable<string> menuIds = null, string dictIds = null, string cacheKey = null)
|
||||||
{
|
{
|
||||||
var cacheKeys = new List<string>();
|
var cacheKeys = new List<string>();
|
||||||
var corsKeys = new List<string>();
|
var corsKeys = new List<string>();
|
||||||
|
|
|
@ -18,7 +18,7 @@ namespace Bootstrap.DataAccess
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="value">需要删除的IDs</param>
|
/// <param name="value">需要删除的IDs</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public virtual bool DeleteDict(IEnumerable<int> value)
|
public virtual bool DeleteDict(IEnumerable<string> value)
|
||||||
{
|
{
|
||||||
var ret = false;
|
var ret = false;
|
||||||
var ids = string.Join(",", value);
|
var ids = string.Join(",", value);
|
||||||
|
@ -41,7 +41,7 @@ namespace Bootstrap.DataAccess
|
||||||
if (dict.Category.Length > 50) dict.Category = dict.Category.Substring(0, 50);
|
if (dict.Category.Length > 50) dict.Category = dict.Category.Substring(0, 50);
|
||||||
if (dict.Name.Length > 50) dict.Name = dict.Name.Substring(0, 50);
|
if (dict.Name.Length > 50) dict.Name = dict.Name.Substring(0, 50);
|
||||||
if (dict.Code.Length > 50) dict.Code = dict.Code.Substring(0, 50);
|
if (dict.Code.Length > 50) dict.Code = dict.Code.Substring(0, 50);
|
||||||
string sql = dict.Id == 0 ?
|
string sql = string.IsNullOrEmpty(dict.Id) ?
|
||||||
"Insert Into Dicts (Category, Name, Code ,Define) Values (@Category, @Name, @Code, @Define)" :
|
"Insert Into Dicts (Category, Name, Code ,Define) Values (@Category, @Name, @Code, @Define)" :
|
||||||
"Update Dicts set Category = @Category, Name = @Name, Code = @Code, Define = @Define where ID = @ID";
|
"Update Dicts set Category = @Category, Name = @Name, Code = @Code, Define = @Define where ID = @ID";
|
||||||
using (DbCommand cmd = DbAccessManager.DBAccess.CreateCommand(CommandType.Text, sql))
|
using (DbCommand cmd = DbAccessManager.DBAccess.CreateCommand(CommandType.Text, sql))
|
||||||
|
@ -53,7 +53,7 @@ namespace Bootstrap.DataAccess
|
||||||
cmd.Parameters.Add(DbAccessManager.DBAccess.CreateParameter("@Define", dict.Define));
|
cmd.Parameters.Add(DbAccessManager.DBAccess.CreateParameter("@Define", dict.Define));
|
||||||
ret = DbAccessManager.DBAccess.ExecuteNonQuery(cmd) == 1;
|
ret = DbAccessManager.DBAccess.ExecuteNonQuery(cmd) == 1;
|
||||||
}
|
}
|
||||||
CacheCleanUtility.ClearCache(dictIds: dict.Id == 0 ? string.Empty : dict.Id.ToString());
|
CacheCleanUtility.ClearCache(dictIds: string.IsNullOrEmpty(dict.Id) ? string.Empty : dict.Id.ToString());
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -81,84 +81,46 @@ namespace Bootstrap.DataAccess
|
||||||
/// 获取字典分类名称
|
/// 获取字典分类名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public virtual IEnumerable<string> RetrieveCategories()
|
public virtual IEnumerable<string> RetrieveCategories() => DictHelper.RetrieveDicts().Select(d => d.Category);
|
||||||
{
|
|
||||||
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())
|
|
||||||
{
|
|
||||||
ret.Add((string)reader[0]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public virtual string RetrieveWebTitle()
|
public virtual string RetrieveWebTitle() => (DictHelper.RetrieveDicts().FirstOrDefault(d => d.Name == "网站标题" && d.Category == "网站设置" && d.Define == 0) ?? new BootstrapDict() { Code = "后台管理系统" }).Code;
|
||||||
{
|
|
||||||
var settings = RetrieveDicts();
|
|
||||||
return (settings.FirstOrDefault(d => d.Name == "网站标题" && d.Category == "网站设置" && d.Define == 0) ?? new BootstrapDict() { Code = "后台管理系统" }).Code;
|
|
||||||
}
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public virtual string RetrieveWebFooter()
|
public virtual string RetrieveWebFooter() => (DictHelper.RetrieveDicts().FirstOrDefault(d => d.Name == "网站页脚" && d.Category == "网站设置" && d.Define == 0) ?? new BootstrapDict() { Code = "2016 © 通用后台管理系统" }).Code;
|
||||||
{
|
|
||||||
var settings = RetrieveDicts();
|
|
||||||
return (settings.FirstOrDefault(d => d.Name == "网站页脚" && d.Category == "网站设置" && d.Define == 0) ?? new BootstrapDict() { Code = "2016 © 通用后台管理系统" }).Code;
|
|
||||||
}
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获得系统中配置的可以使用的网站样式
|
/// 获得系统中配置的可以使用的网站样式
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public virtual IEnumerable<BootstrapDict> RetrieveThemes()
|
public virtual IEnumerable<BootstrapDict> RetrieveThemes() => DictHelper.RetrieveDicts().Where(d => d.Category == "网站样式");
|
||||||
{
|
|
||||||
var data = RetrieveDicts();
|
|
||||||
return data.Where(d => d.Category == "网站样式");
|
|
||||||
}
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获得网站设置中的当前样式
|
/// 获得网站设置中的当前样式
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public virtual string RetrieveActiveTheme()
|
public virtual string RetrieveActiveTheme()
|
||||||
{
|
{
|
||||||
var data = RetrieveDicts();
|
var theme = DictHelper.RetrieveDicts().Where(d => d.Name == "使用样式" && d.Category == "当前样式" && d.Define == 0).FirstOrDefault();
|
||||||
var theme = data.Where(d => d.Name == "使用样式" && d.Category == "当前样式" && d.Define == 0).FirstOrDefault();
|
|
||||||
return theme == null ? string.Empty : (theme.Code.Equals("site.css", StringComparison.OrdinalIgnoreCase) ? string.Empty : theme.Code);
|
return theme == null ? string.Empty : (theme.Code.Equals("site.css", StringComparison.OrdinalIgnoreCase) ? string.Empty : theme.Code);
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取头像路径
|
/// 获取头像路径
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public virtual BootstrapDict RetrieveIconFolderPath()
|
public virtual BootstrapDict RetrieveIconFolderPath() => DictHelper.RetrieveDicts().FirstOrDefault(d => d.Name == "头像路径" && d.Category == "头像地址" && d.Define == 0) ?? new BootstrapDict() { Code = "~/images/uploader/" };
|
||||||
{
|
|
||||||
var data = RetrieveDicts();
|
|
||||||
return data.FirstOrDefault(d => d.Name == "头像路径" && d.Category == "头像地址" && d.Define == 0) ?? new BootstrapDict() { Code = "~/images/uploader/" };
|
|
||||||
}
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获得默认的前台首页地址,默认为~/Home/Index
|
/// 获得默认的前台首页地址,默认为~/Home/Index
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public virtual string RetrieveHomeUrl()
|
public virtual string RetrieveHomeUrl() => (DictHelper.RetrieveDicts().FirstOrDefault(d => d.Name == "前台首页" && d.Category == "网站设置" && d.Define == 0) ?? new BootstrapDict() { Code = "~/Home/Index" }).Code;
|
||||||
{
|
|
||||||
var settings = RetrieveDicts();
|
|
||||||
return (settings.FirstOrDefault(d => d.Name == "前台首页" && d.Category == "网站设置" && d.Define == 0) ?? new BootstrapDict() { Code = "~/Home/Index" }).Code;
|
|
||||||
}
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public virtual IEnumerable<KeyValuePair<string, string>> RetrieveApps()
|
public virtual IEnumerable<KeyValuePair<string, string>> RetrieveApps() => DictHelper.RetrieveDicts().Where(d => d.Category == "应用程序" && d.Define == 0).Select(d => new KeyValuePair<string, string>(d.Code, d.Name)).OrderBy(d => d.Key);
|
||||||
{
|
|
||||||
var settings = RetrieveDicts();
|
|
||||||
return settings.Where(d => d.Category == "应用程序" && d.Define == 0).Select(d => new KeyValuePair<string, string>(d.Code, d.Name)).OrderBy(d => d.Key);
|
|
||||||
}
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 通过数据库获得所有字典表配置信息,缓存Key=DictHelper-RetrieveDicts
|
/// 通过数据库获得所有字典表配置信息,缓存Key=DictHelper-RetrieveDicts
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -17,7 +17,7 @@ namespace Bootstrap.DataAccess
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int Id { get; set; }
|
public string Id { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -112,7 +112,7 @@ namespace Bootstrap.DataAccess
|
||||||
{
|
{
|
||||||
exceptions.Add(new Exceptions()
|
exceptions.Add(new Exceptions()
|
||||||
{
|
{
|
||||||
Id = (int)reader[0],
|
Id = reader[0].ToString(),
|
||||||
AppDomainName = (string)reader[1],
|
AppDomainName = (string)reader[1],
|
||||||
ErrorPage = reader.IsDBNull(2) ? string.Empty : (string)reader[2],
|
ErrorPage = reader.IsDBNull(2) ? string.Empty : (string)reader[2],
|
||||||
UserId = reader.IsDBNull(3) ? string.Empty : (string)reader[3],
|
UserId = reader.IsDBNull(3) ? string.Empty : (string)reader[3],
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
using Longbow;
|
using Longbow.Data;
|
||||||
using Longbow.Data;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
|
@ -17,18 +16,15 @@ namespace Bootstrap.DataAccess
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获得/设置 群组主键ID
|
/// 获得/设置 群组主键ID
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int Id { get; set; }
|
public string Id { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获得/设置 群组名称
|
/// 获得/设置 群组名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string GroupName { get; set; }
|
public string GroupName { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获得/设置 群组描述
|
/// 获得/设置 群组描述
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string Description { get; set; }
|
public string Description { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取/设置 用户群组关联状态 checked 标示已经关联 '' 标示未关联
|
/// 获取/设置 用户群组关联状态 checked 标示已经关联 '' 标示未关联
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -38,7 +34,7 @@ namespace Bootstrap.DataAccess
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="id"></param>
|
/// <param name="id"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public virtual IEnumerable<Group> RetrieveGroups(int id = 0)
|
public virtual IEnumerable<Group> RetrieveGroups()
|
||||||
{
|
{
|
||||||
string sql = "select * from Groups";
|
string sql = "select * from Groups";
|
||||||
List<Group> groups = new List<Group>();
|
List<Group> groups = new List<Group>();
|
||||||
|
@ -49,7 +45,7 @@ namespace Bootstrap.DataAccess
|
||||||
{
|
{
|
||||||
groups.Add(new Group()
|
groups.Add(new Group()
|
||||||
{
|
{
|
||||||
Id = LgbConvert.ReadValue(reader[0], 0),
|
Id = reader[0].ToString(),
|
||||||
GroupName = (string)reader[1],
|
GroupName = (string)reader[1],
|
||||||
Description = reader.IsDBNull(2) ? string.Empty : (string)reader[2]
|
Description = reader.IsDBNull(2) ? string.Empty : (string)reader[2]
|
||||||
});
|
});
|
||||||
|
@ -61,7 +57,7 @@ namespace Bootstrap.DataAccess
|
||||||
/// 删除群组信息
|
/// 删除群组信息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="ids"></param>
|
/// <param name="ids"></param>
|
||||||
public virtual bool DeleteGroup(IEnumerable<int> value)
|
public virtual bool DeleteGroup(IEnumerable<string> value)
|
||||||
{
|
{
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
var ids = string.Join(",", value);
|
var ids = string.Join(",", value);
|
||||||
|
@ -83,7 +79,7 @@ namespace Bootstrap.DataAccess
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
if (p.GroupName.Length > 50) p.GroupName = p.GroupName.Substring(0, 50);
|
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);
|
if (!string.IsNullOrEmpty(p.Description) && p.Description.Length > 500) p.Description = p.Description.Substring(0, 500);
|
||||||
string sql = p.Id == 0 ?
|
string sql = string.IsNullOrEmpty(p.Id) ?
|
||||||
"Insert Into Groups (GroupName, Description) Values (@GroupName, @Description)" :
|
"Insert Into Groups (GroupName, Description) Values (@GroupName, @Description)" :
|
||||||
"Update Groups set GroupName = @GroupName, Description = @Description where ID = @ID";
|
"Update Groups set GroupName = @GroupName, Description = @Description where ID = @ID";
|
||||||
using (DbCommand cmd = DbAccessManager.DBAccess.CreateCommand(CommandType.Text, sql))
|
using (DbCommand cmd = DbAccessManager.DBAccess.CreateCommand(CommandType.Text, sql))
|
||||||
|
@ -93,7 +89,7 @@ namespace Bootstrap.DataAccess
|
||||||
cmd.Parameters.Add(DbAccessManager.DBAccess.CreateParameter("@Description", DbAdapterManager.ToDBValue(p.Description)));
|
cmd.Parameters.Add(DbAccessManager.DBAccess.CreateParameter("@Description", DbAdapterManager.ToDBValue(p.Description)));
|
||||||
ret = DbAccessManager.DBAccess.ExecuteNonQuery(cmd) == 1;
|
ret = DbAccessManager.DBAccess.ExecuteNonQuery(cmd) == 1;
|
||||||
}
|
}
|
||||||
CacheCleanUtility.ClearCache(groupIds: p.Id == 0 ? new List<int>() : new List<int>() { p.Id });
|
CacheCleanUtility.ClearCache(groupIds: string.IsNullOrEmpty(p.Id) ? new List<string>() : new List<string>() { p.Id });
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -101,7 +97,7 @@ namespace Bootstrap.DataAccess
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="userId"></param>
|
/// <param name="userId"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public virtual IEnumerable<Group> RetrieveGroupsByUserId(int userId)
|
public virtual IEnumerable<Group> 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";
|
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>();
|
List<Group> groups = new List<Group>();
|
||||||
|
@ -113,7 +109,7 @@ namespace Bootstrap.DataAccess
|
||||||
{
|
{
|
||||||
groups.Add(new Group()
|
groups.Add(new Group()
|
||||||
{
|
{
|
||||||
Id = LgbConvert.ReadValue(reader[0], 0),
|
Id = reader[0].ToString(),
|
||||||
GroupName = (string)reader[1],
|
GroupName = (string)reader[1],
|
||||||
Description = reader.IsDBNull(2) ? string.Empty : (string)reader[2],
|
Description = reader.IsDBNull(2) ? string.Empty : (string)reader[2],
|
||||||
Checked = (string)reader[3]
|
Checked = (string)reader[3]
|
||||||
|
@ -128,7 +124,7 @@ namespace Bootstrap.DataAccess
|
||||||
/// <param name="userId"></param>
|
/// <param name="userId"></param>
|
||||||
/// <param name="groupIds"></param>
|
/// <param name="groupIds"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public virtual bool SaveGroupsByUserId(int userId, IEnumerable<int> groupIds)
|
public virtual bool SaveGroupsByUserId(string userId, IEnumerable<string> groupIds)
|
||||||
{
|
{
|
||||||
var ret = false;
|
var ret = false;
|
||||||
DataTable dt = new DataTable();
|
DataTable dt = new DataTable();
|
||||||
|
@ -157,7 +153,7 @@ namespace Bootstrap.DataAccess
|
||||||
transaction.CommitTransaction();
|
transaction.CommitTransaction();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CacheCleanUtility.ClearCache(groupIds: groupIds, userIds: new List<int>() { userId });
|
CacheCleanUtility.ClearCache(groupIds: groupIds, userIds: new List<string>() { userId });
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
@ -173,7 +169,7 @@ namespace Bootstrap.DataAccess
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="roleId"></param>
|
/// <param name="roleId"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public virtual IEnumerable<Group> RetrieveGroupsByRoleId(int roleId)
|
public virtual IEnumerable<Group> RetrieveGroupsByRoleId(string roleId)
|
||||||
{
|
{
|
||||||
List<Group> groups = new List<Group>();
|
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";
|
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";
|
||||||
|
@ -185,7 +181,7 @@ namespace Bootstrap.DataAccess
|
||||||
{
|
{
|
||||||
groups.Add(new Group()
|
groups.Add(new Group()
|
||||||
{
|
{
|
||||||
Id = LgbConvert.ReadValue(reader[0], 0),
|
Id = reader[0].ToString(),
|
||||||
GroupName = (string)reader[1],
|
GroupName = (string)reader[1],
|
||||||
Description = reader.IsDBNull(2) ? string.Empty : (string)reader[2],
|
Description = reader.IsDBNull(2) ? string.Empty : (string)reader[2],
|
||||||
Checked = (string)reader[3]
|
Checked = (string)reader[3]
|
||||||
|
@ -200,7 +196,7 @@ namespace Bootstrap.DataAccess
|
||||||
/// <param name="roleId"></param>
|
/// <param name="roleId"></param>
|
||||||
/// <param name="groupIds"></param>
|
/// <param name="groupIds"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public virtual bool SaveGroupsByRoleId(int roleId, IEnumerable<int> groupIds)
|
public virtual bool SaveGroupsByRoleId(string roleId, IEnumerable<string> groupIds)
|
||||||
{
|
{
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
DataTable dt = new DataTable();
|
DataTable dt = new DataTable();
|
||||||
|
@ -227,7 +223,7 @@ namespace Bootstrap.DataAccess
|
||||||
transaction.CommitTransaction();
|
transaction.CommitTransaction();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CacheCleanUtility.ClearCache(groupIds: groupIds, roleIds: new List<int>() { roleId });
|
CacheCleanUtility.ClearCache(groupIds: groupIds, roleIds: new List<string>() { roleId });
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|
|
@ -31,7 +31,7 @@ namespace Bootstrap.DataAccess
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="value">需要删除的IDs</param>
|
/// <param name="value">需要删除的IDs</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static bool DeleteDict(IEnumerable<int> value) => DbAdapterManager.Create<Dict>().DeleteDict(value);
|
public static bool DeleteDict(IEnumerable<string> value) => DbAdapterManager.Create<Dict>().DeleteDict(value);
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 保存新建/更新的字典信息
|
/// 保存新建/更新的字典信息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
using Longbow.Cache;
|
using Longbow.Cache;
|
||||||
using Longbow.Data;
|
using Longbow.Data;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
|
|
||||||
namespace Bootstrap.DataAccess
|
namespace Bootstrap.DataAccess
|
||||||
{
|
{
|
||||||
|
@ -19,17 +18,12 @@ namespace Bootstrap.DataAccess
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="id"></param>
|
/// <param name="id"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static IEnumerable<Group> RetrieveGroups(int id = 0)
|
public static IEnumerable<Group> RetrieveGroups() => CacheManager.GetOrAdd(RetrieveGroupsDataKey, key => DbAdapterManager.Create<Group>().RetrieveGroups());
|
||||||
{
|
|
||||||
var ret = CacheManager.GetOrAdd(RetrieveGroupsDataKey, key => DbAdapterManager.Create<Group>().RetrieveGroups(id));
|
|
||||||
return id == 0 ? ret : ret.Where(t => id == t.Id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 删除群组信息
|
/// 删除群组信息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="ids"></param>
|
/// <param name="ids"></param>
|
||||||
public static bool DeleteGroup(IEnumerable<int> value) => DbAdapterManager.Create<Group>().DeleteGroup(value);
|
public static bool DeleteGroup(IEnumerable<string> value) => DbAdapterManager.Create<Group>().DeleteGroup(value);
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 保存新建/更新的群组信息
|
/// 保存新建/更新的群组信息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -41,28 +35,28 @@ namespace Bootstrap.DataAccess
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="userId"></param>
|
/// <param name="userId"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static IEnumerable<Group> RetrieveGroupsByUserId(int userId) => CacheManager.GetOrAdd(string.Format("{0}-{1}", RetrieveGroupsByUserIdDataKey, userId), k => DbAdapterManager.Create<Group>().RetrieveGroupsByUserId(userId), RetrieveGroupsByUserIdDataKey);
|
public static IEnumerable<Group> RetrieveGroupsByUserId(string userId) => CacheManager.GetOrAdd(string.Format("{0}-{1}", RetrieveGroupsByUserIdDataKey, userId), k => DbAdapterManager.Create<Group>().RetrieveGroupsByUserId(userId), RetrieveGroupsByUserIdDataKey);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 保存用户部门关系
|
/// 保存用户部门关系
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="id"></param>
|
/// <param name="userId"></param>
|
||||||
/// <param name="groupIds"></param>
|
/// <param name="groupIds"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static bool SaveGroupsByUserId(int id, IEnumerable<int> groupIds) => DbAdapterManager.Create<Group>().SaveGroupsByUserId(id, groupIds);
|
public static bool SaveGroupsByUserId(string userId, IEnumerable<string> groupIds) => DbAdapterManager.Create<Group>().SaveGroupsByUserId(userId, groupIds);
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 根据角色ID指派部门
|
/// 根据角色ID指派部门
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="roleId"></param>
|
/// <param name="roleId"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static IEnumerable<Group> RetrieveGroupsByRoleId(int roleId) => CacheManager.GetOrAdd(string.Format("{0}-{1}", RetrieveGroupsByRoleIdDataKey, roleId), key => DbAdapterManager.Create<Group>().RetrieveGroupsByRoleId(roleId), RetrieveGroupsByRoleIdDataKey);
|
public static IEnumerable<Group> RetrieveGroupsByRoleId(string roleId) => CacheManager.GetOrAdd(string.Format("{0}-{1}", RetrieveGroupsByRoleIdDataKey, roleId), key => DbAdapterManager.Create<Group>().RetrieveGroupsByRoleId(roleId), RetrieveGroupsByRoleIdDataKey);
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 根据角色ID以及选定的部门ID,保到角色部门表
|
/// 根据角色ID以及选定的部门ID,保到角色部门表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="id"></param>
|
/// <param name="roleId"></param>
|
||||||
/// <param name="groupIds"></param>
|
/// <param name="groupIds"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static bool SaveGroupsByRoleId(int id, IEnumerable<int> groupIds) => DbAdapterManager.Create<Group>().SaveGroupsByRoleId(id, groupIds);
|
public static bool SaveGroupsByRoleId(string roleId, IEnumerable<string> groupIds) => DbAdapterManager.Create<Group>().SaveGroupsByRoleId(roleId, groupIds);
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -20,11 +20,7 @@ namespace Bootstrap.DataAccess
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="tId"></param>
|
/// <param name="tId"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static IEnumerable<Log> RetrieveLogs(string tId = null)
|
public static IEnumerable<Log> RetrieveLogs() => CacheManager.GetOrAdd(RetrieveLogsDataKey, key => DbAdapterManager.Create<Log>().RetrieveLogs());
|
||||||
{
|
|
||||||
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>
|
||||||
/// 保存新增的日志信息
|
/// 保存新增的日志信息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -31,7 +31,7 @@ namespace Bootstrap.DataAccess
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="value"></param>
|
/// <param name="value"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static bool DeleteMenu(IEnumerable<int> value) => DbAdapterManager.Create<Menu>().DeleteMenu(value);
|
public static bool DeleteMenu(IEnumerable<string> value) => DbAdapterManager.Create<Menu>().DeleteMenu(value);
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 通过用户名获得所有菜单
|
/// 通过用户名获得所有菜单
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -43,14 +43,14 @@ namespace Bootstrap.DataAccess
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="roleId"></param>
|
/// <param name="roleId"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static IEnumerable<BootstrapMenu> RetrieveMenusByRoleId(int roleId) => CacheManager.GetOrAdd($"{RetrieveMenusByRoleIdDataKey}-{roleId}", k => DbAdapterManager.Create<Menu>().RetrieveMenusByRoleId(roleId), RetrieveMenusByRoleIdDataKey);
|
public static IEnumerable<BootstrapMenu> RetrieveMenusByRoleId(string roleId) => CacheManager.GetOrAdd($"{RetrieveMenusByRoleIdDataKey}-{roleId}", k => DbAdapterManager.Create<Menu>().RetrieveMenusByRoleId(roleId), RetrieveMenusByRoleIdDataKey);
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="id"></param>
|
/// <param name="id"></param>
|
||||||
/// <param name="value"></param>
|
/// <param name="value"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static bool SaveMenusByRoleId(int id, IEnumerable<int> value) => DbAdapterManager.Create<Menu>().SaveMenusByRoleId(id, value);
|
public static bool SaveMenusByRoleId(string id, IEnumerable<string> value) => DbAdapterManager.Create<Menu>().SaveMenusByRoleId(id, value);
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -62,7 +62,7 @@ namespace Bootstrap.DataAccess
|
||||||
var menus = RetrieveAllMenus(userName).Where(m => m.Category == "1" && m.IsResource == 0);
|
var menus = RetrieveAllMenus(userName).Where(m => m.Category == "1" && m.IsResource == 0);
|
||||||
if (appId != "0") menus = menus.Where(m => m.ApplicationCode == appId);
|
if (appId != "0") menus = menus.Where(m => m.ApplicationCode == appId);
|
||||||
DbHelper.ActiveMenu(null, menus, activeUrl);
|
DbHelper.ActiveMenu(null, menus, activeUrl);
|
||||||
var root = menus.Where(m => m.ParentId == 0).OrderBy(m => m.ApplicationCode).ThenBy(m => m.Order);
|
var root = menus.Where(m => m.ParentId == "0").OrderBy(m => m.ApplicationCode).ThenBy(m => m.Order);
|
||||||
DbHelper.CascadeMenus(menus, root);
|
DbHelper.CascadeMenus(menus, root);
|
||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,7 @@ namespace Bootstrap.DataAccess
|
||||||
{
|
{
|
||||||
var menus = RetrieveAllMenus(userName).Where(m => m.Category == "0" && m.IsResource == 0);
|
var menus = RetrieveAllMenus(userName).Where(m => m.Category == "0" && m.IsResource == 0);
|
||||||
DbHelper.ActiveMenu(null, menus, activeUrl);
|
DbHelper.ActiveMenu(null, menus, activeUrl);
|
||||||
var root = menus.Where(m => m.ParentId == 0).OrderBy(m => m.ApplicationCode).ThenBy(m => m.Order);
|
var root = menus.Where(m => m.ParentId == "0").OrderBy(m => m.ApplicationCode).ThenBy(m => m.Order);
|
||||||
DbHelper.CascadeMenus(menus, root);
|
DbHelper.CascadeMenus(menus, root);
|
||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
|
@ -90,7 +90,7 @@ namespace Bootstrap.DataAccess
|
||||||
public static IEnumerable<BootstrapMenu> RetrieveMenus(string userName)
|
public static IEnumerable<BootstrapMenu> RetrieveMenus(string userName)
|
||||||
{
|
{
|
||||||
var menus = RetrieveAllMenus(userName);
|
var menus = RetrieveAllMenus(userName);
|
||||||
var root = menus.Where(m => m.ParentId == 0).OrderBy(m => m.ApplicationCode).ThenBy(m => m.Order);
|
var root = menus.Where(m => m.ParentId == "0").OrderBy(m => m.ApplicationCode).ThenBy(m => m.Order);
|
||||||
DbHelper.CascadeMenus(menus, root);
|
DbHelper.CascadeMenus(menus, root);
|
||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,28 +21,24 @@ namespace Bootstrap.DataAccess
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="id"></param>
|
/// <param name="id"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static IEnumerable<Role> RetrieveRoles(int id = 0)
|
public static IEnumerable<Role> RetrieveRoles() => CacheManager.GetOrAdd(RetrieveRolesDataKey, key => DbAdapterManager.Create<Role>().RetrieveRoles());
|
||||||
{
|
|
||||||
var ret = CacheManager.GetOrAdd(RetrieveRolesDataKey, key => DbAdapterManager.Create<Role>().RetrieveRoles(id));
|
|
||||||
return id == 0 ? ret : ret.Where(t => id == t.Id);
|
|
||||||
}
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 保存用户角色关系
|
/// 保存用户角色关系
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="userId"></param>
|
/// <param name="userId"></param>
|
||||||
/// <param name="roleIds"></param>
|
/// <param name="roleIds"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static bool SaveRolesByUserId(int userId, IEnumerable<int> roleIds) => DbAdapterManager.Create<Role>().SaveRolesByUserId(userId, roleIds);
|
public static bool SaveRolesByUserId(string userId, IEnumerable<string> roleIds) => DbAdapterManager.Create<Role>().SaveRolesByUserId(userId, roleIds);
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 查询某个用户所拥有的角色
|
/// 查询某个用户所拥有的角色
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static IEnumerable<Role> RetrieveRolesByUserId(int userId) => CacheManager.GetOrAdd($"{RetrieveRolesByUserIdDataKey}-{userId}", key => DbAdapterManager.Create<Role>().RetrieveRolesByUserId(userId), RetrieveRolesByUserIdDataKey);
|
public static IEnumerable<Role> RetrieveRolesByUserId(string userId) => CacheManager.GetOrAdd($"{RetrieveRolesByUserIdDataKey}-{userId}", key => DbAdapterManager.Create<Role>().RetrieveRolesByUserId(userId), RetrieveRolesByUserIdDataKey);
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 删除角色表
|
/// 删除角色表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="value"></param>
|
/// <param name="value"></param>
|
||||||
public static bool DeleteRole(IEnumerable<int> value) => DbAdapterManager.Create<Role>().DeleteRole(value);
|
public static bool DeleteRole(IEnumerable<string> value) => DbAdapterManager.Create<Role>().DeleteRole(value);
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 保存新建/更新的角色信息
|
/// 保存新建/更新的角色信息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -54,27 +50,27 @@ namespace Bootstrap.DataAccess
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="menuId"></param>
|
/// <param name="menuId"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static IEnumerable<Role> RetrieveRolesByMenuId(int menuId) => CacheManager.GetOrAdd(string.Format("{0}-{1}", RetrieveRolesByMenuIdDataKey, menuId), key => DbAdapterManager.Create<Role>().RetrieveRolesByMenuId(menuId), RetrieveRolesByMenuIdDataKey);
|
public static IEnumerable<Role> RetrieveRolesByMenuId(string menuId) => CacheManager.GetOrAdd(string.Format("{0}-{1}", RetrieveRolesByMenuIdDataKey, menuId), key => DbAdapterManager.Create<Role>().RetrieveRolesByMenuId(menuId), RetrieveRolesByMenuIdDataKey);
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="id"></param>
|
/// <param name="id"></param>
|
||||||
/// <param name="roleIds"></param>
|
/// <param name="roleIds"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static bool SavaRolesByMenuId(int id, IEnumerable<int> roleIds) => DbAdapterManager.Create<Role>().SavaRolesByMenuId(id, roleIds);
|
public static bool SavaRolesByMenuId(string id, IEnumerable<string> roleIds) => DbAdapterManager.Create<Role>().SavaRolesByMenuId(id, roleIds);
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 根据GroupId查询和该Group有关的所有Roles
|
/// 根据GroupId查询和该Group有关的所有Roles
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="groupId"></param>
|
/// <param name="groupId"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static IEnumerable<Role> RetrieveRolesByGroupId(int groupId) => CacheManager.GetOrAdd(string.Format("{0}-{1}", RetrieveRolesByGroupIdDataKey, groupId), key => DbAdapterManager.Create<Role>().RetrieveRolesByGroupId(groupId), RetrieveRolesByGroupIdDataKey);
|
public static IEnumerable<Role> RetrieveRolesByGroupId(string groupId) => CacheManager.GetOrAdd(string.Format("{0}-{1}", RetrieveRolesByGroupIdDataKey, groupId), key => DbAdapterManager.Create<Role>().RetrieveRolesByGroupId(groupId), RetrieveRolesByGroupIdDataKey);
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 根据GroupId更新Roles信息,删除旧的Roles信息,插入新的Roles信息
|
/// 根据GroupId更新Roles信息,删除旧的Roles信息,插入新的Roles信息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="id"></param>
|
/// <param name="id"></param>
|
||||||
/// <param name="roleIds"></param>
|
/// <param name="roleIds"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static bool SaveRolesByGroupId(int id, IEnumerable<int> roleIds) => DbAdapterManager.Create<Role>().SaveRolesByGroupId(id, roleIds);
|
public static bool SaveRolesByGroupId(string id, IEnumerable<string> roleIds) => DbAdapterManager.Create<Role>().SaveRolesByGroupId(id, roleIds);
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -37,7 +37,7 @@ namespace Bootstrap.DataAccess
|
||||||
/// 删除用户
|
/// 删除用户
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="value"></param>
|
/// <param name="value"></param>
|
||||||
public static bool DeleteUser(IEnumerable<int> value) => DbAdapterManager.Create<User>().DeleteUser(value);
|
public static bool DeleteUser(IEnumerable<string> value) => DbAdapterManager.Create<User>().DeleteUser(value);
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 保存新建
|
/// 保存新建
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -51,14 +51,14 @@ namespace Bootstrap.DataAccess
|
||||||
/// <param name="password"></param>
|
/// <param name="password"></param>
|
||||||
/// <param name="displayName"></param>
|
/// <param name="displayName"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static bool UpdateUser(int id, string password, string displayName) => DbAdapterManager.Create<User>().UpdateUser(id, password, displayName);
|
public static bool UpdateUser(string id, string password, string displayName) => DbAdapterManager.Create<User>().UpdateUser(id, password, displayName);
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="id"></param>
|
/// <param name="id"></param>
|
||||||
/// <param name="approvedBy"></param>
|
/// <param name="approvedBy"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static bool ApproveUser(int id, string approvedBy) => DbAdapterManager.Create<User>().ApproveUser(id, approvedBy);
|
public static bool ApproveUser(string id, string approvedBy) => DbAdapterManager.Create<User>().ApproveUser(id, approvedBy);
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -74,33 +74,33 @@ namespace Bootstrap.DataAccess
|
||||||
/// <param name="rejectBy"></param>
|
/// <param name="rejectBy"></param>
|
||||||
/// <param name="reason"></param>
|
/// <param name="reason"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static bool RejectUser(int id, string rejectBy) => DbAdapterManager.Create<User>().RejectUser(id, rejectBy);
|
public static bool RejectUser(string id, string rejectBy) => DbAdapterManager.Create<User>().RejectUser(id, rejectBy);
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 通过roleId获取所有用户
|
/// 通过roleId获取所有用户
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="roleId"></param>
|
/// <param name="roleId"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static IEnumerable<User> RetrieveUsersByRoleId(int roleId) => CacheManager.GetOrAdd(string.Format("{0}-{1}", RetrieveUsersByRoleIdDataKey, roleId), k => DbAdapterManager.Create<User>().RetrieveUsersByRoleId(roleId), RetrieveUsersByRoleIdDataKey);
|
public static IEnumerable<User> RetrieveUsersByRoleId(string roleId) => CacheManager.GetOrAdd(string.Format("{0}-{1}", RetrieveUsersByRoleIdDataKey, roleId), k => DbAdapterManager.Create<User>().RetrieveUsersByRoleId(roleId), RetrieveUsersByRoleIdDataKey);
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 通过角色ID保存当前授权用户(插入)
|
/// 通过角色ID保存当前授权用户(插入)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="id">角色ID</param>
|
/// <param name="id">角色ID</param>
|
||||||
/// <param name="userIds">用户ID数组</param>
|
/// <param name="userIds">用户ID数组</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static bool SaveUsersByRoleId(int id, IEnumerable<int> userIds) => DbAdapterManager.Create<User>().SaveUsersByRoleId(id, userIds);
|
public static bool SaveUsersByRoleId(string id, IEnumerable<string> userIds) => DbAdapterManager.Create<User>().SaveUsersByRoleId(id, userIds);
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 通过groupId获取所有用户
|
/// 通过groupId获取所有用户
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="groupId"></param>
|
/// <param name="groupId"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static IEnumerable<User> RetrieveUsersByGroupId(int groupId) => CacheManager.GetOrAdd(string.Format("{0}-{1}", RetrieveUsersByGroupIdDataKey, groupId), k => DbAdapterManager.Create<User>().RetrieveUsersByGroupId(groupId), RetrieveUsersByRoleIdDataKey);
|
public static IEnumerable<User> RetrieveUsersByGroupId(string groupId) => CacheManager.GetOrAdd(string.Format("{0}-{1}", RetrieveUsersByGroupIdDataKey, groupId), k => DbAdapterManager.Create<User>().RetrieveUsersByGroupId(groupId), RetrieveUsersByRoleIdDataKey);
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 通过部门ID保存当前授权用户(插入)
|
/// 通过部门ID保存当前授权用户(插入)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="id">GroupID</param>
|
/// <param name="id">GroupID</param>
|
||||||
/// <param name="userIds">用户ID数组</param>
|
/// <param name="userIds">用户ID数组</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static bool SaveUsersByGroupId(int id, IEnumerable<int> userIds) => DbAdapterManager.Create<User>().SaveUsersByGroupId(id, userIds);
|
public static bool SaveUsersByGroupId(string id, IEnumerable<string> userIds) => DbAdapterManager.Create<User>().SaveUsersByGroupId(id, userIds);
|
||||||
/// 根据用户名修改用户头像
|
/// 根据用户名修改用户头像
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="userName"></param>
|
/// <param name="userName"></param>
|
||||||
|
|
|
@ -15,7 +15,7 @@ namespace Bootstrap.DataAccess
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获得/设置 操作日志主键ID
|
/// 获得/设置 操作日志主键ID
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int Id { get; set; }
|
public string Id { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获得/设置 操作类型
|
/// 获得/设置 操作类型
|
||||||
|
@ -51,7 +51,7 @@ namespace Bootstrap.DataAccess
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="tId"></param>
|
/// <param name="tId"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public virtual IEnumerable<Log> RetrieveLogs(string tId = null)
|
public virtual IEnumerable<Log> RetrieveLogs()
|
||||||
{
|
{
|
||||||
string sql = "select * from Logs where DATEDIFF(Week, LogTime, GETDATE()) = 0";
|
string sql = "select * from Logs where DATEDIFF(Week, LogTime, GETDATE()) = 0";
|
||||||
List<Log> logs = new List<Log>();
|
List<Log> logs = new List<Log>();
|
||||||
|
@ -62,7 +62,7 @@ namespace Bootstrap.DataAccess
|
||||||
{
|
{
|
||||||
logs.Add(new Log()
|
logs.Add(new Log()
|
||||||
{
|
{
|
||||||
Id = (int)reader[0],
|
Id = reader[0].ToString(),
|
||||||
CRUD = (string)reader[1],
|
CRUD = (string)reader[1],
|
||||||
UserName = (string)reader[2],
|
UserName = (string)reader[2],
|
||||||
LogTime = (DateTime)reader[3],
|
LogTime = (DateTime)reader[3],
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
using Bootstrap.Security;
|
using Bootstrap.Security;
|
||||||
using Bootstrap.Security.DataAccess;
|
using Bootstrap.Security.DataAccess;
|
||||||
using Longbow;
|
|
||||||
using Longbow.Data;
|
using Longbow.Data;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
@ -20,7 +19,7 @@ namespace Bootstrap.DataAccess
|
||||||
/// 删除菜单信息
|
/// 删除菜单信息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="value"></param>
|
/// <param name="value"></param>
|
||||||
public virtual bool DeleteMenu(IEnumerable<int> value)
|
public virtual bool DeleteMenu(IEnumerable<string> value)
|
||||||
{
|
{
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
var ids = string.Join(",", value);
|
var ids = string.Join(",", value);
|
||||||
|
@ -44,7 +43,7 @@ namespace Bootstrap.DataAccess
|
||||||
if (p.Name.Length > 50) p.Name = p.Name.Substring(0, 50);
|
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.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);
|
if (p.Url != null && p.Url.Length > 4000) p.Url = p.Url.Substring(0, 4000);
|
||||||
string sql = p.Id == 0 ?
|
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)" :
|
"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";
|
"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))
|
using (DbCommand cmd = DbAccessManager.DBAccess.CreateCommand(CommandType.Text, sql))
|
||||||
|
@ -61,7 +60,7 @@ namespace Bootstrap.DataAccess
|
||||||
cmd.Parameters.Add(DbAccessManager.DBAccess.CreateParameter("@ApplicationCode", p.ApplicationCode));
|
cmd.Parameters.Add(DbAccessManager.DBAccess.CreateParameter("@ApplicationCode", p.ApplicationCode));
|
||||||
ret = DbAccessManager.DBAccess.ExecuteNonQuery(cmd) == 1;
|
ret = DbAccessManager.DBAccess.ExecuteNonQuery(cmd) == 1;
|
||||||
}
|
}
|
||||||
CacheCleanUtility.ClearCache(menuIds: p.Id == 0 ? new List<int>() : new List<int>() { p.Id });
|
CacheCleanUtility.ClearCache(menuIds: string.IsNullOrEmpty(p.Id) ? new List<string>() : new List<string>() { p.Id });
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -69,7 +68,7 @@ namespace Bootstrap.DataAccess
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="roleId"></param>
|
/// <param name="roleId"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public virtual IEnumerable<BootstrapMenu> RetrieveMenusByRoleId(int roleId)
|
public virtual IEnumerable<BootstrapMenu> RetrieveMenusByRoleId(string roleId)
|
||||||
{
|
{
|
||||||
var menus = new List<BootstrapMenu>();
|
var menus = new List<BootstrapMenu>();
|
||||||
string sql = "select NavigationID from NavigationRole where RoleID = @RoleID";
|
string sql = "select NavigationID from NavigationRole where RoleID = @RoleID";
|
||||||
|
@ -82,7 +81,7 @@ namespace Bootstrap.DataAccess
|
||||||
{
|
{
|
||||||
menus.Add(new BootstrapMenu()
|
menus.Add(new BootstrapMenu()
|
||||||
{
|
{
|
||||||
Id = LgbConvert.ReadValue(reader[0], 0)
|
Id = reader[0].ToString()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -95,7 +94,7 @@ namespace Bootstrap.DataAccess
|
||||||
/// <param name="roleId"></param>
|
/// <param name="roleId"></param>
|
||||||
/// <param name="menuIds"></param>
|
/// <param name="menuIds"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public virtual bool SaveMenusByRoleId(int roleId, IEnumerable<int> menuIds)
|
public virtual bool SaveMenusByRoleId(string roleId, IEnumerable<string> menuIds)
|
||||||
{
|
{
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
DataTable dt = new DataTable();
|
DataTable dt = new DataTable();
|
||||||
|
@ -121,7 +120,7 @@ namespace Bootstrap.DataAccess
|
||||||
transaction.CommitTransaction();
|
transaction.CommitTransaction();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CacheCleanUtility.ClearCache(menuIds: menuIds, roleIds: new List<int>() { roleId });
|
CacheCleanUtility.ClearCache(menuIds: menuIds, roleIds: new List<string>() { roleId });
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
@ -133,7 +132,7 @@ namespace Bootstrap.DataAccess
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 通过当前用户名获得所有菜单,层次化后集合
|
/// 通过当前用户名获得所有菜单
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="userName">当前登陆的用户名</param>
|
/// <param name="userName">当前登陆的用户名</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
|
|
|
@ -15,7 +15,7 @@ namespace Bootstrap.DataAccess
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 消息主键 数据库自增
|
/// 消息主键 数据库自增
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int Id { get; set; }
|
public string Id { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 标题
|
/// 标题
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -85,7 +85,7 @@ namespace Bootstrap.DataAccess
|
||||||
{
|
{
|
||||||
messages.Add(new Message()
|
messages.Add(new Message()
|
||||||
{
|
{
|
||||||
Id = (int)reader[0],
|
Id = reader[0].ToString(),
|
||||||
Title = (string)reader[1],
|
Title = (string)reader[1],
|
||||||
Content = (string)reader[2],
|
Content = (string)reader[2],
|
||||||
From = (string)reader[3],
|
From = (string)reader[3],
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
using Bootstrap.Security.DataAccess;
|
using Bootstrap.Security.DataAccess;
|
||||||
using Longbow;
|
|
||||||
using Longbow.Data;
|
using Longbow.Data;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
@ -18,7 +17,7 @@ namespace Bootstrap.DataAccess
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获得/设置 角色主键ID
|
/// 获得/设置 角色主键ID
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int Id { get; set; }
|
public string Id { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获得/设置 角色名称
|
/// 获得/设置 角色名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -34,9 +33,8 @@ namespace Bootstrap.DataAccess
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 查询所有角色
|
/// 查询所有角色
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="id"></param>
|
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public virtual IEnumerable<Role> RetrieveRoles(int id = 0)
|
public virtual IEnumerable<Role> RetrieveRoles()
|
||||||
{
|
{
|
||||||
string sql = "select * from Roles";
|
string sql = "select * from Roles";
|
||||||
var roles = new List<Role>();
|
var roles = new List<Role>();
|
||||||
|
@ -47,7 +45,7 @@ namespace Bootstrap.DataAccess
|
||||||
{
|
{
|
||||||
roles.Add(new Role()
|
roles.Add(new Role()
|
||||||
{
|
{
|
||||||
Id = LgbConvert.ReadValue(reader[0], 0),
|
Id = reader[0].ToString(),
|
||||||
RoleName = (string)reader[1],
|
RoleName = (string)reader[1],
|
||||||
Description = reader.IsDBNull(2) ? string.Empty : (string)reader[2]
|
Description = reader.IsDBNull(2) ? string.Empty : (string)reader[2]
|
||||||
});
|
});
|
||||||
|
@ -61,7 +59,7 @@ namespace Bootstrap.DataAccess
|
||||||
/// <param name="userId"></param>
|
/// <param name="userId"></param>
|
||||||
/// <param name="roleIds"></param>
|
/// <param name="roleIds"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public virtual bool SaveRolesByUserId(int userId, IEnumerable<int> roleIds)
|
public virtual bool SaveRolesByUserId(string userId, IEnumerable<string> roleIds)
|
||||||
{
|
{
|
||||||
var ret = false;
|
var ret = false;
|
||||||
DataTable dt = new DataTable();
|
DataTable dt = new DataTable();
|
||||||
|
@ -91,7 +89,7 @@ namespace Bootstrap.DataAccess
|
||||||
}
|
}
|
||||||
transaction.CommitTransaction();
|
transaction.CommitTransaction();
|
||||||
}
|
}
|
||||||
CacheCleanUtility.ClearCache(userIds: new List<int>() { userId }, roleIds: roleIds);
|
CacheCleanUtility.ClearCache(userIds: new List<string>() { userId }, roleIds: roleIds);
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
@ -106,7 +104,7 @@ namespace Bootstrap.DataAccess
|
||||||
/// 查询某个用户所拥有的角色
|
/// 查询某个用户所拥有的角色
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public virtual IEnumerable<Role> RetrieveRolesByUserId(int userId)
|
public virtual IEnumerable<Role> RetrieveRolesByUserId(string userId)
|
||||||
{
|
{
|
||||||
List<Role> roles = new List<Role>();
|
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";
|
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";
|
||||||
|
@ -118,7 +116,7 @@ namespace Bootstrap.DataAccess
|
||||||
{
|
{
|
||||||
roles.Add(new Role()
|
roles.Add(new Role()
|
||||||
{
|
{
|
||||||
Id = LgbConvert.ReadValue(reader[0], 0),
|
Id = reader[0].ToString(),
|
||||||
RoleName = (string)reader[1],
|
RoleName = (string)reader[1],
|
||||||
Description = reader.IsDBNull(2) ? string.Empty : (string)reader[2],
|
Description = reader.IsDBNull(2) ? string.Empty : (string)reader[2],
|
||||||
Checked = (string)reader[3]
|
Checked = (string)reader[3]
|
||||||
|
@ -131,7 +129,7 @@ namespace Bootstrap.DataAccess
|
||||||
/// 删除角色表
|
/// 删除角色表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="value"></param>
|
/// <param name="value"></param>
|
||||||
public virtual bool DeleteRole(IEnumerable<int> value)
|
public virtual bool DeleteRole(IEnumerable<string> value)
|
||||||
{
|
{
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
var ids = string.Join(",", value);
|
var ids = string.Join(",", value);
|
||||||
|
@ -153,7 +151,7 @@ namespace Bootstrap.DataAccess
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
if (!string.IsNullOrEmpty(p.RoleName) && p.RoleName.Length > 50) p.RoleName = p.RoleName.Substring(0, 50);
|
if (!string.IsNullOrEmpty(p.RoleName) && p.RoleName.Length > 50) p.RoleName = p.RoleName.Substring(0, 50);
|
||||||
if (!string.IsNullOrEmpty(p.Description) && p.Description.Length > 50) p.Description = p.Description.Substring(0, 500);
|
if (!string.IsNullOrEmpty(p.Description) && p.Description.Length > 50) p.Description = p.Description.Substring(0, 500);
|
||||||
string sql = p.Id == 0 ?
|
string sql = string.IsNullOrEmpty(p.Id) ?
|
||||||
"Insert Into Roles (RoleName, Description) Values (@RoleName, @Description)" :
|
"Insert Into Roles (RoleName, Description) Values (@RoleName, @Description)" :
|
||||||
"Update Roles set RoleName = @RoleName, Description = @Description where ID = @ID";
|
"Update Roles set RoleName = @RoleName, Description = @Description where ID = @ID";
|
||||||
using (DbCommand cmd = DbAccessManager.DBAccess.CreateCommand(CommandType.Text, sql))
|
using (DbCommand cmd = DbAccessManager.DBAccess.CreateCommand(CommandType.Text, sql))
|
||||||
|
@ -163,7 +161,7 @@ namespace Bootstrap.DataAccess
|
||||||
cmd.Parameters.Add(DbAccessManager.DBAccess.CreateParameter("@Description", DbAdapterManager.ToDBValue(p.Description)));
|
cmd.Parameters.Add(DbAccessManager.DBAccess.CreateParameter("@Description", DbAdapterManager.ToDBValue(p.Description)));
|
||||||
ret = DbAccessManager.DBAccess.ExecuteNonQuery(cmd) == 1;
|
ret = DbAccessManager.DBAccess.ExecuteNonQuery(cmd) == 1;
|
||||||
}
|
}
|
||||||
CacheCleanUtility.ClearCache(roleIds: p.Id == 0 ? new List<int>() : new List<int> { p.Id });
|
CacheCleanUtility.ClearCache(roleIds: string.IsNullOrEmpty(p.Id) ? new List<string>() : new List<string> { p.Id });
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -171,7 +169,7 @@ namespace Bootstrap.DataAccess
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="menuId"></param>
|
/// <param name="menuId"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public virtual IEnumerable<Role> RetrieveRolesByMenuId(int menuId)
|
public virtual IEnumerable<Role> RetrieveRolesByMenuId(string menuId)
|
||||||
{
|
{
|
||||||
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";
|
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>();
|
List<Role> roles = new List<Role>();
|
||||||
|
@ -183,7 +181,7 @@ namespace Bootstrap.DataAccess
|
||||||
{
|
{
|
||||||
roles.Add(new Role()
|
roles.Add(new Role()
|
||||||
{
|
{
|
||||||
Id = LgbConvert.ReadValue(reader[0], 0),
|
Id = reader[0].ToString(),
|
||||||
RoleName = (string)reader[1],
|
RoleName = (string)reader[1],
|
||||||
Description = reader.IsDBNull(2) ? string.Empty : (string)reader[2],
|
Description = reader.IsDBNull(2) ? string.Empty : (string)reader[2],
|
||||||
Checked = (string)reader[3]
|
Checked = (string)reader[3]
|
||||||
|
@ -198,7 +196,7 @@ namespace Bootstrap.DataAccess
|
||||||
/// <param name="menuId"></param>
|
/// <param name="menuId"></param>
|
||||||
/// <param name="roleIds"></param>
|
/// <param name="roleIds"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public virtual bool SavaRolesByMenuId(int menuId, IEnumerable<int> roleIds)
|
public virtual bool SavaRolesByMenuId(string menuId, IEnumerable<string> roleIds)
|
||||||
{
|
{
|
||||||
var ret = false;
|
var ret = false;
|
||||||
DataTable dt = new DataTable();
|
DataTable dt = new DataTable();
|
||||||
|
@ -227,7 +225,7 @@ namespace Bootstrap.DataAccess
|
||||||
transaction.CommitTransaction();
|
transaction.CommitTransaction();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CacheCleanUtility.ClearCache(roleIds: roleIds, menuIds: new List<int>() { menuId });
|
CacheCleanUtility.ClearCache(roleIds: roleIds, menuIds: new List<string>() { menuId });
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
@ -243,7 +241,7 @@ namespace Bootstrap.DataAccess
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="groupId"></param>
|
/// <param name="groupId"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public virtual IEnumerable<Role> RetrieveRolesByGroupId(int groupId)
|
public virtual IEnumerable<Role> RetrieveRolesByGroupId(string groupId)
|
||||||
{
|
{
|
||||||
List<Role> roles = new List<Role>();
|
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";
|
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";
|
||||||
|
@ -255,7 +253,7 @@ namespace Bootstrap.DataAccess
|
||||||
{
|
{
|
||||||
roles.Add(new Role()
|
roles.Add(new Role()
|
||||||
{
|
{
|
||||||
Id = LgbConvert.ReadValue(reader[0], 0),
|
Id = reader[0].ToString(),
|
||||||
RoleName = (string)reader[1],
|
RoleName = (string)reader[1],
|
||||||
Description = reader.IsDBNull(2) ? string.Empty : (string)reader[2],
|
Description = reader.IsDBNull(2) ? string.Empty : (string)reader[2],
|
||||||
Checked = (string)reader[3]
|
Checked = (string)reader[3]
|
||||||
|
@ -270,7 +268,7 @@ namespace Bootstrap.DataAccess
|
||||||
/// <param name="groupId"></param>
|
/// <param name="groupId"></param>
|
||||||
/// <param name="roleIds"></param>
|
/// <param name="roleIds"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public virtual bool SaveRolesByGroupId(int groupId, IEnumerable<int> roleIds)
|
public virtual bool SaveRolesByGroupId(string groupId, IEnumerable<string> roleIds)
|
||||||
{
|
{
|
||||||
var ret = false;
|
var ret = false;
|
||||||
//构造表格
|
//构造表格
|
||||||
|
@ -299,7 +297,7 @@ namespace Bootstrap.DataAccess
|
||||||
transaction.CommitTransaction();
|
transaction.CommitTransaction();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CacheCleanUtility.ClearCache(roleIds: roleIds, groupIds: new List<int>() { groupId });
|
CacheCleanUtility.ClearCache(roleIds: roleIds, groupIds: new List<string>() { groupId });
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|
|
@ -10,7 +10,7 @@ namespace Bootstrap.DataAccess
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取/设置 任务ID
|
/// 获取/设置 任务ID
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int Id { get; set; }
|
public string Id { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取/设置 任务名称
|
/// 获取/设置 任务名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -54,7 +54,7 @@ namespace Bootstrap.DataAccess
|
||||||
{
|
{
|
||||||
tasks.Add(new Task()
|
tasks.Add(new Task()
|
||||||
{
|
{
|
||||||
Id = (int)reader[0],
|
Id = reader[0].ToString(),
|
||||||
TaskName = (string)reader[1],
|
TaskName = (string)reader[1],
|
||||||
AssignName = (string)reader[2],
|
AssignName = (string)reader[2],
|
||||||
UserName = (string)reader[3],
|
UserName = (string)reader[3],
|
||||||
|
|
|
@ -20,7 +20,7 @@ namespace Bootstrap.DataAccess
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获得/设置 用户主键ID
|
/// 获得/设置 用户主键ID
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int Id { get; set; }
|
public string Id { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取/设置 密码
|
/// 获取/设置 密码
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -129,7 +129,7 @@ namespace Bootstrap.DataAccess
|
||||||
{
|
{
|
||||||
users.Add(new User()
|
users.Add(new User()
|
||||||
{
|
{
|
||||||
Id = LgbConvert.ReadValue(reader[0], 0),
|
Id = reader[0].ToString(),
|
||||||
UserName = (string)reader[1],
|
UserName = (string)reader[1],
|
||||||
DisplayName = (string)reader[2],
|
DisplayName = (string)reader[2],
|
||||||
RegisterTime = LgbConvert.ReadValue(reader[3], DateTime.MinValue),
|
RegisterTime = LgbConvert.ReadValue(reader[3], DateTime.MinValue),
|
||||||
|
@ -156,7 +156,7 @@ namespace Bootstrap.DataAccess
|
||||||
{
|
{
|
||||||
users.Add(new User()
|
users.Add(new User()
|
||||||
{
|
{
|
||||||
Id = LgbConvert.ReadValue(reader[0], 0),
|
Id = reader[0].ToString(),
|
||||||
UserName = (string)reader[1],
|
UserName = (string)reader[1],
|
||||||
DisplayName = (string)reader[2],
|
DisplayName = (string)reader[2],
|
||||||
RegisterTime = LgbConvert.ReadValue(reader[3], DateTime.MinValue),
|
RegisterTime = LgbConvert.ReadValue(reader[3], DateTime.MinValue),
|
||||||
|
@ -170,7 +170,7 @@ namespace Bootstrap.DataAccess
|
||||||
/// 删除用户
|
/// 删除用户
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="value"></param>
|
/// <param name="value"></param>
|
||||||
public virtual bool DeleteUser(IEnumerable<int> value)
|
public virtual bool DeleteUser(IEnumerable<string> value)
|
||||||
{
|
{
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
var ids = string.Join(",", value);
|
var ids = string.Join(",", value);
|
||||||
|
@ -190,7 +190,7 @@ namespace Bootstrap.DataAccess
|
||||||
public virtual bool SaveUser(User p)
|
public virtual bool SaveUser(User p)
|
||||||
{
|
{
|
||||||
var ret = false;
|
var ret = false;
|
||||||
if (p.Id == 0 && p.Description.Length > 500) p.Description = p.Description.Substring(0, 500);
|
if (string.IsNullOrEmpty(p.Id) && p.Description.Length > 500) p.Description = p.Description.Substring(0, 500);
|
||||||
if (p.UserName.Length > 50) p.UserName = p.UserName.Substring(0, 50);
|
if (p.UserName.Length > 50) p.UserName = p.UserName.Substring(0, 50);
|
||||||
p.PassSalt = LgbCryptography.GenerateSalt();
|
p.PassSalt = LgbCryptography.GenerateSalt();
|
||||||
p.Password = LgbCryptography.ComputeHash(p.Password, p.PassSalt);
|
p.Password = LgbCryptography.ComputeHash(p.Password, p.PassSalt);
|
||||||
|
@ -203,7 +203,7 @@ namespace Bootstrap.DataAccess
|
||||||
cmd.Parameters.Add(DbAccessManager.DBAccess.CreateParameter("@approvedBy", DbAdapterManager.ToDBValue(p.ApprovedBy)));
|
cmd.Parameters.Add(DbAccessManager.DBAccess.CreateParameter("@approvedBy", DbAdapterManager.ToDBValue(p.ApprovedBy)));
|
||||||
cmd.Parameters.Add(DbAccessManager.DBAccess.CreateParameter("@description", p.Description));
|
cmd.Parameters.Add(DbAccessManager.DBAccess.CreateParameter("@description", p.Description));
|
||||||
ret = DbAccessManager.DBAccess.ExecuteNonQuery(cmd) == -1;
|
ret = DbAccessManager.DBAccess.ExecuteNonQuery(cmd) == -1;
|
||||||
if (ret) CacheCleanUtility.ClearCache(userIds: p.Id == 0 ? new List<int>() : new List<int>() { p.Id });
|
if (ret) CacheCleanUtility.ClearCache(userIds: string.IsNullOrEmpty(p.Id) ? new List<string>() : new List<string>() { p.Id });
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -214,7 +214,7 @@ namespace Bootstrap.DataAccess
|
||||||
/// <param name="password"></param>
|
/// <param name="password"></param>
|
||||||
/// <param name="displayName"></param>
|
/// <param name="displayName"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public virtual bool UpdateUser(int id, string password, string displayName)
|
public virtual bool UpdateUser(string id, string password, string displayName)
|
||||||
{
|
{
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
string sql = "Update Users set Password = @Password, PassSalt = @PassSalt, DisplayName = @DisplayName where ID = @id";
|
string sql = "Update Users set Password = @Password, PassSalt = @PassSalt, DisplayName = @DisplayName where ID = @id";
|
||||||
|
@ -227,7 +227,7 @@ namespace Bootstrap.DataAccess
|
||||||
cmd.Parameters.Add(DbAccessManager.DBAccess.CreateParameter("@Password", newPassword));
|
cmd.Parameters.Add(DbAccessManager.DBAccess.CreateParameter("@Password", newPassword));
|
||||||
cmd.Parameters.Add(DbAccessManager.DBAccess.CreateParameter("@PassSalt", passSalt));
|
cmd.Parameters.Add(DbAccessManager.DBAccess.CreateParameter("@PassSalt", passSalt));
|
||||||
ret = DbAccessManager.DBAccess.ExecuteNonQuery(cmd) == 1;
|
ret = DbAccessManager.DBAccess.ExecuteNonQuery(cmd) == 1;
|
||||||
if (ret) CacheCleanUtility.ClearCache(userIds: id == 0 ? new List<int>() : new List<int>() { id });
|
if (ret) CacheCleanUtility.ClearCache(userIds: string.IsNullOrEmpty(id) ? new List<string>() : new List<string>() { id });
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -237,7 +237,7 @@ namespace Bootstrap.DataAccess
|
||||||
/// <param name="id"></param>
|
/// <param name="id"></param>
|
||||||
/// <param name="approvedBy"></param>
|
/// <param name="approvedBy"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public virtual bool ApproveUser(int id, string approvedBy)
|
public virtual bool ApproveUser(string id, string approvedBy)
|
||||||
{
|
{
|
||||||
var ret = false;
|
var ret = false;
|
||||||
var sql = "update Users set ApprovedTime = GETDATE(), ApprovedBy = @approvedBy where ID = @id";
|
var sql = "update Users set ApprovedTime = GETDATE(), ApprovedBy = @approvedBy where ID = @id";
|
||||||
|
@ -246,7 +246,7 @@ namespace Bootstrap.DataAccess
|
||||||
cmd.Parameters.Add(DbAccessManager.DBAccess.CreateParameter("@id", id));
|
cmd.Parameters.Add(DbAccessManager.DBAccess.CreateParameter("@id", id));
|
||||||
cmd.Parameters.Add(DbAccessManager.DBAccess.CreateParameter("@approvedBy", approvedBy));
|
cmd.Parameters.Add(DbAccessManager.DBAccess.CreateParameter("@approvedBy", approvedBy));
|
||||||
ret = DbAccessManager.DBAccess.ExecuteNonQuery(cmd) == 1;
|
ret = DbAccessManager.DBAccess.ExecuteNonQuery(cmd) == 1;
|
||||||
if (ret) CacheCleanUtility.ClearCache(userIds: new List<int>() { id });
|
if (ret) CacheCleanUtility.ClearCache(userIds: new List<string>() { id });
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -255,9 +255,8 @@ namespace Bootstrap.DataAccess
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="id"></param>
|
/// <param name="id"></param>
|
||||||
/// <param name="rejectBy"></param>
|
/// <param name="rejectBy"></param>
|
||||||
/// <param name="reason"></param>
|
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public virtual bool RejectUser(int id, string rejectBy)
|
public virtual bool RejectUser(string id, string rejectBy)
|
||||||
{
|
{
|
||||||
var ret = false;
|
var ret = false;
|
||||||
using (DbCommand cmd = DbAccessManager.DBAccess.CreateCommand(CommandType.StoredProcedure, "Proc_RejectUsers"))
|
using (DbCommand cmd = DbAccessManager.DBAccess.CreateCommand(CommandType.StoredProcedure, "Proc_RejectUsers"))
|
||||||
|
@ -266,7 +265,7 @@ namespace Bootstrap.DataAccess
|
||||||
cmd.Parameters.Add(DbAccessManager.DBAccess.CreateParameter("@rejectedBy", rejectBy));
|
cmd.Parameters.Add(DbAccessManager.DBAccess.CreateParameter("@rejectedBy", rejectBy));
|
||||||
cmd.Parameters.Add(DbAccessManager.DBAccess.CreateParameter("@rejectedReason", "未填写"));
|
cmd.Parameters.Add(DbAccessManager.DBAccess.CreateParameter("@rejectedReason", "未填写"));
|
||||||
ret = DbAccessManager.DBAccess.ExecuteNonQuery(cmd) == -1;
|
ret = DbAccessManager.DBAccess.ExecuteNonQuery(cmd) == -1;
|
||||||
if (ret) CacheCleanUtility.ClearCache(userIds: new List<int>() { id });
|
if (ret) CacheCleanUtility.ClearCache(userIds: new List<string>() { id });
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -275,7 +274,7 @@ namespace Bootstrap.DataAccess
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="roleId"></param>
|
/// <param name="roleId"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public virtual IEnumerable<User> RetrieveUsersByRoleId(int roleId)
|
public virtual IEnumerable<User> RetrieveUsersByRoleId(string roleId)
|
||||||
{
|
{
|
||||||
List<User> users = new List<User>();
|
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";
|
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";
|
||||||
|
@ -287,7 +286,7 @@ namespace Bootstrap.DataAccess
|
||||||
{
|
{
|
||||||
users.Add(new User()
|
users.Add(new User()
|
||||||
{
|
{
|
||||||
Id = LgbConvert.ReadValue(reader[0], 0),
|
Id = reader[0].ToString(),
|
||||||
UserName = (string)reader[1],
|
UserName = (string)reader[1],
|
||||||
DisplayName = (string)reader[2],
|
DisplayName = (string)reader[2],
|
||||||
Checked = (string)reader[3]
|
Checked = (string)reader[3]
|
||||||
|
@ -302,7 +301,7 @@ namespace Bootstrap.DataAccess
|
||||||
/// <param name="roleId">角色ID</param>
|
/// <param name="roleId">角色ID</param>
|
||||||
/// <param name="userIds">用户ID数组</param>
|
/// <param name="userIds">用户ID数组</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public virtual bool SaveUsersByRoleId(int roleId, IEnumerable<int> userIds)
|
public virtual bool SaveUsersByRoleId(string roleId, IEnumerable<string> userIds)
|
||||||
{
|
{
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
DataTable dt = new DataTable();
|
DataTable dt = new DataTable();
|
||||||
|
@ -328,7 +327,7 @@ namespace Bootstrap.DataAccess
|
||||||
transaction.CommitTransaction();
|
transaction.CommitTransaction();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CacheCleanUtility.ClearCache(userIds: userIds, roleIds: new List<int>() { roleId });
|
CacheCleanUtility.ClearCache(userIds: userIds, roleIds: new List<string>() { roleId });
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
@ -344,7 +343,7 @@ namespace Bootstrap.DataAccess
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="groupId"></param>
|
/// <param name="groupId"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public virtual IEnumerable<User> RetrieveUsersByGroupId(int groupId)
|
public virtual IEnumerable<User> RetrieveUsersByGroupId(string groupId)
|
||||||
{
|
{
|
||||||
List<User> users = new List<User>();
|
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";
|
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";
|
||||||
|
@ -356,7 +355,7 @@ namespace Bootstrap.DataAccess
|
||||||
{
|
{
|
||||||
users.Add(new User()
|
users.Add(new User()
|
||||||
{
|
{
|
||||||
Id = LgbConvert.ReadValue(reader[0], 0),
|
Id = reader[0].ToString(),
|
||||||
UserName = (string)reader[1],
|
UserName = (string)reader[1],
|
||||||
DisplayName = (string)reader[2],
|
DisplayName = (string)reader[2],
|
||||||
Checked = (string)reader[3]
|
Checked = (string)reader[3]
|
||||||
|
@ -371,7 +370,7 @@ namespace Bootstrap.DataAccess
|
||||||
/// <param name="groupId">GroupID</param>
|
/// <param name="groupId">GroupID</param>
|
||||||
/// <param name="userIds">用户ID数组</param>
|
/// <param name="userIds">用户ID数组</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public virtual bool SaveUsersByGroupId(int groupId, IEnumerable<int> userIds)
|
public virtual bool SaveUsersByGroupId(string groupId, IEnumerable<string> userIds)
|
||||||
{
|
{
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
DataTable dt = new DataTable();
|
DataTable dt = new DataTable();
|
||||||
|
@ -398,7 +397,7 @@ namespace Bootstrap.DataAccess
|
||||||
transaction.CommitTransaction();
|
transaction.CommitTransaction();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CacheCleanUtility.ClearCache(userIds: userIds, groupIds: new List<int>() { groupId });
|
CacheCleanUtility.ClearCache(userIds: userIds, groupIds: new List<string>() { groupId });
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|
|
@ -41,6 +41,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SQLite", "SQLite", "{523515
|
||||||
DatabaseScripts\SQLite\Install.sql = DatabaseScripts\SQLite\Install.sql
|
DatabaseScripts\SQLite\Install.sql = DatabaseScripts\SQLite\Install.sql
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Bootstrap.DataAccess.MongoDB", "Bootstrap.DataAccess.MongoDB\Bootstrap.DataAccess.MongoDB.csproj", "{8336F096-4B4A-4710-A1FA-0F5E44CD8D26}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
@ -67,6 +69,10 @@ Global
|
||||||
{BC18A24F-5C99-4DF5-803D-72A912BCBD57}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{BC18A24F-5C99-4DF5-803D-72A912BCBD57}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{BC18A24F-5C99-4DF5-803D-72A912BCBD57}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{BC18A24F-5C99-4DF5-803D-72A912BCBD57}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{BC18A24F-5C99-4DF5-803D-72A912BCBD57}.Release|Any CPU.Build.0 = Release|Any CPU
|
{BC18A24F-5C99-4DF5-803D-72A912BCBD57}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{8336F096-4B4A-4710-A1FA-0F5E44CD8D26}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{8336F096-4B4A-4710-A1FA-0F5E44CD8D26}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{8336F096-4B4A-4710-A1FA-0F5E44CD8D26}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{8336F096-4B4A-4710-A1FA-0F5E44CD8D26}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|
Loading…
Reference in New Issue