public int AddNoSpeak(int days) { int result = 0; using (livecloudEntities db = new livecloudEntities()) { dt_UserBarrageNoSpeak dt_UserBarrageNoSpeak = new dt_UserBarrageNoSpeak() { identityid = Identityid, UserName = UserName, UserNickName = string.IsNullOrEmpty(UserNickName) ? "" : UserNickName, Remark = ChatMessage, Type = 0, Duration = days, AddTime = DateTime.Now, OperateUser = "******" }; db.dt_UserBarrageNoSpeak.Add(dt_UserBarrageNoSpeak); db.SaveChanges(); //更新NoSpeak緩存 StaticTables.sdt_UserBarrageNoSpeak = (from p in db.dt_UserBarrageNoSpeak select p).OrderByDescending(p => p.lockid).ToList(); } return(result); }
/// <summary> /// 用戶自由聊天內容記錄至DB /// </summary> public void UserBarrageLog() { // 用戶彈幕內容記錄至DB using (var db = new livecloudEntities()) { dt_UserBarrageLog userBarrageLog = new dt_UserBarrageLog { UserName = this.UserName, UserNickName = this.UserNickName, ChatMessage = this.ChatMessage, AddTime = DateTime.Now }; db.dt_UserBarrageLog.Add(userBarrageLog); db.SaveChanges(); } }
/// <summary> /// 用戶系統彈幕內容記錄至DB /// </summary> public void SystemBarrageLog() { using (var db = new livecloudEntities()) { var sysbarrageId = int.Parse(ChatMessage.Replace("##", "")); var systembarrage = new dt_SystemBarrageLog { barrageId = sysbarrageId, operUser = UserName, add_time = System.DateTime.Now, signal = 0 }; db.dt_SystemBarrageLog.Add(systembarrage); var sysBarrageTimes = db.dt_SystemBarrageTimes.Find(sysbarrageId); if (sysBarrageTimes == null) { sysBarrageTimes = new dt_SystemBarrageTimes() { systembarrageid = sysbarrageId, times = 1, updatetime = DateTime.Now }; db.dt_SystemBarrageTimes.Add(sysBarrageTimes); } else { var now = DateTime.Now; var addDays = ((int)now.DayOfWeek == 0) //週日 ? 6 : (int)now.DayOfWeek - 1; var startTime = new DateTime(now.Year, now.Month, now.Day, 0, 0, 0).AddDays(-addDays); //該週周一凌晨12點 sysBarrageTimes.times = (sysBarrageTimes.updatetime >= startTime) ? sysBarrageTimes.times + 1 : 1; sysBarrageTimes.updatetime = now; } db.SaveChanges(); } }
/// <summary> /// 自由發言阻擋紀錄 /// </summary> /// <param name="blockType">0:黑名单|1:禁用词 | 2:人工審核</param> public void ChatBlockLog(int blockType, string fuckWords = "") { using (var db = new livecloudEntities()) { var blockLog = new ChatMessageBlockLog { UserName = UserName, UserNickName = UserNickName ?? "", State = blockType, Content = ChatMessage, BlockWords = fuckWords, Time = DateTime.Now }; db.ChatMessageBlockLog.Add(blockLog); db.SaveChanges(); } }