/// <summary> /// Download the result list as CSV file when click [Download] button on Grid /// </summary> public void CMS030_DownloadAsCSV() { CMS030_ScreenParameter sParam = GetScreenObject <CMS030_ScreenParameter>(); MemoryStream msStreamReport = new MemoryStream(); sParam.StreamReport.CopyTo(msStreamReport); this.DownloadCSVFile(sParam.FileName, msStreamReport.ToArray()); }
/// <summary> /// Check permission for access screen CMS030 /// </summary> /// <param name="param"></param> /// <returns></returns> public ActionResult CMS030_Authority(CMS030_ScreenParameter param) { ObjectResultData res = new ObjectResultData(); if (!CheckUserPermission(ScreenID.C_SCREEN_ID_DOWNLOAD_DOC, FunctionID.C_FUNC_ID_OPERATE)) { res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0053); return(Json(res)); } return(InitialScreenEnvironment <CMS030_ScreenParameter>("CMS030", param, res)); }
/// <summary> /// Mothod for download document (PDF) and write history to download log /// </summary> /// <param name="strDocumentNo"></param> /// <param name="documentOCC"></param> /// <param name="strDocumentCode"></param> /// <param name="fileName"></param> /// <returns></returns> public ActionResult CMS030_DownloadPdfAndWriteLog(string strDocumentNo, string documentOCC, string strDocumentCode, string fileName) { ObjectResultData res = new ObjectResultData(); CMS030_ScreenParameter sParam = GetScreenObject <CMS030_ScreenParameter>(); //Add by Jutarat A. on 17082012 using (TransactionScope t = new TransactionScope()) { try { // doDocumentDownloadLog doDocumentDownloadLog cond = new doDocumentDownloadLog(); cond.DocumentNo = strDocumentNo; cond.DocumentCode = strDocumentCode; cond.DownloadDate = CommonUtil.dsTransData.dtOperationData.ProcessDateTime; cond.DownloadBy = CommonUtil.dsTransData.dtUserData.EmpNo; cond.DocumentOCC = documentOCC; ILogHandler handlerLog = ServiceContainer.GetService <ILogHandler>() as ILogHandler; int isOK = handlerLog.WriteDocumentDownloadLog(cond); //Update firstIssueFlag for invoice report if (cond.DocumentCode == ReportID.C_REPORT_ID_INVOICE) { IBillingHandler billingHandler = ServiceContainer.GetService <IBillingHandler>() as IBillingHandler; billingHandler.UpdateFirstIssue(cond.DocumentNo, cond.DocumentOCC, cond.DownloadDate.Value, CommonUtil.dsTransData.dtUserData.EmpNo); } IDocumentHandler handlerDoc = ServiceContainer.GetService <IDocumentHandler>() as IDocumentHandler; Stream reportStream = handlerDoc.GetDocumentReportFileStream(fileName); FileInfo fileinfo = new FileInfo(fileName); if (fileinfo.Extension.ToUpper().Equals(".CSV")) { //Modify by Jutarat A. on 17082012 //FileStreamResult result = File(reportStream, "text/csv"); //result.FileDownloadName = fileinfo.Name; //t.Complete(); //return result; sParam.FileName = fileinfo.Name; sParam.StreamReport = reportStream; res.ResultData = true; t.Complete(); return(Json(res)); //End Modify } else { t.Complete(); return(File(reportStream, "application/pdf")); } } catch (Exception ex) { t.Dispose(); res.AddErrorMessage(ex); return(Json(res)); } } }