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); }
internal doBatchProcessResult BatchGenerateDebtTracingNoticeProcess(string UserId, DateTime BatchDate, string strServiceTypeCode) { string BatchUserID = (strServiceTypeCode == ServiceType.C_SERVICE_TYPE_SALE ? "ICP060" : "ICP070"); try { var handler = new IncomeHandler(); var dochandler = new IncomeDocumentHandler(); handler.GenerateDebtTracingNotice(BatchDate, null, strServiceTypeCode, BatchDate, BatchUserID); List <doDebtTracingDocNoForGenerate> lstDocNo = handler.GetDebtTracingDocNoForGenerate(BatchDate, strServiceTypeCode); var result = new doBatchProcessResult() { Result = FlagType.C_FLAG_ON, BatchStatus = BatchStatus.C_BATCH_STATUS_SUCCEEDED, Total = lstDocNo.Count, Complete = 0, Failed = 0, ErrorMessage = null, BatchUser = BatchUserID, BatchDate = BatchDate }; foreach (var doc in lstDocNo) { using (TransactionScope scope = new TransactionScope()) { try { string reportpath = null; if (doc.DocumentType == RunningType.C_RUNNING_TYPE_DEBT_TRACING_NOTICE1) { reportpath = dochandler.GenerateICR030FilePath(doc.DocumentNo, BatchUserID, BatchDate); } else if (doc.DocumentType == RunningType.C_RUNNING_TYPE_DEBT_TRACING_NOTICE2) { reportpath = dochandler.GenerateICR040FilePath(doc.DocumentNo, BatchUserID, BatchDate); } handler.UpdateDebtTracingNoticeGenerateFlag(doc.DocumentNo); if (string.IsNullOrEmpty(reportpath)) { result.Failed++; } else { result.Complete++; } scope.Complete(); } catch (Exception ex) { result.Failed++; result.ErrorMessage = ex.Message; scope.Dispose(); return(result); } } } return(result); } catch (Exception ex) { return(new doBatchProcessResult() { Result = FlagType.C_FLAG_OFF, BatchStatus = BatchStatus.C_BATCH_STATUS_FAILED, Total = 1, Complete = 0, Failed = 1, ErrorMessage = ex.Message, //msg.Message, BatchUser = BatchUserID, BatchDate = BatchDate }); } }