F_SYS_0101.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_SYS_0101.cs
  5. * 2.功能描述:系统登录主界面
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 张国印 2014/08/27 1.00 新建
  9. *******************************************************************************/
  10. using System;
  11. using System.IO;
  12. using System.Reflection;
  13. using System.Windows.Forms;
  14. using Dongke.IBOSS.PRD.Basics.BaseControls;
  15. using Dongke.IBOSS.PRD.Basics.BaseResources;
  16. using Dongke.IBOSS.PRD.Basics.Library;
  17. using Dongke.IBOSS.PRD.Client.CommonModule;
  18. using Dongke.IBOSS.PRD.Client.DataModels;
  19. using Dongke.IBOSS.PRD.WCF.DataModels;
  20. using Dongke.IBOSS.PRD.WCF.Proxys;
  21. using Dongke.IBOSS.PRD.WCF.Proxys.DKIBOSSPRDService;
  22. namespace Dongke.IBOSS.PRD.Client
  23. {
  24. /// <summary>
  25. /// 系统登录页面
  26. /// </summary>
  27. public partial class F_SYS_0101 : FormBase
  28. {
  29. #region 成员变量
  30. // 帐套
  31. private string _accountCode;
  32. // 用户
  33. private string _userCode;
  34. // 密码
  35. private string _password;
  36. // 配置文件的全路径
  37. private string _iniFilePath = LocalPath.RootPath + Constant.INI_FILE_NAME;
  38. private string _localiniFilePath = AppDomain.CurrentDomain.BaseDirectory + Constant.INI_FILE_NAME;
  39. // 用户登录信息
  40. private LoginRequestEntity _requestEntity = null;
  41. #endregion
  42. #region 构造函数
  43. /// <summary>
  44. /// 构造函数
  45. /// </summary>
  46. public F_SYS_0101()
  47. {
  48. InitializeComponent();
  49. this.SetFromTitleInfo();
  50. }
  51. #endregion
  52. #region
  53. /// <summary>
  54. /// 获取或设置密码
  55. /// </summary>
  56. public string Password
  57. {
  58. get
  59. {
  60. return this.txtPassword.Text;
  61. }
  62. set
  63. {
  64. this.txtPassword.Text = value;
  65. }
  66. }
  67. /// <summary>
  68. /// 切换用户
  69. /// </summary>
  70. public bool IsChangedUser
  71. {
  72. get;
  73. set;
  74. }
  75. #endregion
  76. #region 事件处理
  77. /// <summary>
  78. /// 窗体加载事件
  79. /// </summary>
  80. /// <param name="sender"></param>
  81. /// <param name="e"></param>
  82. private void F_SYS_0101_Shown(object sender, EventArgs e)
  83. {
  84. try
  85. {
  86. // 存在该文件,直接读取该文件,否则不读取
  87. if (File.Exists(_localiniFilePath))
  88. {
  89. this.txtAccount.Text = Utility.ReadIniFile(Constant.INI_SECTION_SETTINGS,
  90. Constant.INI_KEY_ACCOUNT_CODE, this._localiniFilePath);
  91. this.txtUserCode.Text = Utility.ReadIniFile(Constant.INI_SECTION_SETTINGS,
  92. Constant.INI_KEY_USER_CODE, this._localiniFilePath);
  93. }
  94. else if (File.Exists(this._iniFilePath))
  95. {
  96. //this.txtAccount.Text = Utility.ReadIniFile(Constant.INI_SECTION_SETTINGS,
  97. // Constant.INI_KEY_ACCOUNT_CODE, this._iniFilePath);
  98. //this.txtUserCode.Text = Utility.ReadIniFile(Constant.INI_SECTION_SETTINGS,
  99. // Constant.INI_KEY_USER_CODE, this._iniFilePath);
  100. File.Copy(this._iniFilePath, _localiniFilePath);
  101. this.txtAccount.Text = Utility.ReadIniFile(Constant.INI_SECTION_SETTINGS,
  102. Constant.INI_KEY_ACCOUNT_CODE, this._localiniFilePath);
  103. this.txtUserCode.Text = Utility.ReadIniFile(Constant.INI_SECTION_SETTINGS,
  104. Constant.INI_KEY_USER_CODE, this._localiniFilePath);
  105. }
  106. // 激活窗体
  107. this.ActivateForm();
  108. // 设置焦点
  109. if (string.IsNullOrEmpty(this.txtAccount.Text))
  110. {
  111. this.txtAccount.Focus();
  112. }
  113. else if (string.IsNullOrEmpty(this.txtUserCode.Text))
  114. {
  115. this.txtUserCode.Focus();
  116. }
  117. else
  118. {
  119. if (this.IsChangedUser)
  120. {
  121. this.txtUserCode.Focus();
  122. this.txtUserCode.SelectAll();
  123. return;
  124. }
  125. this.txtPassword.Focus();
  126. }
  127. if (!string.IsNullOrWhiteSpace(this.txtPassword.Text))
  128. {
  129. this.btnLogin_Click(null, null);
  130. }
  131. }
  132. catch (Exception ex)
  133. {
  134. // 对异常进行共通处理
  135. ExceptionManager.HandleEventException(this.ToString(),
  136. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  137. }
  138. }
  139. /// <summary>
  140. /// 登录按钮
  141. /// </summary>
  142. /// <param name="sender"></param>
  143. /// <param name="e"></param>
  144. private void btnLogin_Click(object sender, EventArgs e)
  145. {
  146. this._accountCode = this.txtAccount.Text.Trim();
  147. this._userCode = this.txtUserCode.Text.Trim();
  148. this._password = this.txtPassword.Text;
  149. // 画面有为输入的必输项目
  150. if (!this.IsInputValid())
  151. {
  152. return;
  153. }
  154. try
  155. {
  156. // 判断是否设置Web服务器地址,未进行配置,则提示
  157. string ipAddress = null;
  158. string serverPort = null;
  159. if (File.Exists(_localiniFilePath))
  160. {
  161. ipAddress = Utility.ReadIniFile(Constant.INI_SECTION_NET,
  162. Constant.INI_KEY_IP, this._localiniFilePath);
  163. serverPort = Utility.ReadIniFile(Constant.INI_SECTION_NET,
  164. Constant.INI_KEY_PORT, this._localiniFilePath);
  165. }
  166. else if (File.Exists(this._iniFilePath))
  167. {
  168. ipAddress = Utility.ReadIniFile(Constant.INI_SECTION_NET,
  169. Constant.INI_KEY_IP, this._iniFilePath);
  170. serverPort = Utility.ReadIniFile(Constant.INI_SECTION_NET,
  171. Constant.INI_KEY_PORT, this._iniFilePath);
  172. }
  173. if (string.IsNullOrWhiteSpace(ipAddress) || string.IsNullOrWhiteSpace(serverPort))
  174. {
  175. MessageBox.Show(Messages.MSG_SYS_W001, Messages.MSG_TITLE_W01, MessageBoxButtons.OK,
  176. MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  177. return;
  178. }
  179. // 设定静态常量中的web服务地址
  180. ProxySettings.ResetRemoteAddress(ipAddress, serverPort);
  181. // 将密码进行MD5加密
  182. this._password = Encryption.GetMD5String(this.txtPassword.Text);
  183. this._requestEntity = new LoginRequestEntity();
  184. this._requestEntity.AccountCode = this._accountCode;
  185. this._requestEntity.UserCode = this._userCode;
  186. this._requestEntity.Password = this._password;
  187. this._requestEntity.IPAddress = SystemAPI.IPAddress;
  188. this._requestEntity.MACAddress = SystemAPI.MacAddress;
  189. this._requestEntity.ComputerName = SystemAPI.ComputerName;
  190. LoginResultEntity result = (LoginResultEntity)DoAsync(new BaseAsyncMethod(() =>
  191. {
  192. return DKIBOSSPRDProxy.Service.DoLogin(this._requestEntity);
  193. }));
  194. // 登录认证失败
  195. if (result == null)
  196. {
  197. MessageBox.Show(Messages.MSG_SYS_W002, Messages.MSG_TITLE_W01, MessageBoxButtons.OK,
  198. MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  199. return;
  200. }
  201. // 根据状态进行登录处理
  202. this.LoginCheck(result);
  203. }
  204. catch (Exception ex)
  205. {
  206. // 对异常进行共通处理
  207. ExceptionManager.HandleEventException(this.ToString(),
  208. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  209. }
  210. }
  211. /// <summary>
  212. /// 系统设置按钮,打开系统设置页面
  213. /// </summary>
  214. /// <param name="sender"></param>
  215. /// <param name="e"></param>
  216. private void btnSetting_Click(object sender, EventArgs e)
  217. {
  218. try
  219. {
  220. F_SYS_0102 frmSYS0102 = new F_SYS_0102();
  221. frmSYS0102.ShowDialog();
  222. }
  223. catch (Exception ex)
  224. {
  225. // 对异常进行共通处理
  226. ExceptionManager.HandleEventException(this.ToString(),
  227. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  228. }
  229. }
  230. #endregion
  231. #region 私有方法
  232. /// <summary>
  233. /// 设置窗体按钮的文本信息
  234. /// </summary>
  235. private void SetFromTitleInfo()
  236. {
  237. this.Text = FormTitles.F_SYS_0101;
  238. this.btnLogin.Text = ButtonText.BTN_LOGIN;
  239. this.btnSetting.Text = ButtonText.BTN_SETTING;
  240. }
  241. /// <summary>
  242. /// 检查页面的输入项目
  243. /// </summary>
  244. /// <remarks>
  245. /// </remarks>
  246. /// <returns>True 为验证通过 False 为验证不通过</returns>
  247. private bool IsInputValid()
  248. {
  249. // 帐套未输入值
  250. if (string.IsNullOrEmpty(this._accountCode))
  251. {
  252. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "帐套"),
  253. Messages.MSG_TITLE_W01,
  254. MessageBoxButtons.OK,
  255. MessageBoxIcon.Warning,
  256. MessageBoxDefaultButton.Button1);
  257. this.txtAccount.Focus();
  258. return false;
  259. }
  260. // 用户名未输入值
  261. else if (string.IsNullOrEmpty(this._userCode))
  262. {
  263. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "用户"),
  264. Messages.MSG_TITLE_W01,
  265. MessageBoxButtons.OK,
  266. MessageBoxIcon.Warning,
  267. MessageBoxDefaultButton.Button1);
  268. this.txtUserCode.Focus();
  269. return false;
  270. }
  271. // 用户密码未输入值
  272. else if (string.IsNullOrEmpty(this._password))
  273. {
  274. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "密码"),
  275. Messages.MSG_TITLE_W01,
  276. MessageBoxButtons.OK,
  277. MessageBoxIcon.Warning,
  278. MessageBoxDefaultButton.Button1);
  279. this.txtPassword.Focus();
  280. return false;
  281. }
  282. else
  283. {
  284. return true;
  285. }
  286. }
  287. /// <summary>
  288. /// 根据传入的参数值,判断登录状态
  289. /// </summary>
  290. /// <param name="loginStatus">
  291. /// 0:登录成功
  292. /// 1:帐套不存在
  293. /// 2:该帐套不存在该用户
  294. /// 3:用户密码不正确
  295. /// 4:MAC地址错误
  296. /// 5:登录时间错误
  297. /// 6:用户停用
  298. /// 7:用户被锁死
  299. /// 8:此用户不能在移动端登录
  300. /// 9:此用户不能在PC端登录
  301. /// 10:服务器日期错误
  302. /// 11:没有找到加服务器密锁
  303. /// 12:服务器加密锁不是东科的加密锁
  304. /// 13:读取服务器锁内客户编码内容失败
  305. /// 21:没有找到license文件
  306. /// 22:license文件损坏
  307. /// 23:license文件内容不正确
  308. /// 31:服务器加密锁的内容和license文件的内容不相符
  309. /// 32:临时的License已经过期
  310. /// 41:打开客户端加密锁失败
  311. /// 42:没有找到客户端加密锁
  312. /// 43:客户端加密锁不是东科的加密锁
  313. /// 44:读取加密锁信息失败(硬件损坏、管理密码错误等)
  314. /// 45:加密锁的内容和license内容不一致
  315. /// </param>
  316. private void LoginCheck(LoginResultEntity userEntity)
  317. {
  318. switch (userEntity.LoginStatus)
  319. {
  320. case -1:
  321. // 其他状态提示
  322. MessageBox.Show(userEntity.LoginMessage,
  323. Messages.MSG_TITLE_W01,
  324. MessageBoxButtons.OK,
  325. MessageBoxIcon.Warning,
  326. MessageBoxDefaultButton.Button1);
  327. this.btnLogin.Focus();
  328. break;
  329. case Constant.LOGIN_IS_SUCCESS:
  330. // 登录认证成功
  331. this.SaveUserSettings();
  332. this.ConvertUserLogInInfo(userEntity);
  333. Program.IsLogin = true;
  334. this.DialogResult = DialogResult.OK;
  335. this.Close();
  336. break;
  337. case Constant.LOGIN_ACCOUNT_NOT_EXIST:
  338. // 帐套不存在
  339. MessageBox.Show(string.Format(Messages.MSG_CMN_W002, "帐套"),
  340. Messages.MSG_TITLE_W01,
  341. MessageBoxButtons.OK,
  342. MessageBoxIcon.Warning,
  343. MessageBoxDefaultButton.Button1);
  344. this.txtAccount.Focus();
  345. this.txtAccount.SelectAll();
  346. break;
  347. case Constant.LOGIN_USER_NOT_EXIST:
  348. // 用户不存在
  349. MessageBox.Show(string.Format(Messages.MSG_CMN_W002, "用户"),
  350. Messages.MSG_TITLE_W01,
  351. MessageBoxButtons.OK,
  352. MessageBoxIcon.Warning,
  353. MessageBoxDefaultButton.Button1);
  354. this.txtUserCode.Focus();
  355. this.txtUserCode.SelectAll();
  356. break;
  357. case Constant.LOGIN_PASSORD_ERROR:
  358. // 密码错误
  359. MessageBox.Show(string.Format(Messages.MSG_CMN_W003, "用户密码"),
  360. Messages.MSG_TITLE_W01,
  361. MessageBoxButtons.OK,
  362. MessageBoxIcon.Warning,
  363. MessageBoxDefaultButton.Button1);
  364. this.txtPassword.Focus();
  365. this.txtPassword.SelectAll();
  366. break;
  367. case Constant.LOGIN_MAC_ERROR:
  368. // MAC地址错误
  369. MessageBox.Show(Messages.MSG_SYS_W004,
  370. Messages.MSG_TITLE_W01,
  371. MessageBoxButtons.OK,
  372. MessageBoxIcon.Warning,
  373. MessageBoxDefaultButton.Button1);
  374. this.btnLogin.Focus();
  375. break;
  376. case Constant.LOGIN_DATETIME_ERROR:
  377. // 登录时间段错误
  378. MessageBox.Show(Messages.MSG_SYS_W005,
  379. Messages.MSG_TITLE_W01,
  380. MessageBoxButtons.OK,
  381. MessageBoxIcon.Warning,
  382. MessageBoxDefaultButton.Button1);
  383. this.btnLogin.Focus();
  384. break;
  385. case Constant.LOGIN_USER_DISABLE:
  386. // 用户为停用用户
  387. MessageBox.Show(Messages.MSG_SYS_W006,
  388. Messages.MSG_TITLE_W01,
  389. MessageBoxButtons.OK,
  390. MessageBoxIcon.Warning,
  391. MessageBoxDefaultButton.Button1);
  392. this.btnLogin.Focus();
  393. break;
  394. case Constant.LOGIN_USER_IS_LOCK:
  395. // 用户被锁死
  396. MessageBox.Show(Messages.MSG_SYS_W007,
  397. Messages.MSG_TITLE_W01,
  398. MessageBoxButtons.OK,
  399. MessageBoxIcon.Warning,
  400. MessageBoxDefaultButton.Button1);
  401. this.btnLogin.Focus();
  402. break;
  403. case Constant.LOGIN_USER_NOT_IN_SMART:
  404. // 此用户不能在移动端登录
  405. MessageBox.Show(Messages.MSG_SYS_W022,
  406. Messages.MSG_TITLE_W01,
  407. MessageBoxButtons.OK,
  408. MessageBoxIcon.Warning,
  409. MessageBoxDefaultButton.Button1);
  410. this.btnLogin.Focus();
  411. break;
  412. case Constant.LOGIN_USER_NOT_IN_PC:
  413. // 此用户不能在PC端登录
  414. MessageBox.Show(Messages.MSG_SYS_W023,
  415. Messages.MSG_TITLE_W01,
  416. MessageBoxButtons.OK,
  417. MessageBoxIcon.Warning,
  418. MessageBoxDefaultButton.Button1);
  419. this.btnLogin.Focus();
  420. break;
  421. case Constant.LOGIN_USER_SYSTEMDATE_ERROR:
  422. // 服务器日期错误
  423. MessageBox.Show(Messages.MSG_SYS_W024,
  424. Messages.MSG_TITLE_W01,
  425. MessageBoxButtons.OK,
  426. MessageBoxIcon.Warning,
  427. MessageBoxDefaultButton.Button1);
  428. this.btnLogin.Focus();
  429. break;
  430. case Constant.LOGIN_NOT_ENCRYPTION_LOCK:
  431. // 没有找到加密锁
  432. MessageBox.Show(Messages.MSG_SYS_W008,
  433. Messages.MSG_TITLE_W01,
  434. MessageBoxButtons.OK,
  435. MessageBoxIcon.Warning,
  436. MessageBoxDefaultButton.Button1);
  437. this.btnLogin.Focus();
  438. break;
  439. case Constant.LOGIN_NOT_DONGKE_ENCRYPTION_LOCK:
  440. // 加密锁不是东科的加密锁
  441. MessageBox.Show(Messages.MSG_SYS_W009,
  442. Messages.MSG_TITLE_W01,
  443. MessageBoxButtons.OK,
  444. MessageBoxIcon.Warning,
  445. MessageBoxDefaultButton.Button1);
  446. this.btnLogin.Focus();
  447. break;
  448. case Constant.LOGIN_ENCRYPTION_LOCK_CUSTOMER_ERROR:
  449. // 读取锁内客户编码内容失败
  450. MessageBox.Show(Messages.MSG_SYS_W010,
  451. Messages.MSG_TITLE_W01,
  452. MessageBoxButtons.OK,
  453. MessageBoxIcon.Warning,
  454. MessageBoxDefaultButton.Button1);
  455. this.btnLogin.Focus();
  456. break;
  457. case Constant.LOGIN_NOT_LICENSE:
  458. // 没有找到license文件
  459. MessageBox.Show(Messages.MSG_SYS_W011,
  460. Messages.MSG_TITLE_W01,
  461. MessageBoxButtons.OK,
  462. MessageBoxIcon.Warning,
  463. MessageBoxDefaultButton.Button1);
  464. this.btnLogin.Focus();
  465. break;
  466. case Constant.LOGIN_LICENSE_ERROR:
  467. // license文件损坏
  468. MessageBox.Show(Messages.MSG_SYS_W012,
  469. Messages.MSG_TITLE_W01,
  470. MessageBoxButtons.OK,
  471. MessageBoxIcon.Warning,
  472. MessageBoxDefaultButton.Button1);
  473. this.btnLogin.Focus();
  474. break;
  475. case Constant.LOGIN_LICENSE_CONTENT_ERROR:
  476. // license文件内容不正确
  477. MessageBox.Show(Messages.MSG_SYS_W013,
  478. Messages.MSG_TITLE_W01,
  479. MessageBoxButtons.OK,
  480. MessageBoxIcon.Warning,
  481. MessageBoxDefaultButton.Button1);
  482. this.btnLogin.Focus();
  483. break;
  484. case Constant.LOGIN_LICENSE_ENCRYPTION_LOCK_ERROR:
  485. // 加密锁的内容和license文件的内容不相符
  486. MessageBox.Show(Messages.MSG_SYS_W014,
  487. Messages.MSG_TITLE_W01,
  488. MessageBoxButtons.OK,
  489. MessageBoxIcon.Warning,
  490. MessageBoxDefaultButton.Button1);
  491. this.btnLogin.Focus();
  492. break;
  493. case Constant.LOGIN_LICENSE_BE_OVERDUE:
  494. // 临时的License已经过期
  495. MessageBox.Show(Messages.MSG_SYS_W015,
  496. Messages.MSG_TITLE_W01,
  497. MessageBoxButtons.OK,
  498. MessageBoxIcon.Warning,
  499. MessageBoxDefaultButton.Button1);
  500. this.btnLogin.Focus();
  501. break;
  502. case Constant.LOGIN_CLENT_ENCRYPTION_LOCK_ERROR:
  503. // 打开客户端加密锁失败
  504. MessageBox.Show(Messages.MSG_SYS_W016,
  505. Messages.MSG_TITLE_W01,
  506. MessageBoxButtons.OK,
  507. MessageBoxIcon.Warning,
  508. MessageBoxDefaultButton.Button1);
  509. this.btnLogin.Focus();
  510. break;
  511. case Constant.LOGIN_CLENT_NOT_ENCRYPTION_LOCK:
  512. // 没有找到客户端加密锁
  513. MessageBox.Show(Messages.MSG_SYS_W017,
  514. Messages.MSG_TITLE_W01,
  515. MessageBoxButtons.OK,
  516. MessageBoxIcon.Warning,
  517. MessageBoxDefaultButton.Button1);
  518. this.btnLogin.Focus();
  519. break;
  520. case Constant.LOGIN_CLENT_NOT_DONGKE_ENCRYPTION_LOCK:
  521. // 客户端加密锁不是东科的加密锁
  522. MessageBox.Show(Messages.MSG_SYS_W018,
  523. Messages.MSG_TITLE_W01,
  524. MessageBoxButtons.OK,
  525. MessageBoxIcon.Warning,
  526. MessageBoxDefaultButton.Button1);
  527. this.btnLogin.Focus();
  528. break;
  529. case Constant.LOGIN_CLENT_ENCRYPTION_LOCK_DAMAGE:
  530. // 读取加密锁信息失败(硬件损坏、管理密码错误等)
  531. MessageBox.Show(Messages.MSG_SYS_W019,
  532. Messages.MSG_TITLE_W01,
  533. MessageBoxButtons.OK,
  534. MessageBoxIcon.Warning,
  535. MessageBoxDefaultButton.Button1);
  536. this.btnLogin.Focus();
  537. break;
  538. case Constant.LOGIN_CLENT_LICENSE_ENCRYPTION_LOCK_ERROR:
  539. // 加密锁的内容和license内容不一致
  540. MessageBox.Show(Messages.MSG_SYS_W020,
  541. Messages.MSG_TITLE_W01,
  542. MessageBoxButtons.OK,
  543. MessageBoxIcon.Warning,
  544. MessageBoxDefaultButton.Button1);
  545. this.btnLogin.Focus();
  546. break;
  547. default:
  548. // 登录失败
  549. MessageBox.Show(Messages.MSG_SYS_W002,
  550. Messages.MSG_TITLE_W01,
  551. MessageBoxButtons.OK,
  552. MessageBoxIcon.Warning,
  553. MessageBoxDefaultButton.Button1);
  554. break;
  555. }
  556. }
  557. /// <summary>
  558. /// 将用户信息保存到配置文件
  559. /// </summary>
  560. private void SaveUserSettings()
  561. {
  562. if (!File.Exists(_localiniFilePath))
  563. {
  564. File.Create(this._localiniFilePath).Close();
  565. }
  566. // 保存业务系统配置
  567. Utility.WriteIniFile(Constant.INI_SECTION_SETTINGS, Constant.INI_KEY_ACCOUNT_CODE,
  568. this._accountCode, this._localiniFilePath);
  569. Utility.WriteIniFile(Constant.INI_SECTION_SETTINGS, Constant.INI_KEY_USER_CODE,
  570. this._userCode, this._localiniFilePath);
  571. //{
  572. // // 文件夹不存在的情况下创建文件夹
  573. // if (!Directory.Exists(LocalPath.RootPath))
  574. // {
  575. // Directory.CreateDirectory(LocalPath.RootPath);
  576. // }
  577. // // 存在该文件,更改文件
  578. // if (!File.Exists(this._iniFilePath))
  579. // {
  580. // File.Create(this._iniFilePath).Close();
  581. // }
  582. // // 保存业务系统配置
  583. // Utility.WriteIniFile(Constant.INI_SECTION_SETTINGS, Constant.INI_KEY_ACCOUNT_CODE,
  584. // this._accountCode, this._iniFilePath);
  585. // Utility.WriteIniFile(Constant.INI_SECTION_SETTINGS, Constant.INI_KEY_USER_CODE,
  586. // this._userCode, this._iniFilePath);
  587. //}
  588. }
  589. /// <summary>
  590. /// 数据实体转换,将WCF端的用户信息保存到本地实体中
  591. /// </summary>
  592. /// <param name="loginResultEntity"></param>
  593. public void ConvertUserLogInInfo(LoginResultEntity loginResultEntity)
  594. {
  595. Dongke.IBOSS.PRD.Client.DataModels.UserEntity userEntity =
  596. new Dongke.IBOSS.PRD.Client.DataModels.UserEntity();
  597. DataConvert.Convert(loginResultEntity.CurrentUserEntity, userEntity);
  598. LogInUserInfo tempUser = new LogInUserInfo(userEntity, loginResultEntity.LicenseInfo,
  599. loginResultEntity.SysParameter);
  600. LogInUserInfo.LoginMessage = loginResultEntity.LoginMessage;
  601. this._requestEntity.SessionKey = loginResultEntity.CurrentUserEntity.SessionKey;
  602. ProxySettings.LoginUserInfo = this._requestEntity;
  603. ProxySettings.IPPostName = loginResultEntity.CurrentUserEntity.Remarks;
  604. GridSettingManager.AccountCode = ProxySettings.LoginUserInfo.AccountCode;
  605. GridSettingManager.UserCode = ProxySettings.LoginUserInfo.UserCode;
  606. }
  607. #endregion
  608. }
  609. }