diff --git a/IISAbout/IISOperation.cs b/IISAbout/IISOperation.cs
index 7788516..f0dcbd2 100644
--- a/IISAbout/IISOperation.cs
+++ b/IISAbout/IISOperation.cs
@@ -6,6 +6,7 @@
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Web.Administration;
+using Microsoft.Win32;
namespace Beinet.cn.Tools.IISAbout
{
@@ -30,6 +31,30 @@ public IISOperation(string serverIp = "127.0.0.1")
ServerIp = serverIp;
}
+ ///
+ /// 获取IIS版本
+ ///
+ ///
+ public Version GetIisVersion()
+ {
+ using (var componentsKey = Registry.LocalMachine.OpenSubKey(@"Software\Microsoft\InetStp", false))
+ {
+ if (componentsKey != null)
+ {
+ int majorVersion = (int)componentsKey.GetValue("MajorVersion", -1);
+ int minorVersion = (int)componentsKey.GetValue("MinorVersion", -1);
+
+ if (majorVersion != -1 && minorVersion != -1)
+ {
+ return new Version(majorVersion, minorVersion);
+ }
+ }
+
+ return new Version(0, 0);
+ }
+ }
+
+
///
/// 获取所有站点列表返回
///
@@ -39,7 +64,7 @@ public List ListSite()
var ret = new List();
using (var sm = ServerManager.OpenRemote(ServerIp))
{
- foreach (Microsoft.Web.Administration.Site iissite in sm.Sites)
+ foreach (Microsoft.Web.Administration.Site iissite in sm.Sites.OrderBy(item => item.Name))
{
var site = BindSite(iissite, sm);
if (site != null)
@@ -69,17 +94,28 @@ Site BindSite(Microsoft.Web.Administration.Site iissite, ServerManager sm)
}
var defaultApp = iissite.Applications[SITE_KEY];
var defaultVirDir = defaultApp.VirtualDirectories[SITE_KEY];
+ int state;
+ try
+ {
+ state = (int) iissite.State;
+ }
+ catch
+ {
+ // 注意:ftp站点会抛异常,ftp状态要用 iissite.GetChildElement("ftpServer")["state"]
+ state = -1;
+ }
var site = new Site()
{
Id = iissite.Id,
Name = iissite.Name,
- State = (int)iissite.State,
+ State = state,
Dir = defaultVirDir.PhysicalPath,
- Bindings = GetBinding(iissite.Bindings),
+ Bindings = GetBinding(iissite.Bindings, out var isHttp),
PoolName = defaultApp.ApplicationPoolName,
ConnectionTimeOut = (int)iissite.Limits.ConnectionTimeout.TotalSeconds,
};
site.LogDir = iissite.LogFile.Enabled ? iissite.LogFile.Directory + "\\W3SVC" + site.Id.ToString() : "";
+ site.IsHttp = isHttp;
try
{
// 读取是否启用预加载
@@ -112,6 +148,7 @@ public bool StopSite(string name, int waitSecond = 10)
if (site.State == ObjectState.Stopped)
return true;
site.Stop();
+ Utility.Log("stop site:" + name);
return (CheckState(site, ObjectState.Stopped, waitSecond));
}
}
@@ -130,6 +167,7 @@ public bool StartSite(string name, int waitSecond = 10)
if (site.State == ObjectState.Started)
return true;
site.Start();
+ Utility.Log("start site:" + name);
return (CheckState(site, ObjectState.Started, waitSecond));
}
}
@@ -158,6 +196,7 @@ public int RestartSite(string name, int waitSecond = 10)
return 2;
}
}
+ Utility.Log("restart site:" + name);
return 0;
}
@@ -203,6 +242,8 @@ public string CreateSite(string name, string sitePath, string binding,
SetPoolRecyleTime(pool, recyleTimes);
sm.CommitChanges();
}
+ Utility.Log($"create site:{name},{sitePath},{binding},{poolname},{preloadEnabled}," +
+ $"{timeoutSeconds},{recyleTimes}");
return "OK";
}
@@ -244,6 +285,8 @@ public string UpdateSite(string name, string sitePath, string binding,
SetPoolRecyleTime(pool, recyleTimes);
sm.CommitChanges();
}
+ Utility.Log($"update site:{name},{sitePath},{binding},{poolname},{preloadEnabled}," +
+ $"{timeoutSeconds},{recyleTimes}");
return "OK";
}
@@ -288,6 +331,7 @@ List SplitBind(string binding)
///
public string StopSite(bool startLater, params string[] siteNames)
{
+ int ok = 0, fail = 0, noop = 0;
var ret = new StringBuilder();
var waitSecond = 30;
using (var sm = ServerManager.OpenRemote(ServerIp))
@@ -314,8 +358,17 @@ public string StopSite(bool startLater, params string[] siteNames)
if (!CheckState(site, ObjectState.Stopped, waitSecond))
{
ret.AppendFormat("site:{0},", site.Name);
+ fail++;
+ }
+ else
+ {
+ ok++;
}
}
+ else
+ {
+ noop++;
+ }
}
catch (Exception)
{
@@ -339,7 +392,16 @@ public string StopSite(bool startLater, params string[] siteNames)
if (!CheckState(pool, ObjectState.Stopped, waitSecond))
{
ret.AppendFormat("pool:{0},", pool.Name);
+ fail++;
}
+ else
+ {
+ ok++;
+ }
+ }
+ else
+ {
+ noop++;
}
}
catch (Exception)
@@ -352,6 +414,13 @@ public string StopSite(bool startLater, params string[] siteNames)
}
});
}
+ if (ret.Length > 0)
+ {
+ ret.Insert(0, "操作失败列表:\r\n");
+ }
+ var strCnt = $"成功/失败/无操作:{ok.ToString()}/{fail.ToString()}/{noop.ToString()}\r\n";
+ ret.Insert(0, strCnt);
+ Utility.Log("StopSite:" + startLater + "\r\n" + ret);
return ret.ToString();
}
@@ -362,10 +431,10 @@ public string StopSite(bool startLater, params string[] siteNames)
///
public string StartSitePreload(params string[] sites)
{
+ int ok = 0, fail = 0, noop = 0;
var ret = new StringBuilder();
using (var sm = ServerManager.OpenRemote(ServerIp))
{
-
foreach (var site in sm.Sites)
{
if (sites == null || sites.Length == 0 || sites.Contains(site.Name))
@@ -373,16 +442,80 @@ public string StartSitePreload(params string[] sites)
try
{
var defaultApp = site.Applications[SITE_KEY];
- defaultApp.SetAttributeValue("preloadEnabled", true);
+ if ((bool) defaultApp.GetAttributeValue("preloadEnabled"))
+ {
+ noop++;
+ }
+ else
+ {
+ defaultApp.SetAttributeValue("preloadEnabled", true);
+ ok++;
+ }
}
catch
{
+ fail++;
ret.AppendFormat("{0},", site.Name);
}
}
}
sm.CommitChanges();
}
+ if (ret.Length > 0)
+ {
+ ret.Insert(0, "操作失败列表:\r\n");
+ }
+ var strCnt = $"成功/失败/无操作:{ok.ToString()}/{fail.ToString()}/{noop.ToString()}\r\n";
+ ret.Insert(0, strCnt);
+ Utility.Log("批量启动站点预加载:\r\n" + ret);
+ return ret.ToString();
+ }
+
+ ///
+ /// 根据站点名创建程序池,并修改站点的程序池
+ ///
+ ///
+ ///
+ public string ModiSitesPool(params string[] sites)
+ {
+ int ok = 0, fail = 0, noop = 0;
+ var ret = new StringBuilder();
+ using (var sm = ServerManager.OpenRemote(ServerIp))
+ {
+ foreach (var site in sm.Sites)
+ {
+ if (sites == null || sites.Length == 0 || sites.Contains(site.Name))
+ {
+ try
+ {
+ var defaultApp = site.Applications[SITE_KEY];
+ if (defaultApp.ApplicationPoolName == site.Name)
+ {
+ noop++;
+ }
+ else
+ {
+ CreatePool(site.Name, sm);
+ defaultApp.ApplicationPoolName = site.Name;
+ ok++;
+ }
+ }
+ catch(Exception)
+ {
+ fail++;
+ ret.AppendFormat("{0},", site.Name);
+ }
+ }
+ }
+ sm.CommitChanges();
+ }
+ if (ret.Length > 0)
+ {
+ ret.Insert(0, "操作失败列表:\r\n");
+ }
+ var strCnt = $"成功/失败/无操作:{ok.ToString()}/{fail.ToString()}/{noop.ToString()}\r\n";
+ ret.Insert(0, strCnt);
+ Utility.Log("修改站点为同名程序池:\r\n" + ret);
return ret.ToString();
}
#endregion
@@ -390,7 +523,59 @@ public string StartSitePreload(params string[] sites)
#region 程序池操作
- void SetPoolRecyleTime(ApplicationPool pool, string times)
+ ///
+ /// 批量设置站点对应的程序池回收时间
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public string SetPoolsRecyleTime(int hour, int minute, int diffMinute, params string[] sites)
+ {
+ int ok = 0, fail = 0;
+ var ret = new StringBuilder();
+ var logMsg = new StringBuilder("批量设置程序池回收时间:\r\n");
+ var ts = new TimeSpan(hour, minute, 0);
+ var addTs = TimeSpan.FromMinutes(diffMinute);
+ using (var sm = ServerManager.OpenRemote(ServerIp))
+ {
+ foreach (var site in sm.Sites.OrderBy(item => item.Name))
+ {
+ if (sites == null || sites.Length == 0 || sites.Contains(site.Name))
+ {
+ try
+ {
+ var poolName = site.Applications[SITE_KEY].ApplicationPoolName;
+ var pool = sm.ApplicationPools[poolName];
+ logMsg.AppendFormat("{0}-Pool:{1} :{2}\r\n", site.Name, pool.Name, ts.ToString());
+ pool.Recycling.PeriodicRestart.Schedule.Clear();
+ pool.Recycling.PeriodicRestart.Schedule.Add(ts);
+ ok++;
+ }
+ catch
+ {
+ fail++;
+ ret.AppendFormat("{0},", site.Name);
+ }
+ }
+ ts = ts.Add(addTs);
+ }
+ sm.CommitChanges();
+ }
+
+ if (ret.Length > 0)
+ {
+ ret.Insert(0, "操作失败列表:\r\n");
+ }
+ var strCnt = $"成功/失败:{ok.ToString()}/{fail.ToString()}\r\n";
+ ret.Insert(0, strCnt);
+ Utility.Log(logMsg + "\r\n" + ret);
+ return ret.ToString();
+ }
+
+
+ private void SetPoolRecyleTime(ApplicationPool pool, string times)
{
pool.Recycling.PeriodicRestart.Schedule.Clear();
foreach (var item in times.Split(';'))
@@ -402,7 +587,7 @@ void SetPoolRecyleTime(ApplicationPool pool, string times)
}
}
- ApplicationPool CreatePool(string name, ServerManager sm)
+ private ApplicationPool CreatePool(string name, ServerManager sm)
{
//创建应用程序池
ApplicationPool appPool = sm.ApplicationPools.FirstOrDefault(x => x.Name == name);
@@ -441,6 +626,7 @@ public bool StopPool(string name, int waitSecond = 10)
if (pool.State == ObjectState.Stopped)
return true;
pool.Stop();
+ Utility.Log("stop pool:" + name);
return (CheckState(pool, ObjectState.Stopped, waitSecond));
}
}
@@ -459,6 +645,7 @@ public bool StartPool(string name, int waitSecond = 10)
if (pool.State == ObjectState.Started)
return true;
pool.Start();
+ Utility.Log("start pool:" + name);
return (CheckState(pool, ObjectState.Started, waitSecond));
}
}
@@ -488,6 +675,7 @@ public int RestartPool(string name, int waitSecond = 10)
return 2;
}
}
+ Utility.Log("restart pool:" + name);
return 0;
}
@@ -499,6 +687,7 @@ public int RestartPool(string name, int waitSecond = 10)
///
public string RemovePoolGc(params string[] poolNames)
{
+ int ok = 0, fail = 0, noop = 0;
var ret = new StringBuilder();
using (var sm = ServerManager.OpenRemote(ServerIp))
{
@@ -506,12 +695,34 @@ public string RemovePoolGc(params string[] poolNames)
{
if (poolNames == null || poolNames.Length == 0 || poolNames.Contains(pool.Name))
{
- pool.Recycling.PeriodicRestart.Schedule.Clear();
- ret.AppendFormat("{0},", pool.Name);
+ try
+ {
+ if (pool.Recycling.PeriodicRestart.Schedule.Count > 0)
+ {
+ noop++;
+ }
+ else
+ {
+ ok++;
+ pool.Recycling.PeriodicRestart.Schedule.Clear();
+ }
+ }
+ catch (Exception)
+ {
+ fail++;
+ ret.AppendFormat("{0},", pool.Name);
+ }
}
}
sm.CommitChanges();
}
+ if (ret.Length > 0)
+ {
+ ret.Insert(0, "下列程序池操作失败:\r\n");
+ }
+ var strCnt = $"成功/失败/无操作:{ok.ToString()}/{fail.ToString()}/{noop.ToString()}\r\n";
+ ret.Insert(0, strCnt);
+ Utility.Log("批量删除程序池回收时间设置:\r\n" + ret);
return ret.ToString();
}
#endregion
@@ -552,8 +763,9 @@ bool CheckState(Microsoft.Web.Administration.ApplicationPool pool, ObjectState s
}
- string GetBinding(BindingCollection bindings)
+ string GetBinding(BindingCollection bindings, out bool haveHttp)
{
+ haveHttp = false;
if (bindings == null)
{
return "";
@@ -561,6 +773,8 @@ string GetBinding(BindingCollection bindings)
var sb = new StringBuilder();
foreach (var binding in bindings)
{
+ if (binding.Protocol.StartsWith("http", StringComparison.OrdinalIgnoreCase))
+ haveHttp = true;
sb.AppendFormat("{0}:{1};", binding.Protocol, binding.BindingInformation);
}
return sb.ToString();
@@ -645,11 +859,15 @@ public string StateText
///
public bool Preload { get; set; }
+ ///
+ /// 当前站点是否允许http协议(比如ftp站点就不允许)
+ ///
+ public bool IsHttp { get; set; }
+
public override string ToString()
{
var sb = new StringBuilder();
- sb.AppendFormat(@"站点ID:{0}
-站点名称:{1}
+ sb.AppendFormat(@"ID与名称:{0} {1}
物理目录:{2}
绑定域名:{3}
程序池名:{4}
@@ -667,6 +885,7 @@ public override string ToString()
/**
+ * https://www.cnblogs.com/jjg0519/p/7277971.html
Microsoft.Web.Administration.ServerManager sm = new Microsoft.Web.Administration.ServerManager();
System.Console.WriteLine("应用程序池默认设置:");
diff --git a/IISAbout/IIStool.Designer.cs b/IISAbout/IIStool.Designer.cs
index 23042df..bf70598 100644
--- a/IISAbout/IIStool.Designer.cs
+++ b/IISAbout/IIStool.Designer.cs
@@ -29,7 +29,7 @@ protected override void Dispose(bool disposing)
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
- System.Windows.Forms.TreeNode treeNode1 = new System.Windows.Forms.TreeNode("网站列表");
+ System.Windows.Forms.TreeNode treeNode1 = new System.Windows.Forms.TreeNode("网站列表", 2, 2);
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(IIStool));
this.label1 = new System.Windows.Forms.Label();
this.txtLogFile = new System.Windows.Forms.TextBox();
@@ -45,15 +45,18 @@ private void InitializeComponent()
this.chkTimeAdd8 = new System.Windows.Forms.CheckBox();
this.tabControl1 = new System.Windows.Forms.TabControl();
this.tabPage2 = new System.Windows.Forms.TabPage();
+ this.btnOpen = new System.Windows.Forms.Button();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.btnRestartAll = new System.Windows.Forms.Button();
this.btnStopAll = new System.Windows.Forms.Button();
this.btnCopyAll = new System.Windows.Forms.Button();
- this.btnReset = new System.Windows.Forms.Button();
+ this.btnSetGCTime = new System.Windows.Forms.Button();
+ this.btnModifyPool = new System.Windows.Forms.Button();
this.btnEnableAllPreload = new System.Windows.Forms.Button();
this.btnDelAllGc = new System.Windows.Forms.Button();
this.lstPreView = new System.Windows.Forms.ComboBox();
this.labLogDir = new System.Windows.Forms.LinkLabel();
+ this.btnReset = new System.Windows.Forms.Button();
this.txtTimeout = new System.Windows.Forms.TextBox();
this.txtSitePoolName = new System.Windows.Forms.TextBox();
this.txtGcTime = new System.Windows.Forms.TextBox();
@@ -61,17 +64,9 @@ private void InitializeComponent()
this.txtSiteDir = new System.Windows.Forms.TextBox();
this.labSiteId = new System.Windows.Forms.Label();
this.labSiteStatus = new System.Windows.Forms.Label();
- this.label10 = new System.Windows.Forms.Label();
- this.label11 = new System.Windows.Forms.Label();
- this.label13 = new System.Windows.Forms.Label();
this.txtSiteName = new System.Windows.Forms.TextBox();
- this.label12 = new System.Windows.Forms.Label();
- this.label14 = new System.Windows.Forms.Label();
- this.label9 = new System.Windows.Forms.Label();
- this.label8 = new System.Windows.Forms.Label();
this.treeIISSite = new System.Windows.Forms.TreeView();
this.imageList1 = new System.Windows.Forms.ImageList(this.components);
- this.label7 = new System.Windows.Forms.Label();
this.btnRestartIIS = new System.Windows.Forms.Button();
this.btnStopIIS = new System.Windows.Forms.Button();
this.btnCopyIIS = new System.Windows.Forms.Button();
@@ -79,13 +74,21 @@ private void InitializeComponent()
this.btnUpdate = new System.Windows.Forms.Button();
this.btnNewSite = new System.Windows.Forms.Button();
this.btnListSite = new System.Windows.Forms.Button();
- this.label6 = new System.Windows.Forms.Label();
this.txtIISIP = new System.Windows.Forms.TextBox();
- this.label5 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
+ this.label10 = new System.Windows.Forms.Label();
+ this.label11 = new System.Windows.Forms.Label();
+ this.label13 = new System.Windows.Forms.Label();
+ this.label12 = new System.Windows.Forms.Label();
+ this.label14 = new System.Windows.Forms.Label();
+ this.label9 = new System.Windows.Forms.Label();
+ this.label15 = new System.Windows.Forms.Label();
+ this.label8 = new System.Windows.Forms.Label();
+ this.label7 = new System.Windows.Forms.Label();
+ this.label6 = new System.Windows.Forms.Label();
+ this.label5 = new System.Windows.Forms.Label();
this.tabPage1 = new System.Windows.Forms.TabPage();
this.contextMenuStripIIS = new System.Windows.Forms.ContextMenuStrip(this.components);
- this.label15 = new System.Windows.Forms.Label();
this.tabControl1.SuspendLayout();
this.tabPage2.SuspendLayout();
this.groupBox1.SuspendLayout();
@@ -224,9 +227,11 @@ private void InitializeComponent()
//
// tabPage2
//
+ this.tabPage2.Controls.Add(this.btnOpen);
this.tabPage2.Controls.Add(this.groupBox1);
this.tabPage2.Controls.Add(this.lstPreView);
this.tabPage2.Controls.Add(this.labLogDir);
+ this.tabPage2.Controls.Add(this.btnReset);
this.tabPage2.Controls.Add(this.txtTimeout);
this.tabPage2.Controls.Add(this.txtSitePoolName);
this.tabPage2.Controls.Add(this.txtGcTime);
@@ -264,13 +269,25 @@ private void InitializeComponent()
this.tabPage2.Text = "IIS操作";
this.tabPage2.UseVisualStyleBackColor = true;
//
+ // btnOpen
+ //
+ this.btnOpen.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
+ this.btnOpen.Location = new System.Drawing.Point(663, 93);
+ this.btnOpen.Name = "btnOpen";
+ this.btnOpen.Size = new System.Drawing.Size(69, 23);
+ this.btnOpen.TabIndex = 26;
+ this.btnOpen.Text = "打开目录";
+ this.btnOpen.UseVisualStyleBackColor = true;
+ this.btnOpen.Click += new System.EventHandler(this.btnOpen_Click);
+ //
// groupBox1
//
this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.groupBox1.Controls.Add(this.btnRestartAll);
this.groupBox1.Controls.Add(this.btnStopAll);
this.groupBox1.Controls.Add(this.btnCopyAll);
- this.groupBox1.Controls.Add(this.btnReset);
+ this.groupBox1.Controls.Add(this.btnSetGCTime);
+ this.groupBox1.Controls.Add(this.btnModifyPool);
this.groupBox1.Controls.Add(this.btnEnableAllPreload);
this.groupBox1.Controls.Add(this.btnDelAllGc);
this.groupBox1.Location = new System.Drawing.Point(227, 399);
@@ -282,9 +299,9 @@ private void InitializeComponent()
//
// btnRestartAll
//
- this.btnRestartAll.Location = new System.Drawing.Point(122, 67);
+ this.btnRestartAll.Location = new System.Drawing.Point(370, 14);
this.btnRestartAll.Name = "btnRestartAll";
- this.btnRestartAll.Size = new System.Drawing.Size(110, 43);
+ this.btnRestartAll.Size = new System.Drawing.Size(87, 43);
this.btnRestartAll.TabIndex = 21;
this.btnRestartAll.Text = "重启全部\r\n站点程序池";
this.btnRestartAll.UseVisualStyleBackColor = true;
@@ -292,9 +309,9 @@ private void InitializeComponent()
//
// btnStopAll
//
- this.btnStopAll.Location = new System.Drawing.Point(6, 67);
+ this.btnStopAll.Location = new System.Drawing.Point(280, 14);
this.btnStopAll.Name = "btnStopAll";
- this.btnStopAll.Size = new System.Drawing.Size(110, 43);
+ this.btnStopAll.Size = new System.Drawing.Size(84, 43);
this.btnStopAll.TabIndex = 20;
this.btnStopAll.Text = "停止全部\r\n站点程序池";
this.btnStopAll.UseVisualStyleBackColor = true;
@@ -304,28 +321,38 @@ private void InitializeComponent()
//
this.btnCopyAll.Location = new System.Drawing.Point(6, 14);
this.btnCopyAll.Name = "btnCopyAll";
- this.btnCopyAll.Size = new System.Drawing.Size(110, 43);
+ this.btnCopyAll.Size = new System.Drawing.Size(84, 43);
this.btnCopyAll.TabIndex = 17;
this.btnCopyAll.TabStop = false;
- this.btnCopyAll.Text = "复制全部配置";
+ this.btnCopyAll.Text = "复制\r\n全部配置";
this.btnCopyAll.UseVisualStyleBackColor = true;
this.btnCopyAll.Click += new System.EventHandler(this.btnCopyAll_Click);
//
- // btnReset
+ // btnSetGCTime
//
- this.btnReset.Location = new System.Drawing.Point(412, 14);
- this.btnReset.Name = "btnReset";
- this.btnReset.Size = new System.Drawing.Size(87, 43);
- this.btnReset.TabIndex = 22;
- this.btnReset.Text = "IISReset";
- this.btnReset.UseVisualStyleBackColor = true;
- this.btnReset.Click += new System.EventHandler(this.btnReset_Click);
+ this.btnSetGCTime.Location = new System.Drawing.Point(99, 67);
+ this.btnSetGCTime.Name = "btnSetGCTime";
+ this.btnSetGCTime.Size = new System.Drawing.Size(87, 43);
+ this.btnSetGCTime.TabIndex = 23;
+ this.btnSetGCTime.Text = "回收时间\r\n【批量设置】";
+ this.btnSetGCTime.UseVisualStyleBackColor = true;
+ this.btnSetGCTime.Click += new System.EventHandler(this.btnSetGCTime_Click);
+ //
+ // btnModifyPool
+ //
+ this.btnModifyPool.Location = new System.Drawing.Point(6, 67);
+ this.btnModifyPool.Name = "btnModifyPool";
+ this.btnModifyPool.Size = new System.Drawing.Size(87, 43);
+ this.btnModifyPool.TabIndex = 22;
+ this.btnModifyPool.Text = "批量按网站名设置程序池";
+ this.btnModifyPool.UseVisualStyleBackColor = true;
+ this.btnModifyPool.Click += new System.EventHandler(this.btnModifyPool_Click);
//
// btnEnableAllPreload
//
- this.btnEnableAllPreload.Location = new System.Drawing.Point(238, 14);
+ this.btnEnableAllPreload.Location = new System.Drawing.Point(187, 14);
this.btnEnableAllPreload.Name = "btnEnableAllPreload";
- this.btnEnableAllPreload.Size = new System.Drawing.Size(110, 43);
+ this.btnEnableAllPreload.Size = new System.Drawing.Size(87, 43);
this.btnEnableAllPreload.TabIndex = 19;
this.btnEnableAllPreload.Text = "启用全部\r\n预加载";
this.btnEnableAllPreload.UseVisualStyleBackColor = true;
@@ -333,11 +360,11 @@ private void InitializeComponent()
//
// btnDelAllGc
//
- this.btnDelAllGc.Location = new System.Drawing.Point(122, 14);
+ this.btnDelAllGc.Location = new System.Drawing.Point(95, 14);
this.btnDelAllGc.Name = "btnDelAllGc";
- this.btnDelAllGc.Size = new System.Drawing.Size(110, 43);
+ this.btnDelAllGc.Size = new System.Drawing.Size(87, 43);
this.btnDelAllGc.TabIndex = 18;
- this.btnDelAllGc.Text = "删除全部\r\n回收时间配置";
+ this.btnDelAllGc.Text = "回收时间\r\n【批量删除】";
this.btnDelAllGc.UseVisualStyleBackColor = true;
this.btnDelAllGc.Click += new System.EventHandler(this.btnDelAllGc_Click);
//
@@ -360,9 +387,20 @@ private void InitializeComponent()
this.labLogDir.Name = "labLogDir";
this.labLogDir.Size = new System.Drawing.Size(11, 12);
this.labLogDir.TabIndex = 0;
+ this.labLogDir.TabStop = true;
this.labLogDir.Text = "-";
this.labLogDir.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.labLogDir_LinkClicked);
//
+ // btnReset
+ //
+ this.btnReset.Location = new System.Drawing.Point(307, 9);
+ this.btnReset.Name = "btnReset";
+ this.btnReset.Size = new System.Drawing.Size(129, 23);
+ this.btnReset.TabIndex = 25;
+ this.btnReset.Text = "IISReset";
+ this.btnReset.UseVisualStyleBackColor = true;
+ this.btnReset.Click += new System.EventHandler(this.btnReset_Click);
+ //
// txtTimeout
//
this.txtTimeout.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
@@ -405,7 +443,7 @@ private void InitializeComponent()
| System.Windows.Forms.AnchorStyles.Right)));
this.txtSiteDir.Location = new System.Drawing.Point(319, 95);
this.txtSiteDir.Name = "txtSiteDir";
- this.txtSiteDir.Size = new System.Drawing.Size(413, 21);
+ this.txtSiteDir.Size = new System.Drawing.Size(338, 21);
this.txtSiteDir.TabIndex = 9;
//
// labSiteId
@@ -428,33 +466,6 @@ private void InitializeComponent()
this.labSiteStatus.TabIndex = 0;
this.labSiteStatus.Text = "-";
//
- // label10
- //
- this.label10.AutoSize = true;
- this.label10.Location = new System.Drawing.Point(255, 279);
- this.label10.Name = "label10";
- this.label10.Size = new System.Drawing.Size(65, 12);
- this.label10.TabIndex = 0;
- this.label10.Text = "站点状态:";
- //
- // label11
- //
- this.label11.AutoSize = true;
- this.label11.Location = new System.Drawing.Point(255, 257);
- this.label11.Name = "label11";
- this.label11.Size = new System.Drawing.Size(65, 12);
- this.label11.TabIndex = 0;
- this.label11.Text = "日志目录:";
- //
- // label13
- //
- this.label13.AutoSize = true;
- this.label13.Location = new System.Drawing.Point(237, 152);
- this.label13.Name = "label13";
- this.label13.Size = new System.Drawing.Size(83, 12);
- this.label13.TabIndex = 0;
- this.label13.Text = "连接超时-秒:";
- //
// txtSiteName
//
this.txtSiteName.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
@@ -465,42 +476,6 @@ private void InitializeComponent()
this.txtSiteName.TabIndex = 8;
this.txtSiteName.KeyUp += new System.Windows.Forms.KeyEventHandler(this.txtSiteName_KeyUp);
//
- // label12
- //
- this.label12.AutoSize = true;
- this.label12.Location = new System.Drawing.Point(267, 179);
- this.label12.Name = "label12";
- this.label12.Size = new System.Drawing.Size(53, 12);
- this.label12.TabIndex = 0;
- this.label12.Text = "预加载:";
- //
- // label14
- //
- this.label14.AutoSize = true;
- this.label14.Location = new System.Drawing.Point(230, 234);
- this.label14.Name = "label14";
- this.label14.Size = new System.Drawing.Size(89, 12);
- this.label14.TabIndex = 0;
- this.label14.Text = "特定回收时间:";
- //
- // label9
- //
- this.label9.AutoSize = true;
- this.label9.Location = new System.Drawing.Point(242, 207);
- this.label9.Name = "label9";
- this.label9.Size = new System.Drawing.Size(77, 12);
- this.label9.TabIndex = 0;
- this.label9.Text = "应用程序池:";
- //
- // label8
- //
- this.label8.AutoSize = true;
- this.label8.Location = new System.Drawing.Point(279, 125);
- this.label8.Name = "label8";
- this.label8.Size = new System.Drawing.Size(41, 12);
- this.label8.TabIndex = 0;
- this.label8.Text = "绑定:";
- //
// treeIISSite
//
this.treeIISSite.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
@@ -509,7 +484,9 @@ private void InitializeComponent()
this.treeIISSite.ImageList = this.imageList1;
this.treeIISSite.Location = new System.Drawing.Point(9, 42);
this.treeIISSite.Name = "treeIISSite";
+ treeNode1.ImageIndex = 2;
treeNode1.Name = "iisRootNode";
+ treeNode1.SelectedImageIndex = 2;
treeNode1.Text = "网站列表";
this.treeIISSite.Nodes.AddRange(new System.Windows.Forms.TreeNode[] {
treeNode1});
@@ -527,15 +504,6 @@ private void InitializeComponent()
this.imageList1.Images.SetKeyName(1, "stop.jpg");
this.imageList1.Images.SetKeyName(2, "root.jpg");
//
- // label7
- //
- this.label7.AutoSize = true;
- this.label7.Location = new System.Drawing.Point(279, 98);
- this.label7.Name = "label7";
- this.label7.Size = new System.Drawing.Size(41, 12);
- this.label7.TabIndex = 0;
- this.label7.Text = "目录:";
- //
// btnRestartIIS
//
this.btnRestartIIS.Location = new System.Drawing.Point(620, 40);
@@ -600,21 +568,12 @@ private void InitializeComponent()
//
this.btnListSite.Location = new System.Drawing.Point(173, 9);
this.btnListSite.Name = "btnListSite";
- this.btnListSite.Size = new System.Drawing.Size(87, 23);
+ this.btnListSite.Size = new System.Drawing.Size(124, 23);
this.btnListSite.TabIndex = 2;
- this.btnListSite.Text = "获取站点列表";
+ this.btnListSite.Text = "获取or刷新站点列表";
this.btnListSite.UseVisualStyleBackColor = true;
this.btnListSite.Click += new System.EventHandler(this.btnListSite_Click);
//
- // label6
- //
- this.label6.AutoSize = true;
- this.label6.Location = new System.Drawing.Point(267, 71);
- this.label6.Name = "label6";
- this.label6.Size = new System.Drawing.Size(53, 12);
- this.label6.TabIndex = 0;
- this.label6.Text = "网站名:";
- //
// txtIISIP
//
this.txtIISIP.Location = new System.Drawing.Point(67, 9);
@@ -624,15 +583,6 @@ private void InitializeComponent()
this.txtIISIP.TabIndex = 1;
this.txtIISIP.Text = "127.0.0.1";
//
- // label5
- //
- this.label5.AutoSize = true;
- this.label5.Location = new System.Drawing.Point(267, 45);
- this.label5.Name = "label5";
- this.label5.Size = new System.Drawing.Size(53, 12);
- this.label5.TabIndex = 0;
- this.label5.Text = "网站ID:";
- //
// label4
//
this.label4.AutoSize = true;
@@ -642,6 +592,108 @@ private void InitializeComponent()
this.label4.TabIndex = 0;
this.label4.Text = "服务器IP:";
//
+ // label10
+ //
+ this.label10.AutoSize = true;
+ this.label10.Location = new System.Drawing.Point(255, 279);
+ this.label10.Name = "label10";
+ this.label10.Size = new System.Drawing.Size(65, 12);
+ this.label10.TabIndex = 0;
+ this.label10.Text = "站点状态:";
+ //
+ // label11
+ //
+ this.label11.AutoSize = true;
+ this.label11.Location = new System.Drawing.Point(255, 257);
+ this.label11.Name = "label11";
+ this.label11.Size = new System.Drawing.Size(65, 12);
+ this.label11.TabIndex = 0;
+ this.label11.Text = "日志目录:";
+ //
+ // label13
+ //
+ this.label13.AutoSize = true;
+ this.label13.Location = new System.Drawing.Point(237, 152);
+ this.label13.Name = "label13";
+ this.label13.Size = new System.Drawing.Size(83, 12);
+ this.label13.TabIndex = 0;
+ this.label13.Text = "连接超时-秒:";
+ //
+ // label12
+ //
+ this.label12.AutoSize = true;
+ this.label12.Location = new System.Drawing.Point(267, 179);
+ this.label12.Name = "label12";
+ this.label12.Size = new System.Drawing.Size(53, 12);
+ this.label12.TabIndex = 0;
+ this.label12.Text = "预加载:";
+ //
+ // label14
+ //
+ this.label14.AutoSize = true;
+ this.label14.Location = new System.Drawing.Point(230, 234);
+ this.label14.Name = "label14";
+ this.label14.Size = new System.Drawing.Size(89, 12);
+ this.label14.TabIndex = 0;
+ this.label14.Text = "特定回收时间:";
+ //
+ // label9
+ //
+ this.label9.AutoSize = true;
+ this.label9.Location = new System.Drawing.Point(242, 207);
+ this.label9.Name = "label9";
+ this.label9.Size = new System.Drawing.Size(77, 12);
+ this.label9.TabIndex = 0;
+ this.label9.Text = "应用程序池:";
+ //
+ // label15
+ //
+ this.label15.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
+ this.label15.AutoSize = true;
+ this.label15.ForeColor = System.Drawing.Color.Red;
+ this.label15.Location = new System.Drawing.Point(422, 149);
+ this.label15.Name = "label15";
+ this.label15.Size = new System.Drawing.Size(215, 48);
+ this.label15.TabIndex = 0;
+ this.label15.Text = "绑定格式:协议:IP:端口:主机名,如:\r\nhttp:*:80:a.1.com\r\nhttp:*:80:;\r\nhttps:10.8.0.18:443:cc.dd.e" +
+ "e.com";
+ //
+ // label8
+ //
+ this.label8.AutoSize = true;
+ this.label8.Location = new System.Drawing.Point(279, 125);
+ this.label8.Name = "label8";
+ this.label8.Size = new System.Drawing.Size(41, 12);
+ this.label8.TabIndex = 0;
+ this.label8.Text = "绑定:";
+ //
+ // label7
+ //
+ this.label7.AutoSize = true;
+ this.label7.Location = new System.Drawing.Point(279, 98);
+ this.label7.Name = "label7";
+ this.label7.Size = new System.Drawing.Size(41, 12);
+ this.label7.TabIndex = 0;
+ this.label7.Text = "目录:";
+ //
+ // label6
+ //
+ this.label6.AutoSize = true;
+ this.label6.Location = new System.Drawing.Point(267, 71);
+ this.label6.Name = "label6";
+ this.label6.Size = new System.Drawing.Size(53, 12);
+ this.label6.TabIndex = 0;
+ this.label6.Text = "网站名:";
+ //
+ // label5
+ //
+ this.label5.AutoSize = true;
+ this.label5.Location = new System.Drawing.Point(267, 45);
+ this.label5.Name = "label5";
+ this.label5.Size = new System.Drawing.Size(53, 12);
+ this.label5.TabIndex = 0;
+ this.label5.Text = "网站ID:";
+ //
// tabPage1
//
this.tabPage1.Controls.Add(this.txtRet);
@@ -669,17 +721,6 @@ private void InitializeComponent()
this.contextMenuStripIIS.Name = "contextMenuStripIIS";
this.contextMenuStripIIS.Size = new System.Drawing.Size(61, 4);
this.contextMenuStripIIS.ItemClicked += new System.Windows.Forms.ToolStripItemClickedEventHandler(this.contextMenuStripIIS_ItemClicked);
- //
- // label15
- //
- this.label15.AutoSize = true;
- this.label15.ForeColor = System.Drawing.Color.Red;
- this.label15.Location = new System.Drawing.Point(414, 149);
- this.label15.Name = "label15";
- this.label15.Size = new System.Drawing.Size(215, 48);
- this.label15.TabIndex = 0;
- this.label15.Text = "绑定格式:协议:IP:端口:主机名,如:\r\nhttp:*:80:a.1.com\r\nhttp:*:80:;\r\nhttps:10.8.0.18:443:cc.dd.e" +
- "e.com";
//
// IIStool
//
@@ -757,5 +798,8 @@ private void InitializeComponent()
private System.Windows.Forms.Button btnUpdate;
private System.Windows.Forms.Button btnEnableAllPreload;
private System.Windows.Forms.Label label15;
+ private System.Windows.Forms.Button btnModifyPool;
+ private System.Windows.Forms.Button btnSetGCTime;
+ private System.Windows.Forms.Button btnOpen;
}
}
\ No newline at end of file
diff --git a/IISAbout/IIStool.cs b/IISAbout/IIStool.cs
index 6fbfcf5..9efeb90 100644
--- a/IISAbout/IIStool.cs
+++ b/IISAbout/IIStool.cs
@@ -7,6 +7,7 @@
using System.IO;
using System.Linq;
using System.Text;
+using System.Text.RegularExpressions;
using System.Threading;
using System.Windows.Forms;
@@ -54,6 +55,8 @@ private void btnListSite_Click(object sender, EventArgs e)
root.Nodes.Clear();
_operation = new IISOperation(txtIISIP.Text);
+ root.Text = "IIS-" + _operation.GetIisVersion().ToString();
+
var sites = _operation.ListSite();
_arrSites = sites.ToDictionary(item => item.Name);
foreach (var site in sites)
@@ -130,14 +133,7 @@ private void btnCopyIIS_Click(object sender, EventArgs e)
private void labLogDir_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
- // %SystemDrive%环境变量转换
- var dir = Environment.ExpandEnvironmentVariables(labLogDir.Text);
- if (!Directory.Exists(dir))
- {
- Alert("目录不存在:" + dir);
- return;
- }
- Process.Start("explorer", dir);
+ Utility.OpenDir(labLogDir.Text);
}
private void btnNewSite_Click(object sender, EventArgs e)
@@ -272,7 +268,7 @@ private void btnDelAllGc_Click(object sender, EventArgs e)
return;
}
var ret = _operation.RemovePoolGc();
- Alert("下列程序池已取消特定时间回收配置:\n" + ret);
+ Alert(ret);
}
private void btnStopAll_Click(object sender, EventArgs e)
@@ -289,14 +285,7 @@ private void btnStopAll_Click(object sender, EventArgs e)
}
var begin = DateTime.Now;
var ret = _operation.StopSite(false);
- if (ret.Length == 0)
- {
- Alert("全部停止完成", begin);
- }
- else
- {
- Alert("下列站点或程序池停止失败:\n" + ret, begin);
- }
+ Alert(ret, begin);
}
@@ -340,14 +329,61 @@ private void btnEnableAllPreload_Click(object sender, EventArgs e)
}
var begin = DateTime.Now;
var ret = _operation.StartSitePreload();
- if (ret.Length == 0)
+ Alert(ret, begin);
+ }
+ private void btnModifyPool_Click(object sender, EventArgs e)
+ {
+ if (_operation == null)
{
- Alert("全部开启完成", begin);
+ Alert("请先连接服务器");
+ return;
}
- else
+ if (!Confirm("按每个网站名创建程序池,并把网站绑定到该程序池,确认要继续吗?\r\n已存在的程序池不会新建,直接使用。"))
+ {
+ return;
+ }
+ var begin = DateTime.Now;
+ var ret = _operation.ModiSitesPool();
+ Alert(ret, begin);
+ }
+
+ private void btnSetGCTime_Click(object sender, EventArgs e)
+ {
+ if (_operation == null)
+ {
+ Alert("请先连接服务器");
+ return;
+ }
+ if (!PromptWin.GetPrompt(out var strTime, "请输入第一个站点的回收时间, 格式必须是:HH:mm", "04:30", this))
+ {
+ return;
+ }
+ if (!Regex.IsMatch(strTime, @"^([01]\d|2[0-3]):[0-5]\d$"))
+ {
+ Alert("回收时间格式必须是小时分钟:HH:mm");
+ return;
+ }
+ if (!PromptWin.GetPrompt(out var strMinute, "请输入每2个站点的回收间隔时间, 单位分钟", "1", this))
+ {
+ return;
+ }
+ if (!int.TryParse(strMinute, out var deffMinute) || deffMinute > 30 || deffMinute < 1)
{
- Alert("下列站点开启失败:\n" + ret, begin);
+ Alert("时间间隔必须是1~30之间的数字");
+ return;
}
+ var tmpArr = strTime.Split(':');
+ int hour = int.Parse(tmpArr[0]);
+ int minute = int.Parse(tmpArr[1]);
+ var begin = DateTime.Now;
+ var ret = _operation.SetPoolsRecyleTime(hour, minute, deffMinute);
+ Alert(ret, begin);
+ }
+
+
+ private void btnOpen_Click(object sender, EventArgs e)
+ {
+ Utility.OpenDir(txtSiteDir.Text);
}
#endregion
@@ -472,7 +508,7 @@ void RestartSite(object data)
}
Alert("站点和程序池重启成功:" + siteName, begin);
}
- // 重启站点和应用程序池
+ // 停止站点和应用程序池
void StopSite(object data)
{
var begin = DateTime.Now;
@@ -521,9 +557,19 @@ void OperationSite(int flg)
CopySite(siteName);
return;
case 1:
+ if (!site.IsHttp)
+ {
+ Alert("不支持ftp站点");
+ return;
+ }
RestartSite(siteName);
break;
case 2:
+ if (!site.IsHttp)
+ {
+ Alert("不支持ftp站点");
+ return;
+ }
StopSite(siteName);
break;
}
@@ -924,5 +970,6 @@ static bool Confirm(string msg)
MessageBoxDefaultButton.Button2);
return ret == DialogResult.Yes;
}
+
}
}
diff --git a/IISAbout/IIStool.resx b/IISAbout/IIStool.resx
index 2a6696b..0393ebe 100644
--- a/IISAbout/IIStool.resx
+++ b/IISAbout/IIStool.resx
@@ -124,8 +124,8 @@
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
- ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAABm
- CQAAAk1TRnQBSQFMAgEBAwEAASgBAAEoAQABEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
+ ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAAM
+ CQAAAk1TRnQBSQFMAgEBAwEAAVgBAAFYAQABEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
AwABQAMAARADAAEBAQABCAYAAQQYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA
AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5
AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA
@@ -153,19 +153,17 @@
AcwBAAH/AZkB/wEAAf8BzAIAAf8BzAEzAQAB/wHMAWYBAAH/AcwBmQEAAf8CzAEAAf8BzAH/AQAC/wEz
AQABzAH/AWYBAAL/AZkBAAL/AcwBAAJmAf8BAAFmAf8BZgEAAWYC/wEAAf8CZgEAAf8BZgH/AQAC/wFm
AQABIQEAAaUBAANfAQADdwEAA4YBAAOWAQADywEAA7IBAAPXAQAD3QEAA+MBAAPqAQAD8QEAA/gBAAHw
- AfsB/wEAAaQCoAEAA4ADAAH/AgAB/wMAAv8BAAH/AwAB/wEAAf8BAAL/AgAD/wEABkMBFANtARMKQwEV
- AW0B6gNtARIEQxCQEAABFQJDARUBFALqARIBEwESAeoBbQESA0MEFQFtAeoBEgEQAgsBFALqAxUQkBAA
- AxUBEgHqAUMBIgQnAREC6gUVAW0B6gELBR4BCwETAeoCFRCQEAABFAEVARQB6gEhBycBIQHqARIDFQLq
- AQsIHgETAeoBFRCQEAACFAHqAUMJJwEhAeoDFAHqAQ8JHgELAeoBEgmWApABgQSQEAACFAHqCycBEgET
- ARQBEwHqAQsGHgELAx4BEQHqDJYEkBAAARMB6gESAicBSQEnAigCJwFJAicBFQHqARQCEgIeAUQB6gHt
- AT4BHAEHAZMCHgELAeoLlgWQEAABEwHqARUCJwFDAUkCQwHrAScBwgInASEBEgETARIBQwIeAUQDGgEM
- AQcBEQE+AR4BCwHqDZYBkAKWEAABEwESARUCTwHtAXIBmAFyARIB7QHzAicBIQESARMBEgEVA0UBkwHz
- AUQBkwGNAbwCHgELARIQlhAAAhIBFAVPAUkCJwGYAicBEQQSAUQDRQJEBR4BCwESEJYQAAMSBU8BSQEo
- BCcBEwQSAQsERQFEBR4BFAESEJYQAAMSAUkDTwNJASgCJwERARMEEgEVAUQCRQNEASMCHgELARMB6hCW
- EAAB6gESAeoBEgFyAk8DSQIoAUkBEwESBOoBEgELAT4FRAE+AQsBEwESAeoQlhAAA+oBEgETAU8GSQIT
- BuoBEwFDAQsBHgNEAQsBEwESAuoQlhAABOoCEgEUA0kBFAETARII6gETARIBEwEUAhMBEgTqEJYQAAFt
- BeoBEgETAhIBEwFtCOoDbQMSAW0D6gFtAeoQlhAAAUIBTQE+BwABPgMAASgDAAFAAwABEAMAAQEBAAEB
- BQABgBcAA/+BAAs=
+ AfsB/wEAAaQCoAEAA4ADAAH/AgAB/wMAAv8BAAH/AwAB/wEAAf8BAAL/AgAD/wEAEFUQRyAABlUBdwlV
+ DEcBRgNHBwACwwKgAeUUAARVAXEBtwHvCVUERwJZAVMBRgFHAVMBWQFTAVkDRwEAAREDAAEPAQACwwGg
+ AuUUAARVAXECtwG9AXEHVQRHA/sBKwFHAVkD+wNHAQABrgHQAdYC3QHyAcMCoAHlAV4B5RMABFUBcQS3
+ Ae8GVQRHA/sBKwFHAVkD+wNHAgAB0AHWA90BDgHDAaAC5QFeEwAEVQFxBbcBvQFxA1UBdwRHA/sBKwFH
+ AVkD+wNHAgAB0AHWA90BAALDARQBSgHlEwAEVQFxB7cBcgNVBEcD+wErAUcBWQP7A0cCAAGvAdYD3QHq
+ AQ4BlwKeAQgTAARVAXEItwG9AlUERwP7ASsBRwFZA/sDRwIAAQ4BjQHXAd0BEgEOAScB5AGeAQgCwhIA
+ BFUBcQe3Ab0BcgJVBEcD+wErAUcBWQP7A0cDAAEWAkQBaQEXAQAB5AGeAQgCwhIABFUBcQa3Ab0EVQRH
+ A/sBKwFHAVkD+wNHAwABFgTjAQ4B5AGeAQgCwgEOEQAEVQFxBbcBcgVVBEcD+wErAUcBWQP7A0cDAAGT
+ BBYBGgGYAZ4BwQLCAfcRAARVAXEEtwFPBlUERwP7ASsBRwFZA/sDRwQABZQBAAEOAwABDhEABFUBcQG3
+ Ab0BmAJ3BlUERwNTAUYBRwRTA0cEAAG9AbcDvRcABFUBcQG9AXEJVRBHIAAQVRBHIAAFVQFPClUQRyAA
+ AUIBTQE+BwABPgMAASgDAAFAAwABEAMAAQEBAAEBBQABgBcAA/+BAAs=
diff --git a/IISAbout/root.jpg b/IISAbout/root.jpg
index 5692af3..77fc0c4 100644
Binary files a/IISAbout/root.jpg and b/IISAbout/root.jpg differ
diff --git a/IISAbout/start.jpg b/IISAbout/start.jpg
index 1db4fb9..a3988d1 100644
Binary files a/IISAbout/start.jpg and b/IISAbout/start.jpg differ
diff --git a/IISAbout/stop.jpg b/IISAbout/stop.jpg
index 25863f6..f8e46da 100644
Binary files a/IISAbout/stop.jpg and b/IISAbout/stop.jpg differ
diff --git a/README.md b/README.md
index bc62d86..7d08ae6 100644
--- a/README.md
+++ b/README.md
@@ -1,8 +1,8 @@
水边开发的工具合集
==================
-整合了11个工具:
- 1、上下线控制(用于配置CheckIpInfo.aspx页面进行前端负载均衡控制,便于多台服务器的发布)
+整合了12个工具:
+ 1、IIS运维管理工具
2、DES/3DES/Base64加密解密工具,MD5/Hash/Hash32加密工具
3、DotNet的DLL合并工具
4、检测DLL是64位还是32位,.net的程序或dll是Release还是Debug版本
@@ -13,6 +13,7 @@
9、SqlServer数据库同步工具
10、IP纯真库查询和导入数据库工具
11、站点是否开启GZIP压缩的测试
+ 12、上下线控制(用于配置CheckIpInfo.aspx页面进行前端负载均衡控制,便于多台服务器的发布)
另:项目根目录下有个Tools.aspx页面文件,是一个工具页面,支持如下功能:
1、在线文件管理器(类似于Windows的资源管理器),同时可以配合FileHash工具,进行在线文件MD5对比
diff --git a/Util/PromptWin.Designer.cs b/Util/PromptWin.Designer.cs
index 9d7807c..4d063d3 100644
--- a/Util/PromptWin.Designer.cs
+++ b/Util/PromptWin.Designer.cs
@@ -79,10 +79,12 @@ private void InitializeComponent()
this.Controls.Add(this.button1);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.label1);
+ this.KeyPreview = true;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "PromptWin";
this.Text = "PromptWin";
+ this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.PromptWin_KeyDown);
this.ResumeLayout(false);
this.PerformLayout();
diff --git a/Util/PromptWin.cs b/Util/PromptWin.cs
index 473cda2..62af978 100644
--- a/Util/PromptWin.cs
+++ b/Util/PromptWin.cs
@@ -12,6 +12,7 @@ namespace Beinet.cn.Tools
public partial class PromptWin : Form
{
public string PromptText { get; set; }
+ private string _title { get; set; }
//public PromptWin()
// : this(null)
@@ -21,16 +22,17 @@ public partial class PromptWin : Form
public PromptWin(string title)
{
InitializeComponent();
- if (!string.IsNullOrEmpty(title))
- {
- Text = title;
- }
+ _title = title;
ShowInTaskbar = false;// 不能放到OnLoad里,会导致窗体消失
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
+ if (!string.IsNullOrEmpty(_title))
+ {
+ Text = _title;
+ }
if (Owner != null)
{
@@ -42,36 +44,71 @@ protected override void OnLoad(EventArgs e)
}
private void button1_Click(object sender, EventArgs e)
+ {
+ Ok();
+ }
+
+ private void button2_Click(object sender, EventArgs e)
+ {
+ Cancel();
+ }
+
+ void Ok()
{
this.DialogResult = DialogResult.OK;
PromptText = textBox1.Text;
Close();
}
-
- private void button2_Click(object sender, EventArgs e)
+ void Cancel()
{
this.DialogResult = DialogResult.Cancel;
PromptText = null;
Close();
}
+ private void PromptWin_KeyDown(object sender, KeyEventArgs e)
+ {
+ switch (e.KeyCode)
+ {
+ case Keys.Escape:
+ Cancel();
+ break;
+ case Keys.Enter:
+ Ok();
+ break;
+ }
+ }
+
+
+
///
/// 弹出模态窗口,获取返回值
///
- ///
- ///
- ///
///
- public static bool GetPrompt(out string msg, string title = null, IWin32Window window = null)
+ public static bool GetPrompt(out string msg, string title = null,
+ string defaultVal = null, IWin32Window window = null)
{
- var win = new PromptWin(title);
- DialogResult ret = win.ShowDialog(window);
- if(ret == DialogResult.OK)
+ try
+ {
+ using (var win = new PromptWin(title))
+ {
+ if (!string.IsNullOrEmpty(defaultVal))
+ {
+ win.textBox1.Text = defaultVal;
+ }
+ DialogResult ret = win.ShowDialog(window);
+ if (ret == DialogResult.OK)
+ {
+ msg = win.PromptText;
+ return true;
+ }
+ }
+ msg = null;
+ }
+ catch
{
- msg = win.PromptText;
- return true;
+ msg = null;
}
- msg = null;
return false;
}
}
diff --git a/Util/Utility.cs b/Util/Utility.cs
index 7a90a46..689dcc3 100644
--- a/Util/Utility.cs
+++ b/Util/Utility.cs
@@ -1077,5 +1077,21 @@ public static T FromJson(string source)
}
+ public static void OpenDir(string dir)
+ {
+ if (string.IsNullOrEmpty(dir))
+ {
+ MessageBox.Show("目录不能为空");
+ return;
+ }
+ // %SystemDrive%环境变量转换
+ dir = Environment.ExpandEnvironmentVariables(dir);
+ if (!Directory.Exists(dir))
+ {
+ MessageBox.Show("目录不存在:" + dir);
+ return;
+ }
+ Process.Start("explorer", dir);
+ }
}
}