예제 #1
0
        public void LoginRecord(UserInfoOutputDto userInfo, string ip, LoginType type)
        {
            Interview   view   = InterviewBll.GetFirstEntityFromL2CacheNoTracking(i => i.IP.Equals(ip), i => i.ViewTime, false);
            string      addr   = view.Address;
            string      prov   = view.Province;
            LoginRecord record = new LoginRecord()
            {
                IP = ip, LoginTime = DateTime.Now, LoginType = type, PhysicAddress = addr, Province = prov
            };
            UserInfo u = UserInfoBll.GetByUsername(userInfo.Username);

            u.LoginRecord.Add(record);
            UserInfoBll.UpdateEntitySaved(u);
            string content = System.IO.File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + "template\\login.html").Replace("{{name}}", u.Username).Replace("{{time}}", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")).Replace("{{ip}}", record.IP).Replace("{{address}}", record.PhysicAddress);

            CommonHelper.SendMail(CommonHelper.GetSettings("Title") + "账号登录通知", content, CommonHelper.GetSettings("ReceiveEmail"));
        }