Exemplo n.º 1
0
        public static void UploadAttachments(string DocPath, string FileName)
        {
            FileUploadResponse fileUploadResponse = null;

            if (!string.IsNullOrEmpty(DocPath))
            {
                var downFileResponse = DownloadFileAttachment(DocPath, FileName);
                if (downFileResponse != null && downFileResponse.FileBytes.IsValid())
                {
                    if (downFileResponse.FileBytes.Length > 0)
                    {
                        using (var stream = new MemoryStream(downFileResponse.FileBytes))
                        {
                            fileUploadResponse = UploadToFileSystem(FileName, stream);
                        }
                    }
                    if (fileUploadResponse.IsValid() && fileUploadResponse.IsSuccess)
                    {
                        var Attchment = MapDownloadAttachment(fileUploadResponse);
                        DBUtil.Instance.UpdateAttachmentData(Attchment);
                    }
                }
                else
                {
                    throw new System.Exception("File Upload : " + FileName + " has no data");
                }
            }
            else
            {
                throw new System.Exception("LetterStream is missing");
            }
        }