Form1.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. using Abp;
  2. using DataTransmission.Joint;
  3. using System.CodeDom.Compiler;
  4. using System.Data;
  5. namespace DataTransmission
  6. {
  7. public partial class Form1 : Form
  8. {
  9. private readonly Order order = new Order();
  10. private readonly Execute execute = new Execute();
  11. private readonly CommonTool tool = new CommonTool();
  12. private readonly Knowledge knowledge = new Knowledge();
  13. public static string Name = string.Empty;
  14. public static string CenterId = string.Empty;
  15. public static string Paseword = string.Empty;
  16. public static string ModuleId = string.Empty;
  17. public Form1()
  18. {
  19. InitializeComponent();
  20. cbox_bb.Items.Add("宜宾");
  21. cbox_bb.Items.Add("自贡");
  22. cbox_bb.Items.Add("泸州");
  23. cbox_bb.SelectedIndex = 0;
  24. }
  25. private void btn_tb_Click(object sender, EventArgs e)
  26. {
  27. btn_tb.Enabled = false;
  28. //if (cbox_bb.SelectedText ="宜宾")
  29. //{
  30. //}
  31. switch (cbox_bb.SelectedText)
  32. {
  33. case "宜宾":
  34. Name = "宜宾市";
  35. CenterId = "23";
  36. Paseword = "AQAAAAIAAYagAAAAELQ9clcozvhLoTC0pUjUwv40VXsIp3JyxFhEmqVQOmBLMZ7gGmne6cqL9FHXb0CUBQ==";
  37. ModuleId = "08db8db3-eea4-4737-88dd-6c7b990c7705";
  38. break;
  39. case "自贡":
  40. Name = "自贡市";
  41. CenterId = "2";
  42. Paseword = "AQAAAAIAAYagAAAAEJZNauXWsvzHDvSCLEwNjA3qVJcQqEHAexlWDg6ONJJtK5hDNnL8gwwXxwZW5YszfA==";
  43. ModuleId = "2430d69a-59df-46a1-b155-85e69cfba010";
  44. break;
  45. case "泸州":
  46. Name = "泸州市";
  47. CenterId = "23";
  48. Paseword = "AQAAAAIAAYagAAAAELQ9clcozvhLoTC0pUjUwv40VXsIp3JyxFhEmqVQOmBLMZ7gGmne6cqL9FHXb0CUBQ==";
  49. ModuleId = "08db8db3-eea4-4737-88dd-6c7b990c7705";
  50. break;
  51. default:
  52. break;
  53. }
  54. if (cb_opp.Checked)
  55. {//同步工单发布公开数据ExecuteInsertOrderPublic
  56. execute.ExecuteInsertOrderPublic(st_time.Value.ToString("yyyy-MM-dd") + " 00:00:00", end_time.Value.ToString("yyyy-MM-dd") + " 23:59:59");
  57. }
  58. if (cb_tz.Checked)
  59. {
  60. execute.ExecuteInsertNotice(st_time.Value.ToString("yyyy-MM-dd") + " 00:00:00", end_time.Value.ToString("yyyy-MM-dd") + " 23:59:59");
  61. }
  62. if (cb_zsk.Checked)
  63. {
  64. execute.ExecuteInsertKnowledge(st_time.Value.ToString("yyyy-MM-dd") + " 00:00:00", end_time.Value.ToString("yyyy-MM-dd") + " 23:59:59");
  65. }
  66. if (cb_zsklx.Checked)
  67. {
  68. //知识库类型
  69. execute.ExecuteTypeSql();
  70. }
  71. if (cb_order.Checked)
  72. {
  73. ExecuteInsert();
  74. }
  75. if (cb_jg.Checked)
  76. {
  77. execute.ExecuteOrganizeSql();
  78. }
  79. if (cb_user.Checked)
  80. {
  81. execute.ExecuteUserSql();
  82. //工号
  83. //execute.ExecuteStaffSql();
  84. }
  85. MessageBox.Show("同步完成!请先别关闭程序!");
  86. btn_tb.Enabled = true;
  87. }
  88. private void ExecuteInsert()
  89. {
  90. var orderTable = order.GetOrder(st_time.Value.ToString("yyyy-MM-dd") + " 00:00:00", end_time.Value.ToString("yyyy-MM-dd") + " 23:59:59");
  91. var count = orderTable.Rows.Count;
  92. var exNum = 0;
  93. var threadNum = 100;
  94. var divisor = count / threadNum;
  95. var remainder = count % threadNum;
  96. for (int i = 0; i < divisor; i++)
  97. {
  98. var stNum = exNum;
  99. var enNum = exNum + threadNum;
  100. var data = orderTable.AsEnumerable().Where(x => ((int)x.Field<long>("Serial")) > stNum && ((int)x.Field<long>("Serial")) <= enNum).CopyToDataTable();
  101. execute.ExecuteSql(data);
  102. exNum += threadNum;
  103. }
  104. if (remainder > 0)
  105. {
  106. var stNum = divisor * threadNum;
  107. var data = orderTable.AsEnumerable().Where(x => ((int)x.Field<long>("Serial")) >= stNum).CopyToDataTable();
  108. execute.ExecuteSql(data);
  109. }
  110. }
  111. }
  112. }