Esempio n. 1
0
        public override BoxMessage Perform()
        {
            BoxMessage msg = null;

            if (RemoteExplorerConfig.AllowAccess(Username, Path.GetDirectoryName(m_Filename)))
            {
                if (RemoteExplorerConfig.VeirfyExtension(m_Filename))
                {
                    try
                    {
                        StreamWriter writer = new StreamWriter(FullPath, false);
                        writer.Write(m_Text);
                        writer.Close();

                        msg = new GenericOK();
                    }
                    catch (Exception err)
                    {
                        msg = new ErrorMessage("An I/O error occurred when writing the file.\n\n{0}", err.ToString());
                    }
                }
                else
                {
                    // Extension not supported
                    msg = new ErrorMessage("File type not allowed.");
                }
            }
            else
            {
                // Trying to upload to a folder that isn't registered for the user
                msg = new ErrorMessage("You aren't allowed to manipulate that folder.");
            }

            return(msg);
        }
Esempio n. 2
0
        public override BoxMessage Perform()
        {
            BoxMessage msg = null;

            if (RemoteExplorerConfig.AllowAccess(Username, m_Folder))
            {
                try
                {
                    string path = System.IO.Path.Combine(BoxUtil.RunUOFolder, m_Folder);

                    System.IO.Directory.CreateDirectory(path);
                    msg = new GenericOK();
                }
                catch (Exception err)
                {
                    msg = new ErrorMessage("An error occurred when creating the folder:\n\n{0}", err.ToString());
                }
            }
            else
            {
                msg = new ErrorMessage("You can't create folders there");
            }

            return(msg);
        }
Esempio n. 3
0
        public override BoxMessage Perform()
        {
            string     folder = Path.GetDirectoryName(m_Filename);
            BoxMessage msg    = null;

            if (RemoteExplorerConfig.AllowAccess(Username, folder))
            {
                if (File.Exists(FullPath))
                {
                    FileInfo info = new FileInfo(FullPath);

                    if (info.Length <= RemoteExplorerConfig.MaxFileSize)
                    {
                        try
                        {
                            msg = new FileTransport();

                            StreamReader reader = new StreamReader(info.FullName);
                            (msg as FileTransport).Text = reader.ReadToEnd();
                            reader.Close();
                        }
                        catch (Exception err)
                        {
                            msg = new ErrorMessage("An I/O error occurred when reading the file:\n\n", err.ToString());
                        }
                    }
                    else
                    {
                        // File is too big
                        msg = new ErrorMessage("The requested file is too big.");
                    }
                }
                else
                {
                    // File not found
                    msg = new ErrorMessage("The requested file could not be found");
                }
            }
            else
            {
                // Trying to request a file from a folder that isn't registered
                msg = new ErrorMessage("The requested resource isn't available to you.");
            }

            return(msg);
        }
Esempio n. 4
0
        public override BoxMessage Perform()
        {
            BoxMessage msg = null;

            if (RemoteExplorerConfig.AllowAccess(Username, System.IO.Path.GetDirectoryName(m_Path)))
            {
                if (Directory.Exists(FullPath))
                {
                    try
                    {
                        Directory.Delete(FullPath, true);
                        msg = new GenericOK();
                    }
                    catch (Exception err)
                    {
                        msg = new ErrorMessage("Couldn't delete the directory {0}. The following error occurred:\n\n{1}", m_Path, err.ToString());
                    }
                }
                else if (File.Exists(FullPath))
                {
                    try
                    {
                        File.Delete(FullPath);
                        msg = null;
                    }
                    catch (Exception err)
                    {
                        msg = new ErrorMessage("Couldn't delete the file {0}. The following error occurred:\n\n{1}", m_Path, err.ToString());
                    }
                }
                else
                {
                    // Not found
                    msg = new ErrorMessage("The requested resource could not be found on the server, please refresh your view.");
                }
            }
            else
            {
                // Can't manipulate that folder
                msg = new ErrorMessage("You aren't allowed to manipulate the folder : {0}", m_Path);
            }

            return(msg);
        }
Esempio n. 5
0
        public override BoxMessage Perform()
        {
            BoxMessage msg = null;

            string folderOld = Path.GetDirectoryName(m_OldPath);
            string folderNew = Path.GetDirectoryName(m_NewPath);

            string from = Path.Combine(BoxUtil.RunUOFolder, m_OldPath);
            string to   = Path.Combine(BoxUtil.RunUOFolder, m_NewPath);

            if (RemoteExplorerConfig.AllowAccess(Username, folderOld) && RemoteExplorerConfig.AllowAccess(Username, folderNew))
            {
                try
                {
                    if (File.Exists(from))
                    {
                        File.Move(from, to);
                        msg = null;
                    }
                    else if (Directory.Exists(from))
                    {
                        Directory.Move(from, to);
                        msg = new GenericOK();
                    }
                    else
                    {
                        msg = new ErrorMessage("The requested object could not be found ({0})", m_OldPath);
                    }
                }
                catch (Exception err)
                {
                    msg = new ErrorMessage("An error occurred while processing the move request :\n\n{0}", err.ToString());
                }
            }
            else
            {
                msg = new ErrorMessage("You aren't allowed to access that.");
            }

            return(msg);
        }