public virtual ActionResult Download(string filePath) { string extension = System.IO.Path.GetExtension(filePath); ZFileTypes fileType = LibraryHelper.GetFileType(extension); return(File(filePath, LibraryHelper.GetContentType(fileType), Path.GetFileName(filePath))); }
public byte[] ReadFile(string entityName, int key, ZFileTypes fileType) { byte[] file = new byte[0]; string path = GetFilePath(entityName, key, fileType, false); if (FTPFileExists(path)) { ftpClient.SetWorkingDirectory("/"); using (var ftpStream = ftpClient.OpenRead(path)) using (var memoryStream = new MemoryStream((int)ftpStream.Length)) { int count; byte[] buffer = new byte[8 * 1024]; while ((count = ftpStream.Read(buffer, 0, buffer.Length)) > 0) { memoryStream.Write(buffer, 0, count); } file = memoryStream.ToArray(); } } return(file); }
public ActionResult Read(string entityName, int id, string acronym) { ZFileTypes fileType = LibraryHelper.GetFileType(acronym); byte[] file = EDMManager.ReadFile(entityName, id, fileType); string extension = LibraryHelper.GetFileExtension(fileType); return(File(file, LibraryHelper.GetContentType(fileType), entityName + "-" + id.ToString().Trim() + extension)); }
public ActionResult Read(string entityName, int id, string acronym) { IEdmManager edmManager = DependencyResolver.Current.GetService <IEdmManager>(); ZFileTypes fileType = LibraryHelper.GetFileType(acronym); byte[] file = edmManager.ReadFile(entityName, id, fileType); string extension = LibraryHelper.GetFileExtension(fileType); return(File(file, LibraryHelper.GetContentType(fileType), entityName + "-" + id.ToString().Trim() + extension)); }
public byte[] ReadFile(string entityName, int key, ZFileTypes fileType) { byte[] file = new byte[0]; if (FileExists(entityName, key, fileType)) { file = File.ReadAllBytes(GetFilePath(entityName, key, fileType, false)); } return(file); }
public bool WriteFile(string entityName, int key, ZFileTypes fileType, string filePath) { bool result = false; if (File.Exists(filePath)) { result = WriteFile(entityName, key, fileType, File.ReadAllBytes(filePath)); } return(result); }
public string GetFilePath(string entityName, int key, ZFileTypes fileType, bool create) { string filePath = ""; string extension = LibraryHelper.GetFileExtension(fileType); string workingDirectory = ""; try { workingDirectory = ftpClient.GetWorkingDirectory(); entityName = (entityName == null) ? "" : entityName; string entityKey = String.Format("{0:000000000}", (key / 100) * 100); string directoryPath = LibraryHelper.AddDirectorySeparator(RootDirectory) + ((entityName == "") ? entityName : entityName + "/") + entityKey; FTPCreateDirectoryPath(directoryPath); /* * ftpClient.SetWorkingDirectory("/"); * if (!FTPDirectoryExists(path) && create) // /root/entityName/entityTree * { * if (FTPCreateDirectory(RootDirectory)) * { * ftpClient.SetWorkingDirectory(RootDirectory); * if (FTPCreateDirectory(entityName)) * { * ftpClient.SetWorkingDirectory(entityName); * FTPCreateDirectory(entityTree); * } * } * } */ ftpClient.SetWorkingDirectory("/"); if (FTPDirectoryExists(directoryPath)) { filePath = directoryPath + "/" + String.Format("{0:000000000}", key) + extension; } } finally { if (!String.IsNullOrEmpty(workingDirectory)) { ftpClient.SetWorkingDirectory(workingDirectory); } } return(filePath); }
public bool DeleteFile(string entityName, int key, ZFileTypes fileType) { bool result = false; string filePath = GetFilePath(entityName, key, fileType, false); if (File.Exists(filePath)) { File.Delete(filePath); result = true; } return(result); }
public bool WriteFile(string entityName, int key, ZFileTypes fileType, byte[] file) { bool result = false; ftpClient.SetWorkingDirectory("/"); using (var memoryStream = new MemoryStream(file)) using (var ftpStream = ftpClient.OpenWrite(GetFilePath(entityName, key, fileType, true))) { int count; byte[] buffer = new byte[8 * 1024]; while ((count = memoryStream.Read(buffer, 0, buffer.Length)) > 0) { ftpStream.Write(buffer, 0, count); } } result = true; return(result); }
public string GetFilePath(string entityName, int key, ZFileTypes fileType, bool create) { string filePath = ""; string extension = LibraryHelper.GetFileExtension(fileType); entityName = (entityName == null) ? "" : entityName; string entityKey = String.Format("{0:000000000}", (key / 100) * 100); string directoryPath = LibraryHelper.AddDirectorySeparator(RootDirectory) + ((entityName == "") ? entityName : entityName + "/") + entityKey; if (!Directory.Exists(directoryPath) && create) { Directory.CreateDirectory(directoryPath); } if (Directory.Exists(directoryPath)) { filePath = directoryPath + "/" + String.Format("{0:000000000}", key) + extension; } return(filePath); }
public ActionResult Delete(CustomerDocumentItemModel customerDocumentItemModel) // !!! { try { int customerDocumentId = customerDocumentItemModel.CustomerDocument.CustomerDocumentId; ZFileTypes fileType = LibraryHelper.GetFileType(customerDocumentItemModel.CustomerDocument.FileAcronym); if (Application.Delete(customerDocumentItemModel.OperationResult, (CustomerDocumentDTO)customerDocumentItemModel.CustomerDocument.ToDTO())) { IEdmManager edmManager = DependencyResolver.Current.GetService <IEdmManager>(); edmManager.DeleteFile("CustomerDocument", customerDocumentId, fileType); return(RedirectToUrlDictionary()); } } catch (Exception exception) { customerDocumentItemModel.OperationResult.ParseException(exception); } customerDocumentItemModel.IsSecurityOperations = IsSecurityOperations; return(View(customerDocumentItemModel)); }
public ActionResult Create(CustomerDocumentItemModel customerDocumentItemModel) // !!! { try { if (ValidateModelState(Application.Repository)) { if (customerDocumentItemModel.Upload != null && customerDocumentItemModel.Upload.ContentLength > 0) { ZFileTypes fileType = LibraryHelper.GetFileType(Path.GetExtension(customerDocumentItemModel.Upload.FileName)); string acronym = LibraryHelper.GetAcronym(fileType); customerDocumentItemModel.CustomerDocument.FileAcronym = acronym; CustomerDocumentDTO customerDocumentDTO = (CustomerDocumentDTO)customerDocumentItemModel.CustomerDocument.ToDTO(); if (Application.Create(customerDocumentItemModel.OperationResult, customerDocumentDTO)) { byte[] uploadArray = new byte[customerDocumentItemModel.Upload.ContentLength]; customerDocumentItemModel.Upload.InputStream.Read(uploadArray, 0, uploadArray.Length); IEdmManager edmManager = DependencyResolver.Current.GetService <IEdmManager>(); edmManager.WriteFile("CustomerDocument", customerDocumentDTO.CustomerDocumentId, fileType, uploadArray); return(RedirectToUrlDictionary()); } } } } catch (Exception exception) { customerDocumentItemModel.OperationResult.ParseException(exception); } customerDocumentItemModel.IsSecurityOperations = IsSecurityOperations; return(View(customerDocumentItemModel)); }
public byte[] ReadFile(int key, ZFileTypes fileType) { return(ReadFile("", key, fileType)); }
public string GetFilePath(int key, ZFileTypes fileType, bool create) { return(GetFilePath("", key, fileType, create)); }
public bool FileExists(int key, ZFileTypes fileType) { return(true); }
public bool DeleteFile(int key, ZFileTypes fileType) { return(DeleteFile("", key, fileType)); }
public bool WriteFile(string entityName, int key, ZFileTypes fileType, byte[] file) { File.WriteAllBytes(GetFilePath(entityName, key, fileType, true), file); return(true); }
public bool WriteFile(string entityName, int key, ZFileTypes fileType, byte[] file) { return(true); }
public bool WriteFile(int key, ZFileTypes fileType, byte[] file) { return(true); }
public byte[] ReadFile(string entityName, int key, ZFileTypes fileType) { return(new byte[0] { }); }
public byte[] ReadFile(int key, ZFileTypes fileType) { return(new byte[0] { }); }
public string GetFilePath(string entityName, int key, ZFileTypes fileType, bool create) { return(""); }
public bool FileExists(string entityName, int key, ZFileTypes fileType) { return(true); }
public bool WriteFile(int key, ZFileTypes fileType, byte[] file) { return(WriteFile("", key, fileType, file)); }
public bool WriteFile(int key, ZFileTypes fileType, string filePath) { return(WriteFile("", key, fileType, filePath)); }
public bool WriteFile(string entityName, int key, ZFileTypes fileType, string filePath) { return(true); }
public bool FileExists(int key, ZFileTypes fileType) { return(FileExists("", key, fileType)); }
public bool FileExists(string entityName, int key, ZFileTypes fileType) { return(File.Exists(GetFilePath(entityName, key, fileType, false))); }
public bool WriteFile(int key, ZFileTypes fileType, string filePath) { return(true); }
public bool DeleteFile(string entityName, int key, ZFileTypes fileType) { return(true); }