private void menu_Click(object sender, EventArgs e) { void original() { Menu.Enabled = true; Menu_Progress_Show.Text = "目前進度:0%"; Menu_Progress.Value = 0; } Menu.Enabled = false; Compatible_Extend.Task_Extend.Run(() => { try { template.Non_Override_Download(menu_file.Text); ExcelStream excel = new ExcelStream(menu_file.Text, sender.Equals(download_menu)); Update_Menu menu_update = new Update_Menu(req, excel); UpdateProgress progress = new UpdateProgress((int value) => { Invoke((MethodInvoker)(() => { Menu_Progress.Value = value; Menu_Progress_Show.Text = "目前進度:" + value.ToString() + "%"; })); }); if (sender.Equals(download_menu)) { menu_update.Download(progress); } else { menu_update.Upload(progress); } excel.Close(); if (sender.Equals(download_menu)) { Process.Start(menu_file.Text); } Invoke((MethodInvoker)(() => { original(); if (sender.Equals(upload_menu)) { MessageBox.Show("上載完成"); } })); } catch (Exception ex) { req.Report_Error(ex.ToString()); Invoke((MethodInvoker)(() => { original(); Error_Report.Text += ex.Message + "\r\n ----------- \r\n"; })); } }); }
private void download_money_Click(object sender, EventArgs e) { void original() { Money.Enabled = true; Money_Progress_Show.Text = "目前進度:0%"; Money_Progress.Value = 0; } Money.Enabled = false; Compatible_Extend.Task_Extend.Run(() => { try { template.Non_Override_Download(money_file.Text); ExcelStream excel = new ExcelStream(money_file.Text, false); Money_Report money_update = new Money_Report(req, excel); money_update.Download(money_start.Value.ToString("yyyy-MM-dd HH:mm:ss"), money_end.Value.ToString("yyyy-MM-dd HH:mm:ss"), new UpdateProgress((int value) => { Invoke((MethodInvoker)(() => { Money_Progress.Value = value; Money_Progress_Show.Text = "目前進度:" + value.ToString() + "%"; })); })); excel.Close(); Process.Start(money_file.Text); Invoke((MethodInvoker)(() => original())); } catch (Exception ex) { req.Report_Error(ex.ToString()); Invoke((MethodInvoker)(() => { original(); Error_Report.Text += ex.Message + "\r\n ----------- \r\n"; })); } }); }
private void download_custom_Click(object sender, EventArgs e) { void original() { Custom.Enabled = true; Custom_Progress_Show.Text = "目前進度:0%"; Custom_Progress.Value = 0; } Custom.Enabled = false; Task.Run(() => { try { ExcelStream excel = new ExcelStream(custom_file.Text); Custom_Report custom_update = new Custom_Report(req, excel); custom_update.Download(custom_start.Value.ToString("yyyy-MM-dd HH:mm:ss"), custom_end.Value.ToString("yyyy-MM-dd HH:mm:ss"), new UpdateProgress((int value) => { Invoke((MethodInvoker)(() => { Custom_Progress.Value = value; Custom_Progress_Show.Text = "目前進度:" + value.ToString() + "%"; })); })); excel.Close(); Process.Start(custom_file.Text); Invoke((MethodInvoker)(() => original())); } catch (Exception ex) { req.Report_Error(ex.ToString()); Invoke((MethodInvoker)(() => { original(); Error_Report.Text += ex.Message + "\r\n ----------- \r\n"; })); } }); }