F_SYS_0101.cs 27 KB

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