我创建了一个提取数据的界面,有几个简单的步骤。
用户从下拉框中选择所需的数据,然后单击“检查可用”按钮,如果有可用记录,则会显示“发送请求”按钮。
单击发送请求按钮后,SQL 表被发送到一个 excel 文件,该文件用 vba 稍微处理,然后从 C# 向用户发送电子邮件,其中包含指向该 excel 文件的链接。
我面临的问题是用户在一两秒后变得不耐烦,并开始一遍又一遍地捣碎“发送请求”按钮。这种不耐烦会使应用程序崩溃。
我怎样才能使页面行为,以便在单击“发送请求”后刷新页面,但该过程仍然在服务器上执行,并且电子邮件仍然从 C# 发送。
public void SendRequest_Click(object sender, EventArgs e)
{
//Insert amazing line of code that refreshes the web form but does everything beyond this line
SendRequest.Visible = false;
//Creating a new class
QueryMule mule = new QueryMule();
Label11.Visible = true;
string myfilename = Label3.Text;
string splitusernum = Label4.Text;
string dtablenum = Label4.Text;
string exportnum = Label4.Text;
//Export all export tables to mercuryexport excel file
mule.SQLExport(18, splitusernum, exportnum);
//Creating a new excel application to open the mercury template and run its macro
ExcelApp.Application appExl;
ExcelApp.Workbook workbook;
ExcelApp.Worksheet newSheet;
ExcelApp.Range Range;
appExl = new ExcelApp.Application();
RegionName.SelectedItem.Value + timestampeddone + ".xlsm";
workbook = appExl.Workbooks.Open(@"filepath", Missing.Value,
Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value,
Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value,
Missing.Value, Missing.Value, Missing.Value);
appExl.Visible = true;
appExl.DisplayAlerts = true;
System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
message.To.Add '''REMOVED EMAIL ADDRESS
message.Subject = "Delivery System";
message.From '''REMOVED EMAIL ADDRESS
message.Body = "filepath" + myfilename;
System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("mailhost");
smtp.Send(message);
Label4.Text = "Email Sent";
mule.DropTable(dtablenum);
mule.DropTable1(dtablenum);
mule.DropTable2(dtablenum);
mule.DropExportTable(dtablenum);
}