1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- using System;
- using System.Collections.Generic;
- using System.Threading;
- using System.Linq;
- using System.Data;
- using MySystem;
- using MySystem.PxcModels;
- using Library;
- public class TestHelper
- {
- public readonly static TestHelper Instance = new TestHelper();
- private TestHelper()
- {
- }
-
- public void Start()
- {
- Thread th = new Thread(DoWorks);
- th.IsBackground = true;
- th.Start();
- }
- private void DoWorks()
- {
- // bool op = true;
- // while (op)
- // {
- // WebCMSEntities db = new WebCMSEntities();
- // int StartId = RedisDbconn.Instance.Get<int>("SetCertUserId");
- // 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();
- // if (list.Count > 0)
- // {
- // foreach (var sub in list)
- // {
- // Users user = db.Users.FirstOrDefault(m => m.Id == sub.Id && string.IsNullOrEmpty(m.CertId));
- // if (user != null)
- // {
- // DataTable dt = dbconn.dtable("select CertId from TmpCert where MakerCode='" + user.MakerCode + "'");
- // if (dt.Rows.Count > 0)
- // {
- // string CertId = dt.Rows[0]["CertId"].ToString();
- // user.CertId = CertId;
- // }
- // RedisDbconn.Instance.Set("SetCertUserId", sub.Id);
- // }
- // }
- // db.SaveChanges();
- // db.Dispose();
- // }
- // else
- // {
- // op = false;
- // }
- // Thread.Sleep(10);
- // }
- WebCMSEntities db = new WebCMSEntities();
- IQueryable<Users> users = db.Users.Where(m => m.AuthFlag == 1).OrderBy(m => m.Id);
- foreach (Users user in users.ToList())
- {
- 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/");
- path = path.Replace("//", "/");
- string resultpath = "/bsserver_com/static/ReferenceQrCode/" + function.MD5_16(user.Id.ToString() + "8745") + "Pic.png";
- MakeReferenceQrCodeService.Instance.MakeQRCode(function.getPath("/static/QrCodeBg.png"), function.getPath(path), function.getPath(resultpath), user);
- resultpath = resultpath.Replace("bsserver_com/", "");
- user.ReferenceQrCode = resultpath;
- db.SaveChanges();
- RedisDbconn.Instance.Set("Users:" + user.Id, user);
- function.WriteLog(user.Id.ToString(), "生成邀请二维码");
- }
- function.WriteLog("finish", "生成邀请二维码");
- }
- }
|