using System; using System.Diagnostics; using System.IO; using System.Reflection; using System.Windows.Forms; using Dongke.IBOSS.PRD.Basics.BaseResources; using Dongke.IBOSS.PRD.Basics.Library; using Dongke.IBOSS.PRD.Client.CommonModule; using Dongke.IBOSS.PRD.WCF.DataModels; using Dongke.IBOSS.PRD.WCF.Proxys; namespace Dongke.IBOSS.PRD.Client.Public { public partial class F_P_00001 : Form { public static int AccountID = 1; private string _filePath = LocalPath.RootPath + Constant.INI_FILE_NAME; private string _ipAddress = null; private string _serverPort = null; public F_P_00001() { InitializeComponent(); } private void F_P_00001_Load(object sender, EventArgs e) { this.lblTest.Text = this.Text; } private void F_P_00001_Shown(object sender, EventArgs e) { try { if (this.CheckIP(true)) { // 设定静态常量中的web服务地址 ProxySettings.ResetRemoteAddress(this._ipAddress, this._serverPort); } this.btnFP00002_Click(null, null); } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), MethodBase.GetCurrentMethod().Name, this.Text, ex); } } private void btnSetting_Click(object sender, System.EventArgs e) { try { F_SYS_0102 frmSYS0102 = new F_SYS_0102(); if (frmSYS0102.ShowDialog(this) == DialogResult.OK) { this._ipAddress = Utility.ReadIniFile(Constant.INI_SECTION_NET, Constant.INI_KEY_IP, this._filePath); this._serverPort = Utility.ReadIniFile(Constant.INI_SECTION_NET, Constant.INI_KEY_PORT, this._filePath); // 设定静态常量中的web服务地址 ProxySettings.ResetRemoteAddress(this._ipAddress, this._serverPort); } } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), MethodBase.GetCurrentMethod().Name, this.Text, ex); } } private void btnUpdate_Click(object sender, System.EventArgs e) { try { if (!AutoUp()) { MessageBox.Show("已是最新版本,无需升级。", Messages.MSG_TITLE_I01 , MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), MethodBase.GetCurrentMethod().Name, this.Text, ex); } } private bool CheckService() { if (!this.CheckIP(false)) { MessageBox.Show("未配置服务地址或端口。\r\n请先配置服务地址和端口,再进行操作。", Messages.MSG_TITLE_W01 , MessageBoxButtons.OK, MessageBoxIcon.Warning); return false; } AutoUp(); return true; } private bool CheckIP(bool isSet) { if (isSet && File.Exists(this._filePath)) { this._ipAddress = Utility.ReadIniFile(Constant.INI_SECTION_NET, Constant.INI_KEY_IP, this._filePath); this._serverPort = Utility.ReadIniFile(Constant.INI_SECTION_NET, Constant.INI_KEY_PORT, this._filePath); string accountID = Utility.ReadIniFile(Constant.INI_SECTION_SETTINGS, "AccountID", this._filePath); if (!string.IsNullOrWhiteSpace(accountID)) { F_P_00001.AccountID = int.Parse(accountID); } else { Utility.WriteIniFile(Constant.INI_SECTION_SETTINGS, "AccountID", F_P_00001.AccountID.ToString(), this._filePath); } } if (string.IsNullOrWhiteSpace(this._ipAddress) || string.IsNullOrWhiteSpace(this._serverPort)) { if (isSet) { F_SYS_0102 fsys0102 = new F_SYS_0102(); if (fsys0102.ShowDialog() == DialogResult.OK) { this._ipAddress = Utility.ReadIniFile(Constant.INI_SECTION_NET, Constant.INI_KEY_IP, this._filePath); this._serverPort = Utility.ReadIniFile(Constant.INI_SECTION_NET, Constant.INI_KEY_PORT, this._filePath); return true; } } return false; } return true; } public static bool AutoUp() { FileVersionInfo info = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location); // 自动更新 NeedUpgradeResultEntity needUpgradeInfo = PublicModuleProxy.Service.IsNeedUpgrade(info.FileVersion); if (needUpgradeInfo.UpgradeState) { //needUpgradeInfo.GradeInfo = // string.Format("本地程序版本:{0}\r\n最新程序版本:{1}", // info.FileVersion, needUpgradeInfo.ServerVersion); // 如果有提示信息提示,没有就跳过 //if (!string.IsNullOrEmpty(needUpgradeInfo.GradeInfo)) //{ // F_SYS_0103 frmAutoUpgradeInfo = new F_SYS_0103(needUpgradeInfo.GradeInfo); // DialogResult dialogResult = frmAutoUpgradeInfo.ShowDialog(this); // if (dialogResult != DialogResult.OK) // { // Application.Exit(); // } // else // { // Application.Exit(); // //Process.Start("AutoUpgrade.exe"); // Process.Start(System.AppDomain.CurrentDomain.BaseDirectory + "AutoUpgrade.exe", "IBOSSPRDPublic.exe"); // } // Process.Start(System.AppDomain.CurrentDomain.BaseDirectory + "AutoUpgrade.exe", "IBOSSPRDPublic.exe"); //} //else { Application.Exit(); Process.Start(System.AppDomain.CurrentDomain.BaseDirectory + "AutoUpgrade.exe", "IBOSSPRDPublic.exe"); } return true; } else { return false; } } private void btnFP00002_Click(object sender, EventArgs e) { try { if (!this.CheckService()) { return; } F_P_00002 FP00002 = new F_P_00002(); FP00002.ShowDialog(this); } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), MethodBase.GetCurrentMethod().Name, this.Text, ex); } } private void btnClose_Click(object sender, EventArgs e) { this.Close(); } private void btnCache_Click(object sender, EventArgs e) { System.Diagnostics.Process.Start(LocalPath.RootPath); } } }