diff --git a/CNAS_RunSync/app.config b/CNAS_RunSync/app.config
index f306c20..4c47e64 100644
--- a/CNAS_RunSync/app.config
+++ b/CNAS_RunSync/app.config
@@ -1,66 +1,53 @@
-
+
-
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
-
-
+
+
-
-
+
+
-
-
-
-
-
+
+
+
+
+
-
+
-
-
+
+
-
-
-
-
-
+
+
+
+
+
-
+
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
diff --git a/CNAS_RunSync/frmSynchrousMain.Designer.cs b/CNAS_RunSync/frmSynchrousMain.Designer.cs
index 9a6d485..6f7272e 100644
--- a/CNAS_RunSync/frmSynchrousMain.Designer.cs
+++ b/CNAS_RunSync/frmSynchrousMain.Designer.cs
@@ -54,7 +54,7 @@
this.pnlLeft.Location = new System.Drawing.Point(0, 0);
this.pnlLeft.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.pnlLeft.Name = "pnlLeft";
- this.pnlLeft.Size = new System.Drawing.Size(5, 621);
+ this.pnlLeft.Size = new System.Drawing.Size(5, 793);
this.pnlLeft.TabIndex = 0;
//
// pnlAll
@@ -68,7 +68,7 @@
this.pnlAll.Location = new System.Drawing.Point(0, 0);
this.pnlAll.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.pnlAll.Name = "pnlAll";
- this.pnlAll.Size = new System.Drawing.Size(944, 621);
+ this.pnlAll.Size = new System.Drawing.Size(1207, 793);
this.pnlAll.TabIndex = 1;
//
// pnlCenter
@@ -80,7 +80,7 @@
this.pnlCenter.Location = new System.Drawing.Point(5, 3);
this.pnlCenter.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.pnlCenter.Name = "pnlCenter";
- this.pnlCenter.Size = new System.Drawing.Size(934, 613);
+ this.pnlCenter.Size = new System.Drawing.Size(1197, 785);
this.pnlCenter.TabIndex = 4;
//
// pnlCenterCenter
@@ -89,7 +89,7 @@
this.pnlCenterCenter.Location = new System.Drawing.Point(0, 30);
this.pnlCenterCenter.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.pnlCenterCenter.Name = "pnlCenterCenter";
- this.pnlCenterCenter.Size = new System.Drawing.Size(934, 579);
+ this.pnlCenterCenter.Size = new System.Drawing.Size(1197, 751);
this.pnlCenterCenter.TabIndex = 3;
//
// pnlCenterTop
@@ -99,12 +99,11 @@
this.pnlCenterTop.Location = new System.Drawing.Point(0, 0);
this.pnlCenterTop.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.pnlCenterTop.Name = "pnlCenterTop";
- this.pnlCenterTop.Size = new System.Drawing.Size(934, 30);
+ this.pnlCenterTop.Size = new System.Drawing.Size(1197, 30);
this.pnlCenterTop.TabIndex = 2;
//
// menuButton
//
- this.menuButton.GripMargin = new System.Windows.Forms.Padding(2, 2, 0, 2);
this.menuButton.ImageScalingSize = new System.Drawing.Size(24, 24);
this.menuButton.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.tsmDbSeting,
@@ -113,7 +112,7 @@
this.menuButton.Location = new System.Drawing.Point(0, 0);
this.menuButton.Name = "menuButton";
this.menuButton.Padding = new System.Windows.Forms.Padding(7, 3, 0, 3);
- this.menuButton.Size = new System.Drawing.Size(934, 34);
+ this.menuButton.Size = new System.Drawing.Size(1197, 27);
this.menuButton.TabIndex = 0;
this.menuButton.Text = "menuStrip1";
this.menuButton.ItemClicked += new System.Windows.Forms.ToolStripItemClickedEventHandler(this.menuButton_ItemClicked);
@@ -121,40 +120,40 @@
// tsmDbSeting
//
this.tsmDbSeting.Name = "tsmDbSeting";
- this.tsmDbSeting.Size = new System.Drawing.Size(139, 28);
+ this.tsmDbSeting.Size = new System.Drawing.Size(96, 21);
this.tsmDbSeting.Text = "数据库配置(&B)";
this.tsmDbSeting.Click += new System.EventHandler(this.tsmDbSeting_Click);
//
// tsmSynchrousSetting
//
this.tsmSynchrousSetting.Name = "tsmSynchrousSetting";
- this.tsmSynchrousSetting.Size = new System.Drawing.Size(120, 28);
+ this.tsmSynchrousSetting.Size = new System.Drawing.Size(83, 21);
this.tsmSynchrousSetting.Text = "同步配置(&S)";
this.tsmSynchrousSetting.Click += new System.EventHandler(this.tsmSynchrousSetting_Click);
//
// tsmHelper
//
this.tsmHelper.Name = "tsmHelper";
- this.tsmHelper.Size = new System.Drawing.Size(88, 28);
+ this.tsmHelper.Size = new System.Drawing.Size(61, 21);
this.tsmHelper.Text = "帮助(&H)";
this.tsmHelper.Click += new System.EventHandler(this.tsmHelper_Click);
//
// pnlCenterBottom
//
this.pnlCenterBottom.Dock = System.Windows.Forms.DockStyle.Bottom;
- this.pnlCenterBottom.Location = new System.Drawing.Point(0, 609);
+ this.pnlCenterBottom.Location = new System.Drawing.Point(0, 781);
this.pnlCenterBottom.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.pnlCenterBottom.Name = "pnlCenterBottom";
- this.pnlCenterBottom.Size = new System.Drawing.Size(934, 4);
+ this.pnlCenterBottom.Size = new System.Drawing.Size(1197, 4);
this.pnlCenterBottom.TabIndex = 0;
//
// pnlBottom
//
this.pnlBottom.Dock = System.Windows.Forms.DockStyle.Bottom;
- this.pnlBottom.Location = new System.Drawing.Point(5, 616);
+ this.pnlBottom.Location = new System.Drawing.Point(5, 788);
this.pnlBottom.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.pnlBottom.Name = "pnlBottom";
- this.pnlBottom.Size = new System.Drawing.Size(934, 5);
+ this.pnlBottom.Size = new System.Drawing.Size(1197, 5);
this.pnlBottom.TabIndex = 3;
//
// pnlTop
@@ -163,23 +162,23 @@
this.pnlTop.Location = new System.Drawing.Point(5, 0);
this.pnlTop.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.pnlTop.Name = "pnlTop";
- this.pnlTop.Size = new System.Drawing.Size(934, 3);
+ this.pnlTop.Size = new System.Drawing.Size(1197, 3);
this.pnlTop.TabIndex = 2;
//
// pnlRight
//
this.pnlRight.Dock = System.Windows.Forms.DockStyle.Right;
- this.pnlRight.Location = new System.Drawing.Point(939, 0);
+ this.pnlRight.Location = new System.Drawing.Point(1202, 0);
this.pnlRight.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.pnlRight.Name = "pnlRight";
- this.pnlRight.Size = new System.Drawing.Size(5, 621);
+ this.pnlRight.Size = new System.Drawing.Size(5, 793);
this.pnlRight.TabIndex = 1;
//
// frmSynchrousMain
//
- this.AutoScaleDimensions = new System.Drawing.SizeF(11F, 24F);
+ this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 17F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(944, 621);
+ this.ClientSize = new System.Drawing.Size(1207, 793);
this.Controls.Add(this.pnlAll);
this.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
diff --git a/CNAS_RunSync/ucSynchrousMain.Designer.cs b/CNAS_RunSync/ucSynchrousMain.Designer.cs
index c5db9cf..15f29ab 100644
--- a/CNAS_RunSync/ucSynchrousMain.Designer.cs
+++ b/CNAS_RunSync/ucSynchrousMain.Designer.cs
@@ -35,7 +35,7 @@
this.pnlCenterBody_Center = new System.Windows.Forms.Panel();
this.dgvSyncData = new System.Windows.Forms.DataGridView();
this.pnlCenterBody_Bottom = new System.Windows.Forms.Panel();
- this.pnlSubmit_Right = new System.Windows.Forms.Panel();
+ this.lblTitleLastUpdateTime = new System.Windows.Forms.Label();
this.btnRunData = new System.Windows.Forms.Button();
this.pnlCenterBody_Top = new System.Windows.Forms.Panel();
this.tableTop = new System.Windows.Forms.TableLayoutPanel();
@@ -68,13 +68,13 @@
this.pnlLeft = new System.Windows.Forms.Panel();
this.pnlBottom = new System.Windows.Forms.Panel();
this.pnlTop = new System.Windows.Forms.Panel();
+ this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
this.pnlAll.SuspendLayout();
this.pnlCenter.SuspendLayout();
this.pnlCenterBody.SuspendLayout();
this.pnlCenterBody_Center.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.dgvSyncData)).BeginInit();
this.pnlCenterBody_Bottom.SuspendLayout();
- this.pnlSubmit_Right.SuspendLayout();
this.pnlCenterBody_Top.SuspendLayout();
this.tableTop.SuspendLayout();
this.pnlSelect.SuspendLayout();
@@ -83,6 +83,7 @@
this.pnlDate.SuspendLayout();
this.pnlCenterBottom.SuspendLayout();
this.pnlCenterBottom_Top.SuspendLayout();
+ this.tableLayoutPanel1.SuspendLayout();
this.SuspendLayout();
//
// pnlAll
@@ -147,29 +148,34 @@
// pnlCenterBody_Bottom
//
this.pnlCenterBody_Bottom.BackColor = System.Drawing.Color.White;
- this.pnlCenterBody_Bottom.Controls.Add(this.pnlSubmit_Right);
+ this.pnlCenterBody_Bottom.Controls.Add(this.tableLayoutPanel1);
this.pnlCenterBody_Bottom.Dock = System.Windows.Forms.DockStyle.Bottom;
this.pnlCenterBody_Bottom.Location = new System.Drawing.Point(0, 390);
this.pnlCenterBody_Bottom.Name = "pnlCenterBody_Bottom";
this.pnlCenterBody_Bottom.Size = new System.Drawing.Size(916, 41);
this.pnlCenterBody_Bottom.TabIndex = 1;
//
- // pnlSubmit_Right
+ // lblTitleLastUpdateTime
//
- this.pnlSubmit_Right.Controls.Add(this.btnRunData);
- this.pnlSubmit_Right.Dock = System.Windows.Forms.DockStyle.Right;
- this.pnlSubmit_Right.Location = new System.Drawing.Point(716, 0);
- this.pnlSubmit_Right.Name = "pnlSubmit_Right";
- this.pnlSubmit_Right.Size = new System.Drawing.Size(200, 41);
- this.pnlSubmit_Right.TabIndex = 3;
+ this.lblTitleLastUpdateTime.AutoSize = true;
+ this.lblTitleLastUpdateTime.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.lblTitleLastUpdateTime.Font = new System.Drawing.Font("微软雅黑", 8F);
+ this.lblTitleLastUpdateTime.Location = new System.Drawing.Point(3, 0);
+ this.lblTitleLastUpdateTime.Name = "lblTitleLastUpdateTime";
+ this.lblTitleLastUpdateTime.Size = new System.Drawing.Size(814, 41);
+ this.lblTitleLastUpdateTime.TabIndex = 2;
+ this.lblTitleLastUpdateTime.Text = "最近上传时间:<未知>";
+ this.lblTitleLastUpdateTime.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// btnRunData
//
+ this.btnRunData.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+ | System.Windows.Forms.AnchorStyles.Right)));
this.btnRunData.Image = ((System.Drawing.Image)(resources.GetObject("btnRunData.Image")));
this.btnRunData.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
- this.btnRunData.Location = new System.Drawing.Point(100, 4);
+ this.btnRunData.Location = new System.Drawing.Point(823, 3);
this.btnRunData.Name = "btnRunData";
- this.btnRunData.Size = new System.Drawing.Size(90, 30);
+ this.btnRunData.Size = new System.Drawing.Size(90, 35);
this.btnRunData.TabIndex = 2;
this.btnRunData.Text = "执行上传";
this.btnRunData.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
@@ -191,7 +197,7 @@
this.tableTop.ColumnCount = 3;
this.tableTop.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 95.77922F));
this.tableTop.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 4.220779F));
- this.tableTop.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 537F));
+ this.tableTop.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 540F));
this.tableTop.Controls.Add(this.pnlSelect, 0, 0);
this.tableTop.Controls.Add(this.pnlRunData, 1, 0);
this.tableTop.Controls.Add(this.pnlConfig, 2, 0);
@@ -210,16 +216,16 @@
this.pnlSelect.Dock = System.Windows.Forms.DockStyle.Fill;
this.pnlSelect.Location = new System.Drawing.Point(3, 3);
this.pnlSelect.Name = "pnlSelect";
- this.pnlSelect.Size = new System.Drawing.Size(357, 78);
+ this.pnlSelect.Size = new System.Drawing.Size(354, 78);
this.pnlSelect.TabIndex = 0;
//
// lblTitleMsg
//
this.lblTitleMsg.AutoSize = true;
this.lblTitleMsg.Font = new System.Drawing.Font("微软雅黑", 8F);
- this.lblTitleMsg.Location = new System.Drawing.Point(7, 39);
+ this.lblTitleMsg.Location = new System.Drawing.Point(7, 50);
this.lblTitleMsg.Name = "lblTitleMsg";
- this.lblTitleMsg.Size = new System.Drawing.Size(156, 16);
+ this.lblTitleMsg.Size = new System.Drawing.Size(155, 16);
this.lblTitleMsg.TabIndex = 1;
this.lblTitleMsg.Text = "类型:<未知> 路径:<未知>";
//
@@ -227,7 +233,7 @@
//
this.lblTitle.AutoSize = true;
this.lblTitle.Font = new System.Drawing.Font("微软雅黑", 10F, System.Drawing.FontStyle.Bold);
- this.lblTitle.Location = new System.Drawing.Point(6, 13);
+ this.lblTitle.Location = new System.Drawing.Point(6, 15);
this.lblTitle.Name = "lblTitle";
this.lblTitle.Size = new System.Drawing.Size(119, 19);
this.lblTitle.TabIndex = 0;
@@ -236,7 +242,7 @@
// pnlRunData
//
this.pnlRunData.Dock = System.Windows.Forms.DockStyle.Fill;
- this.pnlRunData.Location = new System.Drawing.Point(366, 3);
+ this.pnlRunData.Location = new System.Drawing.Point(363, 3);
this.pnlRunData.Name = "pnlRunData";
this.pnlRunData.Size = new System.Drawing.Size(9, 78);
this.pnlRunData.TabIndex = 1;
@@ -252,9 +258,9 @@
this.pnlConfig.Controls.Add(this.cmbColumns);
this.pnlConfig.Controls.Add(this.btnFind);
this.pnlConfig.Dock = System.Windows.Forms.DockStyle.Fill;
- this.pnlConfig.Location = new System.Drawing.Point(381, 3);
+ this.pnlConfig.Location = new System.Drawing.Point(378, 3);
this.pnlConfig.Name = "pnlConfig";
- this.pnlConfig.Size = new System.Drawing.Size(532, 78);
+ this.pnlConfig.Size = new System.Drawing.Size(535, 78);
this.pnlConfig.TabIndex = 2;
//
// btnCancelFind
@@ -486,6 +492,21 @@
this.pnlTop.Size = new System.Drawing.Size(920, 5);
this.pnlTop.TabIndex = 0;
//
+ // tableLayoutPanel1
+ //
+ this.tableLayoutPanel1.ColumnCount = 2;
+ this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
+ this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 96F));
+ this.tableLayoutPanel1.Controls.Add(this.btnRunData, 1, 0);
+ this.tableLayoutPanel1.Controls.Add(this.lblTitleLastUpdateTime, 0, 0);
+ this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0);
+ this.tableLayoutPanel1.Name = "tableLayoutPanel1";
+ this.tableLayoutPanel1.RowCount = 1;
+ this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
+ this.tableLayoutPanel1.Size = new System.Drawing.Size(916, 41);
+ this.tableLayoutPanel1.TabIndex = 4;
+ //
// ucSynchrousMain
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 17F);
@@ -502,7 +523,6 @@
this.pnlCenterBody_Center.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.dgvSyncData)).EndInit();
this.pnlCenterBody_Bottom.ResumeLayout(false);
- this.pnlSubmit_Right.ResumeLayout(false);
this.pnlCenterBody_Top.ResumeLayout(false);
this.tableTop.ResumeLayout(false);
this.pnlSelect.ResumeLayout(false);
@@ -516,6 +536,8 @@
this.pnlCenterBottom.ResumeLayout(false);
this.pnlCenterBottom_Top.ResumeLayout(false);
this.pnlCenterBottom_Top.PerformLayout();
+ this.tableLayoutPanel1.ResumeLayout(false);
+ this.tableLayoutPanel1.PerformLayout();
this.ResumeLayout(false);
}
@@ -560,6 +582,7 @@
private System.Windows.Forms.Button btnFind;
private System.Windows.Forms.Label lblTitleMsg;
private System.Windows.Forms.Panel pnlCenterBottom_Line;
- private System.Windows.Forms.Panel pnlSubmit_Right;
+ private System.Windows.Forms.Label lblTitleLastUpdateTime;
+ private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
}
}
diff --git a/CNAS_RunSync/ucSynchrousMain.cs b/CNAS_RunSync/ucSynchrousMain.cs
index b4375a4..c947c88 100644
--- a/CNAS_RunSync/ucSynchrousMain.cs
+++ b/CNAS_RunSync/ucSynchrousMain.cs
@@ -9,6 +9,11 @@ using System.Windows.Forms;
using CnasSynchronusClient;
using CnasSynchrousModel;
using CnasSynchronousCommon;
+using log4net.Repository.Hierarchy;
+using System.Threading;
+using System.IO;
+using Newtonsoft.Json;
+using System.Diagnostics;
namespace CNAS_RunSync
{
@@ -94,24 +99,75 @@ namespace CNAS_RunSync
string strColumnName = item.SourceField;
if (DictField.ContainsKey(strColumnName))
strColumnName = DictField[strColumnName];
- AddDatagridColumn(dgvSyncData, item.SourceField, strColumnName, 150);
+ AddDatagridColumn(dgvSyncData, item.SourceField, strColumnName, 150, bSort: item.IfDateField);
}
//创建GUID列
AddDatagridColumn(dgvSyncData, "GridGuid", "GridGuid", 50, false);
+ //2.2获取数据源数据
+ this.RefreshData();
+
+ //3.初始化查询相关内容
+ //3.1 绑定Combobox数据源
+ foreach (DataColumn dc in dtSource.Columns)
+ {
+ if (syncInstrumentItem.LstSyncPramas.Where(s => s.SourceField == dc.ColumnName.ToUpper()).LongCount() > 0)
+ {
+ string strColumnName = dc.ColumnName.ToUpper();
+ if (DictField.ContainsKey(strColumnName))
+ strColumnName = DictField[strColumnName];
+ DictComboBox.Add(strColumnName, dc.DataType);
+ }
+ }
+ if (DictComboBox.Count > 0)
+ {
+ BindingSource bsComboBox = new BindingSource
+ {
+ DataSource = DictComboBox
+ };
+ cmbColumns.DataSource = bsComboBox;
+ cmbColumns.ValueMember = "Key";
+ cmbColumns.DisplayMember = "Key";
+ }
+
+ //4.初始化最近上传时间
+ //4.1 获取目标表最近上传时间
+ Dictionary times = this.ReadSyncTime();
+ if (true == times?.ContainsKey(this.syncInstrumentItem.Code))
+ {
+ this.lblTitleLastUpdateTime.Text = $"最近上传时间:{times[this.syncInstrumentItem.Code]}";
+ }
+ }
+
+ ///
+ ///
+ ///
+ private void RefreshData()
+ {
+ //清空现有绑定
+ dictSource?.Clear();
+ dtSource?.Clear();
+ dtSource?.Dispose();
+ dtSource = null;
+ dgvSyncData?.Rows?.Clear();
+
//2.2 获取数据源数据,构建datagridviewcell
//2.2.1 获取数据源数据
var query = syncInstrumentItem.LstSyncPramas.Where(s => s.IfDateField == true).ToList();
if (query.Count == 1)
{
object[] obj = new object[]
- {
- syncInstrumentItem.LstSyncPramas[0].SourceTable,
- query[0].SourceField,
- DateTime.Now.AddDays(Convert.ToInt32(delayDays)).ToString("yyyy-MM-dd HH:mm:ss")
- };
+ {
+ syncInstrumentItem.LstSyncPramas[0].SourceTable,
+ query[0].SourceField,
+ DateTime.Now.AddDays(Convert.ToInt32(delayDays)).ToString("yyyy-MM-dd HH:mm:ss")
+ };
InstrumentData instrumentData = InstrumentDataFact.CreateInstrumentDataSource(syncInstrumentItem.SyncInstrumentDSInfo, obj);
dtSource = instrumentData.GetInstrumentDataByDate();
+
+ DataView dv = dtSource.DefaultView;
+ dv.Sort = $"{query[0].SourceField} DESC";
+ dtSource = dv.ToTable();
}
//2.2.2 构建datagridviewcell
@@ -140,29 +196,6 @@ namespace CNAS_RunSync
dictSource.Add(strGuid, dr);
}
-
- //3.初始化查询相关内容
- //3.1 绑定Combobox数据源
- foreach (DataColumn dc in dtSource.Columns)
- {
- if (syncInstrumentItem.LstSyncPramas.Where(s => s.SourceField == dc.ColumnName.ToUpper()).LongCount() > 0)
- {
- string strColumnName = dc.ColumnName.ToUpper();
- if (DictField.ContainsKey(strColumnName))
- strColumnName = DictField[strColumnName];
- DictComboBox.Add(strColumnName, dc.DataType);
- }
- }
- if (DictComboBox.Count > 0)
- {
- BindingSource bsComboBox = new BindingSource
- {
- DataSource = DictComboBox
- };
- cmbColumns.DataSource = bsComboBox;
- cmbColumns.ValueMember = "Key";
- cmbColumns.DisplayMember = "Key";
- }
}
///
@@ -173,7 +206,7 @@ namespace CNAS_RunSync
///
///
///
- private void AddDatagridColumn(DataGridView dgvShow, string strColumnName, string strColumnHeaderText, int Width, bool bVisible = true)
+ private void AddDatagridColumn(DataGridView dgvShow, string strColumnName, string strColumnHeaderText, int Width, bool bVisible = true, bool bSort = false)
{
DataGridViewColumn Column = new DataGridViewColumn()
{
@@ -182,7 +215,8 @@ namespace CNAS_RunSync
Width = Width,
Visible = bVisible,
CellTemplate = new DataGridViewTextBoxCell(),
- ReadOnly = true
+ ReadOnly = true,
+ SortMode = bSort ? DataGridViewColumnSortMode.Automatic : DataGridViewColumnSortMode.NotSortable
};
//设置文本对齐方式
@@ -386,6 +420,15 @@ namespace CNAS_RunSync
AppLog.Error($"未成功上传的数据如下:{TransConvert.ListToString(lstError)}");
WriteMsgToRichTextBox($"未成功上传的数据如下:{TransConvert.ListToString(lstError)}");
}
+
+ // 记录上传时间
+ if (0 < SuccessCount)
+ {
+ DateTime time = DateTime.Now;
+
+ this.lblTitleLastUpdateTime.Text = $"最近上传时间:{time.ToString("yyyy-MM-dd HH:mm:ss")}";
+ this.WriteSyncTime(time);
+ }
}
private string kxjsf(string sss)
@@ -511,7 +554,14 @@ namespace CNAS_RunSync
private void btnFind_Click(object sender, EventArgs e)
{
- if (cmbColumns.SelectedValue == null) return;
+ if (cmbColumns.SelectedValue == null)
+ {
+ return;
+ }
+
+ //0.获取数据源数据
+ this.RefreshData();
+
//1.合法性检测
if (DictComboBox[cmbColumns.SelectedValue.ToString()].ToString().Equals("System.DateTime"))
{
@@ -530,36 +580,34 @@ namespace CNAS_RunSync
}
}
-
//2.将datagridview中满足条件的项修改背景色
//2.1 判断当前显示的datagridview是否含有旧的查询数据
//2.2 将满足条件的项背景色改为特殊颜色
- foreach (DataGridViewRow dgvrow in dgvSyncData.Rows)
+ for (int index = dgvSyncData.Rows.Count - 1; 0 <= index; --index)
{
- dgvrow.DefaultCellStyle.BackColor = Color.White;
-
+ DataGridViewRow row = dgvSyncData.Rows[index];
//查询列的当前值
- string strGuid = dgvrow.Cells["GridGuid"].Value.ToString();
+ string strGuid = row.Cells["GridGuid"].Value.ToString();
if (DictField.Count > 0)
{
var query = DictField.Where(s => s.Value == cmbColumns.SelectedValue.ToString());
if (query.Count() == 1)
{
- string strValue = dgvrow.Cells[query.ElementAtOrDefault(0).Key].Value.ToString();
+ string strValue = row.Cells[query.ElementAtOrDefault(0).Key].Value.ToString();
//判断是否满足条件
- if (CheckMatchCondition(strValue))
+ if (false == CheckMatchCondition(strValue))
{
- dgvrow.DefaultCellStyle.BackColor = FinedBackColor;
+ dgvSyncData.Rows.RemoveAt(index);
}
}
}
else
{
- string strValue = dgvrow.Cells[cmbColumns.SelectedValue.ToString()].Value.ToString();
+ string strValue = row.Cells[cmbColumns.SelectedValue.ToString()].Value.ToString();
//判断是否满足条件
- if (CheckMatchCondition(strValue))
+ if (false == CheckMatchCondition(strValue))
{
- dgvrow.DefaultCellStyle.BackColor = FinedBackColor;
+ dgvSyncData.Rows.RemoveAt(index);
}
}
}
@@ -712,6 +760,83 @@ namespace CNAS_RunSync
{
this.rtxtLog.Text += string.Format("{0} 日期: {1}\n", strMsg,DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
}));
- }
+ }
+
+ ///
+ ///
+ ///
+ ///
+ private void WriteSyncTime(DateTime time)
+ {
+ try
+ {
+ /* 创建文件夹 */
+ string logDirectory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Cache");
+ if (!Directory.Exists(logDirectory))
+ {
+ Directory.CreateDirectory(logDirectory);
+ }
+
+ /* 更新时间 */
+ string file = Path.Combine(logDirectory, $"SyncTime.bin");
+ Dictionary times = this.ReadSyncTime() ?? new Dictionary();
+ if (true == times.ContainsKey(this.syncInstrumentItem.Code))
+ {
+ times[this.syncInstrumentItem.Code] = time.ToString("yyyy-MM-dd HH:mm:ss");
+ }
+ else
+ {
+ times.Add(this.syncInstrumentItem.Code, time.ToString("yyyy-MM-dd HH:mm:ss"));
+ }
+
+ /* 写入文件 */
+ File.WriteAllText(file, JsonConvert.SerializeObject(times, Formatting.Indented));
+ }
+ catch (Exception exception)
+ {
+ Invoke(new MethodInvoker(delegate ()
+ {
+ this.rtxtLog.Text += $"记录同步时间出错!错误信息:{exception.Message} 日期: {DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}\n";
+ }));
+ }
+ }
+
+ ///
+ ///
+ ///
+ private Dictionary ReadSyncTime()
+ {
+ Dictionary times = null;
+
+ if (File.Exists(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Cache", $"SyncTime.bin")))
+ {
+ try
+ {
+ using (StreamReader reader = new StreamReader(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Cache", $"SyncTime.bin"), Encoding.UTF8))
+ {
+ try
+ {
+ string json = reader.ReadToEnd();
+ times = JsonConvert.DeserializeObject>(json);
+ }
+ catch
+ {
+
+ }
+ finally
+ {
+ reader.Close();
+ reader.Dispose();
+ }
+ }
+ }
+ catch (Exception exception)
+ {
+ Debug.WriteLine(exception.Message);
+ }
+ }
+
+ return times;
+ }
}
}