移除Rules&Terminals两个示例相关类,使用Users前台展示,数据库使用BootstrapAdmin

This commit is contained in:
Argo-Lenovo 2016-10-22 20:55:07 +08:00
parent bcf2a8d6fa
commit 6eb56183f0
27 changed files with 548 additions and 1291 deletions

View File

@ -148,7 +148,7 @@
<Content Include="Content\js\messages_zh.js" /> <Content Include="Content\js\messages_zh.js" />
<Content Include="Content\js\messages_zh.min.js" /> <Content Include="Content\js\messages_zh.min.js" />
<Content Include="Scripts\Login.js" /> <Content Include="Scripts\Login.js" />
<Content Include="Scripts\Terminals.js" /> <Content Include="Scripts\Users.js" />
<Content Include="Content\js\jquery-1.10.2.js" /> <Content Include="Content\js\jquery-1.10.2.js" />
<Content Include="Content\js\jquery-1.10.2.min.js" /> <Content Include="Content\js\jquery-1.10.2.min.js" />
<Content Include="Content\js\sweetalert.js" /> <Content Include="Content\js\sweetalert.js" />
@ -172,8 +172,6 @@
<Compile Include="App_Start\WebApiConfig.cs" /> <Compile Include="App_Start\WebApiConfig.cs" />
<Compile Include="Controllers\AdminController.cs" /> <Compile Include="Controllers\AdminController.cs" />
<Compile Include="Controllers\HomeController.cs" /> <Compile Include="Controllers\HomeController.cs" />
<Compile Include="Controllers\RulesController.cs" />
<Compile Include="Controllers\TerminalsController.cs" />
<Compile Include="Controllers\UsersController.cs" /> <Compile Include="Controllers\UsersController.cs" />
<Compile Include="Global.asax.cs"> <Compile Include="Global.asax.cs">
<DependentUpon>Global.asax</DependentUpon> <DependentUpon>Global.asax</DependentUpon>
@ -182,15 +180,12 @@
<Compile Include="Models\ModelBase.cs" /> <Compile Include="Models\ModelBase.cs" />
<Compile Include="Models\NavigatorBarModel.cs" /> <Compile Include="Models\NavigatorBarModel.cs" />
<Compile Include="Models\PaginationOption.cs" /> <Compile Include="Models\PaginationOption.cs" />
<Compile Include="Models\TerminalsModel.cs" /> <Compile Include="Models\UserEntity.cs" />
<Compile Include="Models\UserModel.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Content Include="Views\web.config" /> <Content Include="Views\web.config" />
<Content Include="packages.config" /> <Content Include="packages.config" />
<Content Include="Views\Home\Terminals.cshtml" />
<Content Include="Views\Home\Rules.cshtml" />
<Content Include="Content\fonts\fontawesome-webfont.ttf" /> <Content Include="Content\fonts\fontawesome-webfont.ttf" />
<Content Include="Content\fonts\fontawesome-webfont.woff" /> <Content Include="Content\fonts\fontawesome-webfont.woff" />
<Content Include="Views\Shared\_Fix.cshtml" /> <Content Include="Views\Shared\_Fix.cshtml" />

View File

@ -1,6 +1,4 @@
/// <reference path="jquery-1.10.2.js" /> (function ($) {
(function ($) {
// 增加Array扩展 // 增加Array扩展
if (!$.isFunction(Array.prototype.filter)) { if (!$.isFunction(Array.prototype.filter)) {
Array.prototype.filter = function (callback, thisObject) { Array.prototype.filter = function (callback, thisObject) {
@ -94,6 +92,32 @@
that.animate({ marginTop: "+=" + getHeight() }); that.animate({ marginTop: "+=" + getHeight() });
} }
}); });
$.fn.extend({
autoValidate: function (options) {
// validate
$("#dataForm").validate({
ignore: "ignore",
rules: $.extend({}, options),
unhighlight: function (element, errorClass, validClass) {
$.validator.defaults.unhighlight(element, errorClass, validClass);
$(element).popover('destroy');
},
errorPlacement: function (label, element) {
$(element).popover('destroy');
$(element).popover({
animation: true,
delay: { "show": 100, "hide": 100 },
container: 'form',
trigger: 'manual',
content: $(label).text(),
placement: 'auto'
});
$(element).popover('show');
}
});
}
});
})(jQuery); })(jQuery);
$(function () { $(function () {

View File

@ -1,153 +1,153 @@
(function ($) { (function ($) {
ExtenderChecker = function (options) { BootstrapAdmin = function (options) {
var that = this; var that = this;
this.options = $.extend({}, ExtenderChecker.settings, options); this.options = $.extend({}, BootstrapAdmin.settings, options);
this.dataEntity = options.dataEntity; this.dataEntity = options.dataEntity;
if (!(this.dataEntity instanceof DataEntity) && window.console) { if (!(this.dataEntity instanceof DataEntity) && window.console) {
window.console.log('初始化参数中没有DataEntity实例'); window.console.log('初始化参数中没有DataEntity实例');
} }
// handler click event // handler click event
for (name in this.options.click) { for (name in this.options.click) {
var source = $("#" + this.options.click[name]); var source = $("#" + this.options.click[name]);
source.data('click', name); source.data('click', name);
$("#" + this.options.click[name]).click(function () { $("#" + this.options.click[name]).click(function () {
var method = $(this).data('click'); var method = $(this).data('click');
ExtenderChecker.prototype[method].apply(that); BootstrapAdmin.prototype[method].apply(that);
}); });
} }
// handler modal window show event // handler modal window show event
if (this.options.modal.constructor === String) { if (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.constructor === String) { if (that.options.validateForm.constructor === String) {
var v = $('#' + that.options.validateForm).validate(); var v = $('#' + that.options.validateForm).validate();
v.currentElements.each(function () { $(this).popover('destroy'); }) v.currentElements.each(function () { $(this).popover('destroy'); })
v.resetForm(); v.resetForm();
} }
}); });
} }
}; };
ExtenderChecker.VERSION = "1.0"; BootstrapAdmin.VERSION = "1.0";
ExtenderChecker.Author = "Argo Zhang"; BootstrapAdmin.Author = "Argo Zhang";
ExtenderChecker.Email = "argo@163.com"; BootstrapAdmin.Email = "argo@163.com";
ExtenderChecker.settings = { BootstrapAdmin.settings = {
url: undefined, url: undefined,
bootstrapTable: 'table', bootstrapTable: 'table',
validateForm: 'dataForm', validateForm: 'dataForm',
modal: 'dialogNew', modal: 'dialogNew',
click: {} click: {}
} }
ExtenderChecker.idFormatter = function (value, row, index) { BootstrapAdmin.idFormatter = function (value, row, index) {
return "<a class='edit' href='javascript:void(0)'>" + value + "</a>"; return "<a class='edit' href='javascript:void(0)'>" + value + "</a>";
}; };
ExtenderChecker.prototype = { BootstrapAdmin.prototype = {
constructor: ExtenderChecker, constructor: BootstrapAdmin,
query: function () { query: function () {
if (this.options.bootstrapTable.constructor === String) $(this.options.bootstrapTable).bootstrapTable('refresh'); if (this.options.bootstrapTable.constructor === String) $(this.options.bootstrapTable).bootstrapTable('refresh');
}, },
create: function () { create: function () {
this.dataEntity.reset(); this.dataEntity.reset();
if (this.options.modal.constructor === String) $('#' + this.options.modal).modal("show"); if (this.options.modal.constructor === String) $('#' + this.options.modal).modal("show");
if (this.options.bootstrapTable.constructor === String) $(this.options.bootstrapTable).bootstrapTable('uncheckAll'); if (this.options.bootstrapTable.constructor === String) $(this.options.bootstrapTable).bootstrapTable('uncheckAll');
}, },
edit: function () { edit: function () {
options = this.options; options = this.options;
if (options.bootstrapTable.constructor !== String) return; if (options.bootstrapTable.constructor !== String) return;
var arrselections = $(options.bootstrapTable).bootstrapTable('getSelections'); var arrselections = $(options.bootstrapTable).bootstrapTable('getSelections');
if (arrselections.length == 0) { if (arrselections.length == 0) {
swal('请选择要编辑的条目', "编辑操作", "warning"); swal('请选择要编辑的条目', "编辑操作", "warning");
} }
else if (arrselections.length > 1) { else if (arrselections.length > 1) {
swal('请选择一个要编辑的条目', "编辑操作", "warning"); swal('请选择一个要编辑的条目', "编辑操作", "warning");
} }
else { else {
this.dataEntity.load(arrselections[0]); this.dataEntity.load(arrselections[0]);
if (options.modal.constructor === String) $('#' + options.modal).modal("show"); if (options.modal.constructor === String) $('#' + options.modal).modal("show");
} }
}, },
del: function () { del: function () {
var options = this.options; var options = this.options;
if (options.bootstrapTable.constructor !== String) return; if (options.bootstrapTable.constructor !== String) return;
var arrselections = $(options.bootstrapTable).bootstrapTable('getSelections'); var arrselections = $(options.bootstrapTable).bootstrapTable('getSelections');
if (arrselections.length == 0) { if (arrselections.length == 0) {
swal('请选择要删除的条目', "删除操作", "warning"); swal('请选择要删除的条目', "删除操作", "warning");
return; return;
} }
else { else {
swal({ swal({
title: "您确定要删除吗?", title: "您确定要删除吗?",
text: "删除操作", text: "删除操作",
type: "warning", type: "warning",
showCancelButton: true, showCancelButton: true,
closeOnConfirm: true, closeOnConfirm: true,
confirmButtonText: "是的,我要删除", confirmButtonText: "是的,我要删除",
confirmButtonColor: "#d9534f", confirmButtonColor: "#d9534f",
cancelButtonText: "取消" cancelButtonText: "取消"
}, function () { }, function () {
var iDs = arrselections.map(function (element, index) { return element.ID }).join(","); var iDs = arrselections.map(function (element, index) { return element.ID }).join(",");
$.ajax({ $.ajax({
url: options.url, url: options.url,
data: { "": iDs }, data: { "": iDs },
type: 'DELETE', type: 'DELETE',
success: function (result) { success: function (result) {
if (result) setTimeout(function () { swal("成功!", "删除数据", "success"); $(options.bootstrapTable).bootstrapTable('refresh'); }, 100); if (result) setTimeout(function () { swal("成功!", "删除数据", "success"); $(options.bootstrapTable).bootstrapTable('refresh'); }, 100);
else setTimeout(function () { swal("失败", "删除数据", "error"); }, 200); else setTimeout(function () { swal("失败", "删除数据", "error"); }, 200);
}, },
error: function (XMLHttpRequest, textStatus, errorThrown) { error: function (XMLHttpRequest, textStatus, errorThrown) {
swal("失败", "删除数据", "error"); swal("失败", "删除数据", "error");
} }
}); });
}); });
} }
}, },
save: function () { save: function () {
var options = $.extend({}, this.options, { data: this.dataEntity.get() }); var options = $.extend({}, this.options, { data: this.dataEntity.get() });
if (options.validateForm.constructor === String && !$("#" + options.validateForm).valid()) return; if (options.validateForm.constructor === String && !$("#" + options.validateForm).valid()) return;
$.ajax({ $.ajax({
url: options.url, url: options.url,
data: options.data, data: options.data,
type: 'POST', type: 'POST',
success: function (result) { success: function (result) {
if (result) { if (result) {
if ($.isFunction(options.success)) options.success(options.data); if ($.isFunction(options.success)) options.success(options.data);
if (options.bootstrapTable.constructor === String && options.data.ID.constructor === String) { if (options.bootstrapTable.constructor === String && options.data.ID.constructor === String) {
// 更新表格 // 更新表格
if (options.data.ID > 0) { if (options.data.ID > 0) {
var allTableData = $(options.bootstrapTable).bootstrapTable('getData'); var allTableData = $(options.bootstrapTable).bootstrapTable('getData');
for (index = 0; index < allTableData.length; index++) { for (index = 0; index < allTableData.length; index++) {
var temp = allTableData[index]; var temp = allTableData[index];
if (temp.ID == options.data.ID) { if (temp.ID == options.data.ID) {
$(options.bootstrapTable).bootstrapTable('updateRow', { index: index, row: $.extend(temp, options.data) }); $(options.bootstrapTable).bootstrapTable('updateRow', { index: index, row: $.extend(temp, options.data) });
break; break;
} }
} }
} }
else { else {
$(options.bootstrapTable).bootstrapTable('refresh'); $(options.bootstrapTable).bootstrapTable('refresh');
} }
} }
if (options.modal.constructor === String) $('#' + options.modal).modal("hide"); if (options.modal.constructor === String) $('#' + options.modal).modal("hide");
swal("成功", "保存数据", "success"); swal("成功", "保存数据", "success");
} }
else { else {
swal("失败", "保存数据", "error"); swal("失败", "保存数据", "error");
} }
}, },
error: function (XMLHttpRequest, textStatus, errorThrown) { error: function (XMLHttpRequest, textStatus, errorThrown) {
swal("失败", "保存数据失败", "error"); swal("失败", "保存数据失败", "error");
} }
}); });
} }
}; };
})(jQuery); })(jQuery);

View File

@ -16,26 +16,7 @@ namespace Bootstrap.Admin.Controllers
public ActionResult Index() public ActionResult Index()
{ {
var v = new HeaderBarModel(); var v = new HeaderBarModel();
return View(v); v.ShowMenu = "hide";
}
/// <summary>
///
/// </summary>
/// <returns></returns>
public ActionResult Rules()
{
var v = new HeaderBarModel();
v.BreadcrumbName = "规则设置";
return View(v);
}
/// <summary>
///
/// </summary>
/// <returns></returns>
public ActionResult Terminals()
{
var v = new HeaderBarModel();
v.BreadcrumbName = "输入口设置";
return View(v); return View(v);
} }
/// <summary> /// <summary>

View File

@ -1,35 +0,0 @@
using System.Collections.Generic;
using System.Web.Http;
namespace Bootstrap.Admin.Controllers
{
public class RulesController : ApiController
{
// GET api/<controller>
public IEnumerable<string> Get()
{
return new string[] { "value1", "value2" };
}
// GET api/<controller>/5
public string Get(int id)
{
return "value";
}
// POST api/<controller>
public void Post([FromBody]string value)
{
}
// PUT api/<controller>/5
public void Put(int id, [FromBody]string value)
{
}
// DELETE api/<controller>/5
public void Delete(int id)
{
}
}
}

View File

@ -1,48 +0,0 @@
using Bootstrap.Admin.Models;
using Bootstrap.DataAccess;
using System.Linq;
using System.Web.Http;
namespace Bootstrap.Admin.Controllers
{
public class TerminalsController : ApiController
{
// GET api/<controller>
[HttpGet]
public TerminalsModel Get([FromUri]TerminalsPageOption value)
{
var ret = new TerminalsModel();
ret.RetrieveTerminals(value);
return ret;
}
// GET api/<controller>/5
[HttpGet]
public Terminal Get(int id)
{
return TerminalHelper.RetrieveTerminals(string.Empty).FirstOrDefault(t => t.ID == id);
}
// POST api/<controller>
[HttpPost]
public bool Post([FromBody]Terminal value)
{
return TerminalHelper.SaveTerminal(value);
}
// PUT api/<controller>/5
[HttpPut]
public bool Put(int id, [FromBody]Terminal value)
{
return TerminalHelper.SaveTerminal(value);
}
// DELETE api/<controller>/5
[HttpDelete]
public bool Delete([FromBody]string value)
{
TerminalHelper.DeleteTerminal(value);
return true;
}
}
}

View File

@ -1,38 +1,55 @@
using Bootstrap.Admin.Models; using Bootstrap.Admin.Models;
using System.Web.Http; using Bootstrap.DataAccess;
using System.Web.Http;
namespace Bootstrap.Admin.Controllers using System.Linq;
{
public class UsersController : ApiController namespace Bootstrap.Admin.Controllers
{ {
// GET api/<controller> /// <summary>
[HttpGet] ///
public UserModel Get() /// </summary>
{ public class UsersController : ApiController
return new UserModel() {
{ /// <summary>
}; ///
} /// </summary>
/// <param name="value"></param>
// GET api/<controller>/5 /// <returns></returns>
public string Get(int id) [HttpGet]
{ public UserEntity Get([FromUri]TerminalsPageOption value)
return "value"; {
} var ret = new UserEntity();
ret.RetrieveUsers(value);
// POST api/<controller> return ret;
public void Post([FromBody]string value)
{ }
} /// <summary>
///
// PUT api/<controller>/5 /// </summary>
public void Put(int id, [FromBody]string value) /// <param name="id"></param>
{ /// <returns></returns>
} [HttpGet]
public User Get(int id)
// DELETE api/<controller>/5 {
public void Delete(int id) return UserHelper.RetrieveUsers().FirstOrDefault(t => t.ID == id);
{ }
} /// <summary>
} ///
/// </summary>
/// <param name="value"></param>
[HttpPost]
public bool Post([FromBody]User value)
{
return UserHelper.SaveUser(value);
}
/// <summary>
///
/// </summary>
/// <param name="id"></param>
[HttpDelete]
public bool Delete([FromBody]string value)
{
return UserHelper.DeleteUser(value);
}
}
} }

View File

@ -4,27 +4,23 @@ using System.Linq;
namespace Bootstrap.Admin.Models namespace Bootstrap.Admin.Models
{ {
public class TerminalsModel public class UserEntity
{ {
public int total { get; private set; } public int total { get; private set; }
public IEnumerable<Terminal> rows { get; private set; } public IEnumerable<User> rows { get; private set; }
public void RetrieveTerminals(TerminalsPageOption option) public void RetrieveUsers(TerminalsPageOption option)
{ {
// int limit, int offset, string name, string price, string sort, string order // int limit, int offset, string name, string price, string sort, string order
var data = TerminalHelper.RetrieveTerminals(string.Empty); var data = UserHelper.RetrieveUsers(string.Empty);
if (!string.IsNullOrEmpty(option.Name)) if (!string.IsNullOrEmpty(option.Name))
{ {
data = data.Where(t => t.Name.Contains(option.Name)); data = data.Where(t => t.UserName.Contains(option.Name));
}
if (!string.IsNullOrEmpty(option.Ip))
{
data = data.Where(t => t.ServerIP.Contains(option.Ip));
} }
total = data.Count(); total = data.Count();
// TODO: 通过option.Sort属性判断对那列进行排序现在统一对名称列排序 // TODO: 通过option.Sort属性判断对那列进行排序现在统一对名称列排序
data = option.Order == "asc" ? data.OrderBy(t => t.Name) : data.OrderByDescending(t => t.Name); data = option.Order == "asc" ? data.OrderBy(t => t.UserName) : data.OrderByDescending(t => t.UserName);
rows = data.Skip(option.Offset).Take(option.Limit); rows = data.Skip(option.Offset).Take(option.Limit);
} }
} }
@ -34,7 +30,5 @@ namespace Bootstrap.Admin.Models
public class TerminalsPageOption : PaginationOption public class TerminalsPageOption : PaginationOption
{ {
public string Name { get; set; } public string Name { get; set; }
public string Ip { get; set; }
} }
} }

View File

@ -1,7 +0,0 @@
namespace Bootstrap.Admin.Models
{
public class UserModel : HeaderBarModel
{
}
}

View File

@ -1,150 +0,0 @@
$(function () {
var dataEntity = new DataEntity({
map: {
ID: "terminalId",
Name: "terminalName",
ClientIP: "clientIP",
ClientPort: "clientPort",
ServerIP: "serverIP",
ServerPort: "serverPort",
DeviceIP: "deviceIP",
DevicePort: "devicePort",
DatabaseName: "databaseName",
DatabaseUserName: "databaseUserName",
DatabasePassword: "databasePassword"
}
});
var extender = new ExtenderChecker({
url: '../api/Terminals',
dataEntity: dataEntity,
click: {
query: 'btn_query',
create: 'btn_add',
edit: 'btn_edit',
del: 'btn_delete',
save: 'btnSubmit'
}
});
idEvents = {
'click .edit': function (e, value, row, index) {
dataEntity.load(row);
$('table').bootstrapTable('uncheckAll');
$('table').bootstrapTable('check', index);
$("#dialogNew").modal("show");
}
};
$('table').bootstrapTable({
url: '../api/Terminals', //请求后台的URL*
method: 'get', //请求方式(*
toolbar: '#toolbar', //工具按钮用哪个容器
striped: true, //是否显示行间隔色
cache: false, //是否使用缓存默认为true所以一般情况下需要设置一下这个属性*
pagination: true, //是否显示分页(*
sortable: true, //是否启用排序
sortName: 'Name',
sortOrder: "asc", //排序方式
queryParams: function (params) { return $.extend(params, { name: $("#txt_search_name").val(), ip: $("#txt_search_ip").val() }); }, //传递参数(*
sidePagination: "server", //分页方式client客户端分页server服务端分页*
pageNumber: 1, //初始化加载第一页,默认第一页
pageSize: 10, //每页的记录行数(*
pageList: [10, 25, 50, 100], //可供选择的每页的行数(*
search: false, //是否显示表格搜索,此搜索是客户端搜索,不会进服务端,所以,个人感觉意义不大
strictSearch: false,
showColumns: true, //是否显示所有的列
showRefresh: true, //是否显示刷新按钮
minimumCountColumns: 2, //最少允许的列数
clickToSelect: false, //是否启用点击选中行
//height: 500, //行高如果没有设置height属性表格自动根据记录条数觉得表格高度
idField: "Id",
uniqueId: "Id", //每一行的唯一标识,一般为主键列
showToggle: true, //是否显示详细视图和列表视图的切换按钮
cardView: false, //是否显示详细视图
detailView: false, //是否显示父子表
clickToSelect: false,
columns: [{ checkbox: true },
{ title: "Id", field: "ID", events: idEvents, formatter: ExtenderChecker.idFormatter },
{ title: "输入口名称", field: "Name", sortable: true },
{ title: "工控机IP", field: "ClientIP", sortable: false },
{ title: "工控机Port", field: "ClientPort", sortable: false },
{ title: "服务器IP", field: "ServerIP", sortable: false },
{ title: "服务器Port", field: "ServerPort", sortable: false },
{ title: "比对设备IP", field: "DeviceIP", sortable: false },
{ title: "比对设备Port", field: "DevicePort", sortable: false },
{ title: "数据库名称", field: "DatabaseName", sortable: false },
{ title: "数据库用户名", field: "DatabaseUserName", sortable: false },
{ title: "数据库密码", field: "DatabasePassword", sortable: false }
]
});
// validate
$("#dataForm").validate({
ignore: "ignore",
rules: {
terminalName: {
required: true,
maxlength: 50
},
clientIP: {
required: true,
ip: true,
maxlength: 15
},
clientPort: {
required: true,
digits: true,
range: [0, 65535],
maxlength: 5
},
serverIP: {
required: true,
ip: true,
maxlength: 15
},
serverPort: {
required: true,
digits: true,
range: [1000, 65535],
minlength: 4
},
deviceIP: {
required: true,
ip: true,
maxlength: 15
},
devicePort: {
required: true,
digits: true,
range: [1000, 65535],
minlength: 4
},
databaseName: {
maxlength: 50
},
databaseUserName: {
maxlength: 50
},
databasePassword: {
maxlength: 50
}
},
unhighlight: function (element, errorClass, validClass) {
$.validator.defaults.unhighlight(element, errorClass, validClass);
$(element).popover('destroy');
},
errorPlacement: function (label, element) {
$(element).popover('destroy');
$(element).popover({
animation: true,
delay: { "show": 100, "hide": 100 },
container: 'form',
trigger: 'manual',
content: $(label).text(),
placement: 'auto'
});
$(element).popover('show');
}
});
});

View File

@ -0,0 +1,80 @@
$(function () {
var dataEntity = new DataEntity({
map: {
ID: "userID",
UserName: "userName",
Password: "password"
}
});
var extender = new BootstrapAdmin({
url: '../api/Users',
dataEntity: dataEntity,
click: {
query: 'btn_query',
create: 'btn_add',
edit: 'btn_edit',
del: 'btn_delete',
save: 'btnSubmit'
}
});
idEvents = {
'click .edit': function (e, value, row, index) {
dataEntity.load(row);
$('table').bootstrapTable('uncheckAll');
$('table').bootstrapTable('check', index);
$("#dialogNew").modal("show");
}
};
$('table').bootstrapTable({
url: '../api/Users', //请求后台的URL*
method: 'get', //请求方式(*
toolbar: '#toolbar', //工具按钮用哪个容器
striped: true, //是否显示行间隔色
cache: false, //是否使用缓存默认为true所以一般情况下需要设置一下这个属性*
pagination: true, //是否显示分页(*
sortable: true, //是否启用排序
sortName: 'UserName',
sortOrder: "asc", //排序方式
queryParams: function (params) { return $.extend(params, { name: $("#txt_search_name").val() }); }, //传递参数(*
sidePagination: "server", //分页方式client客户端分页server服务端分页*
pageNumber: 1, //初始化加载第一页,默认第一页
pageSize: 10, //每页的记录行数(*
pageList: [10, 25, 50, 100], //可供选择的每页的行数(*
search: false, //是否显示表格搜索,此搜索是客户端搜索,不会进服务端,所以,个人感觉意义不大
strictSearch: false,
showColumns: true, //是否显示所有的列
showRefresh: true, //是否显示刷新按钮
minimumCountColumns: 2, //最少允许的列数
clickToSelect: false, //是否启用点击选中行
//height: 500, //行高如果没有设置height属性表格自动根据记录条数觉得表格高度
idField: "Id",
uniqueId: "Id", //每一行的唯一标识,一般为主键列
showToggle: true, //是否显示详细视图和列表视图的切换按钮
cardView: false, //是否显示详细视图
detailView: false, //是否显示父子表
clickToSelect: false,
columns: [{ checkbox: true },
{ title: "Id", field: "ID", events: idEvents, formatter: BootstrapAdmin.idFormatter },
{ title: "用户名称", field: "UserName", sortable: true }
]
});
// validate
$('#dataForm').autoValidate({
userName: {
required: true,
maxlength: 50
},
password: {
required: true,
maxlength: 50
},
confirm: {
required: true,
equalTo: "#password"
}
});
});

View File

@ -5,7 +5,6 @@
} }
@section Javascript { @section Javascript {
<script src="~/scripts/Users.js"></script> <script src="~/scripts/Users.js"></script>
<script src="~/scripts/Terminals.js"></script>
} }
@section header { @section header {
@Html.Partial("Header", Model) @Html.Partial("Header", Model)
@ -16,9 +15,9 @@
@section query { @section query {
<form class="form-horizontal" role="form"> <form class="form-horizontal" role="form">
<div class="form-group terminal-form-group"> <div class="form-group terminal-form-group">
<label class="control-label col-lg-1" for="txt_search_name">用户名</label> <label class="control-label col-lg-1" for="txt_search_name">用户名</label>
<div class="col-lg-4"> <div class="col-lg-4">
<input type="text" class="form-control" id="txt_username" /> <input type="text" class="form-control" id="txt_search_name" />
</div> </div>
<div class="col-lg-2"> <div class="col-lg-2">
<button type="button" id="btn_query" class="btn btn-primary"><span class="glyphicon glyphicon-search" aria-hidden="true"></span>查询</button> <button type="button" id="btn_query" class="btn btn-primary"><span class="glyphicon glyphicon-search" aria-hidden="true"></span>查询</button>
@ -35,58 +34,22 @@
<div class="modal-body"> <div class="modal-body">
<form class="form-horizontal terminal-form-group" id="dataForm" name="dataForm" role="form"> <form class="form-horizontal terminal-form-group" id="dataForm" name="dataForm" role="form">
<div class="form-group"> <div class="form-group">
<label class="control-label col-sm-2" for="terminalName">输入口名称</label> <label class="control-label col-sm-2" for="userName">用户名称</label>
<div class="col-sm-4"> <div class="col-sm-4">
<input type="text" class="form-control" id="terminalName" name="terminalName" size="20" maxlength="50" /> <input type="text" class="form-control" id="userName" name="userName" maxlength="50" />
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="clientIP">工控机IP</label>
<div class="col-sm-4">
<input type="text" class="form-control" id="clientIP" name="clientIP" size="20" maxlength="15" />
</div>
<label class="control-label col-sm-2" for="clientPort">工控机Port</label>
<div class="col-sm-4">
<input type="text" class="form-control" id="clientPort" name="clientPort" size="20" maxlength="5" />
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="serverIP">服务器IP</label>
<div class="col-sm-4">
<input type="text" class="form-control" id="serverIP" name="serverIP" size="20" maxlength="15" />
</div>
<label class="control-label col-sm-2" for="serverPort">服务器Port</label>
<div class="col-sm-4">
<input type="text" class="form-control" id="serverPort" name="serverPort" size="20" maxlength="5" />
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="deviceIP">比对设备IP</label>
<div class="col-sm-4">
<input type="text" class="form-control" id="deviceIP" name="deviceIP" size="20" maxlength="15" />
</div>
<label class="control-label col-sm-2" for="devicePort">比对设备Port</label>
<div class="col-sm-4">
<input type="text" class="form-control" id="devicePort" name="devicePort" size="20" maxlength="5" />
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="databaseName">数据库名称</label>
<div class="col-sm-4">
<input type="text" class="form-control" id="databaseName" name="databaseName" maxlength="50" />
</div> </div>
<div class="col-sm-1" style="display:none;"> <div class="col-sm-1" style="display:none;">
<input type="text" class="form-control" id="terminalId" /> <input type="text" class="form-control" id="userID" name="userID" />
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="control-label col-sm-2" for="databaseUserName">数据库用户名</label> <label class="control-label col-sm-2" for="password">登录密码</label>
<div class="col-sm-4"> <div class="col-sm-4">
<input type="text" class="form-control" id="databaseUserName" name="databaseUserName" size="20" maxlength="50" /> <input type="text" class="form-control" id="password" name="password" maxlength="15" />
</div> </div>
<label class="control-label col-sm-2" for="databasePassword">数据库密码</label> <label class="control-label col-sm-2" for="confirm">确认密码</label>
<div class="col-sm-4"> <div class="col-sm-4">
<input type="text" class="form-control" id="databasePassword" name="databasePassword" size="20" maxlength="50" /> <input type="text" class="form-control" id="confirm" name="confirm" maxlength="5" />
</div> </div>
</div> </div>
</form> </form>

View File

@ -1,137 +0,0 @@
@model Bootstrap.Admin.Models.HeaderBarModel
@{
ViewBag.Title = "Rules";
Layout = "~/Views/Shared/_Fix.cshtml";
}
@section Javascript {
<script src="~/content/js/sweetalert.js"></script>
<script src="~/content/js/bootstrap-table.js"></script>
<script src="~/content/js/bootstrap-table-zh-CN.js"></script>
<script src="~/content/js/jquery.validate.js"></script>
<script src="~/content/js/messages_zh.js"></script>
<script src="~/scripts/Terminals.js"></script>
}
@section header {
@Html.Partial("Header", Model)
}
<div class="panel panel-default">
<div class="panel-heading">查询条件</div>
<div class="panel-body">
<form class="form-horizontal" role="form">
<div class="form-group terminal-form-group">
<label class="control-label col-sm-1" for="txt_search_name">输入口名称</label>
<div class="col-sm-4">
<input type="text" class="form-control" id="txt_search_name" />
</div>
<label class="control-label col-sm-1" for="txt_search_ip">服务器IP</label>
<div class="col-sm-2">
<input type="text" class="form-control" id="txt_search_ip" size="15" maxlength="15" />
</div>
<div class="col-sm-2">
<button type="button" id="btn_query" class="btn btn-primary"><span class="glyphicon glyphicon-search" aria-hidden="true"></span>查询</button>
</div>
</div>
</form>
</div>
</div>
<div id="toolbar" class="btn-group">
<button id="btn_add" type="button" class="btn btn-success">
<span class="glyphicon glyphicon-plus" aria-hidden="true"></span>新增
</button>
<button id="btn_delete" type="button" class="btn btn-danger">
<span class="glyphicon glyphicon-remove" aria-hidden="true"></span>删除
</button>
<button id="btn_edit" type="button" class="btn btn-primary">
<span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>编辑
</button>
</div>
<div class="panel panel-default terminal-pannel">
<div class="panel-heading">
查询结果
</div>
<div class="panel-body table-body">
<table></table>
</div>
</div>
@section modal {
<div class="modal fade" id="dialogNew" tabindex="-1" role="dialog" data-backdrop="static" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog terminal-dialog">
<div class="modal-content">
<div class="modal-header terminal-dialog-header">
<button type="button" class="close terminal-close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title" id="myModalLabel">输入口编辑窗口</h4>
</div>
<div class="modal-body">
<form class="form-horizontal terminal-form-group" id="dataForm" name="dataForm" role="form">
<div class="form-group">
<label class="control-label col-sm-2" for="terminalName">输入口名称</label>
<div class="col-sm-4">
<input type="text" class="form-control" id="terminalName" name="terminalName" size="20" maxlength="50" />
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="clientIP">工控机IP</label>
<div class="col-sm-4">
<input type="text" class="form-control" id="clientIP" name="clientIP" size="20" maxlength="15" />
</div>
<label class="control-label col-sm-2" for="clientPort">工控机Port</label>
<div class="col-sm-4">
<input type="text" class="form-control" id="clientPort" name="clientPort" size="20" maxlength="5" />
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="serverIP">服务器IP</label>
<div class="col-sm-4">
<input type="text" class="form-control" id="serverIP" name="serverIP" size="20" maxlength="15" />
</div>
<label class="control-label col-sm-2" for="serverPort">服务器Port</label>
<div class="col-sm-4">
<input type="text" class="form-control" id="serverPort" name="serverPort" size="20" maxlength="5" />
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="deviceIP">比对设备IP</label>
<div class="col-sm-4">
<input type="text" class="form-control" id="deviceIP" name="deviceIP" size="20" maxlength="15" />
</div>
<label class="control-label col-sm-2" for="devicePort">比对设备Port</label>
<div class="col-sm-4">
<input type="text" class="form-control" id="devicePort" name="devicePort" size="20" maxlength="5" />
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="databaseName">数据库名称</label>
<div class="col-sm-4">
<input type="text" class="form-control" id="databaseName" name="databaseName" maxlength="50" />
</div>
<div class="col-sm-1" style="display:none;">
<input type="text" class="form-control" id="terminalId" />
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="databaseUserName">数据库用户名</label>
<div class="col-sm-4">
<input type="text" class="form-control" id="databaseUserName" name="databaseUserName" size="20" maxlength="50" />
</div>
<label class="control-label col-sm-2" for="databasePassword">数据库密码</label>
<div class="col-sm-4">
<input type="text" class="form-control" id="databasePassword" name="databasePassword" size="20" maxlength="50" />
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">
关闭
</button>
<button type="button" class="btn btn-primary" id="btnSubmit">
提交更改
</button>
</div>
</div>
</div>
</div>
}

View File

@ -1,137 +0,0 @@
@model Bootstrap.Admin.Models.HeaderBarModel
@{
ViewBag.Title = "Terminals";
Layout = "~/Views/Shared/_Normal.cshtml";
}
@section Javascript {
<script src="~/content/js/sweetalert.js"></script>
<script src="~/content/js/bootstrap-table.js"></script>
<script src="~/content/js/bootstrap-table-zh-CN.js"></script>
<script src="~/content/js/jquery.validate.js"></script>
<script src="~/content/js/messages_zh.js"></script>
<script src="~/scripts/Terminals.js"></script>
}
@section header {
@Html.Partial("Header", Model)
}
<div class="panel panel-default">
<div class="panel-heading">查询条件</div>
<div class="panel-body">
<form class="form-horizontal" role="form">
<div class="form-group terminal-form-group">
<label class="control-label col-sm-1" for="txt_search_name">输入口名称</label>
<div class="col-sm-4">
<input type="text" class="form-control" id="txt_search_name" />
</div>
<label class="control-label col-sm-1" for="txt_search_ip">服务器IP</label>
<div class="col-sm-2">
<input type="text" class="form-control" id="txt_search_ip" size="15" maxlength="15" />
</div>
<div class="col-sm-2">
<button type="button" id="btn_query" class="btn btn-primary"><span class="glyphicon glyphicon-search" aria-hidden="true"></span>查询</button>
</div>
</div>
</form>
</div>
</div>
<div id="toolbar" class="btn-group">
<button id="btn_add" type="button" class="btn btn-success">
<span class="glyphicon glyphicon-plus" aria-hidden="true"></span>新增
</button>
<button id="btn_delete" type="button" class="btn btn-danger">
<span class="glyphicon glyphicon-remove" aria-hidden="true"></span>删除
</button>
<button id="btn_edit" type="button" class="btn btn-primary">
<span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>编辑
</button>
</div>
<div class="panel panel-default terminal-pannel">
<div class="panel-heading">
查询结果
</div>
<div class="panel-body table-body">
<table></table>
</div>
</div>
@section modal {
<div class="modal fade" id="dialogNew" tabindex="-1" role="dialog" data-backdrop="static" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog terminal-dialog">
<div class="modal-content">
<div class="modal-header terminal-dialog-header">
<button type="button" class="close terminal-close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title" id="myModalLabel">输入口编辑窗口</h4>
</div>
<div class="modal-body">
<form class="form-horizontal terminal-form-group" id="dataForm" name="dataForm" role="form">
<div class="form-group">
<label class="control-label col-sm-2" for="terminalName">输入口名称</label>
<div class="col-sm-4">
<input type="text" class="form-control" id="terminalName" name="terminalName" size="20" maxlength="50" />
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="clientIP">工控机IP</label>
<div class="col-sm-4">
<input type="text" class="form-control" id="clientIP" name="clientIP" size="20" maxlength="15" />
</div>
<label class="control-label col-sm-2" for="clientPort">工控机Port</label>
<div class="col-sm-4">
<input type="text" class="form-control" id="clientPort" name="clientPort" size="20" maxlength="5" />
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="serverIP">服务器IP</label>
<div class="col-sm-4">
<input type="text" class="form-control" id="serverIP" name="serverIP" size="20" maxlength="15" />
</div>
<label class="control-label col-sm-2" for="serverPort">服务器Port</label>
<div class="col-sm-4">
<input type="text" class="form-control" id="serverPort" name="serverPort" size="20" maxlength="5" />
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="deviceIP">比对设备IP</label>
<div class="col-sm-4">
<input type="text" class="form-control" id="deviceIP" name="deviceIP" size="20" maxlength="15" />
</div>
<label class="control-label col-sm-2" for="devicePort">比对设备Port</label>
<div class="col-sm-4">
<input type="text" class="form-control" id="devicePort" name="devicePort" size="20" maxlength="5" />
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="databaseName">数据库名称</label>
<div class="col-sm-4">
<input type="text" class="form-control" id="databaseName" name="databaseName" maxlength="50" />
</div>
<div class="col-sm-1" style="display:none;">
<input type="text" class="form-control" id="terminalId" />
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="databaseUserName">数据库用户名</label>
<div class="col-sm-4">
<input type="text" class="form-control" id="databaseUserName" name="databaseUserName" size="20" maxlength="50" />
</div>
<label class="control-label col-sm-2" for="databasePassword">数据库密码</label>
<div class="col-sm-4">
<input type="text" class="form-control" id="databasePassword" name="databasePassword" size="20" maxlength="50" />
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">
关闭
</button>
<button type="button" class="btn btn-primary" id="btnSubmit">
提交更改
</button>
</div>
</div>
</div>
</div>
}

View File

@ -1,61 +1,61 @@
@model Bootstrap.Admin.Models.HeaderBarModel @model Bootstrap.Admin.Models.HeaderBarModel
<!--header start--> <!--header start-->
<header class="header white-bg"> <header class="header white-bg">
<div class="sidebar-toggle-box"> <div class="sidebar-toggle-box">
<div class="fa fa-bars tooltips" data-placement="right" data-original-title="展开/收起 导航条"></div> <div class="fa fa-bars tooltips" data-placement="right" data-original-title="展开/收起 导航条"></div>
</div> </div>
<!--logo start--> <!--logo start-->
<a href="#" class="logo">后台管理系统</a> <a href="#" class="logo">后台管理系统</a>
<!--logo end--> <!--logo end-->
<nav class="navbar lgbMenu @Model.ShowMenu"> <nav class="navbar lgbMenu @Model.ShowMenu">
<div id="navbar" class="navbar-collapse collapse"> <div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav"> <ul class="nav navbar-nav">
<li class="dropdown"> <li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">参数设置 <span class="caret"></span></a> <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">参数设置 <span class="caret"></span></a>
<ul class="dropdown-menu" role="menu"> <ul class="dropdown-menu" role="menu">
<li><a href="~/Home/Rules">规则设置</a></li> <li><a href="~/Home/Rules">规则设置</a></li>
<li class="divider"></li> <li class="divider"></li>
<li><a href="~/Home/Terminals">输入口设置</a></li> <li><a href="~/Home/Terminals">输入口设置</a></li>
</ul> </ul>
</li> </li>
</ul> </ul>
</div><!--/.nav-collapse --> </div><!--/.nav-collapse -->
</nav> </nav>
<div class="top-nav"> <div class="top-nav">
<!--search & user info start--> <!--search & user info start-->
<ul class="nav pull-right top-menu"> <ul class="nav pull-right top-menu">
<li> <li>
<input type="text" class="form-control search" placeholder="搜索"> <input type="text" class="form-control search" placeholder="搜索">
</li> </li>
<!-- user login dropdown start--> <!-- user login dropdown start-->
<li class="dropdown"> <li class="dropdown">
<a data-toggle="dropdown" class="dropdown-toggle" href="#"> <a data-toggle="dropdown" class="dropdown-toggle" href="#">
<img alt="" src="../content/images/logo6.jpg"> <img alt="" src="../content/images/logo6.jpg">
<span class="username">@Model.UserName</span> <span class="username">@Model.UserName</span>
<b class="caret"></b> <b class="caret"></b>
</a> </a>
<ul class="dropdown-menu extended logout"> <ul class="dropdown-menu extended logout">
<div class="log-arrow-up"></div> <div class="log-arrow-up"></div>
<li><a href="#"><i class=" fa fa-suitcase"></i> 个人中心</a></li> <li><a href="#"><i class=" fa fa-suitcase"></i> 个人中心</a></li>
<li><a href="#"><i class="fa fa-cog"></i> 设置</a></li> <li><a href="~/Admin"><i class="fa fa-cog"></i> 设置</a></li>
<li><a href="#"><i class="fa fa-bell-o"></i> 通知</a></li> <li><a href="#"><i class="fa fa-bell-o"></i> 通知</a></li>
<li><a href="~/Home/Logout"><i class="fa fa-key"></i> 注销</a></li> <li><a href="~/Home/Logout"><i class="fa fa-key"></i> 注销</a></li>
</ul> </ul>
</li> </li>
<!-- user login dropdown end --> <!-- user login dropdown end -->
</ul> </ul>
<!--search & user info end--> <!--search & user info end-->
</div> </div>
<!--breadcrumbs start --> <!--breadcrumbs start -->
<div class="lgbBreadcrumb"> <div class="lgbBreadcrumb">
<ul class="breadcrumb"> <ul class="breadcrumb">
<li><a href="@Url.Content(Model.HomeUrl)"><i class="fa fa-home"></i>首页</a></li> <li><a href="@Url.Content(Model.HomeUrl)"><i class="fa fa-home"></i>首页</a></li>
@if (!string.IsNullOrEmpty(Model.BreadcrumbName)) @if (!string.IsNullOrEmpty(Model.BreadcrumbName))
{ {
<li>@Model.BreadcrumbName</li> <li>@Model.BreadcrumbName</li>
} }
</ul> </ul>
</div> </div>
<!--breadcrumbs end --> <!--breadcrumbs end -->
</header> </header>
<!--header end--> <!--header end-->

View File

@ -18,16 +18,13 @@
</appSettings> </appSettings>
<connectionStrings> <connectionStrings>
<add name="SQL" providerName="System.Data.SqlClient" connectionString="Data Source=.;Initial Catalog=ExtendedChecker;User ID=sa;Password=sa"/> <add name="SQL" providerName="System.Data.SqlClient" connectionString="Data Source=.;Initial Catalog=BootstrapAdmin;User ID=sa;Password=sa"/>
</connectionStrings> </connectionStrings>
<cacheManager> <cacheManager>
<add key="TerminalData-CodeTerminalHelper" interval="600" desc="输入口信息缓存" /> <add key="TerminalData-CodeTerminalHelper" interval="600" desc="输入口信息缓存" />
<add key="GroupData-CodeGroupHelper" interval="600" desc="群组信息缓存" /> <add key="GroupData-CodeGroupHelper" interval="600" desc="群组信息缓存" />
<add key="UserData-CodeUserHelper" interval="600" desc="用户信息缓存" /> <add key="UserData-CodeUserHelper" interval="600" desc="用户信息缓存" />
</cacheManager> </cacheManager>
<cacheManagerList> <cacheManagerList>

View File

@ -61,8 +61,6 @@
<Compile Include="GroupHelper.cs" /> <Compile Include="GroupHelper.cs" />
<Compile Include="Menu.cs" /> <Compile Include="Menu.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Terminal.cs" />
<Compile Include="TerminalHelper.cs" />
<Compile Include="User.cs" /> <Compile Include="User.cs" />
<Compile Include="UserHelper.cs" /> <Compile Include="UserHelper.cs" />
</ItemGroup> </ItemGroup>

View File

@ -1,77 +0,0 @@
namespace Bootstrap.DataAccess
{
/// <summary>
///
/// </summary>
public class Terminal
{
/// <summary>
/// 获得/设置 输入口主键ID
/// </summary>
public int ID { get; set; }
/// <summary>
/// 获得/设置 输入口名称
/// </summary>
public string Name { get; set; }
/// <summary>
/// 获得/设置 公共机IP
/// </summary>
public string ClientIP { get; set; }
/// <summary>
/// 获得/设置 公共机Port
/// </summary>
public int ClientPort { get; set; }
/// <summary>
/// 获得/设置 服务器IP
/// </summary>
public string ServerIP { get; set; }
/// <summary>
/// 获得/设置 服务器Port
/// </summary>
public int ServerPort { get; set; }
/// <summary>
/// 获得/设置 比对设备IP
/// </summary>
public string DeviceIP { get; set; }
/// <summary>
/// 获得/设置 比对设备Port
/// </summary>
public int DevicePort { get; set; }
/// <summary>
/// 获得/设置 数据库名称
/// </summary>
public string DatabaseName { get; set; }
/// <summary>
/// 获得/设置 数据库用户名
/// </summary>
public string DatabaseUserName { get; set; }
/// <summary>
/// 获得/设置 数据库密码
/// </summary>
public string DatabasePassword { get; set; }
/// <summary>
/// 获得/设置 输入口状态 真为开启,假为停止
/// </summary>
public bool Status { get; set; }
/// <summary>
/// 获得/设置 规则名称
/// </summary>
public string RuleName { get; set; }
/// <summary>
/// 获得/设置 规则ID
/// </summary>
public int RuleID { get; set; }
/// <summary>
/// 获得/设置 与其相关联的DataGridViewRowIndex
/// </summary>
public int RowIndex { get; set; }
/// <summary>
/// 获得/设置 错误描述信息
/// </summary>
public string Error { get; set; }
/// <summary>
/// 获得/设置 条码信息
/// </summary>
public string BarCode { get; set; }
}
}

View File

@ -1,173 +0,0 @@
using Longbow;
using Longbow.Caching;
using Longbow.Caching.Configuration;
using Longbow.Data;
using Longbow.ExceptionManagement;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Globalization;
using System.Linq;
namespace Bootstrap.DataAccess
{
public static class TerminalHelper
{
private const string TerminalDataKey = "TerminalData-CodeTerminalHelper";
/// <summary>
/// 查询所有输入口
/// </summary>
/// <param name="pIds"></param>
/// <returns></returns>
public static IEnumerable<Terminal> RetrieveTerminals(string tId = null)
{
string sql = "select t.*, tc.RuleID, r.Name RuleName from Terminals t left join TerminalRuleConfig tc on t.ID = tc.TerminalId left join Rules r on tc.RuleId = r.Id order by t.Name";
var ret = CacheManager.GetOrAdd(TerminalDataKey, CacheSection.RetrieveIntervalByKey(TerminalDataKey), key =>
{
List<Terminal> Terminals = new List<Terminal>();
DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql);
try
{
using (DbDataReader reader = DBAccessManager.SqlDBAccess.ExecuteReader(cmd))
{
while (reader.Read())
{
Terminals.Add(new Terminal()
{
ID = (int)reader[0],
Name = (string)reader[1],
ClientIP = (string)reader[2],
ClientPort = (int)reader[3],
ServerIP = (string)reader[4],
ServerPort = (int)reader[5],
DeviceIP = (string)reader[6],
DevicePort = (int)reader[7],
DatabaseName = LgbConvert.ReadValue(reader[8], string.Empty),
DatabaseUserName = LgbConvert.ReadValue(reader[9], string.Empty),
DatabasePassword = LgbConvert.ReadValue(reader[10], string.Empty),
Status = LgbConvert.ReadValue(reader[11], false),
RuleID = LgbConvert.ReadValue(reader[12], 0),
RuleName = LgbConvert.ReadValue(reader[13], string.Empty)
});
}
}
}
catch (Exception ex) { ExceptionManager.Publish(ex); }
return Terminals;
}, CacheSection.RetrieveDescByKey(TerminalDataKey));
return string.IsNullOrEmpty(tId) ? ret : ret.Where(t => tId.Equals(t.ID.ToString(), StringComparison.OrdinalIgnoreCase));
}
/// <summary>
/// 删除输入口
/// </summary>
/// <param name="ids"></param>
public static void DeleteTerminal(string ids)
{
if (string.IsNullOrEmpty(ids) || ids.Contains("'")) return;
string sql = string.Format(CultureInfo.InvariantCulture, "Delete from Terminals where ID in ({0})", ids);
using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql))
{
DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd);
ClearCache();
}
}
/// <summary>
/// 保存新建/更新的输入口信息
/// </summary>
/// <param name="p"></param>
/// <returns></returns>
public static bool SaveTerminal(Terminal p)
{
if (p == null) throw new ArgumentNullException("p");
bool ret = false;
if (p.Name.Length > 50) p.Name.Substring(0, 50);
if (p.ClientIP.Length > 15) p.ClientIP.Substring(0, 15);
p.ClientPort = Math.Max(0, p.ClientPort);
if (p.ServerIP.Length > 15) p.ServerIP.Substring(0, 15);
p.ServerPort = Math.Max(1, p.ServerPort);
if (p.DeviceIP.Length > 15) p.DeviceIP.Substring(0, 15);
p.DevicePort = Math.Max(1, p.DevicePort);
if (!string.IsNullOrEmpty(p.DatabaseName) && p.DatabaseName.Length > 50) p.DatabaseName = p.DatabaseName.Substring(0, 50);
if (!string.IsNullOrEmpty(p.DatabaseUserName) && p.DatabaseUserName.Length > 50) p.DatabaseUserName = p.DatabaseUserName.Substring(0, 50);
if (!string.IsNullOrEmpty(p.DatabasePassword) && p.DatabasePassword.Length > 50) p.DatabasePassword = p.DatabasePassword.Substring(0, 50);
string sql = p.ID == 0 ?
"Insert Into Terminals (Name, ClientIP, ClientPort, ServerIP, ServerPort, DeviceIP, DevicePort, DatabaseName, DatabaseUserName, DatabasePassword) Values (@Name, @ClientIP, @ClientPort, @ServerIP, @ServerPort, @DeviceIP, @DevicePort, @DatabaseName, @DatabaseUserName, @DatabasePassword)" :
"Update Terminals set Name = @Name, ClientIP = @ClientIP, ClientPort = @ClientPort, ServerIP = @ServerIP, ServerPort = @ServerPort, DeviceIP = @DeviceIP, DevicePort = @DevicePort, DatabaseName = @DatabaseName, DatabaseUserName = @DatabaseUserName, DatabasePassword = @DatabasePassword 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("@Name", p.Name, ParameterDirection.Input));
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@ClientIP", p.ClientIP, ParameterDirection.Input));
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@ClientPort", p.ClientPort, ParameterDirection.Input));
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@ServerIP", p.ServerIP, ParameterDirection.Input));
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@ServerPort", p.ServerPort, ParameterDirection.Input));
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@DeviceIP", p.DeviceIP, ParameterDirection.Input));
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@DevicePort", p.DevicePort, ParameterDirection.Input));
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@DatabaseName", DBAccess.ToDBValue(p.DatabaseName), ParameterDirection.Input));
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@DatabaseUserName", DBAccess.ToDBValue(p.DatabaseUserName), ParameterDirection.Input));
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@DatabasePassword", DBAccess.ToDBValue(p.DatabasePassword), ParameterDirection.Input));
DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd);
}
ret = true;
ClearCache();
}
catch (DbException ex)
{
ExceptionManager.Publish(ex);
}
return ret;
}
// 更新缓存
private static void ClearCache()
{
CacheManager.Clear(key => key.Contains("TerminalData-"));
}
/// <summary>
///
/// </summary>
/// <param name="terminalId"></param>
/// <param name="ruleId"></param>
public static void StartTerminal(int terminalId, int ruleId)
{
try
{
using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.StoredProcedure, "Proc_StartTerminal"))
{
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@tId", terminalId, ParameterDirection.Input));
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@rId", ruleId, ParameterDirection.Input));
DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd);
}
}
catch (DbException ex)
{
ExceptionManager.Publish(ex);
}
}
/// <summary>
///
/// </summary>
/// <param name="terminalId"></param>
public static void StopTerminal(int terminalId)
{
try
{
using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.StoredProcedure, "Proc_StopTerminal"))
{
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@tId", terminalId, ParameterDirection.Input));
DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd);
}
}
catch (DbException ex)
{
ExceptionManager.Publish(ex);
}
}
}
}

View File

@ -38,9 +38,7 @@ namespace Bootstrap.DataAccess
Users.Add(new User() Users.Add(new User()
{ {
ID = (int)reader[0], ID = (int)reader[0],
UserName = (string)reader[1], UserName = (string)reader[1]
Password = (string)reader[2],
PassSalt = (string)reader[3],
}); });
} }
} }
@ -54,15 +52,25 @@ namespace Bootstrap.DataAccess
/// 删除用户 /// 删除用户
/// </summary> /// </summary>
/// <param name="ids"></param> /// <param name="ids"></param>
public static void DeleteUser(string ids) public static bool DeleteUser(string ids)
{ {
if (string.IsNullOrEmpty(ids) || ids.Contains("'")) return; bool ret = false;
string sql = string.Format(CultureInfo.InvariantCulture, "Delete from Users where ID in ({0})", ids); if (string.IsNullOrEmpty(ids) || ids.Contains("'")) return ret;
using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql)) try
{ {
DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd); string sql = string.Format(CultureInfo.InvariantCulture, "Delete from Users where ID in ({0})", ids);
using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql))
{
DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd);
}
ClearCache(); ClearCache();
ret = true;
} }
catch (Exception ex)
{
ExceptionManager.Publish(ex);
}
return ret;
} }
/// <summary> /// <summary>
/// 保存新建/更新的用户信息 /// 保存新建/更新的用户信息
@ -71,11 +79,11 @@ namespace Bootstrap.DataAccess
/// <returns></returns> /// <returns></returns>
public static bool SaveUser(User p) public static bool SaveUser(User p)
{ {
//TODO: 这里这样处理明显不行,需要用非对称加密算法进行混淆加密后存储到数据库中
if (p == null) throw new ArgumentNullException("p"); if (p == null) throw new ArgumentNullException("p");
bool ret = false; bool ret = false;
if (p.UserName.Length > 50) p.UserName.Substring(0, 50); if (p.UserName.Length > 50) p.UserName.Substring(0, 50);
if (p.Password.Length > 50) p.Password.Substring(0, 50); if (p.Password.Length > 50) p.Password.Substring(0, 50);
if (p.PassSalt.Length > 50) p.PassSalt.Substring(0, 50);
string sql = p.ID == 0 ? string sql = p.ID == 0 ?
"Insert Into Users (UserName, Password, PassSalt) Values (@UserName, @Password, @PassSalt)" : "Insert Into Users (UserName, Password, PassSalt) Values (@UserName, @Password, @PassSalt)" :
"Update Users set UserName = @UserName, Password = @Password, PassSalt = @PassSalt where ID = @ID"; "Update Users set UserName = @UserName, Password = @Password, PassSalt = @PassSalt where ID = @ID";
@ -86,7 +94,7 @@ namespace Bootstrap.DataAccess
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@ID", p.ID, ParameterDirection.Input)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@ID", p.ID, ParameterDirection.Input));
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@UserName", p.UserName, ParameterDirection.Input)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@UserName", p.UserName, ParameterDirection.Input));
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@Password", p.Password, ParameterDirection.Input)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@Password", p.Password, ParameterDirection.Input));
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@PassSalt", p.PassSalt, ParameterDirection.Input)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@PassSalt", DBNull.Value, ParameterDirection.Input));
DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd); DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd);
} }
ret = true; ret = true;

View File

@ -9,7 +9,7 @@
</configSections> </configSections>
<connectionStrings> <connectionStrings>
<add name="SQL" providerName="System.Data.SqlClient" connectionString="Data Source=.;Initial Catalog=ExtendedChecker;User ID=sa;Password=sa"/> <add name="SQL" providerName="System.Data.SqlClient" connectionString="Data Source=.;Initial Catalog=BootstrapAdmin;User ID=sa;Password=sa"/>
</connectionStrings> </connectionStrings>
<cacheManager> <cacheManager>

View File

@ -52,13 +52,9 @@
</Otherwise> </Otherwise>
</Choose> </Choose>
<ItemGroup> <ItemGroup>
<Compile Include="TerminalHelperTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="GroupHelperTests.cs" /> <Compile Include="GroupHelperTests.cs" />
<Compile Include="UserHelperTests.cs" /> <Compile Include="UserHelperTests.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Bootstrap.DataAccess\Bootstrap.DataAccess.csproj"> <ProjectReference Include="..\Bootstrap.DataAccess\Bootstrap.DataAccess.csproj">

View File

@ -1,18 +0,0 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Linq;
namespace Bootstrap.DataAccess.Tests
{
[TestClass()]
public class MenuTests
{
[TestMethod()]
public void RetrieveMenusTest()
{
var result = TerminalHelper.RetrieveTerminals("1");
Assert.IsTrue((result.Count() == 0 || result.Count() == 1), "带有参数的TerminalHelper.RetrieveTerminals方法调用失败请检查数据库连接或者数据库SQL语句");
result = TerminalHelper.RetrieveTerminals();
Assert.IsTrue(result.Count() >= 0, "不带参数的TerminalHelper.RetrieveTerminals方法调用失败请检查数据库连接或者数据库SQL语句");
}
}
}

View File

@ -1,55 +1,47 @@
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Linq; using System.Linq;
namespace Bootstrap.DataAccess.Tests namespace Bootstrap.DataAccess.Tests
{ {
[TestClass] [TestClass]
public class UserHelperTests public class UserHelperTests
{ {
[TestMethod] [TestMethod]
public void RetrieveUsersTest() public void RetrieveUsersTest()
{ {
var result = UserHelper.RetrieveUsers("1"); var result = UserHelper.RetrieveUsers("1");
Assert.IsTrue((result.Count() == 0 || result.Count() == 1), "带有参数的UserHelper.RetrieveUsers方法调用失败请检查数据库连接或者数据库SQL语句"); Assert.IsTrue((result.Count() == 0 || result.Count() == 1), "带有参数的UserHelper.RetrieveUsers方法调用失败请检查数据库连接或者数据库SQL语句");
result = UserHelper.RetrieveUsers(); result = UserHelper.RetrieveUsers();
Assert.IsTrue(result.Count() >= 0, "不带参数的UserHelper.RetrieveUsers方法调用失败请检查数据库连接或者数据库SQL语句"); Assert.IsTrue(result.Count() >= 0, "不带参数的UserHelper.RetrieveUsers方法调用失败请检查数据库连接或者数据库SQL语句");
} }
[TestMethod] [TestMethod]
public void DeleteUserTest() public void DeleteUserTest()
{ {
string ids = "2"; //TODO: Delete方法没有返回值自己想想做一个返回值即可
try Assert.IsTrue(UserHelper.DeleteUser("1,2"), "带有参数的UserHelper.DeleteUserTest方法调用失败请检查数据库连接或者数据库SQL语句");
{ Assert.IsFalse(UserHelper.DeleteUser(string.Empty), "参数为空字符串的UserHelper.DeleteUserTest方法调用失败请检查数据库连接或者数据库SQL语句");
UserHelper.DeleteUser(ids); }
Assert.IsTrue(true);
} [TestMethod]
catch public void SaveUserTest()
{ {
Assert.IsTrue(false,"带有参数的UserHelper.DeleteUserTest方法调用失败请检查数据库连接或者数据库SQL语句"); //TODO: 两个提示一模一样完全不知道哪里出了问题,本单元测试未通过
} User users = new User();
users.ID = 0;
} users.UserName = "liqi";
users.Password = "123";
[TestMethod] users.PassSalt = "123";
public void SaveUserTest() var result = UserHelper.SaveUser(users);
{ Assert.IsTrue(result == true, "带有参数的UserHelper.SaveUser方法中新建用户信息失败请检查数据库连接或者数据库SQL语句");
User users = new User();
users.ID = 0; User users1 = new User();
users.UserName = "liqi"; users1.ID = 1;
users.Password = "123"; users1.UserName = "Lily";
users.PassSalt = "123"; users1.Password = "123456";
var result = UserHelper.SaveUser(users); users1.PassSalt = "123456";
Assert.IsTrue(result == true, "带有参数的UserHelper.SaveUser方法中新建用户信息失败请检查数据库连接或者数据库SQL语句"); result = UserHelper.SaveUser(users1);
Assert.IsTrue(result == true, "带有参数的UserHelper.SaveUser方法中更新用户信息失败请检查数据库连接或者数据库SQL语句");
User users1 = new User(); }
users1.ID = 1; }
users1.UserName = "Lily"; }
users1.Password = "123456";
users1.PassSalt = "123456";
result = UserHelper.SaveUser(users1);
Assert.IsTrue(result == true, "带有参数的UserHelper.SaveUser方法中更新用户信息失败请检查数据库连接或者数据库SQL语句");
}
}
}

View File

@ -7,10 +7,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Bootstrap.DataAccess", "Boo
EndProject EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "sql", "sql", "{87319AF5-7C40-4362-B67C-35F9DD737DB4}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "sql", "sql", "{87319AF5-7C40-4362-B67C-35F9DD737DB4}"
ProjectSection(SolutionItems) = preProject ProjectSection(SolutionItems) = preProject
DatabaseScripts\ExtendedChecker.sql = DatabaseScripts\ExtendedChecker.sql
DatabaseScripts\Install.sql = DatabaseScripts\Install.sql DatabaseScripts\Install.sql = DatabaseScripts\Install.sql
DatabaseScripts\Proc_StartTerminal.sql = DatabaseScripts\Proc_StartTerminal.sql
DatabaseScripts\Proc_StopTerminal.sql = DatabaseScripts\Proc_StopTerminal.sql
DatabaseScripts\Readme.txt = DatabaseScripts\Readme.txt DatabaseScripts\Readme.txt = DatabaseScripts\Readme.txt
EndProjectSection EndProjectSection
EndProject EndProject

View File

@ -1,147 +1,144 @@
USE [master] USE [master]
GO GO
Create database [ExtendedChecker] Create database [BootstrapAdmin]
GO GO
ALTER DATABASE [ExtendedChecker] SET RECOVERY SIMPLE ALTER DATABASE [BootstrapAdmin] SET RECOVERY SIMPLE
GO GO
ALTER DATABASE [ExtendedChecker] SET AUTO_SHRINK ON ALTER DATABASE [BootstrapAdmin] SET AUTO_SHRINK ON
GO GO
USE [ExtendedChecker] USE [BootstrapAdmin]
GO GO
/****** Object: Table [dbo].[Rules] Script Date: 9/1/2016 7:44:10 PM ******/ /****** Object: Table [dbo].[Users] Script Date: 10/22/2016 09:44:03 ******/
SET ANSI_NULLS ON SET ANSI_NULLS ON
GO GO
SET QUOTED_IDENTIFIER ON SET QUOTED_IDENTIFIER ON
GO GO
CREATE TABLE [dbo].[Terminals]( CREATE TABLE [dbo].[Users](
[ID] [int] IDENTITY(1,1) NOT NULL, [ID] [int] IDENTITY(1,1) NOT NULL,
[Name] [nvarchar](50) NOT NULL, [UserName] [nvarchar](50) NULL,
[ClientIP] [varchar](15) NOT NULL, [Password] [nvarchar](50) NULL,
[ClientPort] [int] NOT NULL, [PassSalt] [nvarchar](50) NULL,
[ServerIP] [varchar](15) NOT NULL, CONSTRAINT [PK_Users] PRIMARY KEY CLUSTERED
[ServerPort] [int] NOT NULL,
[DeviceIP] [varchar](15) NOT NULL,
[DevicePort] [int] NOT NULL,
[DatabaseName] [varchar](50) NULL,
[DatabaseUserName] [varchar](50) NULL,
[DatabasePassword] [varchar](50) NULL,
[Status] [bit] NOT NULL,
CONSTRAINT [PK_Terminal] PRIMARY KEY CLUSTERED
( (
[ID] ASC [ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] ) ON [PRIMARY]
GO GO
SET ANSI_PADDING OFF EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Users', @level2type=N'COLUMN',@level2name=N'ID'
GO GO
/****** Object: Table [dbo].[TerminalRuleConfig] Script Date: 09/06/2016 14:31:10 ******/ EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'用户名' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Users', @level2type=N'COLUMN',@level2name=N'UserName'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'密码' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Users', @level2type=N'COLUMN',@level2name=N'Password'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'验证' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Users', @level2type=N'COLUMN',@level2name=N'PassSalt'
GO
/****** Object: Table [dbo].[UserRole] Script Date: 10/22/2016 09:44:03 ******/
SET ANSI_NULLS ON SET ANSI_NULLS ON
GO GO
SET QUOTED_IDENTIFIER ON SET QUOTED_IDENTIFIER ON
GO GO
CREATE TABLE [dbo].[TerminalRuleConfig]( CREATE TABLE [dbo].[UserRole](
[TerminalID] [int] NOT NULL,
[RuleID] [int] NOT NULL
) ON [PRIMARY]
GO
/****** Object: Table [dbo].[ScanInventory] Script Date: 09/06/2016 14:31:10 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[ScanInventory](
[ID] [int] IDENTITY(1,1) NOT NULL, [ID] [int] IDENTITY(1,1) NOT NULL,
[BarCode] [varchar](32) NOT NULL, [UserID] [int] NOT NULL,
[TerminalID] [int] NOT NULL, [RoleID] [int] NOT NULL,
[ScanTime] [datetime] NOT NULL, CONSTRAINT [PK_UserRole] PRIMARY KEY CLUSTERED
[BarCodeType] [int] NOT NULL,
CONSTRAINT [PK_ScanInventory] PRIMARY KEY CLUSTERED
( (
[ID] ASC [ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] ) ON [PRIMARY]
GO GO
SET ANSI_PADDING OFF EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'UserRole', @level2type=N'COLUMN',@level2name=N'ID'
GO GO
/****** Object: Table [dbo].[Rules] Script Date: 09/06/2016 14:31:10 ******/ EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'用户ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'UserRole', @level2type=N'COLUMN',@level2name=N'UserID'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'角色ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'UserRole', @level2type=N'COLUMN',@level2name=N'RoleID'
GO
/****** Object: Table [dbo].[UserGroup] Script Date: 10/22/2016 09:44:03 ******/
SET ANSI_NULLS ON SET ANSI_NULLS ON
GO GO
SET QUOTED_IDENTIFIER ON SET QUOTED_IDENTIFIER ON
GO GO
CREATE TABLE [dbo].[Rules]( CREATE TABLE [dbo].[UserGroup](
[ID] [int] IDENTITY(1,1) NOT NULL, [ID] [int] IDENTITY(1,1) NOT NULL,
[Name] [nvarchar](200) NOT NULL, [UserID] [int] NOT NULL,
[Memo] [nvarchar](2000) NULL, [GroupID] [int] NOT NULL,
[Interval] [int] NOT NULL, CONSTRAINT [PK_UserGroup] PRIMARY KEY CLUSTERED
[Enabled] [bit] NOT NULL,
CONSTRAINT [PK_Rules] PRIMARY KEY CLUSTERED
( (
[ID] ASC [ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] ) ON [PRIMARY]
GO GO
/****** Object: Default [DF_Rules_Enabled] Script Date: 09/06/2016 14:31:10 ******/ EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'UserGroup', @level2type=N'COLUMN',@level2name=N'ID'
ALTER TABLE [dbo].[Rules] ADD CONSTRAINT [DF_Rules_Enabled] DEFAULT ((1)) FOR [Enabled]
GO GO
/****** Object: Default [DF_Terminals_Satus] Script Date: 09/06/2016 14:31:10 ******/ EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'用户ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'UserGroup', @level2type=N'COLUMN',@level2name=N'UserID'
ALTER TABLE [dbo].[Terminals] ADD CONSTRAINT [DF_Terminals_Satus] DEFAULT ((0)) FOR [Status]
GO GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'部门ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'UserGroup', @level2type=N'COLUMN',@level2name=N'GroupID'
GO
/****** Object: Table [dbo].[Roles] Script Date: 10/22/2016 09:44:03 ******/
SET ANSI_NULLS ON SET ANSI_NULLS ON
GO GO
SET QUOTED_IDENTIFIER ON SET QUOTED_IDENTIFIER ON
GO GO
-- ============================================= CREATE TABLE [dbo].[Roles](
-- Author: Argo Zhang [ID] [int] IDENTITY(1,1) NOT NULL,
-- Create date: 2016-09-06 [RoleName] [nvarchar](50) NULL,
-- Description: [Description] [nvarchar](500) NULL,
-- ============================================= CONSTRAINT [PK_Roles] PRIMARY KEY CLUSTERED
CREATE PROCEDURE Proc_StartTerminal (
-- Add the parameters for the stored procedure here [ID] ASC
@tId int, )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
@rId int ) ON [PRIMARY]
WITH ENCRYPTION
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
SET XACT_ABORT ON;
-- Insert statements for procedure here
delete from TerminalRuleConfig where TerminalID = @tId;
insert into TerminalRuleConfig (TerminalID, RuleID) values (@tId, @rId);
update Terminals set Status = 1 where Id = @tId;
END
GO GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Roles', @level2type=N'COLUMN',@level2name=N'ID'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'角色名称' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Roles', @level2type=N'COLUMN',@level2name=N'RoleName'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'描述' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Roles', @level2type=N'COLUMN',@level2name=N'Description'
GO
/****** Object: Table [dbo].[RoleGroup] Script Date: 10/22/2016 09:44:03 ******/
SET ANSI_NULLS ON SET ANSI_NULLS ON
GO GO
SET QUOTED_IDENTIFIER ON SET QUOTED_IDENTIFIER ON
GO GO
-- ============================================= CREATE TABLE [dbo].[RoleGroup](
-- Author: Argo Zhang [ID] [int] IDENTITY(1,1) NOT NULL,
-- Create date: 2016-09-06 [RoleID] [int] NOT NULL,
-- Description: [GroupID] [int] NOT NULL,
-- ============================================= CONSTRAINT [PK_RoleGroup] PRIMARY KEY CLUSTERED
CREATE PROCEDURE Proc_StopTerminal (
-- Add the parameters for the stored procedure here [ID] ASC
@tId int )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
WITH ENCRYPTION ) ON [PRIMARY]
AS GO
BEGIN EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'RoleGroup', @level2type=N'COLUMN',@level2name=N'ID'
-- SET NOCOUNT ON added to prevent extra result sets from GO
-- interfering with SELECT statements. EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'角色ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'RoleGroup', @level2type=N'COLUMN',@level2name=N'RoleID'
SET NOCOUNT ON; GO
SET XACT_ABORT ON; EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'部门ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'RoleGroup', @level2type=N'COLUMN',@level2name=N'GroupID'
-- Insert statements for procedure here GO
delete from TerminalRuleConfig where TerminalID = @tId; /****** Object: Table [dbo].[Groups] Script Date: 10/22/2016 09:44:03 ******/
update Terminals set Status = 0 where Id = @tId; SET ANSI_NULLS ON
END GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Groups](
[ID] [int] IDENTITY(1,1) NOT NULL,
[GroupName] [nvarchar](50) NULL,
[Description] [nvarchar](500) NULL,
CONSTRAINT [PK_Groups] PRIMARY KEY CLUSTERED
(
[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Groups', @level2type=N'COLUMN',@level2name=N'ID'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'部门名称' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Groups', @level2type=N'COLUMN',@level2name=N'GroupName'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'描述' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Groups', @level2type=N'COLUMN',@level2name=N'Description'
GO GO