F_P_00001.cs 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. 
  2. using System;
  3. using System.Diagnostics;
  4. using System.IO;
  5. using System.Reflection;
  6. using System.Windows.Forms;
  7. using Dongke.IBOSS.PRD.Basics.BaseResources;
  8. using Dongke.IBOSS.PRD.Basics.Library;
  9. using Dongke.IBOSS.PRD.Client.CommonModule;
  10. using Dongke.IBOSS.PRD.WCF.DataModels;
  11. using Dongke.IBOSS.PRD.WCF.Proxys;
  12. namespace Dongke.IBOSS.PRD.Client.Public
  13. {
  14. public partial class F_P_00001 : Form
  15. {
  16. public static int AccountID = 1;
  17. private string _filePath = LocalPath.RootPath + Constant.INI_FILE_NAME;
  18. private string _ipAddress = null;
  19. private string _serverPort = null;
  20. public F_P_00001()
  21. {
  22. InitializeComponent();
  23. }
  24. private void F_P_00001_Load(object sender, EventArgs e)
  25. {
  26. this.lblTest.Text = this.Text;
  27. }
  28. private void F_P_00001_Shown(object sender, EventArgs e)
  29. {
  30. try
  31. {
  32. if (this.CheckIP(true))
  33. {
  34. // 设定静态常量中的web服务地址
  35. ProxySettings.ResetRemoteAddress(this._ipAddress, this._serverPort);
  36. }
  37. this.btnFP00002_Click(null, null);
  38. }
  39. catch (Exception ex)
  40. {
  41. // 对异常进行共通处理
  42. ExceptionManager.HandleEventException(this.ToString(),
  43. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  44. }
  45. }
  46. private void btnSetting_Click(object sender, System.EventArgs e)
  47. {
  48. try
  49. {
  50. F_SYS_0102 frmSYS0102 = new F_SYS_0102();
  51. if (frmSYS0102.ShowDialog(this) == DialogResult.OK)
  52. {
  53. this._ipAddress = Utility.ReadIniFile(Constant.INI_SECTION_NET,
  54. Constant.INI_KEY_IP, this._filePath);
  55. this._serverPort = Utility.ReadIniFile(Constant.INI_SECTION_NET,
  56. Constant.INI_KEY_PORT, this._filePath);
  57. // 设定静态常量中的web服务地址
  58. ProxySettings.ResetRemoteAddress(this._ipAddress, this._serverPort);
  59. }
  60. }
  61. catch (Exception ex)
  62. {
  63. // 对异常进行共通处理
  64. ExceptionManager.HandleEventException(this.ToString(),
  65. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  66. }
  67. }
  68. private void btnUpdate_Click(object sender, System.EventArgs e)
  69. {
  70. try
  71. {
  72. if (!AutoUp())
  73. {
  74. MessageBox.Show("已是最新版本,无需升级。", Messages.MSG_TITLE_I01
  75. , MessageBoxButtons.OK, MessageBoxIcon.Information);
  76. }
  77. }
  78. catch (Exception ex)
  79. {
  80. // 对异常进行共通处理
  81. ExceptionManager.HandleEventException(this.ToString(),
  82. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  83. }
  84. }
  85. private bool CheckService()
  86. {
  87. if (!this.CheckIP(false))
  88. {
  89. MessageBox.Show("未配置服务地址或端口。\r\n请先配置服务地址和端口,再进行操作。", Messages.MSG_TITLE_W01
  90. , MessageBoxButtons.OK, MessageBoxIcon.Warning);
  91. return false;
  92. }
  93. AutoUp();
  94. return true;
  95. }
  96. private bool CheckIP(bool isSet)
  97. {
  98. if (isSet && File.Exists(this._filePath))
  99. {
  100. this._ipAddress = Utility.ReadIniFile(Constant.INI_SECTION_NET,
  101. Constant.INI_KEY_IP, this._filePath);
  102. this._serverPort = Utility.ReadIniFile(Constant.INI_SECTION_NET,
  103. Constant.INI_KEY_PORT, this._filePath);
  104. string accountID = Utility.ReadIniFile(Constant.INI_SECTION_SETTINGS,
  105. "AccountID", this._filePath);
  106. if (!string.IsNullOrWhiteSpace(accountID))
  107. {
  108. F_P_00001.AccountID = int.Parse(accountID);
  109. }
  110. else
  111. {
  112. Utility.WriteIniFile(Constant.INI_SECTION_SETTINGS, "AccountID",
  113. F_P_00001.AccountID.ToString(), this._filePath);
  114. }
  115. }
  116. if (string.IsNullOrWhiteSpace(this._ipAddress) ||
  117. string.IsNullOrWhiteSpace(this._serverPort))
  118. {
  119. if (isSet)
  120. {
  121. F_SYS_0102 fsys0102 = new F_SYS_0102();
  122. if (fsys0102.ShowDialog() == DialogResult.OK)
  123. {
  124. this._ipAddress = Utility.ReadIniFile(Constant.INI_SECTION_NET,
  125. Constant.INI_KEY_IP, this._filePath);
  126. this._serverPort = Utility.ReadIniFile(Constant.INI_SECTION_NET,
  127. Constant.INI_KEY_PORT, this._filePath);
  128. return true;
  129. }
  130. }
  131. return false;
  132. }
  133. return true;
  134. }
  135. public static bool AutoUp()
  136. {
  137. FileVersionInfo info = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location);
  138. // 自动更新
  139. NeedUpgradeResultEntity needUpgradeInfo = PublicModuleProxy.Service.IsNeedUpgrade(info.FileVersion);
  140. if (needUpgradeInfo.UpgradeState)
  141. {
  142. //needUpgradeInfo.GradeInfo =
  143. // string.Format("本地程序版本:{0}\r\n最新程序版本:{1}",
  144. // info.FileVersion, needUpgradeInfo.ServerVersion);
  145. // 如果有提示信息提示,没有就跳过
  146. //if (!string.IsNullOrEmpty(needUpgradeInfo.GradeInfo))
  147. //{
  148. // F_SYS_0103 frmAutoUpgradeInfo = new F_SYS_0103(needUpgradeInfo.GradeInfo);
  149. // DialogResult dialogResult = frmAutoUpgradeInfo.ShowDialog(this);
  150. // if (dialogResult != DialogResult.OK)
  151. // {
  152. // Application.Exit();
  153. // }
  154. // else
  155. // {
  156. // Application.Exit();
  157. // //Process.Start("AutoUpgrade.exe");
  158. // Process.Start(System.AppDomain.CurrentDomain.BaseDirectory + "AutoUpgrade.exe", "IBOSSPRDPublic.exe");
  159. // }
  160. // Process.Start(System.AppDomain.CurrentDomain.BaseDirectory + "AutoUpgrade.exe", "IBOSSPRDPublic.exe");
  161. //}
  162. //else
  163. {
  164. Application.Exit();
  165. Process.Start(System.AppDomain.CurrentDomain.BaseDirectory + "AutoUpgrade.exe", "IBOSSPRDPublic.exe");
  166. }
  167. return true;
  168. }
  169. else
  170. {
  171. return false;
  172. }
  173. }
  174. private void btnFP00002_Click(object sender, EventArgs e)
  175. {
  176. try
  177. {
  178. if (!this.CheckService())
  179. {
  180. return;
  181. }
  182. F_P_00002 FP00002 = new F_P_00002();
  183. FP00002.ShowDialog(this);
  184. }
  185. catch (Exception ex)
  186. {
  187. // 对异常进行共通处理
  188. ExceptionManager.HandleEventException(this.ToString(),
  189. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  190. }
  191. }
  192. private void btnClose_Click(object sender, EventArgs e)
  193. {
  194. this.Close();
  195. }
  196. private void btnCache_Click(object sender, EventArgs e)
  197. {
  198. System.Diagnostics.Process.Start(LocalPath.RootPath);
  199. }
  200. }
  201. }