Beispiel #1
0
        public DTO.PersonAttatchFile SaveEditAttachFileTemp(DTO.PersonAttatchFile attachFile, Stream fileSteam)
        {
            using (FileService.FileTransferServiceClient svc = new FileService.FileTransferServiceClient())
            {
                UploadFileResponse response     = new UploadFileResponse();
                String             fs_container = String.Format(@"{0}\{1}", TempFileContainer, attachFile.TempFilePath);

                String filename = String.Format("{0}.{1}", IAS.BLL.Helpers.GenerateIdHelper.GetGenAutoId(), attachFile.FileName.Split('.')[attachFile.FileName.Split('.').Length - 1]);
                response = svc.UploadFile(new UploadFileRequest()
                {
                    TargetContainer = fs_container,
                    TargetFileName  = filename,
                    FileStream      = fileSteam
                });

                if (response.Code != "0000")
                {
                    throw new IOException(response.Message);
                }

                attachFile.ATTACH_FILE_PATH = response.TargetFullName;
                attachFile.FILE_STATUS      = "W";
            }

            return(attachFile);
        }
Beispiel #2
0
        public UploadFileResponse UploadAttachFileToTemp(BLL.AttachFilesIAS.AttachFile attachFile, Stream fileStream)
        {
            String brokenRuleString = ThrowExceptionIfUploadInvalid(attachFile);

            if (!String.IsNullOrEmpty(brokenRuleString))
            {
                throw new ApplicationException(brokenRuleString);
            }
            UploadFileResponse response = new UploadFileResponse();

            using (FileService.FileTransferServiceClient svc = new FileService.FileTransferServiceClient())
            {
                String fs_container = String.Format(@"{0}\{1}", TempFileContainer, attachFile.REGISTRATION_ID);

                String filename = String.Format("{0}{1}", IAS.BLL.Helpers.GenerateIdHelper.GetGenAutoId(), attachFile.EXTENSION);

                UploadFileResponse res = svc.UploadFile(new UploadFileRequest()
                {
                    TargetContainer = fs_container,
                    TargetFileName  = filename,
                    FileStream      = fileStream
                });

                return(res);

                //if (response.Code != "0000")
                //    throw new IOException(response.Message);

                //attachFile.ATTACH_FILE_PATH = response.TargetFullName;
            }
            return(response);
        }
Beispiel #3
0
        //public DTO.PersonAttatchFile SaveToEditAttachFilePath(DTO.PersonAttatchFile newAttachFile, DTO.PersonAttatchFile oldAttachFile, Stream fileSteam)
        //{
        //    DTO.RegistrationAttatchFile _newAttachFile =  new DTO.RegistrationAttatchFile();
        //    DTO.RegistrationAttatchFile _oldAttachFile = new DTO.RegistrationAttatchFile();
        //    newAttachFile.MappingToEntity<DTO.RegistrationAttatchFile>(_newAttachFile);
        //    oldAttachFile.MappingToEntity<DTO.RegistrationAttatchFile>(_oldAttachFile);

        //    using (FileService.FileTransferServiceClient svc = new FileService.FileTransferServiceClient())
        //    {

        //        String findString = "_"+oldAttachFile.ATTACH_FILE_TYPE.ToInt().ToString("00");
        //        String newfileName = oldAttachFile.ATTACH_FILE_PATH.Replace(findString, findString + IAS.BLL.Helpers.GenerateIdHelper.GetGenAutoId());


        //        MoveFileResponse moveResponse = svc.MoveFile("", oldAttachFile.ATTACH_FILE_PATH, "", newfileName);
        //        if (moveResponse.Code != "0000")
        //            throw new IOException(moveResponse.Message);

        //        DeleteFileResponse deleteResponse = svc.DeleteFile(oldAttachFile.ATTACH_FILE_PATH);
        //        if (deleteResponse.Code != "0000")
        //            throw new IOException(deleteResponse.Message);

        //        UploadFileResponse uploadResponse = svc.UploadFile("", oldAttachFile.ATTACH_FILE_PATH, fileSteam);
        //        if (uploadResponse.Code != "0000")
        //            throw new IOException(uploadResponse.Message);



        //        _newAttachFile.ATTACH_FILE_PATH = uploadResponse.TargetFullName;

        //    }
        //    _newAttachFile.MappingToEntity<DTO.RegistrationAttatchFile, DTO.PersonAttatchFile>(newAttachFile);
        //    return newAttachFile;

        //}

        public DTO.RegistrationAttatchFile SaveToAttachFilePath(DTO.RegistrationAttatchFile attachFile, Stream fileSteam)
        {
            using (FileService.FileTransferServiceClient svc = new FileService.FileTransferServiceClient())
            {
                UploadFileResponse response     = new UploadFileResponse();
                String             fs_container = String.Format(@"{0}\{1}", AttachFileContainer, attachFile.TempFilePath);

                //String newFileName = this.ID_CARD_NO + "_"
                //                                    + Convert.ToInt32(attachFile.ATTACH_FILE_TYPE).ToString("00")
                //                                    + "." + GetExtensionFile(attachFile.FileName);

                response = svc.UploadFile(new UploadFileRequest()
                {
                    TargetContainer = fs_container,
                    TargetFileName  = attachFile.FileName,
                    FileStream      = fileSteam
                });
                if (response.Code != "0000")
                {
                    throw new IOException(response.Message);
                }

                attachFile.ATTACH_FILE_PATH = response.TargetFullName;
            }

            return(attachFile);
        }
Beispiel #4
0
 public void DeleteTempFile(String pathRemoteFile)
 {
     using (FileService.FileTransferServiceClient svc = new FileService.FileTransferServiceClient())
     {
         DeleteFileResponse response = svc.DeleteFile(new DeleteFileRequest()
         {
             TargetFileName = pathRemoteFile
         });
         if (response.Code != "0000")
         {
             throw new IOException(response.Message);
         }
     }
 }
Beispiel #5
0
        public DTO.ResponseService <DTO.RegistrationAttatchFile> DeleteAttatchFile(string Id)
        {
            DTO.ResponseService <DTO.RegistrationAttatchFile> res = svc.DeleteAttatchFile(Id);
            if (!res.IsError)
            {
                using (FileService.FileTransferServiceClient svcFile = new FileService.FileTransferServiceClient())
                {
                    //DTO.FileService.DeleteFileResponse resDelete = svcFile.DeleteFile(new DTO.FileService.DeleteFileRequest() { TargetFileName = res.DataResponse.ATTACH_FILE_PATH });
                    //if (resDelete.Code != "0000")
                    //    throw new ApplicationException(resDelete.Message);
                }
            }

            return(res);
        }
Beispiel #6
0
        private static String UploadFileApplicantToTemp(Stream rawData)
        {
            String filePath = "";
            using (FileService.FileTransferServiceClient serviceFile = new FileService.FileTransferServiceClient())
            {
                String container = Path.Combine("Applicant", DateTime.Now.ToString("yyyyMMdd"));
                String upfilename = String.Format("{0}.txt", DateTime.Now.ToString("yyyyMMddHHmmss"));
                DTO.FileService.UploadFileResponse resFile = serviceFile.UploadFile(new DTO.FileService.UploadFileRequest() { FileStream = rawData, TargetFileName = upfilename, TargetContainer = container });
                if (resFile.Code != "0000")
                {
                    throw new ApplicationException("ไม่สามารถ นำเข้าเอกสารได้");
                }

                filePath = resFile.TargetFullName;
            }
            return filePath;
        }
Beispiel #7
0
        public void DeleteAttachFileInTemp(String pathRemoteFile)
        {
            if (String.IsNullOrEmpty(pathRemoteFile))
            {
                throw new IOException(Resources.errorUploadDataBiz_001);
            }

            using (FileService.FileTransferServiceClient svc = new FileService.FileTransferServiceClient())
            {
                DeleteFileResponse response = svc.DeleteFile(new DeleteFileRequest()
                {
                    TargetFileName = pathRemoteFile
                });
                if (response.Code != "0000")
                {
                    throw new IOException(response.Message);
                }
            }
        }
Beispiel #8
0
        public virtual void GetFile(string pathRemoteFile, ref Stream fileStrem)
        {
            //DTO.RegistrationAttatchFile attachFile = new DTO.RegistrationAttatchFile();
            //if (_attachFiles.Where(a => a.ATTACH_FILE_TYPE == type).Count() <= 0)
            //    throw new RegisterationException("ไม่พบเอกสารแนบตามประเภทที่ต้องการ !!!");

            //attachFile = _attachFiles.Where(a => a.ATTACH_FILE_TYPE == type).FirstOrDefault();
            using (FileService.FileTransferServiceClient svc = new FileService.FileTransferServiceClient())
            {
                DownloadFileResponse response = svc.DownloadFile(new DownloadFileRequest()
                {
                    TargetContainer = "", TargetFileName = pathRemoteFile
                });
                if (response.Code != "0000")
                {
                    throw new IOException(response.Message);
                }

                fileStrem = response.FileByteStream;
            }
        }
Beispiel #9
0
        public DTO.RegistrationAttatchFile SaveAttachToTemp(DTO.RegistrationAttatchFile attachFile, Stream fileSteam)
        {
            using (FileService.FileTransferServiceClient svc = new FileService.FileTransferServiceClient())
            {
                UploadFileResponse response     = new UploadFileResponse();
                String             fs_container = String.Format(@"{0}\{1}", TempFileContainer, attachFile.TempFilePath);


                response = svc.UploadFile(new UploadFileRequest()
                {
                    TargetContainer = fs_container,
                    TargetFileName  = attachFile.FileName,
                    FileStream      = fileSteam
                });
                if (response.Code != "0000")
                {
                    throw new IOException(response.Message);
                }

                attachFile.ATTACH_FILE_PATH = response.TargetFullName;
            }

            return(attachFile);
        }
Beispiel #10
0
        UploadData(string pathFileName, DTO.UserProfile userProfile, string petitionTypeCode, string licenseTypeCode, Stream fileSteam, string replaceType, string approveCom)
        {
            var res = new DTO.ResponseService <DTO.SummaryReceiveLicense>();

            res.DataResponse = new DTO.SummaryReceiveLicense();
            UploadFileResponse response = new UploadFileResponse();

            try
            {
                //String attachFilePath = "";
                using (FileService.FileTransferServiceClient svcFile = new FileService.FileTransferServiceClient())
                {
                    String fileName  = String.Format(@"{0}.{1}", IAS.BLL.Helpers.GenerateIdHelper.GetGenAutoId(), pathFileName.Split('.')[pathFileName.Split('.').Length - 1]);;
                    String container = String.Format(@"{0}\{1}", TempFileContainer, IAS.BLL.Helpers.GenerateIdHelper.GetGenAutoId());

                    response = svcFile.UploadFile(new UploadFileRequest()
                    {
                        TargetContainer = container,
                        TargetFileName  = fileName,
                        FileStream      = fileSteam
                    });


                    if (response.Code != "0000")
                    {
                        res.ErrorMsg = response.Message;
                        return(res);
                    }
                    //FileService.UploadFileResponse resUpload = svcFile.UploadFile(new UploadFileRequest()
                    //{
                    //    TargetContainer = container,
                    //    TargetFileName = fileName,
                    //    FileStream = fileSteam
                    //});

                    //if (resUpload.Code != "0000")
                    //{
                    //    res.ErrorMsg = resUpload.Message;
                    //    return res;
                    //}
                    //pathFileName = resUpload.TargetFullName;
                    pathFileName = response.TargetFullName;
                }

                DTO.DataLicenseRequest request = new DTO.DataLicenseRequest()
                {
                    FileName          = pathFileName,
                    LicenseTypeCode   = licenseTypeCode,
                    PettitionTypeCode = petitionTypeCode,
                    UserProfile       = userProfile,
                    ReplaceType       = replaceType,
                    ApproveCom        = approveCom
                };


                res = svc.UploadDataLicense(request);
            }
            catch (IOException ioEx)
            {
                res.ErrorMsg = Resources.errorLicenseBiz_001;
            }
            catch (Exception ex)
            {
                res.ErrorMsg = Resources.errorLicenseBiz_001;
            }
            return(res);
        }
Beispiel #11
0
 public FileBiz()
 {
     this.svc = new FileService.FileTransferServiceClient();
 }