ソースを参照

下载机器码 激活码验证

master
OCEAN 4ヶ月前
コミット
25f1263a2e
22個のファイルの変更584行の追加41行の削除
  1. +4
    -0
      CNAS_Authorize/CNAS_Authorize.csproj
  2. +0
    -9
      CNAS_Authorize/MachineAuth.cs
  3. +41
    -26
      CNAS_Authorize/MainWindow.xaml.cs
  4. +115
    -0
      CNAS_DBSync/ActivationForm.Designer.cs
  5. +173
    -0
      CNAS_DBSync/ActivationForm.cs
  6. +120
    -0
      CNAS_DBSync/ActivationForm.resx
  7. +9
    -0
      CNAS_DBSync/CNAS_DBSync.csproj
  8. +12
    -2
      CNAS_DBSync/Program.cs
  9. +5
    -0
      CnasSynchronusClient/TargetCnasData/DB2CNASDataOperation.cs
  10. +10
    -0
      CnasSynchronusClient/TargetCnasData/ICnasDataOperation.cs
  11. +19
    -0
      CnasSynchronusClient/TargetCnasData/MySQLCNASDataOperation.cs
  12. +5
    -0
      CnasSynchronusClient/TargetCnasData/MySQLCNASDataOperationByWeb.cs
  13. +5
    -0
      CnasSynchronusClient/TargetCnasData/OracleCnasDataOperation.cs
  14. +25
    -1
      CnasSynchronusDAL/DAL/MySQLDAL.cs
  15. +5
    -0
      CnasSynchronusDAL/Service/Db2DBService.cs
  16. +20
    -1
      CnasSynchronusDAL/Service/MySqlDBService.cs
  17. +5
    -0
      CnasSynchronusDAL/Service/OracleDBService.cs
  18. +11
    -2
      CnasSynchronusIDAL/ITargetDataBaseService.cs
  19. バイナリ
      dll/CNAS_DBSync.exe
  20. バイナリ
      dll/CnasSynchronusClient.dll
  21. バイナリ
      dll/CnasSynchronusDAL.dll
  22. バイナリ
      dll/CnasSynchronusIDAL.dll

+ 4
- 0
CNAS_Authorize/CNAS_Authorize.csproj ファイルの表示

@@ -99,6 +99,10 @@
</None>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\CnasSynchronousCommon\CnasSynchronousCommon.csproj">
<Project>{8E0E5F2E-2BA2-4952-9F31-34C072CD86B3}</Project>
<Name>CnasSynchronousCommon</Name>
</ProjectReference>
<ProjectReference Include="..\CnasSynchronusClient\CnasSynchronusBLL.csproj">
<Project>{CB9B6D92-3CC4-46C6-92E8-A6FD0AD48041}</Project>
<Name>CnasSynchronusBLL</Name>


+ 0
- 9
CNAS_Authorize/MachineAuth.cs ファイルの表示

@@ -95,15 +95,6 @@ namespace CNAS_Authorize
}
}

//获取Machine表的数据
//m_machines = new List<Machine>();
////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<Machine>();
m_rangle.AddRange(m_machines);



+ 41
- 26
CNAS_Authorize/MainWindow.xaml.cs ファイルの表示

@@ -1,6 +1,8 @@
using CnasSynchronusClient;
using CnasSynchronousCommon;
using CnasSynchronusClient;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
@@ -32,6 +34,11 @@ namespace CNAS_Authorize
}

private void Window_Loaded(object sender, RoutedEventArgs e)
{
this.LoadData();
}

private void LoadData()
{
m_machines = new MachineAuth();
m_machines.Load();
@@ -99,28 +106,36 @@ namespace CNAS_Authorize

private void ConfirmImport_Click(object sender, RoutedEventArgs e)
{
//MySQLHelper.ExecuteNonQuery(strInsertSql, parameters);
//int iReturn = CnasDataOperationFact.CnasDataOperation().InsertDataToCNASTable(ConvertDataRowToTable(drNewTarget), targetdataBase, banlanceitem.syncParamasInfos, banlanceitem.CnasInstrumentColumn, banlanceitem.lstFixedValue);
//if (iReturn <= 0) //此时出现问题
//{
// if (iReturn == -1)
// {
// AppLog.ServiceInfo("数据库连接中断,终止本次上传。");
// break; //此时数据库连接中断,直接跳出循环,结束本次数据同步传输
// }
// else if (iReturn == -2) //等于-2表示插入准备更新时发现数据一致,不再执行
// {
// OtherCount++;
// }
// else
// {
// ErrorCount++;
// /*需要转换一下,否则会将整个dt全部写入日志*/
// lstError.Add(GlobalCommonOperation.ConvertDataRowToTable(drNewTarget).Rows[0]);
// }

// bSuccess = false;
//}

//加载CNAS数据库配置
var targetDataBase = FileOperation.GetLocalCnasDB();
if (!CnasDataOperationFact.CnasDataOperation().TestConnect(targetDataBase))
{
MessageBox.Show("CNAS数据库无法正常连接...", "提示");
return;
}

var existData = CnasDataOperationFact.CnasDataOperation().GetTableData(targetDataBase, $"select * from macaddress where MAC_ADDRESS='{edtMachine.Text.Trim()}'");
if(existData!=null&& existData.Rows.Count > 0)
{
MessageBox.Show("已经导入!");
return;
}
StringBuilder sb = new StringBuilder();
sb.AppendFormat($"insert into macaddress(MAC_ADDRESS,PLANTCODE,CREATETIME,FACILITY_STYLE) VALUES('{edtMachine.Text.Trim()}','{edtFactory.Text.Trim()}',now(),'999')");

//1.加载数据
var flag = CnasDataOperationFact.CnasDataOperation().InsertTableData(targetDataBase, sb.ToString());
if (flag)
{
AppLog.ServiceInfo("导入成功");
MessageBox.Show("导入成功...", "提示");
this.LoadData();
}
else
{
MessageBox.Show("导入失败...", "提示");
}
}

private void DownloadActivationCode_Click(object sender, RoutedEventArgs e)
@@ -133,7 +148,7 @@ namespace CNAS_Authorize
{
// 生成激活码
string activationCode = GenerateActivationCode(machine.MachineCode);
// 创建保存文件对话框
var saveFileDialog = new Microsoft.Win32.SaveFileDialog
{
@@ -147,7 +162,7 @@ namespace CNAS_Authorize
// 将激活码写入文件
System.IO.File.WriteAllText(saveFileDialog.FileName, activationCode);
MessageBox.Show("激活码已成功保存!", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
// 更新状态
machine.IsGenerated = true;
refreshBind();
@@ -170,7 +185,7 @@ namespace CNAS_Authorize
string input = machineCode + DateTime.Now.ToString("yyyyMMdd");
byte[] inputBytes = Encoding.UTF8.GetBytes(input);
byte[] hashBytes = md5.ComputeHash(inputBytes);
// 转换为16进制字符串
StringBuilder sb = new StringBuilder();
for (int i = 0; i < hashBytes.Length; i++)


+ 115
- 0
CNAS_DBSync/ActivationForm.Designer.cs ファイルの表示

@@ -0,0 +1,115 @@
namespace CNAS_DBSync
{
partial class ActivationForm
{
private System.ComponentModel.IContainer components = null;

protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}

private void InitializeComponent()
{
this.lblTitle = new System.Windows.Forms.Label();
this.lblDescription = new System.Windows.Forms.Label();
this.lblActivationCode = new System.Windows.Forms.Label();
this.txtActivationCode = new System.Windows.Forms.TextBox();
this.btnActivate = new System.Windows.Forms.Button();
this.lnkDownloadCode = new System.Windows.Forms.LinkLabel();
this.SuspendLayout();
//
// lblTitle
//
this.lblTitle.Location = new System.Drawing.Point(0, 0);
this.lblTitle.Name = "lblTitle";
this.lblTitle.Size = new System.Drawing.Size(100, 23);
this.lblTitle.TabIndex = 0;
//
// lblDescription
//
this.lblDescription.Font = new System.Drawing.Font("微软雅黑", 10F);
this.lblDescription.ForeColor = System.Drawing.Color.Red;
this.lblDescription.Location = new System.Drawing.Point(20, 60);
this.lblDescription.Name = "lblDescription";
this.lblDescription.Size = new System.Drawing.Size(560, 40);
this.lblDescription.TabIndex = 1;
this.lblDescription.Text = "请点击上方按钮下载机器识别码,然后将机器识别码发给平台管理员申请授权文件后进行激活,激活后才可正常使用取数仪器客户端。";
//
// lblActivationCode
//
this.lblActivationCode.AutoSize = true;
this.lblActivationCode.Location = new System.Drawing.Point(20, 120);
this.lblActivationCode.Name = "lblActivationCode";
this.lblActivationCode.Size = new System.Drawing.Size(82, 24);
this.lblActivationCode.TabIndex = 2;
this.lblActivationCode.Text = "激活码:";
//
// txtActivationCode
//
this.txtActivationCode.Location = new System.Drawing.Point(20, 140);
this.txtActivationCode.Multiline = true;
this.txtActivationCode.Name = "txtActivationCode";
this.txtActivationCode.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
this.txtActivationCode.Size = new System.Drawing.Size(560, 150);
this.txtActivationCode.TabIndex = 0;
//
// btnActivate
//
this.btnActivate.Location = new System.Drawing.Point(250, 310);
this.btnActivate.Name = "btnActivate";
this.btnActivate.Size = new System.Drawing.Size(100, 30);
this.btnActivate.TabIndex = 3;
this.btnActivate.Text = "输入激活";
this.btnActivate.Click += new System.EventHandler(this.btnActivate_Click);
//
// lnkDownloadCode
//
this.lnkDownloadCode.ActiveLinkColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(102)))), ((int)(((byte)(204)))));
this.lnkDownloadCode.AutoSize = true;
this.lnkDownloadCode.Font = new System.Drawing.Font("微软雅黑", 10F);
this.lnkDownloadCode.LinkBehavior = System.Windows.Forms.LinkBehavior.HoverUnderline;
this.lnkDownloadCode.LinkColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(102)))), ((int)(((byte)(204)))));
this.lnkDownloadCode.Location = new System.Drawing.Point(20, 23);
this.lnkDownloadCode.Name = "lnkDownloadCode";
this.lnkDownloadCode.Size = new System.Drawing.Size(152, 27);
this.lnkDownloadCode.TabIndex = 4;
this.lnkDownloadCode.TabStop = true;
this.lnkDownloadCode.Text = "下载机器识别码";
this.lnkDownloadCode.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.lnkDownloadCode_LinkClicked);
//
// ActivationForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(11F, 24F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(600, 360);
this.Controls.Add(this.lblTitle);
this.Controls.Add(this.lblDescription);
this.Controls.Add(this.lblActivationCode);
this.Controls.Add(this.txtActivationCode);
this.Controls.Add(this.btnActivate);
this.Controls.Add(this.lnkDownloadCode);
this.Font = new System.Drawing.Font("微软雅黑", 9F);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "ActivationForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "下载机器识别码";
this.ResumeLayout(false);
this.PerformLayout();

}

private System.Windows.Forms.Label lblTitle;
private System.Windows.Forms.Label lblDescription;
private System.Windows.Forms.Label lblActivationCode;
private System.Windows.Forms.TextBox txtActivationCode;
private System.Windows.Forms.Button btnActivate;
private System.Windows.Forms.LinkLabel lnkDownloadCode;
}
}

+ 173
- 0
CNAS_DBSync/ActivationForm.cs ファイルの表示

@@ -0,0 +1,173 @@
using System;
using System.Text;
using System.Windows.Forms;
using System.Management;
using System.Net.NetworkInformation;
using System.Collections.Generic;
using System.IO;

namespace CNAS_DBSync
{
public partial class ActivationForm : Form
{
public bool IsActivated { get; private set; }

public ActivationForm()
{
InitializeComponent();
IsActivated = false;
}

private void btnActivate_Click(object sender, EventArgs e)
{
string activationCode = txtActivationCode.Text.Trim();
if (string.IsNullOrEmpty(activationCode))
{
MessageBox.Show("请输入激活码!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}

try
{
if (ValidateActivationCode(activationCode))
{
IsActivated = true;
this.DialogResult = DialogResult.OK;
this.Close();
}
else
{
MessageBox.Show("激活码无效!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
catch (Exception ex)
{
MessageBox.Show($"激活失败:{ex.Message}", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}

private void lnkDownloadCode_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
try
{
string machineCode = GetMachineCode();
// 创建保存文件对话框
var saveFileDialog = new SaveFileDialog
{
FileName = $"机器码_{DateTime.Now:yyyyMMdd}",
DefaultExt = ".txt",
Filter = "文本文件|*.txt"
};

if (saveFileDialog.ShowDialog() == DialogResult.OK)
{
File.WriteAllText(saveFileDialog.FileName, machineCode);
MessageBox.Show("机器码已成功保存!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
catch (Exception ex)
{
MessageBox.Show($"获取机器码失败:{ex.Message}", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}

private string GetMachineCode()
{
StringBuilder machineCode = new StringBuilder();

// 获取CPU ID
string cpuId = GetCPUId();
machineCode.Append(cpuId);

// 获取所有MAC地址
List<string> macAddresses = GetMACAddresses();
foreach (string mac in macAddresses)
{
machineCode.Append("_").Append(mac);
}

return machineCode.ToString();
}

private string GetCPUId()
{
try
{
using (ManagementClass mc = new ManagementClass("Win32_Processor"))
{
ManagementObjectCollection moc = mc.GetInstances();
foreach (ManagementObject mo in moc)
{
return mo.Properties["ProcessorId"].Value.ToString();
}
}
}
catch (Exception ex)
{
throw new Exception("获取CPU ID失败: " + ex.Message);
}
return string.Empty;
}

private List<string> GetMACAddresses()
{
List<string> macAddresses = new List<string>();
try
{
NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces();
foreach (NetworkInterface adapter in nics)
{
// 只获取物理网卡的MAC地址
if (adapter.NetworkInterfaceType == NetworkInterfaceType.Ethernet ||
adapter.NetworkInterfaceType == NetworkInterfaceType.Wireless80211)
{
string mac = adapter.GetPhysicalAddress().ToString();
if (!string.IsNullOrEmpty(mac))
{
macAddresses.Add(mac);
}
}
}
}
catch (Exception ex)
{
throw new Exception("获取MAC地址失败: " + ex.Message);
}
return macAddresses;
}

private bool ValidateActivationCode(string activationCode)
{
// 使用实际的机器码来验证
string machineCode = GetMachineCode();
return GenerateActivationCode(machineCode) == activationCode;
}

private string GenerateActivationCode(string machineCode)
{
// 这里实现激活码生成算法
// 示例:简单的加密算法,实际应用中应该使用更安全的加密方式
using (var md5 = System.Security.Cryptography.MD5.Create())
{
// 加入时间戳使得生成的激活码具有时效性
string input = machineCode + DateTime.Now.ToString("yyyyMMdd");
byte[] inputBytes = Encoding.UTF8.GetBytes(input);
byte[] hashBytes = md5.ComputeHash(inputBytes);

// 转换为16进制字符串
StringBuilder sb = new StringBuilder();
for (int i = 0; i < hashBytes.Length; i++)
{
sb.Append(hashBytes[i].ToString("X2"));
// 每4个字符添加一个分隔符,提高可读性
if ((i + 1) % 4 == 0 && i != hashBytes.Length - 1)
{
sb.Append("-");
}
}
return sb.ToString();
}
}
}
}

+ 120
- 0
CNAS_DBSync/ActivationForm.resx ファイルの表示

@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.

mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

+ 9
- 0
CNAS_DBSync/CNAS_DBSync.csproj ファイルの表示

@@ -63,6 +63,12 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="ActivationForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="ActivationForm.Designer.cs">
<DependentUpon>ActivationForm.cs</DependentUpon>
</Compile>
<Compile Include="FormSizeHelper.cs" />
<Compile Include="SourceSettingTextBoxDecrible.cs" />
<Compile Include="frmAddSubtract.cs">
@@ -157,6 +163,9 @@
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="ActivationForm.resx">
<DependentUpon>ActivationForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="frmAddSubtract.resx">
<DependentUpon>frmAddSubtract.cs</DependentUpon>
</EmbeddedResource>


+ 12
- 2
CNAS_DBSync/Program.cs ファイルの表示

@@ -23,8 +23,18 @@ namespace CNAS_DBSync
/*CheckAvailability(ref strMsg);*/
if (strMsg == "")
{
if (new frmOperationPwd().ShowDialog() == DialogResult.OK)
Application.Run(new frmSyncParams());
// 显示激活窗口
using (var activationForm = new ActivationForm())
{
if (activationForm.ShowDialog() == DialogResult.OK)
{
// 激活成功,显示主窗口
if (new frmOperationPwd().ShowDialog() == DialogResult.OK)
Application.Run(new frmSyncParams());
}
//else
// MessageBox.Show("激活失败");
}
}
else
MessageBox.Show(strMsg);


+ 5
- 0
CnasSynchronusClient/TargetCnasData/DB2CNASDataOperation.cs ファイルの表示

@@ -73,6 +73,11 @@ namespace CnasSynchronusClient
return db2DataBaseService.InsertDataToCNASTable(dt, dataBase, syncParamasInfos, strInsturmentColumn, lstFixedValue);
}

public bool InsertTableData(DataBaseInfo dataBase, string strSql)
{
throw new NotImplementedException();
}

public bool TestConnect(DataBaseInfo dataBase)
{
return db2DataBaseService.TestConnect(dataBase.DBHost, dataBase.DBName, dataBase.DBUser, dataBase.DBPwd, dataBase.DBPort);


+ 10
- 0
CnasSynchronusClient/TargetCnasData/ICnasDataOperation.cs ファイルの表示

@@ -62,6 +62,16 @@ namespace CnasSynchronusClient
/// <param name="strSql"></param>
/// <returns></returns>
DataTable GetTableData(DataBaseInfo dataBase, string strSql);


/// <summary>
/// 插入某个表的数据
/// </summary>
/// <param name="dataBase"></param>
/// <param name="strSql"></param>
/// <returns></returns>
bool InsertTableData(DataBaseInfo dataBase, string strSql);

}




+ 19
- 0
CnasSynchronusClient/TargetCnasData/MySQLCNASDataOperation.cs ファイルの表示

@@ -95,5 +95,24 @@ namespace CnasSynchronusClient
}
return dt;
}

/// <summary>
/// 插入某个表的数据
/// </summary>
/// <param name="dataBase"></param>
/// <param name="strSql"></param>
/// <returns></returns>
public bool InsertTableData(DataBaseInfo dataBase, string strSql)
{
try
{
return mysqlDataBaseService.InsertTableData(dataBase, strSql);
}
catch (Exception ex)
{
AppLog.Error(ex.Message);
}
return false;
}
}
}

+ 5
- 0
CnasSynchronusClient/TargetCnasData/MySQLCNASDataOperationByWeb.cs ファイルの表示

@@ -326,5 +326,10 @@ namespace CnasSynchronusClient
{
throw new NotImplementedException();
}

public bool InsertTableData(DataBaseInfo dataBase, string strSql)
{
throw new NotImplementedException();
}
}
}

+ 5
- 0
CnasSynchronusClient/TargetCnasData/OracleCnasDataOperation.cs ファイルの表示

@@ -56,6 +56,11 @@ namespace CnasSynchronusClient
return oracleDatabaseService.InsertDataToCNASTable(dt, dataBase, syncParamasInfos, strInstrumentColumn, lstFixedValue);
}

public bool InsertTableData(DataBaseInfo dataBase, string strSql)
{
throw new System.NotImplementedException();
}

public bool TestConnect(DataBaseInfo dataBase)
{
return oracleDatabaseService.TestConnect(dataBase.DBHost, dataBase.DBName, dataBase.DBUser, dataBase.DBPwd, dataBase.DBPort);


+ 25
- 1
CnasSynchronusDAL/DAL/MySQLDAL.cs ファイルの表示

@@ -7,6 +7,7 @@ using MySql.Data.MySqlClient;
using CnasSynchronousCommon;
using CnasSynchrousModel;
using System.Reflection;
using Devart.Common;

namespace CnasSynchronusDAL
{
@@ -554,7 +555,11 @@ namespace CnasSynchronusDAL
return dtNewFormat;
}

//获取某个表的数据
/// <summary>
/// 获取某个表的数据
/// </summary>
/// <param name="strSql"></param>
/// <returns></returns>
public DataTable GetTableData(string strSql)
{
DataTable dt = new DataTable();
@@ -569,5 +574,24 @@ namespace CnasSynchronusDAL
return dt;
}

/// <summary>
/// 插入某个表的数据
/// </summary>
/// <param name="strSql"></param>
/// <returns></returns>
public bool InsertTableData(string strSql)
{
try
{
return MySQLHelper.ExecuteNonQuery(strSql)>0;
}
catch (Exception ex)
{
AppLog.Error(ex.Message);
}
return false;
}

}
}

+ 5
- 0
CnasSynchronusDAL/Service/Db2DBService.cs ファイルの表示

@@ -67,6 +67,11 @@ namespace CnasSynchronusDAL
return baseDAL.InsertCnasData(dt, syncParamasInfos, strInstrumentColumn, lstFixedValue);
}

public bool InsertTableData(DataBaseInfo dataBase, string strSql)
{
throw new NotImplementedException();
}

public bool TestConnect(string strHost, string strName, string strUser, string strPwd, string strPort)
{
SQLDB2DAL basedal = new SQLDB2DAL();


+ 20
- 1
CnasSynchronusDAL/Service/MySqlDBService.cs ファイルの表示

@@ -110,7 +110,12 @@ namespace CnasSynchronusDAL
}


//获取某个表的数据
/// <summary>
/// 获取某个表的数据
/// </summary>
/// <param name="dataBase"></param>
/// <param name="strSql"></param>
/// <returns></returns>
public DataTable GetTableData(DataBaseInfo dataBase, string strSql)
{
MySQLDAL mySQLBase = new MySQLDAL();
@@ -119,5 +124,19 @@ namespace CnasSynchronusDAL
return mySQLBase.GetTableData(strSql);
}

/// <summary>
/// 插入某个表的数据
/// </summary>
/// <param name="dataBase"></param>
/// <param name="strSql"></param>
/// <returns></returns>
public bool InsertTableData(DataBaseInfo dataBase, string strSql)
{
MySQLDAL mySQLBase = new MySQLDAL();
mySQLBase.CreateConnectString(dataBase.DBHost, dataBase.DBPort, dataBase.DBName, dataBase.DBUser, dataBase.DBPwd);

return mySQLBase.InsertTableData(strSql);
}

}
}

+ 5
- 0
CnasSynchronusDAL/Service/OracleDBService.cs ファイルの表示

@@ -86,6 +86,11 @@ namespace CnasSynchronusDAL
return OracleDAL.InsertCnasData(dt, syncParamasInfos, lstFixedValue, strInstrumentColumn);
}

public bool InsertTableData(DataBaseInfo dataBase, string strSql)
{
throw new NotImplementedException();
}

public bool TestConnect(string strHost, string strName, string strUser, string strPwd, string strPort)
{
OracleDAL.CreateConnection(strHost, strName, strUser, strPwd, strPort);


+ 11
- 2
CnasSynchronusIDAL/ITargetDataBaseService.cs ファイルの表示

@@ -44,7 +44,7 @@ namespace CnasSynchronusIDAL
/// <param name="syncParamasInfos"></param>
/// <param name="lstFixedValue"></param>
/// <returns></returns>
int InsertDataToCNASTable(DataTable dt, DataBaseInfo dataBase, List<SyncParamasInfo> syncParamasInfos,string strInstrumentColumn,List<CnasConditionMapValue> lstFixedValue = null);
int InsertDataToCNASTable(DataTable dt, DataBaseInfo dataBase, List<SyncParamasInfo> syncParamasInfos, string strInstrumentColumn, List<CnasConditionMapValue> lstFixedValue = null);

/// <summary>
/// 获取所有表的数据类型和长度
@@ -61,7 +61,7 @@ namespace CnasSynchronusIDAL
/// <param name="strTableName"></param>
/// <param name="strDateColumn"></param>
/// <returns></returns>
string GetMaxTimeByTableName(DataBaseInfo dataBase, string strTableName, string strDateColumn,string strInstrumentColumn,string strInstrumentValue);
string GetMaxTimeByTableName(DataBaseInfo dataBase, string strTableName, string strDateColumn, string strInstrumentColumn, string strInstrumentValue);

/// <summary>
/// 根据用户名密码获取登陆信息
@@ -87,5 +87,14 @@ namespace CnasSynchronusIDAL
/// <param name="strSql"></param>
/// <returns></returns>
DataTable GetTableData(DataBaseInfo dataBase, string strSql);

/// <summary>
/// 插入某个表的数据
/// </summary>
/// <param name="dataBase"></param>
/// <param name="strSql"></param>
/// <returns></returns>
bool InsertTableData(DataBaseInfo dataBase, string strSql);

}
}

バイナリ
dll/CNAS_DBSync.exe ファイルの表示


バイナリ
dll/CnasSynchronusClient.dll ファイルの表示


バイナリ
dll/CnasSynchronusDAL.dll ファイルの表示


バイナリ
dll/CnasSynchronusIDAL.dll ファイルの表示


読み込み中…
キャンセル
保存