|
@@ -2,6 +2,8 @@
|
|
|
using System;
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
using System.Collections.Generic;
|
|
|
using System.Data;
|
|
using System.Data;
|
|
|
|
|
+using System.Globalization;
|
|
|
|
|
+using System.Linq;
|
|
|
using System.Text;
|
|
using System.Text;
|
|
|
using System.Threading;
|
|
using System.Threading;
|
|
|
using System.Windows.Forms;
|
|
using System.Windows.Forms;
|
|
@@ -80,11 +82,11 @@ namespace UAS_CheckWork
|
|
|
MessageBox.Show("请先连接设备", "Error");
|
|
MessageBox.Show("请先连接设备", "Error");
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
InitGetInfo = new Thread(InPrint);
|
|
InitGetInfo = new Thread(InPrint);
|
|
|
SetLoadingWindow stw = new SetLoadingWindow(InitGetInfo, "正在同步数据...");
|
|
SetLoadingWindow stw = new SetLoadingWindow(InitGetInfo, "正在同步数据...");
|
|
|
stw.StartPosition = FormStartPosition.CenterParent;
|
|
stw.StartPosition = FormStartPosition.CenterParent;
|
|
|
stw.ShowDialog();
|
|
stw.ShowDialog();
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void InPrint()
|
|
private void InPrint()
|
|
@@ -95,8 +97,13 @@ namespace UAS_CheckWork
|
|
|
{
|
|
{
|
|
|
//循环获取
|
|
//循环获取
|
|
|
DataTable dt = new DataTable();
|
|
DataTable dt = new DataTable();
|
|
|
- dt.Columns.Add("cl_emcode");
|
|
|
|
|
|
|
+ string LastDate = dh.getFieldDataByCondition("cardlog", "to_char(max(cl_time),'yyyy-MM-dd HH24:mi:ss')", "cl_address='考勤机数据导入'").ToString();
|
|
|
|
|
+ dt.Columns.Add("cl_cardcode");
|
|
|
dt.Columns.Add("cl_time");
|
|
dt.Columns.Add("cl_time");
|
|
|
|
|
+ if (LastDate == "")
|
|
|
|
|
+ {
|
|
|
|
|
+ LastDate = "1990-01-01 00:00:00";
|
|
|
|
|
+ }
|
|
|
string enrollNumber = "";//记录用户ID
|
|
string enrollNumber = "";//记录用户ID
|
|
|
int verifyCode = 0;//记录用户验证方式 0 为密码验证,1 为指纹验证,2 为卡验证
|
|
int verifyCode = 0;//记录用户验证方式 0 为密码验证,1 为指纹验证,2 为卡验证
|
|
|
int inoutMode = 0;//考勤状态,具体含义如下: 默认 0—Check-In 1—Check-Out 2—Break-Out 3—Break-In 4—OT-In 5—OT-Out
|
|
int inoutMode = 0;//考勤状态,具体含义如下: 默认 0—Check-In 1—Check-Out 2—Break-Out 3—Break-In 4—OT-In 5—OT-Out
|
|
@@ -110,28 +117,41 @@ namespace UAS_CheckWork
|
|
|
List<string> cl_cardcode = new List<string>();
|
|
List<string> cl_cardcode = new List<string>();
|
|
|
List<string> cl_time = new List<string>();
|
|
List<string> cl_time = new List<string>();
|
|
|
StringBuilder sql = new StringBuilder();
|
|
StringBuilder sql = new StringBuilder();
|
|
|
- sql.Append("insert into cardlog (cl_id,cl_cardcode,cl_time) values (cardlog_seq.nextval,:cl_emcode,TO_DATE(:cl_time,'yyyy-MM-dd hh24:mi:ss'))");
|
|
|
|
|
|
|
+ sql.Append("insert into cardlog (cl_id,cl_cardcode,cl_time,cl_address) values (cardlog_seq.nextval,:cl_emcode,TO_DATE(:cl_time,'yyyy-MM-dd hh24:mi:ss'),'考勤机数据导入')");
|
|
|
int count = 0;
|
|
int count = 0;
|
|
|
while (axCZKEM1.SSR_GetGeneralLogData(iMachineNumber, out enrollNumber, out verifyCode, out inoutMode, out year, out month, out day, out hour, out minute, out second, ref workCode))
|
|
while (axCZKEM1.SSR_GetGeneralLogData(iMachineNumber, out enrollNumber, out verifyCode, out inoutMode, out year, out month, out day, out hour, out minute, out second, ref workCode))
|
|
|
{
|
|
{
|
|
|
- cl_cardcode.Add(enrollNumber);
|
|
|
|
|
- cl_time.Add(year + "-" + month + "-" + day + " " + hour + ":" + minute + ":" + second);
|
|
|
|
|
- if (count % 1000 == 0)
|
|
|
|
|
|
|
+ string logtime = year + "-" + month + "-" + day + " " + hour + ":" + minute + ":" + second;
|
|
|
|
|
+ if (Convert.ToDateTime(logtime) > Convert.ToDateTime(LastDate))
|
|
|
{
|
|
{
|
|
|
- dh.BatchInsert(sql.ToString(), new string[] { "cl_cardcode", "cl_time" }, cl_cardcode.ToArray(), cl_time.ToArray());
|
|
|
|
|
- cl_cardcode.Clear();
|
|
|
|
|
- cl_time.Clear();
|
|
|
|
|
|
|
+ cl_cardcode.Add(enrollNumber);
|
|
|
|
|
+ cl_time.Add(year + "-" + month + "-" + day + " " + hour + ":" + minute + ":" + second);
|
|
|
|
|
+ if (count % 1000 == 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ dh.BatchInsert(sql.ToString(), new string[] { "cl_cardcode", "cl_time" }, cl_cardcode.ToArray(), cl_time.ToArray());
|
|
|
|
|
+ cl_cardcode.Clear();
|
|
|
|
|
+ cl_time.Clear();
|
|
|
|
|
+ }
|
|
|
|
|
+ count = count + 1;
|
|
|
|
|
+ //将数据加入DataTable中
|
|
|
|
|
+ DataRow dr = dt.NewRow();
|
|
|
|
|
+ dr["cl_cardcode"] = enrollNumber;
|
|
|
|
|
+ dr["cl_time"] = logtime;
|
|
|
|
|
+ dt.Rows.Add(dr);
|
|
|
}
|
|
}
|
|
|
- count = count + 1;
|
|
|
|
|
- //将数据加入DataTable中
|
|
|
|
|
- DataRow dr = dt.NewRow();
|
|
|
|
|
- dr["cl_emcode"] = enrollNumber;
|
|
|
|
|
- dr["cl_time"] = year + "-" + month + "-" + day + " " + hour + ":" + minute + ":" + second;
|
|
|
|
|
- dt.Rows.Add(dr);
|
|
|
|
|
}
|
|
}
|
|
|
- dh.BatchInsert(sql.ToString(), new string[] { "cl_cardcode", "cl_time" }, cl_cardcode.ToArray(), cl_time.ToArray());
|
|
|
|
|
|
|
+ if (cl_time.Count > 0)
|
|
|
|
|
+ dh.BatchInsert(sql.ToString(), new string[] { "cl_cardcode", "cl_time" }, cl_cardcode.ToArray(), cl_time.ToArray());
|
|
|
allData.DataSource = dt;
|
|
allData.DataSource = dt;
|
|
|
showDataGrid.DataSource = (DataTable)allData.DataSource;
|
|
showDataGrid.DataSource = (DataTable)allData.DataSource;
|
|
|
|
|
+ if (dt.Rows.Count > 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ MessageBox.Show("数据同步成功");
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ MessageBox.Show("没有需要同步的数据");
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
else
|
|
else
|
|
|
{
|
|
{
|
|
@@ -140,27 +160,9 @@ namespace UAS_CheckWork
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- private void saveData_Click(object sender, EventArgs e)
|
|
|
|
|
|
|
+ private void showDataGrid_DataError(object sender, DataGridViewDataErrorEventArgs e)
|
|
|
{
|
|
{
|
|
|
- //点击保存数据
|
|
|
|
|
- string lastTime = dh.getFieldDataByCondition("cardlog", "TO_CHAR(max(wl_indate),'yyyy-MM-dd hh24:mi:ss')", "1=1").ToString();
|
|
|
|
|
- //筛选数据
|
|
|
|
|
- DataTable fd = dh.filterDataTable((DataTable)allData.DataSource, "cl_time > '" + lastTime + "'");
|
|
|
|
|
- //插入数据库
|
|
|
|
|
- //新增的数据
|
|
|
|
|
- List<string> cl_emcode = new List<string>();
|
|
|
|
|
- List<string> cl_time = new List<string>();
|
|
|
|
|
- for (int i = 0; i < fd.Rows.Count; i++)
|
|
|
|
|
- {
|
|
|
|
|
- cl_emcode.Add(fd.Rows[i]["cl_emcode"].ToString());
|
|
|
|
|
- cl_time.Add(fd.Rows[i]["cl_time"].ToString());
|
|
|
|
|
- }
|
|
|
|
|
- //批量插入
|
|
|
|
|
- StringBuilder sql = new StringBuilder();
|
|
|
|
|
- sql.Append("insert into cardlog (cl_id,cl_emcode,cl_time) values (cardlog_seq.nextval,:cl_emcode,TO_DATE(:cl_time,'yyyy-MM-dd hh24:mi:ss'))");
|
|
|
|
|
- dh.BatchInsert(sql.ToString(), new string[] { "cl_emcode", "cl_time" }, cl_emcode.ToArray(), cl_time.ToArray());
|
|
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|