Beispiel #1
0
        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);
        }
Beispiel #2
0
        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);
        }
        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));
        }