Exemplo n.º 1
0
        /// <summary>
        /// Download slip report
        /// </summary>
        /// <returns></returns>
        public ActionResult IVS100_DownloadPdfAndWriteLog()
        {
            try
            {
                IVS100_ScreenParameter param = GetScreenObject <IVS100_ScreenParameter>();
                string fileName = param.slipNoReportPath;

                doDocumentDownloadLog doDownloadLog = new doDocumentDownloadLog()
                {
                    DocumentNo   = param.slipNo,
                    DocumentCode = ReportID.C_INV_REPORT_ID_REPAIR_REQUEST, // IVR070
                    DocumentOCC  = ConfigName.C_CONFIG_DOC_OCC_DEFAULT,
                    DownloadDate = CommonUtil.dsTransData.dtOperationData.ProcessDateTime,
                    DownloadBy   = CommonUtil.dsTransData.dtUserData.EmpNo
                };


                ILogHandler handlerLog = ServiceContainer.GetService <ILogHandler>() as ILogHandler;
                int         isSuccess  = handlerLog.WriteDocumentDownloadLog(doDownloadLog);

                IDocumentHandler handlerDoc   = ServiceContainer.GetService <IDocumentHandler>() as IDocumentHandler;
                Stream           reportStream = handlerDoc.GetDocumentReportFileStream(fileName);

                return(File(reportStream, "application/pdf"));
            }
            catch (Exception ex)
            {
                ObjectResultData res = new ObjectResultData();
                res.AddErrorMessage(ex);
                return(Json(res));
            }
        }
        public ActionResult IVS220_DownloadPreparedPO()
        {
            try
            {
                IVS220_ScreenParameter prm = GetScreenObject <IVS220_ScreenParameter>();
                if (prm.PreparedDownloadPO == null)
                {
                    return(HttpNotFound());
                }

                doDocumentDownloadLog doDownloadLog = new doDocumentDownloadLog()
                {
                    DocumentNo   = prm.PreparedDownloadPO.DocumentNo,
                    DocumentCode = prm.PreparedDownloadPO.DocumentCode,
                    DocumentOCC  = prm.PreparedDownloadPO.DocumentOCC,
                    DownloadDate = CommonUtil.dsTransData.dtOperationData.ProcessDateTime,
                    DownloadBy   = CommonUtil.dsTransData.dtUserData.EmpNo
                };

                ILogHandler handlerLog = ServiceContainer.GetService <ILogHandler>() as ILogHandler;
                int         isSuccess  = handlerLog.WriteDocumentDownloadLog(doDownloadLog);

                IDocumentHandler handlerDoc   = ServiceContainer.GetService <IDocumentHandler>() as IDocumentHandler;
                Stream           reportStream = handlerDoc.GetDocumentReportFileStream(prm.PreparedDownloadPO.FilePath);

                prm.PreparedDownloadPO = null;

                return(File(reportStream, "application/pdf"));
            }
            catch (Exception ex)
            {
                return(HttpNotFound());
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Send document to client and write log.
        /// </summary>
        /// <param name="strInvSlipNo"></param>
        /// <returns></returns>
        public ActionResult IVS030_DownloadPdfAndWriteLog(string strDocumentNo, string documentOCC, string strDocumentCode, string fileName)
        {
            try
            {
                doDocumentDownloadLog doDownloadLog = new doDocumentDownloadLog()
                {
                    DocumentNo   = strDocumentNo,
                    DocumentCode = strDocumentCode,
                    DocumentOCC  = documentOCC,
                    DownloadDate = CommonUtil.dsTransData.dtOperationData.ProcessDateTime,
                    DownloadBy   = CommonUtil.dsTransData.dtUserData.EmpNo
                };

                ILogHandler handlerLog = ServiceContainer.GetService <ILogHandler>() as ILogHandler;
                int         isSuccess  = handlerLog.WriteDocumentDownloadLog(doDownloadLog);

                IDocumentHandler handlerDoc   = ServiceContainer.GetService <IDocumentHandler>() as IDocumentHandler;
                Stream           reportStream = handlerDoc.GetDocumentReportFileStream(fileName);

                return(File(reportStream, "application/pdf"));
            }
            catch (Exception ex)
            {
                ObjectResultData res = new ObjectResultData();
                res.AddErrorMessage(ex);
                return(Json(res));
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Mothod for download document (PDF) and write history to download log
        /// </summary>
        /// <param name="fileName"></param>
        /// <returns></returns>
        public ActionResult ACS010_DownloadDocument()
        {
            ObjectResultData       res    = new ObjectResultData();
            ACS010_ScreenParameter sParam = GetScreenObject <ACS010_ScreenParameter>();

            try
            {
                IDocumentHandler handlerDoc    = ServiceContainer.GetService <IDocumentHandler>() as IDocumentHandler;
                FileInfo         fileinfo      = new FileInfo(sParam.FileName);
                string           fileExtension = fileinfo.Extension.ToUpper();

                Stream reportStream = handlerDoc.GetDocumentReportFileStream(sParam.FileName);

                if (fileExtension.Equals(".CSV"))
                {
                    sParam.StreamReport = reportStream;
                    res.ResultData      = true;
                    return(Json(res));
                }
                else
                {
                    return(File(reportStream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", fileinfo.Name));
                }
            }
            catch (Exception ex)
            {
                res.AddErrorMessage(ex);
                return(Json(res));
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Generate taxinvoice/receipt pdf report
        /// </summary>
        /// <returns></returns>
        public ActionResult ICS050_DisplayReport()
        {
            ICS050_ScreenParameter screenSession = GetScreenObject <ICS050_ScreenParameter>();

            if (screenSession != null && !string.IsNullOrEmpty(screenSession.PDFFilePath))
            {
                IDocumentHandler handlerDocument = ServiceContainer.GetService <IDocumentHandler>() as IDocumentHandler;
                Stream           filestream      = handlerDocument.GetDocumentReportFileStream(screenSession.PDFFilePath);
                return(File(filestream, "application/pdf"));
            }
            else
            {
                //Do nothing
                ObjectResultData res = new ObjectResultData();
                res.MessageType = MessageModel.MESSAGE_TYPE.WARNING;
                return(Json(res));
            }
        }
        /// <summary>
        /// Download document.
        /// </summary>
        /// <param name="strDocumentNo">Document No.</param>
        /// <param name="documentOCC">Document OCC.</param>
        /// <param name="strDocumentCode">Document Code.</param>
        /// <param name="fileName">File Name.</param>
        /// <returns>Return ActionResult of file's stream.</returns>
        //public ActionResult IVS240_DownloadPdfAndWriteLog(string strDocumentNo, string documentOCC, string strDocumentCode, string fileName)
        public ActionResult IVS240_DownloadPdfAndWriteLog(string k) //Modify by Jutarat A. on 04122012
        {
            Stream reportStream = null;                             //Add by Jutarat A. on 04122012

            try
            {
                //Modify by Jutarat A. on 04122012
                IVS240_ScreenParameter sParam = GetScreenObject <IVS240_ScreenParameter>(k);
                if (sParam.ResultDocument != null)
                {
                    doDocumentDownloadLog doDownloadLog = new doDocumentDownloadLog()
                    {
                        DocumentNo   = sParam.ResultDocument.DocumentNo,   //strDocumentNo,
                        DocumentCode = sParam.ResultDocument.DocumentCode, //strDocumentCode,
                        DocumentOCC  = sParam.ResultDocument.DocumentOCC,  //documentOCC,
                        DownloadDate = CommonUtil.dsTransData.dtOperationData.ProcessDateTime,
                        DownloadBy   = CommonUtil.dsTransData.dtUserData.EmpNo
                    };

                    ILogHandler handlerLog = ServiceContainer.GetService <ILogHandler>() as ILogHandler;
                    int         isSuccess  = handlerLog.WriteDocumentDownloadLog(doDownloadLog);

                    if (sParam.ResultStream != null)
                    {
                        reportStream        = sParam.ResultStream;
                        sParam.ResultStream = null;
                    }
                    else
                    {
                        IDocumentHandler handlerDoc = ServiceContainer.GetService <IDocumentHandler>() as IDocumentHandler;
                        reportStream = handlerDoc.GetDocumentReportFileStream(sParam.ResultDocument.FilePath); //(fileName);
                    }
                }
                //End Modify

                return(File(reportStream, "application/pdf"));
            }
            catch (Exception ex)
            {
                ObjectResultData res = new ObjectResultData();
                res.AddErrorMessage(ex);
                return(Json(res));
            }
        }
        /// <summary>
        /// Download report and write log.
        /// </summary>
        /// <returns></returns>
        public ActionResult IVS250_DownloadPdfAndWriteLog()
        {
            try
            {
                IVS250_ScreenParameter prm = GetScreenObject <IVS250_ScreenParameter>();
                string fileName            = prm.reportFilePath;

                doDocumentDownloadLog doDownloadLog = new doDocumentDownloadLog()
                {
                    DocumentNo   = prm.slipNo,
                    DocumentOCC  = ConfigName.C_CONFIG_DOC_OCC_DEFAULT,
                    DownloadDate = CommonUtil.dsTransData.dtOperationData.ProcessDateTime,
                    DownloadBy   = CommonUtil.dsTransData.dtUserData.EmpNo
                };

                //if (prm.SpecifyPOrder250.PurchaseOrderType == PurchaseOrderType.C_PURCHASE_ORDER_TYPE_SECOM)
                //{
                //    doDownloadLog.DocumentCode = ReportID.C_INV_REPORT_ID_PURCHASE_ORDER_CHN;
                //}
                //else if (prm.SpecifyPOrder250.PurchaseOrderType == PurchaseOrderType.C_PURCHASE_ORDER_TYPE_DOMESTIC)
                //{
                //    doDownloadLog.DocumentCode = ReportID.C_INV_REPORT_ID_PURCHASE_ORDER_DOM;
                //}

                doDownloadLog.DocumentCode = ReportID.C_INV_REPORT_ID_PURCHASE_ORDER;

                ILogHandler handlerLog = ServiceContainer.GetService <ILogHandler>() as ILogHandler;
                int         isSuccess  = handlerLog.WriteDocumentDownloadLog(doDownloadLog);

                IDocumentHandler handlerDoc   = ServiceContainer.GetService <IDocumentHandler>() as IDocumentHandler;
                Stream           reportStream = handlerDoc.GetDocumentReportFileStream(fileName);

                return(File(reportStream, "application/pdf"));
            }
            catch (Exception ex)
            {
                ObjectResultData res = new ObjectResultData();
                res.AddErrorMessage(ex);
                return(Json(res));
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// Download document (PDF)
        /// </summary>
        /// <param name="inventorySlipNo"></param>
        /// <returns></returns>
        public ActionResult CMS450_DownloadDocument(string reportId, string docNo)
        {
            ObjectResultData res     = new ObjectResultData();
            IDocumentHandler handler = ServiceContainer.GetService <IDocumentHandler>() as IDocumentHandler;

            try
            {
                List <dtDocumentData> list = handler.GetDocumentDataListByDocumentCode(docNo, reportId, null);
                if (list != null && list.Count > 0)
                {
                    Stream reportStream = handler.GetDocumentReportFileStream(list[0].FilePath);
                    return(File(reportStream, "application/octet-stream", Path.GetFileName(list[0].FilePath)));
                }
            }
            catch (Exception ex)
            {
                res.AddErrorMessage(ex);
            }

            return(Json(res));
        }
        /// <summary>
        /// Download document (PDF)
        /// </summary>
        /// <param name="inventorySlipNo"></param>
        /// <returns></returns>
        public ActionResult IVS220_DownloadInventorySlip(string inventorySlipNo)
        {
            ObjectResultData res     = new ObjectResultData();
            IDocumentHandler handler = ServiceContainer.GetService <IDocumentHandler>() as IDocumentHandler;

            try
            {
                //List<dtDocumentData> list = handler.GetDocumentDataList(new doDocumentDataCondition() { DocumentNo = inventorySlipNo });
                List <dtDocumentData> list = handler.GetDocumentDataListByInventorySlipNo(inventorySlipNo);
                if (list != null && list.Count > 0)
                {
                    Stream reportStream = handler.GetDocumentReportFileStream(list[0].FilePath);
                    return(File(reportStream, "application/octet-stream", Path.GetFileName(list[0].FilePath)));
                }
            }
            catch (Exception ex)
            {
                res.AddErrorMessage(ex);
            }

            return(Json(res));
        }
Exemplo n.º 10
0
        /// <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));
                }
            }
        }