F_SYS_0101.cs 27 KB

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