diff --git a/.vs/CNAS_DBSync/v15/.suo b/.vs/CNAS_DBSync/v15/.suo index ae8df38..3a499ed 100644 Binary files a/.vs/CNAS_DBSync/v15/.suo and b/.vs/CNAS_DBSync/v15/.suo differ diff --git a/.vs/CNAS_DBSync/v15/Server/sqlite3/storage.ide-shm b/.vs/CNAS_DBSync/v15/Server/sqlite3/storage.ide-shm index a117898..678d1c2 100644 Binary files a/.vs/CNAS_DBSync/v15/Server/sqlite3/storage.ide-shm and b/.vs/CNAS_DBSync/v15/Server/sqlite3/storage.ide-shm differ diff --git a/.vs/CNAS_DBSync/v15/Server/sqlite3/storage.ide-wal b/.vs/CNAS_DBSync/v15/Server/sqlite3/storage.ide-wal index c8a64da..e629b65 100644 Binary files a/.vs/CNAS_DBSync/v15/Server/sqlite3/storage.ide-wal and b/.vs/CNAS_DBSync/v15/Server/sqlite3/storage.ide-wal differ diff --git a/CNAS_Authorize/App.config b/CNAS_Authorize/App.config new file mode 100644 index 0000000..a5fb8f8 --- /dev/null +++ b/CNAS_Authorize/App.config @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/CNAS_Authorize/App.xaml b/CNAS_Authorize/App.xaml new file mode 100644 index 0000000..c690a3d --- /dev/null +++ b/CNAS_Authorize/App.xaml @@ -0,0 +1,9 @@ + + + + + diff --git a/CNAS_Authorize/App.xaml.cs b/CNAS_Authorize/App.xaml.cs new file mode 100644 index 0000000..a58c4a9 --- /dev/null +++ b/CNAS_Authorize/App.xaml.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Data; +using System.Linq; +using System.Threading.Tasks; +using System.Windows; + +namespace CNAS_Authorize +{ + /// + /// App.xaml 的交互逻辑 + /// + public partial class App : Application + { + } +} diff --git a/CNAS_Authorize/CNAS_Authorize.csproj b/CNAS_Authorize/CNAS_Authorize.csproj new file mode 100644 index 0000000..c283acc --- /dev/null +++ b/CNAS_Authorize/CNAS_Authorize.csproj @@ -0,0 +1,123 @@ + + + + + Debug + AnyCPU + {9B4A6989-A7A6-41C0-ADFE-D470EB972D79} + WinExe + Properties + CNAS_Authorize + CNAS_Authorize + v4.8 + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 4 + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + 4.0 + + + + + + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + App.xaml + Code + + + + MainWindow.xaml + Code + + + + + Code + + + True + True + Resources.resx + + + True + Settings.settings + True + + + ResXFileCodeGenerator + Resources.Designer.cs + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + + + + Always + + + + + {8E0E5F2E-2BA2-4952-9F31-34C072CD86B3} + CnasSynchronousCommon + + + {CB9B6D92-3CC4-46C6-92E8-A6FD0AD48041} + CnasSynchronusBLL + + + {0C3243F5-729E-409C-B406-C6DE56E632E0} + CnasSynchrousModel + + + + + \ No newline at end of file diff --git a/CNAS_Authorize/MachineAuth.cs b/CNAS_Authorize/MachineAuth.cs new file mode 100644 index 0000000..8bd8bbb --- /dev/null +++ b/CNAS_Authorize/MachineAuth.cs @@ -0,0 +1,243 @@ +using CnasSynchronusClient; +using CnasSynchrousModel; +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; + +namespace CNAS_Authorize +{ + public class Machine + { + public string FactoryName { get; set; } + public string MachineCode { get; set; } + public string ImportTime { get; set; } + public bool IsGenerated { get; set; } + + public Machine(string name, string code, string time, bool isGen) + { + FactoryName = name; + MachineCode = code; + ImportTime = time; + IsGenerated = isGen; + } + + } + + class MachineAuth + { + /// + /// 所有数据行 + /// + private List m_machines; + /// + /// 编码过滤 + /// + private string m_filter_code; + /// + /// 名称过滤 + /// + private string m_filter_factory; + //以下都是过滤过的数据 + /// + /// 过滤过的数据 + /// + private List m_rangle; + /// + /// 过滤过的当前页 + /// + private List m_page; + /// + /// 每页数量 + /// + private int m_pageSize; + /// + /// 页号 + /// + private int m_pageIndex; + /// + /// 总页数 + /// + private int m_pageCount; + + + public MachineAuth() + { + m_pageSize = 10; + m_pageIndex = 1; + } + DataBaseInfo targetDataBase = new DataBaseInfo(); + public void Load() + { + //加载CNAS数据库配置 + targetDataBase = FileOperation.GetLocalCnasDB(); + if (!CnasDataOperationFact.CnasDataOperation().TestConnect(targetDataBase)) + { + MessageBox.Show("CNAS数据库无法正常连接...", "提示"); + return; + } + + + m_machines = new List(); + ////1.加载数据 + DataTable dtmacaddressinfo = CnasDataOperationFact.CnasDataOperation().GetTableData(targetDataBase, "select * from macaddress"); + if (dtmacaddressinfo != null && dtmacaddressinfo.Rows.Count > 0) + { + List lstCnasTables = new List(); + foreach (DataRow dr in dtmacaddressinfo.Rows) + { + Machine m = new Machine( dr["PLANTCODE"].ToString(), dr["MAC_ADDRESS"].ToString(), dr["CREATETIME"].ToString(), true); + m_machines.Add(m); + lstCnasTables.Add(dr["MAC_ADDRESS"].ToString()); + } + } + + m_rangle = new List(); + m_rangle.AddRange(m_machines); + + m_pageSize = 10; + m_pageIndex = 1; + m_pageCount = (m_rangle.Count / m_pageSize) + (m_rangle.Count % m_pageSize == 0 ? 0 : 1); + + m_page = getPageData(m_pageIndex); + + } + + public int PageSize + { + get { return m_pageSize; } + set + { + m_pageSize = value; + updateView(); + } + } + + public string CurrentPage + { + get + { + return m_pageCount == 0 ? "" : string.Format("{0} / {1}", m_pageIndex, m_pageCount); + } + set + { + + } + } + + public int TotalCount + { + get + { + return m_machines == null ? 0 : m_machines.Count; + } + set + { + + } + } + + private void updateView() + { + List view = new List(); + if (!string.IsNullOrEmpty(m_filter_code) || !string.IsNullOrEmpty(m_filter_factory)) + { + foreach (Machine item in m_machines) + { + bool flag = true; + if (!string.IsNullOrEmpty(m_filter_code)) + { + if (item.MachineCode.IndexOf(m_filter_code) == -1) + { + flag = false; + } + } + if (!string.IsNullOrEmpty(m_filter_factory)) + { + if (item.FactoryName.IndexOf(m_filter_factory) == -1) + { + flag = false; + } + } + if (flag) + { + view.Add(item); + } + } + } + else + { + view.AddRange(m_machines); + } + m_rangle = view; + m_pageIndex = 1; + m_pageCount = (m_rangle.Count / m_pageSize) + (m_rangle.Count % m_pageSize == 0 ? 0 : 1); + m_page = getPageData(m_pageIndex); + } + + public void ChangeFilter(string code, string factory) + { + this.m_filter_code = code; + this.m_filter_factory = factory; + + updateView(); + } + + public List Page + { + get + { + return m_page; + } + } + + private List getPageData(int pageIndex) + { + int index = (pageIndex - 1) * m_pageSize; + List page = new List(m_pageSize); + for (int i = 0; i < m_pageSize && index < m_rangle.Count; i++) + { + page.Add(m_rangle[index]); + index++; + } + return page; + } + + public List NextPage(out bool ok) + { + int index = m_pageIndex * m_pageSize; + if (m_rangle == null || index >= m_rangle.Count) + { + ok = false; + return null; + } + + m_pageIndex++; + m_page = getPageData(m_pageIndex); + + ok = true; + return m_page; + } + + public List PrevPage(out bool ok) + { + if (m_pageIndex == 1 || m_rangle == null) + { + ok = false; + return null; + } + m_pageIndex--; + + m_page = getPageData(m_pageIndex); + + ok = true; + return m_page; + + } + + + } +} diff --git a/CNAS_Authorize/MainWindow.xaml b/CNAS_Authorize/MainWindow.xaml new file mode 100644 index 0000000..ffa3d7e --- /dev/null +++ b/CNAS_Authorize/MainWindow.xaml @@ -0,0 +1,130 @@ + + + + + + + + + + +