//
------------------------------------------------------------
//
All Rights Reserved , Copyright (C) 2010 , CDPF , Ltd.
//
------------------------------------------------------------
using
System;
using
System.Configuration;
using
System.Windows.Forms;
using
Utilities;
namespace
DirectSeeding
{
///
<summary>
///
FrmConfig
///
讀取配置文件
///
///
修改紀錄
///
///
2011.01.14 版本: 1.0 JiRiGaLa 完善程序的註釋等、重新整理代碼。
///
///
版本:1.0
///
///
<author>
///
<name>
JiRiGaLa
</name>
///
<date>
2011.01.14
</date>
///
</author>
///
</summary>
public
partial
class
FrmConfig : Form
{
public
FrmConfig()
{
InitializeComponent();
}
///
<summary>
///
讀取配置文件
///
</summary>
private
void
GetConfig()
{
this
.txtWriteFileName.Text
=
ConfigurationManager.AppSettings[
"
WriteFileName
"
];
this
.txtWritePath.Text
=
ConfigurationManager.AppSettings[
"
WritePath
"
].Replace(
"
|
"
, Environment.NewLine);
this
.txtPostMessageURL.Text
=
ConfigurationManager.AppSettings[
"
PostMessageURL
"
];
this
.txtLeasedLineURL.Text
=
ConfigurationManager.AppSettings[
"
LeasedLineURL
"
];
}
private
void
FrmDirectSeeding_Load(
object
sender, EventArgs e)
{
this
.GetConfig();
}
///
<summary>
///
保存配置文件
///
</summary>
private
void
SaveConfig()
{
//
寫入參數設置
Configuration configuration
=
ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
configuration.AppSettings.Settings[
"
WriteFileName
"
].Value
=
this
.txtWriteFileName.Text;
configuration.AppSettings.Settings[
"
WritePath
"
].Value
=
this
.txtWritePath.Text.Trim().Replace(Environment.NewLine,
"
|
"
);
configuration.AppSettings.Settings[
"
PostMessageURL
"
].Value
=
this
.txtPostMessageURL.Text;
configuration.AppSettings.Settings[
"
LeasedLineURL
"
].Value
=
this
.txtLeasedLineURL.Text;
configuration.Save();
//
從新讀取參數
ConfigurationManager.RefreshSection(
"
appSettings
"
);
WriteFile.WriteFileName
=
ConfigurationManager.AppSettings[
"
WriteFileName
"
];
WriteFile.WritePath
=
ConfigurationManager.AppSettings[
"
WritePath
"
].Split(
'
|
'
);
PostMessage.PostMessageURL
=
ConfigurationManager.AppSettings[
"
PostMessageURL
"
];
//
PostMessage.LeasedLineURL = ConfigurationManager.AppSettings["LeasedLineURL"];
}
private
void
btnSavaConfig_Click(
object
sender, EventArgs e)
{
//
保存設置
SaveConfig();
}
}
}