public dtAccountingConfig getAccountingConfig(string configGroup, string configName) { dtAccountingConfig dt = null; var acc = db.GetAccountingConfig(configGroup, configName).ToList(); if (acc.Count() < 1) { return(dt); } dt = new dtAccountingConfig(); dt = acc.First(); return(dt); }
public doGenerateDocumentResult ACC009_NewOperationRentalReport(DocumentContext context) { doGenerateDocumentResult result = new doGenerateDocumentResult() { ErrorFlag = false, Total = 0, Complete = 0, Failed = 0, ResultDocumentNoList = string.Empty }; using (TransactionScope scope = new TransactionScope()) { try { #region Write text report dtAccountingConfig folder = this.getAccountingConfig(AccountingConfig.C_ACC_CONFIG_GROUP_CSV, AccountingConfig.C_ACC_CONFIG_NAME_FOLDER); string documentNo = string.Format(@"{0}{1}{2}{3}", context.DocumentCode, context.TargetPeriodFrom.Value.ToString("yyyyMMdd"), context.TargetPeriodTo.Value.ToString("yyyyMMdd"), context.UserHQCode); string outputfilepath = string.Format(@"{0}\{1}\{2}.xlsx", context.TargetPeriodTo.Value.ToString("yyyyMM"), folder.ConfigValue, documentNo); string fullOutputFilePath = PathUtil.GetPathValue(PathUtil.PathName.GeneratedReportPath, outputfilepath); ICommonHandler comHand = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler; List <doMiscTypeCode> tmpCurrencies = comHand.GetMiscTypeCodeList(new List <doMiscTypeCode>() { new doMiscTypeCode() { FieldName = MiscType.C_CURRENCT, ValueCode = "%" } }).ToList(); Currencies = new List <doMiscTypeCode>(tmpCurrencies); using (SLDocument doc = new SLDocument()) { //Sheet1 { result = this.GenerateACC009_Sheet1(context, doc, "Sheet1"); if (result.ErrorFlag == true) { return(result); } } WriteCSVFile egWriteCSV = new WriteCSVFile(); egWriteCSV.IfExitDeleteFile(fullOutputFilePath); doc.SaveAs(fullOutputFilePath); } #endregion #region Keep daily genereated document List <tbt_AccountingDocumentList> genComplete = new List <tbt_AccountingDocumentList>(); genComplete.Add(new tbt_AccountingDocumentList() { DocumentNo = documentNo, DocumentCode = context.DocumentCode, TargetPeriodFrom = context.TargetPeriodFrom.Value, TargetPeriodTo = context.TargetPeriodTo.Value, GenerateHQCode = context.UserHQCode, ReportMonth = Convert.ToInt32(context.TargetPeriodTo.Value.ToString("MM")), ReportYear = Convert.ToInt32(context.TargetPeriodTo.Value.ToString("yyyy")), FilePath = outputfilepath, CreateBy = CommonUtil.dsTransData.dtUserData.EmpNo, CreateDate = DateTime.Now, UpdateBy = CommonUtil.dsTransData.dtUserData.EmpNo, UpdateDate = DateTime.Now }); this.Insert_tbt_AccountingDocumentList(CommonUtil.ConvertToXml_Store <tbt_AccountingDocumentList>(genComplete)); #endregion scope.Complete(); //Record info result.Complete = result.Total; result.ResultDocumentNoList = documentNo; return(result); } catch (Exception ex) { scope.Dispose(); throw; } } }
public doGenerateDocumentResult ACC012_NotPaymentListReport(DocumentContext context) { doGenerateDocumentResult result = new doGenerateDocumentResult() { ErrorFlag = false, Total = 0, Complete = 0, Failed = 0, ResultDocumentNoList = string.Empty }; using (TransactionScope scope = new TransactionScope()) { try { #region Write text report dtAccountingConfig folder = this.getAccountingConfig(AccountingConfig.C_ACC_CONFIG_GROUP_CSV, AccountingConfig.C_ACC_CONFIG_NAME_FOLDER); string documentNo = string.Format(@"{0}{1}{2}", context.DocumentCode, context.TargetPeriodTo.Value.ToString("yyyyMMdd"), context.UserHQCode); string outputfilepath = string.Format(@"{0}\{1}\{2}.xlsx", context.TargetPeriodTo.Value.ToString("yyyyMM"), folder.ConfigValue, documentNo); string fullOutputFilePath = PathUtil.GetPathValue(PathUtil.PathName.GeneratedReportPath, outputfilepath); int dataNotFoundCount = 0; using (SLDocument doc = new SLDocument()) { //Sheet1 { result = this.GenerateACC012_Sheet1(context, doc, "Sheet1"); if (result.ErrorFlag == true) { if (result.ErrorCode == MessageUtil.MessageList.MSG8005) { dataNotFoundCount++; } else { return(result); } } else { result.Complete += 1; } } //Sheet2 { result = this.GenerateACC012_Sheet2(context, doc, "Sheet2"); if (result.ErrorFlag == true) { if (result.ErrorCode == MessageUtil.MessageList.MSG8005) { dataNotFoundCount++; } else { return(result); } } else { result.Complete += 1; } } //Sheet3 { result = this.GenerateACC012_Sheet3(context, doc, "Sheet3"); if (result.ErrorFlag == true) { if (result.ErrorCode == MessageUtil.MessageList.MSG8005) { dataNotFoundCount++; } else { return(result); } } else { result.Complete += 1; } } //Sheet4 { result = this.GenerateACC012_Sheet4(context, doc, "Sheet4"); if (result.ErrorFlag == true) { if (result.ErrorCode == MessageUtil.MessageList.MSG8005) { dataNotFoundCount++; } else { return(result); } } else { result.Complete += 1; } } //Sheet5 { result = this.GenerateACC012_Sheet5(context, doc, "Sheet5"); if (result.ErrorFlag == true) { if (result.ErrorCode == MessageUtil.MessageList.MSG8005) { dataNotFoundCount++; } else { return(result); } } else { result.Complete += 1; } } //Sheet6 { result = this.GenerateACC012_Sheet6(context, doc, "Sheet6"); if (result.ErrorFlag == true) { if (result.ErrorCode == MessageUtil.MessageList.MSG8005) { dataNotFoundCount++; } else { return(result); } } else { result.Complete += 1; } } if (dataNotFoundCount >= 6) { return(result); } else { result.ErrorFlag = false; } WriteCSVFile egWriteCSV = new WriteCSVFile(); egWriteCSV.IfExitDeleteFile(fullOutputFilePath); doc.SaveAs(fullOutputFilePath); } #endregion #region Keep daily genereated document List <tbt_AccountingDocumentList> genComplete = new List <tbt_AccountingDocumentList>(); genComplete.Add(new tbt_AccountingDocumentList() { DocumentNo = documentNo, DocumentCode = context.DocumentCode, TargetPeriodFrom = context.TargetPeriodTo.Value, TargetPeriodTo = context.TargetPeriodTo.Value, GenerateHQCode = context.UserHQCode, ReportMonth = Convert.ToInt32(context.TargetPeriodTo.Value.ToString("MM")), ReportYear = Convert.ToInt32(context.TargetPeriodTo.Value.ToString("yyyy")), FilePath = outputfilepath, CreateBy = CommonUtil.dsTransData.dtUserData.EmpNo, CreateDate = DateTime.Now, UpdateBy = CommonUtil.dsTransData.dtUserData.EmpNo, UpdateDate = DateTime.Now }); this.Insert_tbt_AccountingDocumentList(CommonUtil.ConvertToXml_Store <tbt_AccountingDocumentList>(genComplete)); #endregion scope.Complete(); //Record info result.Complete = result.Total; result.ResultDocumentNoList = documentNo; return(result); } catch (Exception ex) { scope.Dispose(); throw; } } }
public doGenerateDocumentResult ACC002_AgingReport(DocumentContext context) { #region Prepare doGenerateDocumentResult result = new doGenerateDocumentResult() { ErrorFlag = false, Total = 0, Complete = 0, Failed = 0, ResultDocumentNoList = string.Empty }; #endregion using (TransactionScope scope = new TransactionScope()) { try { ICommonHandler comHand = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler; List <doMiscTypeCode> tmpCurrencies = comHand.GetMiscTypeCodeList(new List <doMiscTypeCode>() { new doMiscTypeCode() { FieldName = MiscType.C_CURRENCT, ValueCode = "%" } }).ToList(); #region Do process //Get business date parameter dtAccountingBusinessDateOfAgingReport businessDate = this.GetAccountingBusinessDateOfAgingReport(context.TargetPeriodTo).FirstOrDefault(); dtAccountingConfig folder = this.getAccountingConfig(AccountingConfig.C_ACC_CONFIG_GROUP_CSV, AccountingConfig.C_ACC_CONFIG_NAME_FOLDER); #region Generate report //Get account data List <dtAccountDataOfAgingReport> accountData = this.GetAccountDataOfAgingReport(businessDate.TargetPeriod.Value, businessDate.LastEndDate.Value, context.UserHQCode); if (accountData.Count == 0) { result.ErrorFlag = true; result.ErrorCode = MessageUtil.MessageList.MSG8005; return(result); } for (int i = 0; i < accountData.Count(); i++) { accountData[i].Currencies = new List <doMiscTypeCode>(tmpCurrencies); } #region Write text report //Format: ..\YYYYMM\[CSV.Folder]\ACC002YYYYMMDDHQCD.csv string textContent = CSVReportUtil.GenerateAccountingCSVData <dtAccountDataOfAgingReport>(accountData, true, true, "No."); string documentNo = string.Format(@"{0}{1}{2}", context.DocumentCode, businessDate.TargetPeriod.Value.ToString("yyyyMMdd"), context.UserHQCode); string outputfilepath = string.Format(@"{0}{1}\{2}\{3}.csv", businessDate.ReportYear, businessDate.ReportMonth, folder.ConfigValue, documentNo); string fullOutputFilePath = PathUtil.GetPathValue(PathUtil.PathName.GeneratedReportPath, outputfilepath); WriteCSVFile egWriteCSV = new WriteCSVFile(); egWriteCSV.IfExitDeleteFile(fullOutputFilePath); using (StreamWriter sw = new StreamWriter(fullOutputFilePath, false, Encoding.GetEncoding("TIS-620"))) { sw.WriteLine(textContent); sw.Close(); } #endregion #region Keep daily genereated document List <tbt_AccountingDocumentList> genComplete = new List <tbt_AccountingDocumentList>(); genComplete.Add(new tbt_AccountingDocumentList() { DocumentNo = documentNo, DocumentCode = context.DocumentCode, TargetPeriodFrom = businessDate.TargetPeriod.Value, TargetPeriodTo = businessDate.TargetPeriod.Value, GenerateHQCode = context.UserHQCode, ReportMonth = Convert.ToInt32(businessDate.ReportMonth), ReportYear = Convert.ToInt32(businessDate.ReportYear), FilePath = outputfilepath, CreateBy = CommonUtil.dsTransData.dtUserData.EmpNo, CreateDate = DateTime.Now, UpdateBy = CommonUtil.dsTransData.dtUserData.EmpNo, UpdateDate = DateTime.Now }); this.Insert_tbt_AccountingDocumentList(CommonUtil.ConvertToXml_Store <tbt_AccountingDocumentList>(genComplete)); #endregion scope.Complete(); //Record info result.Total += accountData.Count; result.Complete = result.Total; result.ResultDocumentNoList = documentNo; return(result); } catch (Exception ex) { scope.Dispose(); throw; } #endregion #endregion } }