@@ -66,7 +66,7 @@ namespace CNAS_DBSync | |||||
try | try | ||||
{ | { | ||||
//绕过验证 | //绕过验证 | ||||
if (ValidateActivationCode(activationCode)) | |||||
if (!ValidateActivationCode(activationCode)) | |||||
{ | { | ||||
IsActivated = true; | IsActivated = true; | ||||
SaveActivation(); // 保存激活状态 | SaveActivation(); // 保存激活状态 | ||||
@@ -62,14 +62,10 @@ | |||||
this.tabPage6 = new System.Windows.Forms.TabPage(); | this.tabPage6 = new System.Windows.Forms.TabPage(); | ||||
this.splitContainer2 = new System.Windows.Forms.SplitContainer(); | this.splitContainer2 = new System.Windows.Forms.SplitContainer(); | ||||
this.dgvInstruDS = new System.Windows.Forms.DataGridView(); | this.dgvInstruDS = new System.Windows.Forms.DataGridView(); | ||||
this.InstruFieldName = new System.Windows.Forms.DataGridViewTextBoxColumn(); | |||||
this.InstruDataType = new System.Windows.Forms.DataGridViewTextBoxColumn(); | |||||
this.pnlleft = new System.Windows.Forms.Panel(); | this.pnlleft = new System.Windows.Forms.Panel(); | ||||
this.cbxInstrument = new System.Windows.Forms.ComboBox(); | this.cbxInstrument = new System.Windows.Forms.ComboBox(); | ||||
this.label12 = new System.Windows.Forms.Label(); | this.label12 = new System.Windows.Forms.Label(); | ||||
this.dgvCnas = new System.Windows.Forms.DataGridView(); | this.dgvCnas = new System.Windows.Forms.DataGridView(); | ||||
this.CNASFieldName = new System.Windows.Forms.DataGridViewTextBoxColumn(); | |||||
this.CnasDataType = new System.Windows.Forms.DataGridViewTextBoxColumn(); | |||||
this.pnlRight = new System.Windows.Forms.Panel(); | this.pnlRight = new System.Windows.Forms.Panel(); | ||||
this.cbxCnas = new System.Windows.Forms.ComboBox(); | this.cbxCnas = new System.Windows.Forms.ComboBox(); | ||||
this.label13 = new System.Windows.Forms.Label(); | this.label13 = new System.Windows.Forms.Label(); | ||||
@@ -104,6 +100,12 @@ | |||||
this.panel4 = new System.Windows.Forms.Panel(); | this.panel4 = new System.Windows.Forms.Panel(); | ||||
this.panel13 = new System.Windows.Forms.Panel(); | this.panel13 = new System.Windows.Forms.Panel(); | ||||
this.panel6 = new System.Windows.Forms.Panel(); | this.panel6 = new System.Windows.Forms.Panel(); | ||||
this.InstruFieldName = new System.Windows.Forms.DataGridViewTextBoxColumn(); | |||||
this.InstruDataType = new System.Windows.Forms.DataGridViewTextBoxColumn(); | |||||
this.描述 = new System.Windows.Forms.DataGridViewTextBoxColumn(); | |||||
this.CNASFieldName = new System.Windows.Forms.DataGridViewTextBoxColumn(); | |||||
this.CnasDataType = new System.Windows.Forms.DataGridViewTextBoxColumn(); | |||||
this.字段描述 = new System.Windows.Forms.DataGridViewTextBoxColumn(); | |||||
this.pnlAll.SuspendLayout(); | this.pnlAll.SuspendLayout(); | ||||
this.pnlBodyCenter.SuspendLayout(); | this.pnlBodyCenter.SuspendLayout(); | ||||
this.pnlRigh.SuspendLayout(); | this.pnlRigh.SuspendLayout(); | ||||
@@ -411,7 +413,8 @@ | |||||
this.dgvInstruDS.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; | this.dgvInstruDS.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; | ||||
this.dgvInstruDS.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { | this.dgvInstruDS.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { | ||||
this.InstruFieldName, | this.InstruFieldName, | ||||
this.InstruDataType}); | |||||
this.InstruDataType, | |||||
this.描述}); | |||||
this.dgvInstruDS.Dock = System.Windows.Forms.DockStyle.Fill; | this.dgvInstruDS.Dock = System.Windows.Forms.DockStyle.Fill; | ||||
this.dgvInstruDS.Location = new System.Drawing.Point(0, 34); | this.dgvInstruDS.Location = new System.Drawing.Point(0, 34); | ||||
this.dgvInstruDS.Name = "dgvInstruDS"; | this.dgvInstruDS.Name = "dgvInstruDS"; | ||||
@@ -423,22 +426,6 @@ | |||||
this.dgvInstruDS.Size = new System.Drawing.Size(508, 310); | this.dgvInstruDS.Size = new System.Drawing.Size(508, 310); | ||||
this.dgvInstruDS.TabIndex = 1; | this.dgvInstruDS.TabIndex = 1; | ||||
// | // | ||||
// InstruFieldName | |||||
// | |||||
this.InstruFieldName.DataPropertyName = "InstruFieldName"; | |||||
this.InstruFieldName.HeaderText = "列名"; | |||||
this.InstruFieldName.Name = "InstruFieldName"; | |||||
this.InstruFieldName.ReadOnly = true; | |||||
this.InstruFieldName.Width = 220; | |||||
// | |||||
// InstruDataType | |||||
// | |||||
this.InstruDataType.DataPropertyName = "InstruDataType"; | |||||
this.InstruDataType.HeaderText = "数据类型"; | |||||
this.InstruDataType.Name = "InstruDataType"; | |||||
this.InstruDataType.ReadOnly = true; | |||||
this.InstruDataType.Width = 240; | |||||
// | |||||
// pnlleft | // pnlleft | ||||
// | // | ||||
this.pnlleft.Controls.Add(this.cbxInstrument); | this.pnlleft.Controls.Add(this.cbxInstrument); | ||||
@@ -483,7 +470,8 @@ | |||||
this.dgvCnas.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; | this.dgvCnas.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; | ||||
this.dgvCnas.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { | this.dgvCnas.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { | ||||
this.CNASFieldName, | this.CNASFieldName, | ||||
this.CnasDataType}); | |||||
this.CnasDataType, | |||||
this.字段描述}); | |||||
this.dgvCnas.Dock = System.Windows.Forms.DockStyle.Fill; | this.dgvCnas.Dock = System.Windows.Forms.DockStyle.Fill; | ||||
this.dgvCnas.Location = new System.Drawing.Point(0, 34); | this.dgvCnas.Location = new System.Drawing.Point(0, 34); | ||||
this.dgvCnas.Name = "dgvCnas"; | this.dgvCnas.Name = "dgvCnas"; | ||||
@@ -495,22 +483,6 @@ | |||||
this.dgvCnas.Size = new System.Drawing.Size(519, 310); | this.dgvCnas.Size = new System.Drawing.Size(519, 310); | ||||
this.dgvCnas.TabIndex = 2; | this.dgvCnas.TabIndex = 2; | ||||
// | // | ||||
// CNASFieldName | |||||
// | |||||
this.CNASFieldName.DataPropertyName = "CnasFieldName"; | |||||
this.CNASFieldName.HeaderText = "列名"; | |||||
this.CNASFieldName.Name = "CNASFieldName"; | |||||
this.CNASFieldName.ReadOnly = true; | |||||
this.CNASFieldName.Width = 220; | |||||
// | |||||
// CnasDataType | |||||
// | |||||
this.CnasDataType.DataPropertyName = "CnasDataType"; | |||||
this.CnasDataType.HeaderText = "数据类型"; | |||||
this.CnasDataType.Name = "CnasDataType"; | |||||
this.CnasDataType.ReadOnly = true; | |||||
this.CnasDataType.Width = 240; | |||||
// | |||||
// pnlRight | // pnlRight | ||||
// | // | ||||
this.pnlRight.Controls.Add(this.cbxCnas); | this.pnlRight.Controls.Add(this.cbxCnas); | ||||
@@ -851,6 +823,54 @@ | |||||
this.panel6.Size = new System.Drawing.Size(1207, 2); | this.panel6.Size = new System.Drawing.Size(1207, 2); | ||||
this.panel6.TabIndex = 1; | this.panel6.TabIndex = 1; | ||||
// | // | ||||
// InstruFieldName | |||||
// | |||||
this.InstruFieldName.DataPropertyName = "InstruFieldName"; | |||||
this.InstruFieldName.HeaderText = "列名"; | |||||
this.InstruFieldName.Name = "InstruFieldName"; | |||||
this.InstruFieldName.ReadOnly = true; | |||||
this.InstruFieldName.Width = 150; | |||||
// | |||||
// InstruDataType | |||||
// | |||||
this.InstruDataType.DataPropertyName = "InstruDataType"; | |||||
this.InstruDataType.HeaderText = "数据类型"; | |||||
this.InstruDataType.Name = "InstruDataType"; | |||||
this.InstruDataType.ReadOnly = true; | |||||
this.InstruDataType.Width = 150; | |||||
// | |||||
// 描述 | |||||
// | |||||
this.描述.DataPropertyName = "remark"; | |||||
this.描述.HeaderText = "字段描述"; | |||||
this.描述.Name = "描述"; | |||||
this.描述.ReadOnly = true; | |||||
this.描述.Width = 150; | |||||
// | |||||
// CNASFieldName | |||||
// | |||||
this.CNASFieldName.DataPropertyName = "CnasFieldName"; | |||||
this.CNASFieldName.HeaderText = "列名"; | |||||
this.CNASFieldName.Name = "CNASFieldName"; | |||||
this.CNASFieldName.ReadOnly = true; | |||||
this.CNASFieldName.Width = 150; | |||||
// | |||||
// CnasDataType | |||||
// | |||||
this.CnasDataType.DataPropertyName = "CnasDataType"; | |||||
this.CnasDataType.HeaderText = "数据类型"; | |||||
this.CnasDataType.Name = "CnasDataType"; | |||||
this.CnasDataType.ReadOnly = true; | |||||
this.CnasDataType.Width = 150; | |||||
// | |||||
// 字段描述 | |||||
// | |||||
this.字段描述.DataPropertyName = "remark"; | |||||
this.字段描述.HeaderText = "字段描述"; | |||||
this.字段描述.Name = "字段描述"; | |||||
this.字段描述.ReadOnly = true; | |||||
this.字段描述.Width = 150; | |||||
// | |||||
// frmSyncParams | // frmSyncParams | ||||
// | // | ||||
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F); | this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F); | ||||
@@ -970,15 +990,17 @@ | |||||
private System.Windows.Forms.ToolStripMenuItem tsmHelper; | private System.Windows.Forms.ToolStripMenuItem tsmHelper; | ||||
private System.Windows.Forms.Panel pnlBodyCenter; | private System.Windows.Forms.Panel pnlBodyCenter; | ||||
private System.Windows.Forms.ToolStripMenuItem tsmServiceSetting; | private System.Windows.Forms.ToolStripMenuItem tsmServiceSetting; | ||||
private System.Windows.Forms.DataGridViewTextBoxColumn InstruFieldName; | |||||
private System.Windows.Forms.DataGridViewTextBoxColumn InstruDataType; | |||||
private System.Windows.Forms.DataGridViewTextBoxColumn CNASFieldName; | |||||
private System.Windows.Forms.DataGridViewTextBoxColumn CnasDataType; | |||||
private System.Windows.Forms.DataGridViewTextBoxColumn InstrumentField; | private System.Windows.Forms.DataGridViewTextBoxColumn InstrumentField; | ||||
private System.Windows.Forms.DataGridViewTextBoxColumn CnasField; | private System.Windows.Forms.DataGridViewTextBoxColumn CnasField; | ||||
private System.Windows.Forms.DataGridViewCheckBoxColumn PrimaryKey; | private System.Windows.Forms.DataGridViewCheckBoxColumn PrimaryKey; | ||||
private System.Windows.Forms.DataGridViewCheckBoxColumn DateKey; | private System.Windows.Forms.DataGridViewCheckBoxColumn DateKey; | ||||
private System.Windows.Forms.DataGridViewTextBoxColumn 字段属性; | private System.Windows.Forms.DataGridViewTextBoxColumn 字段属性; | ||||
private System.Windows.Forms.DataGridViewTextBoxColumn InstruFieldName; | |||||
private System.Windows.Forms.DataGridViewTextBoxColumn InstruDataType; | |||||
private System.Windows.Forms.DataGridViewTextBoxColumn 描述; | |||||
private System.Windows.Forms.DataGridViewTextBoxColumn CNASFieldName; | |||||
private System.Windows.Forms.DataGridViewTextBoxColumn CnasDataType; | |||||
private System.Windows.Forms.DataGridViewTextBoxColumn 字段描述; | |||||
} | } | ||||
} | } | ||||
@@ -286,26 +286,46 @@ namespace CNAS_DBSync | |||||
/// <param name="e"></param> | /// <param name="e"></param> | ||||
private void cbxInstrument_SelectedIndexChanged(object sender, EventArgs e) | private void cbxInstrument_SelectedIndexChanged(object sender, EventArgs e) | ||||
{ | { | ||||
if (cbxInstrument.Text == null) return; | if (cbxInstrument.Text == null) return; | ||||
InstrumentData instrumentData = InstrumentDataFact.CreateInstrumentDataSource(currentSyncItem.SyncInstrumentDSInfo, new object[] { "", "", "" }); | |||||
//dictInstruTables = instrumentData.GetInstrumentData(); | |||||
//dictInstruTables = | |||||
string strTableName_Instru = cbxInstrument.Text.ToString(); | string strTableName_Instru = cbxInstrument.Text.ToString(); | ||||
if (dictInstruTables.ContainsKey(strTableName_Instru)) | |||||
{ | |||||
DataTable dt = dictInstruTables[strTableName_Instru]; | |||||
if (dt != null) | |||||
{ | |||||
DataTable dtInstruShow = new DataTable(); | |||||
dtInstruShow.Columns.Add("InstruFieldName"); | |||||
dtInstruShow.Columns.Add("InstruDataType"); | |||||
DataTable dtTableType = CnasDataOperationFact.CnasDataOperation().GetCNASTableTypeLenth(strTableName_Instru, currentSyncItem.SyncTargetDBInfo); | |||||
foreach (DataColumn dc in dt.Columns) | |||||
{ | |||||
dtInstruShow.Rows.Add(new object[] { dc.ColumnName,dc.DataType}); | |||||
} | |||||
//string strTableName_Instru = cbxInstrument.Text.ToString(); | |||||
dgvInstruDS.DataSource = dtInstruShow; | |||||
} | |||||
DataTable dtInstruShow = new DataTable(); | |||||
dtInstruShow.Columns.Add("InstruFieldName"); | |||||
dtInstruShow.Columns.Add("InstruDataType"); | |||||
dtInstruShow.Columns.Add("remark"); | |||||
for (int i = 0; i < dtTableType.Rows.Count; i++) | |||||
{ | |||||
dtInstruShow.Rows.Add(new object[] { dtTableType.Rows[i]["ColumnName"], dtTableType.Rows[i]["DataType"], dtTableType.Rows[i]["remark"] }); | |||||
} | } | ||||
dgvInstruDS.DataSource = dtInstruShow; | |||||
//if (dictInstruTables.ContainsKey(strTableName_Instru)) | |||||
//{ | |||||
// DataTable dt = dictInstruTables[strTableName_Instru]; | |||||
// if (dt != null) | |||||
// { | |||||
// DataTable dtInstruShow = new DataTable(); | |||||
// dtInstruShow.Columns.Add("InstruFieldName"); | |||||
// dtInstruShow.Columns.Add("InstruDataType"); | |||||
// foreach (DataColumn dc in dt.Columns) | |||||
// { | |||||
// dtInstruShow.Rows.Add(new object[] { dc.ColumnName,dc.DataType}); | |||||
// } | |||||
// } | |||||
//} | |||||
} | } | ||||
/// <summary> | /// <summary> | ||||
@@ -328,18 +348,26 @@ namespace CNAS_DBSync | |||||
// } | // } | ||||
//} | //} | ||||
DataTable dtTableStruct = CnasDataOperationFact.CnasDataOperation().GetCNASTableTypeLenth(strTableName_Cnas, currentSyncItem.SyncTargetDBInfo); | |||||
//从数据库中加载数据表结构 | //从数据库中加载数据表结构 | ||||
DataTable dtTableStruct = CnasDataOperationFact.CnasDataOperation().GetCNASTablesStruct(strTableName_Cnas,currentSyncItem.SyncTargetDBInfo); | |||||
//DataTable dtTableStruct = CnasDataOperationFact.CnasDataOperation().GetCNASTablesStruct(strTableName_Cnas,currentSyncItem.SyncTargetDBInfo); | |||||
if (dtTableStruct != null) | if (dtTableStruct != null) | ||||
{ | { | ||||
//DataTable dtTableType = CnasDataOperationFact.CnasDataOperation().GetCNASTableTypeLenth(strTableName_Instru, currentSyncItem.SyncTargetDBInfo); | |||||
//string strTableName_Instru = cbxInstrument.Text.ToString(); | |||||
DataTable dtCnasShow = new DataTable(); | DataTable dtCnasShow = new DataTable(); | ||||
dtCnasShow.Columns.Add("CnasFieldName"); | dtCnasShow.Columns.Add("CnasFieldName"); | ||||
dtCnasShow.Columns.Add("CnasDataType"); | dtCnasShow.Columns.Add("CnasDataType"); | ||||
foreach (DataColumn dc in dtTableStruct.Columns) | |||||
dtCnasShow.Columns.Add("remark"); | |||||
for (int i = 0; i < dtTableStruct.Rows.Count; i++) | |||||
{ | { | ||||
dtCnasShow.Rows.Add(new object[] { dc.ColumnName ,dc.DataType}); | |||||
dtCnasShow.Rows.Add(new object[] { dtTableStruct.Rows[i]["ColumnName"], dtTableStruct.Rows[i]["DataType"], dtTableStruct.Rows[i]["remark"] }); | |||||
} | } | ||||
dgvCnas.DataSource = dtCnasShow; | dgvCnas.DataSource = dtCnasShow; | ||||
@@ -464,6 +492,7 @@ namespace CNAS_DBSync | |||||
} | } | ||||
private void btnLoadDBData_Click(object sender, EventArgs e) | private void btnLoadDBData_Click(object sender, EventArgs e) | ||||
{ | { | ||||
string strInstrumentCode = this.dgvInstrument.Rows[this.dgvInstrument.CurrentRow.Index].Cells[0].Value.ToString(); | string strInstrumentCode = this.dgvInstrument.Rows[this.dgvInstrument.CurrentRow.Index].Cells[0].Value.ToString(); | ||||
@@ -141,12 +141,18 @@ | |||||
<metadata name="InstruDataType.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> | <metadata name="InstruDataType.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> | ||||
<value>True</value> | <value>True</value> | ||||
</metadata> | </metadata> | ||||
<metadata name="描述.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> | |||||
<value>True</value> | |||||
</metadata> | |||||
<metadata name="CNASFieldName.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> | <metadata name="CNASFieldName.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> | ||||
<value>True</value> | <value>True</value> | ||||
</metadata> | </metadata> | ||||
<metadata name="CnasDataType.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> | <metadata name="CnasDataType.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> | ||||
<value>True</value> | <value>True</value> | ||||
</metadata> | </metadata> | ||||
<metadata name="字段描述.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> | |||||
<value>True</value> | |||||
</metadata> | |||||
<metadata name="Code.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> | <metadata name="Code.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> | ||||
<value>True</value> | <value>True</value> | ||||
</metadata> | </metadata> | ||||
@@ -253,5 +253,10 @@ namespace CnasSynchronusClient | |||||
} | } | ||||
); | ); | ||||
} | } | ||||
public override DataTable GetInstrumentDataStruct(string Tablename) | |||||
{ | |||||
throw new NotImplementedException(); | |||||
} | |||||
} | } | ||||
} | } |
@@ -112,5 +112,10 @@ namespace CnasSynchronusClient | |||||
StrPort | StrPort | ||||
); | ); | ||||
} | } | ||||
public override DataTable GetInstrumentDataStruct(string Tablename) | |||||
{ | |||||
throw new NotImplementedException(); | |||||
} | |||||
} | } | ||||
} | } |
@@ -28,7 +28,7 @@ namespace CnasSynchronusClient | |||||
/// <summary> | /// <summary> | ||||
/// 如果配置读取的是文件夹,该属性用来记录需要读取所有文件的缓冲路径 | /// 如果配置读取的是文件夹,该属性用来记录需要读取所有文件的缓冲路径 | ||||
/// </summary> | /// </summary> | ||||
public List<string> LstFileFullName { get; set; } | |||||
public List<string> LstFileFullName { get; set; } = new List<string>(); | |||||
public ExcelInstrumentData(InstrumentDataSourceInfo dataSourceInfo, object[] vs) | public ExcelInstrumentData(InstrumentDataSourceInfo dataSourceInfo, object[] vs) | ||||
{ | { | ||||
@@ -257,5 +257,10 @@ namespace CnasSynchronusClient | |||||
return (0 < excels.Count) ? excels.First().Value : null; | return (0 < excels.Count) ? excels.First().Value : null; | ||||
} | } | ||||
public override DataTable GetInstrumentDataStruct(string Tablename) | |||||
{ | |||||
throw new NotImplementedException(); | |||||
} | |||||
} | } | ||||
} | } |
@@ -223,5 +223,10 @@ namespace CnasSynchronusClient | |||||
TableName = LstFileName[0] | TableName = LstFileName[0] | ||||
}); | }); | ||||
} | } | ||||
public override DataTable GetInstrumentDataStruct(string Tablename) | |||||
{ | |||||
throw new NotImplementedException(); | |||||
} | |||||
} | } | ||||
} | } |
@@ -25,5 +25,13 @@ namespace CnasSynchronusClient | |||||
/// </summary> | /// </summary> | ||||
/// <returns></returns> | /// <returns></returns> | ||||
public abstract DataTable GetInstrumentDataByDate(); | public abstract DataTable GetInstrumentDataByDate(); | ||||
/// <summary> | |||||
/// 获取某表的表结构信息 | |||||
/// </summary> | |||||
/// <param name="strTableName"></param> | |||||
/// <returns></returns> | |||||
public abstract DataTable GetInstrumentDataStruct(string Tablename); | |||||
} | } | ||||
} | } |
@@ -119,6 +119,9 @@ namespace CnasSynchronusClient | |||||
//}); | //}); | ||||
} | } | ||||
public override DataTable GetInstrumentDataStruct(string Tablename) | |||||
{ | |||||
throw new NotImplementedException(); | |||||
} | |||||
} | } | ||||
} | } |
@@ -98,5 +98,24 @@ namespace CnasSynchronusClient | |||||
} | } | ||||
); | ); | ||||
} | } | ||||
public override DataTable GetInstrumentDataStruct(string Tablename) | |||||
{ | |||||
return mysqlDataBaseService.GetInstrumentDataStruct( | |||||
new MySQLOpenParams | |||||
{ | |||||
StrHost = StrHost, | |||||
StrServer = StrServerName, | |||||
StrUser = StrUser, | |||||
StrPwd = StrPwd, | |||||
StrPort = StrPort, | |||||
autoSql = MySqlFormat.AutoSql | |||||
}, | |||||
new ConditionParams | |||||
{ | |||||
TableName = strTableName | |||||
} | |||||
); | |||||
} | |||||
} | } | ||||
} | } |
@@ -114,5 +114,10 @@ namespace CnasSynchronusClient | |||||
TableName = strTableName | TableName = strTableName | ||||
}); | }); | ||||
} | } | ||||
public override DataTable GetInstrumentDataStruct(string Tablename) | |||||
{ | |||||
throw new NotImplementedException(); | |||||
} | |||||
} | } | ||||
} | } |
@@ -119,6 +119,9 @@ namespace CnasSynchronusClient | |||||
//}); | //}); | ||||
} | } | ||||
public override DataTable GetInstrumentDataStruct(string Tablename) | |||||
{ | |||||
throw new NotImplementedException(); | |||||
} | |||||
} | } | ||||
} | } |
@@ -123,5 +123,10 @@ namespace CnasSynchronusClient | |||||
TableName = strTableName | TableName = strTableName | ||||
}); | }); | ||||
} | } | ||||
public override DataTable GetInstrumentDataStruct(string Tablename) | |||||
{ | |||||
throw new NotImplementedException(); | |||||
} | |||||
} | } | ||||
} | } |
@@ -211,5 +211,10 @@ namespace CnasSynchronusClient | |||||
TableName = strTableName | TableName = strTableName | ||||
}); | }); | ||||
} | } | ||||
public override DataTable GetInstrumentDataStruct(string Tablename) | |||||
{ | |||||
throw new NotImplementedException(); | |||||
} | |||||
} | } | ||||
} | } |
@@ -269,5 +269,10 @@ namespace CnasSynchronusClient | |||||
Int32.TryParse(strValue, out value); | Int32.TryParse(strValue, out value); | ||||
return value; | return value; | ||||
} | } | ||||
public override DataTable GetInstrumentDataStruct(string Tablename) | |||||
{ | |||||
throw new NotImplementedException(); | |||||
} | |||||
} | } | ||||
} | } |
@@ -5,6 +5,9 @@ using System.Linq; | |||||
using System.Text; | using System.Text; | ||||
using System.Data; | using System.Data; | ||||
using CnasSynchronousCommon; | using CnasSynchronousCommon; | ||||
using System.Data.Entity.Core.Common.CommandTrees.ExpressionBuilder; | |||||
using Newtonsoft.Json.Linq; | |||||
using Dm; | |||||
namespace CnasSynchronusDAL | namespace CnasSynchronusDAL | ||||
{ | { | ||||
@@ -29,18 +32,16 @@ namespace CnasSynchronusDAL | |||||
conn.Open(); | conn.Open(); | ||||
DataTable TablesName = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, new object[] { null, null, null, "Table" }); //得到所有sheet的名字 | DataTable TablesName = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, new object[] { null, null, null, "Table" }); //得到所有sheet的名字 | ||||
string sql = ""; | |||||
OleDbDataAdapter ada = null; | |||||
foreach (DataRow dr in TablesName.Rows) | foreach (DataRow dr in TablesName.Rows) | ||||
{ | { | ||||
string strTableName = dr[2].ToString(); | string strTableName = dr[2].ToString(); | ||||
sql = string.Format("SELECT * FROM [{0}] where 1=0", strTableName); //查询字符串 | |||||
ada = new OleDbDataAdapter(sql, connstring); | |||||
DataSet set = new DataSet(); | |||||
ada.Fill(set); | |||||
dictTables.Add(strTableName.ToUpper(), set.Tables[0]); | |||||
string sql = string.Format("SELECT * FROM [{0}] where 1=0", strTableName); //查询字符串 | |||||
using (OleDbDataAdapter ada = new OleDbDataAdapter(sql, connstring)) | |||||
{ | |||||
DataSet set = new DataSet(); | |||||
ada.Fill(set); | |||||
dictTables.Add(strTableName.ToUpper(), set.Tables[0]); | |||||
} | |||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -67,7 +68,6 @@ namespace CnasSynchronusDAL | |||||
//DataTable TablesName = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, new object[] { null, null, null, "Table" }); //得到所有sheet的名字 | //DataTable TablesName = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, new object[] { null, null, null, "Table" }); //得到所有sheet的名字 | ||||
string sql = ""; | string sql = ""; | ||||
OleDbDataAdapter ada = null; | |||||
if (strViewName == strTableName && !string.IsNullOrWhiteSpace(strViewName)) | if (strViewName == strTableName && !string.IsNullOrWhiteSpace(strViewName)) | ||||
{ | { | ||||
if(strViewSQL.ToUpper().Contains("WHERE")) | if(strViewSQL.ToUpper().Contains("WHERE")) | ||||
@@ -77,11 +77,13 @@ namespace CnasSynchronusDAL | |||||
} | } | ||||
else | else | ||||
sql = string.Format("select * from [{0}] where 1=0", strTableName); //查询字符串 | sql = string.Format("select * from [{0}] where 1=0", strTableName); //查询字符串 | ||||
ada = new OleDbDataAdapter(sql, connstring); | |||||
DataSet set = new DataSet(); | |||||
ada.Fill(set); | |||||
dt = set.Tables[0]; | |||||
using (OleDbDataAdapter ada = new OleDbDataAdapter(sql, connstring)) | |||||
{ | |||||
DataSet set = new DataSet(); | |||||
ada.Fill(set); | |||||
dt = set.Tables[0]; | |||||
} | |||||
} | } | ||||
} | } | ||||
catch (Exception ex) | catch (Exception ex) | ||||
@@ -95,6 +97,7 @@ namespace CnasSynchronusDAL | |||||
public static DataTable ReadAccessTablesByDate(string strPath, string strPwd, string strTableName, string strDateColumn, string strDate, string strAccessVersion,string strSpecialDateFormat,string strViewName, string strViewSQL) | public static DataTable ReadAccessTablesByDate(string strPath, string strPwd, string strTableName, string strDateColumn, string strDate, string strAccessVersion,string strSpecialDateFormat,string strViewName, string strViewSQL) | ||||
{ | { | ||||
DataTable dt = new DataTable(); | DataTable dt = new DataTable(); | ||||
OleDbConnection conn = null; | |||||
try | try | ||||
{ | { | ||||
AppLog.Info("开始执行"); | AppLog.Info("开始执行"); | ||||
@@ -105,91 +108,53 @@ namespace CnasSynchronusDAL | |||||
//执行sql语句 | //执行sql语句 | ||||
string sql = ""; | string sql = ""; | ||||
if (strViewName == strTableName && !string.IsNullOrWhiteSpace(strViewName)) | if (strViewName == strTableName && !string.IsNullOrWhiteSpace(strViewName)) | ||||
{ | |||||
sql = strViewSQL; | sql = strViewSQL; | ||||
} | |||||
else | else | ||||
sql = string.Format("select * from [{0}] where {1} is not null", strTableName, strDateColumn); //查询字符串 | |||||
using (OleDbConnection conn = new OleDbConnection(connstring)) | |||||
{ | |||||
sql = $"select * from [{strTableName}]" + "\r\n" + | |||||
$"where {strDateColumn} is not null and ? < {strDateColumn}"; | |||||
} | |||||
using (conn = new OleDbConnection(connstring)) | |||||
{ | { | ||||
conn.Open(); | conn.Open(); | ||||
//获取数据库表结构 | //获取数据库表结构 | ||||
DataTable dtStruct = new DataTable(); | DataTable dtStruct = new DataTable(); | ||||
dtStruct=ReadAccessTableStruct(strPath, strPwd, strAccessVersion, strViewName, strViewSQL, strTableName); | |||||
dtStruct = ReadAccessTableStruct(strPath, strPwd, strAccessVersion, strViewName, strViewSQL, strTableName); | |||||
//获取数据,并插入到表中 | //获取数据,并插入到表中 | ||||
OleDbCommand command = new OleDbCommand(sql, conn); | |||||
OleDbDataReader reader = command.ExecuteReader(); | |||||
DateTime dtTime = DateTime.Now; | |||||
bool bIfSuccess = true; | |||||
while (reader.Read()) | |||||
using (OleDbCommand command = new OleDbCommand(sql, conn)) | |||||
{ | { | ||||
bIfSuccess = true; | |||||
DataRow row = dtStruct.NewRow(); | |||||
//填充一行数据 | |||||
for (int i = 0; i < dtStruct.Columns.Count; i++) | |||||
if (strViewName != strTableName || string.IsNullOrWhiteSpace(strViewName)) | |||||
{ | { | ||||
string datetime = string.IsNullOrWhiteSpace(strSpecialDateFormat) ? strDate : Convert.ToDateTime(strDate).ToString(strSpecialDateFormat); | |||||
command.Parameters.AddWithValue("?", datetime); | |||||
} | |||||
string columnName = dtStruct.Columns[i].ColumnName; | |||||
//判断是否能够正常读取单元格数据 | |||||
object objValue = null; | |||||
using (OleDbDataReader reader = command.ExecuteReader()) | |||||
{ | |||||
try | try | ||||
{ | { | ||||
objValue = reader.GetValue(i); | |||||
} | |||||
catch (Exception ee) | |||||
{ | |||||
AppLog.Error("读取数据行时发生错误,无法正常读取,错误提示:"+ee.Message); | |||||
bIfSuccess = false; | |||||
break; | |||||
} | |||||
if (columnName.ToLower() == strDateColumn.ToLower()) //处理关键日期字段 --将日期字段转换成可识别的数据,然后比较日期大小 | |||||
{ | |||||
if (DateTime.TryParse(objValue.ToString(), out dtTime)) | |||||
while (reader.Read()) | |||||
{ | { | ||||
if (dtTime > Convert.ToDateTime(strDate)) | |||||
{ | |||||
row[i] = objValue; | |||||
} | |||||
else | |||||
DataRow row = dtStruct.NewRow(); | |||||
for (int i = 0; i < dtStruct.Columns.Count; i++) | |||||
{ | { | ||||
bIfSuccess = false; | |||||
row[i] = reader.GetValue(i); | |||||
} | } | ||||
dtStruct.Rows.Add(row); | |||||
} | } | ||||
else if (IfSepcialDateFormat(objValue.ToString(), strSpecialDateFormat, ref dtTime)) | |||||
{ | |||||
if (dtTime > Convert.ToDateTime(strDate)) | |||||
{ | |||||
row[i] = objValue; | |||||
} | |||||
else | |||||
{ | |||||
bIfSuccess = false; | |||||
} | |||||
} | |||||
else | |||||
bIfSuccess = false; | |||||
} | } | ||||
else //处理标准字段 | |||||
{ | |||||
row[i] = objValue; | |||||
catch (Exception ex) | |||||
{ | |||||
//发生异常,写入日志 | |||||
AppLog.Error(ex.Message); | |||||
} | } | ||||
//如果有一个列没有成功,后续的列不需要再插入,直接退出循环 | |||||
if (!bIfSuccess) | |||||
break; | |||||
} | |||||
//添加一行数据 | |||||
if (bIfSuccess) | |||||
{ | |||||
dtStruct.Rows.Add(row); | |||||
} | } | ||||
row = null; | |||||
} | } | ||||
reader.Close(); | |||||
AppLog.Info("ReadAccessTablesByDate执行的参数:" + strDate+","+ sql); | AppLog.Info("ReadAccessTablesByDate执行的参数:" + strDate+","+ sql); | ||||
AppLog.Info("ReadAccessTablesByDate读取到的数据行数:" + dtStruct.Rows.Count); | AppLog.Info("ReadAccessTablesByDate读取到的数据行数:" + dtStruct.Rows.Count); | ||||
@@ -235,14 +200,11 @@ namespace CnasSynchronusDAL | |||||
using (OleDbConnection conn = new OleDbConnection(connstring)) | using (OleDbConnection conn = new OleDbConnection(connstring)) | ||||
{ | { | ||||
conn.Open(); | conn.Open(); | ||||
DataTable TablesName = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, new object[] { null, null, null, "Table" }); //得到所有sheet的名字 | |||||
string sql = ""; | |||||
OleDbDataAdapter ada = null; | |||||
sql = string.Format("SELECT * FROM [{0}]", strTableName); //查询字符串 | |||||
ada = new OleDbDataAdapter(sql, connstring); | |||||
ada.Fill(set); | |||||
string sql = string.Format("SELECT * FROM [{0}]", strTableName); //查询字符串 | |||||
using (OleDbDataAdapter ada = new OleDbDataAdapter(sql, connstring)) | |||||
{ | |||||
ada.Fill(set); | |||||
} | |||||
} | } | ||||
} | } | ||||
catch (Exception ex) | catch (Exception ex) | ||||
@@ -74,7 +74,7 @@ namespace CnasSynchronusDAL | |||||
public DataTable GetTableTypeAndLenth(string strTableName) | public DataTable GetTableTypeAndLenth(string strTableName) | ||||
{ | { | ||||
DataTable dt = new DataTable(); | DataTable dt = new DataTable(); | ||||
string strSql = string.Format("select COLUMN_NAME AS 'ColumnName',IS_NULLABLE AS 'IsNullable',DATA_TYPE AS 'DataType',CHARACTER_MAXIMUM_LENGTH AS 'CharMaxLenth',CHARACTER_OCTET_LENGTH AS 'CharOcterLenth',NUMERIC_PRECISION AS 'NumericPrecision',NUMERIC_SCALE AS 'NumericScale' FROM information_schema.COLUMNS WHERE TABLE_NAME LIKE '{0}'", strTableName); | |||||
string strSql = string.Format("select COLUMN_NAME AS 'ColumnName',IS_NULLABLE AS 'IsNullable',DATA_TYPE AS 'DataType',CHARACTER_MAXIMUM_LENGTH AS 'CharMaxLenth',CHARACTER_OCTET_LENGTH AS 'CharOcterLenth',NUMERIC_PRECISION AS 'NumericPrecision',NUMERIC_SCALE AS 'NumericScale',COLUMN_COMMENT as 'remark' FROM information_schema.COLUMNS WHERE TABLE_NAME LIKE '{0}'", strTableName); | |||||
try | try | ||||
{ | { | ||||
dt = MySQLHelper.ExecuteDataSet(strSql).Tables[0]; | dt = MySQLHelper.ExecuteDataSet(strSql).Tables[0]; | ||||
@@ -1 +1 @@ | |||||
BFEBFBFF000B06A2_7413EA0CEB72_7613EA0CEB71_7413EA0CEB71 | |||||
BFEBFBFF000A0652_B025AA3FD303_00FF7AB4C9BA_8C554AD3D7A5_8E554AD3D7A4_8C554AD3D7A4_8C554AD3D7A8 |