add update components
This commit is contained in:
parent
86f95b930f
commit
ebc22b5064
BIN
net.nutcore.aliddns/AutoUpdater/AutoUpdateHelper/AutoUpdater.cs
Normal file
BIN
net.nutcore.aliddns/AutoUpdater/AutoUpdateHelper/AutoUpdater.cs
Normal file
Binary file not shown.
@ -0,0 +1,56 @@
|
||||
/*****************************************************************
|
||||
* Copyright (C) Knights Warrior Corporation. All rights reserved.
|
||||
*
|
||||
* Author: 圣殿骑士(Knights Warrior)
|
||||
* Email: KnightsWarrior@msn.com
|
||||
* Website: http://www.cnblogs.com/KnightsWarrior/ https://github.com/knightswarrior
|
||||
* Create Date: 5/8/2010
|
||||
* Usage:
|
||||
*
|
||||
* RevisionHistory
|
||||
* Date Author Description
|
||||
*
|
||||
*****************************************************************/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using System.Diagnostics;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace KnightsWarriorAutoupdater
|
||||
{
|
||||
class CommonUnitity
|
||||
{
|
||||
public static string SystemBinUrl = AppDomain.CurrentDomain.BaseDirectory;
|
||||
|
||||
public static void RestartApplication()
|
||||
{
|
||||
Process.Start(Application.ExecutablePath);
|
||||
Environment.Exit(0);
|
||||
}
|
||||
|
||||
public static string GetFolderUrl(DownloadFileInfo file)
|
||||
{
|
||||
string folderPathUrl = string.Empty;
|
||||
int folderPathPoint = file.DownloadUrl.IndexOf("/", 15) + 1;
|
||||
string filepathstring = file.DownloadUrl.Substring(folderPathPoint);
|
||||
int folderPathPoint1 = filepathstring.IndexOf("/");
|
||||
string filepathstring1 = filepathstring.Substring(folderPathPoint1 + 1);
|
||||
if (filepathstring1.IndexOf("/") != -1)
|
||||
{
|
||||
string[] ExeGroup = filepathstring1.Split('/');
|
||||
for (int i = 0; i < ExeGroup.Length - 1; i++)
|
||||
{
|
||||
folderPathUrl += "\\" + ExeGroup[i];
|
||||
}
|
||||
if (!Directory.Exists(SystemBinUrl + ConstFile.TEMPFOLDERNAME + folderPathUrl))
|
||||
{
|
||||
Directory.CreateDirectory(SystemBinUrl + ConstFile.TEMPFOLDERNAME + folderPathUrl);
|
||||
}
|
||||
}
|
||||
return folderPathUrl;
|
||||
}
|
||||
}
|
||||
}
|
111
net.nutcore.aliddns/AutoUpdater/AutoUpdateHelper/Config.cs
Normal file
111
net.nutcore.aliddns/AutoUpdater/AutoUpdateHelper/Config.cs
Normal file
@ -0,0 +1,111 @@
|
||||
/*****************************************************************
|
||||
* Copyright (C) Knights Warrior Corporation. All rights reserved.
|
||||
*
|
||||
* Author: Ê¥µîÆïÊ¿£¨Knights Warrior£©
|
||||
* Email: KnightsWarrior@msn.com
|
||||
* Website: http://www.cnblogs.com/KnightsWarrior/ https://github.com/knightswarrior
|
||||
* Create Date: 5/8/2010
|
||||
* Usage:
|
||||
*
|
||||
* RevisionHistory
|
||||
* Date Author Description
|
||||
*
|
||||
*****************************************************************/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
using System.Xml.Serialization;
|
||||
using System.IO;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace KnightsWarriorAutoupdater
|
||||
{
|
||||
[Serializable]
|
||||
[XmlRoot("configuration")]
|
||||
public class Config
|
||||
{
|
||||
#region The private fields
|
||||
private bool enabled = true;
|
||||
private bool silence = false;
|
||||
private string serverUrl = string.Empty;
|
||||
private UpdateFileList updateFileList = new UpdateFileList();
|
||||
private static readonly string configFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, ConstFile.FILENAME);
|
||||
#endregion
|
||||
|
||||
#region The public property
|
||||
[XmlElement("Enabled")]
|
||||
public bool Enabled
|
||||
{
|
||||
get { return enabled; }
|
||||
set { enabled = value; }
|
||||
}
|
||||
[XmlElement("Silence")]
|
||||
public bool Silence
|
||||
{
|
||||
get { return silence; }
|
||||
set { silence = value; }
|
||||
}
|
||||
[XmlElement("ServerUrl")]
|
||||
public string ServerUrl
|
||||
{
|
||||
get { return serverUrl; }
|
||||
set { serverUrl = value; }
|
||||
}
|
||||
[XmlArray("UpdateFileList")]
|
||||
[XmlArrayItem("LocalFile")]
|
||||
public UpdateFileList UpdateFileList
|
||||
{
|
||||
get { return updateFileList; }
|
||||
set { updateFileList = value; }
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region The public method
|
||||
public Config()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!File.Exists(configFilePath))
|
||||
{
|
||||
CreatDefaultConfig(configFilePath);
|
||||
}
|
||||
}
|
||||
catch (Exception errMsg)
|
||||
{
|
||||
Console.WriteLine("Config::Config() running error! " + errMsg);
|
||||
}
|
||||
}
|
||||
public static Config LoadConfig(string file)
|
||||
{
|
||||
XmlSerializer xs = new XmlSerializer(typeof(Config));
|
||||
StreamReader sr = new StreamReader(file);
|
||||
Config config = xs.Deserialize(sr) as Config;
|
||||
sr.Close();
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
public void SaveConfig(string file)
|
||||
{
|
||||
XmlSerializer xs = new XmlSerializer(typeof(Config));
|
||||
StreamWriter sw = new StreamWriter(file);
|
||||
xs.Serialize(sw, this);
|
||||
sw.Close();
|
||||
}
|
||||
|
||||
public void CreatDefaultConfig(string file)
|
||||
{
|
||||
this.Silence = false;
|
||||
this.Enabled = false;
|
||||
this.ServerUrl = ConstFile.SERVERURL;
|
||||
FileInfo fileInfo = new FileInfo(Application.ExecutablePath);
|
||||
this.UpdateFileList.Add(new LocalFile(Path.GetFileName(Application.ExecutablePath), Application.ProductVersion, (int)fileInfo.Length));
|
||||
this.UpdateFileList.Add(new LocalFile("AutoUpdater.dll", "0.0.0.0", 0));
|
||||
|
||||
this.SaveConfig(file);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
/*****************************************************************
|
||||
* Copyright (C) Knights Warrior Corporation. All rights reserved.
|
||||
*
|
||||
* Author: 圣殿骑士(Knights Warrior)
|
||||
* Email: KnightsWarrior@msn.com
|
||||
* Website: http://www.cnblogs.com/KnightsWarrior/ https://github.com/knightswarrior
|
||||
* Create Date: 5/8/2010
|
||||
* Usage:
|
||||
*
|
||||
* RevisionHistory
|
||||
* Date Author Description
|
||||
*
|
||||
*****************************************************************/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace KnightsWarriorAutoupdater
|
||||
{
|
||||
public class ConstFile
|
||||
{
|
||||
public const string TEMPFOLDERNAME = "TempFolder";
|
||||
public const string CONFIGFILEKEY = "config_";
|
||||
public const string FILENAME = "aliddns_update.xml";
|
||||
public const string ROOLBACKFILE = "AliDDNS.exe";
|
||||
public const string MESSAGETITLE = "自动升级";
|
||||
public const string CANCELORNOT = FILENAME + " 正在升级中,请确认是否取消?";
|
||||
public const string APPLYTHEUPDATE = "程序需要重启以完成升级,点击“OK”重启!";
|
||||
public const string NOTNETWORK = "更新本地应用失败!请检查" + FILENAME + "下载文件清单。\r\n应用程序将重启,您可能需要选择“跳过”停止循环升级。";
|
||||
public const string SERVERURL = "https://www.demodomain.cn/AliDDNS/updatefilelist.xml";
|
||||
}
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
/*****************************************************************
|
||||
* Copyright (C) Knights Warrior Corporation. All rights reserved.
|
||||
*
|
||||
* Author: 圣殿骑士(Knights Warrior)
|
||||
* Email: KnightsWarrior@msn.com
|
||||
* Website: http://www.cnblogs.com/KnightsWarrior/ https://github.com/knightswarrior
|
||||
* Create Date: 5/8/2010
|
||||
* Usage:
|
||||
*
|
||||
* RevisionHistory
|
||||
* Date Author Description
|
||||
*
|
||||
*****************************************************************/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
|
||||
namespace KnightsWarriorAutoupdater
|
||||
{
|
||||
public class DownloadFileInfo
|
||||
{
|
||||
#region The private fields
|
||||
string downloadUrl = string.Empty;
|
||||
string fileName = string.Empty;
|
||||
string lastver = string.Empty;
|
||||
int size = 0;
|
||||
#endregion
|
||||
|
||||
#region The public property
|
||||
public string DownloadUrl { get { return downloadUrl; } }
|
||||
public string FileFullName { get { return fileName; } }
|
||||
public string FileName { get { return Path.GetFileName(FileFullName); } }
|
||||
public string LastVer { get { return lastver; } set { lastver = value; } }
|
||||
public int Size { get { return size; } }
|
||||
#endregion
|
||||
|
||||
#region The constructor of DownloadFileInfo
|
||||
public DownloadFileInfo(string url, string name, string ver, int size)
|
||||
{
|
||||
this.downloadUrl = url;
|
||||
this.fileName = name;
|
||||
this.lastver = ver;
|
||||
this.size = size;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
/*****************************************************************
|
||||
* Copyright (C) Knights Warrior Corporation. All rights reserved.
|
||||
*
|
||||
* Author: 圣殿骑士(Knights Warrior)
|
||||
* Email: KnightsWarrior@msn.com
|
||||
* Website: http://www.cnblogs.com/KnightsWarrior/ https://github.com/knightswarrior
|
||||
* Create Date: 5/8/2010
|
||||
* Usage:
|
||||
*
|
||||
* RevisionHistory
|
||||
* Date Author Description
|
||||
*
|
||||
*****************************************************************/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace KnightsWarriorAutoupdater
|
||||
{
|
||||
public interface IAutoUpdater
|
||||
{
|
||||
void Update();
|
||||
|
||||
void RollBack();
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
/*****************************************************************
|
||||
* Copyright (C) Knights Warrior Corporation. All rights reserved.
|
||||
*
|
||||
* Author: 圣殿骑士(Knights Warrior)
|
||||
* Email: KnightsWarrior@msn.com
|
||||
* Website: http://www.cnblogs.com/KnightsWarrior/ https://github.com/knightswarrior
|
||||
* Create Date: 5/8/2010
|
||||
* Usage:
|
||||
*
|
||||
* RevisionHistory
|
||||
* Date Author Description
|
||||
*
|
||||
*****************************************************************/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
namespace KnightsWarriorAutoupdater
|
||||
{
|
||||
public class LocalFile
|
||||
{
|
||||
#region The private fields
|
||||
private string path = "";
|
||||
private string lastver = "";
|
||||
private int size = 0;
|
||||
#endregion
|
||||
|
||||
#region The public property
|
||||
[XmlAttribute("path")]
|
||||
public string Path { get { return path; } set { path = value; } }
|
||||
[XmlAttribute("lastver")]
|
||||
public string LastVer { get { return lastver; } set { lastver = value; } }
|
||||
[XmlAttribute("size")]
|
||||
public int Size { get { return size; } set { size = value; } }
|
||||
#endregion
|
||||
|
||||
#region The constructor of LocalFile
|
||||
public LocalFile(string path, string ver, int size)
|
||||
{
|
||||
this.path = path;
|
||||
this.lastver = ver;
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
public LocalFile()
|
||||
{
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
/*****************************************************************
|
||||
* Copyright (C) Knights Warrior Corporation. All rights reserved.
|
||||
*
|
||||
* Author: 圣殿骑士(Knights Warrior)
|
||||
* Email: KnightsWarrior@msn.com
|
||||
* Website: http://www.cnblogs.com/KnightsWarrior/ https://github.com/knightswarrior
|
||||
* Create Date: 5/8/2010
|
||||
* Usage:
|
||||
*
|
||||
* RevisionHistory
|
||||
* Date Author Description
|
||||
*
|
||||
*****************************************************************/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
|
||||
namespace KnightsWarriorAutoupdater
|
||||
{
|
||||
public class RemoteFile
|
||||
{
|
||||
#region The private fields
|
||||
private string path = "";
|
||||
private string url = "";
|
||||
private string lastver = "";
|
||||
private int size = 0;
|
||||
private bool needRestart = false;
|
||||
#endregion
|
||||
|
||||
#region The public property
|
||||
public string Path { get { return path; } }
|
||||
public string Url { get { return url; } }
|
||||
public string LastVer { get { return lastver; } }
|
||||
public int Size { get { return size; } }
|
||||
public bool NeedRestart { get { return needRestart; } }
|
||||
#endregion
|
||||
|
||||
#region The constructor of AutoUpdater
|
||||
public RemoteFile(XmlNode node)
|
||||
{
|
||||
this.path = node.Attributes["path"].Value;
|
||||
this.url = node.Attributes["url"].Value;
|
||||
this.lastver = node.Attributes["lastver"].Value;
|
||||
this.size = Convert.ToInt32(node.Attributes["size"].Value);
|
||||
this.needRestart = Convert.ToBoolean(node.Attributes["needRestart"].Value);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
/*****************************************************************
|
||||
* Copyright (C) Knights Warrior Corporation. All rights reserved.
|
||||
*
|
||||
* Author: 圣殿骑士(Knights Warrior)
|
||||
* Email: KnightsWarrior@msn.com
|
||||
* Website: http://www.cnblogs.com/KnightsWarrior/ https://github.com/knightswarrior
|
||||
* Create Date: 5/8/2010
|
||||
* Usage:
|
||||
*
|
||||
* RevisionHistory
|
||||
* Date Author Description
|
||||
*
|
||||
*****************************************************************/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace KnightsWarriorAutoupdater
|
||||
{
|
||||
public class UpdateFileList : List<LocalFile>
|
||||
{
|
||||
|
||||
}
|
||||
}
|
98
net.nutcore.aliddns/AutoUpdater/AutoUpdater.csproj
Normal file
98
net.nutcore.aliddns/AutoUpdater/AutoUpdater.csproj
Normal file
@ -0,0 +1,98 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="Current" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>9.0.30729</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{4BA4719C-C6AB-49BA-9754-848CA24C1FD6}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>AutoUpdater</RootNamespace>
|
||||
<AssemblyName>AutoUpdater</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<FileUpgradeFlags>
|
||||
</FileUpgradeFlags>
|
||||
<UpgradeBackupLocation>
|
||||
</UpgradeBackupLocation>
|
||||
<OldToolsVersion>3.5</OldToolsVersion>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\net.nutcore.aliddns\bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>..\net.nutcore.aliddns\bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml.Linq">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Data.DataSetExtensions">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AutoUpdateHelper\AutoUpdater.cs" />
|
||||
<Compile Include="AutoUpdateHelper\CommonUnitity.cs" />
|
||||
<Compile Include="AutoUpdateHelper\Config.cs" />
|
||||
<Compile Include="AutoUpdateHelper\ConstFile.cs" />
|
||||
<Compile Include="AutoUpdateHelper\DownloadFileInfo.cs" />
|
||||
<Compile Include="AutoUpdateHelper\IAutoUpdater.cs" />
|
||||
<Compile Include="AutoUpdateHelper\LocalFile.cs" />
|
||||
<Compile Include="AutoUpdateHelper\RemoteFile.cs" />
|
||||
<Compile Include="AutoUpdateHelper\UpdateFileList.cs" />
|
||||
<Compile Include="DownloadConfirm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="DownloadConfirm.designer.cs">
|
||||
<DependentUpon>DownloadConfirm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="DownloadProgress.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="DownloadProgress.designer.cs">
|
||||
<DependentUpon>DownloadProgress.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="DownloadConfirm.resx">
|
||||
<DependentUpon>DownloadConfirm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="DownloadProgress.resx">
|
||||
<DependentUpon>DownloadProgress.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Autoupdater.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
8
net.nutcore.aliddns/AutoUpdater/Autoupdater.config
Normal file
8
net.nutcore.aliddns/AutoUpdater/Autoupdater.config
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
|
||||
<Enabled>true</Enabled>
|
||||
<ServerUrl>http://localhost/KnightsWarriorClientService/AutoupdateService.xml</ServerUrl>
|
||||
<UpdateFileList>
|
||||
<LocalFile path="KnightsWarriorClient" lastver="1.0.4.17" size="11913728" />
|
||||
</UpdateFileList>
|
||||
</Config>
|
52
net.nutcore.aliddns/AutoUpdater/DownloadConfirm.cs
Normal file
52
net.nutcore.aliddns/AutoUpdater/DownloadConfirm.cs
Normal file
@ -0,0 +1,52 @@
|
||||
/*****************************************************************
|
||||
* Copyright (C) Knights Warrior Corporation. All rights reserved.
|
||||
*
|
||||
* Author: Ê¥µîÆïÊ¿£¨Knights Warrior£©
|
||||
* Email: KnightsWarrior@msn.com
|
||||
* Website: http://www.cnblogs.com/KnightsWarrior/ https://github.com/knightswarrior
|
||||
* Create Date: 5/8/2010
|
||||
* Usage:
|
||||
*
|
||||
* RevisionHistory
|
||||
* Date Author Description
|
||||
*
|
||||
*****************************************************************/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace KnightsWarriorAutoupdater
|
||||
{
|
||||
public partial class DownloadConfirm : Form
|
||||
{
|
||||
#region The private fields
|
||||
List<DownloadFileInfo> downloadFileList = null;
|
||||
#endregion
|
||||
|
||||
#region The constructor of DownloadConfirm
|
||||
public DownloadConfirm(List<DownloadFileInfo> downloadfileList)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
downloadFileList = downloadfileList;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region The private method
|
||||
private void OnLoad(object sender, EventArgs e)
|
||||
{
|
||||
foreach (DownloadFileInfo file in this.downloadFileList)
|
||||
{
|
||||
ListViewItem item = new ListViewItem(new string[] { file.FileName, file.LastVer, file.Size.ToString() });
|
||||
}
|
||||
|
||||
this.Activate();
|
||||
this.Focus();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
162
net.nutcore.aliddns/AutoUpdater/DownloadConfirm.designer.cs
generated
Normal file
162
net.nutcore.aliddns/AutoUpdater/DownloadConfirm.designer.cs
generated
Normal file
@ -0,0 +1,162 @@
|
||||
namespace KnightsWarriorAutoupdater
|
||||
{
|
||||
partial class DownloadConfirm
|
||||
{
|
||||
/// <summary>
|
||||
/// 必需的设计器变量。
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// 清理所有正在使用的资源。
|
||||
/// </summary>
|
||||
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows 窗体设计器生成的代码
|
||||
|
||||
/// <summary>
|
||||
/// 设计器支持所需的方法 - 不要
|
||||
/// 使用代码编辑器修改此方法的内容。
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(DownloadConfirm));
|
||||
this.btnOk = new System.Windows.Forms.Button();
|
||||
this.btnCancel = new System.Windows.Forms.Button();
|
||||
this.pictureBox1 = new System.Windows.Forms.PictureBox();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.panel1 = new System.Windows.Forms.Panel();
|
||||
this.panel3 = new System.Windows.Forms.Panel();
|
||||
this.splitter1 = new System.Windows.Forms.Splitter();
|
||||
this.splitter2 = new System.Windows.Forms.Splitter();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
|
||||
this.panel1.SuspendLayout();
|
||||
this.panel3.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// btnOk
|
||||
//
|
||||
this.btnOk.DialogResult = System.Windows.Forms.DialogResult.OK;
|
||||
this.btnOk.Location = new System.Drawing.Point(62, 12);
|
||||
this.btnOk.Name = "btnOk";
|
||||
this.btnOk.Size = new System.Drawing.Size(83, 23);
|
||||
this.btnOk.TabIndex = 0;
|
||||
this.btnOk.Text = "开始";
|
||||
this.btnOk.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// btnCancel
|
||||
//
|
||||
this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.btnCancel.Location = new System.Drawing.Point(172, 12);
|
||||
this.btnCancel.Name = "btnCancel";
|
||||
this.btnCancel.Size = new System.Drawing.Size(83, 23);
|
||||
this.btnCancel.TabIndex = 0;
|
||||
this.btnCancel.Text = "跳过";
|
||||
this.btnCancel.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// pictureBox1
|
||||
//
|
||||
this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
|
||||
this.pictureBox1.Location = new System.Drawing.Point(226, 3);
|
||||
this.pictureBox1.Name = "pictureBox1";
|
||||
this.pictureBox1.Size = new System.Drawing.Size(79, 55);
|
||||
this.pictureBox1.TabIndex = 4;
|
||||
this.pictureBox1.TabStop = false;
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(16, 24);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(209, 12);
|
||||
this.label2.TabIndex = 3;
|
||||
this.label2.Text = "发现程序组件新版本,是否开始下载?";
|
||||
//
|
||||
// panel1
|
||||
//
|
||||
this.panel1.BackColor = System.Drawing.SystemColors.ButtonHighlight;
|
||||
this.panel1.Controls.Add(this.pictureBox1);
|
||||
this.panel1.Controls.Add(this.label2);
|
||||
this.panel1.Dock = System.Windows.Forms.DockStyle.Top;
|
||||
this.panel1.Location = new System.Drawing.Point(0, 0);
|
||||
this.panel1.Name = "panel1";
|
||||
this.panel1.Size = new System.Drawing.Size(316, 65);
|
||||
this.panel1.TabIndex = 4;
|
||||
//
|
||||
// panel3
|
||||
//
|
||||
this.panel3.Controls.Add(this.btnOk);
|
||||
this.panel3.Controls.Add(this.btnCancel);
|
||||
this.panel3.Dock = System.Windows.Forms.DockStyle.Bottom;
|
||||
this.panel3.Location = new System.Drawing.Point(0, 67);
|
||||
this.panel3.Name = "panel3";
|
||||
this.panel3.Size = new System.Drawing.Size(316, 44);
|
||||
this.panel3.TabIndex = 6;
|
||||
//
|
||||
// splitter1
|
||||
//
|
||||
this.splitter1.BackColor = System.Drawing.SystemColors.InactiveBorder;
|
||||
this.splitter1.Dock = System.Windows.Forms.DockStyle.Top;
|
||||
this.splitter1.Location = new System.Drawing.Point(0, 65);
|
||||
this.splitter1.Name = "splitter1";
|
||||
this.splitter1.Size = new System.Drawing.Size(316, 2);
|
||||
this.splitter1.TabIndex = 7;
|
||||
this.splitter1.TabStop = false;
|
||||
//
|
||||
// splitter2
|
||||
//
|
||||
this.splitter2.BackColor = System.Drawing.SystemColors.InactiveBorder;
|
||||
this.splitter2.Dock = System.Windows.Forms.DockStyle.Bottom;
|
||||
this.splitter2.Location = new System.Drawing.Point(0, 65);
|
||||
this.splitter2.Name = "splitter2";
|
||||
this.splitter2.Size = new System.Drawing.Size(316, 2);
|
||||
this.splitter2.TabIndex = 8;
|
||||
this.splitter2.TabStop = false;
|
||||
//
|
||||
// DownloadConfirm
|
||||
//
|
||||
this.AcceptButton = this.btnOk;
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.CancelButton = this.btnCancel;
|
||||
this.ClientSize = new System.Drawing.Size(316, 111);
|
||||
this.ControlBox = false;
|
||||
this.Controls.Add(this.splitter2);
|
||||
this.Controls.Add(this.splitter1);
|
||||
this.Controls.Add(this.panel3);
|
||||
this.Controls.Add(this.panel1);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "DownloadConfirm";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
this.Text = "新版本提醒";
|
||||
this.Load += new System.EventHandler(this.OnLoad);
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
|
||||
this.panel1.ResumeLayout(false);
|
||||
this.panel1.PerformLayout();
|
||||
this.panel3.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Button btnOk;
|
||||
private System.Windows.Forms.Button btnCancel;
|
||||
private System.Windows.Forms.PictureBox pictureBox1;
|
||||
private System.Windows.Forms.Label label2;
|
||||
private System.Windows.Forms.Panel panel1;
|
||||
private System.Windows.Forms.Panel panel3;
|
||||
private System.Windows.Forms.Splitter splitter1;
|
||||
private System.Windows.Forms.Splitter splitter2;
|
||||
}
|
||||
}
|
171
net.nutcore.aliddns/AutoUpdater/DownloadConfirm.resx
Normal file
171
net.nutcore.aliddns/AutoUpdater/DownloadConfirm.resx
Normal file
@ -0,0 +1,171 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
||||
<data name="pictureBox1.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
R0lGODlhSAA5AIcAAAAAAIAAAACAAICAAAAAgIAAgACAgLq/u8Hcw6bK8BZrviB+HiRwwSl7tCp0wyqI
|
||||
KC58vjGNLTSfYzOnZDakaDWrZj1qdjp9qDl8xjyVOjqtZDysazmtaz+wV0FseUBupkCFxkKPbkeNkEKV
|
||||
a0KaQkWdcEGncEK1OU1yfUeAwEyGyUaIzkiXc1GXlUmPxEmcS0idWEilOkuoR0mkdUuje0q1Qkq0WEmz
|
||||
Xkuzak6xdlC8RlaMaFGKz1SRpU+WvVKhUU+cdVKjYFO3RlO3U1h5jF+BZFyBjFmFxVyL01iPrlmW0FuW
|
||||
01ubo1mazlakUlupZVutiVq4VVjAS2HFVWNoVWVtXWV4m2mIo2aHu2aGw2GUu2eTxmOS1WCbtGKdyWCk
|
||||
nmSrZ2K3XmO6f2pzZmh4fGl9hmyU1m2lw2ye12ilumytaWu2aWi7XG2+bGjLWXN9enSAf3KVt3ORxnWZ
|
||||
pHSesHWbz3Se2XCm0HK3cW+yp3O9X3jFenPTXn+GdHmFg36Oqnqf23ym0ne2d3uzm36x0ne8doK7t3vB
|
||||
Yn/CmXjLc3vZYYOWm4Kn3YTBqoTFZX/HeoTGg4TFiYuq34yt0Yu03Y2/vo7Hao3FkY3Ri5aaiZKcqpiu
|
||||
z5S24ZS13pS+zpbKeZPFt5XPjpfJppuej5u34pnLcJrPl6KmlKSnnqWstaO+uaO85qPH0aPE3qbH5KLP
|
||||
eqXO1qLXn6qrk6yvprCym63G6KrUha7WjLLXlK3UnqrWqarrlLO1prS3sbi9pbm+sbHG1a7M3rXJvrfN
|
||||
6rXWjLXYorrW1bnT3rzcprDcrrXbtLProbe9nbzAp77FssDKprnbnsPfsbvhu73evcLDrMK+tMXIvsXP
|
||||
tsrZzsXV78Deqczd7cjjuc3QtMrWts3Vvc7Vxc7lxc7lz9bZutPazdbbwNTg8tblz9jm3Nzfwdng1d7h
|
||||
3d/n39/n79zs197t3uPt6+bu4+zx7ezy+Pb4+P7+/v/78J6inoCAgP8AAAD/AP//AAAA//8A/wD/////
|
||||
/yH/C05FVFNDQVBFMi4wAwEBAAAh+QQAAAAAACwAAAAASAA5AAAI/wDrCRxIsKDBgwgTKlzIsKHDhxAj
|
||||
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
|
||||
</value>
|
||||
</data>
|
||||
</root>
|
375
net.nutcore.aliddns/AutoUpdater/DownloadProgress.cs
Normal file
375
net.nutcore.aliddns/AutoUpdater/DownloadProgress.cs
Normal file
@ -0,0 +1,375 @@
|
||||
/*****************************************************************
|
||||
* Copyright (C) Knights Warrior Corporation. All rights reserved.
|
||||
*
|
||||
* Author: Ê¥µîÆïÊ¿£¨Knights Warrior£©
|
||||
* Email: KnightsWarrior@msn.com
|
||||
* Website: http://www.cnblogs.com/KnightsWarrior/ https://github.com/knightswarrior
|
||||
* Create Date: 5/8/2010
|
||||
* Usage:
|
||||
*
|
||||
* RevisionHistory
|
||||
* Date Author Description
|
||||
*
|
||||
*****************************************************************/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using System.Threading;
|
||||
using System.Net;
|
||||
using System.IO;
|
||||
using System.Diagnostics;
|
||||
using System.Xml;
|
||||
|
||||
namespace KnightsWarriorAutoupdater
|
||||
{
|
||||
public partial class DownloadProgress : Form
|
||||
{
|
||||
#region The private fields
|
||||
private bool isFinished = false;
|
||||
private List<DownloadFileInfo> downloadFileList = null;
|
||||
private List<DownloadFileInfo> allFileList = null;
|
||||
private ManualResetEvent evtDownload = null;
|
||||
private ManualResetEvent evtPerDonwload = null;
|
||||
private WebClient clientDownload = null;
|
||||
#endregion
|
||||
|
||||
#region The constructor of DownloadProgress
|
||||
public DownloadProgress(List<DownloadFileInfo> downloadFileListTemp)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
this.downloadFileList = downloadFileListTemp;
|
||||
allFileList = new List<DownloadFileInfo>();
|
||||
foreach (DownloadFileInfo file in downloadFileListTemp)
|
||||
{
|
||||
allFileList.Add(file);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region The method and event
|
||||
private void OnFormClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
if (!isFinished && DialogResult.No == MessageBox.Show(ConstFile.CANCELORNOT, ConstFile.MESSAGETITLE, MessageBoxButtons.YesNo, MessageBoxIcon.Question))
|
||||
{
|
||||
e.Cancel = true;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (clientDownload != null)
|
||||
clientDownload.CancelAsync();
|
||||
|
||||
evtDownload.Set();
|
||||
evtPerDonwload.Set();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnFormLoad(object sender, EventArgs e)
|
||||
{
|
||||
evtDownload = new ManualResetEvent(true);
|
||||
evtDownload.Reset();
|
||||
ThreadPool.QueueUserWorkItem(new WaitCallback(this.ProcDownload));
|
||||
}
|
||||
|
||||
long total = 0;
|
||||
long nDownloadedTotal = 0;
|
||||
|
||||
private void ProcDownload(object o)
|
||||
{
|
||||
string tempFolderPath = Path.Combine(CommonUnitity.SystemBinUrl, ConstFile.TEMPFOLDERNAME);
|
||||
if (!Directory.Exists(tempFolderPath))
|
||||
{
|
||||
Directory.CreateDirectory(tempFolderPath);
|
||||
}
|
||||
|
||||
|
||||
evtPerDonwload = new ManualResetEvent(false);
|
||||
|
||||
foreach (DownloadFileInfo file in this.downloadFileList)
|
||||
{
|
||||
total += file.Size;
|
||||
}
|
||||
try
|
||||
{
|
||||
while (!evtDownload.WaitOne(0, false))
|
||||
{
|
||||
if (this.downloadFileList.Count == 0)
|
||||
break;
|
||||
|
||||
DownloadFileInfo file = this.downloadFileList[0];
|
||||
|
||||
|
||||
//Debug.WriteLine(String.Format("Start Download:{0}", file.FileName));
|
||||
|
||||
this.ShowCurrentDownloadFileName(file.FileName);
|
||||
|
||||
//Download
|
||||
clientDownload = new WebClient();
|
||||
|
||||
//Added the function to support proxy
|
||||
//clientDownload.Proxy = System.Net.WebProxy.GetDefaultProxy();
|
||||
clientDownload.Proxy = WebRequest.GetSystemWebProxy();
|
||||
clientDownload.Proxy.Credentials = CredentialCache.DefaultCredentials;
|
||||
clientDownload.Credentials = System.Net.CredentialCache.DefaultCredentials;
|
||||
//End added
|
||||
|
||||
clientDownload.DownloadProgressChanged += (object sender, DownloadProgressChangedEventArgs e) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
this.SetProcessBar(e.ProgressPercentage, (int)((nDownloadedTotal + e.BytesReceived) * 100 / total));
|
||||
}
|
||||
catch
|
||||
{
|
||||
//log the error message,you can use the application's log code
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
clientDownload.DownloadFileCompleted += (object sender, AsyncCompletedEventArgs e) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
DealWithDownloadErrors();
|
||||
DownloadFileInfo dfile = e.UserState as DownloadFileInfo;
|
||||
nDownloadedTotal += dfile.Size;
|
||||
this.SetProcessBar(0, (int)(nDownloadedTotal * 100 / total));
|
||||
evtPerDonwload.Set();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//log the error message,you can use the application's log code
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
evtPerDonwload.Reset();
|
||||
|
||||
//Download the folder file
|
||||
string tempFolderPath1 = CommonUnitity.GetFolderUrl(file);
|
||||
if (!string.IsNullOrEmpty(tempFolderPath1))
|
||||
{
|
||||
tempFolderPath = Path.Combine(CommonUnitity.SystemBinUrl, ConstFile.TEMPFOLDERNAME);
|
||||
tempFolderPath += tempFolderPath1;
|
||||
}
|
||||
else
|
||||
{
|
||||
tempFolderPath = Path.Combine(CommonUnitity.SystemBinUrl, ConstFile.TEMPFOLDERNAME);
|
||||
}
|
||||
|
||||
clientDownload.DownloadFileAsync(new Uri(file.DownloadUrl), Path.Combine(tempFolderPath, file.FileFullName), file);
|
||||
|
||||
//Wait for the download complete
|
||||
evtPerDonwload.WaitOne();
|
||||
|
||||
clientDownload.Dispose();
|
||||
clientDownload = null;
|
||||
|
||||
//Remove the downloaded files
|
||||
this.downloadFileList.Remove(file);
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
ShowErrorAndRestartApplication();
|
||||
//throw;
|
||||
}
|
||||
|
||||
//When the files have not downloaded,return.
|
||||
if (downloadFileList.Count > 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//Test network and deal with errors if there have
|
||||
DealWithDownloadErrors();
|
||||
|
||||
//Debug.WriteLine("All Downloaded");
|
||||
foreach (DownloadFileInfo file in this.allFileList)
|
||||
{
|
||||
string tempUrlPath = CommonUnitity.GetFolderUrl(file);
|
||||
string oldPath = string.Empty;
|
||||
string newPath = string.Empty;
|
||||
try
|
||||
{
|
||||
if (!string.IsNullOrEmpty(tempUrlPath))
|
||||
{
|
||||
oldPath = Path.Combine(CommonUnitity.SystemBinUrl + tempUrlPath.Substring(1), file.FileName);
|
||||
newPath = Path.Combine(CommonUnitity.SystemBinUrl + ConstFile.TEMPFOLDERNAME + tempUrlPath, file.FileName);
|
||||
}
|
||||
else
|
||||
{
|
||||
oldPath = Path.Combine(CommonUnitity.SystemBinUrl, file.FileName);
|
||||
newPath = Path.Combine(CommonUnitity.SystemBinUrl + ConstFile.TEMPFOLDERNAME, file.FileName);
|
||||
}
|
||||
|
||||
//just deal with the problem which the files EndsWith xml can not download
|
||||
System.IO.FileInfo f = new FileInfo(newPath);
|
||||
if (!file.Size.ToString().Equals(f.Length.ToString()) && !file.FileName.ToString().EndsWith(".xml"))
|
||||
{
|
||||
ShowErrorAndRestartApplication();
|
||||
}
|
||||
|
||||
|
||||
//Added for dealing with the config file download errors
|
||||
string newfilepath = string.Empty;
|
||||
if (newPath.Substring(newPath.LastIndexOf(".") + 1).Equals(ConstFile.CONFIGFILEKEY))
|
||||
{
|
||||
if (System.IO.File.Exists(newPath))
|
||||
{
|
||||
if (newPath.EndsWith("_"))
|
||||
{
|
||||
newfilepath = newPath;
|
||||
newPath = newPath.Substring(0, newPath.Length - 1);
|
||||
oldPath = oldPath.Substring(0, oldPath.Length - 1);
|
||||
}
|
||||
File.Move(newfilepath, newPath);
|
||||
}
|
||||
}
|
||||
//End added
|
||||
|
||||
if (File.Exists(oldPath))
|
||||
{
|
||||
MoveFolderToOld(oldPath, newPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Edit for config_ file
|
||||
if (!string.IsNullOrEmpty(tempUrlPath))
|
||||
{
|
||||
if (!Directory.Exists(CommonUnitity.SystemBinUrl + tempUrlPath.Substring(1)))
|
||||
{
|
||||
Directory.CreateDirectory(CommonUnitity.SystemBinUrl + tempUrlPath.Substring(1));
|
||||
|
||||
|
||||
MoveFolderToOld(oldPath, newPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
MoveFolderToOld(oldPath, newPath);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MoveFolderToOld(oldPath, newPath);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
catch (Exception exp)
|
||||
{
|
||||
//log the error message,you can use the application's log code
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//After dealed with all files, clear the data
|
||||
this.allFileList.Clear();
|
||||
|
||||
if (this.downloadFileList.Count == 0)
|
||||
Exit(true);
|
||||
else
|
||||
Exit(false);
|
||||
|
||||
evtDownload.Set();
|
||||
}
|
||||
|
||||
//To delete or move to old files
|
||||
void MoveFolderToOld(string oldPath, string newPath)
|
||||
{
|
||||
if (File.Exists(oldPath + ".old"))
|
||||
File.Delete(oldPath + ".old");
|
||||
|
||||
if (File.Exists(oldPath))
|
||||
File.Move(oldPath, oldPath + ".old");
|
||||
|
||||
|
||||
|
||||
File.Move(newPath, oldPath);
|
||||
//File.Delete(oldPath + ".old");
|
||||
}
|
||||
|
||||
delegate void ShowCurrentDownloadFileNameCallBack(string name);
|
||||
private void ShowCurrentDownloadFileName(string name)
|
||||
{
|
||||
if (this.labelCurrentItem.InvokeRequired)
|
||||
{
|
||||
ShowCurrentDownloadFileNameCallBack cb = new ShowCurrentDownloadFileNameCallBack(ShowCurrentDownloadFileName);
|
||||
this.Invoke(cb, new object[] { name });
|
||||
}
|
||||
else
|
||||
{
|
||||
this.labelCurrentItem.Text = name;
|
||||
}
|
||||
}
|
||||
|
||||
delegate void SetProcessBarCallBack(int current, int total);
|
||||
private void SetProcessBar(int current, int total)
|
||||
{
|
||||
if (this.progressBarCurrent.InvokeRequired)
|
||||
{
|
||||
SetProcessBarCallBack cb = new SetProcessBarCallBack(SetProcessBar);
|
||||
this.Invoke(cb, new object[] { current, total });
|
||||
}
|
||||
else
|
||||
{
|
||||
this.progressBarCurrent.Value = current;
|
||||
this.progressBarTotal.Value = total;
|
||||
}
|
||||
}
|
||||
|
||||
delegate void ExitCallBack(bool success);
|
||||
private void Exit(bool success)
|
||||
{
|
||||
if (this.InvokeRequired)
|
||||
{
|
||||
ExitCallBack cb = new ExitCallBack(Exit);
|
||||
this.Invoke(cb, new object[] { success });
|
||||
}
|
||||
else
|
||||
{
|
||||
this.isFinished = success;
|
||||
this.DialogResult = success ? DialogResult.OK : DialogResult.Cancel;
|
||||
this.Close();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnCancel(object sender, EventArgs e)
|
||||
{
|
||||
//bCancel = true;
|
||||
//evtDownload.Set();
|
||||
//evtPerDonwload.Set();
|
||||
ShowErrorAndRestartApplication();
|
||||
}
|
||||
|
||||
private void DealWithDownloadErrors()
|
||||
{
|
||||
try
|
||||
{
|
||||
//Test Network is OK or not.
|
||||
Config config = Config.LoadConfig(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, ConstFile.FILENAME));
|
||||
WebClient client = new WebClient();
|
||||
client.DownloadString(config.ServerUrl);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//log the error message,you can use the application's log code
|
||||
ShowErrorAndRestartApplication();
|
||||
}
|
||||
}
|
||||
|
||||
private void ShowErrorAndRestartApplication()
|
||||
{
|
||||
MessageBox.Show(ConstFile.NOTNETWORK,ConstFile.MESSAGETITLE, MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
CommonUnitity.RestartApplication();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
243
net.nutcore.aliddns/AutoUpdater/DownloadProgress.designer.cs
generated
Normal file
243
net.nutcore.aliddns/AutoUpdater/DownloadProgress.designer.cs
generated
Normal file
@ -0,0 +1,243 @@
|
||||
namespace KnightsWarriorAutoupdater
|
||||
{
|
||||
partial class DownloadProgress
|
||||
{
|
||||
/// <summary>
|
||||
/// 必需的设计器变量。
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// 清理所有正在使用的资源。
|
||||
/// </summary>
|
||||
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows 窗体设计器生成的代码
|
||||
|
||||
/// <summary>
|
||||
/// 设计器支持所需的方法 - 不要
|
||||
/// 使用代码编辑器修改此方法的内容。
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(DownloadProgress));
|
||||
this.labelCurrentItem = new System.Windows.Forms.Label();
|
||||
this.buttonOk = new System.Windows.Forms.Button();
|
||||
this.panel1 = new System.Windows.Forms.Panel();
|
||||
this.pictureBox1 = new System.Windows.Forms.PictureBox();
|
||||
this.label4 = new System.Windows.Forms.Label();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.panel2 = new System.Windows.Forms.Panel();
|
||||
this.progressBarTotal = new System.Windows.Forms.ProgressBar();
|
||||
this.progressBarCurrent = new System.Windows.Forms.ProgressBar();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.labelCurrent = new System.Windows.Forms.Label();
|
||||
this.label6 = new System.Windows.Forms.Label();
|
||||
this.panel3 = new System.Windows.Forms.Panel();
|
||||
this.splitter1 = new System.Windows.Forms.Splitter();
|
||||
this.splitter2 = new System.Windows.Forms.Splitter();
|
||||
this.panel1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
|
||||
this.panel2.SuspendLayout();
|
||||
this.panel3.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// labelCurrentItem
|
||||
//
|
||||
this.labelCurrentItem.AutoSize = true;
|
||||
this.labelCurrentItem.Location = new System.Drawing.Point(82, 7);
|
||||
this.labelCurrentItem.Name = "labelCurrentItem";
|
||||
this.labelCurrentItem.Size = new System.Drawing.Size(0, 12);
|
||||
this.labelCurrentItem.TabIndex = 0;
|
||||
//
|
||||
// buttonOk
|
||||
//
|
||||
this.buttonOk.Location = new System.Drawing.Point(211, 9);
|
||||
this.buttonOk.Name = "buttonOk";
|
||||
this.buttonOk.Size = new System.Drawing.Size(83, 23);
|
||||
this.buttonOk.TabIndex = 2;
|
||||
this.buttonOk.Text = "取消";
|
||||
this.buttonOk.UseVisualStyleBackColor = true;
|
||||
this.buttonOk.Click += new System.EventHandler(this.OnCancel);
|
||||
//
|
||||
// panel1
|
||||
//
|
||||
this.panel1.BackColor = System.Drawing.SystemColors.ButtonHighlight;
|
||||
this.panel1.Controls.Add(this.pictureBox1);
|
||||
this.panel1.Controls.Add(this.label4);
|
||||
this.panel1.Controls.Add(this.label2);
|
||||
this.panel1.Dock = System.Windows.Forms.DockStyle.Top;
|
||||
this.panel1.Location = new System.Drawing.Point(0, 0);
|
||||
this.panel1.Name = "panel1";
|
||||
this.panel1.Size = new System.Drawing.Size(352, 63);
|
||||
this.panel1.TabIndex = 3;
|
||||
//
|
||||
// pictureBox1
|
||||
//
|
||||
this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
|
||||
this.pictureBox1.Location = new System.Drawing.Point(264, 3);
|
||||
this.pictureBox1.Name = "pictureBox1";
|
||||
this.pictureBox1.Size = new System.Drawing.Size(79, 55);
|
||||
this.pictureBox1.TabIndex = 1;
|
||||
this.pictureBox1.TabStop = false;
|
||||
//
|
||||
// label4
|
||||
//
|
||||
this.label4.AutoSize = true;
|
||||
this.label4.Location = new System.Drawing.Point(16, 35);
|
||||
this.label4.Name = "label4";
|
||||
this.label4.Size = new System.Drawing.Size(221, 12);
|
||||
this.label4.TabIndex = 0;
|
||||
this.label4.Text = "在升级过程中,不影响您使用其它应用。";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(16, 18);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(149, 12);
|
||||
this.label2.TabIndex = 0;
|
||||
this.label2.Text = "升级过程可能持续几分钟。";
|
||||
//
|
||||
// panel2
|
||||
//
|
||||
this.panel2.Controls.Add(this.progressBarTotal);
|
||||
this.panel2.Controls.Add(this.progressBarCurrent);
|
||||
this.panel2.Controls.Add(this.label1);
|
||||
this.panel2.Controls.Add(this.labelCurrent);
|
||||
this.panel2.Controls.Add(this.labelCurrentItem);
|
||||
this.panel2.Controls.Add(this.label6);
|
||||
this.panel2.ForeColor = System.Drawing.SystemColors.ControlDark;
|
||||
this.panel2.Location = new System.Drawing.Point(-3, 66);
|
||||
this.panel2.Name = "panel2";
|
||||
this.panel2.Size = new System.Drawing.Size(353, 108);
|
||||
this.panel2.TabIndex = 4;
|
||||
//
|
||||
// progressBarTotal
|
||||
//
|
||||
this.progressBarTotal.Location = new System.Drawing.Point(21, 63);
|
||||
this.progressBarTotal.Name = "progressBarTotal";
|
||||
this.progressBarTotal.Size = new System.Drawing.Size(313, 12);
|
||||
this.progressBarTotal.Step = 1;
|
||||
this.progressBarTotal.TabIndex = 4;
|
||||
//
|
||||
// progressBarCurrent
|
||||
//
|
||||
this.progressBarCurrent.Location = new System.Drawing.Point(20, 23);
|
||||
this.progressBarCurrent.Name = "progressBarCurrent";
|
||||
this.progressBarCurrent.Size = new System.Drawing.Size(314, 12);
|
||||
this.progressBarCurrent.Step = 1;
|
||||
this.progressBarCurrent.TabIndex = 5;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(19, 47);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(35, 12);
|
||||
this.label1.TabIndex = 2;
|
||||
this.label1.Text = "进度:";
|
||||
//
|
||||
// labelCurrent
|
||||
//
|
||||
this.labelCurrent.AutoSize = true;
|
||||
this.labelCurrent.Location = new System.Drawing.Point(19, 8);
|
||||
this.labelCurrent.Name = "labelCurrent";
|
||||
this.labelCurrent.Size = new System.Drawing.Size(59, 12);
|
||||
this.labelCurrent.TabIndex = 3;
|
||||
this.labelCurrent.Text = "正在下载:";
|
||||
//
|
||||
// label6
|
||||
//
|
||||
this.label6.AutoSize = true;
|
||||
this.label6.Location = new System.Drawing.Point(21, 87);
|
||||
this.label6.Name = "label6";
|
||||
this.label6.Size = new System.Drawing.Size(119, 12);
|
||||
this.label6.TabIndex = 0;
|
||||
this.label6.Text = "正在准备应用程序...";
|
||||
//
|
||||
// panel3
|
||||
//
|
||||
this.panel3.Controls.Add(this.buttonOk);
|
||||
this.panel3.Dock = System.Windows.Forms.DockStyle.Bottom;
|
||||
this.panel3.Location = new System.Drawing.Point(0, 177);
|
||||
this.panel3.Name = "panel3";
|
||||
this.panel3.Size = new System.Drawing.Size(352, 42);
|
||||
this.panel3.TabIndex = 4;
|
||||
//
|
||||
// splitter1
|
||||
//
|
||||
this.splitter1.BackColor = System.Drawing.SystemColors.InactiveBorder;
|
||||
this.splitter1.Dock = System.Windows.Forms.DockStyle.Top;
|
||||
this.splitter1.Location = new System.Drawing.Point(0, 63);
|
||||
this.splitter1.Name = "splitter1";
|
||||
this.splitter1.Size = new System.Drawing.Size(352, 2);
|
||||
this.splitter1.TabIndex = 5;
|
||||
this.splitter1.TabStop = false;
|
||||
//
|
||||
// splitter2
|
||||
//
|
||||
this.splitter2.BackColor = System.Drawing.SystemColors.InactiveBorder;
|
||||
this.splitter2.Dock = System.Windows.Forms.DockStyle.Bottom;
|
||||
this.splitter2.Location = new System.Drawing.Point(0, 175);
|
||||
this.splitter2.Name = "splitter2";
|
||||
this.splitter2.Size = new System.Drawing.Size(352, 2);
|
||||
this.splitter2.TabIndex = 6;
|
||||
this.splitter2.TabStop = false;
|
||||
//
|
||||
// DownloadProgress
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(352, 219);
|
||||
this.ControlBox = false;
|
||||
this.Controls.Add(this.splitter2);
|
||||
this.Controls.Add(this.splitter1);
|
||||
this.Controls.Add(this.panel3);
|
||||
this.Controls.Add(this.panel2);
|
||||
this.Controls.Add(this.panel1);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "DownloadProgress";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
this.Text = "升级中...";
|
||||
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.OnFormClosing);
|
||||
this.Load += new System.EventHandler(this.OnFormLoad);
|
||||
this.panel1.ResumeLayout(false);
|
||||
this.panel1.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
|
||||
this.panel2.ResumeLayout(false);
|
||||
this.panel2.PerformLayout();
|
||||
this.panel3.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Label labelCurrentItem;
|
||||
private System.Windows.Forms.Button buttonOk;
|
||||
private System.Windows.Forms.Panel panel1;
|
||||
private System.Windows.Forms.PictureBox pictureBox1;
|
||||
private System.Windows.Forms.Label label2;
|
||||
private System.Windows.Forms.Label label4;
|
||||
private System.Windows.Forms.Panel panel2;
|
||||
private System.Windows.Forms.ProgressBar progressBarTotal;
|
||||
private System.Windows.Forms.ProgressBar progressBarCurrent;
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.Label labelCurrent;
|
||||
private System.Windows.Forms.Label label6;
|
||||
private System.Windows.Forms.Panel panel3;
|
||||
private System.Windows.Forms.Splitter splitter1;
|
||||
private System.Windows.Forms.Splitter splitter2;
|
||||
}
|
||||
}
|
171
net.nutcore.aliddns/AutoUpdater/DownloadProgress.resx
Normal file
171
net.nutcore.aliddns/AutoUpdater/DownloadProgress.resx
Normal file
@ -0,0 +1,171 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
||||
<data name="pictureBox1.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
R0lGODlhSAA5AIcAAAAAAIAAAACAAICAAAAAgIAAgACAgLq/u8Hcw6bK8BZrviB+HiRwwSl7tCp0wyqI
|
||||
KC58vjGNLTSfYzOnZDakaDWrZj1qdjp9qDl8xjyVOjqtZDysazmtaz+wV0FseUBupkCFxkKPbkeNkEKV
|
||||
a0KaQkWdcEGncEK1OU1yfUeAwEyGyUaIzkiXc1GXlUmPxEmcS0idWEilOkuoR0mkdUuje0q1Qkq0WEmz
|
||||
Xkuzak6xdlC8RlaMaFGKz1SRpU+WvVKhUU+cdVKjYFO3RlO3U1h5jF+BZFyBjFmFxVyL01iPrlmW0FuW
|
||||
01ubo1mazlakUlupZVutiVq4VVjAS2HFVWNoVWVtXWV4m2mIo2aHu2aGw2GUu2eTxmOS1WCbtGKdyWCk
|
||||
nmSrZ2K3XmO6f2pzZmh4fGl9hmyU1m2lw2ye12ilumytaWu2aWi7XG2+bGjLWXN9enSAf3KVt3ORxnWZ
|
||||
pHSesHWbz3Se2XCm0HK3cW+yp3O9X3jFenPTXn+GdHmFg36Oqnqf23ym0ne2d3uzm36x0ne8doK7t3vB
|
||||
Yn/CmXjLc3vZYYOWm4Kn3YTBqoTFZX/HeoTGg4TFiYuq34yt0Yu03Y2/vo7Hao3FkY3Ri5aaiZKcqpiu
|
||||
z5S24ZS13pS+zpbKeZPFt5XPjpfJppuej5u34pnLcJrPl6KmlKSnnqWstaO+uaO85qPH0aPE3qbH5KLP
|
||||
eqXO1qLXn6qrk6yvprCym63G6KrUha7WjLLXlK3UnqrWqarrlLO1prS3sbi9pbm+sbHG1a7M3rXJvrfN
|
||||
6rXWjLXYorrW1bnT3rzcprDcrrXbtLProbe9nbzAp77FssDKprnbnsPfsbvhu73evcLDrMK+tMXIvsXP
|
||||
tsrZzsXV78Deqczd7cjjuc3QtMrWts3Vvc7Vxc7lxc7lz9bZutPazdbbwNTg8tblz9jm3Nzfwdng1d7h
|
||||
3d/n39/n79zs197t3uPt6+bu4+zx7ezy+Pb4+P7+/v/78J6inoCAgP8AAAD/AP//AAAA//8A/wD/////
|
||||
/yH/C05FVFNDQVBFMi4wAwEBAAAh+QQAAAAAACwAAAAASAA5AAAI/wDrCRxIsKDBgwgTKlzIsKHDhxAj
|
||||
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
|
||||
</value>
|
||||
</data>
|
||||
</root>
|
36
net.nutcore.aliddns/AutoUpdater/Properties/AssemblyInfo.cs
Normal file
36
net.nutcore.aliddns/AutoUpdater/Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("AutoUpdater")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("AutoUpdater")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2010")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("d35ff3b3-b353-429f-a874-bdcfd4850a1a")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
@ -5,6 +5,8 @@ VisualStudioVersion = 14.0.25420.1
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "net.nutcore.aliddns", "net.nutcore.aliddns\net.nutcore.aliddns.csproj", "{018BAB83-CA31-4BDE-BC01-EEC283CEABEA}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutoUpdater", "AutoUpdater\AutoUpdater.csproj", "{4BA4719C-C6AB-49BA-9754-848CA24C1FD6}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@ -15,6 +17,10 @@ Global
|
||||
{018BAB83-CA31-4BDE-BC01-EEC283CEABEA}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{018BAB83-CA31-4BDE-BC01-EEC283CEABEA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{018BAB83-CA31-4BDE-BC01-EEC283CEABEA}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{4BA4719C-C6AB-49BA-9754-848CA24C1FD6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{4BA4719C-C6AB-49BA-9754-848CA24C1FD6}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{4BA4719C-C6AB-49BA-9754-848CA24C1FD6}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{4BA4719C-C6AB-49BA-9754-848CA24C1FD6}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@ -1,389 +1,253 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Configuration;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
using System.Xml.Linq;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
namespace net.nutcore.aliddns
|
||||
{
|
||||
internal class AppConfigHelper
|
||||
{
|
||||
System.Configuration.Configuration configFile = null;
|
||||
private static readonly string configFileName = "aliddns_config.xml";
|
||||
private static readonly string appExePath = System.AppDomain.CurrentDomain.BaseDirectory;
|
||||
private static readonly string configFilePath = System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, configFileName);
|
||||
#region The private fields
|
||||
private static readonly string configFile = "aliddns_config.xml";
|
||||
private static readonly string configFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, configFile);
|
||||
#endregion
|
||||
|
||||
public Config config = new Config();
|
||||
/// <summary>
|
||||
/// 构造函数
|
||||
/// </summary>
|
||||
public AppConfigHelper()
|
||||
{
|
||||
ExeConfigurationFileMap map = new ExeConfigurationFileMap();
|
||||
map.ExeConfigFilename = configFilePath;
|
||||
try
|
||||
{
|
||||
if (!File.Exists(configFilePath))
|
||||
{
|
||||
CreatNewConfig(configFilePath);
|
||||
this.CreatDefaultConfig(configFilePath);
|
||||
this.LoadConfig(configFilePath);
|
||||
}
|
||||
else
|
||||
{
|
||||
XmlDocument xmlDoc = new XmlDocument();
|
||||
xmlDoc.Load(configFilePath);
|
||||
if(xmlDoc.SelectSingleNode("configuration") == null)
|
||||
this.LoadConfig(configFilePath);
|
||||
if(config == null)
|
||||
{
|
||||
Console.WriteLine("Config file setting error! New config file is created now!");
|
||||
FileInfo fileInfo = new FileInfo(configFilePath);
|
||||
fileInfo.MoveTo(configFilePath + ".bak");
|
||||
CreatNewConfig(configFilePath);
|
||||
this.CreatDefaultConfig(configFilePath);
|
||||
Console.WriteLine("New config file is created ok!");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (xmlDoc.SelectSingleNode(@"configuration/appSettings") == null)
|
||||
{
|
||||
Console.WriteLine("Config file has old format. Update now!");
|
||||
FileInfo fileInfo = new FileInfo(configFilePath);
|
||||
fileInfo.MoveTo(configFilePath + ".bak");
|
||||
CreatNewConfig(configFilePath);
|
||||
configFile = ConfigurationManager.OpenMappedExeConfiguration(map, ConfigurationUserLevel.None);
|
||||
xmlDoc.Load(configFilePath + ".bak");
|
||||
XmlNodeList oldNodes = xmlDoc.SelectSingleNode("configuration").ChildNodes;
|
||||
foreach (XmlNode node in oldNodes)
|
||||
{
|
||||
Console.WriteLine(node.Name.ToString() + " : " + node.InnerText.ToString());
|
||||
SetAppSetting(node.Name.ToString(), node.InnerText.ToString());
|
||||
}
|
||||
}
|
||||
this.LoadConfig(configFilePath);
|
||||
}
|
||||
}
|
||||
configFile = ConfigurationManager.OpenMappedExeConfiguration(map, ConfigurationUserLevel.None);
|
||||
GetAllAppSettings();
|
||||
}
|
||||
catch(Exception error)
|
||||
catch(Exception errMsg)
|
||||
{
|
||||
Console.WriteLine("Class AppConfigHelper running error! " + error);
|
||||
Console.WriteLine("AppConfigHelper() running error! " + errMsg);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建XML格式的配置文件configFile
|
||||
/// 创建XML格式的配置文件file
|
||||
/// </summary>
|
||||
/// <param name="configFile"></param>
|
||||
public void CreatNewConfig(string configFile)
|
||||
/// <param name="fFile"></param>
|
||||
public void CreatDefaultConfig(string file)
|
||||
{
|
||||
/*
|
||||
XmlDocument xmlDoc = new XmlDocument();
|
||||
xmlDoc.AppendChild(xmlDoc.CreateXmlDeclaration("1.0", "utf-8", string.Empty));
|
||||
this.config.startup.supportedRuntime.version = "v4.0";
|
||||
this.config.startup.supportedRuntime.sku = ".NETFramework,Version=v4.5.2";
|
||||
this.config.appSettings.Add(new Add("AliDDNSVersion", System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString()));
|
||||
this.config.appSettings.Add(new Add("AccessKeyID", ""));
|
||||
this.config.appSettings.Add(new Add("AccessKeySecret", ""));
|
||||
this.config.appSettings.Add(new Add("RecordID", ""));
|
||||
this.config.appSettings.Add(new Add("fullDomainName", "www.xxx.com"));
|
||||
this.config.appSettings.Add(new Add("TTL", "600"));
|
||||
this.config.appSettings.Add(new Add("WaitingTime", "600"));
|
||||
this.config.appSettings.Add(new Add("autoUpdate", "Off"));
|
||||
this.config.appSettings.Add(new Add("whatIsUrl", "http://whatismyip.akamai.com/,http://www.3322.org/dyndns/getip,http://ip.qq.com/,http://www.net.cn/static/customercare/yourip.asp"));
|
||||
this.config.appSettings.Add(new Add("autoBoot", "Off"));
|
||||
this.config.appSettings.Add(new Add("minimized", "Off"));
|
||||
this.config.appSettings.Add(new Add("logautosave", "Off"));
|
||||
this.config.appSettings.Add(new Add("ngrokauto", "Off"));
|
||||
this.config.appSettings.Add(new Add("ngrokexists", "Off"));
|
||||
|
||||
XmlElement configurationNode = xmlDoc.CreateElement("configuration");
|
||||
xmlDoc.AppendChild(configurationNode);
|
||||
|
||||
XmlElement startupNode = xmlDoc.CreateElement("startup");
|
||||
configurationNode.AppendChild(startupNode);
|
||||
|
||||
XmlElement supportedRuntimeNode = xmlDoc.CreateElement("supportedRuntime");
|
||||
startupNode.AppendChild(supportedRuntimeNode);
|
||||
supportedRuntimeNode.SetAttribute("version", "v4.0");
|
||||
supportedRuntimeNode.SetAttribute("sku", ".NETFramework,Version=v4.5.2");
|
||||
|
||||
XmlElement appsettingsNode = xmlDoc.CreateElement("appSettings");
|
||||
configurationNode.AppendChild(appsettingsNode);
|
||||
|
||||
xmlDoc.Save(configFilePath);
|
||||
*/
|
||||
XElement xElement = new XElement(
|
||||
new XElement("configuration",
|
||||
new XElement("startup",
|
||||
new XElement("supportedRuntime", new XAttribute("version", "v4.0"), new XAttribute("sku", ".NETFramework,Version=v4.5.2"))
|
||||
),
|
||||
new XElement("appSettings",
|
||||
new XElement("add", new XAttribute("key", "AliDDNS Version"), new XAttribute("value", System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString())),
|
||||
new XElement("add", new XAttribute("key", "AccessKeyID"), new XAttribute("value", "")),
|
||||
new XElement("add", new XAttribute("key", "AccessKeySecret"), new XAttribute("value", "")),
|
||||
new XElement("add", new XAttribute("key", "RecordID"), new XAttribute("value", "")),
|
||||
new XElement("add", new XAttribute("key", "fullDomainName"), new XAttribute("value", "www.xxx.com")),
|
||||
new XElement("add", new XAttribute("key", "WaitingTime"), new XAttribute("value", "600")),
|
||||
new XElement("add", new XAttribute("key", "autoUpdate"), new XAttribute("value", "Off")),
|
||||
new XElement("add", new XAttribute("key", "whatIsUrl"), new XAttribute("value", "http://whatismyip.akamai.com/,http://www.net.cn/static/customercare/yourip.asp")),
|
||||
new XElement("add", new XAttribute("key", "autoBoot"), new XAttribute("value", "Off")),
|
||||
new XElement("add", new XAttribute("key", "minimized"), new XAttribute("value", "Off")),
|
||||
new XElement("add", new XAttribute("key", "logautosave"), new XAttribute("value", "Off")),
|
||||
new XElement("add", new XAttribute("key", "TTL"), new XAttribute("value", "600")),
|
||||
new XElement("add", new XAttribute("key", "ngrokauto"), new XAttribute("value", "Off")),
|
||||
new XElement("add", new XAttribute("key", "ngrokexists"), new XAttribute("value", "Off")),
|
||||
new XElement("add", new XAttribute("key", "autoUpgrade"), new XAttribute("value", "Off")),
|
||||
new XElement("add", new XAttribute("key", "upgradeUrl"), new XAttribute("value", ""))
|
||||
)
|
||||
)
|
||||
);
|
||||
//需要指定编码格式,否则在读取时会抛:根级别上的数据无效。 第 1 行 位置 1异常
|
||||
XmlWriterSettings xmlDoc = new XmlWriterSettings();
|
||||
xmlDoc.Encoding = new UTF8Encoding(false);
|
||||
xmlDoc.Indent = true;
|
||||
XmlWriter xw = XmlWriter.Create(configFilePath, xmlDoc);
|
||||
xElement.Save(xw);//写入文件
|
||||
xw.Close();
|
||||
this.SaveConfig(configFilePath);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 在<appsettings></appsettings>下添加键和值
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="value"></param>
|
||||
public void AddAppSetting(string key, string value)
|
||||
public string GetAppSetting(string strKey)
|
||||
{
|
||||
configFile.AppSettings.Settings.Add(key, value);
|
||||
configFile.Save();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修改<appsettings></appsettings>下指定键的值
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="value"></param>
|
||||
public void SetAppSetting(string key, string value)
|
||||
{
|
||||
KeyValueConfigurationElement _key = configFile.AppSettings.Settings[key];
|
||||
if ( _key == null)
|
||||
foreach(Add item in config.appSettings)
|
||||
{
|
||||
configFile.AppSettings.Settings.Add(key, value);
|
||||
}
|
||||
else
|
||||
{
|
||||
configFile.AppSettings.Settings[key].Value = value;
|
||||
}
|
||||
configFile.Save();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取<appsettings></appsettings>下指定键的值
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <returns></returns>
|
||||
public string GetAppSetting(string key)
|
||||
{
|
||||
return configFile.AppSettings.Settings[key].Value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取<appSettings></appSettings>下所有键和值
|
||||
/// </summary>
|
||||
public string[] GetAllAppSettings()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (configFile.AppSettings.Settings.Count == 0)
|
||||
if(item.key.ToString() == strKey)
|
||||
{
|
||||
Console.WriteLine("AppSettings is empty.");
|
||||
return null;
|
||||
return item.value.ToString();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public bool SetAppSetting(string strKey, string strValue)
|
||||
{
|
||||
foreach(var item in config.appSettings)
|
||||
{
|
||||
if(item.key.ToString() == strKey)
|
||||
{
|
||||
item.value = strValue;
|
||||
this.SaveConfig(configFilePath);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool AddAppSetting(string strKey, string strValue)
|
||||
{
|
||||
foreach (var item in config.appSettings)
|
||||
{
|
||||
if (item.key.ToString() == strKey)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var key in configFile.AppSettings.Settings.AllKeys)
|
||||
{
|
||||
Console.WriteLine("Key: {0} Value: {1}", key, configFile.AppSettings.Settings[key].Value);
|
||||
}
|
||||
return configFile.AppSettings.Settings.AllKeys;
|
||||
config.appSettings.Add(new Add(strKey, strValue));
|
||||
this.SaveConfig(configFilePath);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (ConfigurationErrorsException)
|
||||
{
|
||||
Console.WriteLine("GetAllAppSettings() run error!");
|
||||
return null;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 移除<appSettings></appSettings>下指定键
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
public void DelAppSetting(string key)
|
||||
{
|
||||
configFile.AppSettings.Settings.Remove(key);
|
||||
configFile.Save();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 读取XML配置文件指定元素(Elements)下的值
|
||||
/// </summary>
|
||||
/// <param name="strElem"></param>
|
||||
/// <returns></returns>
|
||||
public ArrayList GetXmlElements(string strElem)
|
||||
{
|
||||
ArrayList list = new ArrayList();
|
||||
XmlDocument xmlDoc = new XmlDocument();
|
||||
xmlDoc.Load(configFilePath);
|
||||
XmlNodeList listNode = xmlDoc.SelectNodes(strElem);
|
||||
foreach (XmlElement el in listNode)
|
||||
{
|
||||
list.Add(el.InnerText);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 使用当前路径中的指定文件作为配置文件
|
||||
/// </summary>
|
||||
/// <param name="configFileName">配置文件名</param>
|
||||
public void SetConfigFile(string configFileName)
|
||||
{
|
||||
string configFilePath = System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, configFileName);
|
||||
System.AppDomain.CurrentDomain.SetData("APP_CONFIG_FILE", configFilePath);
|
||||
//ExeConfigurationFileMap map = new ExeConfigurationFileMap();
|
||||
//map.ExeConfigFilename = configFilePath;
|
||||
//configFile = ConfigurationManager.OpenMappedExeConfiguration(map, ConfigurationUserLevel.None);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 使用指定路径中的指定文件作为配置文件
|
||||
/// </summary>
|
||||
/// <param name="configFileName">配置文件名</param>
|
||||
/// <param name="configFileDirectory">配置文件路径</param>
|
||||
public void SetConfigFile(string configFileName, string configFileDirectory)
|
||||
{
|
||||
string configFilePath = System.IO.Path.Combine(configFileDirectory, configFileName);
|
||||
System.AppDomain.CurrentDomain.SetData("APP_CONFIG_FILE", configFilePath);
|
||||
//ExeConfigurationFileMap map = new ExeConfigurationFileMap();
|
||||
//map.ExeConfigFilename = configFilePath;
|
||||
//configFile = ConfigurationManager.OpenMappedExeConfiguration(map, ConfigurationUserLevel.None);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 判断appSettings中是否有指定键名
|
||||
/// </summary>
|
||||
/// /// <param name="strKey">键名</param>
|
||||
public bool isKeyExists(string strKey)
|
||||
{
|
||||
KeyValueConfigurationElement _key = configFile.AppSettings.Settings[strKey];
|
||||
if ( _key == null )
|
||||
foreach (var item in config.appSettings)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
if (item.key.ToString() == strKey)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修改配置文件指定键和值
|
||||
/// </summary>
|
||||
/// <param name="strKey"></param>
|
||||
/// <param name="value"></param>
|
||||
public static void ModifyAppSettings(string strKey, string value)
|
||||
#region The public method
|
||||
public void LoadConfig(string file)
|
||||
{
|
||||
var doc = new XmlDocument();
|
||||
//获得配置文件的全路径
|
||||
//var strFileName = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile;
|
||||
var strFileName = configFilePath;
|
||||
doc.Load(strFileName);
|
||||
|
||||
//找出名称为“add”的所有元素
|
||||
var nodes = doc.GetElementsByTagName("add");
|
||||
for (int i = 0; i < nodes.Count; i++)
|
||||
{
|
||||
//获得将当前元素的key属性
|
||||
var xmlAttributeCollection = nodes[i].Attributes;
|
||||
if (xmlAttributeCollection != null)
|
||||
{
|
||||
var att = xmlAttributeCollection["key"];
|
||||
if (att == null) continue;
|
||||
//根据元素的第一个属性来判断当前的元素是不是目标元素
|
||||
if (att.Value != strKey) continue;
|
||||
//对目标元素中的第二个属性赋值
|
||||
att = xmlAttributeCollection["value"];
|
||||
att.Value = value;
|
||||
}
|
||||
break;
|
||||
}
|
||||
//保存上面的修改
|
||||
doc.Save(strFileName);
|
||||
ConfigurationManager.RefreshSection("appSettings");
|
||||
XmlSerializer xs = new XmlSerializer(typeof(Config), new XmlRootAttribute("configuration"));
|
||||
StreamReader sr = new StreamReader(file);
|
||||
this.config = xs.Deserialize(sr) as Config;
|
||||
sr.Close();
|
||||
}
|
||||
static class ConfigurationUtil
|
||||
|
||||
public void SaveConfig(string file)
|
||||
{
|
||||
public static void Synchronize<T>() where T : SettingsBase
|
||||
{
|
||||
Type type = typeof(T);
|
||||
System.Reflection.FieldInfo fieldInfo = type.GetField("defaultInstance", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic);
|
||||
|
||||
SettingsBase newInstance = global::System.Configuration.ApplicationSettingsBase.Synchronized(Activator.CreateInstance<T>());
|
||||
|
||||
fieldInfo.SetValue(null, newInstance);
|
||||
|
||||
}
|
||||
public static System.Configuration.Configuration OpenConfiguration(string fileName)
|
||||
{
|
||||
string extention = Path.GetExtension(fileName);
|
||||
|
||||
string file = fileName.Substring(0, fileName.Length - extention.Length);
|
||||
bool createproxyFile = false;
|
||||
if (!File.Exists(file))
|
||||
{
|
||||
createproxyFile = true;
|
||||
File.CreateText(file).Dispose();
|
||||
}
|
||||
if (!File.Exists(fileName))
|
||||
{
|
||||
File.WriteAllText(fileName, "<configuration/>", Encoding.UTF8);
|
||||
}
|
||||
System.Configuration.Configuration config = System.Configuration.ConfigurationManager.OpenExeConfiguration(file);
|
||||
if (createproxyFile)
|
||||
{
|
||||
File.Delete(file);
|
||||
}
|
||||
return config;
|
||||
}
|
||||
public static ConfigurationSectionGroup CreateApplicationSettingsGroup(System.Configuration.Configuration config)
|
||||
{
|
||||
ConfigurationSectionGroup appsg = config.RootSectionGroup.SectionGroups.Get("applicationSettings");
|
||||
if (appsg == null)
|
||||
{
|
||||
appsg = new ApplicationSettingsGroup();
|
||||
//appsg.Type = typeof(ApplicationSettingsGroup).AssemblyQualifiedName;
|
||||
config.RootSectionGroup.SectionGroups.Add("applicationSettings", appsg);
|
||||
//创建节点
|
||||
}
|
||||
return appsg;
|
||||
|
||||
}
|
||||
|
||||
public static void WriteSettingElement(Configuration config, ConfigurationSectionGroup sectionGroup, SettingsSerializeAs sas, string name, string value, string namespaceclass)
|
||||
{
|
||||
|
||||
ConfigurationSection sec = sectionGroup.Sections.Get(namespaceclass);
|
||||
|
||||
System.Configuration.ClientSettingsSection clisec = sec as ClientSettingsSection;
|
||||
if (clisec == null)
|
||||
{
|
||||
//创建节
|
||||
clisec = new ClientSettingsSection();
|
||||
sectionGroup.Sections.Add(namespaceclass, clisec);
|
||||
}
|
||||
|
||||
SettingElement secEle = clisec.Settings.Get(name);
|
||||
if (secEle == null)
|
||||
{
|
||||
secEle = new SettingElement(name, sas);
|
||||
clisec.Settings.Add(secEle);
|
||||
|
||||
}
|
||||
secEle.Value.ValueXml = new XmlDocument().CreateElement("value");
|
||||
if (sas == SettingsSerializeAs.Xml)
|
||||
{
|
||||
|
||||
XmlDocument xmdoc = new XmlDocument();
|
||||
xmdoc.LoadXml(value);
|
||||
secEle.Value.ValueXml.InnerXml = xmdoc.DocumentElement.OuterXml;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
secEle.Value.ValueXml.InnerText = value;
|
||||
}
|
||||
}
|
||||
XmlSerializer xs = new XmlSerializer(typeof(Config));
|
||||
StreamWriter sw = new StreamWriter(file);
|
||||
xs.Serialize(sw, this.config);
|
||||
sw.Close();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
[XmlRoot("configuration")]
|
||||
public class Config
|
||||
{
|
||||
#region The private fields
|
||||
private StartUp startUp = new StartUp();
|
||||
private AppSettingList appSettingList = new AppSettingList();
|
||||
#endregion
|
||||
|
||||
#region The public property
|
||||
[XmlElement("startup")]
|
||||
public StartUp startup
|
||||
{
|
||||
get { return startUp; }
|
||||
set { startUp = value; }
|
||||
}
|
||||
[XmlArray("appSettings")]
|
||||
[XmlArrayItem("add")]
|
||||
public AppSettingList appSettings
|
||||
{
|
||||
get { return appSettingList; }
|
||||
set { appSettingList = value; }
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
public class StartUp
|
||||
{
|
||||
#region The private fields
|
||||
private SupportedRuntime supportedruntime = new SupportedRuntime();
|
||||
#endregion
|
||||
|
||||
#region The public property
|
||||
public SupportedRuntime supportedRuntime
|
||||
{
|
||||
get { return supportedruntime; }
|
||||
set { supportedruntime = value; }
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
public class SupportedRuntime
|
||||
{
|
||||
#region The private fields
|
||||
private string strVer = "v4.0";
|
||||
private string strSku = ".NETFramework,Version=v4.5.2";
|
||||
#endregion
|
||||
|
||||
#region The public property
|
||||
[XmlAttribute("version")]
|
||||
public string version
|
||||
{
|
||||
get { return strVer; }
|
||||
set { strVer = value; }
|
||||
}
|
||||
[XmlAttribute("sku")]
|
||||
public string sku
|
||||
{
|
||||
get { return strSku; }
|
||||
set { strSku = value; }
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
public class AppSettingList : List<Add>
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public class Add
|
||||
{
|
||||
#region The private fields
|
||||
private string strKey = string.Empty;
|
||||
private string strValue = string.Empty;
|
||||
#endregion
|
||||
|
||||
#region The public property
|
||||
[XmlAttribute("key")]
|
||||
public string key
|
||||
{
|
||||
get { return strKey; }
|
||||
set { strKey = value; }
|
||||
}
|
||||
[XmlAttribute("value")]
|
||||
public string value
|
||||
{
|
||||
get { return strValue; }
|
||||
set { strValue = value; }
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region The constructor of LocalFile
|
||||
public Add(string key, string value)
|
||||
{
|
||||
this.strKey = key;
|
||||
this.strValue = value;
|
||||
}
|
||||
|
||||
public Add()
|
||||
{
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
BIN
net.nutcore.aliddns/net.nutcore.aliddns/AutoUpdater.dll
Normal file
BIN
net.nutcore.aliddns/net.nutcore.aliddns/AutoUpdater.dll
Normal file
Binary file not shown.
@ -65,8 +65,9 @@
|
||||
this.autoUpdateTimer = new System.Windows.Forms.Timer(this.components);
|
||||
this.notifyIcon_sysTray = new System.Windows.Forms.NotifyIcon(this.components);
|
||||
this.contextMenuStrip_sysTrayMenu = new System.Windows.Forms.ContextMenuStrip(this.components);
|
||||
this.toolStripMenuItem_Exit = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.ToolStripMenuItem_checkUpdate = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.ToolStripMenuItem_Exit = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.ToolStripMenuItem_checkUpgrade = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.ToolStripMenuItem_about = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.groupBox_netstate = new System.Windows.Forms.GroupBox();
|
||||
this.label_DomainIpStatus = new System.Windows.Forms.Label();
|
||||
this.label_localIpStatus = new System.Windows.Forms.Label();
|
||||
@ -112,6 +113,7 @@
|
||||
this.columnHeader_subdomain = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.tabPage_other = new System.Windows.Forms.TabPage();
|
||||
this.groupBox4 = new System.Windows.Forms.GroupBox();
|
||||
this.checkBox_silence = new System.Windows.Forms.CheckBox();
|
||||
this.textBox_upgradeUrl = new System.Windows.Forms.TextBox();
|
||||
this.label17 = new System.Windows.Forms.Label();
|
||||
this.button_updateTest = new System.Windows.Forms.Button();
|
||||
@ -497,24 +499,32 @@
|
||||
//
|
||||
this.contextMenuStrip_sysTrayMenu.ImageScalingSize = new System.Drawing.Size(24, 24);
|
||||
this.contextMenuStrip_sysTrayMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.toolStripMenuItem_Exit,
|
||||
this.ToolStripMenuItem_checkUpdate});
|
||||
this.ToolStripMenuItem_Exit,
|
||||
this.ToolStripMenuItem_checkUpgrade,
|
||||
this.ToolStripMenuItem_about});
|
||||
this.contextMenuStrip_sysTrayMenu.Name = "contextMenuStrip1";
|
||||
this.contextMenuStrip_sysTrayMenu.Size = new System.Drawing.Size(125, 48);
|
||||
this.contextMenuStrip_sysTrayMenu.Size = new System.Drawing.Size(125, 70);
|
||||
//
|
||||
// toolStripMenuItem_Exit
|
||||
// ToolStripMenuItem_Exit
|
||||
//
|
||||
this.toolStripMenuItem_Exit.Name = "toolStripMenuItem_Exit";
|
||||
this.toolStripMenuItem_Exit.Size = new System.Drawing.Size(124, 22);
|
||||
this.toolStripMenuItem_Exit.Text = "退出";
|
||||
this.toolStripMenuItem_Exit.Click += new System.EventHandler(this.toolStripMenuItem_Quit_Click);
|
||||
this.ToolStripMenuItem_Exit.Name = "ToolStripMenuItem_Exit";
|
||||
this.ToolStripMenuItem_Exit.Size = new System.Drawing.Size(124, 22);
|
||||
this.ToolStripMenuItem_Exit.Text = "退出";
|
||||
this.ToolStripMenuItem_Exit.Click += new System.EventHandler(this.ToolStripMenuItem_Quit_Click);
|
||||
//
|
||||
// ToolStripMenuItem_checkUpdate
|
||||
// ToolStripMenuItem_checkUpgrade
|
||||
//
|
||||
this.ToolStripMenuItem_checkUpdate.Name = "ToolStripMenuItem_checkUpdate";
|
||||
this.ToolStripMenuItem_checkUpdate.Size = new System.Drawing.Size(124, 22);
|
||||
this.ToolStripMenuItem_checkUpdate.Text = "检查升级";
|
||||
this.ToolStripMenuItem_checkUpdate.Click += new System.EventHandler(this.ToolStripMenuItem_checkUpgrade_Click);
|
||||
this.ToolStripMenuItem_checkUpgrade.Name = "ToolStripMenuItem_checkUpgrade";
|
||||
this.ToolStripMenuItem_checkUpgrade.Size = new System.Drawing.Size(124, 22);
|
||||
this.ToolStripMenuItem_checkUpgrade.Text = "检查升级";
|
||||
this.ToolStripMenuItem_checkUpgrade.Click += new System.EventHandler(this.ToolStripMenuItem_checkUpgrade_Click);
|
||||
//
|
||||
// ToolStripMenuItem_about
|
||||
//
|
||||
this.ToolStripMenuItem_about.Name = "ToolStripMenuItem_about";
|
||||
this.ToolStripMenuItem_about.Size = new System.Drawing.Size(124, 22);
|
||||
this.ToolStripMenuItem_about.Text = "关于";
|
||||
this.ToolStripMenuItem_about.Click += new System.EventHandler(this.ToolStripMenuItem_about_Click);
|
||||
//
|
||||
// groupBox_netstate
|
||||
//
|
||||
@ -711,6 +721,7 @@
|
||||
this.checkBox_autoUpdate.TabIndex = 3;
|
||||
this.checkBox_autoUpdate.Text = "自动更新";
|
||||
this.checkBox_autoUpdate.UseVisualStyleBackColor = true;
|
||||
this.checkBox_autoUpdate.CheckedChanged += new System.EventHandler(this.checkBox_autoUpdate_CheckedChanged);
|
||||
//
|
||||
// label3
|
||||
//
|
||||
@ -959,6 +970,7 @@
|
||||
//
|
||||
// groupBox4
|
||||
//
|
||||
this.groupBox4.Controls.Add(this.checkBox_silence);
|
||||
this.groupBox4.Controls.Add(this.textBox_upgradeUrl);
|
||||
this.groupBox4.Controls.Add(this.label17);
|
||||
this.groupBox4.Controls.Add(this.button_updateTest);
|
||||
@ -969,14 +981,25 @@
|
||||
this.groupBox4.Controls.Add(this.label30);
|
||||
this.groupBox4.Location = new System.Drawing.Point(3, 94);
|
||||
this.groupBox4.Name = "groupBox4";
|
||||
this.groupBox4.Size = new System.Drawing.Size(427, 72);
|
||||
this.groupBox4.Size = new System.Drawing.Size(427, 99);
|
||||
this.groupBox4.TabIndex = 1;
|
||||
this.groupBox4.TabStop = false;
|
||||
this.groupBox4.Text = "升级设置";
|
||||
//
|
||||
// checkBox_silence
|
||||
//
|
||||
this.checkBox_silence.AutoSize = true;
|
||||
this.checkBox_silence.Location = new System.Drawing.Point(258, 20);
|
||||
this.checkBox_silence.Name = "checkBox_silence";
|
||||
this.checkBox_silence.Size = new System.Drawing.Size(96, 16);
|
||||
this.checkBox_silence.TabIndex = 8;
|
||||
this.checkBox_silence.Text = "升级静默完成";
|
||||
this.checkBox_silence.UseVisualStyleBackColor = true;
|
||||
this.checkBox_silence.CheckedChanged += new System.EventHandler(this.checkBox_silence_CheckedChanged);
|
||||
//
|
||||
// textBox_upgradeUrl
|
||||
//
|
||||
this.textBox_upgradeUrl.Location = new System.Drawing.Point(42, 43);
|
||||
this.textBox_upgradeUrl.Location = new System.Drawing.Point(48, 44);
|
||||
this.textBox_upgradeUrl.Name = "textBox_upgradeUrl";
|
||||
this.textBox_upgradeUrl.Size = new System.Drawing.Size(194, 21);
|
||||
this.textBox_upgradeUrl.TabIndex = 7;
|
||||
@ -985,7 +1008,7 @@
|
||||
// label17
|
||||
//
|
||||
this.label17.AutoSize = true;
|
||||
this.label17.Location = new System.Drawing.Point(7, 46);
|
||||
this.label17.Location = new System.Drawing.Point(7, 47);
|
||||
this.label17.Name = "label17";
|
||||
this.label17.Size = new System.Drawing.Size(35, 12);
|
||||
this.label17.TabIndex = 6;
|
||||
@ -993,7 +1016,7 @@
|
||||
//
|
||||
// button_updateTest
|
||||
//
|
||||
this.button_updateTest.Location = new System.Drawing.Point(258, 40);
|
||||
this.button_updateTest.Location = new System.Drawing.Point(258, 42);
|
||||
this.button_updateTest.Name = "button_updateTest";
|
||||
this.button_updateTest.Size = new System.Drawing.Size(96, 25);
|
||||
this.button_updateTest.TabIndex = 5;
|
||||
@ -1004,18 +1027,18 @@
|
||||
// checkBox_autoUpgrade
|
||||
//
|
||||
this.checkBox_autoUpgrade.AutoSize = true;
|
||||
this.checkBox_autoUpgrade.Location = new System.Drawing.Point(258, 18);
|
||||
this.checkBox_autoUpgrade.Location = new System.Drawing.Point(9, 20);
|
||||
this.checkBox_autoUpgrade.Name = "checkBox_autoUpgrade";
|
||||
this.checkBox_autoUpgrade.Size = new System.Drawing.Size(96, 16);
|
||||
this.checkBox_autoUpgrade.Size = new System.Drawing.Size(108, 16);
|
||||
this.checkBox_autoUpgrade.TabIndex = 4;
|
||||
this.checkBox_autoUpgrade.Text = "自动检测升级";
|
||||
this.checkBox_autoUpgrade.Text = "自动检测新版本";
|
||||
this.checkBox_autoUpgrade.UseVisualStyleBackColor = true;
|
||||
this.checkBox_autoUpgrade.CheckedChanged += new System.EventHandler(this.checkBox_autoUpgrade_CheckedChanged);
|
||||
//
|
||||
// label_latestVer
|
||||
//
|
||||
this.label_latestVer.AutoSize = true;
|
||||
this.label_latestVer.Location = new System.Drawing.Point(185, 19);
|
||||
this.label_latestVer.Location = new System.Drawing.Point(213, 77);
|
||||
this.label_latestVer.Name = "label_latestVer";
|
||||
this.label_latestVer.Size = new System.Drawing.Size(47, 12);
|
||||
this.label_latestVer.TabIndex = 3;
|
||||
@ -1024,7 +1047,7 @@
|
||||
// label28
|
||||
//
|
||||
this.label28.AutoSize = true;
|
||||
this.label28.Location = new System.Drawing.Point(125, 19);
|
||||
this.label28.Location = new System.Drawing.Point(148, 77);
|
||||
this.label28.Name = "label28";
|
||||
this.label28.Size = new System.Drawing.Size(59, 12);
|
||||
this.label28.TabIndex = 2;
|
||||
@ -1033,7 +1056,7 @@
|
||||
// label_currentVer
|
||||
//
|
||||
this.label_currentVer.AutoSize = true;
|
||||
this.label_currentVer.Location = new System.Drawing.Point(71, 19);
|
||||
this.label_currentVer.Location = new System.Drawing.Point(72, 77);
|
||||
this.label_currentVer.Name = "label_currentVer";
|
||||
this.label_currentVer.Size = new System.Drawing.Size(47, 12);
|
||||
this.label_currentVer.TabIndex = 1;
|
||||
@ -1042,7 +1065,7 @@
|
||||
// label30
|
||||
//
|
||||
this.label30.AutoSize = true;
|
||||
this.label30.Location = new System.Drawing.Point(7, 19);
|
||||
this.label30.Location = new System.Drawing.Point(7, 77);
|
||||
this.label30.Name = "label30";
|
||||
this.label30.Size = new System.Drawing.Size(59, 12);
|
||||
this.label30.TabIndex = 0;
|
||||
@ -1182,7 +1205,7 @@
|
||||
private System.Windows.Forms.TextBox textBox_recordId;
|
||||
private System.Windows.Forms.NotifyIcon notifyIcon_sysTray;
|
||||
private System.Windows.Forms.ContextMenuStrip contextMenuStrip_sysTrayMenu;
|
||||
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem_Exit;
|
||||
private System.Windows.Forms.ToolStripMenuItem ToolStripMenuItem_Exit;
|
||||
private System.Windows.Forms.GroupBox groupBox_netstate;
|
||||
private System.Windows.Forms.Label label_DomainIpStatus;
|
||||
private System.Windows.Forms.Label label_localIpStatus;
|
||||
@ -1204,7 +1227,7 @@
|
||||
private System.Windows.Forms.Label label15;
|
||||
private System.Windows.Forms.Label label13;
|
||||
private System.Windows.Forms.TextBox textBox_TTL;
|
||||
private System.Windows.Forms.ToolStripMenuItem ToolStripMenuItem_checkUpdate;
|
||||
private System.Windows.Forms.ToolStripMenuItem ToolStripMenuItem_checkUpgrade;
|
||||
private System.Windows.Forms.CheckBox checkBox_ngrokAuto;
|
||||
private System.Windows.Forms.Button button_addNewDomain;
|
||||
private System.Windows.Forms.Button button_addUrl;
|
||||
@ -1254,6 +1277,8 @@
|
||||
private System.Windows.Forms.TextBox textBox_upgradeUrl;
|
||||
private System.Windows.Forms.Label label17;
|
||||
private System.Windows.Forms.Button button_updateTest;
|
||||
private System.Windows.Forms.CheckBox checkBox_silence;
|
||||
private System.Windows.Forms.ToolStripMenuItem ToolStripMenuItem_about;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12,6 +12,8 @@ using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
using static Aliyun.Acs.Alidns.Model.V20150109.DescribeSubDomainRecordsResponse;
|
||||
using KnightsWarriorAutoupdater;
|
||||
using System.Xml;
|
||||
|
||||
namespace net.nutcore.aliddns
|
||||
{
|
||||
@ -24,6 +26,8 @@ namespace net.nutcore.aliddns
|
||||
private NgrokHelper ngrok = new NgrokHelper();
|
||||
//初始化appconfig操作类
|
||||
private AppConfigHelper cfg = new AppConfigHelper();
|
||||
//初始化升级功能类
|
||||
private AutoUpdater autoUpdater = new AutoUpdater();
|
||||
|
||||
public Form_main()
|
||||
{
|
||||
@ -122,8 +126,7 @@ namespace net.nutcore.aliddns
|
||||
{
|
||||
//执行upgrade
|
||||
textBox_log.AppendText(System.DateTime.Now.ToString() + " " + "正在自动检测升级! " + "\r\n");
|
||||
Thread newThread = new Thread(new ParameterizedThreadStart(simpleUpgrade));
|
||||
newThread.Start(cfg.GetAppSetting("upgradeUrl"));
|
||||
Updater();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -173,24 +176,17 @@ namespace net.nutcore.aliddns
|
||||
|
||||
textBox_TTL.Text = cfg.GetAppSetting("TTL").ToString();
|
||||
|
||||
if (cfg.GetAppSetting("autoUpgrade").ToString() == "On") checkBox_autoUpgrade.Checked = true;
|
||||
else checkBox_autoUpgrade.Checked = false;
|
||||
|
||||
if (cfg.GetAppSetting("ngrokauto").ToString() == "On") checkBox_ngrokAuto.Checked = true;
|
||||
else checkBox_ngrokAuto.Checked = false;
|
||||
|
||||
if (cfg.GetAppSetting("ngrokexists").ToString() == "On") checkBox_ngrokExists.Checked = true;
|
||||
else checkBox_ngrokExists.Checked = false;
|
||||
|
||||
if (cfg.isKeyExists("upgradeUrl"))
|
||||
{
|
||||
textBox_upgradeUrl.Text = cfg.GetAppSetting("upgradeUrl").ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
cfg.SetAppSetting("upgradeUrl", "https://dev.51zyy.cn/aliddns/updater.xml");
|
||||
textBox_upgradeUrl.Text = cfg.GetAppSetting("upgradeUrl").ToString();
|
||||
}
|
||||
if (autoUpdater.config.Enabled) checkBox_autoUpgrade.Checked = true;
|
||||
else checkBox_autoUpgrade.Checked = false;
|
||||
if (autoUpdater.config.Silence) checkBox_silence.Checked = true;
|
||||
else checkBox_silence.Checked = false;
|
||||
textBox_upgradeUrl.Text = autoUpdater.config.ServerUrl.ToString();
|
||||
|
||||
textBox_log.AppendText(System.DateTime.Now.ToString() + " " + "设置文件读取成功!" + "\r\n");
|
||||
return true;
|
||||
@ -577,12 +573,19 @@ namespace net.nutcore.aliddns
|
||||
}
|
||||
}
|
||||
|
||||
private void toolStripMenuItem_Quit_Click(object sender, EventArgs e)
|
||||
private void ToolStripMenuItem_Quit_Click(object sender, EventArgs e)
|
||||
{
|
||||
ngrok.Stop();
|
||||
this.Dispose();
|
||||
}
|
||||
|
||||
private void ToolStripMenuItem_about_Click(object sender, EventArgs e)
|
||||
{
|
||||
this.Show();
|
||||
this.WindowState = FormWindowState.Normal;
|
||||
this.tabControl1.SelectedTab = tabPage_about;
|
||||
}
|
||||
|
||||
private void notifyIcon_sysTray_MouseDoubleClick(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (this.WindowState == FormWindowState.Minimized)
|
||||
@ -823,14 +826,7 @@ namespace net.nutcore.aliddns
|
||||
private void ToolStripMenuItem_checkUpgrade_Click(object sender, EventArgs e)
|
||||
{
|
||||
textBox_log.AppendText(System.DateTime.Now.ToString() + " " + "正在检测升级! " + "\r\n");
|
||||
simpleUpgrade(textBox_upgradeUrl.Text);
|
||||
|
||||
Version remoteVer = new Version(label_latestVer.Text);
|
||||
Version localVer = new Version(label_currentVer.Text);
|
||||
if (remoteVer > localVer)
|
||||
MessageBox.Show("发现新版本: " + remoteVer);
|
||||
else
|
||||
MessageBox.Show("没有新版本,无需升级!");
|
||||
Updater();
|
||||
}
|
||||
|
||||
private void checkBox_ngrokAuto_CheckedChanged(object sender, EventArgs e)
|
||||
@ -961,12 +957,14 @@ namespace net.nutcore.aliddns
|
||||
{
|
||||
if (checkBox_autoUpgrade.Checked == true)
|
||||
{
|
||||
cfg.SetAppSetting("autoUpgrade", "On");
|
||||
autoUpdater.config.Enabled = true;
|
||||
autoUpdater.config.SaveConfig(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, ConstFile.FILENAME));
|
||||
textBox_log.AppendText(System.DateTime.Now.ToString() + " " + "软件自动检测升级启用!" + "\r\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
cfg.SetAppSetting("autoUpgrade", "Off");
|
||||
autoUpdater.config.Enabled = false;
|
||||
autoUpdater.config.SaveConfig(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, ConstFile.FILENAME));
|
||||
textBox_log.AppendText(System.DateTime.Now.ToString() + " " + "软件自动检测升级关闭!" + "\r\n");
|
||||
}
|
||||
}
|
||||
@ -1083,7 +1081,7 @@ namespace net.nutcore.aliddns
|
||||
ngrok.ngrokConfig.server_addr = textBox_serverAddr.Text.ToString();
|
||||
ngrok.ngrokConfig.tunnels = tunnel_saved;
|
||||
|
||||
ngrok.Save();
|
||||
ngrok.SaveConfig();
|
||||
}
|
||||
|
||||
private void button_addnew_Click(object sender, EventArgs e)
|
||||
@ -1160,12 +1158,14 @@ namespace net.nutcore.aliddns
|
||||
private void button_upgradeTest_Click(object sender, EventArgs e)
|
||||
{
|
||||
textBox_log.AppendText(System.DateTime.Now.ToString() + " " + "正在检测升级! " + "\r\n");
|
||||
simpleUpgrade(textBox_upgradeUrl.Text);
|
||||
//simpleUpgrade(textBox_upgradeUrl.Text);
|
||||
Updater();
|
||||
}
|
||||
|
||||
private void textBox_upgradeUrl_Leave(object sender, EventArgs e)
|
||||
{
|
||||
cfg.SetAppSetting("upgradeUrl", this.textBox_upgradeUrl.Text.ToString());
|
||||
autoUpdater.config.ServerUrl = this.textBox_upgradeUrl.Text.ToString();
|
||||
autoUpdater.config.SaveConfig(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, ConstFile.FILENAME));
|
||||
textBox_log.AppendText(System.DateTime.Now.ToString() + " " + "升级地址修改成功!" + "\r\n");
|
||||
}
|
||||
|
||||
@ -1188,6 +1188,7 @@ namespace net.nutcore.aliddns
|
||||
this.textBox_log.AppendText(System.DateTime.Now.ToString() + " " + "获取远程版本信息成功,远程版本: " + txt.ToString() + "\r\n");
|
||||
};
|
||||
this.Invoke(appendText, remoteVer[1].ToString());
|
||||
//this.autoUpdater();
|
||||
}
|
||||
else if(remoteVer[0].ToString() == "NULL")
|
||||
{
|
||||
@ -1214,6 +1215,7 @@ namespace net.nutcore.aliddns
|
||||
{
|
||||
this.label_latestVer.Text = remoteVer[1].ToString();
|
||||
this.textBox_log.AppendText(System.DateTime.Now.ToString() + " " + "获取远程版本信息成功,远程版本: " + remoteVer[1].ToString() + "\r\n");
|
||||
//this.autoUpdater();
|
||||
}
|
||||
else if (remoteVer[0].ToString() == "NULL")
|
||||
{
|
||||
@ -1225,5 +1227,78 @@ namespace net.nutcore.aliddns
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void Updater()
|
||||
{
|
||||
#region check and download new version program
|
||||
bool bHasError = false;
|
||||
//IAutoUpdater autoUpdater = new AutoUpdater();
|
||||
try
|
||||
{
|
||||
autoUpdater.Update();
|
||||
}
|
||||
catch (WebException exp)
|
||||
{
|
||||
//MessageBox.Show("Can not find the specified resource");
|
||||
this.textBox_log.AppendText(System.DateTime.Now.ToString() + " " + "访问网络出错:" + exp + "\r\n");
|
||||
bHasError = true;
|
||||
}
|
||||
catch (XmlException exp)
|
||||
{
|
||||
bHasError = true;
|
||||
//MessageBox.Show("Download the upgrade file error");
|
||||
this.textBox_log.AppendText(System.DateTime.Now.ToString() + " " + "下载升级文件出错:" + exp + "\r\n");
|
||||
}
|
||||
catch (NotSupportedException exp)
|
||||
{
|
||||
bHasError = true;
|
||||
//MessageBox.Show("Upgrade address configuration error");
|
||||
this.textBox_log.AppendText(System.DateTime.Now.ToString() + " " + "升级地址设置错误:" + exp + "\r\n");
|
||||
}
|
||||
catch (ArgumentException exp)
|
||||
{
|
||||
bHasError = true;
|
||||
//MessageBox.Show("Download the upgrade file error");
|
||||
this.textBox_log.AppendText(System.DateTime.Now.ToString() + " " + "下载升级文件出错:" + exp + "\r\n");
|
||||
}
|
||||
catch (Exception exp)
|
||||
{
|
||||
bHasError = true;
|
||||
//MessageBox.Show("An error occurred during the upgrade process");
|
||||
this.textBox_log.AppendText(System.DateTime.Now.ToString() + " " + "升级过程中发现错误:" + exp + "\r\n");
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (bHasError == true)
|
||||
{
|
||||
try
|
||||
{
|
||||
autoUpdater.RollBack();
|
||||
}
|
||||
catch (Exception exp)
|
||||
{
|
||||
//Log the message to your file or database
|
||||
this.textBox_log.AppendText(System.DateTime.Now.ToString() + " " + "升级回滚出错:" + exp + "\r\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
private void checkBox_silence_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (checkBox_silence.Checked == true)
|
||||
{
|
||||
autoUpdater.config.Silence = true;
|
||||
autoUpdater.config.SaveConfig(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, ConstFile.FILENAME));
|
||||
textBox_log.AppendText(System.DateTime.Now.ToString() + " " + "设置升级过程静默开启!" + "\r\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
autoUpdater.config.Silence = false;
|
||||
autoUpdater.config.SaveConfig(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, ConstFile.FILENAME));
|
||||
textBox_log.AppendText(System.DateTime.Now.ToString() + " " + "设置升级过程静默关闭!" + "\r\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,30 +11,41 @@ namespace net.nutcore.aliddns
|
||||
{
|
||||
internal class NgrokHelper
|
||||
{
|
||||
#region The private fields
|
||||
private static readonly string ngrokExecutable = "ngrok.exe";
|
||||
private static readonly string ngrokYamlConfig = "ngrok.cfg";
|
||||
public static readonly string currentDirectory = Path.GetDirectoryName(Application.ExecutablePath);
|
||||
public static readonly string ngrokExecutableFile = Path.Combine(currentDirectory, ngrokExecutable);
|
||||
public static readonly string ngrokConfigFile = Path.Combine(currentDirectory, ngrokYamlConfig);
|
||||
private static readonly string currentDirectory = AppDomain.CurrentDomain.BaseDirectory;
|
||||
private static readonly string ngrokExecutableFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, ngrokExecutable);
|
||||
private static readonly string ngrokConfigFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, ngrokYamlConfig);
|
||||
private static string localHost = "localhost:4040";
|
||||
#endregion
|
||||
|
||||
public Config ngrokConfig = new Config();
|
||||
|
||||
public NgrokHelper()
|
||||
{
|
||||
if (!File.Exists(ngrokConfigFile))
|
||||
try
|
||||
{
|
||||
this.CreateDefaultConfig(ngrokConfigFile);
|
||||
this.Load();
|
||||
}
|
||||
else
|
||||
{
|
||||
FileInfo filereader = new FileInfo(ngrokConfigFile);
|
||||
if (filereader.Length == 0)
|
||||
if (!File.Exists(ngrokConfigFile))
|
||||
{
|
||||
this.CreateDefaultConfig(ngrokConfigFile);
|
||||
this.LoadConfig(ngrokConfigFile);
|
||||
}
|
||||
else
|
||||
{
|
||||
FileInfo filereader = new FileInfo(ngrokConfigFile);
|
||||
if (filereader.Length == 0)
|
||||
{
|
||||
this.CreateDefaultConfig(ngrokConfigFile);
|
||||
}
|
||||
this.LoadConfig(ngrokConfigFile);
|
||||
}
|
||||
this.Load();
|
||||
}
|
||||
catch (Exception errMsg)
|
||||
{
|
||||
Console.WriteLine("NgrokHelper() running error! " + errMsg);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class Config
|
||||
@ -135,14 +146,14 @@ namespace net.nutcore.aliddns
|
||||
}
|
||||
}
|
||||
|
||||
public void Load()
|
||||
public void LoadConfig(string file)
|
||||
{
|
||||
var yaml = File.ReadAllText(ngrokConfigFile);
|
||||
var yaml = File.ReadAllText(file);
|
||||
var deserializer = new Deserializer();
|
||||
this.ngrokConfig = deserializer.Deserialize<Config>(yaml);
|
||||
}
|
||||
|
||||
public void Save()
|
||||
public void SaveConfig()
|
||||
{
|
||||
var serializer = new SerializerBuilder().Build();
|
||||
var yaml = serializer.Serialize(this.ngrokConfig);
|
||||
|
@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
||||
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
|
||||
// 方法是按如下所示使用“*”: :
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("3.9.0.0")]
|
||||
[assembly: AssemblyFileVersion("3.9.0.0")]
|
||||
[assembly: AssemblyVersion("3.9.1.0")]
|
||||
[assembly: AssemblyFileVersion("3.9.1.0")]
|
||||
|
28
net.nutcore.aliddns/net.nutcore.aliddns/Settings.cs
Normal file
28
net.nutcore.aliddns/net.nutcore.aliddns/Settings.cs
Normal file
@ -0,0 +1,28 @@
|
||||
namespace net.nutcore.aliddns.Properties {
|
||||
|
||||
|
||||
// 通过此类可以处理设置类的特定事件:
|
||||
// 在更改某个设置的值之前将引发 SettingChanging 事件。
|
||||
// 在更改某个设置的值之后将引发 PropertyChanged 事件。
|
||||
// 在加载设置值之后将引发 SettingsLoaded 事件。
|
||||
// 在保存设置值之前将引发 SettingsSaving 事件。
|
||||
internal sealed partial class Settings {
|
||||
|
||||
public Settings() {
|
||||
// // 若要为保存和更改设置添加事件处理程序,请取消注释下列行:
|
||||
//
|
||||
// this.SettingChanging += this.SettingChangingEventHandler;
|
||||
//
|
||||
// this.SettingsSaving += this.SettingsSavingEventHandler;
|
||||
//
|
||||
}
|
||||
|
||||
private void SettingChangingEventHandler(object sender, System.Configuration.SettingChangingEventArgs e) {
|
||||
// 在此处添加用于处理 SettingChangingEvent 事件的代码。
|
||||
}
|
||||
|
||||
private void SettingsSavingEventHandler(object sender, System.ComponentModel.CancelEventArgs e) {
|
||||
// 在此处添加用于处理 SettingsSaving 事件的代码。
|
||||
}
|
||||
}
|
||||
}
|
@ -62,6 +62,9 @@
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>.\aliyun-net-sdk-Core.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="AutoUpdater">
|
||||
<HintPath>.\AutoUpdater.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Newtonsoft.Json.12.0.3\lib\net40\Newtonsoft.Json.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
@ -95,6 +98,7 @@
|
||||
<Compile Include="Form_tunnelEdit.Designer.cs">
|
||||
<DependentUpon>Form_tunnelEdit.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Settings.cs" />
|
||||
<Compile Include="YamlHelper.cs" />
|
||||
<Compile Include="EncryptHelper.cs" />
|
||||
<Compile Include="Form_main.cs">
|
||||
|
@ -1,3 +1,9 @@
|
||||
v3.9.1.0
|
||||
|
||||
1、添加升级组件,来源:https://github.com/knightswarrior/AppAutoUpdater
|
||||
2、修复小BUG。
|
||||
|
||||
|
||||
v3.9.0.0
|
||||
|
||||
1、重新设计窗口标签布局。
|
||||
|
Loading…
Reference in New Issue
Block a user