예제 #1
0
        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)));
        }
예제 #2
0
        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);
        }
예제 #3
0
        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));
        }
예제 #4
0
        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));
        }
예제 #5
0
        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);
        }
예제 #6
0
        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);
        }
예제 #7
0
        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);
        }
예제 #8
0
        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);
        }
예제 #9
0
        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);
        }
예제 #10
0
        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));
        }
예제 #13
0
 public byte[] ReadFile(int key, ZFileTypes fileType)
 {
     return(ReadFile("", key, fileType));
 }
예제 #14
0
 public string GetFilePath(int key, ZFileTypes fileType, bool create)
 {
     return(GetFilePath("", key, fileType, create));
 }
예제 #15
0
 public bool FileExists(int key, ZFileTypes fileType)
 {
     return(true);
 }
예제 #16
0
 public bool DeleteFile(int key, ZFileTypes fileType)
 {
     return(DeleteFile("", key, fileType));
 }
예제 #17
0
        public bool WriteFile(string entityName, int key, ZFileTypes fileType, byte[] file)
        {
            File.WriteAllBytes(GetFilePath(entityName, key, fileType, true), file);

            return(true);
        }
예제 #18
0
 public bool WriteFile(string entityName, int key, ZFileTypes fileType, byte[] file)
 {
     return(true);
 }
예제 #19
0
 public bool WriteFile(int key, ZFileTypes fileType, byte[] file)
 {
     return(true);
 }
예제 #20
0
 public byte[] ReadFile(string entityName, int key, ZFileTypes fileType)
 {
     return(new byte[0] {
     });
 }
예제 #21
0
 public byte[] ReadFile(int key, ZFileTypes fileType)
 {
     return(new byte[0] {
     });
 }
예제 #22
0
 public string GetFilePath(string entityName, int key, ZFileTypes fileType, bool create)
 {
     return("");
 }
예제 #23
0
 public bool FileExists(string entityName, int key, ZFileTypes fileType)
 {
     return(true);
 }
예제 #24
0
 public bool WriteFile(int key, ZFileTypes fileType, byte[] file)
 {
     return(WriteFile("", key, fileType, file));
 }
예제 #25
0
 public bool WriteFile(int key, ZFileTypes fileType, string filePath)
 {
     return(WriteFile("", key, fileType, filePath));
 }
예제 #26
0
 public bool WriteFile(string entityName, int key, ZFileTypes fileType, string filePath)
 {
     return(true);
 }
예제 #27
0
 public bool FileExists(int key, ZFileTypes fileType)
 {
     return(FileExists("", key, fileType));
 }
예제 #28
0
 public bool FileExists(string entityName, int key, ZFileTypes fileType)
 {
     return(File.Exists(GetFilePath(entityName, key, fileType, false)));
 }
예제 #29
0
 public bool WriteFile(int key, ZFileTypes fileType, string filePath)
 {
     return(true);
 }
예제 #30
0
 public bool DeleteFile(string entityName, int key, ZFileTypes fileType)
 {
     return(true);
 }