Example #1
0
 public virtual StorageReturnValue CheckFolderAndCreate(string folderName)
 {
     result = new StorageReturnValue(false, FileStorageProperties.GetInstance.WrongInitialManagement, null);
     if (client.FtpCreateDirectory(folderName))
     {
         result = result.SetStorageReturnValue(true, string.Empty, null);
     }
     else
     {
         result = result.SetStorageReturnValue(false, string.Empty, null);
     }
     return(result);
 }
Example #2
0
 public StorageReturnValue IsFileExtAllowed(List <FileStorageAttachment> fileAttachments)
 {
     result = new StorageReturnValue(false, FileStorageProperties.GetInstance.WrongInitialManagement, null);
     if (fileAttachments != null)
     {
         string[] fileExtAllowed = FileStorageProperties.GetInstance.FileExtAllowed;
         if (fileExtAllowed.Contains("*")) // if found * , all files ok
         {
             result.SetStorageReturnValue(true, string.Empty, null);
         }
         else
         {
             if (fileAttachments.Where(a => a.FileNameWithExt.Contains(".") == false).Count() > 0) // filename must have dot (.)
             {
                 result.SetStorageReturnValue(false, FileStorageProperties.GetInstance.WrongFileExt, null);
             }
             else
             {
                 foreach (var item in fileAttachments)
                 {
                     string[] fileNameArray = item.FileNameWithExt.Split(".");
                     if (fileNameArray.Length > 0)
                     {
                         string fileExt = fileNameArray[(fileNameArray.Length) - 1].Trim().Replace(".", "");
                         if (fileExtAllowed.Contains(fileExt))
                         {
                             result.SetStorageReturnValue(true, string.Empty, null);
                         }
                         else
                         {
                             result.SetStorageReturnValue(false, FileStorageProperties.GetInstance.WrongFileExt, null);
                         }
                     }
                 }
             }
         }
     }
     return(result);
 }
Example #3
0
 public virtual StorageReturnValue CheckFolderExist(string pathFolderName)
 {
     result = new StorageReturnValue(false, FileStorageProperties.GetInstance.WrongInitialManagement, null);
     if (!string.IsNullOrEmpty(pathFolderName))
     {
         if (FileStorageProperties.GetInstance.FileStorageType == StorageType.LocalNetwork)
         {
             if (!string.IsNullOrEmpty(localNetwork))
             {
                 string checkFolderAddress = Path.Combine(localNetwork, pathFolderName);
                 if (Directory.Exists(checkFolderAddress))
                 {
                     result = result.SetStorageReturnValue(true, string.Empty, null);
                 }
                 else
                 {
                     result = result.SetStorageReturnValue(false, FileStorageProperties.GetInstance.WrongFolderManagement, null);
                 }
             }
         }
     }
     return(result);
 }
Example #4
0
 public StorageReturnValue IsFileSizeLimitationOK(List <FileStorageAttachment> fileAttachments)
 {
     result = new StorageReturnValue(false, FileStorageProperties.GetInstance.WrongInitialManagement, null);
     if (fileAttachments != null)
     {
         int fileLimit = FileStorageProperties.GetInstance.FileUploadMaxSize;
         int totLimit  = 0;
         foreach (var item in fileAttachments)
         {
             totLimit += item.FileAttachment.Length;
         }
         if (totLimit < fileLimit)
         {
             result = result.SetStorageReturnValue(true, string.Empty, null);
         }
         else
         {
             result = result.SetStorageReturnValue(false, FileStorageProperties.GetInstance.WrongAttachment + " Max Size : "
                                                   + FileStorageProperties.GetInstance.FileUploadMaxSize.ToString(), null);
         }
     }
     return(result);
 }
Example #5
0
        public virtual StorageReturnValue CheckFolderExist(string folderName)
        {
            result = new StorageReturnValue(false, FileStorageProperties.GetInstance.WrongInitialManagement, null);
            var checkDir = client.ListDirectory(folderName).Where(a => (string)a == folderName).ToList();

            if (checkDir.Count > 0)
            {
                result = result.SetStorageReturnValue(true, string.Empty, null);
            }
            else
            {
                result = result.SetStorageReturnValue(false, string.Empty, null);
            }
            return(result);
        }
Example #6
0
 public virtual StorageReturnValue CreateFolder(string pathFolderName)
 {
     result = new StorageReturnValue(false, FileStorageProperties.GetInstance.WrongInitialManagement, null);
     if (!string.IsNullOrEmpty(pathFolderName))
     {
         try
         {
             if (FileStorageProperties.GetInstance.FileStorageType == StorageType.LocalNetwork)
             {
                 string checkFolderAddress = Path.Combine(localNetwork, pathFolderName);
                 Directory.CreateDirectory(checkFolderAddress);
                 result = result.SetStorageReturnValue(true, string.Empty, null);
             }
         }
         catch (Exception ex) { result = result.SetStorageReturnValue(false, ex.Message.ToString(), null); }
     }
     return(result);
 }
Example #7
0
 public virtual StorageReturnValue CheckFolderAndCreate(string pathFolderName)
 {
     result = new StorageReturnValue(false, FileStorageProperties.GetInstance.WrongInitialManagement, null);
     if (!string.IsNullOrEmpty(pathFolderName))
     {
         try
         {
             string localPath     = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
             string localFileName = "DefaultSystemGenerated_" + DateTime.Now.ToString("yyyyMMddhhmmss") + ".txt";
             string PathFileName  = Path.Combine(pathFolderName, localFileName);
             var    sourceFile    = Path.Combine(localPath, localFileName);
             File.WriteAllText(sourceFile, FileStorageProperties.GetInstance.AzureGeneratedFile);
             var myblob = azure.AzureBlobContainer.GetBlockBlobReference(PathFileName);
             myblob.DeleteAsync().Wait();
             myblob.UploadFromFileAsync(sourceFile).Wait();
             FileNetwork.GetInstance.DeleteFile(sourceFile);
             result = result.SetStorageReturnValue(true, string.Empty, null);
         }
         catch (Exception ex) {
             result = result.SetStorageReturnValue(false, ex.Message, null);
         };
     }
     return(result);
 }