diff --git a/Bootstrap.Admin/Views/Home/Rules.cshtml b/Bootstrap.Admin/Views/Home/Rules.cshtml
deleted file mode 100644
index ce095600..00000000
--- a/Bootstrap.Admin/Views/Home/Rules.cshtml
+++ /dev/null
@@ -1,137 +0,0 @@
-@model Bootstrap.Admin.Models.HeaderBarModel
-@{
- ViewBag.Title = "Rules";
- Layout = "~/Views/Shared/_Fix.cshtml";
-}
-@section Javascript {
-
-
-
-
-
-
-}
-@section header {
- @Html.Partial("Header", Model)
-}
-
-
-
-
-
-
-
-
-
-
-@section modal {
-
-}
\ No newline at end of file
diff --git a/Bootstrap.Admin/Views/Home/Terminals.cshtml b/Bootstrap.Admin/Views/Home/Terminals.cshtml
deleted file mode 100644
index 4aa1b629..00000000
--- a/Bootstrap.Admin/Views/Home/Terminals.cshtml
+++ /dev/null
@@ -1,137 +0,0 @@
-@model Bootstrap.Admin.Models.HeaderBarModel
-@{
- ViewBag.Title = "Terminals";
- Layout = "~/Views/Shared/_Normal.cshtml";
-}
-@section Javascript {
-
-
-
-
-
-
-}
-@section header {
- @Html.Partial("Header", Model)
-}
-
-
-
-
-
-
-
-
-
-
-@section modal {
-
-}
\ No newline at end of file
diff --git a/Bootstrap.Admin/Views/Shared/Header.cshtml b/Bootstrap.Admin/Views/Shared/Header.cshtml
index c5f3c327..359934cb 100644
--- a/Bootstrap.Admin/Views/Shared/Header.cshtml
+++ b/Bootstrap.Admin/Views/Shared/Header.cshtml
@@ -1,61 +1,61 @@
-@model Bootstrap.Admin.Models.HeaderBarModel
-
-
-
+@model Bootstrap.Admin.Models.HeaderBarModel
+
+
+
diff --git a/Bootstrap.Admin/Web.config b/Bootstrap.Admin/Web.config
index cca31ef6..ac66f347 100644
--- a/Bootstrap.Admin/Web.config
+++ b/Bootstrap.Admin/Web.config
@@ -18,16 +18,13 @@
-
+
-
-
-
diff --git a/Bootstrap.DataAccess/Bootstrap.DataAccess.csproj b/Bootstrap.DataAccess/Bootstrap.DataAccess.csproj
index 37529f81..367e5fc8 100644
--- a/Bootstrap.DataAccess/Bootstrap.DataAccess.csproj
+++ b/Bootstrap.DataAccess/Bootstrap.DataAccess.csproj
@@ -61,8 +61,6 @@
-
-
diff --git a/Bootstrap.DataAccess/Terminal.cs b/Bootstrap.DataAccess/Terminal.cs
deleted file mode 100644
index d772bd69..00000000
--- a/Bootstrap.DataAccess/Terminal.cs
+++ /dev/null
@@ -1,77 +0,0 @@
-namespace Bootstrap.DataAccess
-{
- ///
- ///
- ///
- public class Terminal
- {
- ///
- /// 获得/设置 输入口主键ID
- ///
- public int ID { get; set; }
- ///
- /// 获得/设置 输入口名称
- ///
- public string Name { get; set; }
- ///
- /// 获得/设置 公共机IP
- ///
- public string ClientIP { get; set; }
- ///
- /// 获得/设置 公共机Port
- ///
- public int ClientPort { get; set; }
- ///
- /// 获得/设置 服务器IP
- ///
- public string ServerIP { get; set; }
- ///
- /// 获得/设置 服务器Port
- ///
- public int ServerPort { get; set; }
- ///
- /// 获得/设置 比对设备IP
- ///
- public string DeviceIP { get; set; }
- ///
- /// 获得/设置 比对设备Port
- ///
- public int DevicePort { get; set; }
- ///
- /// 获得/设置 数据库名称
- ///
- public string DatabaseName { get; set; }
- ///
- /// 获得/设置 数据库用户名
- ///
- public string DatabaseUserName { get; set; }
- ///
- /// 获得/设置 数据库密码
- ///
- public string DatabasePassword { get; set; }
- ///
- /// 获得/设置 输入口状态 真为开启,假为停止
- ///
- public bool Status { get; set; }
- ///
- /// 获得/设置 规则名称
- ///
- public string RuleName { get; set; }
- ///
- /// 获得/设置 规则ID
- ///
- public int RuleID { get; set; }
- ///
- /// 获得/设置 与其相关联的DataGridViewRowIndex
- ///
- public int RowIndex { get; set; }
- ///
- /// 获得/设置 错误描述信息
- ///
- public string Error { get; set; }
- ///
- /// 获得/设置 条码信息
- ///
- public string BarCode { get; set; }
- }
-}
diff --git a/Bootstrap.DataAccess/TerminalHelper.cs b/Bootstrap.DataAccess/TerminalHelper.cs
deleted file mode 100644
index 1eb2d4b5..00000000
--- a/Bootstrap.DataAccess/TerminalHelper.cs
+++ /dev/null
@@ -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";
-
- ///
- /// 查询所有输入口
- ///
- ///
- ///
- public static IEnumerable 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 Terminals = new List();
- 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));
- }
-
- ///
- /// 删除输入口
- ///
- ///
- 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();
- }
- }
-
- ///
- /// 保存新建/更新的输入口信息
- ///
- ///
- ///
- 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-"));
- }
- ///
- ///
- ///
- ///
- ///
- 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);
- }
- }
- ///
- ///
- ///
- ///
- 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);
- }
- }
- }
-}
diff --git a/Bootstrap.DataAccess/UserHelper.cs b/Bootstrap.DataAccess/UserHelper.cs
index c20e1b8b..0ebbd348 100644
--- a/Bootstrap.DataAccess/UserHelper.cs
+++ b/Bootstrap.DataAccess/UserHelper.cs
@@ -38,9 +38,7 @@ namespace Bootstrap.DataAccess
Users.Add(new User()
{
ID = (int)reader[0],
- UserName = (string)reader[1],
- Password = (string)reader[2],
- PassSalt = (string)reader[3],
+ UserName = (string)reader[1]
});
}
}
@@ -54,15 +52,25 @@ namespace Bootstrap.DataAccess
/// 删除用户
///
///
- public static void DeleteUser(string ids)
+ public static bool DeleteUser(string ids)
{
- if (string.IsNullOrEmpty(ids) || ids.Contains("'")) return;
- string sql = string.Format(CultureInfo.InvariantCulture, "Delete from Users where ID in ({0})", ids);
- using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql))
+ bool ret = false;
+ if (string.IsNullOrEmpty(ids) || ids.Contains("'")) return ret;
+ 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();
+ ret = true;
}
+ catch (Exception ex)
+ {
+ ExceptionManager.Publish(ex);
+ }
+ return ret;
}
///
/// 保存新建/更新的用户信息
@@ -71,11 +79,11 @@ namespace Bootstrap.DataAccess
///
public static bool SaveUser(User p)
{
+ //TODO: 这里这样处理明显不行,需要用非对称加密算法进行混淆加密后存储到数据库中
if (p == null) throw new ArgumentNullException("p");
bool ret = false;
if (p.UserName.Length > 50) p.UserName.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 ?
"Insert Into Users (UserName, Password, PassSalt) Values (@UserName, @Password, @PassSalt)" :
"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("@UserName", p.UserName, 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);
}
ret = true;
diff --git a/Bootstrap.DataAccessTests/App.config b/Bootstrap.DataAccessTests/App.config
index df96ee28..dabe6101 100644
--- a/Bootstrap.DataAccessTests/App.config
+++ b/Bootstrap.DataAccessTests/App.config
@@ -9,7 +9,7 @@
-
+
diff --git a/Bootstrap.DataAccessTests/Bootstrap.DataAccessTests.csproj b/Bootstrap.DataAccessTests/Bootstrap.DataAccessTests.csproj
index aaa90f16..13377adc 100644
--- a/Bootstrap.DataAccessTests/Bootstrap.DataAccessTests.csproj
+++ b/Bootstrap.DataAccessTests/Bootstrap.DataAccessTests.csproj
@@ -52,13 +52,9 @@
-
-
-
-
diff --git a/Bootstrap.DataAccessTests/TerminalHelperTests.cs b/Bootstrap.DataAccessTests/TerminalHelperTests.cs
deleted file mode 100644
index dfd350b2..00000000
--- a/Bootstrap.DataAccessTests/TerminalHelperTests.cs
+++ /dev/null
@@ -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语句");
- }
- }
-}
\ No newline at end of file
diff --git a/Bootstrap.DataAccessTests/UserHelperTests.cs b/Bootstrap.DataAccessTests/UserHelperTests.cs
index 1fd8760a..214eff46 100644
--- a/Bootstrap.DataAccessTests/UserHelperTests.cs
+++ b/Bootstrap.DataAccessTests/UserHelperTests.cs
@@ -1,55 +1,47 @@
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using System.Linq;
-
-namespace Bootstrap.DataAccess.Tests
-{
- [TestClass]
- public class UserHelperTests
- {
- [TestMethod]
- public void RetrieveUsersTest()
- {
- var result = UserHelper.RetrieveUsers("1");
- Assert.IsTrue((result.Count() == 0 || result.Count() == 1), "带有参数的UserHelper.RetrieveUsers方法调用失败,请检查数据库连接或者数据库SQL语句");
- result = UserHelper.RetrieveUsers();
- Assert.IsTrue(result.Count() >= 0, "不带参数的UserHelper.RetrieveUsers方法调用失败,请检查数据库连接或者数据库SQL语句");
- }
-
- [TestMethod]
- public void DeleteUserTest()
- {
- string ids = "2";
- try
- {
- UserHelper.DeleteUser(ids);
- Assert.IsTrue(true);
- }
- catch
- {
- Assert.IsTrue(false,"带有参数的UserHelper.DeleteUserTest方法调用失败,请检查数据库连接或者数据库SQL语句");
- }
-
- }
-
- [TestMethod]
- public void SaveUserTest()
- {
- User users = new User();
- users.ID = 0;
- users.UserName = "liqi";
- users.Password = "123";
- users.PassSalt = "123";
- var result = UserHelper.SaveUser(users);
- 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语句");
- }
-
- }
-}
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using System.Linq;
+
+namespace Bootstrap.DataAccess.Tests
+{
+ [TestClass]
+ public class UserHelperTests
+ {
+ [TestMethod]
+ public void RetrieveUsersTest()
+ {
+ var result = UserHelper.RetrieveUsers("1");
+ Assert.IsTrue((result.Count() == 0 || result.Count() == 1), "带有参数的UserHelper.RetrieveUsers方法调用失败,请检查数据库连接或者数据库SQL语句");
+ result = UserHelper.RetrieveUsers();
+ Assert.IsTrue(result.Count() >= 0, "不带参数的UserHelper.RetrieveUsers方法调用失败,请检查数据库连接或者数据库SQL语句");
+ }
+
+ [TestMethod]
+ public void DeleteUserTest()
+ {
+ //TODO: Delete方法没有返回值,自己想想做一个返回值即可
+ Assert.IsTrue(UserHelper.DeleteUser("1,2"), "带有参数的UserHelper.DeleteUserTest方法调用失败,请检查数据库连接或者数据库SQL语句");
+ Assert.IsFalse(UserHelper.DeleteUser(string.Empty), "参数为空字符串的UserHelper.DeleteUserTest方法调用失败,请检查数据库连接或者数据库SQL语句");
+ }
+
+ [TestMethod]
+ public void SaveUserTest()
+ {
+ //TODO: 两个提示一模一样完全不知道哪里出了问题,本单元测试未通过
+ User users = new User();
+ users.ID = 0;
+ users.UserName = "liqi";
+ users.Password = "123";
+ users.PassSalt = "123";
+ var result = UserHelper.SaveUser(users);
+ 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语句");
+ }
+ }
+}
diff --git a/BootstrapAdmin.sln b/BootstrapAdmin.sln
index 7903d1af..c5fd0e69 100644
--- a/BootstrapAdmin.sln
+++ b/BootstrapAdmin.sln
@@ -7,10 +7,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Bootstrap.DataAccess", "Boo
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "sql", "sql", "{87319AF5-7C40-4362-B67C-35F9DD737DB4}"
ProjectSection(SolutionItems) = preProject
- DatabaseScripts\ExtendedChecker.sql = DatabaseScripts\ExtendedChecker.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
EndProjectSection
EndProject
diff --git a/DatabaseScripts/Install.sql b/DatabaseScripts/Install.sql
index e7e9a36d..9937d98f 100644
--- a/DatabaseScripts/Install.sql
+++ b/DatabaseScripts/Install.sql
@@ -1,147 +1,144 @@
USE [master]
GO
-Create database [ExtendedChecker]
+Create database [BootstrapAdmin]
GO
-ALTER DATABASE [ExtendedChecker] SET RECOVERY SIMPLE
+ALTER DATABASE [BootstrapAdmin] SET RECOVERY SIMPLE
GO
-ALTER DATABASE [ExtendedChecker] SET AUTO_SHRINK ON
+ALTER DATABASE [BootstrapAdmin] SET AUTO_SHRINK ON
GO
-USE [ExtendedChecker]
+USE [BootstrapAdmin]
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
GO
SET QUOTED_IDENTIFIER ON
GO
-CREATE TABLE [dbo].[Terminals](
+CREATE TABLE [dbo].[Users](
[ID] [int] IDENTITY(1,1) NOT NULL,
- [Name] [nvarchar](50) NOT NULL,
- [ClientIP] [varchar](15) NOT NULL,
- [ClientPort] [int] NOT NULL,
- [ServerIP] [varchar](15) NOT NULL,
- [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
+ [UserName] [nvarchar](50) NULL,
+ [Password] [nvarchar](50) NULL,
+ [PassSalt] [nvarchar](50) NULL,
+ CONSTRAINT [PK_Users] 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
-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
-/****** 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
GO
SET QUOTED_IDENTIFIER ON
GO
-CREATE TABLE [dbo].[TerminalRuleConfig](
- [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](
+CREATE TABLE [dbo].[UserRole](
[ID] [int] IDENTITY(1,1) NOT NULL,
- [BarCode] [varchar](32) NOT NULL,
- [TerminalID] [int] NOT NULL,
- [ScanTime] [datetime] NOT NULL,
- [BarCodeType] [int] NOT NULL,
- CONSTRAINT [PK_ScanInventory] PRIMARY KEY CLUSTERED
+ [UserID] [int] NOT NULL,
+ [RoleID] [int] NOT NULL,
+ CONSTRAINT [PK_UserRole] 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
-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
-/****** 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
GO
SET QUOTED_IDENTIFIER ON
GO
-CREATE TABLE [dbo].[Rules](
+CREATE TABLE [dbo].[UserGroup](
[ID] [int] IDENTITY(1,1) NOT NULL,
- [Name] [nvarchar](200) NOT NULL,
- [Memo] [nvarchar](2000) NULL,
- [Interval] [int] NOT NULL,
- [Enabled] [bit] NOT NULL,
- CONSTRAINT [PK_Rules] PRIMARY KEY CLUSTERED
+ [UserID] [int] NOT NULL,
+ [GroupID] [int] NOT NULL,
+ CONSTRAINT [PK_UserGroup] 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
-/****** Object: Default [DF_Rules_Enabled] Script Date: 09/06/2016 14:31:10 ******/
-ALTER TABLE [dbo].[Rules] ADD CONSTRAINT [DF_Rules_Enabled] DEFAULT ((1)) FOR [Enabled]
+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'
GO
-/****** Object: Default [DF_Terminals_Satus] Script Date: 09/06/2016 14:31:10 ******/
-ALTER TABLE [dbo].[Terminals] ADD CONSTRAINT [DF_Terminals_Satus] DEFAULT ((0)) FOR [Status]
+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'
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
GO
SET QUOTED_IDENTIFIER ON
GO
--- =============================================
--- Author: Argo Zhang
--- Create date: 2016-09-06
--- Description:
--- =============================================
-CREATE PROCEDURE Proc_StartTerminal
- -- Add the parameters for the stored procedure here
- @tId int,
- @rId int
- 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
+CREATE TABLE [dbo].[Roles](
+ [ID] [int] IDENTITY(1,1) NOT NULL,
+ [RoleName] [nvarchar](50) NULL,
+ [Description] [nvarchar](500) NULL,
+ CONSTRAINT [PK_Roles] 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'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
GO
SET QUOTED_IDENTIFIER ON
GO
--- =============================================
--- Author: Argo Zhang
--- Create date: 2016-09-06
--- Description:
--- =============================================
-CREATE PROCEDURE Proc_StopTerminal
- -- Add the parameters for the stored procedure here
- @tId int
- 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;
- update Terminals set Status = 0 where Id = @tId;
-END
+CREATE TABLE [dbo].[RoleGroup](
+ [ID] [int] IDENTITY(1,1) NOT NULL,
+ [RoleID] [int] NOT NULL,
+ [GroupID] [int] NOT NULL,
+ CONSTRAINT [PK_RoleGroup] 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'RoleGroup', @level2type=N'COLUMN',@level2name=N'ID'
+GO
+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'
+GO
+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'
+GO
+/****** Object: Table [dbo].[Groups] Script Date: 10/22/2016 09:44:03 ******/
+SET ANSI_NULLS ON
+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