重构代码:更改变量名ID=>Id,增加UI字数显示,移除ParameterDirection.Input

This commit is contained in:
Argo-Lenovo 2017-03-30 16:15:45 +08:00
parent 4903e798c2
commit c9389f23e0
51 changed files with 399 additions and 393 deletions

View File

@ -29,7 +29,7 @@ namespace Bootstrap.Admin.Controllers
[HttpGet] [HttpGet]
public Dict Get(int id) public Dict Get(int id)
{ {
return DictHelper.RetrieveDicts().FirstOrDefault(t => t.ID == id); return DictHelper.RetrieveDicts().FirstOrDefault(t => t.Id == id);
} }
/// <summary> /// <summary>
/// ///

View File

@ -28,7 +28,7 @@ namespace Bootstrap.Admin.Controllers
[HttpGet] [HttpGet]
public Group Get(int id) public Group Get(int id)
{ {
return GroupHelper.RetrieveGroups().FirstOrDefault(t => t.ID == id); return GroupHelper.RetrieveGroups().FirstOrDefault(t => t.Id == id);
} }
/// <summary> /// <summary>
/// ///

View File

@ -27,7 +27,7 @@ namespace Bootstrap.Admin.Controllers
[HttpGet] [HttpGet]
public Log Get(int id) public Log Get(int id)
{ {
return LogHelper.RetrieveLogs().FirstOrDefault(t => t.ID == id); return LogHelper.RetrieveLogs().FirstOrDefault(t => t.Id == id);
} }
[HttpPost] [HttpPost]

View File

@ -113,7 +113,7 @@ namespace Bootstrap.Admin.Controllers
break; break;
case "user": case "user":
// 此时 userIds 存储的信息是操作结果 1 标示同意 0 标示拒绝 // 此时 userIds 存储的信息是操作结果 1 标示同意 0 标示拒绝
var user = new User() { ID = id, UserStatus = 2 }; var user = new User() { Id = id, UserStatus = 2 };
if (userIds == "1") if (userIds == "1")
{ {
user.ApprovedBy = User.Identity.Name; user.ApprovedBy = User.Identity.Name;

View File

@ -14,7 +14,7 @@ namespace Bootstrap.Admin.Models
Icon = user.Icon; Icon = user.Icon;
DisplayName = user.DisplayName; DisplayName = user.DisplayName;
UserName = user.UserName; UserName = user.UserName;
UserId = user.ID; UserId = user.Id;
} }
public string UserName { get; private set; } public string UserName { get; private set; }
/// <summary> /// <summary>

View File

@ -39,7 +39,7 @@ namespace Bootstrap.Admin.Models
data = Order == "asc" ? data.OrderBy(t => t.ErrorPage) : data.OrderByDescending(t => t.ErrorPage); data = Order == "asc" ? data.OrderBy(t => t.ErrorPage) : data.OrderByDescending(t => t.ErrorPage);
break; break;
case "UserID": case "UserID":
data = Order == "asc" ? data.OrderBy(t => t.UserID) : data.OrderByDescending(t => t.UserID); data = Order == "asc" ? data.OrderBy(t => t.UserId) : data.OrderByDescending(t => t.UserId);
break; break;
case "UserIp": case "UserIp":
data = Order == "asc" ? data.OrderBy(t => t.UserIp) : data.OrderByDescending(t => t.UserIp); data = Order == "asc" ? data.OrderBy(t => t.UserIp) : data.OrderByDescending(t => t.UserIp);

View File

@ -4,7 +4,7 @@
url: Dicts.url, url: Dicts.url,
dataEntity: new DataEntity({ dataEntity: new DataEntity({
map: { map: {
ID: "dictID", Id: "dictID",
Category: "dictCate", Category: "dictCate",
Name: "dictName", Name: "dictName",
Code: "dictCode", Code: "dictCode",
@ -19,7 +19,7 @@
queryParams: function (params) { return $.extend(params, { category: $('#txt_dict_cate').val(), name: $("#txt_dict_name").val(), define: $("#txt_dict_define").val() }); }, queryParams: function (params) { return $.extend(params, { category: $('#txt_dict_cate').val(), name: $("#txt_dict_name").val(), define: $("#txt_dict_define").val() }); },
columns: [ columns: [
{ checkbox: true }, { checkbox: true },
{ title: "Id", field: "ID", events: bsa.idEvents(), formatter: BootstrapAdmin.idFormatter }, { title: "Id", field: "Id", events: bsa.idEvents(), formatter: BootstrapAdmin.idFormatter },
{ title: "字典标签", field: "Category", sortable: true }, { title: "字典标签", field: "Category", sortable: true },
{ title: "字典名称", field: "Name", sortable: true }, { title: "字典名称", field: "Name", sortable: true },
{ title: "字典代码", field: "Code", sortable: true }, { title: "字典代码", field: "Code", sortable: true },

View File

@ -10,7 +10,7 @@
url: Group.url, url: Group.url,
dataEntity: new DataEntity({ dataEntity: new DataEntity({
map: { map: {
ID: "groupID", Id: "groupID",
GroupName: "groupName", GroupName: "groupName",
Description: "groupDesc" Description: "groupDesc"
} }
@ -20,11 +20,11 @@
id: 'btn_assignRole', id: 'btn_assignRole',
click: function (row) { click: function (row) {
$.bc({ $.bc({
Id: row.ID, url: Role.url, data: { type: "group" }, swal: false, Id: row.Id, url: Role.url, data: { type: "group" }, swal: false,
callback: function (result) { callback: function (result) {
var htmlTemplate = this.htmlTemplate; var htmlTemplate = this.htmlTemplate;
var html = $.map(result, function (element, index) { var html = $.map(result, function (element, index) {
return $.format(htmlTemplate, element.ID, element.RoleName, element.Checked, element.Description); return $.format(htmlTemplate, element.Id, element.RoleName, element.Checked, element.Description);
}).join('') }).join('')
$dialogRoleHeader.text($.format('{0}-角色授权窗口', row.GroupName)); $dialogRoleHeader.text($.format('{0}-角色授权窗口', row.GroupName));
$dialogRoleForm.html(html).find('[role="tooltip"]').each(function (index, label) { $dialogRoleForm.html(html).find('[role="tooltip"]').each(function (index, label) {
@ -38,11 +38,11 @@
id: 'btn_assignUser', id: 'btn_assignUser',
click: function (row) { click: function (row) {
$.bc({ $.bc({
Id: row.ID, url: User.url, data: { type: "group" }, swal: false, Id: row.Id, url: User.url, data: { type: "group" }, swal: false,
callback: function (result) { callback: function (result) {
var htmlTemplate = this.htmlTemplate; var htmlTemplate = this.htmlTemplate;
var html = $.map(result, function (element, index) { var html = $.map(result, function (element, index) {
return $.format(htmlTemplate, element.ID, element.DisplayName, element.Checked, element.UserName); return $.format(htmlTemplate, element.Id, element.DisplayName, element.Checked, element.UserName);
}).join(''); }).join('');
$dialogUserHeader.text($.format('{0}-用户授权窗口', row.GroupName)); $dialogUserHeader.text($.format('{0}-用户授权窗口', row.GroupName));
$dialogUserForm.html(html).find('[role="tooltip"]').each(function (index, label) { $dialogUserForm.html(html).find('[role="tooltip"]').each(function (index, label) {
@ -55,7 +55,7 @@
}, { }, {
id: 'btnSubmitRole', id: 'btnSubmitRole',
click: function (row) { click: function (row) {
var groupId = row.ID; var groupId = row.Id;
var roleIds = $dialogRole.find('input:checked').map(function (index, element) { var roleIds = $dialogRole.find('input:checked').map(function (index, element) {
return $(element).val(); return $(element).val();
}).toArray().join(','); }).toArray().join(',');
@ -64,7 +64,7 @@
}, { }, {
id: 'btnSubmitUser', id: 'btnSubmitUser',
click: function (row) { click: function (row) {
var groupId = row.ID; var groupId = row.Id;
var userIds = $dialogUser.find(':checked').map(function (index, element) { var userIds = $dialogUser.find(':checked').map(function (index, element) {
return $(element).val(); return $(element).val();
}).toArray().join(','); }).toArray().join(',');
@ -79,7 +79,7 @@
sortName: 'GroupName', sortName: 'GroupName',
queryParams: function (params) { return $.extend(params, { groupName: $("#txt_search_name").val(), description: $("#txt_group_desc").val() }); }, //传递参数(* queryParams: function (params) { return $.extend(params, { groupName: $("#txt_search_name").val(), description: $("#txt_group_desc").val() }); }, //传递参数(*
columns: [{ checkbox: true }, columns: [{ checkbox: true },
{ title: "Id", field: "ID", events: bsa.idEvents(), formatter: BootstrapAdmin.idFormatter }, { title: "Id", field: "Id", events: bsa.idEvents(), formatter: BootstrapAdmin.idFormatter },
{ title: "部门名称", field: "GroupName", sortable: true }, { title: "部门名称", field: "GroupName", sortable: true },
{ title: "部门描述", field: "Description", sortable: false } { title: "部门描述", field: "Description", sortable: false }
] ]

View File

@ -315,7 +315,7 @@
minimumCountColumns: 2, //最少允许的列数 minimumCountColumns: 2, //最少允许的列数
clickToSelect: false, //是否启用点击选中行 clickToSelect: false, //是否启用点击选中行
//height: 500, //行高如果没有设置height属性表格自动根据记录条数觉得表格高度 //height: 500, //行高如果没有设置height属性表格自动根据记录条数觉得表格高度
idField: "Id", idfield: "Id",
uniqueId: "Id", //每一行的唯一标识,一般为主键列 uniqueId: "Id", //每一行的唯一标识,一般为主键列
showToggle: true, //是否显示详细视图和列表视图的切换按钮 showToggle: true, //是否显示详细视图和列表视图的切换按钮
cardView: $(window).width() < 768, //是否显示详细视图 cardView: $(window).width() < 768, //是否显示详细视图

View File

@ -25,7 +25,7 @@
url: Menu.url, url: Menu.url,
dataEntity: new DataEntity({ dataEntity: new DataEntity({
map: { map: {
ID: "menuID", Id: "menuID",
ParentId: "parentId", ParentId: "parentId",
ParentName: "parentName", ParentName: "parentName",
Name: "name", Name: "name",
@ -43,11 +43,11 @@
id: 'btn_assignRole', id: 'btn_assignRole',
click: function (row) { click: function (row) {
$.bc({ $.bc({
Id: row.ID, url: Role.url, data: { type: "menu" }, swal: false, Id: row.Id, url: Role.url, data: { type: "menu" }, swal: false,
callback: function (result) { callback: function (result) {
var htmlTemplate = this.htmlTemplate; var htmlTemplate = this.htmlTemplate;
var html = $.map(result, function (element, index) { var html = $.map(result, function (element, index) {
return $.format(htmlTemplate, element.ID, element.RoleName, element.Checked, element.Description); return $.format(htmlTemplate, element.Id, element.RoleName, element.Checked, element.Description);
}).join('') }).join('')
$dialogRoleHeader.text($.format('{0}-角色授权窗口', row.Name)); $dialogRoleHeader.text($.format('{0}-角色授权窗口', row.Name));
$dialogRoleForm.html(html).find('[role="tooltip"]').each(function (index, label) { $dialogRoleForm.html(html).find('[role="tooltip"]').each(function (index, label) {
@ -60,7 +60,7 @@
}, { }, {
id: 'btnSubmitRole', id: 'btnSubmitRole',
click: function (row) { click: function (row) {
var menuId = row.ID; var menuId = row.Id;
var roleIds = $dialogRole.find('input:checked').map(function (index, element) { var roleIds = $dialogRole.find('input:checked').map(function (index, element) {
return $(element).val(); return $(element).val();
}).toArray().join(','); }).toArray().join(',');
@ -82,7 +82,7 @@
queryParams: function (params) { return $.extend(params, { parentName: $('#txt_parent_menus_name').val(), name: $("#txt_menus_name").val(), category: $('#sel_menus_category').val(), isresource: $('#sel_menus_res').val() }); }, //传递参数(* queryParams: function (params) { return $.extend(params, { parentName: $('#txt_parent_menus_name').val(), name: $("#txt_menus_name").val(), category: $('#sel_menus_category').val(), isresource: $('#sel_menus_res').val() }); }, //传递参数(*
columns: [ columns: [
{ checkbox: true }, { checkbox: true },
{ title: "Id", field: "ID", events: bsa.idEvents(), formatter: BootstrapAdmin.idFormatter }, { title: "Id", field: "Id", events: bsa.idEvents(), formatter: BootstrapAdmin.idFormatter },
{ title: "父级菜单", field: "ParentName", sortable: true }, { title: "父级菜单", field: "ParentName", sortable: true },
{ title: "菜单名称", field: "Name", sortable: true }, { title: "菜单名称", field: "Name", sortable: true },
{ title: "菜单序号", field: "Order", sortable: true }, { title: "菜单序号", field: "Order", sortable: true },

View File

@ -26,11 +26,11 @@
id: 'btn_assignUser', id: 'btn_assignUser',
click: function (row) { click: function (row) {
$.bc({ $.bc({
Id: row.ID, url: User.url, data: { type: "role" }, swal: false, Id: row.Id, url: User.url, data: { type: "role" }, swal: false,
callback: function (result) { callback: function (result) {
var htmlTemplate = this.htmlTemplate; var htmlTemplate = this.htmlTemplate;
var html = $.map(result, function (element, index) { var html = $.map(result, function (element, index) {
return $.format(htmlTemplate, element.ID, element.DisplayName, element.Checked, element.UserName); return $.format(htmlTemplate, element.Id, element.DisplayName, element.Checked, element.UserName);
}).join(''); }).join('');
$dialogUserHeader.text($.format('{0}-用户授权窗口', row.RoleName)); $dialogUserHeader.text($.format('{0}-用户授权窗口', row.RoleName));
$dialogUserForm.html(html).find('[role="tooltip"]').each(function (index, label) { $dialogUserForm.html(html).find('[role="tooltip"]').each(function (index, label) {
@ -44,11 +44,11 @@
id: 'btn_assignGroup', id: 'btn_assignGroup',
click: function (row) { click: function (row) {
$.bc({ $.bc({
Id: row.ID, url: Group.url, data: { type: "role" }, swal: false, Id: row.Id, url: Group.url, data: { type: "role" }, swal: false,
callback: function (result) { callback: function (result) {
var htmlTemplate = this.htmlTemplate; var htmlTemplate = this.htmlTemplate;
var html = $.map(result, function (element, index) { var html = $.map(result, function (element, index) {
return $.format(htmlTemplate, element.ID, element.GroupName, element.Checked, element.Description); return $.format(htmlTemplate, element.Id, element.GroupName, element.Checked, element.Description);
}).join(''); }).join('');
$dialogGroupHeader.text($.format('{0}-部门授权窗口', row.RoleName)); $dialogGroupHeader.text($.format('{0}-部门授权窗口', row.RoleName));
$dialogGroupForm.html(html).find('[role="tooltip"]').each(function (index, label) { $dialogGroupForm.html(html).find('[role="tooltip"]').each(function (index, label) {
@ -62,7 +62,7 @@
id: 'btn_assignMenu', id: 'btn_assignMenu',
click: function (row) { click: function (row) {
$.bc({ $.bc({
Id: row.ID, url: Menu.url, data: { type: "role" }, swal: false, Id: row.Id, url: Menu.url, data: { type: "role" }, swal: false,
callback: function (result) { callback: function (result) {
$dialogMenuHeader.text($.format('{0}-菜单授权窗口', row.RoleName)); $dialogMenuHeader.text($.format('{0}-菜单授权窗口', row.RoleName));
$btnSubmitMenu.data('type', 'menu'); $btnSubmitMenu.data('type', 'menu');
@ -70,7 +70,7 @@
var menus = $nestMenu.find('input:checkbox'); var menus = $nestMenu.find('input:checkbox');
menus.removeProp('checked'); menus.removeProp('checked');
$.each(result, function (index, item) { $.each(result, function (index, item) {
var selector = $.format('[value={0}]', item.ID); var selector = $.format('[value={0}]', item.Id);
menus.filter(selector).prop('checked', 'checked'); menus.filter(selector).prop('checked', 'checked');
}); });
$dialogSubMenu.show(); $dialogSubMenu.show();
@ -81,7 +81,7 @@
}, { }, {
id: 'btnSubmitUser', id: 'btnSubmitUser',
click: function (row) { click: function (row) {
var roleId = row.ID; var roleId = row.Id;
var userIds = $dialogUser.find(':checked').map(function (index, element) { var userIds = $dialogUser.find(':checked').map(function (index, element) {
return $(element).val(); return $(element).val();
}).toArray().join(','); }).toArray().join(',');
@ -90,7 +90,7 @@
}, { }, {
id: 'btnSubmitGroup', id: 'btnSubmitGroup',
click: function (row) { click: function (row) {
var roleId = row.ID; var roleId = row.Id;
var groupIds = $dialogGroup.find(':checked').map(function (index, element) { var groupIds = $dialogGroup.find(':checked').map(function (index, element) {
return $(element).val(); return $(element).val();
}).toArray().join(','); }).toArray().join(',');
@ -99,7 +99,7 @@
}, { }, {
id: 'btnSubmitMenu', id: 'btnSubmitMenu',
click: function (row) { click: function (row) {
var roleId = row.ID; var roleId = row.Id;
var type = $btnSubmitMenu.data('type'); var type = $btnSubmitMenu.data('type');
switch (type) { switch (type) {
case "menu": case "menu":
@ -121,7 +121,7 @@
sortName: 'RoleName', sortName: 'RoleName',
queryParams: function (params) { return $.extend(params, { roleName: $("#txt_search_name").val(), description: $("#txt_role_desc").val() }); }, //传递参数(* queryParams: function (params) { return $.extend(params, { roleName: $("#txt_search_name").val(), description: $("#txt_role_desc").val() }); }, //传递参数(*
columns: [{ checkbox: true }, columns: [{ checkbox: true },
{ title: "Id", field: "ID", events: bsa.idEvents(), formatter: BootstrapAdmin.idFormatter }, { title: "Id", field: "Id", events: bsa.idEvents(), formatter: BootstrapAdmin.idFormatter },
{ title: "角色名称", field: "RoleName", sortable: true }, { title: "角色名称", field: "RoleName", sortable: true },
{ title: "角色描述", field: "Description", sortable: false } { title: "角色描述", field: "Description", sortable: false }
] ]

View File

@ -10,7 +10,7 @@
url: User.url, url: User.url,
dataEntity: new DataEntity({ dataEntity: new DataEntity({
map: { map: {
ID: "userID", Id: "userID",
UserName: "userName", UserName: "userName",
Password: "password", Password: "password",
DisplayName: "displayName", DisplayName: "displayName",
@ -22,11 +22,11 @@
id: 'btn_assignRole', id: 'btn_assignRole',
click: function (row) { click: function (row) {
$.bc({ $.bc({
Id: row.ID, url: Role.url, data: { type: "user" }, swal: false, Id: row.Id, url: Role.url, data: { type: "user" }, swal: false,
callback: function (result) { callback: function (result) {
var htmlTemplate = this.htmlTemplate; var htmlTemplate = this.htmlTemplate;
var html = $.map(result, function (element, index) { var html = $.map(result, function (element, index) {
return $.format(htmlTemplate, element.ID, element.RoleName, element.Checked, element.Description); return $.format(htmlTemplate, element.Id, element.RoleName, element.Checked, element.Description);
}).join('') }).join('')
$dialogRoleHeader.text($.format('{0}-角色授权窗口', row.DisplayName)); $dialogRoleHeader.text($.format('{0}-角色授权窗口', row.DisplayName));
$dialogRoleForm.html(html).find('[role="tooltip"]').each(function (index, label) { $dialogRoleForm.html(html).find('[role="tooltip"]').each(function (index, label) {
@ -40,11 +40,11 @@
id: 'btn_assignGroup', id: 'btn_assignGroup',
click: function (row) { click: function (row) {
$.bc({ $.bc({
Id: row.ID, url: Group.url, data: { type: "user" }, swal: false, Id: row.Id, url: Group.url, data: { type: "user" }, swal: false,
callback: function (result) { callback: function (result) {
var htmlTemplate = this.htmlTemplate; var htmlTemplate = this.htmlTemplate;
var html = $.map(result, function (element, index) { var html = $.map(result, function (element, index) {
return $.format(htmlTemplate, element.ID, element.GroupName, element.Checked, element.Description); return $.format(htmlTemplate, element.Id, element.GroupName, element.Checked, element.Description);
}).join(''); }).join('');
$dialogGroupHeader.text($.format('{0}-部门授权窗口', row.DisplayName)); $dialogGroupHeader.text($.format('{0}-部门授权窗口', row.DisplayName));
$dialogGroupForm.html(html).find('[role="tooltip"]').each(function (index, label) { $dialogGroupForm.html(html).find('[role="tooltip"]').each(function (index, label) {
@ -57,7 +57,7 @@
}, { }, {
id: 'btnSubmitRole', id: 'btnSubmitRole',
click: function (row) { click: function (row) {
var userId = row.ID; var userId = row.Id;
var roleIds = $dialogRole.find(':checked').map(function (index, element) { var roleIds = $dialogRole.find(':checked').map(function (index, element) {
return $(element).val(); return $(element).val();
}).toArray().join(','); }).toArray().join(',');
@ -66,7 +66,7 @@
}, { }, {
id: 'btnSubmitGroup', id: 'btnSubmitGroup',
click: function (row) { click: function (row) {
var userId = row.ID; var userId = row.Id;
var groupIds = $dialogGroup.find(':checked').map(function (index, element) { var groupIds = $dialogGroup.find(':checked').map(function (index, element) {
return $(element).val(); return $(element).val();
}).toArray().join(','); }).toArray().join(',');
@ -92,7 +92,7 @@
sortName: 'DisplayName', sortName: 'DisplayName',
queryParams: function (params) { return $.extend(params, { name: $("#txt_search_name").val(), displayName: $('#txt_display_name').val() }); }, //传递参数(* queryParams: function (params) { return $.extend(params, { name: $("#txt_search_name").val(), displayName: $('#txt_display_name').val() }); }, //传递参数(*
columns: [{ checkbox: true }, columns: [{ checkbox: true },
{ title: "Id", field: "ID", events: bsa.idEvents(), formatter: BootstrapAdmin.idFormatter }, { title: "Id", field: "Id", events: bsa.idEvents(), formatter: BootstrapAdmin.idFormatter },
{ title: "登陆名称", field: "UserName", sortable: true }, { title: "登陆名称", field: "UserName", sortable: true },
{ title: "显示名称", field: "DisplayName", sortable: true } { title: "显示名称", field: "DisplayName", sortable: true }
] ]

View File

@ -3,10 +3,10 @@
var html = ""; var html = "";
$.each(menus, function (index, menu) { $.each(menus, function (index, menu) {
if (menu.Menus.length == 0) { if (menu.Menus.length == 0) {
html += $.format('<li class="dd-item dd3-item" data-id="{0}" data-order="{4}" data-category="{3}"><div class="dd-handle dd3-handle"></div><div class="dd3-content"><label><input type="checkbox" value="{0}"><span><i class="{1}"></i>{2}</span></label><label><input type="radio" name="menu" value="{0}"><span><i class="{1}"></i>{2}</span></label><span class="menuType">{5}</span><span class="menuOrder">{4}</span></div></li>', menu.ID, menu.Icon, menu.Name, menu.Category, menu.Order, menu.CategoryName); html += $.format('<li class="dd-item dd3-item" data-id="{0}" data-order="{4}" data-category="{3}"><div class="dd-handle dd3-handle"></div><div class="dd3-content"><label><input type="checkbox" value="{0}"><span><i class="{1}"></i>{2}</span></label><label><input type="radio" name="menu" value="{0}"><span><i class="{1}"></i>{2}</span></label><span class="menuType">{5}</span><span class="menuOrder">{4}</span></div></li>', menu.Id, menu.Icon, menu.Name, menu.Category, menu.Order, menu.CategoryName);
} }
else { else {
html += $.format('<li class="dd-item dd3-item" data-id="{0}" data-order="{5}" data-category="{3}"><div class="dd-handle dd3-handle"></div><div class="dd3-content"><label><input type="checkbox" value="{0}"><span><i class="{1}"></i>{2}</span></label><label><input type="radio" name="menu" value="{0}"><span><i class="{1}"></i>{2}</span></label><span class="menuType">{6}</span><span class="menuOrder">{5}</span></div><ol class="dd-list">{4}</ol></li>', menu.ID, menu.Icon, menu.Name, menu.Category, cascadeSubMenu(menu.Menus), menu.Order, menu.CategoryName); html += $.format('<li class="dd-item dd3-item" data-id="{0}" data-order="{5}" data-category="{3}"><div class="dd-handle dd3-handle"></div><div class="dd3-content"><label><input type="checkbox" value="{0}"><span><i class="{1}"></i>{2}</span></label><label><input type="radio" name="menu" value="{0}"><span><i class="{1}"></i>{2}</span></label><span class="menuType">{6}</span><span class="menuOrder">{5}</span></div><ol class="dd-list">{4}</ol></li>', menu.Id, menu.Icon, menu.Name, menu.Category, cascadeSubMenu(menu.Menus), menu.Order, menu.CategoryName);
} }
}); });
return html; return html;
@ -15,7 +15,7 @@
var cascadeSubMenu = function (menus) { var cascadeSubMenu = function (menus) {
var html = "" var html = ""
$.each(menus, function (index, menu) { $.each(menus, function (index, menu) {
html += $.format('<li class="dd-item dd3-item" data-id="{0}" data-order="{4}" data-category="{3}"><div class="dd-handle dd3-handle"></div><div class="dd3-content"><label><input type="checkbox" value="{0}"><span><i class="{1}"></i>{2}</span></label><label><input type="radio" name="menu" value="{0}"><span><i class="{1}"></i>{2}</span></label><span class="menuType">{5}</span><span class="menuOrder">{4}</span></div></li>', menu.ID, menu.Icon, menu.Name, menu.Category, menu.Order, menu.CategoryName); html += $.format('<li class="dd-item dd3-item" data-id="{0}" data-order="{4}" data-category="{3}"><div class="dd-handle dd3-handle"></div><div class="dd3-content"><label><input type="checkbox" value="{0}"><span><i class="{1}"></i>{2}</span></label><label><input type="radio" name="menu" value="{0}"><span><i class="{1}"></i>{2}</span></label><span class="menuType">{5}</span><span class="menuOrder">{4}</span></div></li>', menu.Id, menu.Icon, menu.Name, menu.Category, menu.Order, menu.CategoryName);
}); });
return html; return html;
}; };
@ -103,7 +103,7 @@ $(function () {
$('#msgHeaderTaskBadge').text(result.TasksCount); $('#msgHeaderTaskBadge').text(result.TasksCount);
var htmlUserTemplate = '<li><a href="../Admin/Tasks?id={3}"><span class="desc">{0}-{2}</span><span class="percent">{1}%</span></span><div class="progress progress-striped"><div class="progress-bar" role="progressbar" aria-valuenow="{1}" aria-valuemin="0" aria-valuemax="100" style="width: {1}%"><span class="sr-only">{1}% 完成</span></div></div></a></li>'; var htmlUserTemplate = '<li><a href="../Admin/Tasks?id={3}"><span class="desc">{0}-{2}</span><span class="percent">{1}%</span></span><div class="progress progress-striped"><div class="progress-bar" role="progressbar" aria-valuenow="{1}" aria-valuemin="0" aria-valuemax="100" style="width: {1}%"><span class="sr-only">{1}% 完成</span></div></div></a></li>';
var html = result.Tasks.map(function (u) { var html = result.Tasks.map(function (u) {
return $.format(htmlUserTemplate, u.TaskName, u.TaskProgress, u.AssignDisplayName, u.ID); return $.format(htmlUserTemplate, u.TaskName, u.TaskProgress, u.AssignDisplayName, u.Id);
}).join(''); }).join('');
$(html).insertAfter($('#msgHeaderTaskContent')); $(html).insertAfter($('#msgHeaderTaskContent'));
@ -139,7 +139,7 @@ $(function () {
$('#msgHeaderMsgBadge').text(result.MessagesCount); $('#msgHeaderMsgBadge').text(result.MessagesCount);
htmlUserTemplate = '<li><a href="../Admin/Messages?id={0}"><span class="photo"><img alt="avatar" src="{1}"></span><span class="subject"><span class="from">{2}</span><span class="time">{4}</span></span><span class="message" title="{5}">{3}</span></a></li>'; htmlUserTemplate = '<li><a href="../Admin/Messages?id={0}"><span class="photo"><img alt="avatar" src="{1}"></span><span class="subject"><span class="from">{2}</span><span class="time">{4}</span></span><span class="message" title="{5}">{3}</span></a></li>';
html = result.Messages.map(function (u) { html = result.Messages.map(function (u) {
return $.format(htmlUserTemplate, u.ID, u.FromIcon, u.FromDisplayName, u.Title, u.Period, u.Content); return $.format(htmlUserTemplate, u.Id, u.FromIcon, u.FromDisplayName, u.Title, u.Period, u.Content);
}).join(''); }).join('');
$(html).insertAfter($('#msgHeaderMsgContent')); $(html).insertAfter($('#msgHeaderMsgContent'));
} }

View File

@ -1,5 +1,5 @@
(function($) { (function ($) {
BootstrapAdmin = function(options) { BootstrapAdmin = function (options) {
var that = this; var that = this;
options = options || {}; options = options || {};
options.click = $.extend({}, BootstrapAdmin.settings.click, options.click); options.click = $.extend({}, BootstrapAdmin.settings.click, options.click);
@ -27,7 +27,7 @@
// handler modal window show event // handler modal window show event
if (this.options.modal && this.options.modal.constructor === String) { if (this.options.modal && this.options.modal.constructor === String) {
$('#' + this.options.modal).on('show.bs.modal', function(e) { $('#' + this.options.modal).on('show.bs.modal', function (e) {
if (that.options.validateForm && that.options.validateForm.constructor === String) { if (that.options.validateForm && that.options.validateForm.constructor === String) {
var v = $('#' + that.options.validateForm); var v = $('#' + that.options.validateForm);
v.validate().resetForm(); v.validate().resetForm();
@ -41,7 +41,7 @@
var source = $("#" + cId); var source = $("#" + cId);
source.data('click', name); source.data('click', name);
if (event !== null) source.data('event', event); if (event !== null) source.data('event', event);
source.click(function(e) { source.click(function (e) {
e.preventDefault(); e.preventDefault();
var method = source.data('click'); var method = source.data('click');
BootstrapAdmin.prototype[method].call(that, this, source.data('event')); BootstrapAdmin.prototype[method].call(that, this, source.data('event'));
@ -68,13 +68,13 @@
} }
}; };
BootstrapAdmin.idFormatter = function(value, row, index) { BootstrapAdmin.idFormatter = function (value, row, index) {
return "<a class='edit' href='javascript:void(0)'>" + value + "</a>"; return "<a class='edit' href='javascript:void(0)'>" + value + "</a>";
}; };
BootstrapAdmin.prototype = { BootstrapAdmin.prototype = {
constructor: BootstrapAdmin, constructor: BootstrapAdmin,
idEvents: function() { idEvents: function () {
var op = { var op = {
dataEntity: $.extend({}, this.options.dataEntity), dataEntity: $.extend({}, this.options.dataEntity),
table: this.options.bootstrapTable, table: this.options.bootstrapTable,
@ -82,7 +82,7 @@
src: this src: this
}; };
return { return {
'click .edit': function(e, value, row, index) { 'click .edit': function (e, value, row, index) {
op.dataEntity.load(row); op.dataEntity.load(row);
$(op.table).bootstrapTable('uncheckAll'); $(op.table).bootstrapTable('uncheckAll');
$(op.table).bootstrapTable('check', index); $(op.table).bootstrapTable('check', index);
@ -92,19 +92,19 @@
} }
}, },
query: function(e, callback) { query: function (e, callback) {
if (this.options.bootstrapTable.constructor === String) $(this.options.bootstrapTable).bootstrapTable('refresh'); if (this.options.bootstrapTable.constructor === String) $(this.options.bootstrapTable).bootstrapTable('refresh');
handlerCallback.call(this, callback, e, { oper: 'query' }); handlerCallback.call(this, callback, e, { oper: 'query' });
}, },
create: function(e, callback) { create: function (e, callback) {
if (this.dataEntity instanceof DataEntity) this.dataEntity.reset(); if (this.dataEntity instanceof DataEntity) this.dataEntity.reset();
if (this.options.modal.constructor === String) $('#' + this.options.modal).modal("show"); if (this.options.modal.constructor === String) $('#' + this.options.modal).modal("show");
if (this.options.bootstrapTable.constructor === String) $(this.options.bootstrapTable).bootstrapTable('uncheckAll'); if (this.options.bootstrapTable.constructor === String) $(this.options.bootstrapTable).bootstrapTable('uncheckAll');
handlerCallback.call(this, callback, e, { oper: 'create' }); handlerCallback.call(this, callback, e, { oper: 'create' });
}, },
edit: function(e, callback) { edit: function (e, callback) {
var options = this.options; var options = this.options;
var data = {}; var data = {};
if (options.bootstrapTable.constructor === String) { if (options.bootstrapTable.constructor === String) {
@ -126,7 +126,7 @@
handlerCallback.call(this, callback, e, { oper: 'edit', data: data }); handlerCallback.call(this, callback, e, { oper: 'edit', data: data });
}, },
del: function(e, callback) { del: function (e, callback) {
var that = this; var that = this;
var options = this.options; var options = this.options;
if (options.bootstrapTable.constructor === String) { if (options.bootstrapTable.constructor === String) {
@ -144,13 +144,13 @@
confirmButtonText: "是的,我要删除", confirmButtonText: "是的,我要删除",
confirmButtonColor: "#d9534f", confirmButtonColor: "#d9534f",
cancelButtonText: "取消" cancelButtonText: "取消"
}, function() { }, function () {
setTimeout(function() { setTimeout(function () {
var iDs = arrselections.map(function(element, index) { return element.ID }).join(","); var iDs = arrselections.map(function (element, index) { return element.Id }).join(",");
options.IDs = iDs; options.IDs = iDs;
$.bc({ $.bc({
url: options.url, data: { "": iDs }, method: 'DELETE', title: '删除数据', url: options.url, data: { "": iDs }, method: 'DELETE', title: '删除数据',
callback: function(result) { callback: function (result) {
if ($.isPlainObject(result)) { if ($.isPlainObject(result)) {
lgbSwal({ title: result.msg, type: result.result ? "success" : "error" }); lgbSwal({ title: result.msg, type: result.result ? "success" : "error" });
result = result.result; result = result.result;
@ -166,24 +166,24 @@
} }
}, },
save: function(e, callback) { save: function (e, callback) {
var that = this; var that = this;
var options = $.extend({ data: {} }, this.options); var options = $.extend({ data: {} }, this.options);
if (this.dataEntity instanceof DataEntity) options = $.extend(options, { data: this.dataEntity.get() }); if (this.dataEntity instanceof DataEntity) options = $.extend(options, { data: this.dataEntity.get() });
if (options.validateForm.constructor === String && !$("#" + options.validateForm).valid()) return; if (options.validateForm.constructor === String && !$("#" + options.validateForm).valid()) return;
$.bc({ $.bc({
url: options.url, data: options.data, title: "保存数据", modal: options.modal, url: options.url, data: options.data, title: "保存数据", modal: options.modal,
callback: function(result) { callback: function (result) {
var finalData = null; var finalData = null;
var index = 0; var index = 0;
if (result) { if (result) {
if (options.bootstrapTable.constructor === String && options.data.ID.constructor === String) { if (options.bootstrapTable.constructor === String && options.data.Id.constructor === String) {
// 更新表格 // 更新表格
if (options.data.ID > 0) { if (options.data.Id > 0) {
var allTableData = $(options.bootstrapTable).bootstrapTable('getData'); var allTableData = $(options.bootstrapTable).bootstrapTable('getData');
for (index = 0; index < allTableData.length; index++) { for (index = 0; index < allTableData.length; index++) {
finalData = allTableData[index]; finalData = allTableData[index];
if (finalData.ID == options.data.ID) { if (finalData.Id == options.data.Id) {
$(options.bootstrapTable).bootstrapTable('updateRow', { index: index, row: $.extend(finalData, options.data) }); $(options.bootstrapTable).bootstrapTable('updateRow', { index: index, row: $.extend(finalData, options.data) });
break; break;
} }
@ -200,7 +200,7 @@
}); });
}, },
assign: function(e, callback) { assign: function (e, callback) {
var options = this.options; var options = this.options;
var row = {}; var row = {};
if (options.bootstrapTable && options.bootstrapTable.constructor === String) { if (options.bootstrapTable && options.bootstrapTable.constructor === String) {
@ -224,7 +224,7 @@
} }
}; };
var handlerCallback = function(callback, e, data) { var handlerCallback = function (callback, e, data) {
if ($.isFunction(callback)) callback.call(e, data); if ($.isFunction(callback)) callback.call(e, data);
if ($.isFunction(this.options.callback)) this.options.callback.call(e, data); if ($.isFunction(this.options.callback)) this.options.callback.call(e, data);
} }

View File

@ -12,7 +12,7 @@
callback: function (result) { callback: function (result) {
if (result) { if (result) {
var content = result.Users.map(function (noti) { var content = result.Users.map(function (noti) {
return $.format(htmlNewUsers, noti.UserName, noti.Description, noti.RegisterTime, noti.ID, noti.DisplayName); return $.format(htmlNewUsers, noti.UserName, noti.Description, noti.RegisterTime, noti.Id, noti.DisplayName);
}).join(''); }).join('');
$taskUsers.append(content); $taskUsers.append(content);
$('#tasks-users').find('[role="tooltip"]').lgbTooltip(); $('#tasks-users').find('[role="tooltip"]').lgbTooltip();

View File

@ -10,7 +10,7 @@
callback: function (result) { callback: function (result) {
if (result) { if (result) {
var content = result.map(function (task) { var content = result.map(function (task) {
return $.format(htmlTask, task.TaskName, task.UserName, task.AssignTime, task.ID); return $.format(htmlTask, task.TaskName, task.UserName, task.AssignTime, task.Id);
}).join(''); }).join('');
$('#list-task').html(content); $('#list-task').html(content);
} }

View File

@ -49,12 +49,12 @@
<div class="row"> <div class="row">
<div class="form-group col-lg-6"> <div class="form-group col-lg-6">
<label class="control-label" for="groupName">部门名称</label> <label class="control-label" for="groupName">部门名称</label>
<input type="text" class="form-control" id="groupName" name="groupName" placeholder="不可为空" maxlength="50" /> <input type="text" class="form-control" id="groupName" name="groupName" placeholder="不可为空50字以内" maxlength="50" />
</div> </div>
<div class="form-group col-lg-6"> <div class="form-group col-lg-6">
<input type="text" class="form-control hidden" id="groupID" name="groupID" /> <input type="text" class="form-control hidden" id="groupID" name="groupID" />
<label class="control-label" for="groupDesc">部门描述</label> <label class="control-label" for="groupDesc">部门描述</label>
<input type="text" class="form-control" id="groupDesc" name="groupDesc" placeholder="描述信息(可为空)" maxlength="50" /> <input type="text" class="form-control" id="groupDesc" name="groupDesc" placeholder="描述信息(可为空)50字以内" maxlength="50" />
</div> </div>
</div> </div>
</form> </form>

View File

@ -82,7 +82,7 @@
<input type="text" class="form-control hidden" id="menuID" name="menuID" /> <input type="text" class="form-control hidden" id="menuID" name="menuID" />
<label class="control-label" for="name">菜单名称</label> <label class="control-label" for="name">菜单名称</label>
<div class="input-group"> <div class="input-group">
<input type="text" class="form-control" id="name" name="name" placeholder="不可为空" maxlength="50" /> <input type="text" class="form-control" id="name" name="name" placeholder="不可为空50字以内" maxlength="50" />
<span class="input-group-btn"> <span class="input-group-btn">
<button data-method="clear" class="btn btn-default" type="button"><i class="fa fa-remove"></i></button> <button data-method="clear" class="btn btn-default" type="button"><i class="fa fa-remove"></i></button>
<button data-method="sel" class="btn btn-default" type="button"><i class="fa fa-edit"></i>全选</button> <button data-method="sel" class="btn btn-default" type="button"><i class="fa fa-edit"></i>全选</button>
@ -93,7 +93,7 @@
<input type="text" class="form-control hidden" id="parentId" name="parentId" /> <input type="text" class="form-control hidden" id="parentId" name="parentId" />
<label class="control-label" for="parentName">父级菜单</label> <label class="control-label" for="parentName">父级菜单</label>
<div class="input-group"> <div class="input-group">
<input type="text" class="form-control" readonly id="parentName" name="parentName" placeholder="请选择...(可为空)" maxlength="50" /> <input type="text" class="form-control" readonly id="parentName" name="parentName" placeholder="请选择...(可为空)50字以内" maxlength="50" />
<span class="input-group-btn"> <span class="input-group-btn">
<button data-method="clear" class="btn btn-default" type="button"><i class="fa fa-remove"></i></button> <button data-method="clear" class="btn btn-default" type="button"><i class="fa fa-remove"></i></button>
<button id="btnMenuParent" class="btn btn-default" type="button"><i class="fa fa-hand-o-up"></i>选择</button> <button id="btnMenuParent" class="btn btn-default" type="button"><i class="fa fa-hand-o-up"></i>选择</button>
@ -113,7 +113,7 @@
<div class="form-group col-sm-6"> <div class="form-group col-sm-6">
<label class="control-label" for="icon">菜单图标</label> <label class="control-label" for="icon">菜单图标</label>
<div class="input-group"> <div class="input-group">
<input type="text" class="form-control" readonly id="icon" name="icon" data-default-val="fa fa-fa" placeholder="请选择...(可为空)" maxlength="50" /> <input type="text" class="form-control" readonly id="icon" name="icon" data-default-val="fa fa-fa" placeholder="请选择...(可为空)50字以内" maxlength="50" />
<span class="input-group-btn"> <span class="input-group-btn">
<button data-method="clear" class="btn btn-default" type="button"><i class="fa fa-remove"></i></button> <button data-method="clear" class="btn btn-default" type="button"><i class="fa fa-remove"></i></button>
<button id="btnIcon" class="btn btn-default" type="button"><i class="fa fa-dashboard"></i>选择</button> <button id="btnIcon" class="btn btn-default" type="button"><i class="fa fa-dashboard"></i>选择</button>
@ -122,7 +122,7 @@
</div> </div>
<div class="form-group col-xs-12"> <div class="form-group col-xs-12">
<label class="control-label" for="url">路径</label> <label class="control-label" for="url">路径</label>
<input type="text" class="form-control form-control-url" id="url" name="url" placeholder="不可为空" /> <input type="text" class="form-control form-control-url" id="url" name="url" placeholder="不可为空4000字以内" maxlength="4000" />
</div> </div>
<div class="form-group col-sm-6 col-xs-12"> <div class="form-group col-sm-6 col-xs-12">
<label class="control-label" for="category">菜单类别</label> <label class="control-label" for="category">菜单类别</label>

View File

@ -28,7 +28,7 @@
</div> </div>
<div class="form-group col-xs-12 col-sm-6"> <div class="form-group col-xs-12 col-sm-6">
<label class="control-label" for="DisplayName">显示名称</label> <label class="control-label" for="DisplayName">显示名称</label>
<input type="text" class="form-control" id="displayName" name="displayName" value="@Model.DisplayName" placeholder="不可为空" maxlength="50" /> <input type="text" class="form-control" id="displayName" name="displayName" value="@Model.DisplayName" placeholder="不可为空50字以内" maxlength="50" />
</div> </div>
</div> </div>
</form> </form>
@ -44,15 +44,15 @@
<div class="row"> <div class="row">
<div class="form-group col-md-4 col-xs-12"> <div class="form-group col-md-4 col-xs-12">
<label class="control-label" for="currentPassword">原密码: </label> <label class="control-label" for="currentPassword">原密码: </label>
<input type="password" class="form-control" id="currentPassword" name="currentPassword" placeholder="原密码" maxlength="50" /> <input type="password" class="form-control" id="currentPassword" name="currentPassword" placeholder="原密码50字以内" maxlength="50" />
</div> </div>
<div class="form-group col-md-4 col-sm-6 col-xs-12"> <div class="form-group col-md-4 col-sm-6 col-xs-12">
<label class="control-label" for="newPassword">新密码: </label> <label class="control-label" for="newPassword">新密码: </label>
<input type="password" class="form-control" id="newPassword" name="newPassword" placeholder="新密码" maxlength="50" /> <input type="password" class="form-control" id="newPassword" name="newPassword" placeholder="新密码50字以内" maxlength="50" />
</div> </div>
<div class="form-group col-md-4 col-sm-6 col-xs-12"> <div class="form-group col-md-4 col-sm-6 col-xs-12">
<label class="control-label" for="confirmPassword">确认密码: </label> <label class="control-label" for="confirmPassword">确认密码: </label>
<input type="password" class="form-control" id="confirmPassword" name="confirmPassword" placeholder="与新密码一致" maxlength="50" /> <input type="password" class="form-control" id="confirmPassword" name="confirmPassword" placeholder="与新密码一致50字以内" maxlength="50" />
</div> </div>
</div> </div>
</form> </form>

View File

@ -59,12 +59,12 @@
<div class="row"> <div class="row">
<div class="form-group col-lg-6"> <div class="form-group col-lg-6">
<label class="control-label" for="roleName">角色名称</label> <label class="control-label" for="roleName">角色名称</label>
<input type="text" class="form-control" id="roleName" name="roleName" placeholder="不可为空" maxlength="50" /> <input type="text" class="form-control" id="roleName" name="roleName" placeholder="不可为空50字以内" maxlength="50" />
</div> </div>
<div class="form-group col-lg-6"> <div class="form-group col-lg-6">
<input type="text" class="form-control hidden" id="roleID" name="roleID" /> <input type="text" class="form-control hidden" id="roleID" name="roleID" />
<label class="control-label" for="roleDesc">角色描述</label> <label class="control-label" for="roleDesc">角色描述</label>
<input type="text" class="form-control" id="roleDesc" name="roleDesc" placeholder="描述信息(可为空)" maxlength="50" /> <input type="text" class="form-control" id="roleDesc" name="roleDesc" placeholder="描述信息(可为空)50字以内" maxlength="50" />
</div> </div>
</div> </div>
</form> </form>

View File

@ -19,7 +19,7 @@
<div class="panel-body"> <div class="panel-body">
<form id="headerDataForm" name="headerDataForm"> <form id="headerDataForm" name="headerDataForm">
<div class="input-group form-group col-xs-12"> <div class="input-group form-group col-xs-12">
<input type="text" class="form-control" id="sysName" name="sysName" placeholder="请输入网站标题" value="@Model.Title" /> <input type="text" class="form-control" id="sysName" name="sysName" placeholder="请输入网站标题50字以内" value="@Model.Title" maxlength="50" />
<span class="input-group-btn"> <span class="input-group-btn">
<button class="btn btn-default" type="button" id="sysSave">保存</button> <button class="btn btn-default" type="button" id="sysSave">保存</button>
</span> </span>
@ -32,7 +32,7 @@
<div class="panel-body"> <div class="panel-body">
<form id="footerDataForm" name="footerDataForm"> <form id="footerDataForm" name="footerDataForm">
<div class="input-group form-group col-xs-12"> <div class="input-group form-group col-xs-12">
<input type="text" class="form-control" id="sysFoot" name="sysFoot" placeholder="请输入网站页脚" value="@Model.Footer" /> <input type="text" class="form-control" id="sysFoot" name="sysFoot" placeholder="请输入网站页脚50字以内" value="@Model.Footer" maxlength="50" />
<span class="input-group-btn"> <span class="input-group-btn">
<button class="btn btn-default" type="button" id="footSave">保存</button> <button class="btn btn-default" type="button" id="footSave">保存</button>
</span> </span>
@ -46,7 +46,7 @@
<form id="CssDataForm" class="form-inline" name="CssDataForm"> <form id="CssDataForm" class="form-inline" name="CssDataForm">
<div class="row"> <div class="row">
<div class="form-group col-xs-12"> <div class="form-group col-xs-12">
<label class="control-label" for="dictDefine">网站样式</label> <label class="control-label">网站样式</label>
<div class="dropdown lgbDropdown"> <div class="dropdown lgbDropdown">
<a id="dictCssDefine" class="btn btn-success" data-toggle="dropdown" data-default-val="site.css"> <a id="dictCssDefine" class="btn btn-success" data-toggle="dropdown" data-default-val="site.css">
<span>默认样式</span> <span>默认样式</span>

View File

@ -50,20 +50,20 @@
<div class="row"> <div class="row">
<div class="form-group col-lg-6"> <div class="form-group col-lg-6">
<label class="control-label" for="userName">登陆名称</label> <label class="control-label" for="userName">登陆名称</label>
<input type="text" class="form-control" id="userName" name="userName" placeholder="不可为空" maxlength="50" /> <input type="text" class="form-control" id="userName" name="userName" placeholder="不可为空50字以内" maxlength="50" />
</div> </div>
<div class="form-group col-lg-6"> <div class="form-group col-lg-6">
<input type="text" class="form-control hidden" id="userID" name="userID" /> <input type="text" class="form-control hidden" id="userID" name="userID" />
<label class="control-label" for="userName">显示名称</label> <label class="control-label" for="userName">显示名称</label>
<input type="text" class="form-control" id="displayName" name="displayName" placeholder="不可为空" maxlength="50" /> <input type="text" class="form-control" id="displayName" name="displayName" placeholder="不可为空50字以内" maxlength="50" />
</div> </div>
<div class="form-group col-lg-6"> <div class="form-group col-lg-6">
<label class="control-label" for="password">登录密码</label> <label class="control-label" for="password">登录密码</label>
<input type="password" class="form-control" id="password" name="password" placeholder="不可为空" maxlength="15" /> <input type="password" class="form-control" id="password" name="password" placeholder="不可为空50字以内" maxlength="50" />
</div> </div>
<div class="form-group col-lg-6"> <div class="form-group col-lg-6">
<label class="control-label" for="confirm">确认密码</label> <label class="control-label" for="confirm">确认密码</label>
<input type="password" class="form-control" id="confirm" name="confirm" placeholder="与登陆密码一致" maxlength="15" /> <input type="password" class="form-control" id="confirm" name="confirm" placeholder="与登陆密码一致50字以内" maxlength="50" />
</div> </div>
</div> </div>
</form> </form>

View File

@ -62,7 +62,7 @@
<label for="description">申请理由:</label> <label for="description">申请理由:</label>
<div class="input-group"> <div class="input-group">
<span class="glyphicon glyphicon-certificate input-group-addon"></span> <span class="glyphicon glyphicon-certificate input-group-addon"></span>
<textarea id="description" name="description" class="form-control" placeholder="申请理由" rows="6" maxlength="500"></textarea> <textarea id="description" name="description" class="form-control" placeholder="申请理由500字以内" rows="6" maxlength="500"></textarea>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">

View File

@ -1,5 +1,4 @@
using Longbow.Caching; using Longbow.Caching.Configuration;
using Longbow.Caching.Configuration;
using Longbow.ExceptionManagement; using Longbow.ExceptionManagement;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -20,6 +19,7 @@ namespace Bootstrap.DataAccess
/// <param name="dictIds"></param> /// <param name="dictIds"></param>
/// <param name="logIds"></param> /// <param name="logIds"></param>
/// <param name="notifyIds"></param> /// <param name="notifyIds"></param>
/// <param name="exceptionIds"></param>
internal static void ClearCache(string roleIds = null, string userIds = null, string groupIds = null, string menuIds = null, string dictIds = null, string logIds = null, string notifyIds = null, string exceptionIds = null) internal static void ClearCache(string roleIds = null, string userIds = null, string groupIds = null, string menuIds = null, string dictIds = null, string logIds = null, string notifyIds = null, string exceptionIds = null)
{ {
var cacheKeys = new List<string>(); var cacheKeys = new List<string>();
@ -27,8 +27,8 @@ namespace Bootstrap.DataAccess
{ {
roleIds.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList().ForEach(id => roleIds.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList().ForEach(id =>
{ {
cacheKeys.Add(string.Format("{0}-{1}", UserHelper.RetrieveUsersByRoleIDDataKey, id)); cacheKeys.Add(string.Format("{0}-{1}", UserHelper.RetrieveUsersByRoleIdDataKey, id));
cacheKeys.Add(string.Format("{0}-{1}", GroupHelper.RetrieveGroupsByRoleIDDataKey, id)); cacheKeys.Add(string.Format("{0}-{1}", GroupHelper.RetrieveGroupsByRoleIdDataKey, id));
}); });
cacheKeys.Add(RoleHelper.RetrieveRolesDataKey + "*"); cacheKeys.Add(RoleHelper.RetrieveRolesDataKey + "*");
cacheKeys.Add(MenuHelper.RetrieveMenusDataKey + "*"); cacheKeys.Add(MenuHelper.RetrieveMenusDataKey + "*");
@ -37,8 +37,8 @@ namespace Bootstrap.DataAccess
{ {
userIds.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList().ForEach(id => userIds.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList().ForEach(id =>
{ {
cacheKeys.Add(string.Format("{0}-{1}", RoleHelper.RetrieveRolesByUserIDDataKey, id)); cacheKeys.Add(string.Format("{0}-{1}", RoleHelper.RetrieveRolesByUserIdDataKey, id));
cacheKeys.Add(string.Format("{0}-{1}", GroupHelper.RetrieveGroupsByUserIDDataKey, id)); cacheKeys.Add(string.Format("{0}-{1}", GroupHelper.RetrieveGroupsByUserIdDataKey, id));
cacheKeys.Add(MenuHelper.RetrieveMenusDataKey); cacheKeys.Add(MenuHelper.RetrieveMenusDataKey);
}); });
cacheKeys.Add(UserHelper.RetrieveNewUsersDataKey + "*"); cacheKeys.Add(UserHelper.RetrieveNewUsersDataKey + "*");
@ -48,8 +48,8 @@ namespace Bootstrap.DataAccess
{ {
groupIds.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList().ForEach(id => groupIds.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList().ForEach(id =>
{ {
cacheKeys.Add(string.Format("{0}-{1}", RoleHelper.RetrieveRolesByGroupIDDataKey, id)); cacheKeys.Add(string.Format("{0}-{1}", RoleHelper.RetrieveRolesByGroupIdDataKey, id));
cacheKeys.Add(string.Format("{0}-{1}", UserHelper.RetrieveUsersByGroupIDDataKey, id)); cacheKeys.Add(string.Format("{0}-{1}", UserHelper.RetrieveUsersByGroupIdDataKey, id));
}); });
cacheKeys.Add(GroupHelper.RetrieveGroupsDataKey + "*"); cacheKeys.Add(GroupHelper.RetrieveGroupsDataKey + "*");
cacheKeys.Add(MenuHelper.RetrieveMenusDataKey + "*"); cacheKeys.Add(MenuHelper.RetrieveMenusDataKey + "*");
@ -58,7 +58,7 @@ namespace Bootstrap.DataAccess
{ {
menuIds.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList().ForEach(id => menuIds.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList().ForEach(id =>
{ {
cacheKeys.Add(string.Format("{0}-{1}", RoleHelper.RetrieveRolesByMenuIDDataKey, id)); cacheKeys.Add(string.Format("{0}-{1}", RoleHelper.RetrieveRolesByMenuIdDataKey, id));
}); });
cacheKeys.Add(MenuHelper.RetrieveMenusDataKey + "*"); cacheKeys.Add(MenuHelper.RetrieveMenusDataKey + "*");
} }

View File

@ -8,7 +8,7 @@ namespace Bootstrap.DataAccess
/// </summary> /// </summary>
public static class DBAccessManager public static class DBAccessManager
{ {
private static Lazy<DBAccess> db = new Lazy<DBAccess>(() => DBAccess.CreateDB("SQL"), true); private static readonly Lazy<DBAccess> db = new Lazy<DBAccess>(() => DBAccess.CreateDB("SQL"), true);
public static DBAccess SqlDBAccess public static DBAccess SqlDBAccess
{ {

View File

@ -2,15 +2,13 @@
{ {
/// <summary> /// <summary>
/// 字典表实体 /// 字典表实体
/// author:renshuo
/// date:2016.10.27
/// </summary> /// </summary>
public class Dict public class Dict
{ {
/// <summary> /// <summary>
/// 字典主键 数据库自增 /// 字典主键 数据库自增
/// </summary> /// </summary>
public int ID { get; set; } public int Id { get; set; }
/// <summary> /// <summary>
/// 分类 /// 分类
/// </summary> /// </summary>

View File

@ -10,6 +10,9 @@ using System.Linq;
namespace Bootstrap.DataAccess namespace Bootstrap.DataAccess
{ {
/// <summary>
///
/// </summary>
public static class DictHelper public static class DictHelper
{ {
internal const string RetrieveDictsDataKey = "DictHelper-RetrieveDicts"; internal const string RetrieveDictsDataKey = "DictHelper-RetrieveDicts";
@ -33,7 +36,7 @@ namespace Bootstrap.DataAccess
{ {
dicts.Add(new Dict() dicts.Add(new Dict()
{ {
ID = (int)reader[0], Id = (int)reader[0],
Category = (string)reader[1], Category = (string)reader[1],
Name = (string)reader[2], Name = (string)reader[2],
Code = (string)reader[3], Code = (string)reader[3],
@ -83,14 +86,14 @@ namespace Bootstrap.DataAccess
if (p.Category.Length > 50) p.Category = p.Category.Substring(0, 50); if (p.Category.Length > 50) p.Category = p.Category.Substring(0, 50);
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.Code.Length > 50) p.Code = p.Code.Substring(0, 50); if (p.Code.Length > 50) p.Code = p.Code.Substring(0, 50);
string sql = p.ID == 0 ? string sql = p.Id == 0 ?
"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";
try try
{ {
using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql)) using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql))
{ {
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@ID", p.ID)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@ID", p.Id));
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@Category", p.Category)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@Category", p.Category));
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@Name", p.Name)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@Name", p.Name));
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@Code", p.Code)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@Code", p.Code));
@ -98,7 +101,7 @@ namespace Bootstrap.DataAccess
DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd); DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd);
} }
ret = true; ret = true;
CacheCleanUtility.ClearCache(dictIds: p.ID == 0 ? string.Empty : p.ID.ToString()); CacheCleanUtility.ClearCache(dictIds: p.Id == 0 ? string.Empty : p.Id.ToString());
} }
catch (DbException ex) catch (DbException ex)
{ {

View File

@ -10,9 +10,18 @@ using System.Data.Common;
namespace Bootstrap.DataAccess namespace Bootstrap.DataAccess
{ {
/// <summary>
///
/// </summary>
public static class ExceptionHelper public static class ExceptionHelper
{ {
internal const string RetrieveExceptionsDataKey = "ExceptionHelper-RetrieveExceptions"; internal const string RetrieveExceptionsDataKey = "ExceptionHelper-RetrieveExceptions";
/// <summary>
///
/// </summary>
/// <param name="ex"></param>
/// <param name="additionalInfo"></param>
/// <returns></returns>
public static bool Log(Exception ex, NameValueCollection additionalInfo) public static bool Log(Exception ex, NameValueCollection additionalInfo)
{ {
bool ret = false; bool ret = false;
@ -21,12 +30,12 @@ namespace Bootstrap.DataAccess
var sql = "insert into Exceptions (AppDomainName, ErrorPage, UserID, UserIp, ExceptionType, Message, StackTrace, LogTime) values (@AppDomainName, @ErrorPage, @UserID, @UserIp, @ExceptionType, @Message, @StackTrace, GetDate())"; var sql = "insert into Exceptions (AppDomainName, ErrorPage, UserID, UserIp, ExceptionType, Message, StackTrace, LogTime) values (@AppDomainName, @ErrorPage, @UserID, @UserIp, @ExceptionType, @Message, @StackTrace, GetDate())";
using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql)) using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql))
{ {
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@AppDomainName", AppDomain.CurrentDomain.FriendlyName, ParameterDirection.Input)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@AppDomainName", AppDomain.CurrentDomain.FriendlyName));
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@ErrorPage", additionalInfo["ErrorPage"], ParameterDirection.Input)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@ErrorPage", additionalInfo["ErrorPage"]));
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@UserID", DBAccess.ToDBValue(additionalInfo["UserId"]), ParameterDirection.Input)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@UserID", DBAccess.ToDBValue(additionalInfo["UserId"])));
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@UserIp", additionalInfo["UserIp"], ParameterDirection.Input)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@UserIp", additionalInfo["UserIp"]));
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@ExceptionType", ex.GetType().FullName, ParameterDirection.Input)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@ExceptionType", ex.GetType().FullName));
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@Message", ex.Message, ParameterDirection.Input)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@Message", ex.Message));
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@StackTrace", DBAccess.ToDBValue(ex.StackTrace), ParameterDirection.Input)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@StackTrace", DBAccess.ToDBValue(ex.StackTrace), ParameterDirection.Input));
DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd); DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd);
} }
@ -41,14 +50,13 @@ namespace Bootstrap.DataAccess
/// <summary> /// <summary>
/// 查询所有异常 /// 查询所有异常
/// </summary> /// </summary>
/// <param name="tId"></param>
/// <returns></returns> /// <returns></returns>
public static IEnumerable<Exceptions> RetrieveExceptions() public static IEnumerable<Exceptions> RetrieveExceptions()
{ {
return CacheManager.GetOrAdd(RetrieveExceptionsDataKey, CacheSection.RetrieveIntervalByKey(RetrieveExceptionsDataKey), key => return CacheManager.GetOrAdd(RetrieveExceptionsDataKey, CacheSection.RetrieveIntervalByKey(RetrieveExceptionsDataKey), key =>
{ {
string sql = "select top 1000 * from Exceptions order by LogTime desc"; string sql = "select top 1000 * from Exceptions order by LogTime desc";
List<Exceptions> Exceptions = new List<Exceptions>(); List<Exceptions> exceptions = new List<Exceptions>();
DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql); DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql);
try try
{ {
@ -56,12 +64,12 @@ namespace Bootstrap.DataAccess
{ {
while (reader.Read()) while (reader.Read())
{ {
Exceptions.Add(new Exceptions() exceptions.Add(new Exceptions()
{ {
ID = (int)reader[0], Id = (int)reader[0],
AppDomainName = (string)reader[1], AppDomainName = (string)reader[1],
ErrorPage = (string)reader[2], ErrorPage = (string)reader[2],
UserID = (string)reader[3], UserId = (string)reader[3],
UserIp = (string)reader[4], UserIp = (string)reader[4],
ExceptionType = (string)reader[5], ExceptionType = (string)reader[5],
Message = (string)reader[6], Message = (string)reader[6],
@ -72,7 +80,7 @@ namespace Bootstrap.DataAccess
} }
} }
catch (Exception ex) { ExceptionManager.Publish(ex); } catch (Exception ex) { ExceptionManager.Publish(ex); }
return Exceptions; return exceptions;
}, CacheSection.RetrieveDescByKey(RetrieveExceptionsDataKey)); }, CacheSection.RetrieveDescByKey(RetrieveExceptionsDataKey));
} }
} }

View File

@ -9,7 +9,7 @@ namespace Bootstrap.DataAccess
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
public int ID { get; set; } public int Id { get; set; }
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
@ -21,7 +21,7 @@ namespace Bootstrap.DataAccess
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
public string UserID { get; set; } public string UserId { get; set; }
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>

View File

@ -1,15 +1,14 @@
namespace Bootstrap.DataAccess namespace Bootstrap.DataAccess
{ {
/// <summary> /// <summary>
/// author:liuchun ///
/// date:2016.10.22
/// </summary> /// </summary>
public class Group public class Group
{ {
/// <summary> /// <summary>
/// 获得/设置 群组主键ID /// 获得/设置 群组主键ID
/// </summary> /// </summary>
public int ID { get; set; } public int Id { get; set; }
/// <summary> /// <summary>
/// 获得/设置 群组名称 /// 获得/设置 群组名称

View File

@ -1,5 +1,4 @@
using Longbow; using Longbow.Caching;
using Longbow.Caching;
using Longbow.Caching.Configuration; using Longbow.Caching.Configuration;
using Longbow.Data; using Longbow.Data;
using Longbow.ExceptionManagement; using Longbow.ExceptionManagement;
@ -8,7 +7,6 @@ using System.Collections.Generic;
using System.Data; using System.Data;
using System.Data.Common; using System.Data.Common;
using System.Data.SqlClient; using System.Data.SqlClient;
using System.Globalization;
using System.Linq; using System.Linq;
namespace Bootstrap.DataAccess namespace Bootstrap.DataAccess
@ -20,8 +18,8 @@ namespace Bootstrap.DataAccess
public static class GroupHelper public static class GroupHelper
{ {
internal const string RetrieveGroupsDataKey = "GroupHelper-RetrieveGroups"; internal const string RetrieveGroupsDataKey = "GroupHelper-RetrieveGroups";
internal const string RetrieveGroupsByUserIDDataKey = "GroupHelper-RetrieveGroupsByUserId"; internal const string RetrieveGroupsByUserIdDataKey = "GroupHelper-RetrieveGroupsByUserId";
internal const string RetrieveGroupsByRoleIDDataKey = "GroupHelper-RetrieveGroupsByRoleId"; internal const string RetrieveGroupsByRoleIdDataKey = "GroupHelper-RetrieveGroupsByRoleId";
/// <summary> /// <summary>
/// 查询所有群组信息 /// 查询所有群组信息
/// </summary> /// </summary>
@ -32,7 +30,7 @@ namespace Bootstrap.DataAccess
var ret = CacheManager.GetOrAdd(RetrieveGroupsDataKey, CacheSection.RetrieveIntervalByKey(RetrieveGroupsDataKey), key => var ret = CacheManager.GetOrAdd(RetrieveGroupsDataKey, CacheSection.RetrieveIntervalByKey(RetrieveGroupsDataKey), key =>
{ {
string sql = "select * from Groups"; string sql = "select * from Groups";
List<Group> Groups = new List<Group>(); List<Group> groups = new List<Group>();
DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql); DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql);
try try
{ {
@ -40,9 +38,9 @@ namespace Bootstrap.DataAccess
{ {
while (reader.Read()) while (reader.Read())
{ {
Groups.Add(new Group() groups.Add(new Group()
{ {
ID = (int)reader[0], Id = (int)reader[0],
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]
}); });
@ -50,9 +48,9 @@ namespace Bootstrap.DataAccess
} }
} }
catch (Exception ex) { ExceptionManager.Publish(ex); } catch (Exception ex) { ExceptionManager.Publish(ex); }
return Groups; return groups;
}, CacheSection.RetrieveDescByKey(RetrieveGroupsDataKey)); }, CacheSection.RetrieveDescByKey(RetrieveGroupsDataKey));
return id == 0 ? ret : ret.Where(t => id == t.ID); return id == 0 ? ret : ret.Where(t => id == t.Id);
} }
/// <summary> /// <summary>
/// 删除群组信息 /// 删除群组信息
@ -60,13 +58,13 @@ namespace Bootstrap.DataAccess
/// <param name="ids"></param> /// <param name="ids"></param>
public static bool DeleteGroup(string ids) public static bool DeleteGroup(string ids)
{ {
if (string.IsNullOrEmpty(ids) || ids.Contains("'")) return false;
bool ret = false; bool ret = false;
if (string.IsNullOrEmpty(ids) || ids.Contains("'")) return ret;
try try
{ {
using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.StoredProcedure, "Proc_DeleteGroups")) using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.StoredProcedure, "Proc_DeleteGroups"))
{ {
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@ids", ids, ParameterDirection.Input)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@ids", ids));
DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd); DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd);
} }
CacheCleanUtility.ClearCache(groupIds: ids); CacheCleanUtility.ClearCache(groupIds: ids);
@ -85,23 +83,22 @@ namespace Bootstrap.DataAccess
/// <returns></returns> /// <returns></returns>
public static bool SaveGroup(Group p) public static bool SaveGroup(Group p)
{ {
if (p == null) throw new ArgumentNullException("p");
bool ret = false; bool ret = false;
if (p.GroupName.Length > 50) 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.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 = p.Id == 0 ?
"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";
try try
{ {
using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql)) using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql))
{ {
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@ID", p.ID, ParameterDirection.Input)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@ID", p.Id));
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@GroupName", p.GroupName, ParameterDirection.Input)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@GroupName", p.GroupName));
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@Description", DBAccess.ToDBValue(p.Description), ParameterDirection.Input)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@Description", DBAccess.ToDBValue(p.Description)));
DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd); DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd);
} }
CacheCleanUtility.ClearCache(groupIds: p.ID == 0 ? string.Empty : p.ID.ToString()); CacheCleanUtility.ClearCache(groupIds: p.Id == 0 ? string.Empty : p.Id.ToString());
ret = true; ret = true;
} }
catch (DbException ex) catch (DbException ex)
@ -117,22 +114,22 @@ namespace Bootstrap.DataAccess
/// <returns></returns> /// <returns></returns>
public static IEnumerable<Group> RetrieveGroupsByUserId(int userId) public static IEnumerable<Group> RetrieveGroupsByUserId(int userId)
{ {
string key = string.Format("{0}-{1}", RetrieveGroupsByUserIDDataKey, userId); string key = string.Format("{0}-{1}", RetrieveGroupsByUserIdDataKey, userId);
var ret = CacheManager.GetOrAdd(key, CacheSection.RetrieveIntervalByKey(RetrieveGroupsByUserIDDataKey), k => var ret = CacheManager.GetOrAdd(key, CacheSection.RetrieveIntervalByKey(RetrieveGroupsByUserIdDataKey), k =>
{ {
string sql = "select g.ID,g.GroupName,g.[Description],case ug.GroupID when g.ID then 'checked' else '' end [status] from Groups g left join UserGroup ug on g.ID=ug.GroupID and UserID=@UserID"; 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>();
DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql); DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql);
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@UserID", userId, ParameterDirection.Input)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@UserID", userId));
try try
{ {
using (DbDataReader reader = DBAccessManager.SqlDBAccess.ExecuteReader(cmd)) using (DbDataReader reader = DBAccessManager.SqlDBAccess.ExecuteReader(cmd))
{ {
while (reader.Read()) while (reader.Read())
{ {
Groups.Add(new Group() groups.Add(new Group()
{ {
ID = (int)reader[0], Id = (int)reader[0],
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]
@ -141,15 +138,15 @@ namespace Bootstrap.DataAccess
} }
} }
catch (Exception ex) { ExceptionManager.Publish(ex); } catch (Exception ex) { ExceptionManager.Publish(ex); }
return Groups; return groups;
}, CacheSection.RetrieveDescByKey(RetrieveGroupsByUserIDDataKey)); }, CacheSection.RetrieveDescByKey(RetrieveGroupsByUserIdDataKey));
return ret; return ret;
} }
/// <summary> /// <summary>
/// 保存用户部门关系 /// 保存用户部门关系
/// </summary> /// </summary>
/// <param name="id"></param> /// <param name="id"></param>
/// <param name="value"></param> /// <param name="groupIds"></param>
/// <returns></returns> /// <returns></returns>
public static bool SaveGroupsByUserId(int id, string groupIds) public static bool SaveGroupsByUserId(int id, string groupIds)
{ {
@ -167,7 +164,7 @@ namespace Bootstrap.DataAccess
string sql = "delete from UserGroup where UserID=@UserID;"; string sql = "delete from UserGroup where UserID=@UserID;";
using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql)) using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql))
{ {
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@UserID", id, ParameterDirection.Input)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@UserID", id));
DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd, transaction); DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd, transaction);
// insert batch data into config table // insert batch data into config table
@ -199,22 +196,22 @@ namespace Bootstrap.DataAccess
/// <returns></returns> /// <returns></returns>
public static IEnumerable<Group> RetrieveGroupsByRoleId(int roleId) public static IEnumerable<Group> RetrieveGroupsByRoleId(int roleId)
{ {
string k = string.Format("{0}-{1}", RetrieveGroupsByRoleIDDataKey, roleId); string k = string.Format("{0}-{1}", RetrieveGroupsByRoleIdDataKey, roleId);
return CacheManager.GetOrAdd(k, CacheSection.RetrieveIntervalByKey(RetrieveGroupsByRoleIDDataKey), key => return CacheManager.GetOrAdd(k, CacheSection.RetrieveIntervalByKey(RetrieveGroupsByRoleIdDataKey), key =>
{ {
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";
DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql); DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql);
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@RoleID", roleId, ParameterDirection.Input)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@RoleID", roleId));
try try
{ {
using (DbDataReader reader = DBAccessManager.SqlDBAccess.ExecuteReader(cmd)) using (DbDataReader reader = DBAccessManager.SqlDBAccess.ExecuteReader(cmd))
{ {
while (reader.Read()) while (reader.Read())
{ {
Groups.Add(new Group() groups.Add(new Group()
{ {
ID = (int)reader[0], Id = (int)reader[0],
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]
@ -223,14 +220,14 @@ namespace Bootstrap.DataAccess
} }
} }
catch (Exception ex) { ExceptionManager.Publish(ex); } catch (Exception ex) { ExceptionManager.Publish(ex); }
return Groups; return groups;
}, CacheSection.RetrieveDescByKey(RetrieveGroupsByRoleIDDataKey)); }, CacheSection.RetrieveDescByKey(RetrieveGroupsByRoleIdDataKey));
} }
/// <summary> /// <summary>
/// 根据角色ID以及选定的部门ID保到角色部门表 /// 根据角色ID以及选定的部门ID保到角色部门表
/// </summary> /// </summary>
/// <param name="roleId"></param> /// <param name="id"></param>
/// <param name="value"></param> /// <param name="groupIds"></param>
/// <returns></returns> /// <returns></returns>
public static bool SaveGroupsByRoleId(int id, string groupIds) public static bool SaveGroupsByRoleId(int id, string groupIds)
{ {
@ -247,7 +244,7 @@ namespace Bootstrap.DataAccess
string sql = "delete from RoleGroup where RoleID=@RoleID"; string sql = "delete from RoleGroup where RoleID=@RoleID";
using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql)) using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql))
{ {
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@RoleID", id, ParameterDirection.Input)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@RoleID", id));
DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd, transaction); DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd, transaction);
//批插入角色部门表 //批插入角色部门表
using (SqlBulkCopy bulk = new SqlBulkCopy((SqlConnection)transaction.Transaction.Connection, SqlBulkCopyOptions.Default, (SqlTransaction)transaction.Transaction)) using (SqlBulkCopy bulk = new SqlBulkCopy((SqlConnection)transaction.Transaction.Connection, SqlBulkCopyOptions.Default, (SqlTransaction)transaction.Transaction))
@ -273,4 +270,3 @@ namespace Bootstrap.DataAccess
} }
} }
} }

View File

@ -6,7 +6,7 @@ namespace Bootstrap.DataAccess
/// <summary> /// <summary>
/// 获得/设置 操作日志主键ID /// 获得/设置 操作日志主键ID
/// </summary> /// </summary>
public int ID { get; set; } public int Id { get; set; }
/// <summary> /// <summary>
/// 获得/设置 操作类型 /// 获得/设置 操作类型

View File

@ -7,7 +7,6 @@ using System.Data;
using System.Data.Common; using System.Data.Common;
using System.Globalization; using System.Globalization;
using System.Linq; using System.Linq;
using System.Web;
namespace Bootstrap.DataAccess namespace Bootstrap.DataAccess
{ {
@ -24,7 +23,7 @@ namespace Bootstrap.DataAccess
var ret = CacheManager.GetOrAdd(RetrieveLogsDataKey, CacheSection.RetrieveIntervalByKey(RetrieveLogsDataKey), key => var ret = CacheManager.GetOrAdd(RetrieveLogsDataKey, CacheSection.RetrieveIntervalByKey(RetrieveLogsDataKey), key =>
{ {
string sql = "select top 1000 * from Logs"; string sql = "select top 1000 * from Logs";
List<Log> Logs = new List<Log>(); List<Log> logs = new List<Log>();
DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql); DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql);
try try
{ {
@ -32,9 +31,9 @@ namespace Bootstrap.DataAccess
{ {
while (reader.Read()) while (reader.Read())
{ {
Logs.Add(new Log() logs.Add(new Log()
{ {
ID = (int)reader[0], Id = (int)reader[0],
CRUD = (string)reader[1], CRUD = (string)reader[1],
UserName = (string)reader[2], UserName = (string)reader[2],
LogTime = (DateTime)reader[3], LogTime = (DateTime)reader[3],
@ -46,9 +45,9 @@ namespace Bootstrap.DataAccess
} }
} }
catch (Exception ex) { ExceptionManager.Publish(ex); } catch (Exception ex) { ExceptionManager.Publish(ex); }
return Logs; return logs;
}, CacheSection.RetrieveDescByKey(RetrieveLogsDataKey)); }, CacheSection.RetrieveDescByKey(RetrieveLogsDataKey));
return string.IsNullOrEmpty(tId) ? ret : ret.Where(t => tId.Equals(t.ID.ToString(), StringComparison.OrdinalIgnoreCase)); return string.IsNullOrEmpty(tId) ? ret : ret.Where(t => tId.Equals(t.Id.ToString(), StringComparison.OrdinalIgnoreCase));
} }
/// <summary> /// <summary>
/// 删除日志信息 /// 删除日志信息
@ -57,8 +56,8 @@ namespace Bootstrap.DataAccess
/// <returns></returns> /// <returns></returns>
public static bool DeleteLog(string ids) public static bool DeleteLog(string ids)
{ {
if (string.IsNullOrEmpty(ids) || ids.Contains("'")) return false;
bool ret = false; bool ret = false;
if (string.IsNullOrEmpty(ids) || ids.Contains("'")) return ret;
try try
{ {
string sql = string.Format(CultureInfo.InvariantCulture, "Delete from Logs where ID in ({0})", ids); string sql = string.Format(CultureInfo.InvariantCulture, "Delete from Logs where ID in ({0})", ids);
@ -89,14 +88,14 @@ namespace Bootstrap.DataAccess
{ {
using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql)) using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql))
{ {
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@CRUD", p.CRUD, ParameterDirection.Input)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@CRUD", p.CRUD));
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@UserName", p.UserName, ParameterDirection.Input)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@UserName", p.UserName));
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@ClientIp", p.ClientIp, ParameterDirection.Input)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@ClientIp", p.ClientIp));
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@ClientAgent", p.ClientAgent, ParameterDirection.Input)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@ClientAgent", p.ClientAgent));
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@RequestUrl", p.RequestUrl, ParameterDirection.Input)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@RequestUrl", p.RequestUrl));
DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd); DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd);
} }
CacheCleanUtility.ClearCache(logIds: p.ID == 0 ? string.Empty : p.ID.ToString()); CacheCleanUtility.ClearCache(logIds: p.Id == 0 ? string.Empty : p.Id.ToString());
ret = true; ret = true;
} }
catch (DbException ex) catch (DbException ex)

View File

@ -10,7 +10,7 @@ namespace Bootstrap.DataAccess
/// <summary> /// <summary>
/// 获得/设置 菜单主键ID /// 获得/设置 菜单主键ID
/// </summary> /// </summary>
public int ID { set; get; } public int Id { set; get; }
/// <summary> /// <summary>
/// 获得/设置 父级菜单ID /// 获得/设置 父级菜单ID
/// </summary> /// </summary>

View File

@ -13,10 +13,13 @@ using System.Linq;
namespace Bootstrap.DataAccess namespace Bootstrap.DataAccess
{ {
/// <summary>
///
/// </summary>
public static class MenuHelper public static class MenuHelper
{ {
internal const string RetrieveMenusDataKey = "MenuHelper-RetrieveMenus"; internal const string RetrieveMenusDataKey = "MenuHelper-RetrieveMenus";
internal const string RetrieveMenusByRoleIDDataKey = "MenuHelper-RetrieveMenusByRoleId"; private const string RetrieveMenusByRoleIdDataKey = "MenuHelper-RetrieveMenusByRoleId";
/// <summary> /// <summary>
/// 查询所有菜单信息 /// 查询所有菜单信息
/// </summary> /// </summary>
@ -28,7 +31,7 @@ namespace Bootstrap.DataAccess
string key = string.Format("{0}-{1}", RetrieveMenusDataKey, userName); string key = string.Format("{0}-{1}", RetrieveMenusDataKey, userName);
return CacheManager.GetOrAdd(key, CacheSection.RetrieveIntervalByKey(RetrieveMenusDataKey), k => return CacheManager.GetOrAdd(key, CacheSection.RetrieveIntervalByKey(RetrieveMenusDataKey), k =>
{ {
List<Menu> Menus = new List<Menu>(); List<Menu> menus = new List<Menu>();
try try
{ {
using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.StoredProcedure, "Proc_RetrieveMenus")) using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.StoredProcedure, "Proc_RetrieveMenus"))
@ -38,9 +41,9 @@ namespace Bootstrap.DataAccess
{ {
while (reader.Read()) while (reader.Read())
{ {
Menus.Add(new Menu() menus.Add(new Menu()
{ {
ID = (int)reader[0], Id = (int)reader[0],
ParentId = (int)reader[1], ParentId = (int)reader[1],
Name = (string)reader[2], Name = (string)reader[2],
Order = (int)reader[3], Order = (int)reader[3],
@ -58,7 +61,7 @@ namespace Bootstrap.DataAccess
} }
} }
catch (Exception ex) { ExceptionManager.Publish(ex); } catch (Exception ex) { ExceptionManager.Publish(ex); }
return Menus; return menus;
}, CacheSection.RetrieveDescByKey(RetrieveMenusDataKey)); }, CacheSection.RetrieveDescByKey(RetrieveMenusDataKey));
} }
/// <summary> /// <summary>
@ -75,7 +78,7 @@ namespace Bootstrap.DataAccess
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
/// <param name="userId"></param> /// <param name="userName"></param>
/// <returns></returns> /// <returns></returns>
public static IEnumerable<Menu> RetrieveNavigationsByUserName(string userName) public static IEnumerable<Menu> RetrieveNavigationsByUserName(string userName)
{ {
@ -100,7 +103,7 @@ namespace Bootstrap.DataAccess
{ {
level.ToList().ForEach(m => level.ToList().ForEach(m =>
{ {
m.Menus = navs.Where(sub => sub.ParentId == m.ID).OrderBy(sub => sub.Order); m.Menus = navs.Where(sub => sub.ParentId == m.Id).OrderBy(sub => sub.Order);
CascadeMenu(navs, m.Menus); CascadeMenu(navs, m.Menus);
}); });
} }
@ -110,13 +113,13 @@ namespace Bootstrap.DataAccess
/// <param name="ids"></param> /// <param name="ids"></param>
public static bool DeleteMenu(string ids) public static bool DeleteMenu(string ids)
{ {
if (string.IsNullOrEmpty(ids) || ids.Contains("'")) return false;
bool ret = false; bool ret = false;
if (string.IsNullOrEmpty(ids) || ids.Contains("'")) return ret;
try try
{ {
using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.StoredProcedure, "Proc_DeleteMenus")) using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.StoredProcedure, "Proc_DeleteMenus"))
{ {
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@ids", ids, ParameterDirection.Input)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@ids", ids));
DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd); DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd);
} }
CacheCleanUtility.ClearCache(menuIds: ids); CacheCleanUtility.ClearCache(menuIds: ids);
@ -135,32 +138,31 @@ namespace Bootstrap.DataAccess
/// <returns></returns> /// <returns></returns>
public static bool SaveMenu(Menu p) public static bool SaveMenu(Menu p)
{ {
if (p == null) throw new ArgumentNullException("p"); if (string.IsNullOrEmpty(p.Name)) return false;
bool ret = false; bool ret = false;
if (string.IsNullOrEmpty(p.Name)) return ret; if (p.Name.Length > 50) p.Name = p.Name.Substring(0, 50);
if (p.Name.Length > 50) 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.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 > 50) p.Url.Substring(0, 50); string sql = p.Id == 0 ?
string sql = p.ID == 0 ?
"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";
try try
{ {
using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql)) using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql))
{ {
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@ID", p.ID, ParameterDirection.Input)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@ID", p.Id));
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@ParentId", p.ParentId, ParameterDirection.Input)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@ParentId", p.ParentId));
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@Name", p.Name, ParameterDirection.Input)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@Name", p.Name));
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@Order", p.Order, ParameterDirection.Input)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@Order", p.Order));
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@Icon", DBAccess.ToDBValue(p.Icon), ParameterDirection.Input)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@Icon", DBAccess.ToDBValue(p.Icon)));
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@Url", DBAccess.ToDBValue(p.Url), ParameterDirection.Input)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@Url", DBAccess.ToDBValue(p.Url)));
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@Category", p.Category, ParameterDirection.Input)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@Category", p.Category));
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@Target", p.Target, ParameterDirection.Input)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@Target", p.Target));
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@IsResource", p.IsResource, ParameterDirection.Input)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@IsResource", p.IsResource));
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@ApplicationCode", p.ApplicationCode, ParameterDirection.Input)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@ApplicationCode", p.ApplicationCode));
DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd); DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd);
} }
CacheCleanUtility.ClearCache(menuIds: p.ID == 0 ? string.Empty : p.ID.ToString()); CacheCleanUtility.ClearCache(menuIds: p.Id == 0 ? string.Empty : p.Id.ToString());
ret = true; ret = true;
} }
catch (DbException ex) catch (DbException ex)
@ -177,31 +179,31 @@ namespace Bootstrap.DataAccess
/// <returns></returns> /// <returns></returns>
public static IEnumerable<Menu> RetrieveMenusByRoleId(int roleId) public static IEnumerable<Menu> RetrieveMenusByRoleId(int roleId)
{ {
string key = string.Format("{0}-{1}", RetrieveMenusByRoleIDDataKey, roleId); string key = string.Format("{0}-{1}", RetrieveMenusByRoleIdDataKey, roleId);
return CacheManager.GetOrAdd(key, CacheSection.RetrieveIntervalByKey(RetrieveMenusByRoleIDDataKey), k => return CacheManager.GetOrAdd(key, CacheSection.RetrieveIntervalByKey(RetrieveMenusByRoleIdDataKey), k =>
{ {
List<Menu> Menus = new List<Menu>(); List<Menu> menus = new List<Menu>();
try try
{ {
string sql = "select NavigationID from NavigationRole where RoleID = @RoleID"; string sql = "select NavigationID from NavigationRole where RoleID = @RoleID";
using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql)) using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql))
{ {
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@RoleID", roleId, ParameterDirection.Input)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@RoleID", roleId));
using (DbDataReader reader = DBAccessManager.SqlDBAccess.ExecuteReader(cmd)) using (DbDataReader reader = DBAccessManager.SqlDBAccess.ExecuteReader(cmd))
{ {
while (reader.Read()) while (reader.Read())
{ {
Menus.Add(new Menu() menus.Add(new Menu()
{ {
ID = (int)reader[0] Id = (int)reader[0]
}); });
} }
} }
} }
} }
catch (Exception ex) { ExceptionManager.Publish(ex); } catch (Exception ex) { ExceptionManager.Publish(ex); }
return Menus; return menus;
}, CacheSection.RetrieveDescByKey(RetrieveMenusByRoleIDDataKey)); }, CacheSection.RetrieveDescByKey(RetrieveMenusByRoleIdDataKey));
} }
/// <summary> /// <summary>
/// 通过角色ID保存当前授权菜单 /// 通过角色ID保存当前授权菜单
@ -224,7 +226,7 @@ namespace Bootstrap.DataAccess
string sql = "delete from NavigationRole where RoleID=@RoleID"; string sql = "delete from NavigationRole where RoleID=@RoleID";
using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql)) using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql))
{ {
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@RoleID", id, ParameterDirection.Input)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@RoleID", id));
DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd, transaction); DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd, transaction);
//批插入菜单角色表 //批插入菜单角色表
using (SqlBulkCopy bulk = new SqlBulkCopy((SqlConnection)transaction.Transaction.Connection, SqlBulkCopyOptions.Default, (SqlTransaction)transaction.Transaction)) using (SqlBulkCopy bulk = new SqlBulkCopy((SqlConnection)transaction.Transaction.Connection, SqlBulkCopyOptions.Default, (SqlTransaction)transaction.Transaction))

View File

@ -6,16 +6,14 @@ using System.Text;
namespace Bootstrap.DataAccess namespace Bootstrap.DataAccess
{ {
/// <summary> /// <summary>
/// 消息表实体 ///
/// author:liuchun
/// date:2016.11.12
/// </summary> /// </summary>
public class Message public class Message
{ {
/// <summary> /// <summary>
/// 消息主键 数据库自增 /// 消息主键 数据库自增
/// </summary> /// </summary>
public int ID { get; set; } public int Id { get; set; }
/// <summary> /// <summary>
/// 标题 /// 标题
/// </summary> /// </summary>

View File

@ -13,16 +13,15 @@ namespace Bootstrap.DataAccess
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
public class MessageHelper public static class MessageHelper
{ {
internal const string RetrieveMessageDataKey = "MessageHelper-RetrieveMessages"; private const string RetrieveMessageDataKey = "MessageHelper-RetrieveMessages";
/// <summary> /// <summary>
/// 所有有关userName所有消息列表 /// 所有有关userName所有消息列表
/// </summary> /// </summary>
/// <param name="id"></param> /// <param name="userName"></param>
/// <returns></returns> /// <returns></returns>
public static IEnumerable<Message> RetrieveMessages(string userName) private static IEnumerable<Message> RetrieveMessages(string userName)
{ {
var messageRet = CacheManager.GetOrAdd(RetrieveMessageDataKey, CacheSection.RetrieveIntervalByKey(RetrieveMessageDataKey), key => var messageRet = CacheManager.GetOrAdd(RetrieveMessageDataKey, CacheSection.RetrieveIntervalByKey(RetrieveMessageDataKey), key =>
{ {
@ -31,14 +30,14 @@ namespace Bootstrap.DataAccess
DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql); DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql);
try try
{ {
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@UserName", userName, ParameterDirection.Input)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@UserName", userName));
using (DbDataReader reader = DBAccessManager.SqlDBAccess.ExecuteReader(cmd)) using (DbDataReader reader = DBAccessManager.SqlDBAccess.ExecuteReader(cmd))
{ {
while (reader.Read()) while (reader.Read())
{ {
messages.Add(new Message() messages.Add(new Message()
{ {
ID = (int)reader[0], Id = (int)reader[0],
Title = (string)reader[1], Title = (string)reader[1],
Content = (string)reader[2], Content = (string)reader[2],
From = (string)reader[3], From = (string)reader[3],
@ -64,7 +63,7 @@ namespace Bootstrap.DataAccess
/// <summary> /// <summary>
/// 收件箱 /// 收件箱
/// </summary> /// </summary>
/// <param name="id"></param> /// <param name="userName"></param>
public static IEnumerable<Message> Inbox(string userName) public static IEnumerable<Message> Inbox(string userName)
{ {
@ -74,7 +73,7 @@ namespace Bootstrap.DataAccess
/// <summary> /// <summary>
/// 发件箱 /// 发件箱
/// </summary> /// </summary>
/// <param name="id"></param> /// <param name="userName"></param>
/// <returns></returns> /// <returns></returns>
public static IEnumerable<Message> SendMail(string userName) public static IEnumerable<Message> SendMail(string userName)
{ {
@ -84,7 +83,7 @@ namespace Bootstrap.DataAccess
/// <summary> /// <summary>
/// 垃圾箱 /// 垃圾箱
/// </summary> /// </summary>
/// <param name="id"></param> /// <param name="userName"></param>
/// <returns></returns> /// <returns></returns>
public static IEnumerable<Message> Trash(string userName) public static IEnumerable<Message> Trash(string userName)
{ {
@ -94,7 +93,7 @@ namespace Bootstrap.DataAccess
/// <summary> /// <summary>
/// 标旗 /// 标旗
/// </summary> /// </summary>
/// <param name="id"></param> /// <param name="userName"></param>
/// <returns></returns> /// <returns></returns>
public static IEnumerable<Message> Mark(string userName) public static IEnumerable<Message> Mark(string userName)
{ {
@ -104,7 +103,7 @@ namespace Bootstrap.DataAccess
/// <summary> /// <summary>
/// 获取Header处显示的消息列表 /// 获取Header处显示的消息列表
/// </summary> /// </summary>
/// <param name="id"></param> /// <param name="userName"></param>
/// <returns></returns> /// <returns></returns>
public static IEnumerable<Message> RetrieveMessagesHeader(string userName) public static IEnumerable<Message> RetrieveMessagesHeader(string userName)
{ {

View File

@ -10,7 +10,7 @@ namespace Bootstrap.DataAccess
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
public int ID { get; set; } public int Id { get; set; }
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>

View File

@ -10,14 +10,15 @@ using System.Linq;
namespace Bootstrap.DataAccess namespace Bootstrap.DataAccess
{ {
public class NotificationHelper /// <summary>
///
/// </summary>
public static class NotificationHelper
{ {
// UNDOEN: 此处需要继续完善,增强异常的通知管理
internal const string RetrieveNotificationsDataKey = "NotificationHelper-RetrieveNotifications"; internal const string RetrieveNotificationsDataKey = "NotificationHelper-RetrieveNotifications";
/// <summary> /// <summary>
/// 新用户注册的通知的面板显示 /// 新用户注册的通知的面板显示
/// </summary> /// </summary>
/// <param name="id"></param>
/// <returns></returns> /// <returns></returns>
public static IEnumerable<Notification> RetrieveNotifications() public static IEnumerable<Notification> RetrieveNotifications()
{ {
@ -34,7 +35,7 @@ namespace Bootstrap.DataAccess
{ {
notifications.Add(new Notification() notifications.Add(new Notification()
{ {
ID = (int)reader[0], Id = (int)reader[0],
Category = (string)reader[1], Category = (string)reader[1],
Title = (string)reader[2], Title = (string)reader[2],
Content = (string)reader[3], Content = (string)reader[3],
@ -68,13 +69,13 @@ namespace Bootstrap.DataAccess
/// <returns></returns> /// <returns></returns>
public static bool ProcessRegisterUser(string id) public static bool ProcessRegisterUser(string id)
{ {
if (string.IsNullOrEmpty(id)) return false;
bool ret = false; bool ret = false;
if (string.IsNullOrEmpty(id)) return ret;
try try
{ {
using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.StoredProcedure, "Proc_ProcessRegisterUser")) using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.StoredProcedure, "Proc_ProcessRegisterUser"))
{ {
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@id", id, ParameterDirection.Input)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@id", id));
DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd); DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd);
} }
CacheCleanUtility.ClearCache(notifyIds: id); CacheCleanUtility.ClearCache(notifyIds: id);
@ -93,14 +94,14 @@ namespace Bootstrap.DataAccess
/// <returns></returns> /// <returns></returns>
public static bool SaveNotification(Notification noti) public static bool SaveNotification(Notification noti)
{ {
if (string.IsNullOrEmpty(noti.Title) || string.IsNullOrEmpty(noti.Content)) return false;
bool ret = false; bool ret = false;
if (string.IsNullOrEmpty(noti.Title) || string.IsNullOrEmpty(noti.Content)) return ret;
try try
{ {
using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, "Insert into Notifications (Category, Title, Content, RegisterTime) values (N'2', @Title, @Content, GetDate())")) using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, "Insert into Notifications (Category, Title, Content, RegisterTime) values (N'2', @Title, @Content, GetDate())"))
{ {
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@Title", noti.Title, ParameterDirection.Input)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@Title", noti.Title));
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@Content", noti.Content, ParameterDirection.Input)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@Content", noti.Content));
DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd); DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd);
} }
CacheCleanUtility.ClearCache(notifyIds: string.Empty); CacheCleanUtility.ClearCache(notifyIds: string.Empty);

View File

@ -1,11 +1,14 @@
namespace Bootstrap.DataAccess namespace Bootstrap.DataAccess
{ {
/// <summary>
///
/// </summary>
public class Role public class Role
{ {
/// <summary> /// <summary>
/// 获得/设置 角色主键ID /// 获得/设置 角色主键ID
/// </summary> /// </summary>
public int ID { get; set; } public int Id { get; set; }
/// <summary> /// <summary>
/// 获得/设置 角色名称 /// 获得/设置 角色名称
/// </summary> /// </summary>

View File

@ -17,9 +17,9 @@ namespace Bootstrap.DataAccess
public static class RoleHelper public static class RoleHelper
{ {
internal const string RetrieveRolesDataKey = "RoleHelper-RetrieveRoles"; internal const string RetrieveRolesDataKey = "RoleHelper-RetrieveRoles";
internal const string RetrieveRolesByUserIDDataKey = "RoleHelper-RetrieveRolesByUserId"; internal const string RetrieveRolesByUserIdDataKey = "RoleHelper-RetrieveRolesByUserId";
internal const string RetrieveRolesByMenuIDDataKey = "RoleHelper-RetrieveRolesByMenuId"; internal const string RetrieveRolesByMenuIdDataKey = "RoleHelper-RetrieveRolesByMenuId";
internal const string RetrieveRolesByGroupIDDataKey = "RoleHelper-RetrieveRolesByGroupId"; internal const string RetrieveRolesByGroupIdDataKey = "RoleHelper-RetrieveRolesByGroupId";
/// <summary> /// <summary>
/// 查询所有角色 /// 查询所有角色
/// </summary> /// </summary>
@ -40,7 +40,7 @@ namespace Bootstrap.DataAccess
{ {
roles.Add(new Role() roles.Add(new Role()
{ {
ID = (int)reader[0], Id = (int)reader[0],
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]
}); });
@ -50,7 +50,7 @@ namespace Bootstrap.DataAccess
catch (Exception ex) { ExceptionManager.Publish(ex); } catch (Exception ex) { ExceptionManager.Publish(ex); }
return roles; return roles;
}, CacheSection.RetrieveDescByKey(RetrieveRolesDataKey)); }, CacheSection.RetrieveDescByKey(RetrieveRolesDataKey));
return id == 0 ? ret : ret.Where(t => id == t.ID); return id == 0 ? ret : ret.Where(t => id == t.Id);
} }
/// <summary> /// <summary>
/// 保存用户角色关系 /// 保存用户角色关系
@ -74,7 +74,7 @@ namespace Bootstrap.DataAccess
string sql = "delete from UserRole where UserID = @UserID;"; string sql = "delete from UserRole where UserID = @UserID;";
using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql)) using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql))
{ {
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@UserID", id, ParameterDirection.Input)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@UserID", id));
DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd, transaction); DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd, transaction);
if (dt.Rows.Count > 0) if (dt.Rows.Count > 0)
{ {
@ -106,22 +106,22 @@ namespace Bootstrap.DataAccess
/// <returns></returns> /// <returns></returns>
public static IEnumerable<Role> RetrieveRolesByUserId(int userId) public static IEnumerable<Role> RetrieveRolesByUserId(int userId)
{ {
string key = string.Format("{0}-{1}", RetrieveRolesByUserIDDataKey, userId); string key = string.Format("{0}-{1}", RetrieveRolesByUserIdDataKey, userId);
return CacheManager.GetOrAdd(key, CacheSection.RetrieveIntervalByKey(RetrieveRolesByUserIDDataKey), k => return CacheManager.GetOrAdd(key, CacheSection.RetrieveIntervalByKey(RetrieveRolesByUserIdDataKey), k =>
{ {
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";
try try
{ {
DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql); DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql);
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@UserID", userId, ParameterDirection.Input)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@UserID", userId));
using (DbDataReader reader = DBAccessManager.SqlDBAccess.ExecuteReader(cmd)) using (DbDataReader reader = DBAccessManager.SqlDBAccess.ExecuteReader(cmd))
{ {
while (reader.Read()) while (reader.Read())
{ {
Roles.Add(new Role() roles.Add(new Role()
{ {
ID = (int)reader[0], Id = (int)reader[0],
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]
@ -130,22 +130,22 @@ namespace Bootstrap.DataAccess
} }
} }
catch (Exception ex) { ExceptionManager.Publish(ex); } catch (Exception ex) { ExceptionManager.Publish(ex); }
return Roles; return roles;
}, CacheSection.RetrieveDescByKey(RetrieveRolesByUserIDDataKey)); }, CacheSection.RetrieveDescByKey(RetrieveRolesByUserIdDataKey));
} }
/// <summary> /// <summary>
/// 删除角色表 /// 删除角色表
/// </summary> /// </summary>
/// <param name="IDs"></param> /// <param name="ids"></param>
public static bool DeleteRole(string ids) public static bool DeleteRole(string ids)
{ {
if (string.IsNullOrEmpty(ids) || ids.Contains("'")) return false;
bool ret = false; bool ret = false;
if (string.IsNullOrEmpty(ids) || ids.Contains("'")) return ret;
try try
{ {
using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.StoredProcedure, "Proc_DeleteRoles")) using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.StoredProcedure, "Proc_DeleteRoles"))
{ {
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@ids", ids, ParameterDirection.Input)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@ids", ids));
DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd); DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd);
} }
CacheCleanUtility.ClearCache(roleIds: ids); CacheCleanUtility.ClearCache(roleIds: ids);
@ -164,23 +164,22 @@ namespace Bootstrap.DataAccess
/// <returns></returns> /// <returns></returns>
public static bool SaveRole(Role p) public static bool SaveRole(Role p)
{ {
if (p == null) throw new ArgumentNullException("p");
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 = p.Id == 0 ?
"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";
try try
{ {
using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql)) using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql))
{ {
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@ID", p.ID, ParameterDirection.Input)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@ID", p.Id));
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@RoleName", p.RoleName, ParameterDirection.Input)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@RoleName", p.RoleName));
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@Description", DBAccess.ToDBValue(p.Description), ParameterDirection.Input)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@Description", DBAccess.ToDBValue(p.Description)));
DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd); DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd);
} }
CacheCleanUtility.ClearCache(roleIds: p.ID == 0 ? string.Empty : p.ID.ToString()); CacheCleanUtility.ClearCache(roleIds: p.Id == 0 ? string.Empty : p.Id.ToString());
ret = true; ret = true;
} }
catch (DbException ex) catch (DbException ex)
@ -196,22 +195,22 @@ namespace Bootstrap.DataAccess
/// <returns></returns> /// <returns></returns>
public static IEnumerable<Role> RetrieveRolesByMenuId(int menuId) public static IEnumerable<Role> RetrieveRolesByMenuId(int menuId)
{ {
string key = string.Format("{0}-{1}", RetrieveRolesByMenuIDDataKey, menuId); string key = string.Format("{0}-{1}", RetrieveRolesByMenuIdDataKey, menuId);
var ret = CacheManager.GetOrAdd(key, CacheSection.RetrieveIntervalByKey(RetrieveRolesByMenuIDDataKey), k => var ret = CacheManager.GetOrAdd(key, CacheSection.RetrieveIntervalByKey(RetrieveRolesByMenuIdDataKey), k =>
{ {
string sql = "select r.ID, r.RoleName, r.[Description], case ur.RoleID when r.ID then 'checked' else '' end [status] from Roles r left join NavigationRole ur on r.ID = ur.RoleID and NavigationID = @NavigationID"; 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>();
DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql); DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql);
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@NavigationID", menuId, ParameterDirection.Input)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@NavigationID", menuId));
try try
{ {
using (DbDataReader reader = DBAccessManager.SqlDBAccess.ExecuteReader(cmd)) using (DbDataReader reader = DBAccessManager.SqlDBAccess.ExecuteReader(cmd))
{ {
while (reader.Read()) while (reader.Read())
{ {
Roles.Add(new Role() roles.Add(new Role()
{ {
ID = (int)reader[0], Id = (int)reader[0],
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]
@ -220,8 +219,8 @@ namespace Bootstrap.DataAccess
} }
} }
catch (Exception ex) { ExceptionManager.Publish(ex); } catch (Exception ex) { ExceptionManager.Publish(ex); }
return Roles; return roles;
}, CacheSection.RetrieveDescByKey(RetrieveRolesByMenuIDDataKey)); }, CacheSection.RetrieveDescByKey(RetrieveRolesByMenuIdDataKey));
return ret; return ret;
} }
public static bool SavaRolesByMenuId(int id, string roleIds) public static bool SavaRolesByMenuId(int id, string roleIds)
@ -240,7 +239,7 @@ namespace Bootstrap.DataAccess
string sql = "delete from NavigationRole where NavigationID=@NavigationID;"; string sql = "delete from NavigationRole where NavigationID=@NavigationID;";
using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql)) using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql))
{ {
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@NavigationID", id, ParameterDirection.Input)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@NavigationID", id));
DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd, transaction); DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd, transaction);
// insert batch data into config table // insert batch data into config table
@ -267,27 +266,27 @@ namespace Bootstrap.DataAccess
} }
/// <summary> /// <summary>
/// 根据GroupId查询和该Group有关的所有Roles /// 根据GroupId查询和该Group有关的所有Roles
/// author:liuchun /// </summary>
/// <param name="tId"></param> /// <param name="groupId"></param>
/// <returns></returns> /// <returns></returns>
public static IEnumerable<Role> RetrieveRolesByGroupId(int groupID) public static IEnumerable<Role> RetrieveRolesByGroupId(int groupId)
{ {
string key = string.Format("{0}-{1}", RetrieveRolesByGroupIDDataKey, groupID); string key = string.Format("{0}-{1}", RetrieveRolesByGroupIdDataKey, groupId);
return CacheManager.GetOrAdd(key, CacheSection.RetrieveIntervalByKey(RetrieveRolesByGroupIDDataKey), k => return CacheManager.GetOrAdd(key, CacheSection.RetrieveIntervalByKey(RetrieveRolesByGroupIdDataKey), k =>
{ {
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";
DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql); DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql);
try try
{ {
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@GroupID", groupID, ParameterDirection.Input)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@GroupID", groupId));
using (DbDataReader reader = DBAccessManager.SqlDBAccess.ExecuteReader(cmd)) using (DbDataReader reader = DBAccessManager.SqlDBAccess.ExecuteReader(cmd))
{ {
while (reader.Read()) while (reader.Read())
{ {
Roles.Add(new Role() roles.Add(new Role()
{ {
ID = (int)reader[0], Id = (int)reader[0],
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]
@ -296,14 +295,15 @@ namespace Bootstrap.DataAccess
} }
} }
catch (Exception ex) { ExceptionManager.Publish(ex); } catch (Exception ex) { ExceptionManager.Publish(ex); }
return Roles; return roles;
}, CacheSection.RetrieveDescByKey(RetrieveRolesByGroupIDDataKey)); }, CacheSection.RetrieveDescByKey(RetrieveRolesByGroupIdDataKey));
} }
/// <summary> /// <summary>
/// 根据GroupId更新Roles信息删除旧的Roles信息插入新的Roles信息 /// 根据GroupId更新Roles信息删除旧的Roles信息插入新的Roles信息
/// </summary> /// </summary>
/// <param name="p"></param> /// <param name="id"></param>
/// <param name="roleIds"></param>
/// <returns></returns> /// <returns></returns>
public static bool SaveRolesByGroupId(int id, string roleIds) public static bool SaveRolesByGroupId(int id, string roleIds)
{ {
@ -321,7 +321,7 @@ namespace Bootstrap.DataAccess
string sql = "delete from RoleGroup where GroupID=@GroupID"; string sql = "delete from RoleGroup where GroupID=@GroupID";
using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql)) using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql))
{ {
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@GroupID", id, ParameterDirection.Input)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@GroupID", id));
DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd, transaction); DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd, transaction);
// insert batch data into config table // insert batch data into config table

View File

@ -7,7 +7,7 @@ namespace Bootstrap.DataAccess
/// <summary> /// <summary>
/// 获取/设置 任务ID /// 获取/设置 任务ID
/// </summary> /// </summary>
public int ID { get; set; } public int Id { get; set; }
/// <summary> /// <summary>
/// 获取/设置 任务名称 /// 获取/设置 任务名称
/// </summary> /// </summary>

View File

@ -10,7 +10,7 @@ namespace Bootstrap.DataAccess
{ {
public static class TaskHelper public static class TaskHelper
{ {
internal const string RetrieveTasksDataKey = "TaskHelper-RetrieveTasks"; private const string RetrieveTasksDataKey = "TaskHelper-RetrieveTasks";
/// <summary> /// <summary>
/// 查询所有任务 /// 查询所有任务
/// </summary> /// </summary>
@ -30,7 +30,7 @@ namespace Bootstrap.DataAccess
{ {
tasks.Add(new Task() tasks.Add(new Task()
{ {
ID = (int)reader[0], Id = (int)reader[0],
TaskName = (string)reader[1], TaskName = (string)reader[1],
AssignName = (string)reader[2], AssignName = (string)reader[2],
UserName = (string)reader[3], UserName = (string)reader[3],

View File

@ -10,7 +10,7 @@ namespace Bootstrap.DataAccess
/// <summary> /// <summary>
/// 获得/设置 用户主键ID /// 获得/设置 用户主键ID
/// </summary> /// </summary>
public int ID { get; set; } public int Id { get; set; }
/// <summary> /// <summary>
/// 获取/设置 密码 /// 获取/设置 密码
/// </summary> /// </summary>

View File

@ -22,8 +22,8 @@ namespace Bootstrap.DataAccess
{ {
internal const string RetrieveUsersDataKey = "UserHelper-RetrieveUsers"; internal const string RetrieveUsersDataKey = "UserHelper-RetrieveUsers";
private const string RetrieveUsersByNameDataKey = "UserHelper-RetrieveUsersByName"; private const string RetrieveUsersByNameDataKey = "UserHelper-RetrieveUsersByName";
internal const string RetrieveUsersByRoleIDDataKey = "UserHelper-RetrieveUsersByRoleId"; internal const string RetrieveUsersByRoleIdDataKey = "UserHelper-RetrieveUsersByRoleId";
internal const string RetrieveUsersByGroupIDDataKey = "UserHelper-RetrieveUsersByGroupId"; internal const string RetrieveUsersByGroupIdDataKey = "UserHelper-RetrieveUsersByGroupId";
internal const string RetrieveNewUsersDataKey = "UserHelper-RetrieveNewUsers"; internal const string RetrieveNewUsersDataKey = "UserHelper-RetrieveNewUsers";
/// <summary> /// <summary>
/// 查询所有用户 /// 查询所有用户
@ -35,7 +35,7 @@ namespace Bootstrap.DataAccess
string sql = "select ID, UserName, DisplayName, RegisterTime, ApprovedTime from Users Where ApprovedTime is not null"; string sql = "select ID, UserName, DisplayName, RegisterTime, ApprovedTime from Users Where ApprovedTime is not null";
var ret = CacheManager.GetOrAdd(RetrieveUsersDataKey, CacheSection.RetrieveIntervalByKey(RetrieveUsersDataKey), key => var ret = CacheManager.GetOrAdd(RetrieveUsersDataKey, CacheSection.RetrieveIntervalByKey(RetrieveUsersDataKey), key =>
{ {
List<User> Users = new List<User>(); List<User> users = new List<User>();
DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql); DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql);
try try
{ {
@ -43,9 +43,9 @@ namespace Bootstrap.DataAccess
{ {
while (reader.Read()) while (reader.Read())
{ {
Users.Add(new User() users.Add(new User()
{ {
ID = (int)reader[0], Id = (int)reader[0],
UserName = (string)reader[1], UserName = (string)reader[1],
DisplayName = (string)reader[2], DisplayName = (string)reader[2],
RegisterTime = (DateTime)reader[3], RegisterTime = (DateTime)reader[3],
@ -55,9 +55,9 @@ namespace Bootstrap.DataAccess
} }
} }
catch (Exception ex) { ExceptionManager.Publish(ex); } catch (Exception ex) { ExceptionManager.Publish(ex); }
return Users; return users;
}, CacheSection.RetrieveDescByKey(RetrieveUsersDataKey)); }, CacheSection.RetrieveDescByKey(RetrieveUsersDataKey));
return id == 0 ? ret : ret.Where(t => id == t.ID); return id == 0 ? ret : ret.Where(t => id == t.Id);
} }
/// <summary> /// <summary>
/// 根据用户名查询用户 /// 根据用户名查询用户
@ -75,14 +75,14 @@ namespace Bootstrap.DataAccess
DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql); DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql);
try try
{ {
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@UserName", userName, ParameterDirection.Input)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@UserName", userName));
using (DbDataReader reader = DBAccessManager.SqlDBAccess.ExecuteReader(cmd)) using (DbDataReader reader = DBAccessManager.SqlDBAccess.ExecuteReader(cmd))
{ {
if (reader.Read()) if (reader.Read())
{ {
user = new User() user = new User()
{ {
ID = (int)reader[0], Id = (int)reader[0],
UserName = (string)reader[1], UserName = (string)reader[1],
DisplayName = (string)reader[2], DisplayName = (string)reader[2],
RegisterTime = (DateTime)reader[3], RegisterTime = (DateTime)reader[3],
@ -105,7 +105,7 @@ namespace Bootstrap.DataAccess
return CacheManager.GetOrAdd(RetrieveNewUsersDataKey, CacheSection.RetrieveIntervalByKey(RetrieveNewUsersDataKey), key => return CacheManager.GetOrAdd(RetrieveNewUsersDataKey, CacheSection.RetrieveIntervalByKey(RetrieveNewUsersDataKey), key =>
{ {
string sql = "select ID, UserName, DisplayName, RegisterTime, [Description] from Users Where ApprovedTime is null and RejectedTime is null order by RegisterTime desc"; string sql = "select ID, UserName, DisplayName, RegisterTime, [Description] from Users Where ApprovedTime is null and RejectedTime is null order by RegisterTime desc";
List<User> Users = new List<User>(); List<User> users = new List<User>();
DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql); DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql);
try try
{ {
@ -113,9 +113,9 @@ namespace Bootstrap.DataAccess
{ {
while (reader.Read()) while (reader.Read())
{ {
Users.Add(new User() users.Add(new User()
{ {
ID = (int)reader[0], Id = (int)reader[0],
UserName = (string)reader[1], UserName = (string)reader[1],
DisplayName = (string)reader[2], DisplayName = (string)reader[2],
RegisterTime = (DateTime)reader[3], RegisterTime = (DateTime)reader[3],
@ -125,7 +125,7 @@ namespace Bootstrap.DataAccess
} }
} }
catch (Exception ex) { ExceptionManager.Publish(ex); } catch (Exception ex) { ExceptionManager.Publish(ex); }
return Users; return users;
}, CacheSection.RetrieveDescByKey(RetrieveNewUsersDataKey)); }, CacheSection.RetrieveDescByKey(RetrieveNewUsersDataKey));
} }
/// <summary> /// <summary>
@ -134,13 +134,13 @@ namespace Bootstrap.DataAccess
/// <param name="ids"></param> /// <param name="ids"></param>
public static bool DeleteUser(string ids) public static bool DeleteUser(string ids)
{ {
if (string.IsNullOrEmpty(ids) || ids.Contains("'")) return false;
bool ret = false; bool ret = false;
if (string.IsNullOrEmpty(ids) || ids.Contains("'")) return ret;
try try
{ {
using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.StoredProcedure, "Proc_DeleteUsers")) using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.StoredProcedure, "Proc_DeleteUsers"))
{ {
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@ids", ids, ParameterDirection.Input)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@ids", ids));
DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd); DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd);
} }
CacheCleanUtility.ClearCache(userIds: ids); CacheCleanUtility.ClearCache(userIds: ids);
@ -159,10 +159,10 @@ namespace Bootstrap.DataAccess
/// <returns></returns> /// <returns></returns>
public static bool SaveUser(User p) public static bool SaveUser(User p)
{ {
if (p.ID == 0 && p.Description.Length > 500) p.Description.Substring(0, 500); if (p.Id == 0 && p.Description.Length > 500) p.Description = p.Description.Substring(0, 500);
if (p.UserStatus != 2) if (p.UserStatus != 2)
{ {
if (p.UserName.Length > 50) 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);
} }
@ -171,19 +171,19 @@ namespace Bootstrap.DataAccess
{ {
using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.StoredProcedure, "Proc_SaveUsers")) using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.StoredProcedure, "Proc_SaveUsers"))
{ {
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@id", p.ID, ParameterDirection.Input)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@id", p.Id));
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@userName", DBAccess.ToDBValue(p.UserName), ParameterDirection.Input)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@userName", DBAccess.ToDBValue(p.UserName)));
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@password", DBAccess.ToDBValue(p.Password), ParameterDirection.Input)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@password", DBAccess.ToDBValue(p.Password)));
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@passSalt", DBAccess.ToDBValue(p.PassSalt), ParameterDirection.Input)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@passSalt", DBAccess.ToDBValue(p.PassSalt)));
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@displayName", DBAccess.ToDBValue(p.DisplayName), ParameterDirection.Input)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@displayName", DBAccess.ToDBValue(p.DisplayName)));
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@description", DBAccess.ToDBValue(p.Description), ParameterDirection.Input)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@description", DBAccess.ToDBValue(p.Description)));
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@approvedBy", DBAccess.ToDBValue(p.ApprovedBy), ParameterDirection.Input)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@approvedBy", DBAccess.ToDBValue(p.ApprovedBy)));
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@rejectedBy", DBAccess.ToDBValue(p.RejectedBy), ParameterDirection.Input)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@rejectedBy", DBAccess.ToDBValue(p.RejectedBy)));
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@rejectedReason", DBAccess.ToDBValue(p.RejectedReason), ParameterDirection.Input)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@rejectedReason", DBAccess.ToDBValue(p.RejectedReason)));
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@userStatus", p.UserStatus, ParameterDirection.Input)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@userStatus", p.UserStatus));
DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd); DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd);
} }
CacheCleanUtility.ClearCache(userIds: p.ID == 0 ? string.Empty : p.ID.ToString()); CacheCleanUtility.ClearCache(userIds: p.Id == 0 ? string.Empty : p.Id.ToString());
ret = true; ret = true;
} }
catch (DbException ex) catch (DbException ex)
@ -199,22 +199,22 @@ namespace Bootstrap.DataAccess
/// <returns></returns> /// <returns></returns>
public static IEnumerable<User> RetrieveUsersByRoleId(int roleId) public static IEnumerable<User> RetrieveUsersByRoleId(int roleId)
{ {
string key = string.Format("{0}-{1}", RetrieveUsersByRoleIDDataKey, roleId); string key = string.Format("{0}-{1}", RetrieveUsersByRoleIdDataKey, roleId);
return CacheManager.GetOrAdd(key, CacheSection.RetrieveIntervalByKey(RetrieveUsersByNameDataKey), k => return CacheManager.GetOrAdd(key, CacheSection.RetrieveIntervalByKey(RetrieveUsersByNameDataKey), k =>
{ {
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";
DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql); DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql);
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@RoleID", roleId, ParameterDirection.Input)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@RoleID", roleId));
try try
{ {
using (DbDataReader reader = DBAccessManager.SqlDBAccess.ExecuteReader(cmd)) using (DbDataReader reader = DBAccessManager.SqlDBAccess.ExecuteReader(cmd))
{ {
while (reader.Read()) while (reader.Read())
{ {
Users.Add(new User() users.Add(new User()
{ {
ID = (int)reader[0], Id = (int)reader[0],
UserName = (string)reader[1], UserName = (string)reader[1],
DisplayName = (string)reader[2], DisplayName = (string)reader[2],
Checked = (string)reader[3] Checked = (string)reader[3]
@ -223,14 +223,14 @@ namespace Bootstrap.DataAccess
} }
} }
catch (Exception ex) { ExceptionManager.Publish(ex); } catch (Exception ex) { ExceptionManager.Publish(ex); }
return Users; return users;
}, CacheSection.RetrieveDescByKey(RetrieveUsersByRoleIDDataKey)); }, CacheSection.RetrieveDescByKey(RetrieveUsersByRoleIdDataKey));
} }
/// <summary> /// <summary>
/// 通过角色ID保存当前授权用户插入 /// 通过角色ID保存当前授权用户插入
/// </summary> /// </summary>
/// <param name="id">角色ID</param> /// <param name="id">角色ID</param>
/// <param name="value">用户ID数组</param> /// <param name="userIds">用户ID数组</param>
/// <returns></returns> /// <returns></returns>
public static bool SaveUsersByRoleId(int id, string userIds) public static bool SaveUsersByRoleId(int id, string userIds)
{ {
@ -247,7 +247,7 @@ namespace Bootstrap.DataAccess
string sql = "delete from UserRole where RoleID=@RoleID"; string sql = "delete from UserRole where RoleID=@RoleID";
using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql)) using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql))
{ {
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@RoleID", id, ParameterDirection.Input)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@RoleID", id));
DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd, transaction); DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd, transaction);
//批插入用户角色表 //批插入用户角色表
using (SqlBulkCopy bulk = new SqlBulkCopy((SqlConnection)transaction.Transaction.Connection, SqlBulkCopyOptions.Default, (SqlTransaction)transaction.Transaction)) using (SqlBulkCopy bulk = new SqlBulkCopy((SqlConnection)transaction.Transaction.Connection, SqlBulkCopyOptions.Default, (SqlTransaction)transaction.Transaction))
@ -273,26 +273,26 @@ namespace Bootstrap.DataAccess
/// <summary> /// <summary>
/// 通过groupId获取所有用户 /// 通过groupId获取所有用户
/// </summary> /// </summary>
/// <param name="roleId"></param> /// <param name="groupId"></param>
/// <returns></returns> /// <returns></returns>
public static IEnumerable<User> RetrieveUsersByGroupId(int groupId) public static IEnumerable<User> RetrieveUsersByGroupId(int groupId)
{ {
string key = string.Format("{0}-{1}", RetrieveUsersByGroupIDDataKey, groupId); string key = string.Format("{0}-{1}", RetrieveUsersByGroupIdDataKey, groupId);
return CacheManager.GetOrAdd(key, CacheSection.RetrieveIntervalByKey(RetrieveUsersByGroupIDDataKey), k => return CacheManager.GetOrAdd(key, CacheSection.RetrieveIntervalByKey(RetrieveUsersByGroupIdDataKey), k =>
{ {
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";
DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql); DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql);
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@GroupID", groupId, ParameterDirection.Input)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@GroupID", groupId));
try try
{ {
using (DbDataReader reader = DBAccessManager.SqlDBAccess.ExecuteReader(cmd)) using (DbDataReader reader = DBAccessManager.SqlDBAccess.ExecuteReader(cmd))
{ {
while (reader.Read()) while (reader.Read())
{ {
Users.Add(new User() users.Add(new User()
{ {
ID = (int)reader[0], Id = (int)reader[0],
UserName = (string)reader[1], UserName = (string)reader[1],
DisplayName = (string)reader[2], DisplayName = (string)reader[2],
Checked = (string)reader[3] Checked = (string)reader[3]
@ -301,14 +301,14 @@ namespace Bootstrap.DataAccess
} }
} }
catch (Exception ex) { ExceptionManager.Publish(ex); } catch (Exception ex) { ExceptionManager.Publish(ex); }
return Users; return users;
}, CacheSection.RetrieveDescByKey(RetrieveUsersByRoleIDDataKey)); }, CacheSection.RetrieveDescByKey(RetrieveUsersByRoleIdDataKey));
} }
/// <summary> /// <summary>
/// 通过部门ID保存当前授权用户插入 /// 通过部门ID保存当前授权用户插入
/// </summary> /// </summary>
/// <param name="id">GroupID</param> /// <param name="id">GroupID</param>
/// <param name="value">用户ID数组</param> /// <param name="userIds">用户ID数组</param>
/// <returns></returns> /// <returns></returns>
public static bool SaveUsersByGroupId(int id, string userIds) public static bool SaveUsersByGroupId(int id, string userIds)
{ {
@ -325,7 +325,7 @@ namespace Bootstrap.DataAccess
string sql = "delete from UserGroup where GroupID = @GroupID"; string sql = "delete from UserGroup where GroupID = @GroupID";
using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql)) using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql))
{ {
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@GroupID", id, ParameterDirection.Input)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@GroupID", id));
DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd, transaction); DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd, transaction);
//批插入用户角色表 //批插入用户角色表
using (SqlBulkCopy bulk = new SqlBulkCopy((SqlConnection)transaction.Transaction.Connection, SqlBulkCopyOptions.Default, (SqlTransaction)transaction.Transaction)) using (SqlBulkCopy bulk = new SqlBulkCopy((SqlConnection)transaction.Transaction.Connection, SqlBulkCopyOptions.Default, (SqlTransaction)transaction.Transaction))
@ -362,8 +362,8 @@ namespace Bootstrap.DataAccess
string sql = "Update Users set Icon = @iconName where UserName = @userName"; string sql = "Update Users set Icon = @iconName where UserName = @userName";
using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql)) using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql))
{ {
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@iconName", iconName, ParameterDirection.Input)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@iconName", iconName));
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@userName", userName, ParameterDirection.Input)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@userName", userName));
DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd); DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd);
string key = string.Format("{0}-{1}", RetrieveUsersByNameDataKey, userName); string key = string.Format("{0}-{1}", RetrieveUsersByNameDataKey, userName);
CacheManager.Clear(k => key == k); CacheManager.Clear(k => key == k);
@ -389,8 +389,8 @@ namespace Bootstrap.DataAccess
string sql = "Update Users set DisplayName = @DisplayName where UserName = @userName"; string sql = "Update Users set DisplayName = @DisplayName where UserName = @userName";
using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql)) using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql))
{ {
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@DisplayName", user.DisplayName, ParameterDirection.Input)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@DisplayName", user.DisplayName));
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@userName", user.UserName, ParameterDirection.Input)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@userName", user.UserName));
DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd); DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd);
CacheCleanUtility.ClearCache(userIds: string.Empty); CacheCleanUtility.ClearCache(userIds: string.Empty);
ret = true; ret = true;
@ -419,9 +419,9 @@ namespace Bootstrap.DataAccess
user.NewPassword = LgbCryptography.ComputeHash(user.NewPassword, user.PassSalt); user.NewPassword = LgbCryptography.ComputeHash(user.NewPassword, user.PassSalt);
using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql)) using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql))
{ {
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@Password", user.NewPassword, ParameterDirection.Input)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@Password", user.NewPassword));
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@PassSalt", user.PassSalt, ParameterDirection.Input)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@PassSalt", user.PassSalt));
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@userName", user.UserName, ParameterDirection.Input)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@userName", user.UserName));
DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd); DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd);
string key = string.Format("{0}-{1}", RetrieveUsersByNameDataKey, user.UserName); string key = string.Format("{0}-{1}", RetrieveUsersByNameDataKey, user.UserName);
CacheManager.Clear(k => k == key); CacheManager.Clear(k => k == key);

View File

@ -43,10 +43,10 @@ namespace Bootstrap.DataAccess.Tests
// 测试更新字典记录方法 ID != 0 // 测试更新字典记录方法 ID != 0
var dict = dicts.FirstOrDefault(d => d.Category == Dict.Category); var dict = dicts.FirstOrDefault(d => d.Category == Dict.Category);
dict.Name = "__测试子字典2__"; dict.Name = "__测试子字典2__";
Assert.IsTrue(DictHelper.SaveDict(dict), string.Format("更新字典记录ID = {0} 操作失败,请检查 DictHelper.SaveDict 方法", dict.ID)); Assert.IsTrue(DictHelper.SaveDict(dict), string.Format("更新字典记录ID = {0} 操作失败,请检查 DictHelper.SaveDict 方法", dict.Id));
var dest = DictHelper.RetrieveDicts().Where(d => d.ID == dict.ID); var dest = DictHelper.RetrieveDicts().Where(d => d.Id == dict.Id);
Assert.IsTrue(dest.Count() == 1, "带参数的DictHelper.RetrieveDicts方法调用失败"); Assert.IsTrue(dest.Count() == 1, "带参数的DictHelper.RetrieveDicts方法调用失败");
Assert.AreEqual(dict.Name, dest.First().Name, string.Format("更新字典记录ID = {0} 操作失败,请检查 DictHelper.SaveDict 方法", dict.ID)); Assert.AreEqual(dict.Name, dest.First().Name, string.Format("更新字典记录ID = {0} 操作失败,请检查 DictHelper.SaveDict 方法", dict.Id));
} }
[TestMethod] [TestMethod]
@ -56,7 +56,7 @@ namespace Bootstrap.DataAccess.Tests
var dict = DictHelper.RetrieveDicts().FirstOrDefault(d => d.Category == Dict.Category); var dict = DictHelper.RetrieveDicts().FirstOrDefault(d => d.Category == Dict.Category);
if (dict == null) DictHelper.SaveDict(Dict); if (dict == null) DictHelper.SaveDict(Dict);
dict = DictHelper.RetrieveDicts().FirstOrDefault(d => d.Category == Dict.Category); dict = DictHelper.RetrieveDicts().FirstOrDefault(d => d.Category == Dict.Category);
Assert.IsTrue(DictHelper.DeleteDict(dict.ID.ToString()), "DictHelper.DeleteDict 方法调用失败"); Assert.IsTrue(DictHelper.DeleteDict(dict.Id.ToString()), "DictHelper.DeleteDict 方法调用失败");
} }
} }
} }

View File

@ -47,10 +47,10 @@ namespace Bootstrap.DataAccess.Tests
//测试更新部门方法 ID!=0 //测试更新部门方法 ID!=0
var group = groups.FirstOrDefault(g => g.GroupName == Group.GroupName); var group = groups.FirstOrDefault(g => g.GroupName == Group.GroupName);
group.Description = "我是测试部门"; group.Description = "我是测试部门";
Assert.IsTrue(GroupHelper.SaveGroup(group), string.Format("更新部门ID={0}操作失败请检查GroupHelper.SaveGroup方法", group.ID)); Assert.IsTrue(GroupHelper.SaveGroup(group), string.Format("更新部门ID={0}操作失败请检查GroupHelper.SaveGroup方法", group.Id));
var ret = GroupHelper.RetrieveGroups(group.ID); var ret = GroupHelper.RetrieveGroups(group.Id);
Assert.IsTrue(ret.Count() == 1, "带参数的GroupHelper.RetrieveGroups方法失败"); Assert.IsTrue(ret.Count() == 1, "带参数的GroupHelper.RetrieveGroups方法失败");
Assert.AreEqual(group.Description, ret.First().Description, string.Format("更新部门ID={0}操作失败请检查GroupHelper.SaveGroup方法", group.ID)); Assert.AreEqual(group.Description, ret.First().Description, string.Format("更新部门ID={0}操作失败请检查GroupHelper.SaveGroup方法", group.Id));
} }
[TestMethod] [TestMethod]
@ -60,7 +60,7 @@ namespace Bootstrap.DataAccess.Tests
var group = GroupHelper.RetrieveGroups().FirstOrDefault(g => g.GroupName == Group.GroupName); var group = GroupHelper.RetrieveGroups().FirstOrDefault(g => g.GroupName == Group.GroupName);
if (group == null) GroupHelper.SaveGroup(Group); if (group == null) GroupHelper.SaveGroup(Group);
group = GroupHelper.RetrieveGroups().FirstOrDefault(g => g.GroupName == Group.GroupName); group = GroupHelper.RetrieveGroups().FirstOrDefault(g => g.GroupName == Group.GroupName);
Assert.IsTrue(GroupHelper.DeleteGroup(group.ID.ToString()), "GroupHelper.DeleteGroup 方法调用失败"); Assert.IsTrue(GroupHelper.DeleteGroup(group.Id.ToString()), "GroupHelper.DeleteGroup 方法调用失败");
} }
[TestMethod] [TestMethod]
@ -73,14 +73,14 @@ namespace Bootstrap.DataAccess.Tests
if (group == null) GroupHelper.SaveGroup(Group); if (group == null) GroupHelper.SaveGroup(Group);
group = GroupHelper.RetrieveGroups().FirstOrDefault(g => g.GroupName == Group.GroupName); group = GroupHelper.RetrieveGroups().FirstOrDefault(g => g.GroupName == Group.GroupName);
Assert.IsTrue(GroupHelper.SaveGroupsByUserId(user.ID, group.ID.ToString()), "存储用户部门信息失败"); Assert.IsTrue(GroupHelper.SaveGroupsByUserId(user.Id, group.Id.ToString()), "存储用户部门信息失败");
Assert.IsTrue(GroupHelper.RetrieveGroupsByUserId(user.ID).Count() >= 1, string.Format("获取用户ID={0}的部门失败", user.ID)); Assert.IsTrue(GroupHelper.RetrieveGroupsByUserId(user.Id).Count() >= 1, string.Format("获取用户ID={0}的部门失败", user.Id));
//删除数据 //删除数据
string sql = "Delete from Users where UserName = '_测试用户_';"; string sql = "Delete from Users where UserName = '_测试用户_';";
sql += "Delete from Groups where GroupName='_测试部门_';"; sql += "Delete from Groups where GroupName='_测试部门_';";
sql += string.Format("Delete from UserGroup where UserID={0};", user.ID); sql += string.Format("Delete from UserGroup where UserID={0};", user.Id);
using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql)) using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql))
{ {
DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd); DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd);
@ -97,14 +97,14 @@ namespace Bootstrap.DataAccess.Tests
if (role == null) RoleHelper.SaveRole(Role); if (role == null) RoleHelper.SaveRole(Role);
role = RoleHelper.RetrieveRoles().FirstOrDefault(r => r.RoleName == Role.RoleName); role = RoleHelper.RetrieveRoles().FirstOrDefault(r => r.RoleName == Role.RoleName);
Assert.IsTrue(GroupHelper.SaveGroupsByRoleId(role.ID, group.ID.ToString()), "存储角色部门信息失败"); Assert.IsTrue(GroupHelper.SaveGroupsByRoleId(role.Id, group.Id.ToString()), "存储角色部门信息失败");
Assert.IsTrue(GroupHelper.RetrieveGroupsByRoleId(role.ID).Count() >= 1, string.Format("获取角色ID={0}的部门信息失败", role.ID)); Assert.IsTrue(GroupHelper.RetrieveGroupsByRoleId(role.Id).Count() >= 1, string.Format("获取角色ID={0}的部门信息失败", role.Id));
//删除数据 //删除数据
string sql = "Delete from Groups where GroupName = '_测试部门_';"; string sql = "Delete from Groups where GroupName = '_测试部门_';";
sql += "Delete from Roles where RoleName='_测试角色_';"; sql += "Delete from Roles where RoleName='_测试角色_';";
sql += string.Format("Delete from RoleGroup where RoleID={0};", role.ID); sql += string.Format("Delete from RoleGroup where RoleID={0};", role.Id);
using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql)) using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql))
{ {
DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd); DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd);

View File

@ -41,7 +41,7 @@ namespace Bootstrap.DataAccess.Tests
var log = LogHelper.RetrieveLogs().FirstOrDefault(l => l.UserName == Log.UserName); var log = LogHelper.RetrieveLogs().FirstOrDefault(l => l.UserName == Log.UserName);
if (log == null) LogHelper.SaveLog(Log); if (log == null) LogHelper.SaveLog(Log);
log = LogHelper.RetrieveLogs().FirstOrDefault(l => l.UserName == Log.UserName); log = LogHelper.RetrieveLogs().FirstOrDefault(l => l.UserName == Log.UserName);
Assert.IsTrue(LogHelper.DeleteLog(log.ID.ToString()), "删除日志信息出错"); Assert.IsTrue(LogHelper.DeleteLog(log.Id.ToString()), "删除日志信息出错");
} }
} }
} }

View File

@ -49,7 +49,7 @@ namespace Bootstrap.DataAccess.Tests
// 测试更新菜单方法 ID != 0 // 测试更新菜单方法 ID != 0
var menu = menus.FirstOrDefault(m => m.Name == Menu.Name); var menu = menus.FirstOrDefault(m => m.Name == Menu.Name);
menu.Icon = "fa"; menu.Icon = "fa";
Assert.IsTrue(MenuHelper.SaveMenu(menu), string.Format("更新菜单ID = {0} 操作失败,请检查 MenuHelper.SaveMenu 方法", menu.ID)); Assert.IsTrue(MenuHelper.SaveMenu(menu), string.Format("更新菜单ID = {0} 操作失败,请检查 MenuHelper.SaveMenu 方法", menu.Id));
} }
[TestMethod] [TestMethod]
@ -59,7 +59,7 @@ namespace Bootstrap.DataAccess.Tests
var menu = MenuHelper.RetrieveMenus().FirstOrDefault(m => m.Name == Menu.Name); var menu = MenuHelper.RetrieveMenus().FirstOrDefault(m => m.Name == Menu.Name);
if (menu == null) MenuHelper.SaveMenu(Menu); if (menu == null) MenuHelper.SaveMenu(Menu);
menu = MenuHelper.RetrieveMenus().FirstOrDefault(m => m.Name == Menu.Name); menu = MenuHelper.RetrieveMenus().FirstOrDefault(m => m.Name == Menu.Name);
Assert.IsTrue(MenuHelper.DeleteMenu(menu.ID.ToString()), "MenuHelper.DeleteMenu 方法调用失败"); Assert.IsTrue(MenuHelper.DeleteMenu(menu.Id.ToString()), "MenuHelper.DeleteMenu 方法调用失败");
} }
[TestMethod] [TestMethod]
@ -73,13 +73,13 @@ namespace Bootstrap.DataAccess.Tests
if (role == null) RoleHelper.SaveRole(Role); if (role == null) RoleHelper.SaveRole(Role);
role = RoleHelper.RetrieveRoles().FirstOrDefault(m => m.RoleName == Role.RoleName); role = RoleHelper.RetrieveRoles().FirstOrDefault(m => m.RoleName == Role.RoleName);
Assert.IsTrue(RoleHelper.SavaRolesByMenuId(menu.ID, role.ID.ToString()), "保存菜单角色关系失败"); Assert.IsTrue(RoleHelper.SavaRolesByMenuId(menu.Id, role.Id.ToString()), "保存菜单角色关系失败");
Assert.IsTrue(RoleHelper.RetrieveRolesByMenuId(menu.ID).Count() > 0, string.Format("获取菜单ID={0}的角色关系失败", menu.ID)); Assert.IsTrue(RoleHelper.RetrieveRolesByMenuId(menu.Id).Count() > 0, string.Format("获取菜单ID={0}的角色关系失败", menu.Id));
//删除数据 //删除数据
string sql = "delete from Navigations where Name='__测试菜单__';"; string sql = "delete from Navigations where Name='__测试菜单__';";
sql += "delete from Roles where RoleName='_测试角色_';"; sql += "delete from Roles where RoleName='_测试角色_';";
sql += string.Format("delete from NavigationRole where NavigationID={0}", menu.ID); sql += string.Format("delete from NavigationRole where NavigationID={0}", menu.Id);
using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql)) using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql))
{ {
DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd); DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd);
@ -95,14 +95,14 @@ namespace Bootstrap.DataAccess.Tests
if (role == null) RoleHelper.SaveRole(Role); if (role == null) RoleHelper.SaveRole(Role);
role = RoleHelper.RetrieveRoles().FirstOrDefault(r => r.RoleName == Role.RoleName); role = RoleHelper.RetrieveRoles().FirstOrDefault(r => r.RoleName == Role.RoleName);
Assert.IsTrue(MenuHelper.SaveMenusByRoleId(role.ID, menu.ID.ToString()), "存储角色菜单信息失败"); Assert.IsTrue(MenuHelper.SaveMenusByRoleId(role.Id, menu.Id.ToString()), "存储角色菜单信息失败");
int x = MenuHelper.RetrieveMenusByRoleId(role.ID).Count(); int x = MenuHelper.RetrieveMenusByRoleId(role.Id).Count();
Assert.IsTrue(x >= 1, string.Format("获取角色ID={0}的菜单信息失败", role.ID)); Assert.IsTrue(x >= 1, string.Format("获取角色ID={0}的菜单信息失败", role.Id));
//删除数据 //删除数据
string sql = "Delete from Navigations where Name = '__测试菜单__';"; string sql = "Delete from Navigations where Name = '__测试菜单__';";
sql += "Delete from Roles where RoleName='_测试角色_';"; sql += "Delete from Roles where RoleName='_测试角色_';";
sql += string.Format("Delete from NavigationRole where RoleID={0};", role.ID); sql += string.Format("Delete from NavigationRole where RoleID={0};", role.Id);
using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql)) using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql))
{ {
DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd); DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd);

View File

@ -37,10 +37,10 @@ namespace Bootstrap.DataAccess.Tests
//测试编辑角色方法 ID != 0 //测试编辑角色方法 ID != 0
var role = roles.FirstOrDefault(m => m.RoleName == Role.RoleName); var role = roles.FirstOrDefault(m => m.RoleName == Role.RoleName);
role.Description = "这是修改后的测试角色"; role.Description = "这是修改后的测试角色";
Assert.IsTrue(RoleHelper.SaveRole(role), string.Format("更新角色ID={0}操作失败请检查RoleHelper.SaveRole方法", role.ID)); Assert.IsTrue(RoleHelper.SaveRole(role), string.Format("更新角色ID={0}操作失败请检查RoleHelper.SaveRole方法", role.Id));
var ret = RoleHelper.RetrieveRoles(role.ID); var ret = RoleHelper.RetrieveRoles(role.Id);
Assert.IsTrue(ret.Count() == 1, "带参数的RoleHelper.RetrieveRoles方法调用失败"); Assert.IsTrue(ret.Count() == 1, "带参数的RoleHelper.RetrieveRoles方法调用失败");
Assert.AreEqual(role.Description, ret.First().Description, string.Format("更新角色ID={0}操作失败请检查RoleHelper.SaveRole方法", role.ID)); Assert.AreEqual(role.Description, ret.First().Description, string.Format("更新角色ID={0}操作失败请检查RoleHelper.SaveRole方法", role.Id));
} }
[TestMethod] [TestMethod]
public void RetrieveRoleTest() public void RetrieveRoleTest()
@ -55,7 +55,7 @@ namespace Bootstrap.DataAccess.Tests
var role = RoleHelper.RetrieveRoles().FirstOrDefault(r => r.RoleName == "_测试角色_"); var role = RoleHelper.RetrieveRoles().FirstOrDefault(r => r.RoleName == "_测试角色_");
if (role == null) RoleHelper.SaveRole(Role); if (role == null) RoleHelper.SaveRole(Role);
role = RoleHelper.RetrieveRoles().FirstOrDefault(r => r.RoleName == "_测试角色_"); role = RoleHelper.RetrieveRoles().FirstOrDefault(r => r.RoleName == "_测试角色_");
Assert.IsTrue(RoleHelper.DeleteRole(role.ID.ToString()), "删除角色失败"); Assert.IsTrue(RoleHelper.DeleteRole(role.Id.ToString()), "删除角色失败");
} }
[TestMethod] [TestMethod]
public void SaveRolesByUserIdTest() public void SaveRolesByUserIdTest()
@ -68,12 +68,12 @@ namespace Bootstrap.DataAccess.Tests
if (user == null) UserHelper.SaveUser(User); if (user == null) UserHelper.SaveUser(User);
user = UserHelper.RetrieveUsers().FirstOrDefault(m => m.DisplayName == User.DisplayName); user = UserHelper.RetrieveUsers().FirstOrDefault(m => m.DisplayName == User.DisplayName);
Assert.IsTrue(RoleHelper.SaveRolesByUserId(user.ID, role.ID.ToString()), "保存用户角色关系失败"); Assert.IsTrue(RoleHelper.SaveRolesByUserId(user.Id, role.Id.ToString()), "保存用户角色关系失败");
Assert.IsTrue(RoleHelper.RetrieveRolesByUserId(user.ID).Count() >= 1, string.Format("获取用户ID={0}的角色信息失败", user.ID)); Assert.IsTrue(RoleHelper.RetrieveRolesByUserId(user.Id).Count() >= 1, string.Format("获取用户ID={0}的角色信息失败", user.Id));
//删除数据 //删除数据
string sql = "delete from Roles where RoleName='_测试角色_';"; string sql = "delete from Roles where RoleName='_测试角色_';";
sql += "delete from Users where UserName='_测试用户_';"; sql += "delete from Users where UserName='_测试用户_';";
sql += string.Format("delete from UserRole where UserID={0}", user.ID); sql += string.Format("delete from UserRole where UserID={0}", user.Id);
using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql)) using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql))
{ {
DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd); DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd);
@ -90,12 +90,12 @@ namespace Bootstrap.DataAccess.Tests
if (group == null) GroupHelper.SaveGroup(Group); if (group == null) GroupHelper.SaveGroup(Group);
group = GroupHelper.RetrieveGroups().FirstOrDefault(m => m.GroupName == Group.GroupName); group = GroupHelper.RetrieveGroups().FirstOrDefault(m => m.GroupName == Group.GroupName);
Assert.IsTrue(RoleHelper.SaveRolesByGroupId(group.ID, role.ID.ToString()), "保存部门角色关系失败"); Assert.IsTrue(RoleHelper.SaveRolesByGroupId(group.Id, role.Id.ToString()), "保存部门角色关系失败");
Assert.IsTrue(RoleHelper.RetrieveRolesByGroupId(group.ID).Count() > 0, string.Format("获取部门ID={0}的角色关系失败", group.ID)); Assert.IsTrue(RoleHelper.RetrieveRolesByGroupId(group.Id).Count() > 0, string.Format("获取部门ID={0}的角色关系失败", group.Id));
//删除数据 //删除数据
string sql = "delete from Roles where RoleName='_测试角色_';"; string sql = "delete from Roles where RoleName='_测试角色_';";
sql += "delete from Groups where GroupName='_测试部门_';"; sql += "delete from Groups where GroupName='_测试部门_';";
sql += string.Format("delete from RoleGroup where GroupID={0}", group.ID); sql += string.Format("delete from RoleGroup where GroupID={0}", group.Id);
using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql)) using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql))
{ {
DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd); DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd);

View File

@ -49,10 +49,10 @@ namespace Bootstrap.DataAccess.Tests
var user = users.FirstOrDefault(u => u.UserName == User.UserName); var user = users.FirstOrDefault(u => u.UserName == User.UserName);
user.DisplayName = "测试者2号"; user.DisplayName = "测试者2号";
user.Description = "测试"; user.Description = "测试";
Assert.IsTrue(UserHelper.SaveUser(user), string.Format("更新用户ID={0}操作失败请检查UserHelper.SaveUser方法", user.ID)); Assert.IsTrue(UserHelper.SaveUser(user), string.Format("更新用户ID={0}操作失败请检查UserHelper.SaveUser方法", user.Id));
var ret = UserHelper.RetrieveUsers(user.ID); var ret = UserHelper.RetrieveUsers(user.Id);
Assert.IsTrue(ret.Count() == 1, "带参数的UserHelper.RetrieveUsers方法调用失败"); Assert.IsTrue(ret.Count() == 1, "带参数的UserHelper.RetrieveUsers方法调用失败");
Assert.AreEqual(user.DisplayName, ret.First().DisplayName, string.Format("更新用户ID={0}操作失败请检查UserHelper.SaveUser方法", user.ID)); Assert.AreEqual(user.DisplayName, ret.First().DisplayName, string.Format("更新用户ID={0}操作失败请检查UserHelper.SaveUser方法", user.Id));
} }
[TestMethod] [TestMethod]
@ -62,7 +62,7 @@ namespace Bootstrap.DataAccess.Tests
var user = UserHelper.RetrieveUsers().FirstOrDefault(u => u.UserName == User.UserName); var user = UserHelper.RetrieveUsers().FirstOrDefault(u => u.UserName == User.UserName);
if (user == null) UserHelper.SaveUser(User); if (user == null) UserHelper.SaveUser(User);
user = UserHelper.RetrieveUsers().FirstOrDefault(u => u.UserName == User.UserName); user = UserHelper.RetrieveUsers().FirstOrDefault(u => u.UserName == User.UserName);
Assert.IsTrue(UserHelper.DeleteUser(user.ID.ToString()), "UserHelper.DeleteUserTest方法调用失败"); Assert.IsTrue(UserHelper.DeleteUser(user.Id.ToString()), "UserHelper.DeleteUserTest方法调用失败");
} }
[TestMethod] [TestMethod]
@ -75,14 +75,14 @@ namespace Bootstrap.DataAccess.Tests
if (role == null) RoleHelper.SaveRole(Role); if (role == null) RoleHelper.SaveRole(Role);
role = RoleHelper.RetrieveRoles().FirstOrDefault(r => r.RoleName == Role.RoleName); role = RoleHelper.RetrieveRoles().FirstOrDefault(r => r.RoleName == Role.RoleName);
Assert.IsTrue(UserHelper.SaveUsersByRoleId(role.ID, user.ID.ToString()), "存储角色用户信息失败"); Assert.IsTrue(UserHelper.SaveUsersByRoleId(role.Id, user.Id.ToString()), "存储角色用户信息失败");
Assert.IsTrue(UserHelper.RetrieveUsersByRoleId(role.ID).Count() >= 1, string.Format("获取角色ID={0}的用户信息失败", role.ID)); Assert.IsTrue(UserHelper.RetrieveUsersByRoleId(role.Id).Count() >= 1, string.Format("获取角色ID={0}的用户信息失败", role.Id));
//删除数据 //删除数据
string sql = "Delete from Users where UserName = '_测试用户_';"; string sql = "Delete from Users where UserName = '_测试用户_';";
sql += "Delete from Roles where RoleName='_测试角色_';"; sql += "Delete from Roles where RoleName='_测试角色_';";
sql += string.Format("Delete from UserRole where RoleID={0};", role.ID); sql += string.Format("Delete from UserRole where RoleID={0};", role.Id);
using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql)) using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql))
{ {
DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd); DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd);
@ -99,14 +99,14 @@ namespace Bootstrap.DataAccess.Tests
if (group == null) GroupHelper.SaveGroup(Group); if (group == null) GroupHelper.SaveGroup(Group);
group = GroupHelper.RetrieveGroups().FirstOrDefault(g => g.GroupName == Group.GroupName); group = GroupHelper.RetrieveGroups().FirstOrDefault(g => g.GroupName == Group.GroupName);
Assert.IsTrue(UserHelper.SaveUsersByGroupId(group.ID, user.ID.ToString()), "存储部门用户信息失败"); Assert.IsTrue(UserHelper.SaveUsersByGroupId(group.Id, user.Id.ToString()), "存储部门用户信息失败");
Assert.IsTrue(UserHelper.RetrieveUsersByGroupId(group.ID).Count() >= 1, string.Format("获取部门ID={0}的用户失败", group.ID)); Assert.IsTrue(UserHelper.RetrieveUsersByGroupId(group.Id).Count() >= 1, string.Format("获取部门ID={0}的用户失败", group.Id));
//删除数据 //删除数据
string sql = "Delete from Users where UserName = '_测试用户_';"; string sql = "Delete from Users where UserName = '_测试用户_';";
sql += "Delete from Groups where GroupName='_测试部门_';"; sql += "Delete from Groups where GroupName='_测试部门_';";
sql += string.Format("Delete from UserGroup where GroupID={0};", group.ID); sql += string.Format("Delete from UserGroup where GroupID={0};", group.Id);
using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql)) using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql))
{ {
DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd); DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd);