Esempio n. 1
0
        // Utility

        #region public static void ProcessDirectory(string _SystemFiles, string targetDirectory, ref DTONode paramDTONode)
        // Process all files in the directory passed in, recurse on any directories
        // that are found, and process the files they contain.
        public static void ProcessDirectory(string _SystemFiles, string targetDirectory, ref DTONode paramDTONode)
        {
            // Process the list of files found in the directory.
            string[] fileEntries = Directory.GetFiles(targetDirectory);
            foreach (string fileName in fileEntries)
            {
                ProcessFile(_SystemFiles, fileName, ref paramDTONode);
            }

            // Recurse into subdirectories of this directory.
            string[] subdirectoryEntries = Directory.GetDirectories(targetDirectory);
            foreach (string subdirectory in subdirectoryEntries)
            {
                string WebRootPath = _SystemFiles + @"\";

                // The directory label should only contain the name of the directory
                string subdirectoryLabel = FixDirectoryName(_SystemFiles, subdirectory);

                DTONode objDTONode = new DTONode();
                objDTONode.label         = subdirectoryLabel;
                objDTONode.data          = subdirectory.Replace(WebRootPath, "");
                objDTONode.expandedIcon  = "fa fa-fw fa fa-folder-open";
                objDTONode.collapsedIcon = "fa fa-fw fa fa-folder";
                objDTONode.children      = new List <DTONode>();
                objDTONode.type          = "folder";

                paramDTONode.children.Add(objDTONode);

                ProcessDirectory(_SystemFiles, subdirectory, ref objDTONode);
            }
        }
Esempio n. 2
0
        public static DTOResponse GetFileContentMethod(DTONode paramDTONode, string _SystemFiles)
        {
            DTOResponse objDTOResponse = new DTOResponse();

            try
            {
                // Construct path
                string FullPath = Path.Combine(_SystemFiles, paramDTONode.data).Replace(@"\", @"/");

                // Get file
                if (System.IO.File.Exists(FullPath))
                {
                    objDTOResponse.isSuccess = true;
                    objDTOResponse.message   = System.IO.File.ReadAllText(FullPath);
                }
            }
            catch (Exception ex)
            {
                objDTOResponse.isSuccess = false;
                objDTOResponse.message   = ex.Message;
                return(objDTOResponse);
            }

            return(objDTOResponse);
        }
Esempio n. 3
0
        public DTOResponse ReturnContent([FromBody] DTONode paramDTONode)
        {
            DTOResponse objDTOResponse = new DTOResponse();

            // Must be a Super User to proceed
            if (!UtilitySecurity.IsSuperUser(this.User.Identity.Name, GetConnectionString()))
            {
                objDTOResponse.isSuccess = false;
                objDTOResponse.message   = "Must be a Super User to proceed";
                return(objDTOResponse);
            }

            return(GetFileContentMethod(paramDTONode, _SystemFiles));
        }
Esempio n. 4
0
        // Insert logic for processing found files here.
        public static void ProcessFile(string _SystemFiles, string path, ref DTONode paramDTONode)
        {
            string WebRootPath = _SystemFiles + @"\";
            string FileName    = Path.GetFileName(path);
            string FilePath    = path;

            DTONode objDTONode = new DTONode();

            objDTONode.label         = FileName;
            objDTONode.data          = FilePath.Replace(WebRootPath, "");
            objDTONode.expandedIcon  = "fas fa-file";
            objDTONode.collapsedIcon = "fas fa-file";
            objDTONode.type          = "file";

            paramDTONode.children.Add(objDTONode);
        }
Esempio n. 5
0
        // Methods

        #region public static DTONode SystemFilesMethod(IHostingEnvironment _hostEnvironment, string _SystemFiles)
        public static DTONode SystemFilesMethod(IWebHostEnvironment _hostEnvironment, string _SystemFiles)
        {
            // Create Root Node
            DTONode objDTONode = new DTONode();

            if (Directory.Exists(_hostEnvironment.WebRootPath))
            {
                objDTONode.label         = "Root";
                objDTONode.data          = "Root";
                objDTONode.expandedIcon  = "fa fa-fw fa fa-folder-open";
                objDTONode.collapsedIcon = "fa fa-fw fa fa-folder";
                objDTONode.children      = new List <DTONode>();

                // Get Files
                ProcessDirectory(_SystemFiles, _SystemFiles, ref objDTONode);
            }

            return(objDTONode);
        }
Esempio n. 6
0
 public DTOResponse GetSystemFile([FromBody] DTONode paramDTONode)
 {
     return(FilesController.GetFileContentMethod(paramDTONode, _SystemFiles));
 }