12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- using Abp;
- using DataTransmission.Joint;
- using System.CodeDom.Compiler;
- using System.Data;
- namespace DataTransmission
- {
- public partial class Form1 : Form
- {
- private readonly Order order = new Order();
- private readonly Execute execute = new Execute();
- private readonly CommonTool tool = new CommonTool();
- private readonly Knowledge knowledge = new Knowledge();
- public Form1()
- {
- InitializeComponent();
- }
- private void btn_tb_Click(object sender, EventArgs e)
- {
- btn_tb.Enabled = false;
- if (cb_opp.Checked)
- {//同步工单发布公开数据ExecuteInsertOrderPublic
- execute.ExecuteInsertOrderPublic(st_time.Value.ToString("yyyy-MM-dd") + " 00:00:00", end_time.Value.ToString("yyyy-MM-dd") + " 23:59:59");
- }
- if (cb_tz.Checked)
- {
- execute.ExecuteInsertNotice(st_time.Value.ToString("yyyy-MM-dd") + " 00:00:00", end_time.Value.ToString("yyyy-MM-dd") + " 23:59:59");
- }
- if (cb_zsk.Checked)
- {
- execute.ExecuteInsertKnowledge(st_time.Value.ToString("yyyy-MM-dd") + " 00:00:00", end_time.Value.ToString("yyyy-MM-dd") + " 23:59:59");
- }
- if (cb_zsklx.Checked)
- {
- //知识库类型
- execute.ExecuteTypeSql();
- }
- if (cb_order.Checked)
- {
- ExecuteInsert();
- }
- if (cb_jg.Checked)
- {
- execute.ExecuteOrganizeSql();
- }
- if (cb_user.Checked)
- {
- execute.ExecuteUserSql();
- //工号
- //execute.ExecuteStaffSql();
- }
- MessageBox.Show("同步完成!请先别关闭程序!");
- btn_tb.Enabled = true;
- }
- private void ExecuteInsert()
- {
- var orderTable = order.GetOrder(st_time.Value.ToString("yyyy-MM-dd") + " 00:00:00", end_time.Value.ToString("yyyy-MM-dd") + " 23:59:59");
- var count = orderTable.Rows.Count;
- var exNum = 0;
- var threadNum = 100;
- var divisor = count / threadNum;
- var remainder = count % threadNum;
- for (int i = 0; i < divisor; i++)
- {
- var stNum = exNum;
- var enNum = exNum + threadNum;
- var data = orderTable.AsEnumerable().Where(x => ((int)x.Field<long>("Serial")) > stNum && ((int)x.Field<long>("Serial")) <= enNum).CopyToDataTable();
- execute.ExecuteSql(data);
- exNum += threadNum;
- }
- if (remainder > 0)
- {
- var stNum = divisor * threadNum;
- var data = orderTable.AsEnumerable().Where(x => ((int)x.Field<long>("Serial")) >= stNum).CopyToDataTable();
- execute.ExecuteSql(data);
- }
- }
- }
- }
|