Beispiel #1
0
        public static void Main()
        {
            try
            {
                IConfigurationProvider configurationProvider = new ConfigFileConfigurationProvider();

                long numberOfFileToUpdate = 0;
                long numberOfFileUpdated  = 0;

                CopyReportStrategy copyReportStrategy = new CopyReportStrategy();
                copyReportStrategy.OnFileProcessed += (sender, args) => numberOfFileToUpdate++;

                FileCopyStrategy fileCopyStrategy = new FileCopyStrategy();
                fileCopyStrategy.OnFileProcessed += (sender, args) =>
                {
                    numberOfFileUpdated++;
                    Console.WriteLine(
                        $"[{numberOfFileUpdated} / {numberOfFileToUpdate}] ({(numberOfFileUpdated / (double)numberOfFileToUpdate):P})");
                };

                FileProcessingStrategyBase[] strategies = { copyReportStrategy, fileCopyStrategy };

                FileSystemProcessor fileSystemProcessor = new FileSystemProcessor(configurationProvider, strategies);
                fileSystemProcessor.Run();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

            Console.ReadLine();
        }
        private void add_upload_controls(PlaceHolder placeHolder, Custom_Tracer Tracer)
        {
            Tracer.Add_Trace("New_Group_And_Item_MySobekViewer.add_upload_controls", String.Empty);

            StringBuilder filesBuilder = new StringBuilder(2000);

            filesBuilder.AppendLine("<script src=\"" + currentMode.Base_URL + "default/scripts/sobekcm_metadata.js\" type=\"text/javascript\"></script>");
            filesBuilder.AppendLine("Add a new file for this package:");
            filesBuilder.AppendLine("<blockquote>");

            LiteralControl filesLiteral2 = new LiteralControl(filesBuilder.ToString());

            placeHolder.Controls.Add(filesLiteral2);
            filesBuilder.Remove(0, filesBuilder.Length);

            DJUploadController1 = new DJUploadController
            {
                CSSPath    = currentMode.Base_URL + "default/scripts/upload_styles",
                ImagePath  = currentMode.Base_URL + "default/scripts/upload_images",
                ScriptPath = currentMode.Base_URL + "default/scripts/upload_scripts"
            };
            placeHolder.Controls.Add(DJUploadController1);

            DJAccessibleProgrssBar1 = new DJAccessibleProgressBar();
            placeHolder.Controls.Add(DJAccessibleProgrssBar1);

            DJFileUpload1 = new DJFileUpload {
                ShowAddButton = false, ShowUploadButton = true, MaxFileUploads = 1
            };
            placeHolder.Controls.Add(DJFileUpload1);

            // Set the default processor
            FileSystemProcessor fs = new FileSystemProcessor {
                OutputPath = digitalResourceDirectory
            };

            DJUploadController1.DefaultFileProcessor = fs;

            // Change the file processor and set it's properties.
            FieldTestProcessor fsd = new FieldTestProcessor {
                OutputPath = digitalResourceDirectory
            };

            DJFileUpload1.FileProcessor = fsd;

            filesBuilder.AppendLine("</blockquote><br />");

            LiteralControl literal1 = new LiteralControl(filesBuilder.ToString());

            placeHolder.Controls.Add(literal1);
        }
Beispiel #3
0
        public FileSystemProvider(string rootPath, IFileSystemProcessor fileSystemProcessor)
        {
            FileSystemProcessor = fileSystemProcessor ?? throw new ArgumentNullException(nameof(fileSystemProcessor));

            if (rootPath == null)
            {
                throw new ArgumentNullException(nameof(rootPath));
            }

            RootDirectory = new DirectoryInfo(rootPath);
            if (!FileSystemProcessor.Exists(RootDirectory))
            {
                throw new DirectoryNotFoundException();
            }

            if (!IsAccessAllowed(rootPath))
            {
                throw new UnauthorizedAccessException();
            }
        }