コード例 #1
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));
        }
コード例 #2
0
ファイル: EDM.cs プロジェクト: anthrax3/EasyLOB-Tools-2
        private static void LibraryEdmDemo(IEdmManager edmManager)
        {
            Console.WriteLine("\nEDM Demo\n");

            string rootDirectory = ConfigurationHelper.AppSettings <string>("EDM.FileSystemDirectory");

            Console.WriteLine("IMPORTANT: Create \"" + rootDirectory + "\" directory !");
            Console.Write("\nPress <KEY> to continue... ");
            Console.ReadKey();
            Console.WriteLine("\n");

            string txtFilePath = LibraryHelper.AddDirectorySeparator(rootDirectory) + "txt.txt";

            using (StreamWriter writer = new StreamWriter(txtFilePath))
            {
                writer.Write("EasyLOB");
            }

            byte[]     file;
            int        key;
            string     entityName = "Entity", exportPath;
            ZFileTypes fileType;

            // 1
            Console.WriteLine("1");

            key        = 1;
            fileType   = ZFileTypes.ftTXT;
            exportPath = LibraryHelper.AddDirectorySeparator(rootDirectory) + "txt.1.txt";

            Console.WriteLine("  Write TXT");
            edmManager.WriteFile(entityName, key, fileType, txtFilePath);
            Console.WriteLine("  Read TXT");
            file = edmManager.ReadFile(entityName, key, fileType);
            File.WriteAllBytes(exportPath, file);
            //Console.WriteLine("  Delete TXT");
            //edmManager.EdmEngine.DeleteFile(entityName, key, fileType);

            // 101
            Console.WriteLine("101");

            key        = 101;
            fileType   = ZFileTypes.ftTXT;
            exportPath = LibraryHelper.AddDirectorySeparator(rootDirectory) + "txt.101.txt";

            Console.WriteLine("  Write TXT");
            edmManager.WriteFile(entityName, key, fileType, txtFilePath);
            Console.WriteLine("  Read TXT");
            file = edmManager.ReadFile(entityName, key, fileType);
            File.WriteAllBytes(exportPath, file);
            //Console.WriteLine("  Delete TXT");
            //edmManager.edmEngine.DeleteFile(entityName, key, fileType);
        }
コード例 #3
0
ファイル: EDM.cs プロジェクト: EasyLOB/EasyLOB-Tools-1
        private static void LibraryEdmFilePathDemo(IEdmManager edmManager)
        {
            Console.WriteLine("\nEDM Demo\n");

            string rootDirectory = LibraryHelper.AppSettings <string>("EDM.FileSystemDirectory");

            Console.WriteLine("IMPORTANT: Create \"" + rootDirectory + "\" directory !");
            Console.Write("\nPress <KEY> to continue... ");
            Console.ReadKey();
            Console.WriteLine("\n");

            string txtFilePath = LibraryHelper.AddDirectorySeparator(rootDirectory) + "txt.txt";

            using (StreamWriter writer = new StreamWriter(txtFilePath))
            {
                writer.Write("EasyLOB");
            }

            byte[] file;
            string edmFilePath, exportPath;

            // 1
            Console.WriteLine("A/B/C");

            edmFilePath = "A/B/C/txt.txt";
            exportPath  = LibraryHelper.AddDirectorySeparator(rootDirectory) + "txt.1.txt";

            Console.WriteLine("  Write TXT");
            edmManager.WriteFile(edmFilePath, txtFilePath);
            Console.WriteLine("  Read TXT");
            file = edmManager.ReadFile(edmFilePath);
            File.WriteAllBytes(exportPath, file);
            //Console.WriteLine("  Delete TXT");
            //edmManager.EdmEngine.DeleteFile(edmFilePath);

            // 101
            Console.WriteLine("101");

            edmFilePath = "A/D/E/txt.txt";
            exportPath  = LibraryHelper.AddDirectorySeparator(rootDirectory) + "txt.101.txt";

            Console.WriteLine("  Write TXT");
            edmManager.WriteFile(edmFilePath, txtFilePath);
            Console.WriteLine("  Read TXT");
            file = edmManager.ReadFile(edmFilePath);
            File.WriteAllBytes(exportPath, file);
            //Console.WriteLine("  Delete TXT");
            //edmManager.EdmEngine.DeleteFile(edmFilePath);
        }
コード例 #4
0
        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));
        }
コード例 #5
0
        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));
        }
コード例 #6
0
 public EDMController(IEdmManager edmManager)
 {
     EDMManager = edmManager;
 }