Esempio n. 1
0
        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);
            }
        }
Esempio n. 2
0
        //#region Member Variable

        //private NASDrive nasDrive;
        //string netDrive = ConfigurationManager.AppSettings["DEFAULT_NET_DRIVE"];
        //string userNetDrive = ConfigurationManager.AppSettings["USER_NET_DRIVE"];
        //string passNetDrive = ConfigurationManager.AppSettings["PASS_NET_DRIVE"];

        //#endregion

        //#region Member Method

        //public void Dispose()
        //{
        //    if (nasDrive != null)
        //    {
        //        nasDrive.Dispose();
        //        nasDrive = null;
        //    }
        //}
        //private void ConnectNetDrive()
        //{
        //    this.nasDrive = new NASDrive(netDrive, userNetDrive, passNetDrive);
        //}

        //private void DisConnectNetDrive()
        //{
        //    if (this.nasDrive != null)
        //    {
        //        this.nasDrive.Dispose();
        //    }
        //}

        //private string GetContentType(string fileExtension)
        //{
        //    if (string.IsNullOrEmpty(fileExtension))
        //        return string.Empty;

        //    string contentType = string.Empty;
        //    switch (fileExtension)
        //    {
        //        case ".htm":
        //        case ".html":
        //            contentType = "text/HTML";
        //            break;

        //        case ".txt":
        //            contentType = "text/plain";
        //            break;

        //        case ".doc":
        //        case ".rtf":
        //        case ".docx":
        //            contentType = "Application/msword";
        //            break;

        //        case ".xls":
        //        case ".xlsx":
        //            contentType = "Application/x-msexcel";
        //            break;

        //        case ".jpg":
        //        case ".jpeg":
        //            contentType = "image/jpeg";
        //            break;

        //        case ".gif":
        //            contentType = "image/GIF";
        //            break;

        //        case ".pdf":
        //            contentType = "application/pdf";
        //            break;
        //    }

        //    return contentType;
        //}

        //#endregion


        /// <summary>
        /// Upload File
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public UploadFileResponse UploadFile(UploadFileRequest request)
        {
            UploadFileResponse response = new UploadFileResponse();

            try
            {
                response = FileManagerService.RemoteFileCommand(request).Action();
            }
            catch (Exception e)
            {
                response.Message = e.Message;
            }

            return(response);
        }
Esempio n. 3
0
        public ContainDetailResponse ContainDetail(ContainDetailRequest request)
        {
            ContainDetailResponse response = new ContainDetailResponse();

            try
            {
                response = FileManagerService.RemoteFileCommand(request).Action();
            }
            catch (Exception ex)
            {
                response.Code    = "0001";
                response.Message = ex.Message;
            }
            return(response);
        }
Esempio n. 4
0
        public DeleteContainerResponse DeleteContainer(DeleteContainerRequest request)
        {
            DeleteContainerResponse response = new DeleteContainerResponse();

            try
            {
                response = FileManagerService.RemoteFileCommand(request).Action();
            }
            catch (Exception ex)
            {
                response.Code    = "0001";
                response.Message = ex.Message;
            }
            return(response);
        }
Esempio n. 5
0
        public AmendFileResponse AmendFile(AmendFileRequest request)
        {
            AmendFileResponse response = new AmendFileResponse();

            try
            {
                response = FileManagerService.RemoteFileCommand(request).Action();
            }
            catch (Exception ex)
            {
                response.Code    = "0001";
                response.Message = ex.Message;
            }
            return(response);
        }