Esempio n. 1
0
        public FileTransferResponse Put(FileTransferRequest fileToPush)
        {
            FileTransferResponse fileTransferResponse = this.CheckFileTransferRequest(fileToPush);

            if (fileTransferResponse.ResponseStatus == "FileIsValed")
            {
                try
                {
                    this.SaveFileStream(System.AppDomain.CurrentDomain.BaseDirectory + "\\Uploads\\PreArrivalAttachments\\" + fileToPush.FileName, new MemoryStream(fileToPush.Content));
                    return(new FileTransferResponse
                    {
                        CreateAt = DateTime.Now,
                        FileName = fileToPush.FileName,
                        Message = "File was transfered",
                        ResponseStatus = "Successful"
                    });
                }
                catch (Exception ex)
                {
                    return(new FileTransferResponse
                    {
                        CreateAt = DateTime.Now,
                        FileName = fileToPush.FileName,
                        Message = ex.Message,
                        ResponseStatus = "Error"
                    });
                }
            }

            return(fileTransferResponse);
        }
Esempio n. 2
0
        private FileTransferResponse CheckFileTransferRequest(FileTransferRequest fileToPush)
        {
            if (fileToPush != null)
            {
                if (!string.IsNullOrEmpty(fileToPush.FileName))
                {
                    if (fileToPush.Content != null)
                    {
                        return(new FileTransferResponse
                        {
                            CreateAt = DateTime.Now,
                            FileName = fileToPush.FileName,
                            Message = string.Empty,
                            ResponseStatus = "FileIsValed"
                        });
                    }

                    return(new FileTransferResponse
                    {
                        CreateAt = DateTime.Now,
                        FileName = "No Name",
                        Message = " File Content is null",
                        ResponseStatus = "Error"
                    });
                }

                return(new FileTransferResponse
                {
                    CreateAt = DateTime.Now,
                    FileName = "No Name",
                    Message = " File Name Can't be Null",
                    ResponseStatus = "Error"
                });
            }

            return(new FileTransferResponse
            {
                CreateAt = DateTime.Now,
                FileName = "No Name",
                Message = " File Can't be Null",
                ResponseStatus = "Error"
            });
        }