示例#1
0
        UploadTo(Stream fileUploadStream, string localFileName, string targetFolder, string targetFileName, string fsFolder)
        {
            var res = new DTO.ResponseService <string>();
            //var resMsg = new FileService.FileUploadMessage();
            UploadFileResponse response = new UploadFileResponse();

            try
            {
                //resMsg.FileByteStream = fileUploadStream;
                //resMsg.Metadata = new FileService.FileMetaData
                //{
                //    localFilename = localFileName,
                //    remoteFilename = targetFileName,
                //    targetFolder = string.Format(fsFolder + @"\{0}\", targetFolder),
                //};

                response = svc.UploadFile(new UploadFileRequest()
                {
                    TargetContainer = String.Format(fsFolder + @"\{0}\", targetFolder),
                    TargetFileName  = targetFileName,
                    FileStream      = fileUploadStream
                });
                //svc.UploadFile(ref resMsg.Metadata, ref fileUploadStream);

                res.DataResponse = response.Message; // resMsg.Metadata.resMsg;
            }
            catch (Exception ex)
            {
                res.ErrorMsg = "กรุณาติดต่อผู้ดูแลระบบ"; // +resMsg.Metadata.resMsg;
            }
            return(res);
        }
示例#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);
        }
示例#3
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);
        }
示例#4
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);
        }
示例#5
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;
        }
示例#6
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);
        }
示例#7
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);
        }