/// <summary> /// 更新用户个人信息 /// </summary> /// <param name="userInfo">用户个人信息</param> public static void UpdateUserInfo(UserInfo userInfo) { //更新个人信息 UserData.UpdateUserInfo(userInfo); //第一次更新个人信息 UserInfoUpdateLog log = new UserInfoUpdateLog { UserId = userInfo.UserId, InfoType = 2 }; bool isFirst = LogsBiz.IsFirstUpdateSelfInfoByUser(log); if (isFirst) { UserConfig userConfig = UserConfigs.GetUserConfigCache(); if (userConfig.SetPersonalExpChanged != 0) { UpdateUserExp(userInfo.UserId, userConfig.SetPersonalExpChanged, "设置个人信息"); } if (userConfig.SetPersonalCoinChanged != 0) { UpdateUserCoin(userInfo.UserId, userConfig.SetPersonalCoinChanged, "设置个人信息"); } } //记录个人信息更新日志 log.Comment = "更新个人信息"; log.CreateDate = DateTime.Now; LogsBiz.CreateLogs <UserInfoUpdateLog>(log); //重置用户缓存 SetUserCacheInfo(userInfo.UserId); }
// ***************************************************** // MONO BEHAVIOUR OVERRIDE // ***************************************************** // Start is called before the first frame update void Start() { // State // Cache userConfigs = FindObjectOfType <UserConfigs>(); audioAnalyzer = FindObjectOfType <AudioAnalyzer>(); }
/// <summary> /// 用户“今日”签到 /// </summary> /// <param name="userId"></param> /// <param name="appChannel"></param> /// <returns></returns> public static string UserCheckInToday(int userId, string appChannel) { UserCheckedInLog log = new UserCheckedInLog { UserId = userId, AppChannel = appChannel, CreateDate = DateTime.Now }; int checkResultCode = UserData.UserCheckInToday(log); if (1 == checkResultCode) { //获取用户10天以内的签到记录:如果一直连续签到,则应得到11条记录 List <UserCheckedInLog> logList = UserData.GetUserCheckedInLogInDays(userId, 10).OrderByDescending(l => l.CreateDate).ToList(); int c = -1; for (int i = 0; i < logList.Count; i++) { if ((int)DateTime.Now.Date.Subtract(logList[i].CreateDate.Date).TotalDays != i) { break; } c++; } //此处c最小应该等于0,最大为10,因为当前签到应该有效。所以对应签到序号应该为0-10; //其中0-9分表表示连续签到1-10天,10表示连续签到超过10天以上 string descText = c < 10 ? string.Format("连续签到 {0} 天", c + 1) : "连续签到10天以上"; UserConfig userConfig = UserConfigs.GetUserConfigCache(); bool isNeedReCache = false; string showText = string.Empty; if (userConfig.ContinuousCheckedInExpChanged != null && userConfig.ContinuousCheckedInExpChanged.Count == 11) { if (userConfig.ContinuousCheckedInExpChanged[c] != 0) { UpdateUserExp(userId, userConfig.ContinuousCheckedInExpChanged[c], descText); isNeedReCache = true; } } if (userConfig.ContinuousCheckedInCoinChanged != null && userConfig.ContinuousCheckedInCoinChanged.Count == 11) { if (userConfig.ContinuousCheckedInCoinChanged[c] != 0) { UpdateUserCoin(userId, userConfig.ContinuousCheckedInCoinChanged[c], descText); isNeedReCache = true; showText = descText + ",金币加 " + userConfig.ContinuousCheckedInCoinChanged[c] + " !"; } } if (isNeedReCache) { SetUserCacheInfo(userId); } return(showText); } return(string.Empty); }
public void SaveConfig(UserConfigs userConfigs, string userID) { userConfigs.CheckForNull(nameof(userConfigs)); var userInDbo = _context.Users.Single(u => u.Id == userID); userInDbo.DefaultCurrencyID = userConfigs.DefaultCurrencyID; userInDbo.CarryoverRests = userConfigs.CarryoverRests; _context.SaveChanges(); }
public UserConfigs GetUserConfigs(string userID) { userID.CheckForNull(nameof(userID)); var user = _context.Users.SingleOrDefault(u => u.Id == userID); var userConfigs = new UserConfigs { CarryoverRests = user.CarryoverRests, DefaultCurrencyID = user.DefaultCurrencyID, UpdateDate = user.UpdateDate }; return(userConfigs); }
public IActionResult SaveConfig(MangeViewModel model) { if (!ModelState.IsValid) { return(null); } var userConfigs = new UserConfigs { CarryoverRests = model.CarryoverRests, DefaultCurrencyID = model.DefaultCurrencyID }; var userID = _httpContextAccessor.HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value; _accountService.SaveConfig(userConfigs, userID); return(RedirectToAction("MainPage", "Transaction")); }
/// <summary> /// 用户登录 /// </summary> /// <param name="extInfo">用户扩展信息</param> public static void UserSignIn(UserExtInfo extInfo) { UserData.UpdateUserWhenSignIn(extInfo); UserConfig userConfig = UserConfigs.GetUserConfigCache(); //登录增加经验值 if (userConfig.LoginExpChanged != 0) { UpdateUserExp(extInfo.UserId, userConfig.LoginExpChanged, "登录"); } //登录增加虚拟币 if (userConfig.LoginCoinChanged != 0) { UpdateUserCoin(extInfo.UserId, userConfig.LoginCoinChanged, "登录"); } }
// ***************************************************** // MONO BEHAVIOUR OVERRIDE // ***************************************************** // Start is called before the first frame update void Start() { // Cache userConfigs = FindObjectOfType <UserConfigs>(); audioAnalyzer = FindObjectOfType <AudioAnalyzer>(); // Instantiate all cubes based on marker locations sampleCubes = new GameObject[userConfigs.fftSize]; for (int i = 0; i < userConfigs.numFreqBands; i++) { // spawn cubes as children at location of the markers sampleCubes[i] = Instantiate( sampleCubePrefab, markers.GetChild(i).position, Quaternion.identity, transform ) as GameObject; } }
// ***************************************************** // MONO BEHAVIOUR OVERRIDE // ***************************************************** // Start is called before the first frame update void Start() { // Cache audioSource = GetComponent <AudioSource>(); userConfigs = FindObjectOfType <UserConfigs>(); // State bins = new BinStereo(UserConfigs.MAX_FFT_SIZE); bands = new FreqBandStereo(userConfigs.numFreqBands); bandBufs = new FreqBandStereo(userConfigs.numFreqBands); _bandBufLeftDecrease = new EasyList <float>(100, userConfigs.bufDecreaseStart); // shouldn't ever be more than 100 freq bands _bandBufRightDecrease = new EasyList <float>(100, userConfigs.bufDecreaseStart); // shouldn't ever be more than 100 freq bands _bandBufLeftDecrease.Resize(userConfigs.numFreqBands); _bandBufRightDecrease.Resize(userConfigs.numFreqBands); // Set the audio clip to play audioSource.clip = userConfigs.audioClip; audioSource.Play(); }
/// <summary> /// 设置用户个人信息背景图片 /// </summary> /// <param name="userId">用户编号</param> /// <param name="iconData">背景图片文件数据</param> /// <param name="fileExtName">图片扩展名</param> /// <returns>头像图片文件访问的HTTP路径</returns> public static string SetUserBackIcon(int userId, byte[] iconData, string fileExtName) { string iconUrl = iconData.SaveMediaFile(FileTarget.User, userId, MediaType.Image, fileExtName); if (!string.IsNullOrEmpty(iconUrl)) { //更新用户背景图片 UserData.UpdateUserIcon(userId, iconUrl, 1); //第一次更新背景图片 UserInfoUpdateLog log = new UserInfoUpdateLog { UserId = userId, InfoType = 0 }; bool isFirst = LogsBiz.IsFirstUpdateSelfInfoByUser(log); if (isFirst) { UserConfig userConfig = UserConfigs.GetUserConfigCache(); if (userConfig.SetBackIconExpChanged != 0) { UpdateUserExp(userId, userConfig.SetBackIconExpChanged, "设置背景图片"); } if (userConfig.SetBackIconCoinChanged != 0) { UpdateUserCoin(userId, userConfig.SetBackIconCoinChanged, "设置背景图片"); } } //记录背景图片更新日志 log.Comment = "更新背景图片"; log.CreateDate = DateTime.Now; LogsBiz.CreateLogs <UserInfoUpdateLog>(log); //重置用户缓存 SetUserCacheInfo(userId); //返回补全的背景图片HTTP路径 return(iconUrl.ImageUrlFixed(480, 240)); } return(iconUrl); }
/// <summary> /// 注册用户账号 /// </summary> /// <param name="uAccount">用户账户信息</param> /// <param name="uInfo">用户个人信息</param> /// <param name="extInfo">用户扩展信息</param> public static void CreateUser(UserAccount uAccount, UserInfo uInfo, UserExtInfo extInfo) { UserConfig userConfig = UserConfigs.GetUserConfigCache(); DateTime dtNow = DateTime.Now; #region UserAccount uAccount.UserId = 0; uAccount.PasswordSalt = EncryptHelper.CreateSalt(16); uAccount.Password = CreatePassword(uAccount.Password, uAccount.PasswordSalt); uAccount.LastPasswordChangedDate = dtNow; uAccount.IsApproved = true; uAccount.ApprovedDate = dtNow; uAccount.IsLocked = false; uAccount.LastLockedoutDate = dtNow; uAccount.CreateDate = dtNow; uAccount.LoginCount = 0; uAccount.LastLoginDate = dtNow; #endregion #region UserInfo uInfo.RealName = string.Empty; uInfo.BackIcon = userConfig == null ? string.Empty : (userConfig.DefaultBackIcon ?? string.Empty); uInfo.HeadIcon = userConfig == null ? string.Empty : (userConfig.DefaultHeadIcon ?? string.Empty); uInfo.Signature = string.Empty; uInfo.Comment = string.Empty; uInfo.Gender = 0; uInfo.Birthday = dtNow.AddYears(-18); //uInfo.UserAge = 0; uInfo.IDCardNo = string.Empty; uInfo.Area = string.Empty; uInfo.Address = string.Empty; uInfo.PostCode = string.Empty; uInfo.Industry = string.Empty; uInfo.Company = string.Empty; uInfo.JobPosition = string.Empty; uInfo.Interests = string.Empty; uInfo.WebSite = string.Empty; uInfo.Email = string.Empty; uInfo.Mobile = string.Empty; uInfo.Telphone = string.Empty; uInfo.QQ = string.Empty; uInfo.MSN = string.Empty; uInfo.OtherInfo = string.Empty; uInfo.LastChangeDate = dtNow; #endregion #region UserExtInfo extInfo.UserSite = 0; extInfo.UserRole = 0; extInfo.UserAccess = UserAccess.App | UserAccess.Web; extInfo.CreateDeviceId = extInfo.CreateDeviceId; extInfo.CreateAPPChannel = extInfo.CreateAPPChannel; extInfo.CreateAccountChannel = extInfo.CreateAccountChannel; extInfo.LastLoginDeviceId = extInfo.CreateDeviceId; extInfo.LastLoginAPPChannel = extInfo.CreateAPPChannel; extInfo.LastLoginAccountChannel = extInfo.CreateAccountChannel; extInfo.ExpScore = 0; extInfo.ExpLevel = 0; extInfo.GradeName = string.Empty; extInfo.GradeIcon = string.Empty; extInfo.VirtualCoinCount = 0; extInfo.FansCount = 0; extInfo.FollowedCount = 0; extInfo.TopicCount = 0; extInfo.ReplyCount = 0; #endregion #region UserCoords UserCoords userCoords = new UserCoords { Longitude = 0, Latitudes = 0, LastChangeTime = dtNow }; #endregion #region UserOptions UserOptions userOptions = new UserOptions { RemindPrivateMessage = true, RemindGroupMessage = true, RemindBeFollowed = false, RemindTopicBeReply = false, LastChangeDate = dtNow }; #endregion #region UserWithSchool UserWithSchool userInSchool = new UserWithSchool { SchoolId = 0, IsTrial = false, TrialedSource = string.Empty, IsActivated = false, ActivatedDate = dtNow, IsExpired = false, ExpiredDate = dtNow, StudNo = string.Empty, ClassInfo = string.Empty, Status = 0, Comment = string.Empty, SyncForBbs = false }; #endregion UserData.CreateUser(uAccount, uInfo, extInfo, userCoords, userOptions, userInSchool); if (uAccount.UserId > 0) { //初始经验值 if (userConfig.InitExp != 0) { UpdateUserExp(uAccount.UserId, userConfig.InitExp, "注册"); } //初始虚拟币 if (userConfig.InitCoin != 0) { UpdateUserCoin(uAccount.UserId, userConfig.InitCoin, "注册"); } } }
/// <summary> /// 获取用户验证信息 /// </summary> /// <param name="uAccount">用户账户信息(用户名和密码)</param> /// <param name="userAccess">用户对应的登录权限</param> /// <returns>用户验证信息</returns> public static UserVaildInfo GetUserVaildInfo(UserAccount uAccount, UserAccess userAccess = UserAccess.App) { UserVaildInfo uVaildInfo = UserData.GetUserVaildInfo(uAccount.UserName, userAccess); #region 密码 uAccount.Password = string.Format("MIAP_{0}_{1}_GW", uAccount.Password, uVaildInfo.PasswordSalt).CreateMD5Encrypt(); if (!uAccount.Password.Equals(uVaildInfo.Password)) { uVaildInfo.UserId = 0; return(uVaildInfo); } #endregion #region 账户是否通过验证 if (!uVaildInfo.IsApproved) { uVaildInfo.UserId = -1; return(uVaildInfo); } #endregion #region 是否被锁定 if (uVaildInfo.IsLocked) { if (DateTime.Now < uVaildInfo.LastLockedoutDate) { uVaildInfo.UserId = -2; return(uVaildInfo); } //锁定时间到期,解锁 UserData.SetUsesUnLocked(uVaildInfo.UserId); //记录状态变更日志 UserStatusChangedLog log = new UserStatusChangedLog { UserId = uVaildInfo.UserId, Action = 1, Comment = "锁定时间到期,自动解锁!", CreateDate = DateTime.Now }; LogsBiz.CreateLogs <UserStatusChangedLog>(log); } #endregion #region 是否为试用账号,如果是,试用账号状态 if (uVaildInfo.UserSite > 0) { UserWithSchool uWithSchool = UserData.GetUserWithSchool(uVaildInfo.UserId); UserWithSchool tempUserWithSchoolInfo; //试用账号 if (uWithSchool.IsTrial) { if (!uWithSchool.IsActivated) { //激活试用账号 UserConfig userConfig = UserConfigs.GetUserConfigCache(); tempUserWithSchoolInfo = new UserWithSchool { UserId = uWithSchool.UserId, IsActivated = true, ActivatedDate = DateTime.Now, IsExpired = false, ExpiredDate = userConfig.TrialAccountExpiredDay > 0 ? DateTime.Now.AddDays(userConfig.TrialAccountExpiredDay) : DateTime.MaxValue }; UserData.SchoolTrialUserStatusChanged(tempUserWithSchoolInfo); } else { //超时时间已过,将试用账号设为过期 if (!uWithSchool.IsExpired && DateTime.Now >= uWithSchool.ExpiredDate) { tempUserWithSchoolInfo = new UserWithSchool { UserId = uWithSchool.UserId, IsActivated = uWithSchool.IsActivated, ActivatedDate = uWithSchool.ActivatedDate, IsExpired = true, ExpiredDate = uWithSchool.ExpiredDate }; UserData.SchoolTrialUserStatusChanged(tempUserWithSchoolInfo, 1); uWithSchool.IsExpired = true; } //试用账号已过期 if (uWithSchool.IsExpired) { uVaildInfo.UserId = -3; return(uVaildInfo); } } } } #endregion return(uVaildInfo); }