예제 #1
0
        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);
        }
예제 #2
0
        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);
        }
예제 #3
0
        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);
        }