|
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using Learun.Application.TwoDevelopment.EvaluationTeach;
-
- namespace Quanjiang.DigitalScholl.Tools
- {
- public partial class FormProgress : Form
- {
- private Eval_MainIBLL ask_MainIBLL = new Eval_MainBLL();
-
- Thread thread = null;
- int max = 0;
- public FormProgress()
- {
- InitializeComponent();
- }
-
- private void FormProgress_Load(object sender, EventArgs e)
- {
- progressBar1.Minimum = 0;
- progressBar1.Maximum = max;
- progressBar1.Value = 0;
- ThreadStart start = new ThreadStart(SyncCoreDB);
- thread = new Thread(start);
- thread.Start();
- }
-
- public void SyncCoreDB()
- {
- try
- {
- SetValueProgressBar(SetValue, 0);
- string vid = "9d2191c4-a709-4a0f-b49b-7ad46667d4e9";
- //获取超过100分的数据
- AppendTextValue("获取超过100分的数据,请耐心等待...\r\n");
- var list = ask_MainIBLL.GetAllNeedClean(vid);
- AppendTextValue("获取超过100分的数据,共"+list.Count+"条,完毕.\r\n");
- SetProgressMax(list.Count);
- //获取vid下问题
- AppendTextValue("获取vid下问题,请耐心等待...\r\n");
- var questionlist = ask_MainIBLL.GetAllQuestion(vid);
- AppendTextValue("获取vid下问题,完毕.\r\n");
- //开始循环超100数据
- foreach (var item in list)
- {
- SetValueProgressBar(SetValue, GetProgressValue() + 1);
- foreach (var questionEntity in questionlist)
- {
- //获取重复数据
- AppendTextValue("获取LessonNo="+item.LessonNo + ",EmpNo=" + item.EmpNo + ",StuNo="+item.StuNo + ",QID="+questionEntity.QID+"的重复数据,请耐心等待...\r\n");
- var muiltyresultlist = ask_MainIBLL.GetMuiltyResults(vid, item.LessonNo, item.EmpNo, item.StuNo,questionEntity.QID);
- AppendTextValue("总计:"+ muiltyresultlist .Count+ "条重复数据,done.\r\n");
- for (int i = 0; i < muiltyresultlist.Count() - 1; i++)
- {
- //循环删除
- string rid = muiltyresultlist[i].RID;
- ask_MainIBLL.DeleteQestionResult(rid);
- AppendTextValue("删除第:" +i+ "条,done.\r\n");
- }
- }
- }
- CloseWindow();
- }
- catch (Exception e)
- {
- AppendTextValue("error:" + e.Message + "\r\n");
- }
- }
-
- #region 委托
-
- public delegate void AppendTextValueDelegate(string text);
- public delegate void SetValueDelegate(int val);
- public delegate void CloseWindowDelegate();
- public delegate void SetWindowTitleDelegate(string text);
- public delegate int GetProgressValueDelegate();
- public delegate void SetProgressMaxDelegate(int max);
- public void AppendTextValue(string text)
- {
- if (this.rtblog.InvokeRequired)
- {
- AppendTextValueDelegate callback = new AppendTextValueDelegate(AppendTextValue);
- this.Invoke(callback, text);
- }
- else
- {
- rtblog.AppendText(text);
-
- }
- }
- public void SetProgressMax(int max)
- {
- if (this.progressBar1.InvokeRequired)
- {
- SetProgressMaxDelegate callback = new SetProgressMaxDelegate(SetProgressMax);
- this.Invoke(callback, max);
- }
- else
- {
- progressBar1.Maximum = max;
- }
- }
- public int GetProgressValue()
- {
- if (this.progressBar1.InvokeRequired)
- {
- GetProgressValueDelegate callback = new GetProgressValueDelegate(GetProgressValue);
- return Convert.ToInt32(this.Invoke(callback));
- }
- else
- {
- return progressBar1.Value;
- }
- }
- public void SetWindowTitle(string text)
- {
- if (this.InvokeRequired)
- {
- SetWindowTitleDelegate callback = new SetWindowTitleDelegate(SetWindowTitle);
- this.Invoke(callback, text);
- }
- else
- {
- this.Text = text;
- }
- }
- public void CloseWindow()
- {
- if (this.InvokeRequired)
- {
- CloseWindowDelegate callback = new CloseWindowDelegate(CloseWindow);
- this.Invoke(callback);
- }
- else
- {
- this.Close();
- }
-
- }
- public void SetValue(int val)
- {
- progressBar1.Value = val;
- }
- public void SetValueProgressBar(SetValueDelegate myDelegate, int val)
- {
- if (this.progressBar1.InvokeRequired)
- {
- this.Invoke(myDelegate, val);
- }
- else
- {
- myDelegate(val);
- }
- }
- #endregion
- }
- }
|