TestHelper.cs 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Threading;
  4. using System.Linq;
  5. using System.Data;
  6. using MySystem;
  7. using MySystem.PxcModels;
  8. using Library;
  9. public class TestHelper
  10. {
  11. public readonly static TestHelper Instance = new TestHelper();
  12. private TestHelper()
  13. {
  14. }
  15. public void Start()
  16. {
  17. Thread th = new Thread(DoWorks);
  18. th.IsBackground = true;
  19. th.Start();
  20. }
  21. private void DoWorks()
  22. {
  23. // bool op = true;
  24. // while (op)
  25. // {
  26. // WebCMSEntities db = new WebCMSEntities();
  27. // int StartId = RedisDbconn.Instance.Get<int>("SetCertUserId");
  28. // var list = db.Users.Select(m => new { m.Id, m.CertId }).Where(m => m.Id > StartId && string.IsNullOrEmpty(m.CertId)).OrderBy(m => m.Id).Take(20).ToList();
  29. // if (list.Count > 0)
  30. // {
  31. // foreach (var sub in list)
  32. // {
  33. // Users user = db.Users.FirstOrDefault(m => m.Id == sub.Id && string.IsNullOrEmpty(m.CertId));
  34. // if (user != null)
  35. // {
  36. // DataTable dt = dbconn.dtable("select CertId from TmpCert where MakerCode='" + user.MakerCode + "'");
  37. // if (dt.Rows.Count > 0)
  38. // {
  39. // string CertId = dt.Rows[0]["CertId"].ToString();
  40. // user.CertId = CertId;
  41. // }
  42. // RedisDbconn.Instance.Set("SetCertUserId", sub.Id);
  43. // }
  44. // }
  45. // db.SaveChanges();
  46. // db.Dispose();
  47. // }
  48. // else
  49. // {
  50. // op = false;
  51. // }
  52. // Thread.Sleep(10);
  53. // }
  54. WebCMSEntities db = new WebCMSEntities();
  55. IQueryable<Users> users = db.Users.Where(m => m.AuthFlag == 1).OrderBy(m => m.Id);
  56. foreach (Users user in users.ToList())
  57. {
  58. string path = function.CreateQRCode2(ConfigurationManager.AppSettings["SourceHost"].ToString() + "p/user-inviteregist-1?Id=" + user.Id, function.MD5_16(user.Id.ToString() + "8745"), "/bsserver_com/static/ReferenceQrCode/");
  59. path = path.Replace("//", "/");
  60. string resultpath = "/bsserver_com/static/ReferenceQrCode/" + function.MD5_16(user.Id.ToString() + "8745") + "Pic.png";
  61. MakeReferenceQrCodeService.Instance.MakeQRCode(function.getPath("/static/QrCodeBg.png"), function.getPath(path), function.getPath(resultpath), user);
  62. resultpath = resultpath.Replace("bsserver_com/", "");
  63. user.ReferenceQrCode = resultpath;
  64. db.SaveChanges();
  65. RedisDbconn.Instance.Set("Users:" + user.Id, user);
  66. function.WriteLog(user.Id.ToString(), "生成邀请二维码");
  67. }
  68. function.WriteLog("finish", "生成邀请二维码");
  69. }
  70. }