From c9389f23e0eefdf78e03ae8dbf4fd70eb3377c1b Mon Sep 17 00:00:00 2001 From: Argo-Lenovo Date: Thu, 30 Mar 2017 16:15:45 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E6=9E=84=E4=BB=A3=E7=A0=81=EF=BC=9A?= =?UTF-8?q?=E6=9B=B4=E6=94=B9=E5=8F=98=E9=87=8F=E5=90=8DID=3D>Id=EF=BC=8C?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0UI=E5=AD=97=E6=95=B0=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=EF=BC=8C=E7=A7=BB=E9=99=A4ParameterDirection.Input?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/DictsController.cs | 2 +- .../Controllers/GroupsController.cs | 2 +- Bootstrap.Admin/Controllers/LogsController.cs | 2 +- .../Controllers/UsersController.cs | 2 +- Bootstrap.Admin/Models/HeaderBarModel.cs | 2 +- .../Models/QueryExceptionOption.cs | 2 +- Bootstrap.Admin/Scripts/Dicts.js | 4 +- Bootstrap.Admin/Scripts/Groups.js | 16 +-- Bootstrap.Admin/Scripts/Longbow.Common.js | 2 +- Bootstrap.Admin/Scripts/Menus.js | 10 +- Bootstrap.Admin/Scripts/Roles.js | 24 ++-- Bootstrap.Admin/Scripts/Users.js | 16 +-- Bootstrap.Admin/Scripts/common-scripts.js | 10 +- Bootstrap.Admin/Scripts/framework.js | 44 +++---- Bootstrap.Admin/Scripts/noti.js | 2 +- Bootstrap.Admin/Scripts/tasks.js | 2 +- Bootstrap.Admin/Views/Admin/Groups.cshtml | 4 +- Bootstrap.Admin/Views/Admin/Menus.cshtml | 8 +- Bootstrap.Admin/Views/Admin/Profiles.cshtml | 8 +- Bootstrap.Admin/Views/Admin/Roles.cshtml | 4 +- Bootstrap.Admin/Views/Admin/Settings.cshtml | 6 +- Bootstrap.Admin/Views/Admin/Users.cshtml | 8 +- Bootstrap.Admin/Views/Home/Register.cshtml | 2 +- Bootstrap.DataAccess/CacheCleanUtility.cs | 18 +-- Bootstrap.DataAccess/DBAccessManager.cs | 2 +- Bootstrap.DataAccess/Dict.cs | 4 +- Bootstrap.DataAccess/DictHelper.cs | 11 +- Bootstrap.DataAccess/ExceptionHelper.cs | 32 +++-- Bootstrap.DataAccess/Exceptions.cs | 4 +- Bootstrap.DataAccess/Group.cs | 5 +- Bootstrap.DataAccess/GroupHelper.cs | 80 ++++++------- Bootstrap.DataAccess/Log.cs | 2 +- Bootstrap.DataAccess/LogHelper.cs | 25 ++-- Bootstrap.DataAccess/Menu.cs | 2 +- Bootstrap.DataAccess/MenuHelper.cs | 72 +++++------ Bootstrap.DataAccess/Message.cs | 6 +- Bootstrap.DataAccess/MessageHelper.cs | 23 ++-- Bootstrap.DataAccess/Notification.cs | 2 +- Bootstrap.DataAccess/NotificationHelper.cs | 19 +-- Bootstrap.DataAccess/Role.cs | 5 +- Bootstrap.DataAccess/RoleHelper.cs | 90 +++++++------- Bootstrap.DataAccess/Task.cs | 2 +- Bootstrap.DataAccess/TaskHelper.cs | 4 +- Bootstrap.DataAccess/User.cs | 2 +- Bootstrap.DataAccess/UserHelper.cs | 112 +++++++++--------- Bootstrap.DataAccessTests/DictHelperTests.cs | 8 +- Bootstrap.DataAccessTests/GroupHelperTests.cs | 20 ++-- Bootstrap.DataAccessTests/LogHelperTests.cs | 2 +- Bootstrap.DataAccessTests/MenuHelperTests.cs | 18 +-- Bootstrap.DataAccessTests/RoleHelperTests.cs | 20 ++-- Bootstrap.DataAccessTests/UserHelperTests.cs | 20 ++-- 51 files changed, 399 insertions(+), 393 deletions(-) diff --git a/Bootstrap.Admin/Controllers/DictsController.cs b/Bootstrap.Admin/Controllers/DictsController.cs index c9d20177..d7824ca8 100644 --- a/Bootstrap.Admin/Controllers/DictsController.cs +++ b/Bootstrap.Admin/Controllers/DictsController.cs @@ -29,7 +29,7 @@ namespace Bootstrap.Admin.Controllers [HttpGet] public Dict Get(int id) { - return DictHelper.RetrieveDicts().FirstOrDefault(t => t.ID == id); + return DictHelper.RetrieveDicts().FirstOrDefault(t => t.Id == id); } /// /// diff --git a/Bootstrap.Admin/Controllers/GroupsController.cs b/Bootstrap.Admin/Controllers/GroupsController.cs index 12f70173..19576130 100644 --- a/Bootstrap.Admin/Controllers/GroupsController.cs +++ b/Bootstrap.Admin/Controllers/GroupsController.cs @@ -28,7 +28,7 @@ namespace Bootstrap.Admin.Controllers [HttpGet] public Group Get(int id) { - return GroupHelper.RetrieveGroups().FirstOrDefault(t => t.ID == id); + return GroupHelper.RetrieveGroups().FirstOrDefault(t => t.Id == id); } /// /// diff --git a/Bootstrap.Admin/Controllers/LogsController.cs b/Bootstrap.Admin/Controllers/LogsController.cs index 49933cf1..7f40805b 100644 --- a/Bootstrap.Admin/Controllers/LogsController.cs +++ b/Bootstrap.Admin/Controllers/LogsController.cs @@ -27,7 +27,7 @@ namespace Bootstrap.Admin.Controllers [HttpGet] public Log Get(int id) { - return LogHelper.RetrieveLogs().FirstOrDefault(t => t.ID == id); + return LogHelper.RetrieveLogs().FirstOrDefault(t => t.Id == id); } [HttpPost] diff --git a/Bootstrap.Admin/Controllers/UsersController.cs b/Bootstrap.Admin/Controllers/UsersController.cs index a4be923d..9696f8a7 100644 --- a/Bootstrap.Admin/Controllers/UsersController.cs +++ b/Bootstrap.Admin/Controllers/UsersController.cs @@ -113,7 +113,7 @@ namespace Bootstrap.Admin.Controllers break; case "user": // 此时 userIds 存储的信息是操作结果 1 标示同意 0 标示拒绝 - var user = new User() { ID = id, UserStatus = 2 }; + var user = new User() { Id = id, UserStatus = 2 }; if (userIds == "1") { user.ApprovedBy = User.Identity.Name; diff --git a/Bootstrap.Admin/Models/HeaderBarModel.cs b/Bootstrap.Admin/Models/HeaderBarModel.cs index 1879be22..901e936c 100644 --- a/Bootstrap.Admin/Models/HeaderBarModel.cs +++ b/Bootstrap.Admin/Models/HeaderBarModel.cs @@ -14,7 +14,7 @@ namespace Bootstrap.Admin.Models Icon = user.Icon; DisplayName = user.DisplayName; UserName = user.UserName; - UserId = user.ID; + UserId = user.Id; } public string UserName { get; private set; } /// diff --git a/Bootstrap.Admin/Models/QueryExceptionOption.cs b/Bootstrap.Admin/Models/QueryExceptionOption.cs index 2f857031..89bf2d53 100644 --- a/Bootstrap.Admin/Models/QueryExceptionOption.cs +++ b/Bootstrap.Admin/Models/QueryExceptionOption.cs @@ -39,7 +39,7 @@ namespace Bootstrap.Admin.Models data = Order == "asc" ? data.OrderBy(t => t.ErrorPage) : data.OrderByDescending(t => t.ErrorPage); break; 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; case "UserIp": data = Order == "asc" ? data.OrderBy(t => t.UserIp) : data.OrderByDescending(t => t.UserIp); diff --git a/Bootstrap.Admin/Scripts/Dicts.js b/Bootstrap.Admin/Scripts/Dicts.js index 6245c141..565d1a4c 100644 --- a/Bootstrap.Admin/Scripts/Dicts.js +++ b/Bootstrap.Admin/Scripts/Dicts.js @@ -4,7 +4,7 @@ url: Dicts.url, dataEntity: new DataEntity({ map: { - ID: "dictID", + Id: "dictID", Category: "dictCate", Name: "dictName", 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() }); }, 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: "Category", sortable: true }, { title: "字典名称", field: "Name", sortable: true }, { title: "字典代码", field: "Code", sortable: true }, diff --git a/Bootstrap.Admin/Scripts/Groups.js b/Bootstrap.Admin/Scripts/Groups.js index 2d15fce3..f31e84b0 100644 --- a/Bootstrap.Admin/Scripts/Groups.js +++ b/Bootstrap.Admin/Scripts/Groups.js @@ -10,7 +10,7 @@ url: Group.url, dataEntity: new DataEntity({ map: { - ID: "groupID", + Id: "groupID", GroupName: "groupName", Description: "groupDesc" } @@ -20,11 +20,11 @@ id: 'btn_assignRole', click: function (row) { $.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) { var htmlTemplate = this.htmlTemplate; 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('') $dialogRoleHeader.text($.format('{0}-角色授权窗口', row.GroupName)); $dialogRoleForm.html(html).find('[role="tooltip"]').each(function (index, label) { @@ -38,11 +38,11 @@ id: 'btn_assignUser', click: function (row) { $.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) { var htmlTemplate = this.htmlTemplate; 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(''); $dialogUserHeader.text($.format('{0}-用户授权窗口', row.GroupName)); $dialogUserForm.html(html).find('[role="tooltip"]').each(function (index, label) { @@ -55,7 +55,7 @@ }, { id: 'btnSubmitRole', click: function (row) { - var groupId = row.ID; + var groupId = row.Id; var roleIds = $dialogRole.find('input:checked').map(function (index, element) { return $(element).val(); }).toArray().join(','); @@ -64,7 +64,7 @@ }, { id: 'btnSubmitUser', click: function (row) { - var groupId = row.ID; + var groupId = row.Id; var userIds = $dialogUser.find(':checked').map(function (index, element) { return $(element).val(); }).toArray().join(','); @@ -79,7 +79,7 @@ sortName: 'GroupName', queryParams: function (params) { return $.extend(params, { groupName: $("#txt_search_name").val(), description: $("#txt_group_desc").val() }); }, //传递参数(*) 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: "Description", sortable: false } ] diff --git a/Bootstrap.Admin/Scripts/Longbow.Common.js b/Bootstrap.Admin/Scripts/Longbow.Common.js index 69b99a50..ffa024db 100644 --- a/Bootstrap.Admin/Scripts/Longbow.Common.js +++ b/Bootstrap.Admin/Scripts/Longbow.Common.js @@ -315,7 +315,7 @@ minimumCountColumns: 2, //最少允许的列数 clickToSelect: false, //是否启用点击选中行 //height: 500, //行高,如果没有设置height属性,表格自动根据记录条数觉得表格高度 - idField: "Id", + idfield: "Id", uniqueId: "Id", //每一行的唯一标识,一般为主键列 showToggle: true, //是否显示详细视图和列表视图的切换按钮 cardView: $(window).width() < 768, //是否显示详细视图 diff --git a/Bootstrap.Admin/Scripts/Menus.js b/Bootstrap.Admin/Scripts/Menus.js index cd33ce5c..783038e1 100644 --- a/Bootstrap.Admin/Scripts/Menus.js +++ b/Bootstrap.Admin/Scripts/Menus.js @@ -25,7 +25,7 @@ url: Menu.url, dataEntity: new DataEntity({ map: { - ID: "menuID", + Id: "menuID", ParentId: "parentId", ParentName: "parentName", Name: "name", @@ -43,11 +43,11 @@ id: 'btn_assignRole', click: function (row) { $.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) { var htmlTemplate = this.htmlTemplate; 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('') $dialogRoleHeader.text($.format('{0}-角色授权窗口', row.Name)); $dialogRoleForm.html(html).find('[role="tooltip"]').each(function (index, label) { @@ -60,7 +60,7 @@ }, { id: 'btnSubmitRole', click: function (row) { - var menuId = row.ID; + var menuId = row.Id; var roleIds = $dialogRole.find('input:checked').map(function (index, element) { return $(element).val(); }).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() }); }, //传递参数(*) 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: "ParentName", sortable: true }, { title: "菜单名称", field: "Name", sortable: true }, { title: "菜单序号", field: "Order", sortable: true }, diff --git a/Bootstrap.Admin/Scripts/Roles.js b/Bootstrap.Admin/Scripts/Roles.js index 387b205a..2d812f88 100644 --- a/Bootstrap.Admin/Scripts/Roles.js +++ b/Bootstrap.Admin/Scripts/Roles.js @@ -26,11 +26,11 @@ id: 'btn_assignUser', click: function (row) { $.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) { var htmlTemplate = this.htmlTemplate; 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(''); $dialogUserHeader.text($.format('{0}-用户授权窗口', row.RoleName)); $dialogUserForm.html(html).find('[role="tooltip"]').each(function (index, label) { @@ -44,11 +44,11 @@ id: 'btn_assignGroup', click: function (row) { $.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) { var htmlTemplate = this.htmlTemplate; 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(''); $dialogGroupHeader.text($.format('{0}-部门授权窗口', row.RoleName)); $dialogGroupForm.html(html).find('[role="tooltip"]').each(function (index, label) { @@ -62,7 +62,7 @@ id: 'btn_assignMenu', click: function (row) { $.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) { $dialogMenuHeader.text($.format('{0}-菜单授权窗口', row.RoleName)); $btnSubmitMenu.data('type', 'menu'); @@ -70,7 +70,7 @@ var menus = $nestMenu.find('input:checkbox'); menus.removeProp('checked'); $.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'); }); $dialogSubMenu.show(); @@ -81,7 +81,7 @@ }, { id: 'btnSubmitUser', click: function (row) { - var roleId = row.ID; + var roleId = row.Id; var userIds = $dialogUser.find(':checked').map(function (index, element) { return $(element).val(); }).toArray().join(','); @@ -90,7 +90,7 @@ }, { id: 'btnSubmitGroup', click: function (row) { - var roleId = row.ID; + var roleId = row.Id; var groupIds = $dialogGroup.find(':checked').map(function (index, element) { return $(element).val(); }).toArray().join(','); @@ -99,7 +99,7 @@ }, { id: 'btnSubmitMenu', click: function (row) { - var roleId = row.ID; + var roleId = row.Id; var type = $btnSubmitMenu.data('type'); switch (type) { case "menu": @@ -121,9 +121,9 @@ sortName: 'RoleName', queryParams: function (params) { return $.extend(params, { roleName: $("#txt_search_name").val(), description: $("#txt_role_desc").val() }); }, //传递参数(*) columns: [{ checkbox: true }, - { title: "Id", field: "ID", events: bsa.idEvents(), formatter: BootstrapAdmin.idFormatter }, - { title: "角色名称", field: "RoleName", sortable: true }, - { title: "角色描述", field: "Description", sortable: false } + { title: "Id", field: "Id", events: bsa.idEvents(), formatter: BootstrapAdmin.idFormatter }, + { title: "角色名称", field: "RoleName", sortable: true }, + { title: "角色描述", field: "Description", sortable: false } ] }); diff --git a/Bootstrap.Admin/Scripts/Users.js b/Bootstrap.Admin/Scripts/Users.js index 8dce0c0a..7eb08c59 100644 --- a/Bootstrap.Admin/Scripts/Users.js +++ b/Bootstrap.Admin/Scripts/Users.js @@ -10,7 +10,7 @@ url: User.url, dataEntity: new DataEntity({ map: { - ID: "userID", + Id: "userID", UserName: "userName", Password: "password", DisplayName: "displayName", @@ -22,11 +22,11 @@ id: 'btn_assignRole', click: function (row) { $.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) { var htmlTemplate = this.htmlTemplate; 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('') $dialogRoleHeader.text($.format('{0}-角色授权窗口', row.DisplayName)); $dialogRoleForm.html(html).find('[role="tooltip"]').each(function (index, label) { @@ -40,11 +40,11 @@ id: 'btn_assignGroup', click: function (row) { $.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) { var htmlTemplate = this.htmlTemplate; 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(''); $dialogGroupHeader.text($.format('{0}-部门授权窗口', row.DisplayName)); $dialogGroupForm.html(html).find('[role="tooltip"]').each(function (index, label) { @@ -57,7 +57,7 @@ }, { id: 'btnSubmitRole', click: function (row) { - var userId = row.ID; + var userId = row.Id; var roleIds = $dialogRole.find(':checked').map(function (index, element) { return $(element).val(); }).toArray().join(','); @@ -66,7 +66,7 @@ }, { id: 'btnSubmitGroup', click: function (row) { - var userId = row.ID; + var userId = row.Id; var groupIds = $dialogGroup.find(':checked').map(function (index, element) { return $(element).val(); }).toArray().join(','); @@ -92,7 +92,7 @@ sortName: 'DisplayName', queryParams: function (params) { return $.extend(params, { name: $("#txt_search_name").val(), displayName: $('#txt_display_name').val() }); }, //传递参数(*) 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: "DisplayName", sortable: true } ] diff --git a/Bootstrap.Admin/Scripts/common-scripts.js b/Bootstrap.Admin/Scripts/common-scripts.js index 81aaf2f5..9f902f91 100644 --- a/Bootstrap.Admin/Scripts/common-scripts.js +++ b/Bootstrap.Admin/Scripts/common-scripts.js @@ -3,10 +3,10 @@ var html = ""; $.each(menus, function (index, menu) { if (menu.Menus.length == 0) { - html += $.format('
  • {5}{4}
  • ', menu.ID, menu.Icon, menu.Name, menu.Category, menu.Order, menu.CategoryName); + html += $.format('
  • {5}{4}
  • ', menu.Id, menu.Icon, menu.Name, menu.Category, menu.Order, menu.CategoryName); } else { - html += $.format('
  • {6}{5}
      {4}
  • ', menu.ID, menu.Icon, menu.Name, menu.Category, cascadeSubMenu(menu.Menus), menu.Order, menu.CategoryName); + html += $.format('
  • {6}{5}
      {4}
  • ', menu.Id, menu.Icon, menu.Name, menu.Category, cascadeSubMenu(menu.Menus), menu.Order, menu.CategoryName); } }); return html; @@ -15,7 +15,7 @@ var cascadeSubMenu = function (menus) { var html = "" $.each(menus, function (index, menu) { - html += $.format('
  • {5}{4}
  • ', menu.ID, menu.Icon, menu.Name, menu.Category, menu.Order, menu.CategoryName); + html += $.format('
  • {5}{4}
  • ', menu.Id, menu.Icon, menu.Name, menu.Category, menu.Order, menu.CategoryName); }); return html; }; @@ -103,7 +103,7 @@ $(function () { $('#msgHeaderTaskBadge').text(result.TasksCount); var htmlUserTemplate = '
  • {0}-{2}{1}%
    {1}% 完成
  • '; 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(''); $(html).insertAfter($('#msgHeaderTaskContent')); @@ -139,7 +139,7 @@ $(function () { $('#msgHeaderMsgBadge').text(result.MessagesCount); htmlUserTemplate = '
  • avatar{2}{4}{3}
  • '; 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(''); $(html).insertAfter($('#msgHeaderMsgContent')); } diff --git a/Bootstrap.Admin/Scripts/framework.js b/Bootstrap.Admin/Scripts/framework.js index 5020b747..f1600c8a 100644 --- a/Bootstrap.Admin/Scripts/framework.js +++ b/Bootstrap.Admin/Scripts/framework.js @@ -1,5 +1,5 @@ -(function($) { - BootstrapAdmin = function(options) { +(function ($) { + BootstrapAdmin = function (options) { var that = this; options = options || {}; options.click = $.extend({}, BootstrapAdmin.settings.click, options.click); @@ -27,7 +27,7 @@ // handler modal window show event 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) { var v = $('#' + that.options.validateForm); v.validate().resetForm(); @@ -41,7 +41,7 @@ var source = $("#" + cId); source.data('click', name); if (event !== null) source.data('event', event); - source.click(function(e) { + source.click(function (e) { e.preventDefault(); var method = source.data('click'); 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 "" + value + ""; }; BootstrapAdmin.prototype = { constructor: BootstrapAdmin, - idEvents: function() { + idEvents: function () { var op = { dataEntity: $.extend({}, this.options.dataEntity), table: this.options.bootstrapTable, @@ -82,7 +82,7 @@ src: this }; return { - 'click .edit': function(e, value, row, index) { + 'click .edit': function (e, value, row, index) { op.dataEntity.load(row); $(op.table).bootstrapTable('uncheckAll'); $(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'); 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.options.modal.constructor === String) $('#' + this.options.modal).modal("show"); if (this.options.bootstrapTable.constructor === String) $(this.options.bootstrapTable).bootstrapTable('uncheckAll'); handlerCallback.call(this, callback, e, { oper: 'create' }); }, - edit: function(e, callback) { + edit: function (e, callback) { var options = this.options; var data = {}; if (options.bootstrapTable.constructor === String) { @@ -126,7 +126,7 @@ handlerCallback.call(this, callback, e, { oper: 'edit', data: data }); }, - del: function(e, callback) { + del: function (e, callback) { var that = this; var options = this.options; if (options.bootstrapTable.constructor === String) { @@ -144,13 +144,13 @@ confirmButtonText: "是的,我要删除", confirmButtonColor: "#d9534f", cancelButtonText: "取消" - }, function() { - setTimeout(function() { - var iDs = arrselections.map(function(element, index) { return element.ID }).join(","); + }, function () { + setTimeout(function () { + var iDs = arrselections.map(function (element, index) { return element.Id }).join(","); options.IDs = iDs; $.bc({ url: options.url, data: { "": iDs }, method: 'DELETE', title: '删除数据', - callback: function(result) { + callback: function (result) { if ($.isPlainObject(result)) { lgbSwal({ title: result.msg, type: result.result ? "success" : "error" }); result = result.result; @@ -166,24 +166,24 @@ } }, - save: function(e, callback) { + save: function (e, callback) { var that = this; var options = $.extend({ data: {} }, this.options); if (this.dataEntity instanceof DataEntity) options = $.extend(options, { data: this.dataEntity.get() }); if (options.validateForm.constructor === String && !$("#" + options.validateForm).valid()) return; $.bc({ url: options.url, data: options.data, title: "保存数据", modal: options.modal, - callback: function(result) { + callback: function (result) { var finalData = null; var index = 0; 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'); for (index = 0; index < allTableData.length; 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) }); break; } @@ -200,7 +200,7 @@ }); }, - assign: function(e, callback) { + assign: function (e, callback) { var options = this.options; var row = {}; 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(this.options.callback)) this.options.callback.call(e, data); } diff --git a/Bootstrap.Admin/Scripts/noti.js b/Bootstrap.Admin/Scripts/noti.js index cef75403..7b2c7ea0 100644 --- a/Bootstrap.Admin/Scripts/noti.js +++ b/Bootstrap.Admin/Scripts/noti.js @@ -12,7 +12,7 @@ callback: function (result) { if (result) { 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(''); $taskUsers.append(content); $('#tasks-users').find('[role="tooltip"]').lgbTooltip(); diff --git a/Bootstrap.Admin/Scripts/tasks.js b/Bootstrap.Admin/Scripts/tasks.js index b1ffd509..f96dd0a7 100644 --- a/Bootstrap.Admin/Scripts/tasks.js +++ b/Bootstrap.Admin/Scripts/tasks.js @@ -10,7 +10,7 @@ callback: function (result) { if (result) { 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(''); $('#list-task').html(content); } diff --git a/Bootstrap.Admin/Views/Admin/Groups.cshtml b/Bootstrap.Admin/Views/Admin/Groups.cshtml index d9599910..3e11273a 100644 --- a/Bootstrap.Admin/Views/Admin/Groups.cshtml +++ b/Bootstrap.Admin/Views/Admin/Groups.cshtml @@ -49,12 +49,12 @@
    - +
    - +
    diff --git a/Bootstrap.Admin/Views/Admin/Menus.cshtml b/Bootstrap.Admin/Views/Admin/Menus.cshtml index 61ec4eda..a955a416 100644 --- a/Bootstrap.Admin/Views/Admin/Menus.cshtml +++ b/Bootstrap.Admin/Views/Admin/Menus.cshtml @@ -82,7 +82,7 @@
    - + @@ -93,7 +93,7 @@
    - + @@ -113,7 +113,7 @@
    - + @@ -122,7 +122,7 @@
    - +
    diff --git a/Bootstrap.Admin/Views/Admin/Profiles.cshtml b/Bootstrap.Admin/Views/Admin/Profiles.cshtml index 528339f7..e4f86360 100644 --- a/Bootstrap.Admin/Views/Admin/Profiles.cshtml +++ b/Bootstrap.Admin/Views/Admin/Profiles.cshtml @@ -28,7 +28,7 @@
    - +
    @@ -44,15 +44,15 @@
    - +
    - +
    - +
    diff --git a/Bootstrap.Admin/Views/Admin/Roles.cshtml b/Bootstrap.Admin/Views/Admin/Roles.cshtml index 9e44d033..93a145ad 100644 --- a/Bootstrap.Admin/Views/Admin/Roles.cshtml +++ b/Bootstrap.Admin/Views/Admin/Roles.cshtml @@ -59,12 +59,12 @@
    - +
    - +
    diff --git a/Bootstrap.Admin/Views/Admin/Settings.cshtml b/Bootstrap.Admin/Views/Admin/Settings.cshtml index c888135d..f9ddb34d 100644 --- a/Bootstrap.Admin/Views/Admin/Settings.cshtml +++ b/Bootstrap.Admin/Views/Admin/Settings.cshtml @@ -19,7 +19,7 @@
    - + @@ -32,7 +32,7 @@
    - + @@ -46,7 +46,7 @@
    - +
    diff --git a/Bootstrap.DataAccess/CacheCleanUtility.cs b/Bootstrap.DataAccess/CacheCleanUtility.cs index 855faeca..f0bc968c 100644 --- a/Bootstrap.DataAccess/CacheCleanUtility.cs +++ b/Bootstrap.DataAccess/CacheCleanUtility.cs @@ -1,5 +1,4 @@ -using Longbow.Caching; -using Longbow.Caching.Configuration; +using Longbow.Caching.Configuration; using Longbow.ExceptionManagement; using System; using System.Collections.Generic; @@ -20,6 +19,7 @@ namespace Bootstrap.DataAccess /// /// /// + /// 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(); @@ -27,8 +27,8 @@ namespace Bootstrap.DataAccess { roleIds.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList().ForEach(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}", UserHelper.RetrieveUsersByRoleIdDataKey, id)); + cacheKeys.Add(string.Format("{0}-{1}", GroupHelper.RetrieveGroupsByRoleIdDataKey, id)); }); cacheKeys.Add(RoleHelper.RetrieveRolesDataKey + "*"); cacheKeys.Add(MenuHelper.RetrieveMenusDataKey + "*"); @@ -37,8 +37,8 @@ namespace Bootstrap.DataAccess { userIds.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList().ForEach(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}", RoleHelper.RetrieveRolesByUserIdDataKey, id)); + cacheKeys.Add(string.Format("{0}-{1}", GroupHelper.RetrieveGroupsByUserIdDataKey, id)); cacheKeys.Add(MenuHelper.RetrieveMenusDataKey); }); cacheKeys.Add(UserHelper.RetrieveNewUsersDataKey + "*"); @@ -48,8 +48,8 @@ namespace Bootstrap.DataAccess { groupIds.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList().ForEach(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}", RoleHelper.RetrieveRolesByGroupIdDataKey, id)); + cacheKeys.Add(string.Format("{0}-{1}", UserHelper.RetrieveUsersByGroupIdDataKey, id)); }); cacheKeys.Add(GroupHelper.RetrieveGroupsDataKey + "*"); cacheKeys.Add(MenuHelper.RetrieveMenusDataKey + "*"); @@ -58,7 +58,7 @@ namespace Bootstrap.DataAccess { 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 + "*"); } diff --git a/Bootstrap.DataAccess/DBAccessManager.cs b/Bootstrap.DataAccess/DBAccessManager.cs index 3dc10e95..59355310 100644 --- a/Bootstrap.DataAccess/DBAccessManager.cs +++ b/Bootstrap.DataAccess/DBAccessManager.cs @@ -8,7 +8,7 @@ namespace Bootstrap.DataAccess ///
    public static class DBAccessManager { - private static Lazy db = new Lazy(() => DBAccess.CreateDB("SQL"), true); + private static readonly Lazy db = new Lazy(() => DBAccess.CreateDB("SQL"), true); public static DBAccess SqlDBAccess { diff --git a/Bootstrap.DataAccess/Dict.cs b/Bootstrap.DataAccess/Dict.cs index 621c054a..3f56bb7b 100644 --- a/Bootstrap.DataAccess/Dict.cs +++ b/Bootstrap.DataAccess/Dict.cs @@ -2,15 +2,13 @@ { /// /// 字典表实体 - /// author:renshuo - /// date:2016.10.27 /// public class Dict { /// /// 字典主键 数据库自增 /// - public int ID { get; set; } + public int Id { get; set; } /// /// 分类 /// diff --git a/Bootstrap.DataAccess/DictHelper.cs b/Bootstrap.DataAccess/DictHelper.cs index 33b3ce27..4aa4eecd 100644 --- a/Bootstrap.DataAccess/DictHelper.cs +++ b/Bootstrap.DataAccess/DictHelper.cs @@ -10,6 +10,9 @@ using System.Linq; namespace Bootstrap.DataAccess { + /// + /// + /// public static class DictHelper { internal const string RetrieveDictsDataKey = "DictHelper-RetrieveDicts"; @@ -33,7 +36,7 @@ namespace Bootstrap.DataAccess { dicts.Add(new Dict() { - ID = (int)reader[0], + Id = (int)reader[0], Category = (string)reader[1], Name = (string)reader[2], 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.Name.Length > 50) p.Name = p.Name.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)" : "Update Dicts set Category = @Category, Name = @Name, Code = @Code, Define = @Define where ID = @ID"; try { 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("@Name", p.Name)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@Code", p.Code)); @@ -98,7 +101,7 @@ namespace Bootstrap.DataAccess DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd); } 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) { diff --git a/Bootstrap.DataAccess/ExceptionHelper.cs b/Bootstrap.DataAccess/ExceptionHelper.cs index 992df8bc..1e9c4d81 100644 --- a/Bootstrap.DataAccess/ExceptionHelper.cs +++ b/Bootstrap.DataAccess/ExceptionHelper.cs @@ -10,9 +10,18 @@ using System.Data.Common; namespace Bootstrap.DataAccess { + /// + /// + /// public static class ExceptionHelper { internal const string RetrieveExceptionsDataKey = "ExceptionHelper-RetrieveExceptions"; + /// + /// + /// + /// + /// + /// public static bool Log(Exception ex, NameValueCollection additionalInfo) { 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())"; 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("@ErrorPage", additionalInfo["ErrorPage"], ParameterDirection.Input)); - cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@UserID", DBAccess.ToDBValue(additionalInfo["UserId"]), ParameterDirection.Input)); - cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@UserIp", additionalInfo["UserIp"], ParameterDirection.Input)); - cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@ExceptionType", ex.GetType().FullName, ParameterDirection.Input)); - cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@Message", ex.Message, ParameterDirection.Input)); + cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@AppDomainName", AppDomain.CurrentDomain.FriendlyName)); + cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@ErrorPage", additionalInfo["ErrorPage"])); + cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@UserID", DBAccess.ToDBValue(additionalInfo["UserId"]))); + cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@UserIp", additionalInfo["UserIp"])); + cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@ExceptionType", ex.GetType().FullName)); + cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@Message", ex.Message)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@StackTrace", DBAccess.ToDBValue(ex.StackTrace), ParameterDirection.Input)); DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd); } @@ -41,14 +50,13 @@ namespace Bootstrap.DataAccess /// /// 查询所有异常 /// - /// /// public static IEnumerable RetrieveExceptions() { return CacheManager.GetOrAdd(RetrieveExceptionsDataKey, CacheSection.RetrieveIntervalByKey(RetrieveExceptionsDataKey), key => { string sql = "select top 1000 * from Exceptions order by LogTime desc"; - List Exceptions = new List(); + List exceptions = new List(); DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql); try { @@ -56,12 +64,12 @@ namespace Bootstrap.DataAccess { while (reader.Read()) { - Exceptions.Add(new Exceptions() + exceptions.Add(new Exceptions() { - ID = (int)reader[0], + Id = (int)reader[0], AppDomainName = (string)reader[1], ErrorPage = (string)reader[2], - UserID = (string)reader[3], + UserId = (string)reader[3], UserIp = (string)reader[4], ExceptionType = (string)reader[5], Message = (string)reader[6], @@ -72,7 +80,7 @@ namespace Bootstrap.DataAccess } } catch (Exception ex) { ExceptionManager.Publish(ex); } - return Exceptions; + return exceptions; }, CacheSection.RetrieveDescByKey(RetrieveExceptionsDataKey)); } } diff --git a/Bootstrap.DataAccess/Exceptions.cs b/Bootstrap.DataAccess/Exceptions.cs index 1fb8c83b..4edbd305 100644 --- a/Bootstrap.DataAccess/Exceptions.cs +++ b/Bootstrap.DataAccess/Exceptions.cs @@ -9,7 +9,7 @@ namespace Bootstrap.DataAccess /// /// /// - public int ID { get; set; } + public int Id { get; set; } /// /// /// @@ -21,7 +21,7 @@ namespace Bootstrap.DataAccess /// /// /// - public string UserID { get; set; } + public string UserId { get; set; } /// /// /// diff --git a/Bootstrap.DataAccess/Group.cs b/Bootstrap.DataAccess/Group.cs index 35b05da8..36861f0b 100644 --- a/Bootstrap.DataAccess/Group.cs +++ b/Bootstrap.DataAccess/Group.cs @@ -1,15 +1,14 @@ namespace Bootstrap.DataAccess { /// - /// author:liuchun - /// date:2016.10.22 + /// /// public class Group { /// /// 获得/设置 群组主键ID /// - public int ID { get; set; } + public int Id { get; set; } /// /// 获得/设置 群组名称 diff --git a/Bootstrap.DataAccess/GroupHelper.cs b/Bootstrap.DataAccess/GroupHelper.cs index 62aea9c0..7bcf38e0 100644 --- a/Bootstrap.DataAccess/GroupHelper.cs +++ b/Bootstrap.DataAccess/GroupHelper.cs @@ -1,5 +1,4 @@ -using Longbow; -using Longbow.Caching; +using Longbow.Caching; using Longbow.Caching.Configuration; using Longbow.Data; using Longbow.ExceptionManagement; @@ -8,7 +7,6 @@ using System.Collections.Generic; using System.Data; using System.Data.Common; using System.Data.SqlClient; -using System.Globalization; using System.Linq; namespace Bootstrap.DataAccess @@ -20,8 +18,8 @@ namespace Bootstrap.DataAccess public static class GroupHelper { internal const string RetrieveGroupsDataKey = "GroupHelper-RetrieveGroups"; - internal const string RetrieveGroupsByUserIDDataKey = "GroupHelper-RetrieveGroupsByUserId"; - internal const string RetrieveGroupsByRoleIDDataKey = "GroupHelper-RetrieveGroupsByRoleId"; + internal const string RetrieveGroupsByUserIdDataKey = "GroupHelper-RetrieveGroupsByUserId"; + internal const string RetrieveGroupsByRoleIdDataKey = "GroupHelper-RetrieveGroupsByRoleId"; /// /// 查询所有群组信息 /// @@ -32,7 +30,7 @@ namespace Bootstrap.DataAccess var ret = CacheManager.GetOrAdd(RetrieveGroupsDataKey, CacheSection.RetrieveIntervalByKey(RetrieveGroupsDataKey), key => { string sql = "select * from Groups"; - List Groups = new List(); + List groups = new List(); DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql); try { @@ -40,9 +38,9 @@ namespace Bootstrap.DataAccess { while (reader.Read()) { - Groups.Add(new Group() + groups.Add(new Group() { - ID = (int)reader[0], + Id = (int)reader[0], GroupName = (string)reader[1], Description = reader.IsDBNull(2) ? string.Empty : (string)reader[2] }); @@ -50,9 +48,9 @@ namespace Bootstrap.DataAccess } } catch (Exception ex) { ExceptionManager.Publish(ex); } - return Groups; + return groups; }, CacheSection.RetrieveDescByKey(RetrieveGroupsDataKey)); - return id == 0 ? ret : ret.Where(t => id == t.ID); + return id == 0 ? ret : ret.Where(t => id == t.Id); } /// /// 删除群组信息 @@ -60,13 +58,13 @@ namespace Bootstrap.DataAccess /// public static bool DeleteGroup(string ids) { + if (string.IsNullOrEmpty(ids) || ids.Contains("'")) return false; bool ret = false; - if (string.IsNullOrEmpty(ids) || ids.Contains("'")) return ret; try { 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); } CacheCleanUtility.ClearCache(groupIds: ids); @@ -85,23 +83,22 @@ namespace Bootstrap.DataAccess /// public static bool SaveGroup(Group p) { - if (p == null) throw new ArgumentNullException("p"); bool ret = false; - if (p.GroupName.Length > 50) p.GroupName.Substring(0, 50); - if (!string.IsNullOrEmpty(p.Description) && p.Description.Length > 500) p.Description.Substring(0, 500); - string sql = p.ID == 0 ? + if (p.GroupName.Length > 50) p.GroupName = p.GroupName.Substring(0, 50); + if (!string.IsNullOrEmpty(p.Description) && p.Description.Length > 500) p.Description = p.Description.Substring(0, 500); + string sql = p.Id == 0 ? "Insert Into Groups (GroupName, Description) Values (@GroupName, @Description)" : "Update Groups set GroupName = @GroupName, Description = @Description where ID = @ID"; try { 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("@GroupName", p.GroupName, ParameterDirection.Input)); - cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@Description", DBAccess.ToDBValue(p.Description), ParameterDirection.Input)); + cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@ID", p.Id)); + cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@GroupName", p.GroupName)); + cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@Description", DBAccess.ToDBValue(p.Description))); 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; } catch (DbException ex) @@ -117,22 +114,22 @@ namespace Bootstrap.DataAccess /// public static IEnumerable RetrieveGroupsByUserId(int userId) { - string key = string.Format("{0}-{1}", RetrieveGroupsByUserIDDataKey, userId); - var ret = CacheManager.GetOrAdd(key, CacheSection.RetrieveIntervalByKey(RetrieveGroupsByUserIDDataKey), k => + string key = string.Format("{0}-{1}", RetrieveGroupsByUserIdDataKey, userId); + 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"; - List Groups = new List(); + List groups = new List(); 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 { using (DbDataReader reader = DBAccessManager.SqlDBAccess.ExecuteReader(cmd)) { while (reader.Read()) { - Groups.Add(new Group() + groups.Add(new Group() { - ID = (int)reader[0], + Id = (int)reader[0], GroupName = (string)reader[1], Description = reader.IsDBNull(2) ? string.Empty : (string)reader[2], Checked = (string)reader[3] @@ -141,15 +138,15 @@ namespace Bootstrap.DataAccess } } catch (Exception ex) { ExceptionManager.Publish(ex); } - return Groups; - }, CacheSection.RetrieveDescByKey(RetrieveGroupsByUserIDDataKey)); + return groups; + }, CacheSection.RetrieveDescByKey(RetrieveGroupsByUserIdDataKey)); return ret; } /// /// 保存用户部门关系 /// /// - /// + /// /// public static bool SaveGroupsByUserId(int id, string groupIds) { @@ -167,7 +164,7 @@ namespace Bootstrap.DataAccess string sql = "delete from UserGroup where UserID=@UserID;"; 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); // insert batch data into config table @@ -199,22 +196,22 @@ namespace Bootstrap.DataAccess /// public static IEnumerable RetrieveGroupsByRoleId(int roleId) { - string k = string.Format("{0}-{1}", RetrieveGroupsByRoleIDDataKey, roleId); - return CacheManager.GetOrAdd(k, CacheSection.RetrieveIntervalByKey(RetrieveGroupsByRoleIDDataKey), key => + string k = string.Format("{0}-{1}", RetrieveGroupsByRoleIdDataKey, roleId); + return CacheManager.GetOrAdd(k, CacheSection.RetrieveIntervalByKey(RetrieveGroupsByRoleIdDataKey), key => { - List Groups = new List(); + List groups = new List(); string sql = "select g.ID,g.GroupName,g.[Description],case rg.GroupID when g.ID then 'checked' else '' end [status] from Groups g left join RoleGroup rg on g.ID=rg.GroupID and RoleID=@RoleID"; DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql); - cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@RoleID", roleId, ParameterDirection.Input)); + cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@RoleID", roleId)); try { using (DbDataReader reader = DBAccessManager.SqlDBAccess.ExecuteReader(cmd)) { while (reader.Read()) { - Groups.Add(new Group() + groups.Add(new Group() { - ID = (int)reader[0], + Id = (int)reader[0], GroupName = (string)reader[1], Description = reader.IsDBNull(2) ? string.Empty : (string)reader[2], Checked = (string)reader[3] @@ -223,14 +220,14 @@ namespace Bootstrap.DataAccess } } catch (Exception ex) { ExceptionManager.Publish(ex); } - return Groups; - }, CacheSection.RetrieveDescByKey(RetrieveGroupsByRoleIDDataKey)); + return groups; + }, CacheSection.RetrieveDescByKey(RetrieveGroupsByRoleIdDataKey)); } /// /// 根据角色ID以及选定的部门ID,保到角色部门表 /// - /// - /// + /// + /// /// public static bool SaveGroupsByRoleId(int id, string groupIds) { @@ -247,7 +244,7 @@ namespace Bootstrap.DataAccess string sql = "delete from RoleGroup where RoleID=@RoleID"; 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); //批插入角色部门表 using (SqlBulkCopy bulk = new SqlBulkCopy((SqlConnection)transaction.Transaction.Connection, SqlBulkCopyOptions.Default, (SqlTransaction)transaction.Transaction)) @@ -273,4 +270,3 @@ namespace Bootstrap.DataAccess } } } - diff --git a/Bootstrap.DataAccess/Log.cs b/Bootstrap.DataAccess/Log.cs index 9a551f72..16dc2ef8 100644 --- a/Bootstrap.DataAccess/Log.cs +++ b/Bootstrap.DataAccess/Log.cs @@ -6,7 +6,7 @@ namespace Bootstrap.DataAccess /// /// 获得/设置 操作日志主键ID /// - public int ID { get; set; } + public int Id { get; set; } /// /// 获得/设置 操作类型 diff --git a/Bootstrap.DataAccess/LogHelper.cs b/Bootstrap.DataAccess/LogHelper.cs index 9ddd6de4..4b01a46a 100644 --- a/Bootstrap.DataAccess/LogHelper.cs +++ b/Bootstrap.DataAccess/LogHelper.cs @@ -7,7 +7,6 @@ using System.Data; using System.Data.Common; using System.Globalization; using System.Linq; -using System.Web; namespace Bootstrap.DataAccess { @@ -24,7 +23,7 @@ namespace Bootstrap.DataAccess var ret = CacheManager.GetOrAdd(RetrieveLogsDataKey, CacheSection.RetrieveIntervalByKey(RetrieveLogsDataKey), key => { string sql = "select top 1000 * from Logs"; - List Logs = new List(); + List logs = new List(); DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql); try { @@ -32,9 +31,9 @@ namespace Bootstrap.DataAccess { while (reader.Read()) { - Logs.Add(new Log() + logs.Add(new Log() { - ID = (int)reader[0], + Id = (int)reader[0], CRUD = (string)reader[1], UserName = (string)reader[2], LogTime = (DateTime)reader[3], @@ -46,9 +45,9 @@ namespace Bootstrap.DataAccess } } catch (Exception ex) { ExceptionManager.Publish(ex); } - return Logs; + return logs; }, 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)); } /// /// 删除日志信息 @@ -57,8 +56,8 @@ namespace Bootstrap.DataAccess /// public static bool DeleteLog(string ids) { + if (string.IsNullOrEmpty(ids) || ids.Contains("'")) return false; bool ret = false; - if (string.IsNullOrEmpty(ids) || ids.Contains("'")) return ret; try { 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)) { - cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@CRUD", p.CRUD, ParameterDirection.Input)); - cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@UserName", p.UserName, ParameterDirection.Input)); - cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@ClientIp", p.ClientIp, ParameterDirection.Input)); - cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@ClientAgent", p.ClientAgent, ParameterDirection.Input)); - cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@RequestUrl", p.RequestUrl, ParameterDirection.Input)); + cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@CRUD", p.CRUD)); + cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@UserName", p.UserName)); + cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@ClientIp", p.ClientIp)); + cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@ClientAgent", p.ClientAgent)); + cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@RequestUrl", p.RequestUrl)); 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; } catch (DbException ex) diff --git a/Bootstrap.DataAccess/Menu.cs b/Bootstrap.DataAccess/Menu.cs index b39f32ff..7e5c8b44 100644 --- a/Bootstrap.DataAccess/Menu.cs +++ b/Bootstrap.DataAccess/Menu.cs @@ -10,7 +10,7 @@ namespace Bootstrap.DataAccess /// /// 获得/设置 菜单主键ID /// - public int ID { set; get; } + public int Id { set; get; } /// /// 获得/设置 父级菜单ID /// diff --git a/Bootstrap.DataAccess/MenuHelper.cs b/Bootstrap.DataAccess/MenuHelper.cs index b38c5718..e22c4309 100644 --- a/Bootstrap.DataAccess/MenuHelper.cs +++ b/Bootstrap.DataAccess/MenuHelper.cs @@ -13,10 +13,13 @@ using System.Linq; namespace Bootstrap.DataAccess { + /// + /// + /// public static class MenuHelper { internal const string RetrieveMenusDataKey = "MenuHelper-RetrieveMenus"; - internal const string RetrieveMenusByRoleIDDataKey = "MenuHelper-RetrieveMenusByRoleId"; + private const string RetrieveMenusByRoleIdDataKey = "MenuHelper-RetrieveMenusByRoleId"; /// /// 查询所有菜单信息 /// @@ -28,7 +31,7 @@ namespace Bootstrap.DataAccess string key = string.Format("{0}-{1}", RetrieveMenusDataKey, userName); return CacheManager.GetOrAdd(key, CacheSection.RetrieveIntervalByKey(RetrieveMenusDataKey), k => { - List Menus = new List(); + List menus = new List(); try { using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.StoredProcedure, "Proc_RetrieveMenus")) @@ -38,9 +41,9 @@ namespace Bootstrap.DataAccess { while (reader.Read()) { - Menus.Add(new Menu() + menus.Add(new Menu() { - ID = (int)reader[0], + Id = (int)reader[0], ParentId = (int)reader[1], Name = (string)reader[2], Order = (int)reader[3], @@ -58,7 +61,7 @@ namespace Bootstrap.DataAccess } } catch (Exception ex) { ExceptionManager.Publish(ex); } - return Menus; + return menus; }, CacheSection.RetrieveDescByKey(RetrieveMenusDataKey)); } /// @@ -75,7 +78,7 @@ namespace Bootstrap.DataAccess /// /// /// - /// + /// /// public static IEnumerable RetrieveNavigationsByUserName(string userName) { @@ -100,7 +103,7 @@ namespace Bootstrap.DataAccess { 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); }); } @@ -110,13 +113,13 @@ namespace Bootstrap.DataAccess /// public static bool DeleteMenu(string ids) { + if (string.IsNullOrEmpty(ids) || ids.Contains("'")) return false; bool ret = false; - if (string.IsNullOrEmpty(ids) || ids.Contains("'")) return ret; try { 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); } CacheCleanUtility.ClearCache(menuIds: ids); @@ -135,32 +138,31 @@ namespace Bootstrap.DataAccess /// public static bool SaveMenu(Menu p) { - if (p == null) throw new ArgumentNullException("p"); + if (string.IsNullOrEmpty(p.Name)) return false; bool ret = false; - if (string.IsNullOrEmpty(p.Name)) return ret; - if (p.Name.Length > 50) p.Name.Substring(0, 50); - if (p.Icon != null && p.Icon.Length > 50) p.Icon.Substring(0, 50); - if (p.Url != null && p.Url.Length > 50) p.Url.Substring(0, 50); - string sql = p.ID == 0 ? + if (p.Name.Length > 50) p.Name = p.Name.Substring(0, 50); + if (p.Icon != null && p.Icon.Length > 50) p.Icon = p.Icon.Substring(0, 50); + if (p.Url != null && p.Url.Length > 4000) p.Url = p.Url.Substring(0, 4000); + string sql = 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)" : "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 { 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("@ParentId", p.ParentId, ParameterDirection.Input)); - cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@Name", p.Name, ParameterDirection.Input)); - cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@Order", p.Order, ParameterDirection.Input)); - cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@Icon", DBAccess.ToDBValue(p.Icon), ParameterDirection.Input)); - cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@Url", DBAccess.ToDBValue(p.Url), ParameterDirection.Input)); - cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@Category", p.Category, ParameterDirection.Input)); - cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@Target", p.Target, ParameterDirection.Input)); - cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@IsResource", p.IsResource, ParameterDirection.Input)); - cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@ApplicationCode", p.ApplicationCode, ParameterDirection.Input)); + cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@ID", p.Id)); + cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@ParentId", p.ParentId)); + cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@Name", p.Name)); + cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@Order", p.Order)); + cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@Icon", DBAccess.ToDBValue(p.Icon))); + cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@Url", DBAccess.ToDBValue(p.Url))); + cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@Category", p.Category)); + cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@Target", p.Target)); + cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@IsResource", p.IsResource)); + cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@ApplicationCode", p.ApplicationCode)); 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; } catch (DbException ex) @@ -177,31 +179,31 @@ namespace Bootstrap.DataAccess /// public static IEnumerable RetrieveMenusByRoleId(int roleId) { - string key = string.Format("{0}-{1}", RetrieveMenusByRoleIDDataKey, roleId); - return CacheManager.GetOrAdd(key, CacheSection.RetrieveIntervalByKey(RetrieveMenusByRoleIDDataKey), k => + string key = string.Format("{0}-{1}", RetrieveMenusByRoleIdDataKey, roleId); + return CacheManager.GetOrAdd(key, CacheSection.RetrieveIntervalByKey(RetrieveMenusByRoleIdDataKey), k => { - List Menus = new List(); + List menus = new List(); try { string sql = "select NavigationID from NavigationRole where RoleID = @RoleID"; 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)) { 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); } - return Menus; - }, CacheSection.RetrieveDescByKey(RetrieveMenusByRoleIDDataKey)); + return menus; + }, CacheSection.RetrieveDescByKey(RetrieveMenusByRoleIdDataKey)); } /// /// 通过角色ID保存当前授权菜单 @@ -224,7 +226,7 @@ namespace Bootstrap.DataAccess string sql = "delete from NavigationRole where RoleID=@RoleID"; 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); //批插入菜单角色表 using (SqlBulkCopy bulk = new SqlBulkCopy((SqlConnection)transaction.Transaction.Connection, SqlBulkCopyOptions.Default, (SqlTransaction)transaction.Transaction)) diff --git a/Bootstrap.DataAccess/Message.cs b/Bootstrap.DataAccess/Message.cs index ea11b43b..1e7bf889 100644 --- a/Bootstrap.DataAccess/Message.cs +++ b/Bootstrap.DataAccess/Message.cs @@ -6,16 +6,14 @@ using System.Text; namespace Bootstrap.DataAccess { /// - /// 消息表实体 - /// author:liuchun - /// date:2016.11.12 + /// /// public class Message { /// /// 消息主键 数据库自增 /// - public int ID { get; set; } + public int Id { get; set; } /// /// 标题 /// diff --git a/Bootstrap.DataAccess/MessageHelper.cs b/Bootstrap.DataAccess/MessageHelper.cs index f95fcc7e..a7a51033 100644 --- a/Bootstrap.DataAccess/MessageHelper.cs +++ b/Bootstrap.DataAccess/MessageHelper.cs @@ -13,16 +13,15 @@ namespace Bootstrap.DataAccess /// /// /// - public class MessageHelper + public static class MessageHelper { - internal const string RetrieveMessageDataKey = "MessageHelper-RetrieveMessages"; - + private const string RetrieveMessageDataKey = "MessageHelper-RetrieveMessages"; /// /// 所有有关userName所有消息列表 /// - /// + /// /// - public static IEnumerable RetrieveMessages(string userName) + private static IEnumerable RetrieveMessages(string userName) { var messageRet = CacheManager.GetOrAdd(RetrieveMessageDataKey, CacheSection.RetrieveIntervalByKey(RetrieveMessageDataKey), key => { @@ -31,14 +30,14 @@ namespace Bootstrap.DataAccess DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql); 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)) { while (reader.Read()) { messages.Add(new Message() { - ID = (int)reader[0], + Id = (int)reader[0], Title = (string)reader[1], Content = (string)reader[2], From = (string)reader[3], @@ -64,7 +63,7 @@ namespace Bootstrap.DataAccess /// /// 收件箱 /// - /// + /// public static IEnumerable Inbox(string userName) { @@ -74,7 +73,7 @@ namespace Bootstrap.DataAccess /// /// 发件箱 /// - /// + /// /// public static IEnumerable SendMail(string userName) { @@ -84,7 +83,7 @@ namespace Bootstrap.DataAccess /// /// 垃圾箱 /// - /// + /// /// public static IEnumerable Trash(string userName) { @@ -94,7 +93,7 @@ namespace Bootstrap.DataAccess /// /// 标旗 /// - /// + /// /// public static IEnumerable Mark(string userName) { @@ -104,7 +103,7 @@ namespace Bootstrap.DataAccess /// /// 获取Header处显示的消息列表 /// - /// + /// /// public static IEnumerable RetrieveMessagesHeader(string userName) { diff --git a/Bootstrap.DataAccess/Notification.cs b/Bootstrap.DataAccess/Notification.cs index 6bc761a5..66a59fc9 100644 --- a/Bootstrap.DataAccess/Notification.cs +++ b/Bootstrap.DataAccess/Notification.cs @@ -10,7 +10,7 @@ namespace Bootstrap.DataAccess /// /// /// - public int ID { get; set; } + public int Id { get; set; } /// /// /// diff --git a/Bootstrap.DataAccess/NotificationHelper.cs b/Bootstrap.DataAccess/NotificationHelper.cs index 660908a2..86676529 100644 --- a/Bootstrap.DataAccess/NotificationHelper.cs +++ b/Bootstrap.DataAccess/NotificationHelper.cs @@ -10,14 +10,15 @@ using System.Linq; namespace Bootstrap.DataAccess { - public class NotificationHelper + /// + /// + /// + public static class NotificationHelper { - // UNDOEN: 此处需要继续完善,增强异常的通知管理 internal const string RetrieveNotificationsDataKey = "NotificationHelper-RetrieveNotifications"; /// /// 新用户注册的通知的面板显示 /// - /// /// public static IEnumerable RetrieveNotifications() { @@ -34,7 +35,7 @@ namespace Bootstrap.DataAccess { notifications.Add(new Notification() { - ID = (int)reader[0], + Id = (int)reader[0], Category = (string)reader[1], Title = (string)reader[2], Content = (string)reader[3], @@ -68,13 +69,13 @@ namespace Bootstrap.DataAccess /// public static bool ProcessRegisterUser(string id) { + if (string.IsNullOrEmpty(id)) return false; bool ret = false; - if (string.IsNullOrEmpty(id)) return ret; try { 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); } CacheCleanUtility.ClearCache(notifyIds: id); @@ -93,14 +94,14 @@ namespace Bootstrap.DataAccess /// public static bool SaveNotification(Notification noti) { + if (string.IsNullOrEmpty(noti.Title) || string.IsNullOrEmpty(noti.Content)) return false; bool ret = false; - if (string.IsNullOrEmpty(noti.Title) || string.IsNullOrEmpty(noti.Content)) return ret; try { 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("@Content", noti.Content, ParameterDirection.Input)); + cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@Title", noti.Title)); + cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@Content", noti.Content)); DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd); } CacheCleanUtility.ClearCache(notifyIds: string.Empty); diff --git a/Bootstrap.DataAccess/Role.cs b/Bootstrap.DataAccess/Role.cs index ebab5ce3..14b5ded2 100644 --- a/Bootstrap.DataAccess/Role.cs +++ b/Bootstrap.DataAccess/Role.cs @@ -1,11 +1,14 @@ namespace Bootstrap.DataAccess { + /// + /// + /// public class Role { /// /// 获得/设置 角色主键ID /// - public int ID { get; set; } + public int Id { get; set; } /// /// 获得/设置 角色名称 /// diff --git a/Bootstrap.DataAccess/RoleHelper.cs b/Bootstrap.DataAccess/RoleHelper.cs index 4ac460df..9cc33402 100644 --- a/Bootstrap.DataAccess/RoleHelper.cs +++ b/Bootstrap.DataAccess/RoleHelper.cs @@ -17,9 +17,9 @@ namespace Bootstrap.DataAccess public static class RoleHelper { internal const string RetrieveRolesDataKey = "RoleHelper-RetrieveRoles"; - internal const string RetrieveRolesByUserIDDataKey = "RoleHelper-RetrieveRolesByUserId"; - internal const string RetrieveRolesByMenuIDDataKey = "RoleHelper-RetrieveRolesByMenuId"; - internal const string RetrieveRolesByGroupIDDataKey = "RoleHelper-RetrieveRolesByGroupId"; + internal const string RetrieveRolesByUserIdDataKey = "RoleHelper-RetrieveRolesByUserId"; + internal const string RetrieveRolesByMenuIdDataKey = "RoleHelper-RetrieveRolesByMenuId"; + internal const string RetrieveRolesByGroupIdDataKey = "RoleHelper-RetrieveRolesByGroupId"; /// /// 查询所有角色 /// @@ -40,7 +40,7 @@ namespace Bootstrap.DataAccess { roles.Add(new Role() { - ID = (int)reader[0], + Id = (int)reader[0], RoleName = (string)reader[1], Description = reader.IsDBNull(2) ? string.Empty : (string)reader[2] }); @@ -50,7 +50,7 @@ namespace Bootstrap.DataAccess catch (Exception ex) { ExceptionManager.Publish(ex); } return roles; }, CacheSection.RetrieveDescByKey(RetrieveRolesDataKey)); - return id == 0 ? ret : ret.Where(t => id == t.ID); + return id == 0 ? ret : ret.Where(t => id == t.Id); } /// /// 保存用户角色关系 @@ -74,7 +74,7 @@ namespace Bootstrap.DataAccess string sql = "delete from UserRole where UserID = @UserID;"; 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); if (dt.Rows.Count > 0) { @@ -106,22 +106,22 @@ namespace Bootstrap.DataAccess /// public static IEnumerable RetrieveRolesByUserId(int userId) { - string key = string.Format("{0}-{1}", RetrieveRolesByUserIDDataKey, userId); - return CacheManager.GetOrAdd(key, CacheSection.RetrieveIntervalByKey(RetrieveRolesByUserIDDataKey), k => + string key = string.Format("{0}-{1}", RetrieveRolesByUserIdDataKey, userId); + return CacheManager.GetOrAdd(key, CacheSection.RetrieveIntervalByKey(RetrieveRolesByUserIdDataKey), k => { - List Roles = new List(); + List roles = new List(); string sql = "select r.ID, r.RoleName, r.[Description], case ur.RoleID when r.ID then 'checked' else '' end [status] from Roles r left join UserRole ur on r.ID = ur.RoleID and UserID = @UserID"; try { 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)) { while (reader.Read()) { - Roles.Add(new Role() + roles.Add(new Role() { - ID = (int)reader[0], + Id = (int)reader[0], RoleName = (string)reader[1], Description = reader.IsDBNull(2) ? string.Empty : (string)reader[2], Checked = (string)reader[3] @@ -130,22 +130,22 @@ namespace Bootstrap.DataAccess } } catch (Exception ex) { ExceptionManager.Publish(ex); } - return Roles; - }, CacheSection.RetrieveDescByKey(RetrieveRolesByUserIDDataKey)); + return roles; + }, CacheSection.RetrieveDescByKey(RetrieveRolesByUserIdDataKey)); } /// /// 删除角色表 /// - /// + /// public static bool DeleteRole(string ids) { + if (string.IsNullOrEmpty(ids) || ids.Contains("'")) return false; bool ret = false; - if (string.IsNullOrEmpty(ids) || ids.Contains("'")) return ret; try { 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); } CacheCleanUtility.ClearCache(roleIds: ids); @@ -164,23 +164,22 @@ namespace Bootstrap.DataAccess /// public static bool SaveRole(Role p) { - if (p == null) throw new ArgumentNullException("p"); bool ret = false; 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); - string sql = p.ID == 0 ? + string sql = p.Id == 0 ? "Insert Into Roles (RoleName, Description) Values (@RoleName, @Description)" : "Update Roles set RoleName = @RoleName, Description = @Description where ID = @ID"; try { 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("@RoleName", p.RoleName, ParameterDirection.Input)); - cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@Description", DBAccess.ToDBValue(p.Description), ParameterDirection.Input)); + cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@ID", p.Id)); + cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@RoleName", p.RoleName)); + cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@Description", DBAccess.ToDBValue(p.Description))); 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; } catch (DbException ex) @@ -196,22 +195,22 @@ namespace Bootstrap.DataAccess /// public static IEnumerable RetrieveRolesByMenuId(int menuId) { - string key = string.Format("{0}-{1}", RetrieveRolesByMenuIDDataKey, menuId); - var ret = CacheManager.GetOrAdd(key, CacheSection.RetrieveIntervalByKey(RetrieveRolesByMenuIDDataKey), k => + string key = string.Format("{0}-{1}", RetrieveRolesByMenuIdDataKey, menuId); + 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"; - List Roles = new List(); + List roles = new List(); 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 { using (DbDataReader reader = DBAccessManager.SqlDBAccess.ExecuteReader(cmd)) { while (reader.Read()) { - Roles.Add(new Role() + roles.Add(new Role() { - ID = (int)reader[0], + Id = (int)reader[0], RoleName = (string)reader[1], Description = reader.IsDBNull(2) ? string.Empty : (string)reader[2], Checked = (string)reader[3] @@ -220,8 +219,8 @@ namespace Bootstrap.DataAccess } } catch (Exception ex) { ExceptionManager.Publish(ex); } - return Roles; - }, CacheSection.RetrieveDescByKey(RetrieveRolesByMenuIDDataKey)); + return roles; + }, CacheSection.RetrieveDescByKey(RetrieveRolesByMenuIdDataKey)); return ret; } public static bool SavaRolesByMenuId(int id, string roleIds) @@ -240,7 +239,7 @@ namespace Bootstrap.DataAccess string sql = "delete from NavigationRole where NavigationID=@NavigationID;"; 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); // insert batch data into config table @@ -267,27 +266,27 @@ namespace Bootstrap.DataAccess } /// /// 根据GroupId查询和该Group有关的所有Roles - /// author:liuchun - /// + /// + /// /// - public static IEnumerable RetrieveRolesByGroupId(int groupID) + public static IEnumerable RetrieveRolesByGroupId(int groupId) { - string key = string.Format("{0}-{1}", RetrieveRolesByGroupIDDataKey, groupID); - return CacheManager.GetOrAdd(key, CacheSection.RetrieveIntervalByKey(RetrieveRolesByGroupIDDataKey), k => + string key = string.Format("{0}-{1}", RetrieveRolesByGroupIdDataKey, groupId); + return CacheManager.GetOrAdd(key, CacheSection.RetrieveIntervalByKey(RetrieveRolesByGroupIdDataKey), k => { - List Roles = new List(); + List roles = new List(); string sql = "select r.ID, r.RoleName, r.[Description], case ur.RoleID when r.ID then 'checked' else '' end [status] from Roles r left join RoleGroup ur on r.ID = ur.RoleID and GroupID = @GroupID"; DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql); 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)) { while (reader.Read()) { - Roles.Add(new Role() + roles.Add(new Role() { - ID = (int)reader[0], + Id = (int)reader[0], RoleName = (string)reader[1], Description = reader.IsDBNull(2) ? string.Empty : (string)reader[2], Checked = (string)reader[3] @@ -296,14 +295,15 @@ namespace Bootstrap.DataAccess } } catch (Exception ex) { ExceptionManager.Publish(ex); } - return Roles; - }, CacheSection.RetrieveDescByKey(RetrieveRolesByGroupIDDataKey)); + return roles; + }, CacheSection.RetrieveDescByKey(RetrieveRolesByGroupIdDataKey)); } /// /// 根据GroupId更新Roles信息,删除旧的Roles信息,插入新的Roles信息 /// - /// + /// + /// /// public static bool SaveRolesByGroupId(int id, string roleIds) { @@ -321,7 +321,7 @@ namespace Bootstrap.DataAccess string sql = "delete from RoleGroup where GroupID=@GroupID"; 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); // insert batch data into config table diff --git a/Bootstrap.DataAccess/Task.cs b/Bootstrap.DataAccess/Task.cs index cf70c996..c258750a 100644 --- a/Bootstrap.DataAccess/Task.cs +++ b/Bootstrap.DataAccess/Task.cs @@ -7,7 +7,7 @@ namespace Bootstrap.DataAccess /// /// 获取/设置 任务ID /// - public int ID { get; set; } + public int Id { get; set; } /// /// 获取/设置 任务名称 /// diff --git a/Bootstrap.DataAccess/TaskHelper.cs b/Bootstrap.DataAccess/TaskHelper.cs index bc121904..f5904345 100644 --- a/Bootstrap.DataAccess/TaskHelper.cs +++ b/Bootstrap.DataAccess/TaskHelper.cs @@ -10,7 +10,7 @@ namespace Bootstrap.DataAccess { public static class TaskHelper { - internal const string RetrieveTasksDataKey = "TaskHelper-RetrieveTasks"; + private const string RetrieveTasksDataKey = "TaskHelper-RetrieveTasks"; /// /// 查询所有任务 /// @@ -30,7 +30,7 @@ namespace Bootstrap.DataAccess { tasks.Add(new Task() { - ID = (int)reader[0], + Id = (int)reader[0], TaskName = (string)reader[1], AssignName = (string)reader[2], UserName = (string)reader[3], diff --git a/Bootstrap.DataAccess/User.cs b/Bootstrap.DataAccess/User.cs index 04d7cc60..438d93a9 100644 --- a/Bootstrap.DataAccess/User.cs +++ b/Bootstrap.DataAccess/User.cs @@ -10,7 +10,7 @@ namespace Bootstrap.DataAccess /// /// 获得/设置 用户主键ID /// - public int ID { get; set; } + public int Id { get; set; } /// /// 获取/设置 密码 /// diff --git a/Bootstrap.DataAccess/UserHelper.cs b/Bootstrap.DataAccess/UserHelper.cs index 8cc05f5e..835001b9 100644 --- a/Bootstrap.DataAccess/UserHelper.cs +++ b/Bootstrap.DataAccess/UserHelper.cs @@ -22,8 +22,8 @@ namespace Bootstrap.DataAccess { internal const string RetrieveUsersDataKey = "UserHelper-RetrieveUsers"; private const string RetrieveUsersByNameDataKey = "UserHelper-RetrieveUsersByName"; - internal const string RetrieveUsersByRoleIDDataKey = "UserHelper-RetrieveUsersByRoleId"; - internal const string RetrieveUsersByGroupIDDataKey = "UserHelper-RetrieveUsersByGroupId"; + internal const string RetrieveUsersByRoleIdDataKey = "UserHelper-RetrieveUsersByRoleId"; + internal const string RetrieveUsersByGroupIdDataKey = "UserHelper-RetrieveUsersByGroupId"; internal const string RetrieveNewUsersDataKey = "UserHelper-RetrieveNewUsers"; /// /// 查询所有用户 @@ -35,7 +35,7 @@ namespace Bootstrap.DataAccess string sql = "select ID, UserName, DisplayName, RegisterTime, ApprovedTime from Users Where ApprovedTime is not null"; var ret = CacheManager.GetOrAdd(RetrieveUsersDataKey, CacheSection.RetrieveIntervalByKey(RetrieveUsersDataKey), key => { - List Users = new List(); + List users = new List(); DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql); try { @@ -43,9 +43,9 @@ namespace Bootstrap.DataAccess { while (reader.Read()) { - Users.Add(new User() + users.Add(new User() { - ID = (int)reader[0], + Id = (int)reader[0], UserName = (string)reader[1], DisplayName = (string)reader[2], RegisterTime = (DateTime)reader[3], @@ -55,9 +55,9 @@ namespace Bootstrap.DataAccess } } catch (Exception ex) { ExceptionManager.Publish(ex); } - return Users; + return users; }, CacheSection.RetrieveDescByKey(RetrieveUsersDataKey)); - return id == 0 ? ret : ret.Where(t => id == t.ID); + return id == 0 ? ret : ret.Where(t => id == t.Id); } /// /// 根据用户名查询用户 @@ -75,14 +75,14 @@ namespace Bootstrap.DataAccess DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql); 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)) { if (reader.Read()) { user = new User() { - ID = (int)reader[0], + Id = (int)reader[0], UserName = (string)reader[1], DisplayName = (string)reader[2], RegisterTime = (DateTime)reader[3], @@ -105,7 +105,7 @@ namespace Bootstrap.DataAccess 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"; - List Users = new List(); + List users = new List(); DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql); try { @@ -113,9 +113,9 @@ namespace Bootstrap.DataAccess { while (reader.Read()) { - Users.Add(new User() + users.Add(new User() { - ID = (int)reader[0], + Id = (int)reader[0], UserName = (string)reader[1], DisplayName = (string)reader[2], RegisterTime = (DateTime)reader[3], @@ -125,7 +125,7 @@ namespace Bootstrap.DataAccess } } catch (Exception ex) { ExceptionManager.Publish(ex); } - return Users; + return users; }, CacheSection.RetrieveDescByKey(RetrieveNewUsersDataKey)); } /// @@ -134,13 +134,13 @@ namespace Bootstrap.DataAccess /// public static bool DeleteUser(string ids) { + if (string.IsNullOrEmpty(ids) || ids.Contains("'")) return false; bool ret = false; - if (string.IsNullOrEmpty(ids) || ids.Contains("'")) return ret; try { 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); } CacheCleanUtility.ClearCache(userIds: ids); @@ -159,10 +159,10 @@ namespace Bootstrap.DataAccess /// 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.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.Password = LgbCryptography.ComputeHash(p.Password, p.PassSalt); } @@ -171,19 +171,19 @@ namespace Bootstrap.DataAccess { 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("@userName", DBAccess.ToDBValue(p.UserName), ParameterDirection.Input)); - cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@password", DBAccess.ToDBValue(p.Password), ParameterDirection.Input)); - cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@passSalt", DBAccess.ToDBValue(p.PassSalt), ParameterDirection.Input)); - cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@displayName", DBAccess.ToDBValue(p.DisplayName), ParameterDirection.Input)); - cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@description", DBAccess.ToDBValue(p.Description), ParameterDirection.Input)); - cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@approvedBy", DBAccess.ToDBValue(p.ApprovedBy), ParameterDirection.Input)); - cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@rejectedBy", DBAccess.ToDBValue(p.RejectedBy), ParameterDirection.Input)); - cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@rejectedReason", DBAccess.ToDBValue(p.RejectedReason), ParameterDirection.Input)); - cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@userStatus", p.UserStatus, ParameterDirection.Input)); + cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@id", p.Id)); + cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@userName", DBAccess.ToDBValue(p.UserName))); + cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@password", DBAccess.ToDBValue(p.Password))); + cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@passSalt", DBAccess.ToDBValue(p.PassSalt))); + cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@displayName", DBAccess.ToDBValue(p.DisplayName))); + cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@description", DBAccess.ToDBValue(p.Description))); + cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@approvedBy", DBAccess.ToDBValue(p.ApprovedBy))); + cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@rejectedBy", DBAccess.ToDBValue(p.RejectedBy))); + cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@rejectedReason", DBAccess.ToDBValue(p.RejectedReason))); + cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@userStatus", p.UserStatus)); 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; } catch (DbException ex) @@ -199,22 +199,22 @@ namespace Bootstrap.DataAccess /// public static IEnumerable 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 => { - List Users = new List(); + List users = new List(); string sql = "select u.ID, u.UserName, u.DisplayName, case ur.UserID when u.ID then 'checked' else '' end [status] from Users u left join UserRole ur on u.ID = ur.UserID and RoleID = @RoleID where u.ApprovedTime is not null"; 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 { using (DbDataReader reader = DBAccessManager.SqlDBAccess.ExecuteReader(cmd)) { while (reader.Read()) { - Users.Add(new User() + users.Add(new User() { - ID = (int)reader[0], + Id = (int)reader[0], UserName = (string)reader[1], DisplayName = (string)reader[2], Checked = (string)reader[3] @@ -223,14 +223,14 @@ namespace Bootstrap.DataAccess } } catch (Exception ex) { ExceptionManager.Publish(ex); } - return Users; - }, CacheSection.RetrieveDescByKey(RetrieveUsersByRoleIDDataKey)); + return users; + }, CacheSection.RetrieveDescByKey(RetrieveUsersByRoleIdDataKey)); } /// /// 通过角色ID保存当前授权用户(插入) /// /// 角色ID - /// 用户ID数组 + /// 用户ID数组 /// public static bool SaveUsersByRoleId(int id, string userIds) { @@ -247,7 +247,7 @@ namespace Bootstrap.DataAccess string sql = "delete from UserRole where RoleID=@RoleID"; 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); //批插入用户角色表 using (SqlBulkCopy bulk = new SqlBulkCopy((SqlConnection)transaction.Transaction.Connection, SqlBulkCopyOptions.Default, (SqlTransaction)transaction.Transaction)) @@ -273,26 +273,26 @@ namespace Bootstrap.DataAccess /// /// 通过groupId获取所有用户 /// - /// + /// /// public static IEnumerable RetrieveUsersByGroupId(int groupId) { - string key = string.Format("{0}-{1}", RetrieveUsersByGroupIDDataKey, groupId); - return CacheManager.GetOrAdd(key, CacheSection.RetrieveIntervalByKey(RetrieveUsersByGroupIDDataKey), k => + string key = string.Format("{0}-{1}", RetrieveUsersByGroupIdDataKey, groupId); + return CacheManager.GetOrAdd(key, CacheSection.RetrieveIntervalByKey(RetrieveUsersByGroupIdDataKey), k => { - List Users = new List(); + List users = new List(); string sql = "select u.ID, u.UserName, u.DisplayName, case ur.UserID when u.ID then 'checked' else '' end [status] from Users u left join UserGroup ur on u.ID = ur.UserID and GroupID =@groupId where u.ApprovedTime is not null"; 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 { using (DbDataReader reader = DBAccessManager.SqlDBAccess.ExecuteReader(cmd)) { while (reader.Read()) { - Users.Add(new User() + users.Add(new User() { - ID = (int)reader[0], + Id = (int)reader[0], UserName = (string)reader[1], DisplayName = (string)reader[2], Checked = (string)reader[3] @@ -301,14 +301,14 @@ namespace Bootstrap.DataAccess } } catch (Exception ex) { ExceptionManager.Publish(ex); } - return Users; - }, CacheSection.RetrieveDescByKey(RetrieveUsersByRoleIDDataKey)); + return users; + }, CacheSection.RetrieveDescByKey(RetrieveUsersByRoleIdDataKey)); } /// /// 通过部门ID保存当前授权用户(插入) /// /// GroupID - /// 用户ID数组 + /// 用户ID数组 /// public static bool SaveUsersByGroupId(int id, string userIds) { @@ -325,7 +325,7 @@ namespace Bootstrap.DataAccess string sql = "delete from UserGroup where GroupID = @GroupID"; 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); //批插入用户角色表 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"; 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("@userName", userName, ParameterDirection.Input)); + cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@iconName", iconName)); + cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@userName", userName)); DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd); string key = string.Format("{0}-{1}", RetrieveUsersByNameDataKey, userName); CacheManager.Clear(k => key == k); @@ -389,8 +389,8 @@ namespace Bootstrap.DataAccess string sql = "Update Users set DisplayName = @DisplayName where UserName = @userName"; 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("@userName", user.UserName, ParameterDirection.Input)); + cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@DisplayName", user.DisplayName)); + cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@userName", user.UserName)); DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd); CacheCleanUtility.ClearCache(userIds: string.Empty); ret = true; @@ -419,9 +419,9 @@ namespace Bootstrap.DataAccess user.NewPassword = LgbCryptography.ComputeHash(user.NewPassword, user.PassSalt); 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("@PassSalt", user.PassSalt, ParameterDirection.Input)); - cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@userName", user.UserName, ParameterDirection.Input)); + cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@Password", user.NewPassword)); + cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@PassSalt", user.PassSalt)); + cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@userName", user.UserName)); DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd); string key = string.Format("{0}-{1}", RetrieveUsersByNameDataKey, user.UserName); CacheManager.Clear(k => k == key); @@ -436,4 +436,4 @@ namespace Bootstrap.DataAccess return ret; } } -} \ No newline at end of file +} diff --git a/Bootstrap.DataAccessTests/DictHelperTests.cs b/Bootstrap.DataAccessTests/DictHelperTests.cs index 29457c09..45996715 100644 --- a/Bootstrap.DataAccessTests/DictHelperTests.cs +++ b/Bootstrap.DataAccessTests/DictHelperTests.cs @@ -43,10 +43,10 @@ namespace Bootstrap.DataAccess.Tests // 测试更新字典记录方法 ID != 0 var dict = dicts.FirstOrDefault(d => d.Category == Dict.Category); dict.Name = "__测试子字典2__"; - Assert.IsTrue(DictHelper.SaveDict(dict), string.Format("更新字典记录ID = {0} 操作失败,请检查 DictHelper.SaveDict 方法", dict.ID)); - var dest = DictHelper.RetrieveDicts().Where(d => d.ID == 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); 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] @@ -56,7 +56,7 @@ namespace Bootstrap.DataAccess.Tests var dict = DictHelper.RetrieveDicts().FirstOrDefault(d => d.Category == Dict.Category); if (dict == null) DictHelper.SaveDict(Dict); 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 方法调用失败"); } } } diff --git a/Bootstrap.DataAccessTests/GroupHelperTests.cs b/Bootstrap.DataAccessTests/GroupHelperTests.cs index af03552c..c0f0e10e 100644 --- a/Bootstrap.DataAccessTests/GroupHelperTests.cs +++ b/Bootstrap.DataAccessTests/GroupHelperTests.cs @@ -47,10 +47,10 @@ namespace Bootstrap.DataAccess.Tests //测试更新部门方法 ID!=0 var group = groups.FirstOrDefault(g => g.GroupName == Group.GroupName); group.Description = "我是测试部门"; - Assert.IsTrue(GroupHelper.SaveGroup(group), string.Format("更新部门ID={0}操作失败,请检查GroupHelper.SaveGroup方法", group.ID)); - var ret = GroupHelper.RetrieveGroups(group.ID); + Assert.IsTrue(GroupHelper.SaveGroup(group), string.Format("更新部门ID={0}操作失败,请检查GroupHelper.SaveGroup方法", group.Id)); + var ret = GroupHelper.RetrieveGroups(group.Id); 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] @@ -60,7 +60,7 @@ namespace Bootstrap.DataAccess.Tests var group = GroupHelper.RetrieveGroups().FirstOrDefault(g => g.GroupName == Group.GroupName); if (group == null) GroupHelper.SaveGroup(Group); 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] @@ -73,14 +73,14 @@ namespace Bootstrap.DataAccess.Tests if (group == null) GroupHelper.SaveGroup(Group); 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 = '_测试用户_';"; 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)) { DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd); @@ -97,14 +97,14 @@ namespace Bootstrap.DataAccess.Tests if (role == null) RoleHelper.SaveRole(Role); 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 = '_测试部门_';"; 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)) { DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd); diff --git a/Bootstrap.DataAccessTests/LogHelperTests.cs b/Bootstrap.DataAccessTests/LogHelperTests.cs index 92224e1a..d78f65cd 100644 --- a/Bootstrap.DataAccessTests/LogHelperTests.cs +++ b/Bootstrap.DataAccessTests/LogHelperTests.cs @@ -41,7 +41,7 @@ namespace Bootstrap.DataAccess.Tests var log = LogHelper.RetrieveLogs().FirstOrDefault(l => l.UserName == Log.UserName); if (log == null) LogHelper.SaveLog(Log); log = LogHelper.RetrieveLogs().FirstOrDefault(l => l.UserName == Log.UserName); - Assert.IsTrue(LogHelper.DeleteLog(log.ID.ToString()), "删除日志信息出错"); + Assert.IsTrue(LogHelper.DeleteLog(log.Id.ToString()), "删除日志信息出错"); } } } \ No newline at end of file diff --git a/Bootstrap.DataAccessTests/MenuHelperTests.cs b/Bootstrap.DataAccessTests/MenuHelperTests.cs index 3a5aa09d..6bbb86e8 100644 --- a/Bootstrap.DataAccessTests/MenuHelperTests.cs +++ b/Bootstrap.DataAccessTests/MenuHelperTests.cs @@ -49,7 +49,7 @@ namespace Bootstrap.DataAccess.Tests // 测试更新菜单方法 ID != 0 var menu = menus.FirstOrDefault(m => m.Name == Menu.Name); 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] @@ -59,7 +59,7 @@ namespace Bootstrap.DataAccess.Tests var menu = MenuHelper.RetrieveMenus().FirstOrDefault(m => m.Name == Menu.Name); if (menu == null) MenuHelper.SaveMenu(Menu); 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] @@ -73,13 +73,13 @@ namespace Bootstrap.DataAccess.Tests if (role == null) RoleHelper.SaveRole(Role); role = RoleHelper.RetrieveRoles().FirstOrDefault(m => m.RoleName == Role.RoleName); - 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.SavaRolesByMenuId(menu.Id, role.Id.ToString()), "保存菜单角色关系失败"); + Assert.IsTrue(RoleHelper.RetrieveRolesByMenuId(menu.Id).Count() > 0, string.Format("获取菜单ID={0}的角色关系失败", menu.Id)); //删除数据 string sql = "delete from Navigations where Name='__测试菜单__';"; 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)) { DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd); @@ -95,14 +95,14 @@ namespace Bootstrap.DataAccess.Tests if (role == null) RoleHelper.SaveRole(Role); role = RoleHelper.RetrieveRoles().FirstOrDefault(r => r.RoleName == Role.RoleName); - Assert.IsTrue(MenuHelper.SaveMenusByRoleId(role.ID, menu.ID.ToString()), "存储角色菜单信息失败"); - int x = MenuHelper.RetrieveMenusByRoleId(role.ID).Count(); - Assert.IsTrue(x >= 1, string.Format("获取角色ID={0}的菜单信息失败", role.ID)); + Assert.IsTrue(MenuHelper.SaveMenusByRoleId(role.Id, menu.Id.ToString()), "存储角色菜单信息失败"); + int x = MenuHelper.RetrieveMenusByRoleId(role.Id).Count(); + Assert.IsTrue(x >= 1, string.Format("获取角色ID={0}的菜单信息失败", role.Id)); //删除数据 string sql = "Delete from Navigations where Name = '__测试菜单__';"; 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)) { DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd); diff --git a/Bootstrap.DataAccessTests/RoleHelperTests.cs b/Bootstrap.DataAccessTests/RoleHelperTests.cs index 08f9fbce..0d929314 100644 --- a/Bootstrap.DataAccessTests/RoleHelperTests.cs +++ b/Bootstrap.DataAccessTests/RoleHelperTests.cs @@ -37,10 +37,10 @@ namespace Bootstrap.DataAccess.Tests //测试编辑角色方法 ID != 0 var role = roles.FirstOrDefault(m => m.RoleName == Role.RoleName); role.Description = "这是修改后的测试角色"; - Assert.IsTrue(RoleHelper.SaveRole(role), string.Format("更新角色ID={0}操作失败,请检查RoleHelper.SaveRole方法", role.ID)); - var ret = RoleHelper.RetrieveRoles(role.ID); + Assert.IsTrue(RoleHelper.SaveRole(role), string.Format("更新角色ID={0}操作失败,请检查RoleHelper.SaveRole方法", role.Id)); + var ret = RoleHelper.RetrieveRoles(role.Id); 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] public void RetrieveRoleTest() @@ -55,7 +55,7 @@ namespace Bootstrap.DataAccess.Tests var role = RoleHelper.RetrieveRoles().FirstOrDefault(r => r.RoleName == "_测试角色_"); if (role == null) RoleHelper.SaveRole(Role); role = RoleHelper.RetrieveRoles().FirstOrDefault(r => r.RoleName == "_测试角色_"); - Assert.IsTrue(RoleHelper.DeleteRole(role.ID.ToString()), "删除角色失败"); + Assert.IsTrue(RoleHelper.DeleteRole(role.Id.ToString()), "删除角色失败"); } [TestMethod] public void SaveRolesByUserIdTest() @@ -68,12 +68,12 @@ namespace Bootstrap.DataAccess.Tests if (user == null) UserHelper.SaveUser(User); user = UserHelper.RetrieveUsers().FirstOrDefault(m => m.DisplayName == User.DisplayName); - 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.SaveRolesByUserId(user.Id, role.Id.ToString()), "保存用户角色关系失败"); + Assert.IsTrue(RoleHelper.RetrieveRolesByUserId(user.Id).Count() >= 1, string.Format("获取用户ID={0}的角色信息失败", user.Id)); //删除数据 string sql = "delete from Roles where RoleName='_测试角色_';"; 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)) { DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd); @@ -90,12 +90,12 @@ namespace Bootstrap.DataAccess.Tests if (group == null) GroupHelper.SaveGroup(Group); group = GroupHelper.RetrieveGroups().FirstOrDefault(m => m.GroupName == Group.GroupName); - 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.SaveRolesByGroupId(group.Id, role.Id.ToString()), "保存部门角色关系失败"); + Assert.IsTrue(RoleHelper.RetrieveRolesByGroupId(group.Id).Count() > 0, string.Format("获取部门ID={0}的角色关系失败", group.Id)); //删除数据 string sql = "delete from Roles where RoleName='_测试角色_';"; 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)) { DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd); diff --git a/Bootstrap.DataAccessTests/UserHelperTests.cs b/Bootstrap.DataAccessTests/UserHelperTests.cs index f99ca712..abdcbad5 100644 --- a/Bootstrap.DataAccessTests/UserHelperTests.cs +++ b/Bootstrap.DataAccessTests/UserHelperTests.cs @@ -49,10 +49,10 @@ namespace Bootstrap.DataAccess.Tests var user = users.FirstOrDefault(u => u.UserName == User.UserName); user.DisplayName = "测试者2号"; user.Description = "测试"; - Assert.IsTrue(UserHelper.SaveUser(user), string.Format("更新用户ID={0}操作失败,请检查UserHelper.SaveUser方法", user.ID)); - var ret = UserHelper.RetrieveUsers(user.ID); + Assert.IsTrue(UserHelper.SaveUser(user), string.Format("更新用户ID={0}操作失败,请检查UserHelper.SaveUser方法", user.Id)); + var ret = UserHelper.RetrieveUsers(user.Id); 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] @@ -62,7 +62,7 @@ namespace Bootstrap.DataAccess.Tests var user = UserHelper.RetrieveUsers().FirstOrDefault(u => u.UserName == User.UserName); if (user == null) UserHelper.SaveUser(User); 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] @@ -75,14 +75,14 @@ namespace Bootstrap.DataAccess.Tests if (role == null) RoleHelper.SaveRole(Role); 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 = '_测试用户_';"; 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)) { DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd); @@ -99,14 +99,14 @@ namespace Bootstrap.DataAccess.Tests if (group == null) GroupHelper.SaveGroup(Group); 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 = '_测试用户_';"; 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)) { DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd);