???????????????????????????????????????????????????????????????????????????????????????????
/// <summary>
/// ?????????????????????
/// </summary>
private void chkLocalVersion_CheckedChanged(object sender?? EventArgs e)
{
SetAccessType(this.chkLocalVersion.Checked);
}
/// <summary>
/// ????????緽????????????
/// </summary>
/// <param name="localType">????????????</param>
private void SetAccessType(bool localType)
{
this.lblNetType.Enabled = !localType;
this.radNetType.Enabled = !localType;
AppConfig config = new AppConfig();
config.AppConfigSet("CallerType"?? localType ? "win" : "wcf");
ConfigurationManager.RefreshSection("appSettings");
}
????????????緽??????????????????????????????????????????????????????????????????????????????????
/// <summary>
/// ???緽????????????????л????????
/// </summary>
private void radNetType_SelectedIndexChanged(object sender?? EventArgs e)
{
ChangeConfig();
}
/// <summary>
/// ??????????
/// </summary>
private void ChangeConfig()
{
if (parameter != null)
{
bool isIntranet = radNetType.EditValue.ToString() == "????";
if (isIntranet)
{
UpdateConfig(parameter.InternalWcfHost?? parameter.InternalWcfPort);
}
else
{
UpdateConfig(parameter.ExternalWcfHost?? parameter.ExternalWcfPort);
}
}
else
{
MessageDxUtil.ShowError("?????????????");
}
}
/// <summary>
/// WCF???£????????????е???????????????
/// </summary>
/// <param name="serverIPAddress">??????????</param>
/// <param name="serverPort">???</param>
private void UpdateConfig(string serverIPAddress?? int serverPort)
{
string basePath = System.Environment.CurrentDirectory;
UpdateConfigFile(serverIPAddress?? serverPort?? Path.Combine(basePath?? "BaseWcfConfig.config"));
UpdateConfigFile(serverIPAddress?? serverPort?? Path.Combine(basePath?? "WcfConfig.config"));
}
/// <summary>
/// ?????????????滻???е???????????????
/// </summary>
/// <param name="serverIPAddress">??????????</param>
/// <param name="serverPort">???</param>
/// <param name="exeFilePath">??????????</param>
private void UpdateConfigFile(string serverIPAddress?? int serverPort?? string exeFilePath)
{
string address = File.ReadAllText(exeFilePath?? System.Text.Encoding.UTF8);
string pattern = "://.*?/";
string replacement = string.Format("://{0}:{1}/"?? serverIPAddress?? serverPort);
address = Regex.Replace(address?? pattern?? replacement);
File.WriteAllText(exeFilePath?? address?? System.Text.Encoding.UTF8);
}
??????????????????????????????????????????е??????????????????????????????а?????