public void InitialDataMocking() { // *********** cost data ********************// CompanyCode = "3139"; CompanyName = "บริษัท ไทยพาณิชย์ประกันภัย จำกัด (มหาชน)"; _userId = "0000000000000000"; DateTime oneYearStart = new DateTime(2013, 1, 1); DateTime oneYearEnd = new DateTime(2014, 12, 31); DateTime fiveYearStart = new DateTime(2013, 1, 1); DateTime fiveYearEnd = new DateTime(2018, 12, 31); /*********************************************/ AG_IAS_LICENSE_H licenseH1 = CreateLicenseH("131004104328818", CompanyCode, CompanyName, 3, "13", "01"); _licenseHs.Add(licenseH1); _licenseDs.Add(CreateLicenseD(licenseH1, (1).ToString("0000"), "L000000111", oneYearStart, oneYearEnd, "1111111111111", "นาย", "กไก่", "กุ่กกุ๊ก", UserId)); _licenseDs.Add(CreateLicenseD(licenseH1, (2).ToString("0000"), "L000000112", oneYearStart, oneYearEnd, "1111111111112", "นาย", "ขไข่", "อยู่ในเล่า", UserId)); _licenseDs.Add(CreateLicenseD(licenseH1, (3).ToString("0000"), "L000000113", oneYearStart, oneYearEnd, "1111111111113", "นาย", "คควาย", "เข้านา", UserId)); AG_IAS_LICENSE_H licenseH2 = CreateLicenseH("131004104328819", CompanyCode, CompanyName, 3, "14", "02"); _licenseHs.Add(licenseH2); _licenseDs.Add(CreateLicenseD(licenseH2, (1).ToString("0000"), "L000000221", fiveYearStart, oneYearEnd, "2222222222221", "นาง", "กไก่", "กุ่กกุ๊ก", UserId)); _licenseDs.Add(CreateLicenseD(licenseH2, (2).ToString("0000"), "L000000222", fiveYearStart, fiveYearEnd, "2222222222222", "นาง", "ขไข่", "อยู่ในเล่า", UserId)); _licenseDs.Add(CreateLicenseD(licenseH2, (3).ToString("0000"), "L000000223", fiveYearStart, fiveYearEnd, "2222222222223", "นาง", "คควาย", "เข้านา", UserId)); AG_IAS_PAYMENT_G_T paymentGT = CreatePaymentGT("999999560900000001", "P", 6); _paymentGTs.Add(paymentGT); AG_IAS_SUBPAYMENT_H_T subHT1 = CreateSubPaymentHT(paymentGT, "1309231620210000", "13", "P", 3); _subPaymentHTs.Add(subHT1); DateTime d = DateTime.Now; _subPaymentDTs.Add(CreateSubPaymentDT(subHT1, (1).ToString("0000"), "1111111111111", "A", "12122e11300001", d)); _subPaymentDTs.Add(CreateSubPaymentDT(subHT1, (2).ToString("0000"), "1111111111112", "A", "12122e11300002", d)); _subPaymentDTs.Add(CreateSubPaymentDT(subHT1, (3).ToString("0000"), "1111111111113", "A", "12122e11300003", d)); AG_IAS_SUBPAYMENT_H_T subHT2 = CreateSubPaymentHT(paymentGT, "1309231620220000", "14", "P", 3); _subPaymentHTs.Add(subHT2); _subPaymentDTs.Add(CreateSubPaymentDT(subHT2, (1).ToString("0000"), "2222222222221", "A", "12122e11300004", d)); _subPaymentDTs.Add(CreateSubPaymentDT(subHT2, (2).ToString("0000"), "2222222222222", "A", "12122e11300005", d)); _subPaymentDTs.Add(CreateSubPaymentDT(subHT2, (3).ToString("0000"), "2222222222223", "A", "12122e11300006", d)); IAS.DAL.Interfaces.IIASPersonEntities ctx = DAL.DALFactory.GetPersonContext(); _licenseTypeRs = ctx.AG_IAS_LICENSE_TYPE_R.ToList(); _petitionTypeRs = ctx.AG_IAS_PETITION_TYPE_R.ToList(); }
public static String StartCompressByOicApprove(IAS.DAL.Interfaces.IIASPersonEntities ctx, List <DTO.GenLicenseDetail> LicenseDetail, String userName, String zipName) { string _netDrive = ConfigurationManager.AppSettings["DEFAULT_NET_DRIVE"]; string _userNetDrive = ConfigurationManager.AppSettings["USER_NET_DRIVE"]; string _passNetDrive = ConfigurationManager.AppSettings["PASS_NET_DRIVE"]; String _compressPath = ConfigurationManager.AppSettings["COMPRESS_FOLDER"].ToString(); String imageTypeCode = ConfigurationManager.AppSettings["CODE_ATTACH_PHOTO"].ToString(); NASDrive nasDrive = new NASDrive(_netDrive, _userNetDrive, _passNetDrive); // กำหนด รหัส TypeImage สำหรับค้นหา Boolean IsNotCreateFolder = true; DirectoryInfo zipFolder = null; foreach (var item in LicenseDetail) { AG_IAS_LICENSE_D LD = ctx.AG_IAS_LICENSE_D.FirstOrDefault(s => s.ID_CARD_NO == item.ID_CARD_NO && s.UPLOAD_GROUP_NO == item.UPLOAD_GROUP_NO); AG_IAS_LICENSE_H LH = ctx.AG_IAS_LICENSE_H.Single(w => w.UPLOAD_GROUP_NO == LD.UPLOAD_GROUP_NO); AG_IAS_LICENSE_TYPE_R licenType = ctx.AG_IAS_LICENSE_TYPE_R.Single(s => s.LICENSE_TYPE_CODE == LH.LICENSE_TYPE_CODE); AG_IAS_ATTACH_FILE_LICENSE attach = Helpers.GetIASConfigHelper.GetAttachLicensePhoto(ctx, LD.ID_CARD_NO, LD.UPLOAD_GROUP_NO); if (attach == null) { nasDrive.Dispose(); throw new ApplicationException(String.Format("ไม่พบ รูปสำหรับทำใบอนุญาติของ {0} {1} {2}", LD.NAMES, LD.LASTNAME, LD.ID_CARD_NO)); } if (IsNotCreateFolder) { zipFolder = CreateDirectory(Path.Combine(_netDrive, _compressPath), (String.IsNullOrEmpty(zipName)) ? DateTime.Now.ToString("yyyy-MM-dd-hhmmss") : zipName, 0); IsNotCreateFolder = false; } AddLicenseRequest(ctx, _netDrive, zipFolder, LD, LH, licenType, attach); } String zipfileName = ""; if (!IsNotCreateFolder) { using (ZipFile zip = new ZipFile()) { zip.AddDirectory(zipFolder.FullName); // recurses subdirectories zipfileName = zipFolder.FullName + ".zip"; zip.Save(zipfileName); zipfileName = zipfileName.Replace(_netDrive, ""); } if (Directory.Exists(zipFolder.FullName)) { Directory.Delete(zipFolder.FullName, true); } } nasDrive.Dispose(); return(zipfileName); }
private static void AddLicenseRequest(IAS.DAL.Interfaces.IIASPersonEntities ctx, String _netDrive, DirectoryInfo zipFolder, AG_IAS_SUBPAYMENT_H_T SubPaymentHT, AG_IAS_SUBPAYMENT_D_T subPaymentDT, AG_IAS_LICENSE_D licenD, AG_IAS_LICENSE_H licenH, AG_IAS_LICENSE_TYPE_R licenType, AG_IAS_ATTACH_FILE_LICENSE attach) { String filePath = String.Format(@"{0}\{1}\{2}\{3}", zipFolder.FullName, ((String.IsNullOrEmpty(licenH.COMP_CODE))?"0000": licenH.COMP_CODE), SubPaymentHT.PETITION_TYPE_CODE, licenType.LICENSE_TYPE_CODE); DirectoryInfo dirInfo = new DirectoryInfo(Path.Combine(_netDrive, filePath)); if (!dirInfo.Exists) { dirInfo.Create(); } FileInfo fileInfo = new FileInfo(Path.Combine(dirInfo.FullName, "1.txt")); if (!fileInfo.Exists) { using (System.IO.StreamWriter file = new System.IO.StreamWriter(fileInfo.FullName, true, Encoding.GetEncoding(874))) { file.WriteLine("ชื่อรูป,เลขที่ใบอนุญาต,เลขบัตรประชาชน,ชื่อ,สกุล,วันที่ออกใบอนุญาต,วันที่หมดอายุ,บริษัท,ประเภทใบอนุญาต,"); } } using (System.IO.StreamWriter file = new System.IO.StreamWriter(fileInfo.FullName, true, Encoding.GetEncoding(874))) { file.WriteLine(String.Format("{0},{1},{2},{3},{4},\"{5}\",\"{6}\",{7},{8},", subPaymentDT.ID_CARD_NO, WordSpacing(subPaymentDT.LICENSE_NO), WordSpacing(subPaymentDT.ID_CARD_NO), String.Format("{0} {1}", licenD.TITLE_NAME, licenD.NAMES), licenD.LASTNAME, ((DateTime)licenD.LICENSE_DATE).ToString("dd/MM/yyy", CultureInfo.CreateSpecificCulture("th-TH")), ((DateTime)licenD.LICENSE_EXPIRE_DATE).ToString("dd/MM/yyy", CultureInfo.CreateSpecificCulture("th-TH")), licenH.COMP_NAME, licenType.LICENSE_TYPE_NAME)); } Int32 start = attach.ATTACH_FILE_PATH.LastIndexOf('.'); Int32 len = attach.ATTACH_FILE_PATH.Length; String extension = attach.ATTACH_FILE_PATH.Substring(attach.ATTACH_FILE_PATH.LastIndexOf('.'), len - start); MoveFileResponse response = FileManagerService.RemoteFileCommand(new MoveFileRequest() { CurrentContainer = "", CurrentFileName = attach.ATTACH_FILE_PATH, TargetContainer = String.Format(@"{0}\{1}", dirInfo.FullName.Replace(_netDrive, ""), "images"), TargetFileName = String.Format("{0}{1}", licenD.ID_CARD_NO, extension) }).Action(); if (response.Code != "0000") { throw new ApplicationException(response.Message); } }
private AG_IAS_LICENSE_D CreateLicenseD(AG_IAS_LICENSE_H h, String seq, String lencenseNo, DateTime licenseStart, DateTime licenseEnd, String idCard, String titleName, String names, String lastName, String userId) { AG_IAS_LICENSE_D license = new AG_IAS_LICENSE_D() { UPLOAD_GROUP_NO = h.UPLOAD_GROUP_NO, SEQ_NO = seq, LICENSE_NO = lencenseNo, LICENSE_DATE = licenseStart, LICENSE_EXPIRE_DATE = licenseEnd, ID_CARD_NO = idCard, TITLE_NAME = titleName, NAMES = names, LASTNAME = lastName }; CreateAttachFileLicense(license, userId); return(license); }
private AG_IAS_SUBPAYMENT_D_T CreateSubPaymentDT(AG_IAS_SUBPAYMENT_H_T ht, String paymentNo, String idCard, String status, String receiptNo, DateTime receiptDate) { AG_IAS_LICENSE_D licenD = LicenseDs.Single(l => l.ID_CARD_NO == idCard); AG_IAS_LICENSE_H licenH = LicenseHs.Single(l => l.UPLOAD_GROUP_NO == licenD.UPLOAD_GROUP_NO); return(new AG_IAS_SUBPAYMENT_D_T() { PAYMENT_NO = paymentNo, HEAD_REQUEST_NO = ht.HEAD_REQUEST_NO, ID_CARD_NO = licenD.ID_CARD_NO, LICENSE_NO = licenD.LICENSE_NO, LICENSE_TYPE_CODE = licenH.LICENSE_TYPE_CODE, RECORD_STATUS = status, RECEIPT_NO = receiptNo, RECEIPT_DATE = receiptDate, UPLOAD_GROUP_NO = licenD.UPLOAD_GROUP_NO, SEQ_NO = licenD.SEQ_NO }); }
public void TestSelect_PaymentRequestLicense_From_MockData() { String zipName = "TestZip6"; DirectoryInfo zipFolder = CreateDirectory(Path.Combine(_netDrive, _oicPath), zipName, 0); //ดึงข้อมูลการเงินจากธนาคารใน Temp ตาม BatchID IEnumerable <AG_IAS_PAYMENT_G_T> paymentGTs = GetPaymentGTs(); foreach (AG_IAS_PAYMENT_G_T paymentGT in paymentGTs) { //หาข้อมูลที่ Sub Payment Head IEnumerable <AG_IAS_SUBPAYMENT_H_T> subPaymentHTs = GetSubPaymentHead(paymentGT); foreach (AG_IAS_SUBPAYMENT_H_T SubPaymentHT in subPaymentHTs) { IEnumerable <AG_IAS_SUBPAYMENT_D_T> subPaymentDTs = GetSubPaymentDetails(SubPaymentHT); foreach (AG_IAS_SUBPAYMENT_D_T subPaymentDT in subPaymentDTs) { AG_IAS_LICENSE_D licenD = LicenseDs.SingleOrDefault(w => w.UPLOAD_GROUP_NO == subPaymentDT.UPLOAD_GROUP_NO && w.SEQ_NO == subPaymentDT.SEQ_NO); AG_IAS_LICENSE_H licenH = LicenseHs.Single(w => w.UPLOAD_GROUP_NO == licenD.UPLOAD_GROUP_NO); AG_IAS_LICENSE_TYPE_R licenType = LicenseTypeRs.Single(l => l.LICENSE_TYPE_CODE == subPaymentDT.LICENSE_TYPE_CODE); AG_IAS_ATTACH_FILE_LICENSE attach = AttachLicenses.Single(a => a.ID_CARD_NO == licenD.ID_CARD_NO && a.GROUP_LICENSE_ID == licenD.UPLOAD_GROUP_NO && a.ATTACH_FILE_PATH.EndsWith("03.jpg")); AddLicenseRequest(zipFolder, SubPaymentHT, subPaymentDT, licenD, licenH, licenType, attach); } } } using (ZipFile zip = new ZipFile()) { zip.AddDirectory(zipFolder.FullName); // recurses subdirectories zip.Save(zipFolder.FullName + ".zip"); } }
public static String StartCompressByPayment(IAS.DAL.Interfaces.IIASPersonEntities ctx, DateTime findDate, String userName, String zipName) { string _netDrive = ConfigurationManager.AppSettings["DEFAULT_NET_DRIVE"]; string _userNetDrive = ConfigurationManager.AppSettings["USER_NET_DRIVE"]; string _passNetDrive = ConfigurationManager.AppSettings["PASS_NET_DRIVE"]; String _compressPath = ConfigurationManager.AppSettings["COMPRESS_FOLDER"].ToString(); String imageTypeCode = ConfigurationManager.AppSettings["CODE_ATTACH_PHOTO"].ToString(); NASDrive nasDrive; nasDrive = new NASDrive(_netDrive, _userNetDrive, _passNetDrive); // กำหนด รหัส TypeImage สำหรับค้นหา Boolean IsNotCreateFolder = true; DirectoryInfo zipFolder = null; //ดึงข้อมูลการเงินจากธนาคารใน Temp ตาม BatchID IEnumerable <AG_IAS_PAYMENT_G_T> paymentGTs = GetPaymentGTs(ctx, findDate); foreach (AG_IAS_PAYMENT_G_T paymentGT in paymentGTs) { //หาข้อมูลที่ Sub Payment Head IEnumerable <AG_IAS_SUBPAYMENT_H_T> subPaymentHTs = GetSubPaymentHead(ctx, paymentGT); foreach (AG_IAS_SUBPAYMENT_H_T SubPaymentHT in subPaymentHTs) { IEnumerable <AG_IAS_SUBPAYMENT_D_T> subPaymentDTs = GetSubPaymentDetails(ctx, SubPaymentHT); foreach (AG_IAS_SUBPAYMENT_D_T subPaymentDT in subPaymentDTs) // milk มาทำ เพิ่ม if else กันกรณีหลุด ไม่มีค่าแล้วเป็นข้อความ error { if ((subPaymentDT.UPLOAD_GROUP_NO != null) && (subPaymentDT.SEQ_NO != null)) { AG_IAS_LICENSE_D licenD = ctx.AG_IAS_LICENSE_D.SingleOrDefault(w => w.UPLOAD_GROUP_NO == subPaymentDT.UPLOAD_GROUP_NO && w.SEQ_NO == subPaymentDT.SEQ_NO); AG_IAS_LICENSE_H licenH = ctx.AG_IAS_LICENSE_H.Single(w => w.UPLOAD_GROUP_NO == licenD.UPLOAD_GROUP_NO); if (subPaymentDT.LICENSE_TYPE_CODE != null) { if (licenD.OIC_APPROVED_BY != null) { String whereType = String.Format("_{0}.", imageTypeCode); AG_IAS_LICENSE_TYPE_R licenType = ctx.AG_IAS_LICENSE_TYPE_R.Single(l => l.LICENSE_TYPE_CODE == subPaymentDT.LICENSE_TYPE_CODE); AG_IAS_ATTACH_FILE_LICENSE attach = ctx.AG_IAS_ATTACH_FILE_LICENSE.SingleOrDefault(a => a.ID_CARD_NO == licenD.ID_CARD_NO && a.GROUP_LICENSE_ID == licenD.UPLOAD_GROUP_NO && a.ATTACH_FILE_PATH.Contains(whereType)); if (attach == null) { nasDrive.Dispose(); throw new ApplicationException(String.Format("ไม่พบ รูปสำหรับทำใบอนุญาติของ {0} {1} {2}", licenD.NAMES, licenD.LASTNAME, licenD.ID_CARD_NO)); } if (IsNotCreateFolder) { zipFolder = CreateDirectory(Path.Combine(_netDrive, _compressPath), (String.IsNullOrEmpty(zipName)) ? findDate.ToString("yyyy-MM-dd-hhmmss") : zipName, 0); IsNotCreateFolder = false; } AddLicenseRequest(ctx, _netDrive, zipFolder, SubPaymentHT, subPaymentDT, licenD, licenH, licenType, attach); } } else { throw new ApplicationException(String.Format("ไม่พบประเภทใบอนุญาตของ {0}{1} {2} {3}", licenD.TITLE_NAME, licenD.NAMES, licenD.LASTNAME, licenD.ID_CARD_NO)); } } else { throw new ApplicationException(String.Format("ไม่พบเลขอ้างอิงในการอัพโหลดเอกสารของ หมายเลขบัตรประชาชน {0} ", subPaymentDT.ID_CARD_NO)); } } } } String zipfileName = ""; if (!IsNotCreateFolder) { using (ZipFile zip = new ZipFile()) { zip.AddDirectory(zipFolder.FullName); // recurses subdirectories zipfileName = zipFolder.FullName + ".zip"; zip.Save(zipfileName); zipfileName = zipfileName.Replace(_netDrive, ""); } } nasDrive.Dispose(); return(zipfileName); }
public static String StartCompressByOicApprove(IAS.DAL.Interfaces.IIASPersonEntities ctx, DateTime findDate, String userName, String zipName) { string _netDrive = ConfigurationManager.AppSettings["DEFAULT_NET_DRIVE"]; string _userNetDrive = ConfigurationManager.AppSettings["USER_NET_DRIVE"]; string _passNetDrive = ConfigurationManager.AppSettings["PASS_NET_DRIVE"]; String _compressPath = ConfigurationManager.AppSettings["COMPRESS_FOLDER"].ToString(); String imageTypeCode = ConfigurationManager.AppSettings["CODE_ATTACH_PHOTO"].ToString(); NASDrive nasDrive; nasDrive = new NASDrive(_netDrive, _userNetDrive, _passNetDrive); // กำหนด รหัส TypeImage สำหรับค้นหา Boolean IsNotCreateFolder = true; DirectoryInfo zipFolder = null; DateTime startDate = new DateTime(findDate.Year, findDate.Month, findDate.Day, 0, 0, 0); DateTime endDate = new DateTime(findDate.Year, findDate.Month, findDate.Day, 23, 59, 59); //ดึงข้อมูลการเงินจากธนาคารใน Temp ตาม BatchID IEnumerable <AG_IAS_LICENSE_D> licenseDs = ctx.AG_IAS_LICENSE_D. Where(a => a.OIC_APPROVED_DATE >= startDate && a.OIC_APPROVED_DATE <= endDate); foreach (AG_IAS_LICENSE_D licenD in licenseDs) // milk มาทำ เพิ่ม if else กันกรณีหลุด ไม่มีค่าแล้วเป็นข้อความ error { AG_IAS_LICENSE_H licenH = ctx.AG_IAS_LICENSE_H.Single(w => w.UPLOAD_GROUP_NO == licenD.UPLOAD_GROUP_NO); String whereType = String.Format("_{0}.", imageTypeCode); AG_IAS_LICENSE_TYPE_R licenType = ctx.AG_IAS_LICENSE_TYPE_R.Single(l => l.LICENSE_TYPE_CODE == licenH.LICENSE_TYPE_CODE); //AG_IAS_ATTACH_FILE_LICENSE attach = ctx.AG_IAS_ATTACH_FILE_LICENSE.SingleOrDefault(a => a.ID_CARD_NO == licenD.ID_CARD_NO // && a.GROUP_LICENSE_ID == licenD.UPLOAD_GROUP_NO // && a.ATTACH_FILE_PATH.Contains(whereType)); AG_IAS_ATTACH_FILE_LICENSE attach = Helpers.GetIASConfigHelper.GetAttachLicensePhoto(ctx, licenD.ID_CARD_NO, licenD.UPLOAD_GROUP_NO); if (attach == null) { nasDrive.Dispose(); throw new ApplicationException(String.Format("ไม่พบ รูปสำหรับทำใบอนุญาติของ {0} {1} {2}", licenD.NAMES, licenD.LASTNAME, licenD.ID_CARD_NO)); } if (IsNotCreateFolder) { zipFolder = CreateDirectory(Path.Combine(_netDrive, _compressPath), (String.IsNullOrEmpty(zipName)) ? findDate.ToString("yyyy-MM-dd-hhmmss") : zipName, 0); IsNotCreateFolder = false; } AddLicenseRequest(ctx, _netDrive, zipFolder, licenD, licenH, licenType, attach); } String zipfileName = ""; if (!IsNotCreateFolder) { using (ZipFile zip = new ZipFile()) { zip.AddDirectory(zipFolder.FullName); // recurses subdirectories zipfileName = zipFolder.FullName + ".zip"; zip.Save(zipfileName); zipfileName = zipfileName.Replace(_netDrive, ""); } } nasDrive.Dispose(); return(zipfileName); }
public void TestSelect_PaymentRequestLicense_From_DAL() { IAS.DAL.Interfaces.IIASPersonEntities ctx = DAL.DALFactory.GetPersonContext(); IList <AG_IAS_LICENSE_H> _licenseHs = new List <AG_IAS_LICENSE_H>(); IList <AG_IAS_LICENSE_D> _licenseDs = new List <AG_IAS_LICENSE_D>(); _licenseTypeRs = ctx.AG_IAS_LICENSE_TYPE_R.ToList(); _petitionTypeRs = ctx.AG_IAS_PETITION_TYPE_R.ToList(); String zipName = "TestZip"; DirectoryInfo zipFolder = CreateDirectory(_netDrive, zipName, 0); //ดึงข้อมูลการเงินจากธนาคารใน Temp ตาม BatchID var paymentGTs = ctx.AG_IAS_PAYMENT_G_T.Where(f => f.STATUS == "P" && f.GROUP_REQUEST_NO == "999999561000000040") .ToList(); foreach (AG_IAS_PAYMENT_G_T paymentGT in paymentGTs) { //หาข้อมูลที่ Sub Payment Head //var subPaymentHTs = ctx.AG_IAS_SUBPAYMENT_H_T // .Where(w => w.GROUP_REQUEST_NO == paymentGT.GROUP_REQUEST_NO && // (w.STATUS != null && w.STATUS == "P")) // .ToList(); var subPaymentHTs = ctx.AG_IAS_SUBPAYMENT_H_T .Where(w => w.GROUP_REQUEST_NO == paymentGT.GROUP_REQUEST_NO && (w.STATUS != null && w.STATUS == "P") && ( w.PETITION_TYPE_CODE == "11" || w.PETITION_TYPE_CODE == "13" || w.PETITION_TYPE_CODE == "14" || w.PETITION_TYPE_CODE == "15" || w.PETITION_TYPE_CODE == "16" || w.PETITION_TYPE_CODE == "17" || w.PETITION_TYPE_CODE == "18" ) ).ToList(); foreach (AG_IAS_SUBPAYMENT_H_T SubPaymentHT in subPaymentHTs) { IEnumerable <AG_IAS_SUBPAYMENT_D_T> subPaymentDTs = ctx.AG_IAS_SUBPAYMENT_D_T.Where(w => w.HEAD_REQUEST_NO == SubPaymentHT.HEAD_REQUEST_NO && !String.IsNullOrEmpty(w.RECEIPT_NO)); foreach (AG_IAS_SUBPAYMENT_D_T subPaymentDT in subPaymentDTs) { AG_IAS_LICENSE_D licenD = ctx.AG_IAS_LICENSE_D.SingleOrDefault(w => w.UPLOAD_GROUP_NO == subPaymentDT.UPLOAD_GROUP_NO && w.SEQ_NO == subPaymentDT.SEQ_NO); AG_IAS_LICENSE_H licenH = ctx.AG_IAS_LICENSE_H.Single(w => w.UPLOAD_GROUP_NO == licenD.UPLOAD_GROUP_NO); AG_IAS_ATTACH_FILE_LICENSE attach = ctx.AG_IAS_ATTACH_FILE_LICENSE.Single(a => a.ID_CARD_NO == licenD.ID_CARD_NO && a.GROUP_LICENSE_ID == licenD.UPLOAD_GROUP_NO && a.ATTACH_FILE_PATH.EndsWith("03.jpg")); AG_IAS_LICENSE_TYPE_R licenType = LicenseTypeRs.Single(l => l.LICENSE_TYPE_CODE == subPaymentDT.LICENSE_TYPE_CODE); String filePath = String.Format(@"{0}\{1}\{2}", zipFolder.FullName, SubPaymentHT.PETITION_TYPE_CODE, licenType.LICENSE_TYPE_NAME); DirectoryInfo dirInfo = new DirectoryInfo(Path.Combine(_netDrive, filePath)); if (!dirInfo.Exists) { dirInfo.Create(); } FileInfo fileInfo = new FileInfo(Path.Combine(dirInfo.FullName, "1.txt")); if (!fileInfo.Exists) { using (System.IO.StreamWriter file = fileInfo.CreateText()) { file.WriteLine("ชื่อรูป,เลขที่ใบอนุญาต,เลขบัตรประชาชน,ชื่อ,สกุล,วันที่ออกใบอนุญาต,วันที่หมดอายุ,บริษัท,ประเภทใบอนุญาต,"); } } using (System.IO.StreamWriter file = fileInfo.AppendText()) { file.WriteLine(String.Format("{0},{1},{2},{3},{4},{5},{6},{7},{8},", subPaymentDT.ID_CARD_NO, WordSpacing(subPaymentDT.LICENSE_NO), WordSpacing(subPaymentDT.ID_CARD_NO), String.Format("{0} {1}", licenD.TITLE_NAME, licenD.NAMES), licenD.LASTNAME, ((DateTime)licenD.LICENSE_DATE).ToString("dd/MM/yyy", CultureInfo.CreateSpecificCulture("th-TH")), ((DateTime)licenD.LICENSE_EXPIRE_DATE).ToString("dd/MM/yyy", CultureInfo.CreateSpecificCulture("th-TH")), licenH.COMP_NAME, licenType.LICENSE_TYPE_NAME)); } } } } }