Example #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);
        }
Example #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;
		}
Example #3
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);
        }
Example #4
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;
		}
Example #5
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;
		}
Example #6
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);
        }
Example #7
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;
		}
Example #8
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);
        }