Configurator.cs
资源名称:FtpServer.rar [点击查看]
上传用户:xuelanruo
上传日期:2015-04-02
资源大小:163k
文件大小:35k
源码类别:
Ftp服务器
开发平台:
C#
- /*
- Dot Net Ftp Gui Interface (configuration of the Dot Net Ftp Service)
- Copyright (C)
- This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
- This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
- You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- Last modification : 04/26/2004 by Simon FERQUEL
- */
- using System;
- using System.Drawing;
- using System.Collections;
- using System.ComponentModel;
- using System.Windows.Forms;
- using System.Data;
- using Microsoft.Win32;
- using System.Security.Permissions;
- using System.ServiceProcess;
- using System.Management;
- using System.Xml;
- using System.IO;
- using System.Xml.XPath;
- using System.Configuration;
- [assembly: RegistryPermissionAttribute(SecurityAction.RequestMinimum,
- All = "HKEY_LOCAL_MACHINE")]
- namespace FtpService
- {
- /// <summary>
- /// Description r閟um閑 de Form1.
- /// </summary>
- ///
- public class FtpConfig : System.Windows.Forms.Form
- {
- private ServiceController _ftpSc = new ServiceController("MajordomoFtpService");
- private System.Windows.Forms.GroupBox groupBox1;
- private System.Windows.Forms.NumericUpDown CommandTimeOut;
- private System.Windows.Forms.GroupBox groupBox2;
- private System.Windows.Forms.NumericUpDown SessionTimeOut;
- private System.Windows.Forms.GroupBox groupBox3;
- private System.Windows.Forms.GroupBox groupBox4;
- private System.Windows.Forms.GroupBox groupBox5;
- private System.Windows.Forms.NumericUpDown Port;
- private System.Windows.Forms.ComboBox IPAddress;
- private System.Windows.Forms.NumericUpDown MaxThreads;
- private System.Windows.Forms.NumericUpDown MaxBadCommands;
- private System.Windows.Forms.GroupBox groupBox7;
- private System.Windows.Forms.Button ServiceStart;
- private System.Windows.Forms.Button ServiceStop;
- private System.Windows.Forms.Button ServiceRestart;
- private System.Windows.Forms.Button OkButton;
- private System.Windows.Forms.Button ApplyButton;
- private System.Windows.Forms.FolderBrowserDialog DefPathDialog;
- private System.Windows.Forms.TabControl tabControl1;
- private System.Windows.Forms.TabPage serverTab;
- private System.Windows.Forms.TabPage homesTab;
- private System.Windows.Forms.GroupBox groupBox6;
- private System.Windows.Forms.TextBox DefaultPath;
- private System.Windows.Forms.Button DefPathButton;
- private System.Windows.Forms.DataGrid homesGrid;
- private System.Data.DataView HomesView;
- private System.Windows.Forms.Button button1;
- private System.Windows.Forms.Button button2;
- private System.Windows.Forms.TabPage VPathTab;
- private System.Windows.Forms.Button button3;
- private System.Windows.Forms.Button button4;
- private System.Windows.Forms.DataGrid DefaultVPathsGrid;
- private System.Windows.Forms.DataGrid PrivateVPathsGrid;
- private System.Windows.Forms.ListBox VPathsUsersListBox;
- private System.Windows.Forms.TextBox VPathsNewUserTxtBox;
- private System.Windows.Forms.Button AddPersonalVpaths;
- private System.Data.DataSet VPathsDataSet;
- private System.Windows.Forms.GroupBox groupBox8;
- private System.Windows.Forms.GroupBox groupBox9;
- /// <summary>
- /// Variable n閏essaire au concepteur.
- /// </summary>
- private System.ComponentModel.Container components = null;
- private string _IPAddress
- {
- get
- {
- try
- {
- return ConfigurationManager.AppSettings["IPAddress"];
- }
- catch
- {
- return "ALL";
- }
- }
- set
- {
- FtpServerLibrary.FtpServer.SetConfigValue("IPAddress", value);
- }
- }
- private int _maxBadCommands
- {
- get
- {
- try
- {
- return Convert.ToInt32(ConfigurationManager.AppSettings["MaxBadCommands"]);
- }
- catch
- {
- return 30;
- }
- }
- set
- {
- try
- {
- FtpServerLibrary.FtpServer.SetConfigValue("MaxBadCommands", value.ToString());
- }
- catch
- {}
- }
- }
- private int _port
- {
- get
- {
- try
- {
- return Convert.ToInt32(ConfigurationManager.AppSettings["Port"]);
- }
- catch
- {
- return 21;
- }
- }
- set
- {
- try
- {
- FtpServerLibrary.FtpServer.SetConfigValue("Port", value.ToString());
- }
- catch
- {}
- }
- }
- private int _maxThreads
- {
- get
- {
- try
- {
- return Convert.ToInt32(ConfigurationManager.AppSettings["MaxThreads"]);
- }
- catch
- {
- return 100;
- }
- }
- set
- {
- try
- {
- FtpServerLibrary.FtpServer.SetConfigValue("MaxThreads", value.ToString());
- }
- catch
- {}
- }
- }
- private int _sessionIdleTimeOut
- {
- get
- {
- try
- {
- return Convert.ToInt32(ConfigurationManager.AppSettings["SessionIdleTimeOut"]);
- }
- catch
- {
- return 800000;
- }
- }
- set
- {
- try
- {
- FtpServerLibrary.FtpServer.SetConfigValue("SessionIdleTimeOut", value.ToString());
- }
- catch
- {}
- }
- }
- private int _commandIdleTimeOut
- {
- get
- {
- try
- {
- return Convert.ToInt32(ConfigurationManager.AppSettings["CommandIdleTimeOut"]);
- }
- catch
- {
- return 60000;
- }
- }
- set
- {
- try
- {
- FtpServerLibrary.FtpServer.SetConfigValue("CommandIdleTimeOut", value.ToString());
- }
- catch
- {}
- }
- }
- private void ApplyHomes()
- {
- try
- {
- string xmlDoc="<?xml version="1.0" encoding="utf-8" ?>n";
- xmlDoc+="<Homes xmlns="http://tempuri.org/config.xsd">n";
- xmlDoc+="<Default home=""+this.DefaultPath.Text+"" />n";
- foreach(System.Data.DataRow row in this.HomesView.Table.Rows)
- {
- xmlDoc+="<Home user=""+(string)row[0]+"" path=""+row[1]+"" />n";
- }
- xmlDoc+="</Homes>n";
- FileStream fs = System.IO.File.Open(System.IO.Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase, "Homes.xml"), FileMode.Create, FileAccess.Write, FileShare.None);
- byte[] bytes=System.Text.Encoding.UTF8.GetBytes(xmlDoc);
- fs.Write(bytes,0,bytes.Length);
- fs.Close();
- }
- catch
- {}
- }
- private void FillVPathsDataSet()
- {
- try
- {
- XPathDocument doc = new XPathDocument(System.IO.Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase, "VPaths.xml"));
- XPathNavigator nav=doc.CreateNavigator();
- if(nav.MoveToFirstChild())
- {
- if(nav.MoveToFirstChild())
- {
- this.VPathsDataSet.Tables.Add("default");
- this.VPathsDataSet.Tables["default"].Columns.Add("source");
- this.VPathsDataSet.Tables["default"].Columns.Add("target");
- if(nav.Name.ToLower()=="default")
- {
- if(nav.MoveToFirstChild())
- {
- string[] row=new string[2];
- row[0]=nav.GetAttribute("source","");
- row[1]=nav.GetAttribute("target","");
- this.VPathsDataSet.Tables["default"].Rows.Add(row);
- while(nav.MoveToNext())
- {
- row=new string[2];
- row[0]=nav.GetAttribute("source","");
- row[1]=nav.GetAttribute("target","");
- this.VPathsDataSet.Tables["default"].Rows.Add(row);
- }
- nav.MoveToParent();
- }
- }
- else if(nav.HasAttributes)
- {
- string curUser=nav.GetAttribute("user","");
- this.VPathsDataSet.Tables.Add(curUser);
- this.VPathsDataSet.Tables[curUser].Columns.Add("source");
- this.VPathsDataSet.Tables[curUser].Columns.Add("target");
- if(nav.MoveToFirstChild())
- {
- string[] row=new string[2];
- row[0]=nav.GetAttribute("source","");
- row[1]=nav.GetAttribute("target","");
- this.VPathsDataSet.Tables[curUser].Rows.Add(row);
- while(nav.MoveToNext())
- {
- row=new string[2];
- row[0]=nav.GetAttribute("source","");
- row[1]=nav.GetAttribute("target","");
- this.VPathsDataSet.Tables[curUser].Rows.Add(row);
- }
- nav.MoveToParent();
- }
- }
- while(nav.MoveToNext())
- {
- if(nav.Name.ToLower()=="default")
- {
- if(nav.MoveToFirstChild())
- {
- string[] row=new string[2];
- row[0]=nav.GetAttribute("source","");
- row[1]=nav.GetAttribute("target","");
- this.VPathsDataSet.Tables["default"].Rows.Add(row);
- while(nav.MoveToNext())
- {
- row=new string[2];
- row[0]=nav.GetAttribute("source","");
- row[1]=nav.GetAttribute("target","");
- this.VPathsDataSet.Tables["default"].Rows.Add(row);
- }
- nav.MoveToParent();
- }
- }
- else if(nav.HasAttributes)
- {
- string curUser=nav.GetAttribute("user","");
- this.VPathsDataSet.Tables.Add(curUser);
- this.VPathsDataSet.Tables[curUser].Columns.Add("source");
- this.VPathsDataSet.Tables[curUser].Columns.Add("target");
- if(nav.MoveToFirstChild())
- {
- string[] row=new string[2];
- row[0]=nav.GetAttribute("source","");
- row[1]=nav.GetAttribute("target","");
- this.VPathsDataSet.Tables[curUser].Rows.Add(row);
- while(nav.MoveToNext())
- {
- row=new string[2];
- row[0]=nav.GetAttribute("source","");
- row[1]=nav.GetAttribute("target","");
- this.VPathsDataSet.Tables[curUser].Rows.Add(row);
- }
- nav.MoveToParent();
- }
- }
- }
- }
- }
- this.DefaultVPathsGrid.DataSource=this.VPathsDataSet.Tables["default"];
- foreach(DataTable table in this.VPathsDataSet.Tables)
- {
- if(table.TableName!="default")
- this.VPathsUsersListBox.Items.Add(table.TableName);
- }
- }
- catch
- {}
- }
- private void SaveVPaths()
- {
- try
- {
- string xml="<?xml version="1.0" encoding="utf-8" ?>rn<VPaths xmlns="http://tempuri.org/config.xsd">";
- foreach(DataTable table in this.VPathsDataSet.Tables)
- {
- if(table.TableName=="default")
- {
- xml+="<default>rn";
- foreach(DataRow row in table.Rows)
- {
- xml+="<VPath source=""+(string)row.ItemArray[0]+"" target=""+(string)row.ItemArray[1]+"" />rn";
- }
- xml+="</default>rn";
- }
- else
- {
- xml+="<private user=""+table.TableName+"">rn";
- foreach(DataRow row in table.Rows)
- {
- xml+="<VPath source=""+(string)row.ItemArray[0]+"" target=""+(string)row.ItemArray[1]+"" />rn";
- }
- xml+="</private>rn";
- }
- }
- xml+="</VPaths>";
- FileStream fs = System.IO.File.Open(System.IO.Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase, "VPaths.xml"), FileMode.Create, FileAccess.Write, FileShare.None);
- byte[] bytes=System.Text.Encoding.UTF8.GetBytes(xml);
- fs.Write(bytes,0,bytes.Length);
- fs.Close();
- }
- catch{}
- }
- private void FillHomesViewAndDefault()
- {
- try
- {
- string defaultHome="";
- System.Collections.Hashtable userHomes=new Hashtable();
- XPathDocument doc = new XPathDocument(System.IO.Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase, "Homes.xml"));
- XPathNavigator nav=doc.CreateNavigator();
- nav.MoveToFirstChild();
- nav.MoveToFirstChild();
- if(nav.Name.ToLower()=="default")
- {
- defaultHome=nav.GetAttribute("home","");
- }
- else if (nav.Name.ToLower()=="home")
- {
- userHomes.Add(nav.GetAttribute("user","").ToLower(),nav.GetAttribute("path",""));
- }
- while(nav.MoveToNext())
- {
- if(nav.Name.ToLower()=="default")
- {
- defaultHome=nav.GetAttribute("home","");
- }
- else if (nav.Name.ToLower()=="home")
- {
- userHomes.Add(nav.GetAttribute("user","").ToLower(),nav.GetAttribute("path",""));
- }
- }
- this.DefaultPath.Text=defaultHome;
- foreach(string user in userHomes.Keys)
- {
- string[] row = new string[2];
- row[0]=user;
- row[1]=(string)userHomes[user];
- this.HomesView.Table.Rows.Add(row);
- }
- }
- catch
- {
- }
- }
- public FtpConfig()
- {
- InitializeComponent();
- this.HomesView.Table=new DataTable("Homes");
- this.HomesView.Table.Columns.Add("User Name");
- this.HomesView.Table.Columns.Add("Path");
- this.HomesView.Table.Constraints.Add("UserNamePK",this.HomesView.Table.Columns["User Name"],true);
- this.FillHomesViewAndDefault();
- this.FillVPathsDataSet();
- this.UpdateServiceState();
- this.IPAddress.Items.Add("ALL");
- ManagementObjectSearcher query = null;
- ManagementObjectCollection queryCollection = null;
- try
- {
- query = new ManagementObjectSearcher("SELECT IPAddress FROM Win32_NetworkAdapterConfiguration where IPEnabled=TRUE") ;
- queryCollection = query.Get();
- foreach( ManagementObject mo in queryCollection )
- {
- if(mo["IPAddress"] != null)
- {
- this.IPAddress.Items.Add(((string[])mo["IPAddress"])[0].ToString());
- }
- }
- }
- catch
- {}
- this.DisplayValues();
- }
- private void DisplayValues()
- {
- this.IPAddress.SelectedItem=this._IPAddress.ToUpper();
- this.MaxBadCommands.Value=Convert.ToDecimal(this._maxBadCommands);
- this.Port.Value=this._port;
- this.MaxThreads.Value=this._maxThreads;
- this.SessionTimeOut.Value=this._sessionIdleTimeOut;
- this.CommandTimeOut.Value=this._commandIdleTimeOut;
- }
- private void ApplyValues()
- {
- try
- {
- this._commandIdleTimeOut=Convert.ToInt32(this.CommandTimeOut.Value);
- }
- catch
- {}
- try
- {
- this._IPAddress=(string)this.IPAddress.SelectedItem;
- }
- catch{}
- try
- {
- this._maxBadCommands=Convert.ToInt32(this.MaxBadCommands.Value);
- }
- catch{}
- try
- {
- this._maxThreads=Convert.ToInt32(this.MaxThreads.Value);
- }
- catch{}
- try
- {
- this._port=Convert.ToInt32(this.Port.Value);
- }
- catch{}
- try
- {
- this._sessionIdleTimeOut=Convert.ToInt32(this.SessionTimeOut.Value);
- }
- catch{}
- }
- private void UpdateServiceState()
- {
- if(this._ftpSc.Status==ServiceControllerStatus.Running)
- {
- this.ServiceRestart.Enabled=true;
- this.ServiceStop.Enabled=true;
- this.ServiceStart.Enabled=false;
- }
- else
- {
- this.ServiceRestart.Enabled=false;
- this.ServiceStop.Enabled=false;
- this.ServiceStart.Enabled=true;
- }
- }
- protected override void Dispose( bool disposing )
- {
- if( disposing )
- {
- if (components != null)
- {
- components.Dispose();
- }
- }
- base.Dispose( disposing );
- }
- #region 窗体设计器生成的代码
- /// <summary>
- /// 设计器支持所需的方法 - 不要
- /// 使用代码编辑器修改此方法的内容。
- /// </summary>
- private void InitializeComponent()
- {
- this.groupBox1 = new System.Windows.Forms.GroupBox();
- this.CommandTimeOut = new System.Windows.Forms.NumericUpDown();
- this.groupBox2 = new System.Windows.Forms.GroupBox();
- this.SessionTimeOut = new System.Windows.Forms.NumericUpDown();
- this.groupBox3 = new System.Windows.Forms.GroupBox();
- this.MaxBadCommands = new System.Windows.Forms.NumericUpDown();
- this.groupBox4 = new System.Windows.Forms.GroupBox();
- this.MaxThreads = new System.Windows.Forms.NumericUpDown();
- this.groupBox5 = new System.Windows.Forms.GroupBox();
- this.Port = new System.Windows.Forms.NumericUpDown();
- this.IPAddress = new System.Windows.Forms.ComboBox();
- this.DefPathDialog = new System.Windows.Forms.FolderBrowserDialog();
- this.groupBox7 = new System.Windows.Forms.GroupBox();
- this.ServiceRestart = new System.Windows.Forms.Button();
- this.ServiceStop = new System.Windows.Forms.Button();
- this.ServiceStart = new System.Windows.Forms.Button();
- this.OkButton = new System.Windows.Forms.Button();
- this.ApplyButton = new System.Windows.Forms.Button();
- this.tabControl1 = new System.Windows.Forms.TabControl();
- this.serverTab = new System.Windows.Forms.TabPage();
- this.homesTab = new System.Windows.Forms.TabPage();
- this.button1 = new System.Windows.Forms.Button();
- this.button2 = new System.Windows.Forms.Button();
- this.homesGrid = new System.Windows.Forms.DataGrid();
- this.HomesView = new System.Data.DataView();
- this.groupBox6 = new System.Windows.Forms.GroupBox();
- this.DefPathButton = new System.Windows.Forms.Button();
- this.DefaultPath = new System.Windows.Forms.TextBox();
- this.VPathTab = new System.Windows.Forms.TabPage();
- this.AddPersonalVpaths = new System.Windows.Forms.Button();
- this.VPathsNewUserTxtBox = new System.Windows.Forms.TextBox();
- this.VPathsUsersListBox = new System.Windows.Forms.ListBox();
- this.DefaultVPathsGrid = new System.Windows.Forms.DataGrid();
- this.button3 = new System.Windows.Forms.Button();
- this.button4 = new System.Windows.Forms.Button();
- this.PrivateVPathsGrid = new System.Windows.Forms.DataGrid();
- this.VPathsDataSet = new System.Data.DataSet();
- this.groupBox8 = new System.Windows.Forms.GroupBox();
- this.groupBox9 = new System.Windows.Forms.GroupBox();
- this.groupBox1.SuspendLayout();
- ((System.ComponentModel.ISupportInitialize)(this.CommandTimeOut)).BeginInit();
- this.groupBox2.SuspendLayout();
- ((System.ComponentModel.ISupportInitialize)(this.SessionTimeOut)).BeginInit();
- this.groupBox3.SuspendLayout();
- ((System.ComponentModel.ISupportInitialize)(this.MaxBadCommands)).BeginInit();
- this.groupBox4.SuspendLayout();
- ((System.ComponentModel.ISupportInitialize)(this.MaxThreads)).BeginInit();
- this.groupBox5.SuspendLayout();
- ((System.ComponentModel.ISupportInitialize)(this.Port)).BeginInit();
- this.groupBox7.SuspendLayout();
- this.tabControl1.SuspendLayout();
- this.serverTab.SuspendLayout();
- this.homesTab.SuspendLayout();
- ((System.ComponentModel.ISupportInitialize)(this.homesGrid)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.HomesView)).BeginInit();
- this.groupBox6.SuspendLayout();
- this.VPathTab.SuspendLayout();
- ((System.ComponentModel.ISupportInitialize)(this.DefaultVPathsGrid)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.PrivateVPathsGrid)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.VPathsDataSet)).BeginInit();
- this.groupBox8.SuspendLayout();
- this.groupBox9.SuspendLayout();
- this.SuspendLayout();
- //
- // groupBox1
- //
- this.groupBox1.Controls.Add(this.CommandTimeOut);
- this.groupBox1.Location = new System.Drawing.Point(24, 16);
- this.groupBox1.Name = "groupBox1";
- this.groupBox1.Size = new System.Drawing.Size(344, 72);
- this.groupBox1.TabIndex = 0;
- this.groupBox1.TabStop = false;
- this.groupBox1.Text = "Command Time Out (maximum time to pass ftp command in ms)";
- //
- // CommandTimeOut
- //
- this.CommandTimeOut.Location = new System.Drawing.Point(104, 32);
- this.CommandTimeOut.Maximum = new System.Decimal(new int[] {
- 999999999,
- 0,
- 0,
- 0});
- this.CommandTimeOut.Name = "CommandTimeOut";
- this.CommandTimeOut.TabIndex = 0;
- //
- // groupBox2
- //
- this.groupBox2.Controls.Add(this.SessionTimeOut);
- this.groupBox2.Location = new System.Drawing.Point(24, 104);
- this.groupBox2.Name = "groupBox2";
- this.groupBox2.Size = new System.Drawing.Size(344, 72);
- this.groupBox2.TabIndex = 1;
- this.groupBox2.TabStop = false;
- this.groupBox2.Text = "Session Time Out (maximum idle time in ms)";
- //
- // SessionTimeOut
- //
- this.SessionTimeOut.Location = new System.Drawing.Point(104, 32);
- this.SessionTimeOut.Maximum = new System.Decimal(new int[] {
- 1410065407,
- 2,
- 0,
- 0});
- this.SessionTimeOut.Name = "SessionTimeOut";
- this.SessionTimeOut.TabIndex = 1;
- //
- // groupBox3
- //
- this.groupBox3.Controls.Add(this.MaxBadCommands);
- this.groupBox3.Location = new System.Drawing.Point(376, 16);
- this.groupBox3.Name = "groupBox3";
- this.groupBox3.Size = new System.Drawing.Size(384, 72);
- this.groupBox3.TabIndex = 2;
- this.groupBox3.TabStop = false;
- this.groupBox3.Text = "Max bad commands (maximum number of commands errors/session)";
- //
- // MaxBadCommands
- //
- this.MaxBadCommands.Location = new System.Drawing.Point(128, 32);
- this.MaxBadCommands.Maximum = new System.Decimal(new int[] {
- 99999,
- 0,
- 0,
- 0});
- this.MaxBadCommands.Name = "MaxBadCommands";
- this.MaxBadCommands.TabIndex = 2;
- //
- // groupBox4
- //
- this.groupBox4.Controls.Add(this.MaxThreads);
- this.groupBox4.Location = new System.Drawing.Point(376, 104);
- this.groupBox4.Name = "groupBox4";
- this.groupBox4.Size = new System.Drawing.Size(384, 72);
- this.groupBox4.TabIndex = 3;
- this.groupBox4.TabStop = false;
- this.groupBox4.Text = "Max Threads ( = max Clients)";
- //
- // MaxThreads
- //
- this.MaxThreads.Location = new System.Drawing.Point(128, 32);
- this.MaxThreads.Maximum = new System.Decimal(new int[] {
- 1410065407,
- 2,
- 0,
- 0});
- this.MaxThreads.Name = "MaxThreads";
- this.MaxThreads.TabIndex = 3;
- //
- // groupBox5
- //
- this.groupBox5.Controls.Add(this.Port);
- this.groupBox5.Controls.Add(this.IPAddress);
- this.groupBox5.Location = new System.Drawing.Point(24, 192);
- this.groupBox5.Name = "groupBox5";
- this.groupBox5.Size = new System.Drawing.Size(344, 72);
- this.groupBox5.TabIndex = 4;
- this.groupBox5.TabStop = false;
- this.groupBox5.Text = "IP Address and Port (listener address)";
- //
- // Port
- //
- this.Port.Location = new System.Drawing.Point(200, 32);
- this.Port.Maximum = new System.Decimal(new int[] {
- 64000,
- 0,
- 0,
- 0});
- this.Port.Name = "Port";
- this.Port.Size = new System.Drawing.Size(56, 20);
- this.Port.TabIndex = 4;
- //
- // IPAddress
- //
- this.IPAddress.Location = new System.Drawing.Point(40, 32);
- this.IPAddress.Name = "IPAddress";
- this.IPAddress.Size = new System.Drawing.Size(121, 21);
- this.IPAddress.TabIndex = 0;
- //
- // groupBox7
- //
- this.groupBox7.Controls.Add(this.ServiceRestart);
- this.groupBox7.Controls.Add(this.ServiceStop);
- this.groupBox7.Controls.Add(this.ServiceStart);
- this.groupBox7.Location = new System.Drawing.Point(376, 192);
- this.groupBox7.Name = "groupBox7";
- this.groupBox7.Size = new System.Drawing.Size(344, 80);
- this.groupBox7.TabIndex = 6;
- this.groupBox7.TabStop = false;
- this.groupBox7.Text = "Service Controls";
- //
- // ServiceRestart
- //
- this.ServiceRestart.Location = new System.Drawing.Point(224, 48);
- this.ServiceRestart.Name = "ServiceRestart";
- this.ServiceRestart.TabIndex = 2;
- this.ServiceRestart.Text = "Restart";
- this.ServiceRestart.Click += new System.EventHandler(this.ServiceRestart_Click);
- //
- // ServiceStop
- //
- this.ServiceStop.Location = new System.Drawing.Point(128, 48);
- this.ServiceStop.Name = "ServiceStop";
- this.ServiceStop.TabIndex = 1;
- this.ServiceStop.Text = "Stop";
- this.ServiceStop.Click += new System.EventHandler(this.ServiceStop_Click);
- //
- // ServiceStart
- //
- this.ServiceStart.Location = new System.Drawing.Point(40, 48);
- this.ServiceStart.Name = "ServiceStart";
- this.ServiceStart.TabIndex = 0;
- this.ServiceStart.Text = "Start";
- this.ServiceStart.Click += new System.EventHandler(this.ServiceStart_Click);
- //
- // OkButton
- //
- this.OkButton.Location = new System.Drawing.Point(280, 304);
- this.OkButton.Name = "OkButton";
- this.OkButton.TabIndex = 7;
- this.OkButton.Text = "Ok";
- this.OkButton.Click += new System.EventHandler(this.OkButton_Click);
- //
- // ApplyButton
- //
- this.ApplyButton.Location = new System.Drawing.Point(392, 304);
- this.ApplyButton.Name = "ApplyButton";
- this.ApplyButton.TabIndex = 8;
- this.ApplyButton.Text = "Apply";
- this.ApplyButton.Click += new System.EventHandler(this.ApplyButton_Click);
- //
- // tabControl1
- //
- this.tabControl1.Controls.Add(this.serverTab);
- this.tabControl1.Controls.Add(this.homesTab);
- this.tabControl1.Controls.Add(this.VPathTab);
- this.tabControl1.Location = new System.Drawing.Point(0, 0);
- this.tabControl1.Name = "tabControl1";
- this.tabControl1.SelectedIndex = 0;
- this.tabControl1.Size = new System.Drawing.Size(792, 376);
- this.tabControl1.TabIndex = 9;
- //
- // serverTab
- //
- this.serverTab.Controls.Add(this.groupBox1);
- this.serverTab.Controls.Add(this.groupBox2);
- this.serverTab.Controls.Add(this.groupBox3);
- this.serverTab.Controls.Add(this.groupBox4);
- this.serverTab.Controls.Add(this.groupBox5);
- this.serverTab.Controls.Add(this.groupBox7);
- this.serverTab.Controls.Add(this.OkButton);
- this.serverTab.Controls.Add(this.ApplyButton);
- this.serverTab.Location = new System.Drawing.Point(4, 22);
- this.serverTab.Name = "serverTab";
- this.serverTab.Size = new System.Drawing.Size(784, 350);
- this.serverTab.TabIndex = 0;
- this.serverTab.Text = "Server";
- //
- // homesTab
- //
- this.homesTab.Controls.Add(this.button1);
- this.homesTab.Controls.Add(this.button2);
- this.homesTab.Controls.Add(this.homesGrid);
- this.homesTab.Controls.Add(this.groupBox6);
- this.homesTab.Location = new System.Drawing.Point(4, 22);
- this.homesTab.Name = "homesTab";
- this.homesTab.Size = new System.Drawing.Size(784, 350);
- this.homesTab.TabIndex = 1;
- this.homesTab.Text = "Root Paths";
- //
- // button1
- //
- this.button1.Location = new System.Drawing.Point(288, 304);
- this.button1.Name = "button1";
- this.button1.TabIndex = 9;
- this.button1.Text = "Ok";
- this.button1.Click += new System.EventHandler(this.OkButton_Click);
- //
- // button2
- //
- this.button2.Location = new System.Drawing.Point(400, 304);
- this.button2.Name = "button2";
- this.button2.TabIndex = 10;
- this.button2.Text = "Apply";
- this.button2.Click += new System.EventHandler(this.ApplyButton_Click);
- //
- // homesGrid
- //
- this.homesGrid.CaptionVisible = false;
- this.homesGrid.DataMember = "";
- this.homesGrid.DataSource = this.HomesView;
- this.homesGrid.HeaderForeColor = System.Drawing.SystemColors.ControlText;
- this.homesGrid.Location = new System.Drawing.Point(8, 96);
- this.homesGrid.Name = "homesGrid";
- this.homesGrid.ParentRowsVisible = false;
- this.homesGrid.Size = new System.Drawing.Size(768, 192);
- this.homesGrid.TabIndex = 1;
- //
- // groupBox6
- //
- this.groupBox6.Controls.Add(this.DefPathButton);
- this.groupBox6.Controls.Add(this.DefaultPath);
- this.groupBox6.Location = new System.Drawing.Point(8, 16);
- this.groupBox6.Name = "groupBox6";
- this.groupBox6.Size = new System.Drawing.Size(456, 64);
- this.groupBox6.TabIndex = 0;
- this.groupBox6.TabStop = false;
- this.groupBox6.Text = "Default Path";
- //
- // DefPathButton
- //
- this.DefPathButton.Location = new System.Drawing.Point(368, 24);
- this.DefPathButton.Name = "DefPathButton";
- this.DefPathButton.TabIndex = 1;
- this.DefPathButton.Text = "Browse";
- //
- // DefaultPath
- //
- this.DefaultPath.Location = new System.Drawing.Point(8, 24);
- this.DefaultPath.Name = "DefaultPath";
- this.DefaultPath.Size = new System.Drawing.Size(336, 20);
- this.DefaultPath.TabIndex = 0;
- this.DefaultPath.Text = "";
- //
- // VPathTab
- //
- this.VPathTab.Controls.Add(this.groupBox9);
- this.VPathTab.Controls.Add(this.groupBox8);
- this.VPathTab.Controls.Add(this.AddPersonalVpaths);
- this.VPathTab.Controls.Add(this.VPathsNewUserTxtBox);
- this.VPathTab.Controls.Add(this.VPathsUsersListBox);
- this.VPathTab.Controls.Add(this.button3);
- this.VPathTab.Controls.Add(this.button4);
- this.VPathTab.Location = new System.Drawing.Point(4, 22);
- this.VPathTab.Name = "VPathTab";
- this.VPathTab.Size = new System.Drawing.Size(784, 350);
- this.VPathTab.TabIndex = 2;
- this.VPathTab.Text = "Virtual Paths";
- //
- // AddPersonalVpaths
- //
- this.AddPersonalVpaths.Location = new System.Drawing.Point(32, 288);
- this.AddPersonalVpaths.Name = "AddPersonalVpaths";
- this.AddPersonalVpaths.Size = new System.Drawing.Size(136, 23);
- this.AddPersonalVpaths.TabIndex = 16;
- this.AddPersonalVpaths.Text = "Add";
- this.AddPersonalVpaths.Click += new System.EventHandler(this.AddPersonalVpaths_Click);
- //
- // VPathsNewUserTxtBox
- //
- this.VPathsNewUserTxtBox.Location = new System.Drawing.Point(32, 256);
- this.VPathsNewUserTxtBox.Name = "VPathsNewUserTxtBox";
- this.VPathsNewUserTxtBox.Size = new System.Drawing.Size(136, 20);
- this.VPathsNewUserTxtBox.TabIndex = 15;
- this.VPathsNewUserTxtBox.Text = "";
- //
- // VPathsUsersListBox
- //
- this.VPathsUsersListBox.Location = new System.Drawing.Point(32, 160);
- this.VPathsUsersListBox.Name = "VPathsUsersListBox";
- this.VPathsUsersListBox.Size = new System.Drawing.Size(136, 82);
- this.VPathsUsersListBox.TabIndex = 14;
- this.VPathsUsersListBox.SelectedIndexChanged += new System.EventHandler(this.VPathsUsersListBox_SelectedIndexChanged);
- //
- // DefaultVPathsGrid
- //
- this.DefaultVPathsGrid.DataMember = "";
- this.DefaultVPathsGrid.DataSource = this.VPathsDataSet;
- this.DefaultVPathsGrid.HeaderForeColor = System.Drawing.SystemColors.ControlText;
- this.DefaultVPathsGrid.Location = new System.Drawing.Point(8, 16);
- this.DefaultVPathsGrid.Name = "DefaultVPathsGrid";
- this.DefaultVPathsGrid.PreferredColumnWidth = 350;
- this.DefaultVPathsGrid.Size = new System.Drawing.Size(720, 112);
- this.DefaultVPathsGrid.TabIndex = 13;
- //
- // button3
- //
- this.button3.Location = new System.Drawing.Point(280, 304);
- this.button3.Name = "button3";
- this.button3.TabIndex = 11;
- this.button3.Text = "Ok";
- this.button3.Click += new System.EventHandler(this.OkButton_Click);
- //
- // button4
- //
- this.button4.Location = new System.Drawing.Point(392, 304);
- this.button4.Name = "button4";
- this.button4.TabIndex = 12;
- this.button4.Text = "Apply";
- this.button4.Click += new System.EventHandler(this.ApplyButton_Click);
- //
- // PrivateVPathsGrid
- //
- this.PrivateVPathsGrid.DataMember = "";
- this.PrivateVPathsGrid.DataSource = this.VPathsDataSet;
- this.PrivateVPathsGrid.HeaderForeColor = System.Drawing.SystemColors.ControlText;
- this.PrivateVPathsGrid.Location = new System.Drawing.Point(8, 16);
- this.PrivateVPathsGrid.Name = "PrivateVPathsGrid";
- this.PrivateVPathsGrid.PreferredColumnWidth = 275;
- this.PrivateVPathsGrid.Size = new System.Drawing.Size(552, 112);
- this.PrivateVPathsGrid.TabIndex = 13;
- //
- // VPathsDataSet
- //
- this.VPathsDataSet.DataSetName = "VPaths";
- this.VPathsDataSet.Locale = new System.Globalization.CultureInfo("fr-FR");
- //
- // groupBox8
- //
- this.groupBox8.Controls.Add(this.DefaultVPathsGrid);
- this.groupBox8.Location = new System.Drawing.Point(16, 8);
- this.groupBox8.Name = "groupBox8";
- this.groupBox8.Size = new System.Drawing.Size(736, 136);
- this.groupBox8.TabIndex = 17;
- this.groupBox8.TabStop = false;
- this.groupBox8.Text = "Global Virtual Paths";
- //
- // groupBox9
- //
- this.groupBox9.Controls.Add(this.PrivateVPathsGrid);
- this.groupBox9.Location = new System.Drawing.Point(184, 152);
- this.groupBox9.Name = "groupBox9";
- this.groupBox9.Size = new System.Drawing.Size(568, 136);
- this.groupBox9.TabIndex = 18;
- this.groupBox9.TabStop = false;
- this.groupBox9.Text = "Personal Virtual Paths";
- //
- // SharpFtpConfig
- //
- this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
- this.ClientSize = new System.Drawing.Size(792, 374);
- this.Controls.Add(this.tabControl1);
- this.Name = "SharpFtpConfig";
- this.Text = "Ftp Dot Net Configurator";
- this.groupBox1.ResumeLayout(false);
- ((System.ComponentModel.ISupportInitialize)(this.CommandTimeOut)).EndInit();
- this.groupBox2.ResumeLayout(false);
- ((System.ComponentModel.ISupportInitialize)(this.SessionTimeOut)).EndInit();
- this.groupBox3.ResumeLayout(false);
- ((System.ComponentModel.ISupportInitialize)(this.MaxBadCommands)).EndInit();
- this.groupBox4.ResumeLayout(false);
- ((System.ComponentModel.ISupportInitialize)(this.MaxThreads)).EndInit();
- this.groupBox5.ResumeLayout(false);
- ((System.ComponentModel.ISupportInitialize)(this.Port)).EndInit();
- this.groupBox7.ResumeLayout(false);
- this.tabControl1.ResumeLayout(false);
- this.serverTab.ResumeLayout(false);
- this.homesTab.ResumeLayout(false);
- ((System.ComponentModel.ISupportInitialize)(this.homesGrid)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.HomesView)).EndInit();
- this.groupBox6.ResumeLayout(false);
- this.VPathTab.ResumeLayout(false);
- ((System.ComponentModel.ISupportInitialize)(this.DefaultVPathsGrid)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.PrivateVPathsGrid)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.VPathsDataSet)).EndInit();
- this.groupBox8.ResumeLayout(false);
- this.groupBox9.ResumeLayout(false);
- this.ResumeLayout(false);
- }
- #endregion
- private void ServiceStart_Click(object sender, System.EventArgs e)
- {
- this._ftpSc.Start();
- this._ftpSc.WaitForStatus(ServiceControllerStatus.Running);
- this.UpdateServiceState();
- }
- private void ServiceStop_Click(object sender, System.EventArgs e)
- {
- this._ftpSc.Stop();
- this._ftpSc.WaitForStatus(ServiceControllerStatus.Stopped);
- this.UpdateServiceState();
- }
- private void ServiceRestart_Click(object sender, System.EventArgs e)
- {
- this._ftpSc.Stop();
- this._ftpSc.WaitForStatus(ServiceControllerStatus.Stopped);
- this._ftpSc.Start();
- this._ftpSc.WaitForStatus(ServiceControllerStatus.Running);
- this.UpdateServiceState();
- }
- private void ApplyButton_Click(object sender, System.EventArgs e)
- {
- this.ApplyValues();
- this.ApplyHomes();
- this.SaveVPaths();
- this.DisplayValues();
- }
- private void OkButton_Click(object sender, System.EventArgs e)
- {
- this.ApplyValues();
- this.ApplyHomes();
- this.SaveVPaths();
- this.DisplayValues();
- Application.Exit();
- }
- private void AddPersonalVpaths_Click(object sender, System.EventArgs e)
- {
- if(this.VPathsNewUserTxtBox.Text.Trim()!="")
- {
- this.VPathsUsersListBox.Items.Add(this.VPathsNewUserTxtBox.Text);
- }
- }
- private void VPathsUsersListBox_SelectedIndexChanged(object sender, System.EventArgs e)
- {
- ListBox list=(ListBox)sender;
- if(this.VPathsDataSet.Tables.Contains((string)list.SelectedItem))
- this.PrivateVPathsGrid.DataMember=(string)list.SelectedItem;
- else
- {
- this.VPathsDataSet.Tables.Add((string)list.SelectedItem);
- this.VPathsDataSet.Tables[(string)list.SelectedItem].Columns.Add("source");
- this.VPathsDataSet.Tables[(string)list.SelectedItem].Columns.Add("target");
- this.PrivateVPathsGrid.DataMember=(string)list.SelectedItem;
- }
- }
- }
- }