1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- 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.Enabled)
- {//同步工单发布公开数据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");
- //知识库类型
- //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);
- }
- }
- }
- }
|