You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

166 lines
5.5 KiB

  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading;
  9. using System.Threading.Tasks;
  10. using System.Windows.Forms;
  11. using Learun.Application.TwoDevelopment.EvaluationTeach;
  12. namespace Quanjiang.DigitalScholl.Tools
  13. {
  14. public partial class FormProgress : Form
  15. {
  16. private Eval_MainIBLL ask_MainIBLL = new Eval_MainBLL();
  17. Thread thread = null;
  18. int max = 0;
  19. public FormProgress()
  20. {
  21. InitializeComponent();
  22. }
  23. private void FormProgress_Load(object sender, EventArgs e)
  24. {
  25. progressBar1.Minimum = 0;
  26. progressBar1.Maximum = max;
  27. progressBar1.Value = 0;
  28. ThreadStart start = new ThreadStart(SyncCoreDB);
  29. thread = new Thread(start);
  30. thread.Start();
  31. }
  32. public void SyncCoreDB()
  33. {
  34. try
  35. {
  36. SetValueProgressBar(SetValue, 0);
  37. string vid = "9d2191c4-a709-4a0f-b49b-7ad46667d4e9";
  38. //获取超过100分的数据
  39. AppendTextValue("获取超过100分的数据,请耐心等待...\r\n");
  40. var list = ask_MainIBLL.GetAllNeedClean(vid);
  41. AppendTextValue("获取超过100分的数据,共"+list.Count+"条,完毕.\r\n");
  42. SetProgressMax(list.Count);
  43. //获取vid下问题
  44. AppendTextValue("获取vid下问题,请耐心等待...\r\n");
  45. var questionlist = ask_MainIBLL.GetAllQuestion(vid);
  46. AppendTextValue("获取vid下问题,完毕.\r\n");
  47. //开始循环超100数据
  48. foreach (var item in list)
  49. {
  50. SetValueProgressBar(SetValue, GetProgressValue() + 1);
  51. foreach (var questionEntity in questionlist)
  52. {
  53. //获取重复数据
  54. AppendTextValue("获取LessonNo="+item.LessonNo + ",EmpNo=" + item.EmpNo + ",StuNo="+item.StuNo + ",QID="+questionEntity.QID+"的重复数据,请耐心等待...\r\n");
  55. var muiltyresultlist = ask_MainIBLL.GetMuiltyResults(vid, item.LessonNo, item.EmpNo, item.StuNo,questionEntity.QID);
  56. AppendTextValue("总计:"+ muiltyresultlist .Count+ "条重复数据,done.\r\n");
  57. for (int i = 0; i < muiltyresultlist.Count() - 1; i++)
  58. {
  59. //循环删除
  60. string rid = muiltyresultlist[i].RID;
  61. ask_MainIBLL.DeleteQestionResult(rid);
  62. AppendTextValue("删除第:" +i+ "条,done.\r\n");
  63. }
  64. }
  65. }
  66. CloseWindow();
  67. }
  68. catch (Exception e)
  69. {
  70. AppendTextValue("error:" + e.Message + "\r\n");
  71. }
  72. }
  73. #region 委托
  74. public delegate void AppendTextValueDelegate(string text);
  75. public delegate void SetValueDelegate(int val);
  76. public delegate void CloseWindowDelegate();
  77. public delegate void SetWindowTitleDelegate(string text);
  78. public delegate int GetProgressValueDelegate();
  79. public delegate void SetProgressMaxDelegate(int max);
  80. public void AppendTextValue(string text)
  81. {
  82. if (this.rtblog.InvokeRequired)
  83. {
  84. AppendTextValueDelegate callback = new AppendTextValueDelegate(AppendTextValue);
  85. this.Invoke(callback, text);
  86. }
  87. else
  88. {
  89. rtblog.AppendText(text);
  90. }
  91. }
  92. public void SetProgressMax(int max)
  93. {
  94. if (this.progressBar1.InvokeRequired)
  95. {
  96. SetProgressMaxDelegate callback = new SetProgressMaxDelegate(SetProgressMax);
  97. this.Invoke(callback, max);
  98. }
  99. else
  100. {
  101. progressBar1.Maximum = max;
  102. }
  103. }
  104. public int GetProgressValue()
  105. {
  106. if (this.progressBar1.InvokeRequired)
  107. {
  108. GetProgressValueDelegate callback = new GetProgressValueDelegate(GetProgressValue);
  109. return Convert.ToInt32(this.Invoke(callback));
  110. }
  111. else
  112. {
  113. return progressBar1.Value;
  114. }
  115. }
  116. public void SetWindowTitle(string text)
  117. {
  118. if (this.InvokeRequired)
  119. {
  120. SetWindowTitleDelegate callback = new SetWindowTitleDelegate(SetWindowTitle);
  121. this.Invoke(callback, text);
  122. }
  123. else
  124. {
  125. this.Text = text;
  126. }
  127. }
  128. public void CloseWindow()
  129. {
  130. if (this.InvokeRequired)
  131. {
  132. CloseWindowDelegate callback = new CloseWindowDelegate(CloseWindow);
  133. this.Invoke(callback);
  134. }
  135. else
  136. {
  137. this.Close();
  138. }
  139. }
  140. public void SetValue(int val)
  141. {
  142. progressBar1.Value = val;
  143. }
  144. public void SetValueProgressBar(SetValueDelegate myDelegate, int val)
  145. {
  146. if (this.progressBar1.InvokeRequired)
  147. {
  148. this.Invoke(myDelegate, val);
  149. }
  150. else
  151. {
  152. myDelegate(val);
  153. }
  154. }
  155. #endregion
  156. }
  157. }