/// <summary> /// 初始化 BackgroundWorker /// </summary> private void InitializeWorker() { _worker = new BackgroundWorker(); _worker.WorkerReportsProgress = true; _worker.DoWork += new DoWorkEventHandler(Worker_DoWork); _worker.ProgressChanged += delegate(object sender, ProgressChangedEventArgs e) { MotherForm.SetStatusBarMessage("" + e.UserState, e.ProgressPercentage); }; _worker.RunWorkerCompleted += delegate(object sender, RunWorkerCompletedEventArgs e) { if (e.Result is List <string> ) { ErrorViewer viewer = new ErrorViewer(); viewer.SetHeader("班級"); foreach (string msg in e.Result as List <string> ) { string className = msg.Split(new string[] { ":" }, StringSplitOptions.None)[0]; string errMsg = msg.Split(new string[] { ":" }, StringSplitOptions.None)[1]; viewer.SetMessage(className, new List <string>(new string[] { errMsg })); } viewer.Show(); } else { MotherForm.SetStatusBarMessage("班級開課完成"); } }; }
private void worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { if (e.Error != null) { if (e.Error is CalculationException) { CalculationException ce = e.Error as CalculationException; new StudentsView <StudentScore>(ce.Students, ce.Message).ShowDialog(); } //2016/6/6 穎驊新增DuplicatedSubjectException,用來處理學生在同學期有同樣科目問題。 if (e.Error is DuplicatedSubjectException) { DuplicatedSubjectException dse = e.Error as DuplicatedSubjectException; //new StudentsView<StudentScore>(dse.Students, dse.Message).ShowDialog(); var dialog = new DuplicatedSubject(); dialog.SetList(dse.DuplicatedList); dialog.ShowDialog(); } else { MotherForm.SetStatusBarMessage(""); MsgBox.Show(e.Error.Message); } } else { MotherForm.SetStatusBarMessage("成績計算完成。"); MsgBox.Show("成績計算完成。"); } }
private void ReadSchoolRecords() { OpenFileDialog dialog = new OpenFileDialog(); dialog.Filter = "*.xlsx|*.xlsx"; dialog.Title = "選擇 DSNS 清單"; if (dialog.ShowDialog() == DialogResult.OK) { try { MotherForm.SetStatusBarMessage("匯入中..."); Dictionary <string, School> schools = FromBackend(); ReadSchoolRecordFromExcel(dialog.FileName, schools); schools.Values.SaveAll(); MessageBox.Show("匯入完成!"); } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { MotherForm.SetStatusBarMessage(""); } } }
private void BackGroundWork_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { Document doc = (Document)e.Result; if (doc != null) { string path = $"{Application.StartupPath}\\Reports\\成績預警通知單.docx"; int i = 1; while (File.Exists(path)) { string docName = Path.GetFileNameWithoutExtension(path); string newPath = $"{Path.GetDirectoryName(path)}\\成績預警通知單{i++}{Path.GetExtension(path)}"; path = newPath; } doc.Save(path, SaveFormat.Docx); MotherForm.SetStatusBarMessage("成績預警通知單 產生完成"); DialogResult result = MsgBox.Show($"{path}\n成績預警通知單產生完成,是否立刻開啟?", "訊息", MessageBoxButtons.YesNo); if (DialogResult.Yes == result) { System.Diagnostics.Process.Start(path); } } else { MotherForm.SetStatusBarMessage("成績資料有誤,無法產生成績預警通知單。"); } }
void BGW_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { Document inResult = (Document)e.Result; btnPrint.Enabled = true; try { SaveFileDialog SaveFileDialog1 = new SaveFileDialog(); SaveFileDialog1.Filter = "Word (*.doc)|*.doc|所有檔案 (*.*)|*.*"; SaveFileDialog1.FileName = "社團幹部證明單"; if (SaveFileDialog1.ShowDialog() == DialogResult.OK) { inResult.Save(SaveFileDialog1.FileName); Process.Start(SaveFileDialog1.FileName); MotherForm.SetStatusBarMessage("社團幹部證明單,列印完成!!"); } else { FISCA.Presentation.Controls.MsgBox.Show("檔案未儲存"); return; } } catch { FISCA.Presentation.Controls.MsgBox.Show("檔案儲存錯誤,請檢查檔案是否開啟中!!"); MotherForm.SetStatusBarMessage("檔案儲存錯誤,請檢查檔案是否開啟中!!"); } }
private void Worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { if (e.Error != null) { MsgBox.Show("產生報表時發生錯誤。" + e.Error.Message); return; } //MotherForm.SetStatusBarMessage(Global.ReportName + "產生完成"); //ReportSaver.SaveDocument(_doc, Global.ReportName); bool pdf = Config.GetBoolean("輸出成PDF格式", false); if (pdf) { MotherForm.SetStatusBarMessage("轉換成 PDF 格式中..."); ReportSaver.SaveDocument(_doc, Global.ReportName, ReportSaver.OutputType.PDF); MotherForm.SetStatusBarMessage(Global.ReportName + "產生完成"); } else { MotherForm.SetStatusBarMessage(Global.ReportName + "產生完成"); ReportSaver.SaveDocument(_doc, Global.ReportName); } }
void bw_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { MotherForm.SetStatusBarMessage(""); btnExport.Enabled = true; btnSave.Enabled = true; MessageBox.Show("儲存完成"); }
private void BGW_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { _doc.MailMerge.RemoveEmptyParagraphs = true; _doc.MailMerge.DeleteFields(); //刪除未使用的功能變數 buttonX1.Enabled = true; try { SaveFileDialog SaveFileDialog1 = new SaveFileDialog(); SaveFileDialog1.Filter = "Word (*.doc)|*.doc|所有檔案 (*.*)|*.*"; SaveFileDialog1.FileName = "社團參與證明單"; if (SaveFileDialog1.ShowDialog() == DialogResult.OK) { _doc.Save(SaveFileDialog1.FileName); Process.Start(SaveFileDialog1.FileName); MotherForm.SetStatusBarMessage("社團參與證明單,列印完成!!"); } else { FISCA.Presentation.Controls.MsgBox.Show("檔案未儲存"); return; } } catch { FISCA.Presentation.Controls.MsgBox.Show("檔案儲存錯誤,請檢查檔案是否開啟中!!"); MotherForm.SetStatusBarMessage("檔案儲存錯誤,請檢查檔案是否開啟中!!"); } }
private void Worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { if (e.Error != null) { MsgBox.Show("產生報表時發生錯誤"); return; } bool pdf = Config.GetBoolean("輸出成PDF格式", false); if (OneFileSave) { FolderBrowserDialog fbd = new FolderBrowserDialog(); fbd.Description = "請選擇儲存資料夾"; fbd.ShowNewFolderButton = true; if (fbd.ShowDialog() == DialogResult.Cancel) { return; } if (pdf) { MotherForm.SetStatusBarMessage("轉換成 PDF 格式中..."); foreach (string each in StudentDoc.Keys) { StudentDoc[each].Save(fbd.SelectedPath + "\\" + each, SaveFormat.AsposePdf); //ReportSaver.SaveDocument(StudentDoc[each], each, ReportSaver.OutputType.PDF); } } else { foreach (string each in StudentDoc.Keys) { StudentDoc[each].Save(fbd.SelectedPath + "\\" + each + ".doc"); } } MotherForm.SetStatusBarMessage("產生完成"); System.Diagnostics.Process.Start(fbd.SelectedPath); } else { if (pdf) { MotherForm.SetStatusBarMessage("轉換成 PDF 格式中..."); ReportSaver.SaveDocument(_doc, Global.ReportName, ReportSaver.OutputType.PDF); MotherForm.SetStatusBarMessage(Global.ReportName + "產生完成"); } else { MotherForm.SetStatusBarMessage(Global.ReportName + "產生完成"); ReportSaver.SaveDocument(_doc, Global.ReportName); } } }
private void MasterWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { Util.EnableControls(this); try { if (Preference.SpiltPDF) { Dictionary <string, Document> dataDict = e.Result as Dictionary <string, Document>; FolderBrowserDialog fbd = new FolderBrowserDialog(); fbd.Description = "請選擇儲存資料夾"; fbd.ShowNewFolderButton = true; if (fbd.ShowDialog() == DialogResult.Cancel) { return; } if (Preference.ConvertToPDF) { MotherForm.SetStatusBarMessage("轉換成 PDF 格式中..."); foreach (string each in dataDict.Keys) { #region 處理產生 PDF string fPath = fbd.SelectedPath + "\\" + each + ".pdf"; dataDict[each].Save(fPath, Aspose.Words.SaveFormat.Pdf); #endregion } } else { MotherForm.SetStatusBarMessage("儲存中..."); foreach (string each in dataDict.Keys) { #region 處理產生 Doc string fPath = fbd.SelectedPath + "\\" + each + ".doc"; dataDict[each].Save(fPath, Aspose.Words.SaveFormat.Doc); #endregion } } MotherForm.SetStatusBarMessage("產生完成"); System.Diagnostics.Process.Start(fbd.SelectedPath); } else { Document doc = e.Result as Document; Util.Save(doc, "學生在校成績證明書_英文", Preference.ConvertToPDF); } } catch (Exception ex) { MsgBox.Show(ex.Message); } }
private void _bgWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { MotherForm.SetStatusBarMessage("學期成績(封存)報表 產生完成。"); if (_wb != null) { Utility.ExprotXls("學期成績(封存)報表", _wb); } }
public void setStudDiplomaInfoData() { MotherForm.SetStatusBarMessage("畢修業證書字號產生中.."); BackgroundWorker bw = new BackgroundWorker(); bw.DoWork += new DoWorkEventHandler(bw_DoWork); bw.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bw_RunWorkerCompleted); bw.RunWorkerAsync(); }
/// <summary> /// 下載合併欄位總表 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void lnkViewMapColumns_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { MotherForm.SetStatusBarMessage("學生第6學期修課紀錄合併欄位總表產生中..."); // 產生合併欄位總表 lnkViewMapColumns.Enabled = false; Global.ExportMappingFieldWord(); lnkViewMapColumns.Enabled = true; MotherForm.SetStatusBarMessage(""); }
private void buttonX1_Click(object xxcxcz, EventArgs zcxzczxce) { string selectValue = comboBoxEx1.Text; if (DevComponents.DotNetBar.MessageBoxEx.Show(selectValue == "" ? "進行分發作業?" : ("進行第" + selectValue + "梯次分發作業?"), "", MessageBoxButtons.OKCancel) == DialogResult.OK) { this.Close(); BackgroundWorker bkw = new BackgroundWorker(); bkw.DoWork += delegate(object sender, DoWorkEventArgs e) { Dictionary <校系資料, int> 配額 = new Dictionary <校系資料, int>(); List <推甄學生資料> 分發對像 = new List <推甄學生資料>(); foreach (var item in 校系資料庫.Items.Values) { 配額.Add(item, item.額); } foreach (var item in _分發學生) { if (item.確定分發結果 && item.分發結果 != null) { 配額[item.分發結果]--; } if (!item.確定分發結果 && ("" + item.梯次) == selectValue) { 分發對像.Add(item); } } Dictionary <校系資料, 推甄學生資料[]> 蘿蔔坑 = new Dictionary <校系資料, 推甄學生資料[]>(); foreach (var item in 配額) { 蘿蔔坑.Add(item.Key, new 推甄學生資料[item.Value]); } 分發對像.取得志願組(); 分發對像.Sort(delegate(推甄學生資料 o1, 推甄學生資料 o2) { return(o1.排名.CompareTo(o2.排名)); }); foreach (var item in 分發對像) { 分發學生(item, 蘿蔔坑); } 分發對像.SaveAll(); e.Result = 分發對像; }; bkw.RunWorkerCompleted += delegate(object sender, RunWorkerCompletedEventArgs e) { MotherForm.SetStatusBarMessage(selectValue == "" ? "分發完成。" : ("第" + selectValue + "梯次分發完成。")); new 統計分發結果(selectValue == "" ? "分發內容" : ("第" + selectValue + "梯次分發內容。"), (List <推甄學生資料>)e.Result).Show(); }; bkw.RunWorkerAsync(); MotherForm.SetStatusBarMessage(selectValue == "" ? "分發中..." : ("第" + selectValue + "梯次分發中...")); } }
void _BKWChecker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { if (e.Cancelled) { StartCheck(); } else { MotherForm.SetStatusBarMessage("驗證課程規劃表完成"); } }
private void Worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { if (e.Error != null) { //throw e.Error; MsgBox.Show("產生報表時發生錯誤。" + e.Error.Message); return; } #region 儲存 if (_doc.Sections.Count > 0) { string path = Path.Combine(Application.StartupPath, "Reports"); DirectoryInfo dir = new DirectoryInfo(path); if (!dir.Exists) { dir.Create(); } path = Path.Combine(path, ReportName + ".doc"); if (File.Exists(path)) { int i = 1; while (true) { string newPath = Path.GetDirectoryName(path) + "\\" + Path.GetFileNameWithoutExtension(path) + (i++) + Path.GetExtension(path); if (!File.Exists(newPath)) { path = newPath; break; } } } try { _doc.Save(path); FISCA.LogAgent.ApplicationLog.Log("成績系統.報表", "列印" + ReportName, string.Format("產生{0}份{1}", _config.Students.Count, ReportName)); MotherForm.SetStatusBarMessage(ReportName + "產生完成"); if (MsgBox.Show(ReportName + "產生完成,是否立刻開啟?", MessageBoxButtons.YesNo) == DialogResult.Yes) { System.Diagnostics.Process.Start(path); } } catch (Exception ex) { MsgBox.Show("儲存失敗"); } } #endregion }
void _BKWChecker_ProgressChanged(object sender, ProgressChangedEventArgs e) { MotherForm.SetStatusBarMessage("驗證課程規劃表", e.ProgressPercentage); if (!(bool)((object[])e.UserState)[0]) { Node item; if (_GPlanMapping.TryGetValue((GraduationPlanInfo)((object[])e.UserState)[1], out item)) { SetWarningNode(item, true); } } }
private void btnSave_Click(object sender, EventArgs e) { MotherForm.SetStatusBarMessage("開始列印學生日常表現總表..."); btnSave.Enabled = false; SetNameIndex(); SingeFile = cbSingeFile.Checked; PrintUpdateStudentFile = checkBoxX1.Checked; BGW.RunWorkerAsync(); }
public void Feedback(string message, int percentage) { if (InvokeRequired) { Invoke(new Action <string, int>(Feedback), new object[] { message, percentage }); } else { MotherForm.SetStatusBarMessage(message, percentage); Application.DoEvents(); } }
private void MasterWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { Util.EnableControls(this); if (e.Error == null) { Document doc = e.Result as Document; //單檔列印 if (OneFileSave.Checked) { FolderBrowserDialog fbd = new FolderBrowserDialog(); fbd.Description = "請選擇儲存資料夾"; fbd.ShowNewFolderButton = true; if (fbd.ShowDialog() == DialogResult.Cancel) { return; } fbdPath = fbd.SelectedPath; Util.DisableControls(this); ConvertToPDF_Worker.RunWorkerAsync(); } else { if (Preference.ConvertToPDF) { MotherForm.SetStatusBarMessage("正在轉換PDF格式... 請耐心等候"); } Util.DisableControls(this); ConvertToPDF_Worker.RunWorkerAsync(); } } else { MsgBox.Show(e.Error.Message); } if (Preference.ConvertToPDF) { MotherForm.SetStatusBarMessage("正在轉換PDF格式", 0); } else { MotherForm.SetStatusBarMessage("產生完成", 100); } }
void BGW_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { this.Text = "社團點名單(跨部別)"; btnStart.Enabled = true; if (!e.Cancelled) { if (e.Error == null) { SaveFileDialog SaveFileDialog1 = new SaveFileDialog(); SaveFileDialog1.Filter = "Word (*.doc)|*.doc|所有檔案 (*.*)|*.*"; SaveFileDialog1.FileName = "社團點名單(跨部別)"; //資料 try { if (SaveFileDialog1.ShowDialog() == DialogResult.OK) { Aspose.Words.Document inResult = (Aspose.Words.Document)e.Result; inResult.Save(SaveFileDialog1.FileName); Process.Start(SaveFileDialog1.FileName); MotherForm.SetStatusBarMessage("社團點名單(跨部別),列印完成!!"); } else { FISCA.Presentation.Controls.MsgBox.Show("檔案未儲存"); return; } } catch { FISCA.Presentation.Controls.MsgBox.Show("檔案儲存錯誤,請檢查檔案是否開啟中!!"); MotherForm.SetStatusBarMessage("檔案儲存錯誤,請檢查檔案是否開啟中!!"); } } else { if (e.Error.Message == "並未將物件參考設定為物件的執行個體。") { MsgBox.Show("列印發生錯誤..\n失敗:登入帳號不是ischool Account"); } else { MsgBox.Show("列印發生錯誤..\n" + e.Error.Message); } } } else { MsgBox.Show("作業已取消"); } }
private void ConvertToPDF_Worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { Util.EnableControls(this); if (Preference.ConvertToPDF) { MotherForm.SetStatusBarMessage("PDF轉換完成", 100); } else { MotherForm.SetStatusBarMessage("存檔完成", 100); } }
private void BackgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { btnExport.Enabled = true; string path = (string)e.Result; MotherForm.SetStatusBarMessage("班級成績預警通知單 產生完成"); DialogResult result = MsgBox.Show($"{path}\n班級成績預警通知單產生完成,是否立刻開啟?", "訊息", MessageBoxButtons.YesNo); if (DialogResult.Yes == result) { System.Diagnostics.Process.Start(path); } }
void _BGWTotalDisciplineAndAbsence_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { string reportName; string path; Workbook wb; object[] result = (object[])e.Result; reportName = (string)result[0]; path = (string)result[1]; wb = (Workbook)result[2]; if (File.Exists(path)) { int i = 1; while (true) { string newPath = Path.GetDirectoryName(path) + "\\" + Path.GetFileNameWithoutExtension(path) + (i++) + Path.GetExtension(path); if (!File.Exists(newPath)) { path = newPath; break; } } } try { wb.Save(path, FileFormatType.Excel2003); MotherForm.SetStatusBarMessage(reportName + "產生完成"); System.Diagnostics.Process.Start(path); } catch { SaveFileDialog sd = new SaveFileDialog(); sd.Title = "另存新檔"; sd.FileName = reportName + ".xls"; sd.Filter = "Excel檔案 (*.xls)|*.xls|所有檔案 (*.*)|*.*"; if (sd.ShowDialog() == DialogResult.OK) { try { wb.Save(sd.FileName, FileFormatType.Excel2003); } catch { MsgBox.Show("指定路徑無法存取。", "建立檔案失敗", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } } }
private void ReportBuilding(object sender, RunWorkerCompletedEventArgs e) { MotherForm.SetStatusBarMessage(" ESL成績單產生完成"); Document doc = (Document)e.Result; doc.MailMerge.DeleteFields(); // 電子報表功能先暫時不製做 #region 電子報表 //// 檢查是否上傳電子報表 //if (chkUploadEPaper.Checked) //{ // List<Document> docList = new List<Document>(); // foreach (Section ss in doc.Sections) // { // Document dc = new Document(); // dc.Sections.Clear(); // dc.Sections.Add(dc.ImportNode(ss, true)); // docList.Add(dc); // } // Update_ePaper up = new Update_ePaper(docList, "超額比序項目積分證明單", PrefixStudent.系統編號); // if (up.ShowDialog() == System.Windows.Forms.DialogResult.Yes) // { // MsgBox.Show("電子報表已上傳!!"); // } // else // { // MsgBox.Show("已取消!!"); // } //} #endregion SaveFileDialog sd = new SaveFileDialog(); sd.Title = "另存新檔"; sd.FileName = "ESL成績單.docx"; sd.Filter = "Word檔案 (*.docx)|*.docx|所有檔案 (*.*)|*.*"; if (sd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { try { doc.Save(sd.FileName, Aspose.Words.SaveFormat.Docx); System.Diagnostics.Process.Start(sd.FileName); } catch { MessageBox.Show("檔案儲存失敗"); } } }
public void BGW_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { if (e.Result == null) { MessageBox.Show("儲存成功"); MotherForm.SetStatusBarMessage("班級選課管理--資料儲存成功"); } if (e.Result != null) { MessageBox.Show("" + e.Result); } this.Close(); }
void _BKWChecker_ProgressChanged(object sender, ProgressChangedEventArgs e) { MotherForm.SetStatusBarMessage("驗證課程規劃表", e.ProgressPercentage); if (!(bool)((object[])e.UserState)[0]) { ButtonItem item; if (_GPlanMapping.TryGetValue((GraduationPlanInfo)((object[])e.UserState)[1], out item)) { item.ButtonStyle = eButtonStyle.ImageAndText; item.Tooltip = "驗證失敗,請檢查內容。\n否則使用此規劃表之學生將無法加入修課。"; item.Image = Properties.Resources.warning1; item.Refresh(); } } }
private void Worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { K12.Presentation.NLDPanels.Student.AddToTemp(_overStudentList); if (e.Error != null) { MsgBox.Show("產生報表時發生錯誤。" + e.Error.Message); return; } if ("" + e.Result == "Cancel") { MotherForm.SetStatusBarMessage(""); return; } MotherForm.SetStatusBarMessage(Global.ReportName + "產生完成"); ReportSaver.SaveDocument(_doc, Global.ReportName); }
void BGW_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { btnSave.Enabled = true; this.Text = "班級社團成績單"; if (e.Cancelled) { MsgBox.Show("列印失敗!未設定成績評量!!"); } else { if (e.Error == null) { SaveFileDialog SaveFileDialog1 = new SaveFileDialog(); SaveFileDialog1.Filter = "Excel (*.xls)|*.xls|所有檔案 (*.*)|*.*"; SaveFileDialog1.FileName = PriontName; //資料 try { if (SaveFileDialog1.ShowDialog() == DialogResult.OK) { Workbook inResult = (Workbook)e.Result; inResult.Save(SaveFileDialog1.FileName, SaveFormat.Excel97To2003); Process.Start(SaveFileDialog1.FileName); MotherForm.SetStatusBarMessage(PriontName + "列印完成!!"); } else { FISCA.Presentation.Controls.MsgBox.Show("檔案未儲存"); return; } } catch { FISCA.Presentation.Controls.MsgBox.Show("檔案儲存錯誤,請檢查檔案是否開啟中!!"); MotherForm.SetStatusBarMessage("檔案儲存錯誤,請檢查檔案是否開啟中!!"); } } else { MsgBox.Show("列印資料發生錯誤\n" + e.Error.Message); SmartSchool.ErrorReporting.ReportingService.ReportException(e.Error); } } }
public void ReportProgress(string message, int progress) { //if (!string.IsNullOrEmpty(message)) // MotherForm.SetStatusBarMessage(message); //else //{ if (_frm.InvokeRequired) { _frm.Invoke(new RaiseProgress(ReportProgress), message, progress); } else { MotherForm.SetStatusBarMessage(message, progress); Application.DoEvents(); } //} }