diff --git a/CNASBalanceDBManage/App.config b/CNASBalanceDBManage/App.config index 774fe69..b24213d 100644 --- a/CNASBalanceDBManage/App.config +++ b/CNASBalanceDBManage/App.config @@ -1,48 +1,49 @@ - + -
+
- - + + + - - + + - - + + - - - - - + + + + + - + - - + + - - - - - + + + + + - + - - + + - \ No newline at end of file + diff --git a/CNASBalanceDBManage/CNASBalanceDBManage.csproj b/CNASBalanceDBManage/CNASBalanceDBManage.csproj index 67ce1eb..2dc1915 100644 --- a/CNASBalanceDBManage/CNASBalanceDBManage.csproj +++ b/CNASBalanceDBManage/CNASBalanceDBManage.csproj @@ -8,9 +8,10 @@ WinExe CNASBalanceDBManage CNASBalanceDBManage - v4.0 + v4.8 512 true + x86 @@ -21,6 +22,7 @@ DEBUG;TRACE prompt 4 + false AnyCPU @@ -30,6 +32,10 @@ TRACE prompt 4 + false + + + database_16px_1229703_easyicon.net.ico @@ -67,6 +73,7 @@ True Resources.resx + True @@ -93,5 +100,8 @@ CnasSynchrousModel + + + \ No newline at end of file diff --git a/CNASBalanceDBManage/Program.cs b/CNASBalanceDBManage/Program.cs index be7496b..b7e5ad8 100644 --- a/CNASBalanceDBManage/Program.cs +++ b/CNASBalanceDBManage/Program.cs @@ -1,4 +1,6 @@ -using System; +using CnasSynchronusClient; +using CnasSynchrousModel; +using System; using System.Collections.Generic; using System.Linq; using System.Windows.Forms; @@ -15,6 +17,13 @@ namespace CNASBalanceDBManage { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); + + SystemFormatConfig systemFormat = FileOperation.GetSystemFormatConfigData(); + GlobalCommonOperation.strStartGeneralVersion = systemFormat.StartGeneralVersion; + GlobalCommonOperation.strStartWebApi = systemFormat.StartWebApi; + GlobalCommonOperation.strWebApiUrl = systemFormat.WebApiUrl; + GlobalCommonOperation.strTargetDbType = systemFormat.TargetDBType; + Application.Run(new frmBalanceDB()); } } diff --git a/CNASBalanceDBManage/Properties/Resources.Designer.cs b/CNASBalanceDBManage/Properties/Resources.Designer.cs index bf41b9a..decc244 100644 --- a/CNASBalanceDBManage/Properties/Resources.Designer.cs +++ b/CNASBalanceDBManage/Properties/Resources.Designer.cs @@ -1,69 +1,61 @@ //------------------------------------------------------------------------------ // // 此代码由工具生成。 -// 运行时版本: 4.0.30319.42000 +// 运行时版本:4.0.30319.42000 // -// 对此文件的更改可能导致不正确的行为,如果 -// 重新生成代码,则所做更改将丢失。 +// 对此文件的更改可能会导致不正确的行为,并且如果 +// 重新生成代码,这些更改将会丢失。 // //------------------------------------------------------------------------------ -namespace CNASBalanceDBManage.Properties -{ - - +namespace CNASBalanceDBManage.Properties { + using System; + + /// - /// 强类型资源类,用于查找本地化字符串等。 + /// 一个强类型的资源类,用于查找本地化的字符串等。 /// // 此类是由 StronglyTypedResourceBuilder // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。 - // 若要添加或删除成员,请编辑 .ResX 文件,然后重新运行 ResGen + // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen // (以 /str 作为命令选项),或重新生成 VS 项目。 - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Resources - { - + internal class Resources { + private static global::System.Resources.ResourceManager resourceMan; - + private static global::System.Globalization.CultureInfo resourceCulture; - + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Resources() - { + internal Resources() { } - + /// - /// 返回此类使用的缓存 ResourceManager 实例。 + /// 返回此类使用的缓存的 ResourceManager 实例。 /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager - { - get - { - if ((resourceMan == null)) - { + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("CNASBalanceDBManage.Properties.Resources", typeof(Resources).Assembly); resourceMan = temp; } return resourceMan; } } - + /// - /// 覆盖当前线程的 CurrentUICulture 属性 - /// 使用此强类型的资源类的资源查找。 + /// 重写当前线程的 CurrentUICulture 属性,对 + /// 使用此强类型资源类的所有资源查找执行重写。 /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture - { - get - { + internal static global::System.Globalization.CultureInfo Culture { + get { return resourceCulture; } - set - { + set { resourceCulture = value; } } diff --git a/CNASBalanceDBManage/Properties/Settings.Designer.cs b/CNASBalanceDBManage/Properties/Settings.Designer.cs index 7a7c9dc..107182a 100644 --- a/CNASBalanceDBManage/Properties/Settings.Designer.cs +++ b/CNASBalanceDBManage/Properties/Settings.Designer.cs @@ -1,28 +1,24 @@ //------------------------------------------------------------------------------ // -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 +// 此代码由工具生成。 +// 运行时版本:4.0.30319.42000 // -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. +// 对此文件的更改可能会导致不正确的行为,并且如果 +// 重新生成代码,这些更改将会丢失。 // //------------------------------------------------------------------------------ -namespace CNASBalanceDBManage.Properties -{ - - +namespace CNASBalanceDBManage.Properties { + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] - internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase - { - + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.0.3.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); - - public static Settings Default - { - get - { + + public static Settings Default { + get { return defaultInstance; } } diff --git a/CNASBalanceDBManage/database_16px_1229703_easyicon.net.ico b/CNASBalanceDBManage/database_16px_1229703_easyicon.net.ico new file mode 100644 index 0000000..98b28ec Binary files /dev/null and b/CNASBalanceDBManage/database_16px_1229703_easyicon.net.ico differ diff --git a/CNASBalanceDBManage/frmBalanceDB.Designer.cs b/CNASBalanceDBManage/frmBalanceDB.Designer.cs index 5b245d6..0c5705d 100644 --- a/CNASBalanceDBManage/frmBalanceDB.Designer.cs +++ b/CNASBalanceDBManage/frmBalanceDB.Designer.cs @@ -31,7 +31,7 @@ System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmBalanceDB)); this.pnlAll = new System.Windows.Forms.Panel(); this.pnlCenter = new System.Windows.Forms.Panel(); - this.tabControl1 = new System.Windows.Forms.TabControl(); + this.tabSetting = new System.Windows.Forms.TabControl(); this.tabCNASDB = new System.Windows.Forms.TabPage(); this.btnCNASTestLink = new System.Windows.Forms.Button(); this.txtPort = new System.Windows.Forms.TextBox(); @@ -69,7 +69,7 @@ this.groupBox1 = new System.Windows.Forms.GroupBox(); this.pnlAll.SuspendLayout(); this.pnlCenter.SuspendLayout(); - this.tabControl1.SuspendLayout(); + this.tabSetting.SuspendLayout(); this.tabCNASDB.SuspendLayout(); this.tabPlatForm.SuspendLayout(); this.tabPwd.SuspendLayout(); @@ -89,24 +89,24 @@ // // pnlCenter // - this.pnlCenter.Controls.Add(this.tabControl1); + this.pnlCenter.Controls.Add(this.tabSetting); this.pnlCenter.Dock = System.Windows.Forms.DockStyle.Fill; this.pnlCenter.Location = new System.Drawing.Point(0, 0); this.pnlCenter.Name = "pnlCenter"; this.pnlCenter.Size = new System.Drawing.Size(493, 258); this.pnlCenter.TabIndex = 1; // - // tabControl1 + // tabSetting // - this.tabControl1.Controls.Add(this.tabCNASDB); - this.tabControl1.Controls.Add(this.tabPlatForm); - this.tabControl1.Controls.Add(this.tabPwd); - this.tabControl1.Dock = System.Windows.Forms.DockStyle.Fill; - this.tabControl1.Location = new System.Drawing.Point(0, 0); - this.tabControl1.Name = "tabControl1"; - this.tabControl1.SelectedIndex = 0; - this.tabControl1.Size = new System.Drawing.Size(493, 258); - this.tabControl1.TabIndex = 36; + this.tabSetting.Controls.Add(this.tabCNASDB); + this.tabSetting.Controls.Add(this.tabPlatForm); + this.tabSetting.Controls.Add(this.tabPwd); + this.tabSetting.Dock = System.Windows.Forms.DockStyle.Fill; + this.tabSetting.Location = new System.Drawing.Point(0, 0); + this.tabSetting.Name = "tabSetting"; + this.tabSetting.SelectedIndex = 0; + this.tabSetting.Size = new System.Drawing.Size(493, 258); + this.tabSetting.TabIndex = 36; // // tabCNASDB // @@ -126,7 +126,7 @@ this.tabCNASDB.Padding = new System.Windows.Forms.Padding(3); this.tabCNASDB.Size = new System.Drawing.Size(485, 228); this.tabCNASDB.TabIndex = 0; - this.tabCNASDB.Text = "CNAS数据库"; + this.tabCNASDB.Text = "目标数据库"; this.tabCNASDB.UseVisualStyleBackColor = true; // // btnCNASTestLink @@ -238,7 +238,7 @@ this.tabPlatForm.Name = "tabPlatForm"; this.tabPlatForm.Size = new System.Drawing.Size(485, 228); this.tabPlatForm.TabIndex = 2; - this.tabPlatForm.Text = "平台数据库"; + this.tabPlatForm.Text = "目标平台数据库"; this.tabPlatForm.UseVisualStyleBackColor = true; // // btnPlatTest @@ -455,7 +455,7 @@ this.Load += new System.EventHandler(this.frmBalanceDB_Load); this.pnlAll.ResumeLayout(false); this.pnlCenter.ResumeLayout(false); - this.tabControl1.ResumeLayout(false); + this.tabSetting.ResumeLayout(false); this.tabCNASDB.ResumeLayout(false); this.tabCNASDB.PerformLayout(); this.tabPlatForm.ResumeLayout(false); @@ -487,7 +487,7 @@ private System.Windows.Forms.Label label9; private System.Windows.Forms.Panel panel1; private System.Windows.Forms.GroupBox groupBox1; - private System.Windows.Forms.TabControl tabControl1; + private System.Windows.Forms.TabControl tabSetting; private System.Windows.Forms.TabPage tabCNASDB; private System.Windows.Forms.TabPage tabPwd; private System.Windows.Forms.TextBox txtRepeatPwd; diff --git a/CNASBalanceDBManage/frmBalanceDB.cs b/CNASBalanceDBManage/frmBalanceDB.cs index 1c46d1c..a0ff119 100644 --- a/CNASBalanceDBManage/frmBalanceDB.cs +++ b/CNASBalanceDBManage/frmBalanceDB.cs @@ -28,7 +28,15 @@ namespace CNASBalanceDBManage return; } - if (CnasDataOperationFact.CnasDataOperation().TestConnect(this.txtDBHost.Text.Trim(), this.txtDBName.Text.Trim(), this.txtDBUser.Text.Trim(), this.txtDBPwd.Text.Trim(), this.txtPort.Text.Trim())) + if (CnasDataOperationFact.CnasDataOperation().TestConnect(new DataBaseInfo() + { + DataBaseCode="cnas", + DBHost = this.txtDBHost.Text.Trim(), + DBName = this.txtDBName.Text.Trim(), + DBUser = this.txtDBUser.Text.Trim(), + DBPwd = this.txtDBPwd.Text.Trim(), + DBPort = this.txtPort.Text.Trim() + })) MessageBox.Show("连接成功!"); else MessageBox.Show("连接失败!"); @@ -55,7 +63,7 @@ namespace CNASBalanceDBManage this.txtPlatPort.Text = PlatDataBase.DBPort; } - strOldPwd = FileOperation.GetLocalOperationPwd(); + strOldPwd = FileOperation.GetLocalOperationPwd(); } private void btnOK_Click(object sender, EventArgs e) @@ -196,10 +204,19 @@ namespace CNASBalanceDBManage return; } - if (CnasDataOperationFact.CnasDataOperation().TestConnect(this.txtPlatHost.Text.Trim(), this.txtPlatServer.Text.Trim(), this.txtPlatUser.Text.Trim(), this.txtPlatPwd.Text.Trim(), this.txtPlatPort.Text.Trim())) + //if (CnasDataOperationFact.CnasDataOperation().TestConnect(this.txtPlatHost.Text.Trim(), this.txtPlatServer.Text.Trim(), this.txtPlatUser.Text.Trim(), this.txtPlatPwd.Text.Trim(), this.txtPlatPort.Text.Trim())) + if (CnasDataOperationFact.CnasDataOperation().TestConnect(new DataBaseInfo() + { + DBHost = this.txtPlatHost.Text.Trim(), + DBName = this.txtPlatServer.Text.Trim(), + DBUser = this.txtPlatUser.Text.Trim(), + DBPwd = this.txtPlatPwd.Text.Trim(), + DBPort = this.txtPlatPort.Text.Trim() + })) MessageBox.Show("连接成功!"); else MessageBox.Show("连接失败!"); } + } } 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..36cc17a --- /dev/null +++ b/CNAS_Authorize/CNAS_Authorize.csproj @@ -0,0 +1,119 @@ + + + + + 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 + + + + + {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..1c57625 --- /dev/null +++ b/CNAS_Authorize/MachineAuth.cs @@ -0,0 +1,252 @@ +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()); + } + } + + //获取Machine表的数据 + //m_machines = new List(); + ////TEST DATA + //for(int i = 0; i < 15; i++) + //{ + // Machine m = new Machine("MACHINEE"+ (i+1), "CODE" + (i + 1), "2025-02-02", i%2==0); + // m_machines.Add(m); + //} + + 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 @@ + + + + + + + + + + +