sync.acc.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. using BizCom;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Data;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using Utils;
  9. namespace SiteCore.Handler
  10. {
  11. public partial class sync
  12. {
  13. #region 账户
  14. public void get_account()
  15. {
  16. DataStruct dStruct = GetStruct();
  17. DataTable dt = WebCache.GetData("x_User", dStruct);
  18. foreach (DataRow dr in dt.Rows)
  19. {
  20. dr["PassWord"] = SecurityHelper.DecryptSymmetric(dr["PassWord"]);
  21. }
  22. writeGridJson(dStruct.TotalCount, Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  23. }
  24. public void save_account()
  25. {
  26. if (UrlParmsCheck("name,pwd"))
  27. {
  28. string name = GetString("name");
  29. if (XUser.Exists("Account=?", name))
  30. {
  31. returnErrorMsg("该账户名已经存在,请更换!");
  32. return;
  33. }
  34. string pwd = GetString("pwd");
  35. XUser user = new XUser();
  36. user.Account = name;
  37. user.CreateTime = DateTime.Now;
  38. user.PassWord = SecurityHelper.EncryptSymmetric(pwd);
  39. user.Create();
  40. returnSuccessMsg("保存成功!");
  41. }
  42. }
  43. public void resetpwd_account()
  44. {
  45. int id = GetInt("id");
  46. int pId = GetInt("pid");
  47. if (id > 0) XUser.ResetPwd(id, SecurityHelper.EncryptSymmetric("000000"));
  48. else if (pId > 0) XUser.ResetPersonPwd(pId, SecurityHelper.EncryptSymmetric("000000"));
  49. returnSuccessMsg("密码重置成功!");
  50. }
  51. public void del_account()
  52. {
  53. if (UrlParmsCheck("id"))
  54. {
  55. int id = GetInt("id");
  56. XUser.Del(id);
  57. returnSuccessMsg("删除成功!");
  58. }
  59. }
  60. public void open_account()
  61. {
  62. if (UrlParmsCheck("id,pid"))
  63. {
  64. int pId = GetInt("pid");
  65. int id = GetInt("id");
  66. XUser.OpenAccount(id, pId);
  67. returnSuccessMsg("成功开通账户!");
  68. }
  69. }
  70. public void close_account()
  71. {
  72. if (UrlParmsCheck("id,pid"))
  73. {
  74. int pId = GetInt("pid");
  75. int id = GetInt("id");
  76. XUser.FreezeAccount(id, pId);
  77. returnSuccessMsg("成功冻结账户!");
  78. }
  79. }
  80. public void update_pwd()
  81. {
  82. if (UrlParmsCheck("pwd,newpwd,newpwd2"))
  83. {
  84. string pwd = SecurityHelper.EncryptSymmetric(GetString("pwd"));
  85. string newpwd = GetString("newpwd");
  86. string newpwd2 = GetString("newpwd2");
  87. XUser user = XUser.Get(CurrentUser.UserID, pwd);
  88. if (user == null)
  89. {
  90. returnErrorMsg("旧密码不正确!");
  91. return;
  92. }
  93. user.PassWord = SecurityHelper.EncryptSymmetric(newpwd);
  94. user.Update();
  95. returnSuccessMsg("密码修改成功!");
  96. }
  97. }
  98. #endregion
  99. }
  100. }