コード例 #1
0
        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());
            }
        }
コード例 #2
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));
            }
        }
コード例 #3
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));
            }
        }
コード例 #4
0
        /// <summary>
        /// Download file and wirte history to download log
        /// </summary>
        /// <param name="fileName"></param>
        /// <returns></returns>
        public ActionResult BLS080_DownloadAndWriteLog(string fileName)
        {
            try
            {
                doDocumentDownloadLog doDownloadLog = new doDocumentDownloadLog()
                {
                    DocumentNo   = fileName,
                    DocumentCode = ReportID.C_REPORT_ID_AUTO_TRANSFER_BANK_FILE,
                    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);

                string fiilPath = PathUtil.GetPathValue(PathUtil.PathName.AutoTransferFile, fileName);// ReportUtil.GetGeneratedReportPath(fileName);

                return(File(fiilPath, "text/csv", fileName));
            }
            catch (Exception ex)
            {
                ObjectResultData res = new ObjectResultData();
                res.AddErrorMessage(ex);
                return(Json(res));
            }
        }
コード例 #5
0
        /// <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));
            }
        }
コード例 #6
0
        /// <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));
            }
        }
コード例 #7
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));
                }
            }
        }
コード例 #8
0
        internal doBatchProcessResult BatchPrintDebtTracingNoticeProcess(string UserId, DateTime BatchDate, string strServiceTypeCode)
        {
            doBatchProcessResult result        = new doBatchProcessResult();
            IncomeHandler        incomeHandler = new IncomeHandler();
            ILogHandler          logHandler    = ServiceContainer.GetService <ILogHandler>() as ILogHandler;
            ICommonHandler       comHandler    = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;

            string pathFoxit    = ConfigurationManager.AppSettings["PrintPDFFoxit"];
            string pathFileName = string.Empty;
            string processID    = (strServiceTypeCode == ServiceType.C_SERVICE_TYPE_SALE ? ProcessID.C_PROCESS_ID_PRINTING_DEBT_NOTICE_SALE : ProcessID.C_PROCESS_ID_PRINTING_DEBT_NOTICE_RENTAL);
            string printflag    = (strServiceTypeCode == ServiceType.C_SERVICE_TYPE_SALE ? PrintingFlag.C_PRINTING_FLAG_ICP080 : PrintingFlag.C_PRINTING_FLAG_ICP090);

            List <doDebtTracingDocNoForPrinting> lstDocNo = incomeHandler.GetDebtTracingDocNoForPrinting(BatchDate, strServiceTypeCode);

            if (lstDocNo != null && lstDocNo.Count > 0)
            {
                result.Result       = false;
                result.Total        = lstDocNo.Count;
                result.Complete     = 0;
                result.Failed       = 0;
                result.ErrorMessage = string.Empty;

                string strErrorMessage = string.Empty;
                bool   bResult         = comHandler.AllocatePrintingProcess(printflag, processID, ref strErrorMessage);
                if (bResult)
                {
                    foreach (doDebtTracingDocNoForPrinting doc in lstDocNo)
                    {
                        using (TransactionScope scope = new TransactionScope())
                        {
                            try
                            {
                                doDocumentDownloadLog cond = new doDocumentDownloadLog();
                                cond.DocumentNo   = doc.DocumentNo;
                                cond.DocumentCode = doc.DocumentCode;
                                cond.DocumentOCC  = doc.DocumentOCC;
                                cond.DownloadDate = BatchDate;
                                cond.DownloadBy   = processID;
                                logHandler.WriteDocumentDownloadLog(cond);

                                incomeHandler.UpdateDebtTracingNoticePrintFlag(doc.DocumentNo);
                                comHandler.PrintPDF(doc.FilePathDocument);

                                scope.Complete();
                                result.Complete++;
                            }
                            catch (Exception ex)
                            {
                                scope.Dispose();
                                result.Failed++;
                                result.ErrorMessage += string.Format("DocumentNo {0} DocumentCode {1} DocumentOCC {2} has Error : {3} {4}\n"
                                                                     , doc.DocumentNo
                                                                     , doc.DocumentCode
                                                                     , doc.DocumentOCC
                                                                     , ex.Message
                                                                     , ex.InnerException != null ? ex.InnerException.Message : ""
                                                                     );
                                break;
                            }
                        }
                    }

                    bResult = comHandler.ResetPrintingProcess(processID);
                }
                else
                {
                    result.Failed = result.Total;
                    if (String.IsNullOrEmpty(strErrorMessage) == false)
                    {
                        result.ErrorMessage = strErrorMessage;
                    }
                }
            }

            result.Result      = (result.Failed == 0);
            result.BatchStatus = (result.Result ? BatchStatus.C_BATCH_STATUS_SUCCEEDED : BatchStatus.C_BATCH_STATUS_FAILED);
            return(result);
        }
コード例 #9
0
        // CMP120
        /// <summary>
        /// Batch Printing Service Process (call sp_CM_DocumentListForPrining)
        /// </summary>
        /// <param name="UserId">User id</param>
        /// <param name="BatchDate">Batch date</param>
        /// <returns></returns>
        public doBatchProcessResult CMP120_PrintingServiceProcess(string UserId, DateTime BatchDate)
        {
            doBatchProcessResult result          = new doBatchProcessResult();
            DocumentHandler      documentHandler = new DocumentHandler();
            ILogHandler          logHandler      = ServiceContainer.GetService <ILogHandler>() as ILogHandler;
            IBillingHandler      billingHandler  = ServiceContainer.GetService <IBillingHandler>() as IBillingHandler;
            ICommonHandler       comHandler      = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler; //Add by Jutarat A. on 17092013

            //--- variable
            string pathFoxit    = ConfigurationManager.AppSettings["PrintPDFFoxit"];
            string pathFileName = string.Empty;

            List <dtDocumentListForPrining> dtDocumentListForPriningData = documentHandler.GetDocumentListForPrining(DocumentType.C_DOCUMENT_TYPE_INCOME, DocumentType.C_DOCUMENT_TYPE_COMMON, BatchDate, null, null);

            if (dtDocumentListForPriningData != null && dtDocumentListForPriningData.Count > 0)
            {
                // Initial value of doBatchProcessResult
                result.Result       = false;
                result.Total        = dtDocumentListForPriningData.Count;
                result.Complete     = 0;
                result.Failed       = 0;
                result.ErrorMessage = string.Empty;

                //logHandler.SearchFoxitProcess("CMP120"); //Add by Jutarat A. on 20082013
                //}

                //Add by Jutarat A. on 17092013
                string strErrorMessage = string.Empty;
                bool   bResult         = comHandler.AllocatePrintingProcess(PrintingFlag.C_PRINTING_FLAG_CMP120, ProcessID.C_PROCESS_ID_PRINTING_SERVICE, ref strErrorMessage);
                if (bResult)
                //End Add
                {
                    foreach (dtDocumentListForPrining list in dtDocumentListForPriningData)
                    {
                        using (TransactionScope scope = new TransactionScope())
                        {
                            try
                            {
                                //3.1
                                doDocumentDownloadLog cond = new doDocumentDownloadLog();
                                cond.DocumentNo   = list.DocumentNo;
                                cond.DocumentCode = list.DocumentCode;
                                cond.DocumentOCC  = list.DocumentOCC;
                                cond.DownloadDate = BatchDate;
                                cond.DownloadBy   = ProcessID.C_PROCESS_ID_PRINTING_SERVICE;
                                logHandler.WriteDocumentDownloadLog(cond);

                                //============ Teerapong 23/07/2012 ===============
                                billingHandler.UpdateFirstIssue(list.DocumentNo, cond.DocumentOCC, BatchDate, UserId);
                                //=================================================

                                //3.2 Send data to specified printer to print documents
                                //PrintPDF(list.FilePathDocument);
                                comHandler.PrintPDF(list.FilePathDocument); //Modify by Jutarat A. on 17092013

                                //3.3
                                scope.Complete();
                                result.Complete++;
                            }
                            catch (Exception ex)
                            {
                                scope.Dispose();
                                result.Failed++;
                                result.ErrorMessage += string.Format("DocumentNo {0} DocumentCode {1} DocumentOCC {2} has Error : {3} {4}\n", list.DocumentNo, list.DocumentCode, list.DocumentOCC, ex.Message, ex.InnerException != null ? ex.InnerException.Message : "");

                                break; //Add by Jutarat A. on 03072013
                            }
                        }
                    }

                    bResult = comHandler.ResetPrintingProcess(ProcessID.C_PROCESS_ID_PRINTING_SERVICE); //Add by Jutarat A. on 17092013
                }
                //Add by Jutarat A. on 17092013
                else
                {
                    result.Failed = result.Total;
                    if (String.IsNullOrEmpty(strErrorMessage) == false)
                    {
                        result.ErrorMessage = strErrorMessage;
                    }
                }
                //End Add
            }

            result.Result      = (result.Failed == 0);
            result.BatchStatus = (result.Result ? BatchStatus.C_BATCH_STATUS_SUCCEEDED : BatchStatus.C_BATCH_STATUS_FAILED);
            return(result);
        }
コード例 #10
0
        /// <summary>
        /// Reprint Data and get document list for printing
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public ActionResult CMS460_ReprintData(CMS460_ScreenInputValidate data)
        {
            ObjectResultData res = new ObjectResultData();

            try
            {
                //Check permission
                if (!CheckUserPermission(ScreenID.C_SCREEN_ID_REPRINT_BILLING_RELATED_DOCUMENT, FunctionID.C_FUNC_ID_VIEW) == false)
                {
                    res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0007);
                    return(Json(res));
                }

                //Check Require field
                if (ModelState.IsValid == false)
                {
                    res.MessageType = MessageModel.MESSAGE_TYPE.WARNING;
                    ValidatorUtil.BuildErrorMessage(res, this);
                    return(Json(res));
                }

                IDocumentHandler handler    = ServiceContainer.GetService <IDocumentHandler>() as IDocumentHandler;
                ILogHandler      WriteLog   = ServiceContainer.GetService <ILogHandler>() as ILogHandler;
                ICommonHandler   comHandler = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler; //Add by Jutarat A. on 17092013

                List <dtDocumentListForPrining> lst = handler.GetDocumentListForPrining(DocumentType.C_DOCUMENT_TYPE_INCOME, DocumentType.C_DOCUMENT_TYPE_COMMON, data.IssueDate, data.ManagementNoFrom, data.ManagementNoTo);
                if (lst == null || lst.Count <= 0)
                {
                    res.ResultData = false;
                    res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0001);
                    return(Json(res));
                }
                else
                {
                    //WriteLog.SearchFoxitProcess("CMS460"); //Add by Jutarat A. on 20082013

                    //Add by Jutarat A. on 17092013
                    string strErrorMessage = string.Empty;
                    bool   bResult         = comHandler.AllocatePrintingProcess(PrintingFlag.C_PRINTING_FLAG_CMS460, ScreenID.C_SCREEN_ID_REPRINT_BILLING_RELATED_DOCUMENT, ref strErrorMessage);
                    if (bResult)
                    //End Add
                    {
                        foreach (dtDocumentListForPrining doclist in lst)
                        {
                            // doDocumentDownloadLog
                            doDocumentDownloadLog cond = new doDocumentDownloadLog();
                            cond.DocumentNo   = doclist.DocumentNo;
                            cond.DocumentCode = doclist.DocumentCode;
                            cond.DocumentOCC  = doclist.DocumentOCC;
                            cond.DownloadDate = CommonUtil.dsTransData.dtOperationData.ProcessDateTime;
                            cond.DownloadBy   = CommonUtil.dsTransData.dtUserData.EmpNo;


                            int isSuccess = WriteLog.WriteDocumentDownloadLog(cond);

                            if (doclist.DocumentCode == ReportID.C_REPORT_ID_ISSUE_LIST)
                            {
                                // print per page

                                string   temPath  = PathUtil.GetTempFileName(".pdf");
                                FileInfo fileInfo = new FileInfo(temPath);

                                if (Directory.Exists(fileInfo.DirectoryName) == false)
                                {
                                    Directory.CreateDirectory(fileInfo.DirectoryName);
                                }

                                int?PageFrom = 0;
                                int?PageTo   = 0;
                                if (data.ManagementNoTo <= doclist.MaxManagementNo)
                                {
                                    if (data.ManagementNoFrom < doclist.MinManagementNo)
                                    {
                                        PageFrom = 1;
                                        PageTo   = (data.ManagementNoTo - doclist.MinManagementNo) + 1;
                                    }
                                    else
                                    {
                                        PageFrom = (data.ManagementNoFrom - doclist.MinManagementNo) + 1;
                                        PageTo   = (data.ManagementNoTo - doclist.MinManagementNo) + 1;
                                    }
                                }
                                else
                                {
                                    if (data.ManagementNoFrom < doclist.MinManagementNo)
                                    {
                                        PageFrom = 1;
                                        PageTo   = (doclist.MaxManagementNo - doclist.MinManagementNo) + 1;
                                    }
                                    else
                                    {
                                        PageFrom = (data.ManagementNoFrom - doclist.MinManagementNo) + 1;
                                        PageTo   = (doclist.MaxManagementNo - doclist.MinManagementNo) + 1;
                                    }
                                }

                                bool iSuccess = ReportUtil.PDFSplitPage(doclist.FilePathDocument, (PageFrom ?? 0), (PageTo ?? 0), temPath);

                                if (iSuccess)
                                {
                                    //PrintPDF(temPath);
                                    comHandler.PrintPDF(temPath); //Modify by Jutarat A. on 17092013
                                }

                                System.IO.File.Delete(temPath);
                            }
                            else
                            {
                                FileInfo fileInfo = new FileInfo(doclist.FilePathDocument);
                                if (fileInfo.Exists)
                                {
                                    //PrintPDF(doclist.FilePathDocument);
                                    comHandler.PrintPDF(doclist.FilePathDocument); //Modify by Jutarat A. on 17092013
                                }
                            }
                        }

                        bResult = comHandler.ResetPrintingProcess(ProcessID.C_PROCESS_ID_PRINTING_SERVICE); //Add by Jutarat A. on 17092013
                    }
                    //Add by Jutarat A. on 17092013
                    else
                    {
                        res.ResultData = false;
                        res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0160);
                        return(Json(res));
                    }
                    //End Add
                }
            }
            catch (Exception ex)
            {
                res.AddErrorMessage(ex);
                return(Json(res));
            }
            return(Json(res));
        }