Beispiel #1
0
        private void RemoteEdit()
        {
            if (Folder != null && m_File != null)
            {
                string filename = System.IO.Path.Combine(Folder, m_File);
                TheBox.BoxServer.DownloadRequest msg = new DownloadRequest();
                Pandora.Profile.Server.FillBoxMessage(msg);
                msg.Filename = filename;

                BoxServerForm form = new BoxServerForm(msg);

                if (form.ShowDialog() == DialogResult.OK)
                {
                    TheBox.BoxServer.FileTransport response = form.Response as FileTransport;

                    if (response != null)
                    {
                        // Download succesful
                        RemoteEditor f = new RemoteEditor(filename, response.Text);
                        Pandora.Localization.LocalizeControl(f);
                        f.Show();
                        f.Closed += new EventHandler(form_Closed);
                        m_Editors.Add(f);
                    }
                    else
                    {
                        sBar.Text = Pandora.Localization.TextProvider["Script.UnexpectedErr"];
                    }
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Downloads the selected file from the server
        /// </summary>
        private void Download()
        {
            if (Folder != null && m_File != null)
            {
                string filename = System.IO.Path.Combine(Folder, m_File);

                SaveFile.Filter   = GetFilter(filename);
                SaveFile.FileName = Path.GetFileNameWithoutExtension(filename);

                if (SaveFile.ShowDialog() == DialogResult.OK)
                {
                    TheBox.BoxServer.DownloadRequest msg = new DownloadRequest();

                    Pandora.Profile.Server.FillBoxMessage(msg);

                    msg.Filename = filename;

                    BoxServerForm form = new BoxServerForm(msg);

                    if (form.ShowDialog() == DialogResult.OK)
                    {
                        TheBox.BoxServer.FileTransport response = form.Response as FileTransport;

                        if (response != null)
                        {
                            // Download succesful
                            try
                            {
                                StreamWriter writer = new StreamWriter(SaveFile.FileName, false);
                                writer.Write(response.Text);
                                writer.Close();

                                sBar.Text = string.Format(Pandora.Localization.TextProvider["Script.DownOk"], m_File, SaveFile.FileName);
                            }
                            catch (Exception err)
                            {
                                Pandora.Log.WriteError(err, "Can't write file {0} to {1}", filename, SaveFile.FileName);
                                MessageBox.Show(Pandora.Localization.TextProvider["Server.CantWriteFile"]);

                                sBar.Text = string.Format(Pandora.Localization.TextProvider["Script.GenericErr"]);
                            }
                        }
                        else
                        {
                            sBar.Text = Pandora.Localization.TextProvider["Script.UnexpectedErr"];
                        }
                    }
                }
            }
        }
Beispiel #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;
		}
Beispiel #4
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);
        }
Beispiel #5
0
        private void miRemoteSave_Click(object sender, System.EventArgs e)
        {
            TheBox.BoxServer.FileTransport msg = new TheBox.BoxServer.FileTransport();
            msg.Filename = m_File;

            Pandora.Profile.Server.FillBoxMessage(msg);
            msg.Text = m_Text;

            GenericOK response = Pandora.BoxConnection.ProcessMessage(msg, true) as GenericOK;

            if (response != null)
            {
                // Success
                sBar.Text = "Remote save succesful";
            }
            else
            {
                sBar.Text = "Remote save failed";
            }
        }
Beispiel #6
0
		/// <summary>
		/// Uploads a file to the server
		/// </summary>
		private void Upload()
		{
			if ( Folder == null )
				return;

			if ( OpenFile.ShowDialog() != DialogResult.OK )
				return;

			string filename = Path.Combine( Folder, Path.GetFileName( OpenFile.FileName ) );

			TheBox.BoxServer.FileTransport msg = new FileTransport();
			msg.Filename = filename;

			Pandora.Profile.Server.FillBoxMessage( msg );
			
			// Read text from the file
			try
			{
				StreamReader reader = new StreamReader( OpenFile.FileName );
				msg.Text = reader.ReadToEnd();
				reader.Close();
			}
			catch ( Exception err )
			{
				Pandora.Log.WriteError( err, "Error when reading text file {0}", OpenFile.FileName );
				sBar.Text = Pandora.Localization.TextProvider[ "Script.ReadErr" ];
				return;
			}

			GenericOK response =  Pandora.BoxConnection.ProcessMessage( msg, true ) as GenericOK;

			if ( response != null )
			{
				// Success
				sBar.Text = Pandora.Localization.TextProvider[ "Script.UploadOk" ];

				// Add item
				TreeNode node = GetTreeNode( Path.GetFileName( OpenFile.FileName ) );
				TreeNode parent = null;

				if ( m_File == null )
				{
					parent = Tree.SelectedNode;
				}
				else
				{
					parent = Tree.SelectedNode.Parent;
				}

				bool exists = false;
				foreach( TreeNode exist in parent.Nodes )
				{
					if ( exist.Text.ToLower() == node.Text.ToLower() )
					{
						exists = true;
						break;
					}
				}

				if ( ! exists )
					parent.Nodes.Add( node );

			}
			else
			{
				sBar.Text = Pandora.Localization.TextProvider[ "Script.UploadFail" ];
			}
		}
Beispiel #7
0
		private void miRemoteSave_Click(object sender, System.EventArgs e)
		{
			TheBox.BoxServer.FileTransport msg = new TheBox.BoxServer.FileTransport();
			msg.Filename = m_File;

			Pandora.Profile.Server.FillBoxMessage( msg );
			msg.Text = m_Text;

			GenericOK response =  Pandora.BoxConnection.ProcessMessage( msg, true ) as GenericOK;

			if ( response != null )
			{
				// Success
				sBar.Text = "Remote save succesful";
			}
			else
			{
				sBar.Text = "Remote save failed";
			}
		}