v3.8.4.8 1、实现实时更新配置文件。2、调整简化代码实现。3、DEBUG...

This commit is contained in:
wisdomwei201804 2018-07-01 21:47:29 +08:00
parent 129a12536f
commit 7da0d1c193
6 changed files with 215 additions and 191 deletions

View File

@ -14,85 +14,122 @@ namespace net.nutcore.aliddns
internal class AppConfigHelper
{
System.Configuration.Configuration configFile = null;
private static readonly string configFileName = "aliddns_config1.xml";
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);
/// <summary>
/// 构造函数
/// </summary>
public AppConfigHelper()
{
ExeConfigurationFileMap map = new ExeConfigurationFileMap();
map.ExeConfigFilename = configFilePath;
try
{
if (!File.Exists(configFilePath))
{
/*
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.AppendChild(xmlDoc.CreateXmlDeclaration("1.0", "utf-8", string.Empty));
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", "")),
new XElement("add", new XAttribute("key", "WaitingTime"), new XAttribute("value", "")),
new XElement("add", new XAttribute("key", "autoUpdate"), new XAttribute("value", "")),
new XElement("add", new XAttribute("key", "whatIsUrl"), new XAttribute("value", "")),
new XElement("add", new XAttribute("key", "autoBoot"), new XAttribute("value", "")),
new XElement("add", new XAttribute("key", "minimized"), new XAttribute("value", "")),
new XElement("add", new XAttribute("key", "logautosave"), new XAttribute("value", "")),
new XElement("add", new XAttribute("key", "TTL"), new XAttribute("value", "")),
new XElement("add", new XAttribute("key", "autoCheckUpdate"), new XAttribute("value", "")),
new XElement("add", new XAttribute("key", "ngrokauto"), 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.Dispose();
//xw.Flush();
//xw.Close();
CreatNewConfig(configFilePath);
}
else
{
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(configFilePath);
if(xmlDoc.SelectSingleNode("configuration") == null)
{
Console.WriteLine("Config file setting error! New config file is creating now!");
FileInfo fileInfo = new FileInfo(configFilePath);
fileInfo.MoveTo(configFilePath + ".bak");
CreatNewConfig(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());
SaveAppSetting(node.Name.ToString(), node.InnerText.ToString());
}
}
}
}
ExeConfigurationFileMap map = new ExeConfigurationFileMap();
map.ExeConfigFilename = configFilePath;
configFile = ConfigurationManager.OpenMappedExeConfiguration(map, ConfigurationUserLevel.None);
GetAllAppSettings();
//GetAllAppSettings();
}
catch(Exception)
catch(Exception error)
{
Console.WriteLine("Class AppConfigHelper running error!");
Console.WriteLine("Class AppConfigHelper running error!" + error);
}
}
/// <summary>
/// 创建XML格式的配置文件configFile
/// </summary>
/// <param name="configFile"></param>
public void CreatNewConfig(string configFile)
{
/*
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.AppendChild(xmlDoc.CreateXmlDeclaration("1.0", "utf-8", string.Empty));
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", "")),
new XElement("add", new XAttribute("key", "WaitingTime"), new XAttribute("value", "")),
new XElement("add", new XAttribute("key", "autoUpdate"), new XAttribute("value", "")),
new XElement("add", new XAttribute("key", "whatIsUrl"), new XAttribute("value", "")),
new XElement("add", new XAttribute("key", "autoBoot"), new XAttribute("value", "")),
new XElement("add", new XAttribute("key", "minimized"), new XAttribute("value", "")),
new XElement("add", new XAttribute("key", "logautosave"), new XAttribute("value", "")),
new XElement("add", new XAttribute("key", "TTL"), new XAttribute("value", "")),
new XElement("add", new XAttribute("key", "autoCheckUpdate"), new XAttribute("value", "")),
new XElement("add", new XAttribute("key", "ngrokauto"), 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.Dispose();
//xw.Flush();
//xw.Close();
}
/// <summary>
/// 在<appsettings></appsettings>下添加键和值
/// </summary>

View File

@ -8,6 +8,7 @@ namespace net.nutcore.aliddns
{
public partial class Form_About : Form
{
private AppConfigHelper cfg = new AppConfigHelper();
public Form_About()
{
@ -34,61 +35,17 @@ namespace net.nutcore.aliddns
private void checkBox_autoCheckUpdate_CheckedChanged(object sender, EventArgs e)
{
string ExePath = System.AppDomain.CurrentDomain.BaseDirectory;
string config_file = ExePath + "aliddns_config.xml";
if(File.Exists(config_file))
{
XmlDocument xmlDOC = new XmlDocument();
xmlDOC.Load(config_file);
if (xmlDOC.GetElementsByTagName("autoCheckUpdate")[0] == null)
{
XmlNode node = xmlDOC.CreateNode(XmlNodeType.Element, "autoCheckUpdate",null);
if (checkBox_autoCheckUpdate.Checked == true)
node.InnerText = "On";
else
node.InnerText = "Off";
xmlDOC.DocumentElement.AppendChild(node);
xmlDOC.Save(config_file);
}
else
{
XmlNode node = xmlDOC.GetElementsByTagName("autoCheckUpdate")[0];
if (checkBox_autoCheckUpdate.Checked == true)
node.InnerText = "On";
else
node.InnerText = "Off";
xmlDOC.DocumentElement.AppendChild(node);
xmlDOC.Save(config_file);
}
}
/*
ExeConfigurationFileMap map = new ExeConfigurationFileMap();
map.ExeConfigFilename = config_file;
Configuration config = ConfigurationManager.OpenMappedExeConfiguration(map, ConfigurationUserLevel.None);
if(checkBox_autoCheckUpdate.Checked == true)
{
if (config.AppSettings.Settings["autoCheckUpdate"] == null)
{
config.AppSettings.Settings.Add("autoCheckUpdate", "On");
}
else
{
config.AppSettings.Settings["autoCheckUpdate"].Value = "On";
}
cfg.SaveAppSetting("autoCheckUpdate", "On");
//mainForm.textBox_log.AppendText(System.DateTime.Now.ToString() + " " + "软件自动检测升级启用!" + "\r\n");
}
else
{
if (config.AppSettings.Settings["autoCheckUpdate"] == null)
{
config.AppSettings.Settings.Add("autoCheckUpdate", "Off");
}
else
{
config.AppSettings.Settings["autoCheckUpdate"].Value = "Off";
}
cfg.SaveAppSetting("autoCheckUpdate", "Off");
//mainForm.textBox_log.AppendText(System.DateTime.Now.ToString() + " " + "软件自动检测升级关闭!" + "\r\n");
}
config.Save();
*/
}
private void Form_About_Load(object sender, EventArgs e)

View File

@ -179,7 +179,7 @@
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(117, 99);
this.label3.Location = new System.Drawing.Point(117, 95);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(77, 12);
this.label3.TabIndex = 4;
@ -188,7 +188,7 @@
// label_nextUpdateSeconds
//
this.label_nextUpdateSeconds.ForeColor = System.Drawing.Color.Red;
this.label_nextUpdateSeconds.Location = new System.Drawing.Point(87, 99);
this.label_nextUpdateSeconds.Location = new System.Drawing.Point(87, 96);
this.label_nextUpdateSeconds.Name = "label_nextUpdateSeconds";
this.label_nextUpdateSeconds.Size = new System.Drawing.Size(30, 12);
this.label_nextUpdateSeconds.TabIndex = 3;
@ -355,6 +355,7 @@
this.textBox_TTL.Size = new System.Drawing.Size(37, 21);
this.textBox_TTL.TabIndex = 15;
this.textBox_TTL.Text = "600";
this.textBox_TTL.Leave += new System.EventHandler(this.textBox_TTL_Leave);
//
// button_ShowHide
//
@ -372,7 +373,7 @@
this.checkAndSaveConfig.Name = "checkAndSaveConfig";
this.checkAndSaveConfig.Size = new System.Drawing.Size(93, 23);
this.checkAndSaveConfig.TabIndex = 10;
this.checkAndSaveConfig.Text = "测试并保存";
this.checkAndSaveConfig.Text = "测试连接";
this.checkAndSaveConfig.UseVisualStyleBackColor = true;
this.checkAndSaveConfig.Click += new System.EventHandler(this.checkConfig_Click);
//
@ -392,6 +393,7 @@
this.newSeconds.Size = new System.Drawing.Size(60, 21);
this.newSeconds.TabIndex = 7;
this.newSeconds.Text = "60";
this.newSeconds.Leave += new System.EventHandler(this.newSeconds_Leave);
//
// label7
//
@ -418,7 +420,7 @@
this.fullDomainName.Size = new System.Drawing.Size(135, 21);
this.fullDomainName.TabIndex = 4;
this.fullDomainName.Text = "www.xxx.com";
this.fullDomainName.ModifiedChanged += new System.EventHandler(this.fullDomainName_ModifiedChanged);
this.fullDomainName.Leave += new System.EventHandler(this.fullDomainName_Leave);
//
// accessKeySecret
//
@ -428,6 +430,7 @@
this.accessKeySecret.Size = new System.Drawing.Size(192, 21);
this.accessKeySecret.TabIndex = 3;
this.accessKeySecret.Text = "null";
this.accessKeySecret.Leave += new System.EventHandler(this.accessKeySecret_Leave);
//
// label5
//
@ -446,6 +449,7 @@
this.accessKeyId.Size = new System.Drawing.Size(192, 21);
this.accessKeyId.TabIndex = 1;
this.accessKeyId.Text = "null";
this.accessKeyId.Leave += new System.EventHandler(this.accessKeyId_Leave);
//
// label4
//
@ -626,6 +630,7 @@
this.comboBox_whatIsUrl.Size = new System.Drawing.Size(189, 20);
this.comboBox_whatIsUrl.TabIndex = 18;
this.comboBox_whatIsUrl.Text = "http://whatismyip.akamai.com/";
this.comboBox_whatIsUrl.Leave += new System.EventHandler(this.comboBox_whatIsUrl_Leave);
//
// button_whatIsTest
//

View File

@ -70,27 +70,6 @@ namespace net.nutcore.aliddns
*/
textBox_log.AppendText(System.DateTime.Now.ToString() + " " + "当前用户需要文件写入和注册表操作权限,否则相关参数不起作用!" + "\r\n");
try //检查设置文件,如果没有则新建,并赋值默认值
{
string ExePath = System.AppDomain.CurrentDomain.BaseDirectory;
string config_file = ExePath + "aliddns_config.xml";
if (File.Exists(config_file) != true) //当设置文件aliddns_config.xml不存在时创建一个新的。
{
textBox_log.AppendText(System.DateTime.Now.ToString() + " " + "没有找到设置文件 aliddns_config.xml重新创建" + "\r\n");
if (saveConfigFile())
{
textBox_log.AppendText(System.DateTime.Now.ToString() + " " + "设置文件 aliddns_config.xml 创建成功!" + "\r\n");
textBox_log.AppendText(System.DateTime.Now.ToString() + " " + "设置文件设置项目默认赋值完成!" + "\r\n");
textBox_log.AppendText(System.DateTime.Now.ToString() + " " + "请填写正确内容,点击“测试并保存”完成设置!" + "\r\n");
}
}
}
catch(Exception error)
{
textBox_log.AppendText(System.DateTime.Now.ToString() + " " + "运行出错!信息: " + error + "\r\n");
this.Dispose();
}
//读取设置文件aliddns_config.xml
if (readConfigFile())
{
@ -156,60 +135,30 @@ namespace net.nutcore.aliddns
{
try
{
//Create xml object
string ExePath = System.AppDomain.CurrentDomain.BaseDirectory;
string config_file = ExePath + "aliddns_config.xml";
XmlDocument xmlDOC = new XmlDocument();
xmlDOC.Load(config_file);
//XmlNodeReader readXML = new XmlNodeReader(xmlDOC);
//textBox_log.AppendText(System.DateTime.Now.ToString() + " DEBUG: " + readXML.Value + "\r\n"); //显示读取内容用于调试DEBUG。
XmlNodeList nodes = xmlDOC.SelectSingleNode("configuration").ChildNodes; //读取config节点下所有元素
/*
for (int i = 0; i < nodes.Count; i++)
{
textBox_log.AppendText(System.DateTime.Now.ToString() + " " + nodes[i].Name + ":" + nodes[i].InnerText + "\r\n"); //显示读取内容用于调试DEBUG。
}
string[] config = new string[nodes.Count]; //创建一个设置读取数组用于存储读取内容
int i = 0;
textBox_log.AppendText(System.DateTime.Now.ToString() + " " + "设置文件找到,开始读取..." + "\r\n");
while (readXML.Read())
{
readXML.MoveToElement(); //Forward
if (readXML.NodeType == XmlNodeType.Text) //(node.NodeType 是Text时即是最内层 即innertext值node.Attributes为null。
{
textBox_log.AppendText(System.DateTime.Now.ToString() + " " + readXML.NodeType + "\r\n"); //显示读取内容用于调试DEBUG。
config[i] = readXML.Value;
//此行用于调试读取内容
//textBox_log.AppendText(System.DateTime.Now.ToString() + " " + "项目[" + i + "]: " + config[i] + "\r\n"); //显示读取内容用于调试DEBUG。
i++;
}
}*/
accessKeyId.Text = EncryptHelper.AESDecrypt(nodes[0].InnerText);
accessKeySecret.Text = EncryptHelper.AESDecrypt(nodes[1].InnerText);
//accessKeyId.Text = nodes[0].InnerText;
//accessKeySecret.Text = nodes[1].InnerText;
recordId.Text = nodes[2].InnerText;
fullDomainName.Text = nodes[3].InnerText;
label_nextUpdateSeconds.Text = newSeconds.Text = nodes[4].InnerText;
if (nodes[5].InnerText == "On") checkBox_autoUpdate.Checked = true;
accessKeyId.Text = EncryptHelper.AESDecrypt(cfg.GetAppSetting("AccessKeyID").ToString());
accessKeySecret.Text = EncryptHelper.AESDecrypt(cfg.GetAppSetting("AccessKeySecret").ToString());
recordId.Text = cfg.GetAppSetting("RecordID").ToString();
fullDomainName.Text = cfg.GetAppSetting("fullDomainName").ToString();
label_nextUpdateSeconds.Text = newSeconds.Text = cfg.GetAppSetting("WaitingTime").ToString();
if (cfg.GetAppSetting("autoUpdate").ToString() == "On") checkBox_autoUpdate.Checked = true;
else checkBox_autoUpdate.Checked = false;
comboBox_whatIsUrl.Text = nodes[6].InnerText;
comboBox_whatIsUrl.Text = cfg.GetAppSetting("whatIsUrl").ToString();
if (nodes[7].InnerText == "On") checkBox_autoBoot.Checked = true;
if (cfg.GetAppSetting("autoBoot").ToString() == "On") checkBox_autoBoot.Checked = true;
else checkBox_autoBoot.Checked = false;
if (nodes[8].InnerText == "On") checkBox_minimized.Checked = true;
if (cfg.GetAppSetting("minimized").ToString() == "On") checkBox_minimized.Checked = true;
else checkBox_minimized.Checked = false;
if (nodes[9].InnerText == "On") checkBox_logAutoSave.Checked = true;
if (cfg.GetAppSetting("logautosave").ToString() == "On") checkBox_logAutoSave.Checked = true;
else checkBox_logAutoSave.Checked = false;
textBox_TTL.Text = nodes[10].InnerText;
textBox_TTL.Text = cfg.GetAppSetting("TTL").ToString();
if (nodes[11].InnerText == "On") checkUpdate = true;
if (cfg.GetAppSetting("autoCheckUpdate").ToString() == "On") checkUpdate = true;
else checkUpdate = false;
if (nodes[12].InnerText == "On")
if (cfg.GetAppSetting("ngrokauto").ToString() == "On")
{
checkBox_ngrok.Checked = true;
button_ngrok.Enabled = false;
@ -577,16 +526,11 @@ namespace net.nutcore.aliddns
client = new DefaultAcsClient(clientProfile);
if (setRecordId()) //检查能否从服务器返回RecordId返回则设置正确否则设置不正确
{
textBox_log.AppendText(System.DateTime.Now.ToString() + " " + "设置项目内容填写正确,即将保存到设置文件! " + "\r\n");
if (saveConfigFile()) //检查设置文件是否保存成功
textBox_log.AppendText(System.DateTime.Now.ToString() + " " + "设置文件保存成功! " + "\r\n");
else
textBox_log.AppendText(System.DateTime.Now.ToString() + " " + "设置文件保存失败,请检查文件权限! " + "\r\n");
textBox_log.AppendText(System.DateTime.Now.ToString() + " " + "阿里云DNS服务返回RecordId连接成功 " + "\r\n");
}
else
{
textBox_log.AppendText(System.DateTime.Now.ToString() + " " + "阿里云DNS服务没有返回RecordId设置项目内容没有保存" + "\r\n");
textBox_log.AppendText(System.DateTime.Now.ToString() + " " + "阿里云DNS服务没有返回RecordId请检查设置项目是否正确" + "\r\n");
}
}
catch (Exception error)
@ -678,11 +622,6 @@ namespace net.nutcore.aliddns
}
}
private void fullDomainName_ModifiedChanged(object sender, EventArgs e)
{
textBox_log.AppendText(System.DateTime.Now.ToString() + " " + "域名修改后请测试并保存!" + "\r\n");
}
private void checkBox_autoBoot_CheckedChanged(object sender, EventArgs e)
{
try
@ -695,6 +634,7 @@ namespace net.nutcore.aliddns
Microsoft.Win32.RegistryKey Rkey = Microsoft.Win32.Registry.LocalMachine.CreateSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run");
Rkey.SetValue("AliDDNS Tray", thisExecutablePath);
Rkey.Close();
cfg.SaveAppSetting("autoBoot", "On");
textBox_log.AppendText(System.DateTime.Now.ToString() + " " + "随系统启动自动运行设置成功!" + "\r\n");
}
else
@ -702,6 +642,7 @@ namespace net.nutcore.aliddns
Microsoft.Win32.RegistryKey Rkey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
Rkey.DeleteValue("AliDDNS Tray");
Rkey.Close();
cfg.SaveAppSetting("autoBoot", "Off");
textBox_log.AppendText(System.DateTime.Now.ToString() + " " + "随系统启动自动运行取消!" + "\r\n");
}
}
@ -720,9 +661,15 @@ namespace net.nutcore.aliddns
private void checkBox_logAutoSave_CheckedChanged(object sender, EventArgs e)
{
if (checkBox_logAutoSave.Checked == true)
{
cfg.SaveAppSetting("ngrokauto", "On");
textBox_log.AppendText(System.DateTime.Now.ToString() + " " + "日志自动转储启用成功日志超过1万行将自动转储。" + "\r\n");
}
else
{
cfg.SaveAppSetting("ngrokauto", "Off");
textBox_log.AppendText(System.DateTime.Now.ToString() + " " + "日志自动转储取消!" + "\r\n");
}
}
private void logToFiles()
@ -760,17 +707,29 @@ namespace net.nutcore.aliddns
private void checkBox_autoUpdate_CheckedChanged(object sender, EventArgs e)
{
if(checkBox_autoUpdate.Checked == true)
{
cfg.SaveAppSetting("autoUpdate", "On");
textBox_log.AppendText(System.DateTime.Now.ToString() + " " + "域名记录自动更新启用成功!" + "\r\n");
}
else
{
cfg.SaveAppSetting("autoUpdate", "Off");
textBox_log.AppendText(System.DateTime.Now.ToString() + " " + "域名记录自动更新取消!" + "\r\n");
}
}
private void checkBox_minimized_CheckedChanged(object sender, EventArgs e)
{
if (checkBox_minimized.Checked == true)
{
cfg.SaveAppSetting("minimized", "On");
textBox_log.AppendText(System.DateTime.Now.ToString() + " " + "软件启动时驻留到系统托盘启用!" + "\r\n");
}
else
{
cfg.SaveAppSetting("minimized", "Off");
textBox_log.AppendText(System.DateTime.Now.ToString() + " " + "软件启动时驻留到系统托盘取消!" + "\r\n");
}
}
private void button_setIP_Click(object sender, EventArgs e)
@ -879,9 +838,11 @@ namespace net.nutcore.aliddns
private async void checkBox_ngrok_CheckedChanged(object sender, EventArgs e)
{
if (checkBox_ngrok.Checked == true)
if (checkBox_ngrok.Checked == true)
{
button_ngrok.Enabled = false;
cfg.SaveAppSetting("ngrokauto", "On");
//检测ngrok.exe是否存在
if (ngrok.IsExists())
{
@ -895,6 +856,7 @@ namespace net.nutcore.aliddns
}
else
{
cfg.SaveAppSetting("ngrokauto", "Off");
await ngrok.Stop();
button_ngrok.Enabled = true;
textBox_log.AppendText(System.DateTime.Now.ToString() + " " + "Ngrok功能关闭再次启动将不会加载" + "\r\n");
@ -915,5 +877,65 @@ namespace net.nutcore.aliddns
MessageBox.Show("设置在当前目录没有发现ngrok.exe请往官网下载自行编译。\nNgrok官网https://ngrok.com/download");
}
}
private void fullDomainName_Leave(object sender, EventArgs e)
{
DialogResult result = MessageBox.Show("请确认域名: " + this.fullDomainName.Text.ToString(), "提醒", MessageBoxButtons.YesNo);
if (result == DialogResult.Yes)
{
cfg.SaveAppSetting("fullDomainName", this.fullDomainName.Text.ToString());
textBox_log.AppendText(System.DateTime.Now.ToString() + " " + "域名已经保存,点击测试连接将测试创建域名记录!" + "\r\n");
}
else
{
this.fullDomainName.Focus();
}
}
private void accessKeyId_Leave(object sender, EventArgs e)
{
DialogResult result = MessageBox.Show("请确认accessKeyId:\n" + this.accessKeyId.Text.ToString(), "提醒", MessageBoxButtons.YesNo);
if (result == DialogResult.Yes)
{
cfg.SaveAppSetting("AccessKeyID", EncryptHelper.AESEncrypt(this.accessKeyId.Text.ToString()));
textBox_log.AppendText(System.DateTime.Now.ToString() + " " + "accessKeyId已经保存请完成设置录入后点击测试连接" + "\r\n");
}
else
{
this.accessKeyId.Focus();
}
}
private void accessKeySecret_Leave(object sender, EventArgs e)
{
DialogResult result = MessageBox.Show("请确认accessKeySecret:\n" + this.accessKeySecret.Text.ToString(), "提醒", MessageBoxButtons.YesNo);
if (result == DialogResult.Yes)
{
cfg.SaveAppSetting("AccessKeySecret", EncryptHelper.AESEncrypt(this.accessKeySecret.Text.ToString()));
textBox_log.AppendText(System.DateTime.Now.ToString() + " " + "accessKeySecret已经保存请完成设置录入后点击测试连接" + "\r\n");
}
else
{
this.accessKeySecret.Focus();
}
}
private void textBox_TTL_Leave(object sender, EventArgs e)
{
cfg.SaveAppSetting("TTL",this.textBox_TTL.Text.ToString());
textBox_log.AppendText(System.DateTime.Now.ToString() + " " + "TTL设置修改保存成功" + "\r\n");
}
private void newSeconds_Leave(object sender, EventArgs e)
{
cfg.SaveAppSetting("WaitingTime", this.textBox_TTL.Text.ToString());
textBox_log.AppendText(System.DateTime.Now.ToString() + " " + "自动更新倒计时设置修改保存成功!" + "\r\n");
}
private void comboBox_whatIsUrl_Leave(object sender, EventArgs e)
{
cfg.SaveAppSetting("whatIsUrl", this.comboBox_whatIsUrl.Text.ToString());
textBox_log.AppendText(System.DateTime.Now.ToString() + " " + "公网IP查询网址修改保存成功" + "\r\n");
}
}
}

View File

@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
// 方法是按如下所示使用“*”: :
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("3.8.4.1")]
[assembly: AssemblyFileVersion("3.8.4.1")]
[assembly: AssemblyVersion("3.8.4.8")]
[assembly: AssemblyFileVersion("3.8.4.8")]

View File

@ -1,3 +1,6 @@
v3.8.4.8
1、实现实时更新配置文件。2、调整简化代码实现。3、DEBUG...
v3.8.4.1
1、配置文件操作优化中...