private void GenerateReport() { if (this.lblStatusDownload.InvokeRequired) { this.lblStatusDownload.BeginInvoke((MethodInvoker) delegate() { this.lblStatusDownload.Text = "Report Generation is in progress, please wait....";;; }); } if (this.btnDownload.InvokeRequired) { this.btnDownload.BeginInvoke((MethodInvoker) delegate() { this.btnDownload.Enabled = false;;; }); } bool exception = false; try { GenerateOutputSpreadsheet reportEngine = new GenerateOutputSpreadsheet(); reportEngine.CreateSpreadSheet(); } catch (Exception ex) { exception = true; if (this.lblStatusDownload.InvokeRequired) { this.lblStatusDownload.BeginInvoke((MethodInvoker) delegate() { this.lblStatusDownload.Text = "Report Generation failed: " + ex.Message;;; }); this.lblStatus.BeginInvoke((MethodInvoker) delegate() { this.lblStatusDownload.ForeColor = Color.Green;;; }); } if (this.btnDownload.InvokeRequired) { this.btnDownload.BeginInvoke((MethodInvoker) delegate() { this.btnDownload.Enabled = true;;; }); } return; } if (!exception) { if (this.lblStatusDownload.InvokeRequired) { this.lblStatusDownload.BeginInvoke((MethodInvoker) delegate() { this.lblStatusDownload.Text = "Report Generation is complete, launching report xlsx...";;; }); } if (this.btnDownload.InvokeRequired) { this.btnDownload.BeginInvoke((MethodInvoker) delegate() { this.btnDownload.Enabled = true;;; }); } } }
private void DownloadSchedule() { this.InvokeEx(f => f.lblStatus.Visible = true); this.InvokeEx(f => f.btnDownloadSchedule.Enabled = false); this.InvokeEx(f => f.groupBoxUpload.Enabled = false); this.InvokeEx(f => f.lblStatus.Text = "In Progress, please wait!"); var schedule = flightScheduleEngine.GetFlightSchedule(); GenerateOutputSpreadsheet.CreateFlightScheduleSpreadSheet(schedule, @"\\192.168.16.208\Digital_Production\Virgin\FlightSchedule"); this.InvokeEx(f => f.btnDownloadSchedule.Enabled = true); this.InvokeEx(f => f.lblStatus.Visible = false); this.InvokeEx(f => f.groupBoxUpload.Enabled = true); }
/// <summary> /// Downlaod Box Ticket excel /// </summary> /// <param name="orderId"></param> private void DownloadBoxTicket(long orderId) { try { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "DownloadInProgress", "DownloadInProgress();", true); //get the order Id of current row var lotNo = _orderManagement.GetLotNoFromOrderId(orderId); var directory = Directory.GetParent(HttpRuntime.AppDomainAppPath); var parentDir = directory.Parent; var boxTicketPath = parentDir.FullName + @"\BoxTicketReport\"; var boxTicketData = _orderManagement.GetBoxTicketData(orderId); GenerateOutputSpreadsheet.CreateBoxTicketSpreadSheet(boxTicketData, orderId, lotNo, boxTicketPath); FileInfo auditfile = new FileInfo(boxTicketPath + "BoxReport_" + orderId + ".xlsx"); if (auditfile.Exists) { string fname = auditfile.Name; fname = fname.Replace(" ", "_"); Response.ClearContent(); Response.Buffer = true; Response.AddHeader("content-disposition", string.Format("attachment; filename={0}", fname)); Response.ContentType = "application/ms-excel"; Response.TransmitFile(auditfile.FullName); Response.End(); } } catch (Exception ex) { //write to Elma ErrorSignal.FromCurrentContext().Raise(ex); } }
private void DownloadPrintRun(long orderId) { try { //get the order Id of current row PackingTicketProcessor packingTicket = new PackingTicketProcessor(); var printRunBundleCountDict = packingTicket.CalculatePrintRunData(orderId); var lotNo = _orderManagement.GetLotNoFromOrderId(orderId); var directory = Directory.GetParent(HttpRuntime.AppDomainAppPath); var parentDir = directory.Parent; var printRunPath = parentDir.FullName + @"\PrintRunReport\"; GenerateOutputSpreadsheet.CreatePrintRunSpreadSheet(printRunBundleCountDict, orderId, lotNo, printRunPath); FileInfo auditfile = new FileInfo(printRunPath + "PrintRun_" + orderId + ".xlsx"); if (auditfile.Exists) { string fname = auditfile.Name; fname = fname.Replace(" ", "_"); Response.ClearContent(); Response.Buffer = true; Response.AddHeader("content-disposition", string.Format("attachment; filename={0}", fname)); Response.ContentType = "application/ms-excel"; Response.TransmitFile(auditfile.FullName); Response.End(); } } catch (Exception ex) { //write to Elma ErrorSignal.FromCurrentContext().Raise(ex); } }