|
From: <du...@us...> - 2007-04-01 16:38:55
|
Revision: 274
http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=274&view=rev
Author: dukus
Date: 2007-04-01 09:38:52 -0700 (Sun, 01 Apr 2007)
Log Message:
-----------
Upload option
Modified Paths:
--------------
trunk/plugins/mpinstaler/MPInstaler/Build dialog.Designer.cs
trunk/plugins/mpinstaler/MPInstaler/Build dialog.cs
trunk/plugins/mpinstaler/MPInstaler/MPInstaler.csproj
trunk/plugins/mpinstaler/MPInstaler/Properties/Resources.Designer.cs
trunk/plugins/mpinstaler/MPInstaler/Properties/Settings.Designer.cs
trunk/plugins/mpinstaler/MPInstaler/download_form.cs
Modified: trunk/plugins/mpinstaler/MPInstaler/Build dialog.Designer.cs
===================================================================
--- trunk/plugins/mpinstaler/MPInstaler/Build dialog.Designer.cs 2007-04-01 16:24:32 UTC (rev 273)
+++ trunk/plugins/mpinstaler/MPInstaler/Build dialog.Designer.cs 2007-04-01 16:38:52 UTC (rev 274)
@@ -37,6 +37,13 @@
this.button3 = new System.Windows.Forms.Button();
this.listBox1 = new System.Windows.Forms.ListBox();
this.progressBar1 = new System.Windows.Forms.ProgressBar();
+ this.button4 = new System.Windows.Forms.Button();
+ this.textBox2 = new System.Windows.Forms.TextBox();
+ this.label2 = new System.Windows.Forms.Label();
+ this.textBox3 = new System.Windows.Forms.TextBox();
+ this.label3 = new System.Windows.Forms.Label();
+ this.textBox4 = new System.Windows.Forms.TextBox();
+ this.label4 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// saveFileDialog1
@@ -48,7 +55,7 @@
//
this.textBox1.Location = new System.Drawing.Point(12, 23);
this.textBox1.Name = "textBox1";
- this.textBox1.Size = new System.Drawing.Size(452, 20);
+ this.textBox1.Size = new System.Drawing.Size(334, 20);
this.textBox1.TabIndex = 0;
//
// label1
@@ -62,7 +69,7 @@
//
// button1
//
- this.button1.Location = new System.Drawing.Point(469, 20);
+ this.button1.Location = new System.Drawing.Point(354, 20);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(27, 23);
this.button1.TabIndex = 2;
@@ -82,7 +89,7 @@
//
// button3
//
- this.button3.Location = new System.Drawing.Point(421, 220);
+ this.button3.Location = new System.Drawing.Point(306, 220);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(75, 23);
this.button3.TabIndex = 4;
@@ -92,29 +99,92 @@
//
// listBox1
//
- this.listBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
this.listBox1.FormattingEnabled = true;
this.listBox1.HorizontalScrollbar = true;
this.listBox1.Location = new System.Drawing.Point(12, 54);
this.listBox1.Name = "listBox1";
- this.listBox1.Size = new System.Drawing.Size(484, 134);
+ this.listBox1.Size = new System.Drawing.Size(369, 134);
this.listBox1.TabIndex = 5;
//
// progressBar1
//
- this.progressBar1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
+ this.progressBar1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.progressBar1.Location = new System.Drawing.Point(12, 198);
this.progressBar1.Name = "progressBar1";
- this.progressBar1.Size = new System.Drawing.Size(484, 16);
+ this.progressBar1.Size = new System.Drawing.Size(369, 16);
this.progressBar1.TabIndex = 6;
//
+ // button4
+ //
+ this.button4.Location = new System.Drawing.Point(147, 220);
+ this.button4.Name = "button4";
+ this.button4.Size = new System.Drawing.Size(95, 23);
+ this.button4.TabIndex = 7;
+ this.button4.Text = "Build && Upload";
+ this.button4.UseVisualStyleBackColor = true;
+ this.button4.Click += new System.EventHandler(this.button4_Click);
+ //
+ // textBox2
+ //
+ this.textBox2.Location = new System.Drawing.Point(403, 54);
+ this.textBox2.Name = "textBox2";
+ this.textBox2.Size = new System.Drawing.Size(249, 20);
+ this.textBox2.TabIndex = 8;
+ this.textBox2.Text = "ftp://ftp.extra.hu/wwwroot";
+ //
+ // label2
+ //
+ this.label2.AutoSize = true;
+ this.label2.Location = new System.Drawing.Point(400, 38);
+ this.label2.Name = "label2";
+ this.label2.Size = new System.Drawing.Size(41, 13);
+ this.label2.TabIndex = 9;
+ this.label2.Text = "Server ";
+ //
+ // textBox3
+ //
+ this.textBox3.Location = new System.Drawing.Point(403, 97);
+ this.textBox3.Name = "textBox3";
+ this.textBox3.Size = new System.Drawing.Size(249, 20);
+ this.textBox3.TabIndex = 10;
+ //
+ // label3
+ //
+ this.label3.AutoSize = true;
+ this.label3.Location = new System.Drawing.Point(400, 81);
+ this.label3.Name = "label3";
+ this.label3.Size = new System.Drawing.Size(58, 13);
+ this.label3.TabIndex = 11;
+ this.label3.Text = "User name";
+ //
+ // textBox4
+ //
+ this.textBox4.Location = new System.Drawing.Point(403, 138);
+ this.textBox4.Name = "textBox4";
+ this.textBox4.Size = new System.Drawing.Size(249, 20);
+ this.textBox4.TabIndex = 12;
+ //
+ // label4
+ //
+ this.label4.AutoSize = true;
+ this.label4.Location = new System.Drawing.Point(400, 122);
+ this.label4.Name = "label4";
+ this.label4.Size = new System.Drawing.Size(53, 13);
+ this.label4.TabIndex = 13;
+ this.label4.Text = "Password";
+ //
// Build_dialog
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(502, 255);
+ this.ClientSize = new System.Drawing.Size(677, 255);
+ this.Controls.Add(this.label4);
+ this.Controls.Add(this.textBox4);
+ this.Controls.Add(this.label3);
+ this.Controls.Add(this.textBox3);
+ this.Controls.Add(this.label2);
+ this.Controls.Add(this.textBox2);
+ this.Controls.Add(this.button4);
this.Controls.Add(this.progressBar1);
this.Controls.Add(this.listBox1);
this.Controls.Add(this.button3);
@@ -144,5 +214,12 @@
private System.Windows.Forms.Button button3;
private System.Windows.Forms.ListBox listBox1;
private System.Windows.Forms.ProgressBar progressBar1;
+ private System.Windows.Forms.Button button4;
+ private System.Windows.Forms.TextBox textBox2;
+ private System.Windows.Forms.Label label2;
+ private System.Windows.Forms.TextBox textBox3;
+ private System.Windows.Forms.Label label3;
+ private System.Windows.Forms.TextBox textBox4;
+ private System.Windows.Forms.Label label4;
}
}
\ No newline at end of file
Modified: trunk/plugins/mpinstaler/MPInstaler/Build dialog.cs
===================================================================
--- trunk/plugins/mpinstaler/MPInstaler/Build dialog.cs 2007-04-01 16:24:32 UTC (rev 273)
+++ trunk/plugins/mpinstaler/MPInstaler/Build dialog.cs 2007-04-01 16:38:52 UTC (rev 274)
@@ -4,6 +4,8 @@
using System.Data;
using System.Drawing;
using System.Text;
+using System.IO;
+using System.Net;
using System.Windows.Forms;
namespace MPInstaler
@@ -39,8 +41,16 @@
private void button2_Click(object sender, EventArgs e)
{
- _struct.BuildFileName = textBox1.Text;
- _struct.BuilFile(listBox1,progressBar1);
+ if (!String.IsNullOrEmpty(textBox1.Text))
+ {
+ _struct.BuildFileName = textBox1.Text;
+ _struct.BuilFile(listBox1, progressBar1);
+ }
+ else
+ {
+ MessageBox.Show("File name is mandatory !", "Stop");
+ textBox1.Focus();
+ }
}
public void onbuild()
{
@@ -51,5 +61,55 @@
{
listBox1.Items.Clear();
}
+
+
+ private void button4_Click(object sender, EventArgs e)
+ {
+ this.Cursor = Cursors.WaitCursor;
+ if (!String.IsNullOrEmpty(textBox1.Text))
+ {
+ _struct.BuildFileName = textBox1.Text;
+ _struct.BuilFile(listBox1, progressBar1);
+ listBox1.Items.Add("Upload begin...");
+ listBox1.SelectedIndex = listBox1.Items.Count - 1;
+ listBox1.Refresh();
+ listBox1.Update();
+ if (download_form.FtpUpload(textBox1.Text, textBox2.Text, textBox3.Text, textBox4.Text))
+ {
+ listBox1.Items.Add("Upload done.");
+ listBox1.Refresh();
+ listBox1.Update();
+ string tempfile = Path.GetTempPath() + @"\MPExtensionFileList.xml";
+ string configfile = textBox2.Text+"/MPExtensionFileList.xml";
+ if (download_form.FtpDownload(configfile, tempfile, textBox3.Text, textBox4.Text))
+ {
+ listBox1.Items.Add("List file downloaded !");
+ listBox1.SelectedIndex = listBox1.Items.Count - 1;
+ listBox1.Refresh();
+ listBox1.Update();
+ MPInstallHelper temp_mpih = new MPInstallHelper();
+ temp_mpih.LoadFromFile(tempfile);
+ MPpackageStruct pk = new MPpackageStruct();
+ pk.LoadFromFile(textBox1.Text);
+ temp_mpih.Add(pk);
+ temp_mpih.SaveToFile();
+ download_form.FtpRenam(configfile, "MPExtensionFileList_old.xml", textBox3.Text, textBox4.Text);
+ listBox1.Items.Add("List file renamed !");
+ listBox1.Refresh();
+ listBox1.Update();
+ download_form.FtpUpload(tempfile, textBox2.Text, textBox3.Text, textBox4.Text);
+ listBox1.Items.Add("List file uploaded !");
+ listBox1.Refresh();
+ listBox1.Update();
+ }
+ }
+ }
+ else
+ {
+ MessageBox.Show("File name is mandatory !", "Stop");
+ textBox1.Focus();
+ }
+ this.Cursor = Cursors.Arrow;
+ }
}
}
\ No newline at end of file
Modified: trunk/plugins/mpinstaler/MPInstaler/MPInstaler.csproj
===================================================================
--- trunk/plugins/mpinstaler/MPInstaler/MPInstaler.csproj 2007-04-01 16:24:32 UTC (rev 273)
+++ trunk/plugins/mpinstaler/MPInstaler/MPInstaler.csproj 2007-04-01 16:38:52 UTC (rev 274)
@@ -147,6 +147,7 @@
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
+ <DesignTime>True</DesignTime>
</Compile>
<None Include="app.config" />
<None Include="MPInstaler_TemporaryKey.pfx" />
Modified: trunk/plugins/mpinstaler/MPInstaler/Properties/Resources.Designer.cs
===================================================================
--- trunk/plugins/mpinstaler/MPInstaler/Properties/Resources.Designer.cs 2007-04-01 16:24:32 UTC (rev 273)
+++ trunk/plugins/mpinstaler/MPInstaler/Properties/Resources.Designer.cs 2007-04-01 16:38:52 UTC (rev 274)
@@ -8,10 +8,10 @@
// </auto-generated>
//------------------------------------------------------------------------------
-namespace MPInstaler.Properties
-{
-
-
+namespace MPInstaler.Properties {
+ using System;
+
+
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
@@ -22,48 +22,40 @@
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- internal class Resources
- {
-
+ internal class Resources {
+
private static global::System.Resources.ResourceManager resourceMan;
-
+
private static global::System.Globalization.CultureInfo resourceCulture;
-
+
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
- internal Resources()
- {
+ internal Resources() {
}
-
+
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
- internal static global::System.Resources.ResourceManager ResourceManager
- {
- get
- {
- if ((resourceMan == null))
- {
+ internal static global::System.Resources.ResourceManager ResourceManager {
+ get {
+ if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("MPInstaler.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
-
+
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
- internal static global::System.Globalization.CultureInfo Culture
- {
- get
- {
+ internal static global::System.Globalization.CultureInfo Culture {
+ get {
return resourceCulture;
}
- set
- {
+ set {
resourceCulture = value;
}
}
Modified: trunk/plugins/mpinstaler/MPInstaler/Properties/Settings.Designer.cs
===================================================================
--- trunk/plugins/mpinstaler/MPInstaler/Properties/Settings.Designer.cs 2007-04-01 16:24:32 UTC (rev 273)
+++ trunk/plugins/mpinstaler/MPInstaler/Properties/Settings.Designer.cs 2007-04-01 16:38:52 UTC (rev 274)
@@ -8,21 +8,17 @@
// </auto-generated>
//------------------------------------------------------------------------------
-namespace MPInstaler.Properties
-{
-
-
+namespace MPInstaler.Properties {
+
+
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "8.0.0.0")]
- internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
- {
-
+ internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
+
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
-
- public static Settings Default
- {
- get
- {
+
+ public static Settings Default {
+ get {
return defaultInstance;
}
}
Modified: trunk/plugins/mpinstaler/MPInstaler/download_form.cs
===================================================================
--- trunk/plugins/mpinstaler/MPInstaler/download_form.cs 2007-04-01 16:24:32 UTC (rev 273)
+++ trunk/plugins/mpinstaler/MPInstaler/download_form.cs 2007-04-01 16:38:52 UTC (rev 274)
@@ -15,6 +15,7 @@
string source = string.Empty;
string dest = string.Empty;
WebClient client = new WebClient();
+ public int direction = 0;
public download_form(string s, string d)
{
InitializeComponent();
@@ -22,6 +23,8 @@
dest = d;
client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(DownloadProgressCallback);
client.DownloadFileCompleted += new AsyncCompletedEventHandler(DownloadEnd);
+ client.UploadProgressChanged+= new UploadProgressChangedEventHandler(UploadProgressCallback);
+ client.UploadFileCompleted += new UploadFileCompletedEventHandler(DownloadEnd);
progressBar1.Minimum = 0;
progressBar1.Maximum = 100;
progressBar1.Value = 0;
@@ -31,7 +34,12 @@
{
if (!String.IsNullOrEmpty(source) && !String.IsNullOrEmpty(dest))
{
- client.DownloadFileAsync(new System.Uri(source), dest);
+ if (direction == 0)
+ client.DownloadFileAsync(new System.Uri(source), dest);
+ else
+ {
+ client.UploadFileAsync(new System.Uri(source), dest);
+ }
//client.DownloadFile(new System.Uri(source), dest);
}
}
@@ -45,6 +53,11 @@
// e.ProgressPercentage);
progressBar1.Value = e.ProgressPercentage;
}
+
+ private void UploadProgressCallback(object sender, UploadProgressChangedEventArgs e)
+ {
+ progressBar1.Value = e.ProgressPercentage;
+ }
private void DownloadEnd(object sender, AsyncCompletedEventArgs e)
{
if (e.Error != null)
@@ -57,6 +70,112 @@
this.Close();
}
+ public static bool FtpDownload(string source, string dest, string user, string pwd)
+ {
+ FtpWebRequest reqFTP;
+ try
+ {
+ //filePath = <<The full path where the file is to be created.>>,
+ //fileName = <<Name of the file to be created(Need not be the name of the file on FTP server).>>
+ FileStream outputStream = new FileStream(dest, FileMode.Create);
+
+ reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(source));
+ reqFTP.Method = WebRequestMethods.Ftp.DownloadFile;
+ reqFTP.UseBinary = true;
+ reqFTP.Credentials = new NetworkCredential(user, pwd);
+ FtpWebResponse response = (FtpWebResponse)reqFTP.GetResponse();
+ Stream ftpStream = response.GetResponseStream();
+ long cl = response.ContentLength;
+ int bufferSize = 2048;
+ int readCount;
+ byte[] buffer = new byte[bufferSize];
+
+ readCount = ftpStream.Read(buffer, 0, bufferSize);
+ while (readCount > 0)
+ {
+ outputStream.Write(buffer, 0, readCount);
+ readCount = ftpStream.Read(buffer, 0, bufferSize);
+ }
+
+ ftpStream.Close();
+ outputStream.Close();
+ response.Close();
+ if (response.StatusCode == FtpStatusCode.ClosingData)
+ return true;
+ else
+ return false;
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message);
+ return false;
+ }
+ }
+
+ public static bool FtpUpload(string source, string dest, string user, string pwd)
+ {
+ try
+ {
+ if (!dest.EndsWith("/")) dest += "/";
+ dest += Path.GetFileName(source);
+ FtpWebRequest request = (FtpWebRequest)WebRequest.Create(dest);
+ request.Method = WebRequestMethods.Ftp.UploadFile;
+ // This example assumes the FTP site uses anonymous logon.
+ request.Credentials = new NetworkCredential(user, pwd);
+ request.UseBinary = true;
+ // Copy the contents of the file to the request stream.
+ StreamReader sourceStream = new StreamReader(source);
+ byte[] fileContents = Encoding.UTF8.GetBytes(sourceStream.ReadToEnd());
+ sourceStream.Close();
+ request.ContentLength = fileContents.Length;
+
+ Stream requestStream = request.GetRequestStream();
+ requestStream.Write(fileContents, 0, fileContents.Length);
+ requestStream.Close();
+
+ FtpWebResponse response = (FtpWebResponse)request.GetResponse();
+ response.Close();
+ if (response.StatusCode == FtpStatusCode.ClosingData)
+ return true;
+ else
+ return false;
+ }
+ catch(Exception ex)
+ {
+ MessageBox.Show("Error :"+ex.Message);
+ return false;
+ }
+ }
+
+ public static bool FtpRenam(string source, string newFilename, string user, string pwd)
+ {
+ FtpWebRequest reqFTP;
+ try
+ {
+ MessageBox.Show(newFilename);
+ reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(source));
+ reqFTP.Method = WebRequestMethods.Ftp.Rename;
+ reqFTP.RenameTo = newFilename;
+ reqFTP.UseBinary = true;
+ reqFTP.Credentials = new NetworkCredential(user , pwd);
+ FtpWebResponse response = (FtpWebResponse)reqFTP.GetResponse();
+ Stream ftpStream = response.GetResponseStream();
+
+ ftpStream.Close();
+ response.Close();
+ if (response.StatusCode == FtpStatusCode.ClosingData)
+ return true;
+ else
+ return false;
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message);
+ return false;
+ }
+ }
+
+
private void button1_Click(object sender, EventArgs e)
{
client.CancelAsync();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|