Ejemplo n.º 1
0
        public string DeleteFile(string directory)
        {
            Json      checkfile  = new Json();
            CheckPath check_path = new CheckPath();


            if (directory.Contains(" "))
            {
                response = "File Cannot Contain Spaces!";
            }
            else if (check_path.directoryexists(@"C:\COSMOS") == false || directory == "/" || directory == @"\")//check if destination exist
            {
                response = "Input Cannot be a Directory!";
            }
            else if (checkfile.checkfile(directory) == false || directory == "." || directory == @"\" || directory == "/")//check if file exists
            {
                response = "File Not found";
            }
            else
            {
                Process.Start("cmd", @"/c cd C:\hadoop-2.7.2\bin && hdfs dfs -rm /" + directory).WaitForExit();

                response = "File Deleted!";
            }



            return(response);
        }
Ejemplo n.º 2
0
        public string GetFile(string directory)
        {
            Json      checkfile  = new Json();
            CheckPath check_path = new CheckPath();

            DirectoryInfo dir = new DirectoryInfo(@"C:\COSMOS");


            ////If the File being downloaded exsits.. Delete the file//////
            if (System.IO.File.Exists(@"C:\COSMOS\" + directory))
            {
                System.IO.File.Delete(@"C:\COSMOS\" + directory);
            }



            if (directory.Contains(" "))
            {
                response = "File Directory Contains Space!";
            }
            else if (check_path.directoryexists(@"C:\COSMOS") == false || directory == "/" || directory == @"\")//check if destination exist
            {
                response = "The Directory Doesn't Exist!";
            }
            else if (checkfile.checkfile(directory) == false || directory == "." || directory == @"\" || directory == "/")//check if file exists
            {
                response = "File Not found";
            }
            else if (checkfile.isfileCorrupt(directory))
            {
                response = "File is Corrupted!";
            }
            else
            {
                Process.Start("cmd", @"/c cd C:\hadoop-2.7.2\bin && hdfs dfs -copyToLocal /" + directory + @" C:\COSMOS").WaitForExit();


                if (check_path.local_file_incomplete(directory, @"C:\COSMOS"))
                {
                    response = "File Download was cancelled upon download!";
                }
                else
                {
                    response = "File downloaded";
                }
            }



            return(response);
        }
Ejemplo n.º 3
0
///<summary>

/// </summary>
/// <param name="directory"></param>
/// <returns></returns>


        public string RegisterFile(string directory)
        {
            Check_Size check_size    = new Check_Size();
            CheckPath  check_path    = new CheckPath();
            Json       is_incomplete = new Json();

            //MD5Checker check = new MD5Checker();
            ////string md5 = check.MD5Check(directory);

            //crc32checker crc32check = new crc32checker();

            if (directory.Contains(" "))
            {
                response = "File Directory Contains Space!";
            }
            else if (Directory.Exists(directory) || directory == "/" || directory == @"\")
            {
                response = "Path is A directory! Please Specify a filename!";
            }
            else if (File.Exists(directory))
            {
                Process.Start("cmd", @"/c cd C:\hadoop-2.7.2\bin && hdfs dfs -put -f " + directory + " /").WaitForExit();
                if (is_incomplete.file_incomplete(directory) == true)
                {
                    response = "File Upload was cancelled upon upload!";
                }
                else
                {
                    response = "File Uploaded";
                }
            }
            else
            {
                response = "Input Invalid~";
            }



            //return crc32;
            return(response);
        }
Ejemplo n.º 4
0
        public string EditFile(string directory)
        {
            Json      checkfile             = new Json();
            CheckPath check_path            = new CheckPath();
            Boolean   file_downloaded_check = false;


            /////////////Delete All Files inside EDITFILES folder///////////////

            DirectoryInfo dir = new DirectoryInfo(@"C:\COSMOS\EDITFILES");

            foreach (FileInfo fi in dir.GetFiles())
            {
                fi.Delete();
            }

            ////////////Create Folder For Files to be Edited////////
            Boolean folderExists = Directory.Exists(@"C:\COSMOS\EDITFILES");

            if (folderExists == false)
            {
                Directory.CreateDirectory(@"C:\COSMOS\EDITFILES");
            }


            ///////////DOWNLOADS FILE FIRST//////////////
            if (directory.Contains(" "))
            {
                response = "File Directory Contains Space!";
            }
            else if (checkfile.checkfile(directory) == false || directory == "." || directory == @"\" || directory == "/")//check if file exists
            {
                response = "File Not found";
            }
            else if (checkfile.isfileCorrupt(directory))
            {
                response = "File is Corrupted!";
            }
            else
            {   //////////////Download from HDFS/////////////////
                Process.Start("cmd", @"/c cd C:\hadoop-2.7.2\bin && hdfs dfs -copyToLocal /" + directory + @" C:\COSMOS\EDITFILES").WaitForExit();


                if (check_path.local_file_incomplete(directory, @"C:\COSMOS\EDITFILES"))
                {
                    response = "File Download was cancelled upon Loading!";
                }
                else
                {
                    //////////////Delete from HDFS once finished Downloading/////////
                    //response = "File downloaded";
                    //Process.Start("cmd", @"/c cd C:\hadoop-2.3.0\bin && hdfs dfs -rm /" + directory ).WaitForExit();
                    SaveFile_Delete       = directory;
                    file_downloaded_check = true;
                }
            }

            if (file_downloaded_check == true)
            {
                Process.Start(@"C:\COSMOS\EDITFILES");
            }

            return(null);
        }