/// <summary> /// 更新系統彈幕次數 /// </summary> private static void UpdateSystemBarrageStatistics() { try { DateTime weekDate = DateTime.Now.AddDays(-7); using (var db = new livecloudEntities()) { //增加 var listSystemBarrageLog = db.dt_SystemBarrageLog.Where(s => s.signal == 0 && s.add_time >= weekDate).ToList(); foreach (dt_SystemBarrageLog systemBarrageLog in listSystemBarrageLog) { dt_SystemBarrage editSystemBarrage = db.dt_SystemBarrage.Find(systemBarrageLog.barrageId); if (editSystemBarrage != null) { editSystemBarrage.times++; systemBarrageLog.signal = 1; } } if (db.ChangeTracker.HasChanges()) { db.SaveChanges(); } //減少 var listSystemBarrageLogDiff = db.dt_SystemBarrageLog.Where(s => s.signal == 1 && s.add_time <= weekDate).ToList(); foreach (dt_SystemBarrageLog systemBarrageLog in listSystemBarrageLogDiff) { dt_SystemBarrage editSystemBarrage = db.dt_SystemBarrage.Find(systemBarrageLog.barrageId); if (editSystemBarrage != null) { editSystemBarrage.times--; systemBarrageLog.signal = 2; } } if (db.ChangeTracker.HasChanges()) { db.SaveChanges(); } } } catch (Exception ex) { Log.Error("global", "UpdateSystemBarrageStatistics", ex.ToString()); } }
public ResultInfoT <object> Post() { var result = new ResultInfoT <object>() { IsLogin = ResultHelper.IsLogin }; var request = HttpContext.Current.Request; var session = HttpContext.Current.Session; try { int managerId = (int)(session["ManagerId"] ?? -1); if (managerId < 0) { // 缺少Log紀錄 result.Code = ResultHelper.NotAuthorized; result.StrCode = ResultHelper.NotLoginMsg; result.IsLogin = ResultHelper.NotLogin; return(result); } var now = DateTime.Now; using (var db = new livecloudEntities()) { var manageLog = new dt_ManageLog() { ManagerId = managerId, ManagerName = db.dt_Manager.Find(managerId).user_name, ActionType = "clearSystemBarrageTimes", AddTime = now, IP = NetworkTool.GetClientIP(HttpContext.Current), Remarks = "系统弹幕使用次数清零" }; db.dt_ManageLog.Add(manageLog); foreach (var data in db.dt_SystemBarrageTimes) { data.times = 0; data.updatetime = now; } db.SaveChanges(); } result.Code = ResultHelper.Success; result.StrCode = ResultHelper.SuccessMsg; return(result); } catch (Exception ex) { Log.Error("ClearSystemBarrageTimes", "ClearSystemBarrageTimes", ex.Message.ToString()); result.Code = ResultHelper.ExecutingError; result.StrCode = ResultHelper.ExecutingErrorMsg; return(result); } }
/// <summary> /// 更新直播狀態 /// </summary> private static void UpdateLiveStatus() { using (var db = new livecloudEntities()) { foreach (var live in db.dt_liveList.Where(s => s.stop_time != "").ToList()) { var livetime = Convert.ToDateTime(live.stop_time); if (livetime <= DateTime.Now) { live.state = Convert.ToByte(1); live.stop_time = ""; live.update_time = DateTime.Now; db.SaveChanges(); } } } }
private void ProcessBlockLogEmptyData() { using (var db = new livecloudEntities()) { var blockLog1 = db.ChatMessageBlockLog.OrderBy(o => o.Id).FirstOrDefault(); if (blockLog1 != null && string.IsNullOrEmpty(blockLog1.BlockWords)) { foreach (var blockLog in db.ChatMessageBlockLog) { if (string.IsNullOrEmpty(blockLog.BlockWords)) { blockLog.BlockWords = GetBlockWords(db, blockLog.Content); } } db.SaveChanges(); } } }
public ResultInfoT <object> Post() { var result = new ResultInfoT <object>() { IsLogin = ResultHelper.IsLogin }; var request = HttpContext.Current.Request; var session = HttpContext.Current.Session; try { int managerId = (int)(session["ManagerId"] ?? -1); if (managerId < 0) { // 缺少Log紀錄 result.Code = ResultHelper.NotAuthorized; result.StrCode = ResultHelper.NotLoginMsg; result.IsLogin = ResultHelper.NotLogin; return(result); } int id = int.TryParse(request.Form["ID"], out id) ? id : -1; byte state = byte.TryParse(request.Form["State"], out state) ? state : (byte)255; //0黑名单|1白名单 var content = request.Form["Content"] ?? ""; var remark = request.Form["Remark"] ?? ""; var action = request.Form["Type"] ?? ""; var now = DateTime.Now; switch (action.ToLower()) { case "add": { if (string.IsNullOrEmpty(content) || state == (byte)255) { result.Code = ResultHelper.ParamFail; result.StrCode = ResultHelper.ParamFailMsg; return(result); } break; } case "edit": { if (id <= 0 || string.IsNullOrEmpty(content)) { result.Code = ResultHelper.ParamFail; result.StrCode = ResultHelper.ParamFailMsg; return(result); } break; } default: result.Code = ResultHelper.ParamFail; result.StrCode = ResultHelper.ParamFailMsg; return(result); } using (var db = new livecloudEntities()) { ////驗證權限(不確定是否為相應的欄位) //var operationManager = db.dt_Manager.Find(managerId); //var operationManagerRole = Cache.Role.Where(o => o.Id == operationManager.admin_role).FirstOrDefault(); //if (operationManagerRole.SentenceManage == false) //{ // result.Code = ResultHelper.NotAuthorized; // result.StrCode = ResultHelper.NotAuthorizedMsg; // return result; //} var manageLog = new dt_ManageLog() { ManagerId = managerId, ManagerName = db.dt_Manager.Find(managerId).user_name, ActionType = "setSentenceManage", AddTime = now, IP = NetworkTool.GetClientIP(HttpContext.Current) }; switch (action.ToLower()) { case "add": { var sentence = db.dt_SensitiveSentences .Where(s => s.content == content.Trim()) .FirstOrDefault(); if (sentence != null) { result.Code = ResultHelper.ParamFail; result.StrCode = "已有相同内容之" + (sentence.state == 0 ? "黑" : "白") + "名单!"; return(result); } var blockWords = db.dt_SensitiveWords .Where(s => s.state == 0 && content.Trim().Contains(s.content)) .FirstOrDefault(); if (blockWords != null) { result.Code = ResultHelper.ParamFail; result.StrCode = "已有包含该内容之禁用词语!"; return(result); } sentence = new dt_SensitiveSentences() { content = content.Trim(), remark = remark, state = state, addtime = now, updatetime = now, adminid = managerId, adminname = db.dt_Manager.Find(managerId).user_name }; manageLog.Remarks = "添加" + ((state == 1) ? "白" : "黑") + "名单:" + content; db.dt_SensitiveSentences.Add(sentence); break; } case "edit": { var sentence = db.dt_SensitiveSentences .Where(s => s.content == content.Trim() && s.id != id) .FirstOrDefault(); if (sentence != null) { result.Code = ResultHelper.ParamFail; result.StrCode = "已有相同内容之" + (sentence.state == 0 ? "黑" : "白") + "名单!"; return(result); } var blockWords = db.dt_SensitiveWords .Where(s => s.state == 0 && content.Trim().Contains(s.content)) .FirstOrDefault(); if (blockWords != null) { result.Code = ResultHelper.ParamFail; result.StrCode = "已有包含该内容之禁用词语!"; return(result); } sentence = db.dt_SensitiveSentences.Find(id); if (sentence == null) { result.Code = ResultHelper.ParamFail; result.StrCode = "找不到ID:" + id + "的数据!"; return(result); } if (!string.IsNullOrEmpty(content.Trim())) { sentence.content = content.Trim(); } if (!string.IsNullOrEmpty(remark.Trim())) { sentence.remark = remark.Trim(); } if (state < 255) { sentence.state = state; } sentence.updatetime = now; sentence.adminid = managerId; sentence.adminname = db.dt_Manager.Find(managerId).user_name; manageLog.Remarks = "修改黑白名单ID:" + sentence.id + ", 內容:" + content; break; } } db.dt_ManageLog.Add(manageLog); db.SaveChanges(); UpdateMsg.PostUpdate("dt_SensitiveSentences"); } result.Code = ResultHelper.Success; result.StrCode = ResultHelper.SuccessMsg; return(result); } catch (DbUpdateException ex) { Log.Info("SetSentenceManage", "SetSentenceManage", ex.InnerException.Message.ToString()); result.Code = ResultHelper.ParamFail; result.StrCode = "已有重复的内容,请刷新页面"; return(result); } catch (Exception ex) { Log.Error("SetSentenceManage", "SetSentenceManage", ex.Message.ToString()); result.Code = ResultHelper.ExecutingError; result.StrCode = ResultHelper.ExecutingErrorMsg; return(result); } }
public ResultInfoT <object> Post() { var result = new ResultInfoT <object>() { IsLogin = ResultHelper.IsLogin }; var request = HttpContext.Current.Request; var session = HttpContext.Current.Session; try { int managerId = (int)(session["ManagerId"] ?? -1); if (managerId < 0) { // 缺少Log紀錄 result.Code = ResultHelper.NotAuthorized; result.StrCode = ResultHelper.NotLoginMsg; result.IsLogin = ResultHelper.NotLogin; return(result); } var userName = request.Form["UserName"] ?? ""; var oldPassword = request.Form["oldPassword"] ?? ""; var newPassword = request.Form["newPassword"] ?? ""; var action = request.Form["Type"] ?? ""; var now = DateTime.Now; if (string.IsNullOrEmpty(userName) || string.IsNullOrEmpty(oldPassword) || string.IsNullOrEmpty(newPassword) || action.ToLower() != "edit") { result.Code = ResultHelper.ParamFail; result.StrCode = ResultHelper.ParamFailMsg; return(result); } using (var db = new livecloudEntities()) { ////驗證權限(不確定是否為相應的欄位) //var operationManager = db.dt_Manager.Find(managerId); //var operationManagerRole = Cache.Role.Where(o => o.Id == operationManager.admin_role).FirstOrDefault(); //if (operationManagerRole.Manager == false) //{ // result.Code = ResultHelper.NotAuthorized; // result.StrCode = ResultHelper.NotAuthorizedMsg; // return result; //} var manager = db.dt_Manager.Where(m => m.user_name == userName).FirstOrDefault(); if (manager == null) { result.Code = ResultHelper.ParamFail; result.StrCode = "不存在管理员帐户:" + userName + "!"; return(result); } if (manager.password != oldPassword) { result.Code = ResultHelper.ParamFail; result.StrCode = "原密码错误!"; return(result); } manager.password = newPassword; var manageLog = new dt_ManageLog() { ManagerId = managerId, ManagerName = db.dt_Manager.Find(managerId).user_name, ActionType = "setPassword", AddTime = now, Remarks = "修改帐户密码:" + manager.user_name, IP = NetworkTool.GetClientIP(HttpContext.Current) }; db.dt_ManageLog.Add(manageLog); db.SaveChanges(); result.Code = ResultHelper.Success; result.StrCode = ResultHelper.SuccessMsg; } return(result); } catch (Exception ex) { Log.Error("SetPassword", "SetPassword", ex.Message.ToString()); result.Code = ResultHelper.ExecutingError; result.StrCode = ResultHelper.ExecutingErrorMsg; return(result); } }
public ResultInfoT <object> Post() { var result = new ResultInfoT <object>() { IsLogin = ResultHelper.IsLogin }; var request = HttpContext.Current.Request; var session = HttpContext.Current.Session; try { int managerId = (int)(session["ManagerId"] ?? -1); if (managerId < 0) { // 缺少Log紀錄 result.Code = ResultHelper.NotAuthorized; result.StrCode = ResultHelper.NotLoginMsg; result.IsLogin = ResultHelper.NotLogin; return(result); } var now = DateTime.Now; var multiId = request.Form["ID"] ?? ""; if (string.IsNullOrEmpty(multiId) || !(new Regex(@"^(([\d]{1,}){1}|(([\d]{1,}\,){1,}([\d]{1,}){1}))$").IsMatch(multiId))) { result.Code = ResultHelper.ParamFail; result.StrCode = ResultHelper.ParamFailMsg; return(result); } ////驗證權限 using (var db = new livecloudEntities()) { var operationManager = db.dt_Manager.Find(managerId); var operationManagerRole = Cache.Role.Where(o => o.Id == operationManager.admin_role).FirstOrDefault(); if (operationManagerRole.AllowIp == false) { result.Code = ResultHelper.NotAuthorized; result.StrCode = ResultHelper.NotAuthorizedMsg; return(result); } } var idList = multiId.Split(',').Select(o => Convert.ToInt32(o)).Distinct().OrderBy(o => o).ToList(); using (var db = new livecloudEntities()) { var delAllowIpList = db.dt_AllowAccessIPList.Where(o => idList.Contains(o.Id)).ToList(); var manager = db.dt_Manager.Find(managerId); bool ipDicSingal = false; if (delAllowIpList.Count > 0) { foreach (var allowIp in delAllowIpList) { var manageLog = new dt_ManageLog() { ManagerId = managerId, ManagerName = manager.user_name, ActionType = "delAllowIp", AddTime = now, Remarks = "删除IP:" + allowIp.Ip + "(ID:" + allowIp.Id + ")", IP = NetworkTool.GetClientIP(HttpContext.Current) }; db.dt_ManageLog.Add(manageLog); ipDicSingal = apiController.RemoveIpList(allowIp.Ip); if (!ipDicSingal) { break; } } db.dt_AllowAccessIPList.RemoveRange(delAllowIpList); if (ipDicSingal) { db.SaveChanges(); } else { result.Code = ResultHelper.ExecutingError; result.StrCode = ResultHelper.ExecutingErrorMsg; return(result); } } result.Code = ResultHelper.Success; result.StrCode = ResultHelper.SuccessMsg; } return(result); } catch (Exception ex) { Log.Error("DelAnchor", "DelAnchor", ex.Message.ToString()); result.Code = ResultHelper.ExecutingError; result.StrCode = ResultHelper.ExecutingErrorMsg; return(result); } }
public ResultInfoT <object> Post() { var result = new ResultInfoT <object>() { IsLogin = ResultHelper.IsLogin }; var request = HttpContext.Current.Request; var session = HttpContext.Current.Session; try { int managerId = (int)(session["ManagerId"] ?? -1); if (managerId < 0) { // 缺少Log紀錄 result.Code = ResultHelper.NotAuthorized; result.StrCode = ResultHelper.NotLoginMsg; result.IsLogin = ResultHelper.NotLogin; return(result); } var action = request.Form["Type"] ?? ""; var content = request.Form["Content"] ?? ""; var remark = request.Form["Remark"] ?? ""; int id = int.TryParse(request.Form["ID"] ?? "", out id) ? id : -1; var now = DateTime.Now; switch (action.ToLower()) { case "add": { if (string.IsNullOrEmpty(content)) { result.Code = ResultHelper.ParamFail; result.StrCode = ResultHelper.ParamFailMsg; return(result); } break; } case "edit": { if (id <= 0 || string.IsNullOrEmpty(content)) { result.Code = ResultHelper.ParamFail; result.StrCode = ResultHelper.ParamFailMsg; return(result); } break; } default: result.Code = ResultHelper.ParamFail; result.StrCode = ResultHelper.ParamFailMsg; return(result); } using (var db = new livecloudEntities()) { ////驗證權限(不確定是否為相應的欄位) //var operationManager = db.dt_Manager.Find(managerId); //var operationManagerRole = Cache.Role.Where(o => o.Id == operationManager.admin_role).FirstOrDefault(); //if (operationManagerRole.SystemBarrage == false) //{ // result.Code = ResultHelper.NotAuthorized; // result.StrCode = ResultHelper.NotAuthorizedMsg; // return result; //} var manageLog = new dt_ManageLog() { ManagerId = managerId, ManagerName = db.dt_Manager.Find(managerId).user_name, ActionType = "setSystemBarrage", AddTime = now, IP = NetworkTool.GetClientIP(HttpContext.Current) }; switch (action.ToLower()) { case "add": { var dupContent = db.dt_SystemBarrage.Where(s => s.content == content).FirstOrDefault(); if (dupContent != null) { result.Code = ResultHelper.ParamFail; result.StrCode = "已存在相同内容的系统弹幕!"; return(result); } var totalCount = db.dt_SystemBarrage.Count(); if (totalCount >= Conf.MaxSystemBarrageCount) { result.Code = ResultHelper.ParamFail; result.StrCode = "系统弹幕已达" + Conf.MaxSystemBarrageCount.ToString() + "条,无法继续添加!"; return(result); } var sysBarrage = new dt_SystemBarrage() { content = content, add_time = now, update_time = now, state = (byte)1, times = 0, operUser = db.dt_Manager.Find(managerId).user_name, Remark = remark }; db.dt_SystemBarrage.Add(sysBarrage); manageLog.Remarks = "添加系统弹幕:" + content; break; } case "edit": { var sysBarrage = db.dt_SystemBarrage.Find(id); if (sysBarrage == null) { result.Code = ResultHelper.ParamFail; result.StrCode = ResultHelper.ParamFailMsg + " ID:" + id + "的系统弹幕不存在"; return(result); } sysBarrage.content = content; sysBarrage.update_time = now; sysBarrage.operUser = db.dt_Manager.Find(managerId).user_name; if (!string.IsNullOrEmpty(remark)) { sysBarrage.Remark = remark; } manageLog.Remarks = "修改系统弹幕:" + content + "(ID:" + sysBarrage.id + ")"; break; } } db.dt_ManageLog.Add(manageLog); db.SaveChanges(); } result.Code = ResultHelper.Success; result.StrCode = ResultHelper.SuccessMsg; return(result); } catch (DbUpdateException ex) { Log.Info("SetSystemBarrage", "SetSystemBarrage", ex.InnerException.Message.ToString()); result.Code = ResultHelper.ParamFail; result.StrCode = "已有重复的内容,请刷新页面"; return(result); } catch (Exception ex) { Log.Error("SetSystemBarrage", "SetSystemBarrage", ex.Message.ToString()); result.Code = ResultHelper.ExecutingError; result.StrCode = ResultHelper.ExecutingErrorMsg; return(result); } }
public ResultInfoT <object> Post() { var result = new ResultInfoT <object>() { IsLogin = ResultHelper.IsLogin }; var request = HttpContext.Current.Request; var session = HttpContext.Current.Session; bool boadflog = false; try { int managerId = (int)(session["ManagerId"] ?? -1); if (managerId < 0) { // 缺少Log紀錄 result.Code = ResultHelper.NotAuthorized; result.StrCode = ResultHelper.NotLoginMsg; result.IsLogin = ResultHelper.NotLogin; return(result); } var now = DateTime.Now; int id = int.TryParse(request.Form["ID"] ?? "-1", out id) ? id : -1; byte state = byte.TryParse(request.Form["State"] ?? "255", out state) ? state : (byte)255; if (id <= 0 && state == (byte)255) { result.Code = ResultHelper.ParamFail; result.StrCode = ResultHelper.ParamFailMsg; return(result); } var sendBarrage = false; dt_ManualReview needReviewBarrage = null; using (var db = new livecloudEntities()) { ////驗證權限(不確定是否為相應的欄位) //var operationManager = db.dt_Manager.Find(managerId); //var operationManagerRole = Cache.Role.Where(o => o.Id == operationManager.admin_role).FirstOrDefault(); //if (operationManagerRole.BarrageManage == false) //{ // result.Code = ResultHelper.NotAuthorized; // result.StrCode = ResultHelper.NotAuthorizedMsg; // return result; //} //needReviewBarrage = db.dt_ManualReview.Find(id); needReviewBarrage = db.dt_ManualReview.Where(o => o.Id == id && o.State != state).FirstOrDefault(); if (needReviewBarrage == null) { result.Code = ResultHelper.ParamFail; result.StrCode = "找不到ID:" + id + "的數據"; return(result); } //表//0未审核 | 1已通过 | 2观察 | 3已屏蔽,为空即全部 //1通过,2观察,3屏蔽 ---,4加入白名单,5加入黑名单 //if (needReviewBarrage.State != 0 && needReviewBarrage.State != 2) //如果不是未審核或觀察中,代表該筆資料已被異動 if (needReviewBarrage.State == 4 || (needReviewBarrage.State == 5)) { result.Code = ResultHelper.ParamFail; result.StrCode = "数据已更新,请重新刷新页面"; return(result); } switch (state) { case 1: sendBarrage = true; needReviewBarrage.State = (byte)1; break; case 4: //白名單 case 5: //黑名單 //表//0未审核 | 1已通过 | 2观察 | 3已屏蔽,为空即全部 //1通过,2观察,3屏蔽,4加入白名单,5加入黑名单 var sentence = db.dt_SensitiveSentences .Where(s => s.content == needReviewBarrage.Content.Trim()) .FirstOrDefault(); if (sentence != null) { result.Code = ResultHelper.ParamFail; result.StrCode = "已有相同内容之" + (sentence.state == 0 ? "黑" : "白") + "名单!"; return(result); } var blockWords = db.dt_SensitiveWords .Where(s => s.state == 0 && needReviewBarrage.Content.Trim().Contains(s.content)) .FirstOrDefault(); if (blockWords != null) { result.Code = ResultHelper.ParamFail; result.StrCode = "已有包含该内容之禁用词语!"; return(result); } sentence = new dt_SensitiveSentences() { adminid = managerId, adminname = db.dt_Manager.Find(managerId).user_name, addtime = now, content = needReviewBarrage.Content, state = (state == 4) ? (byte)1 : (byte)0, remark = "", updatetime = now }; db.dt_SensitiveSentences.Add(sentence); //needReviewBarrage.State = (state == 4) ? (byte)1 : (byte)3; needReviewBarrage.State = state; break; default: needReviewBarrage.State = state; break; } //表//0未审核 | 1已通过 | 2观察 | 3已屏蔽,为空即全部 //1通过,2观察,3屏蔽,4加入白名单,5加入黑名单 TimeSpan ts = (now - needReviewBarrage.AddTime); if (ts.TotalSeconds < 60) { boadflog = true; } needReviewBarrage.AddTime = now; needReviewBarrage.ManagerID = managerId; db.SaveChanges(); UpdateMsg.PostUpdate("dt_SensitiveSentences"); } var values = new NameValueCollection(); values["Target"] = needReviewBarrage.Target; values["GameID"] = needReviewBarrage.GameID; values["Type"] = "Barrage"; values["ChatMessage"] = needReviewBarrage.Content; values["UserGroup"] = needReviewBarrage.UserLevel.ToString(); values["UserName"] = needReviewBarrage.UserName; values["UserNickName"] = needReviewBarrage.UserNickName; values["AllowUserGroups"] = "-1,2,3,5,4,6,7,8,9,1,"; values["MinSendInterval"] = "1"; if (sendBarrage && boadflog) { using (var client = new WebClient() { Encoding = Encoding.UTF8 }) { var ResultTemp = Encoding.UTF8.GetString(client.UploadValues(Conf.SLCMFUrl, values)); //client.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded"; //var message = new //{ // Target = needReviewBarrage.Target, // GameID = needReviewBarrage.GameID, // Data = new // { // Level = needReviewBarrage.UserLevel, // Message = needReviewBarrage.Content, // //NickName = (!string.IsNullOrEmpty(needReviewBarrage.UserNickName)) // // ? needReviewBarrage.UserNickName // // : needReviewBarrage.UserName, // NickName = (!string.IsNullOrEmpty(needReviewBarrage.UserNickName) && SensitiveReplace.IsSafeContent(needReviewBarrage.UserNickName)) // ? needReviewBarrage.UserNickName // : SameMethod.FuzzyName(needReviewBarrage.UserName), // Type = "Barrage" // } //}; //var data = "content=" + JsonConvert.SerializeObject(message); //var resultg = client.UploadString(Conf.WSUrl, "POST", data); //Result resultB = JsonConvert.DeserializeObject<Result>(resultg.ToString()); //if (result.code == 1) // return Ok(); //else // return BadRequest("LIVE_廣播失敗"); } } result.Code = ResultHelper.Success; result.StrCode = ResultHelper.SuccessMsg; return(result); } catch (DbUpdateException ex) { Log.Info("SetManualReview", "SetManualReview", ex.InnerException.Message.ToString()); result.Code = ResultHelper.ParamFail; result.StrCode = "已有重复的内容,请刷新页面"; return(result); } catch (Exception ex) { Log.Error("SetManualReview", "SetManualReview", ex.Message.ToString()); result.Code = ResultHelper.ExecutingError; result.StrCode = ResultHelper.ExecutingErrorMsg; return(result); } }
public ResultInfoT <object> Post() { var result = new ResultInfoT <object>() { IsLogin = ResultHelper.IsLogin }; var request = HttpContext.Current.Request; var session = HttpContext.Current.Session; try { int managerId = (int)(session["ManagerId"] ?? -1); if (managerId < 0) { // 缺少Log紀錄 result.Code = ResultHelper.NotAuthorized; result.StrCode = ResultHelper.NotLoginMsg; result.IsLogin = ResultHelper.NotLogin; return(result); } string action = request.Form["Action"] ?? ""; int id = int.TryParse(request.Form["ID"] ?? "", out id) ? id : 0; string content = request.Form["Content"] ?? ""; string remark = request.Form["Remark"] ?? ""; string type = request.Form["Type"] ?? ""; DateTime now = DateTime.Now; switch (type.ToLower()) { case "add": { if (string.IsNullOrEmpty(content)) { result.Code = ResultHelper.ParamFail; result.StrCode = ResultHelper.ParamFailMsg; return(result); } break; } case "edit": { if (id <= 0) { result.Code = ResultHelper.ParamFail; result.StrCode = ResultHelper.ParamFailMsg; return(result); } break; } default: result.Code = ResultHelper.ParamFail; result.StrCode = ResultHelper.ParamFailMsg; return(result); } using (livecloudEntities db = new livecloudEntities()) { var manageLog = new dt_ManageLog() { ManagerId = managerId, ManagerName = db.dt_Manager.Find(managerId).user_name, ActionType = "setBlackWordManage", AddTime = now, IP = NetworkTool.GetClientIP(HttpContext.Current) }; if (!string.IsNullOrEmpty(content)) { var dupcontent = type == "add" ? db.dt_BlackWords.Where(o => o.content == content.Trim()).FirstOrDefault() : db.dt_BlackWords.Where(o => o.content == content.Trim() & o.id != id).FirstOrDefault(); if (dupcontent != null) { result.Code = ResultHelper.ParamFail; result.StrCode = "已存在相同名称的黑词!"; return(result); } } switch (type.ToLower()) { case "add": { var black = new dt_BlackWords { content = content.Trim(), state = 5, remark = remark.Trim(), addtime = now, updatetime = now, adminid = manageLog.Id, adminname = manageLog.ManagerName }; db.dt_BlackWords.Add(black); db.SaveChanges(); manageLog.Remarks = "添加黑詞名单ID:" + black.id + ", 內容:" + content; break; } case "edit": { var black = db.dt_BlackWords.Where(o => o.content == content.Trim() && o.id != id).FirstOrDefault(); if (black != null) { result.Code = ResultHelper.ParamFail; result.StrCode = "已有相同内容黑词名单!"; return(result); } black = db.dt_BlackWords.Find(id); if (black == null) { result.Code = ResultHelper.ParamFail; result.StrCode = "找不到ID:" + id + "的数据!"; return(result); } if (!string.IsNullOrEmpty(content)) { black.content = content.Trim(); } if (!string.IsNullOrEmpty(remark)) { black.remark = remark.Trim(); } black.updatetime = now; black.adminid = manageLog.Id; black.adminname = manageLog.ManagerName; manageLog.Remarks = "修改黑詞名单ID:" + black.id + ", 內容:" + content; break; } } db.dt_ManageLog.Add(manageLog); db.SaveChanges(); UpdateMsg.PostUpdate("dt_BlackWords"); } result.Code = ResultHelper.Success; result.StrCode = ResultHelper.SuccessMsg; return(result); } catch (DbUpdateException ex) { Log.Info("SetSentenceManage", "SetSentenceManage", ex.InnerException.Message.ToString()); result.Code = ResultHelper.ParamFail; result.StrCode = "已有重复的内容,请刷新页面"; return(result); } catch (Exception ex) { Log.Error("SetSentenceManage", "SetSentenceManage", ex.Message.ToString()); result.Code = ResultHelper.ExecutingError; result.StrCode = ResultHelper.ExecutingErrorMsg; return(result); } }
public ResultInfoT <object> Post() { var result = new ResultInfoT <object>() { IsLogin = ResultHelper.IsLogin }; var request = HttpContext.Current.Request; var session = HttpContext.Current.Session; try { int managerId = (int)(session["ManagerId"] ?? -1); if (managerId < 0) { // 缺少Log紀錄 result.Code = ResultHelper.NotAuthorized; result.StrCode = ResultHelper.NotLoginMsg; result.IsLogin = ResultHelper.NotLogin; return(result); } var now = DateTime.Now; var multiId = request.Form["ID"] ?? ""; if (string.IsNullOrEmpty(multiId) || !(new Regex(@"^(([\d]{1,}){1}|(([\d]{1,}\,){1,}([\d]{1,}){1}))$").IsMatch(multiId))) { result.Code = ResultHelper.ParamFail; result.StrCode = ResultHelper.ParamFailMsg; return(result); } //驗證權限 using (var db = new livecloudEntities()) { var operationManager = db.dt_Manager.Find(managerId); var operationManagerRole = Cache.Role.Where(o => o.Id == operationManager.admin_role).FirstOrDefault(); if (operationManagerRole.RoleManage == false) { result.Code = ResultHelper.NotAuthorized; result.StrCode = ResultHelper.NotAuthorizedMsg; return(result); } } var idList = multiId.Split(',').Select(o => Convert.ToInt32(o)).Distinct().OrderBy(o => o).ToList(); using (var db = new livecloudEntities()) { var usedRolesManagerList = db.dt_Manager.Where(m => idList.Contains(m.admin_role)); if (usedRolesManagerList.Count() > 0) { result.Code = ResultHelper.ParamFail; result.StrCode = "无法删除已绑定管理员之角色!"; return(result); } var delRoleList = db.dt_ManagerRole.RemoveRange(db.dt_ManagerRole.Where(o => idList.Contains(o.Id))); var manager = db.dt_Manager.Find(managerId); foreach (var role in delRoleList) { var manageLog = new dt_ManageLog() { ManagerId = managerId, ManagerName = manager.user_name, ActionType = "delRole", AddTime = now, Remarks = "删除角色:" + role.RoleName + "(ID:" + role.Id + ")", IP = NetworkTool.GetClientIP(HttpContext.Current) }; db.dt_ManageLog.Add(manageLog); } db.dt_ManagerRole.RemoveRange(delRoleList); db.SaveChanges(); result.Code = ResultHelper.Success; result.StrCode = ResultHelper.SuccessMsg; } //刷新腳色緩存 //Cache.refreshRole(); return(result); } catch (Exception ex) { Log.Error("DelRole", "DelRole", ex.Message.ToString()); result.Code = ResultHelper.ExecutingError; result.StrCode = ResultHelper.ExecutingErrorMsg; return(result); } }
public ResultInfoT <object> Post() { var result = new ResultInfoT <object>() { IsLogin = ResultHelper.IsLogin }; var request = HttpContext.Current.Request; var session = HttpContext.Current.Session; try { int managerId = (int)(session["ManagerId"] ?? -1); if (managerId < 0) { // 缺少Log紀錄 result.Code = ResultHelper.NotAuthorized; result.StrCode = ResultHelper.NotLoginMsg; result.IsLogin = ResultHelper.NotLogin; return(result); } var action = request.Form["Type"] ?? ""; int broadcastId = (int.TryParse(request.Form["BroadCastID"] ?? "", out broadcastId)) ? broadcastId : -1; int liveId = (int.TryParse(request.Form["GameID"] ?? "", out liveId)) ? liveId : -1; var now = DateTime.Now; DateTime startTime = DateTime.TryParse(request.Form["StartTime"] ?? "", out startTime) ? startTime : now; DateTime endTime = DateTime.TryParse(request.Form["EndTime"] ?? "", out endTime) ? endTime : now; var content = request.Form["Content"] ?? ""; ////驗證權限(不確定是否為相應的欄位) //using (var db = new livecloudEntities()) //{ // var operationManager = db.dt_Manager.Find(managerId); // var operationManagerRole = Cache.Role.Where(o => o.Id == operationManager.admin_role).FirstOrDefault(); // if (operationManagerRole.SystemBarrage == false) // { // result.Code = ResultHelper.NotAuthorized; // result.StrCode = ResultHelper.NotAuthorizedMsg; // return result; // } //} switch (action.ToLower()) { case "add": { if (liveId <= 0 || string.IsNullOrEmpty(content) || endTime <= startTime) { result.Code = ResultHelper.ParamFail; result.StrCode = ResultHelper.ParamFailMsg; return(result); } break; } case "edit": { if (broadcastId <= 0 || string.IsNullOrEmpty(content) || endTime <= startTime) { result.Code = ResultHelper.ParamFail; result.StrCode = ResultHelper.ParamFailMsg; return(result); } break; } default: result.Code = ResultHelper.ParamFail; result.StrCode = ResultHelper.ParamFailMsg; return(result); } using (var db = new livecloudEntities()) { var manageLog = new dt_ManageLog() { ManagerId = managerId, ManagerName = db.dt_Manager.Find(managerId).user_name, ActionType = "setLiveBroadCast", AddTime = now, IP = NetworkTool.GetClientIP(HttpContext.Current) }; dt_AdminBroadcastLog broadcast = null; switch (action.ToLower()) { case "add": { broadcast = new dt_AdminBroadcastLog() { LiveId = liveId, ManagerId = managerId, SendTime = now, StartTime = startTime, EndTime = endTime, Status = (byte)1, BroadcastText = content }; db.dt_AdminBroadcastLog.Add(broadcast); manageLog.Remarks = "添加广播至直播:" + liveId + ", 内容:" + content; break; } case "edit": { broadcast = db.dt_AdminBroadcastLog.Find(broadcastId); if (broadcast == null) { result.Code = ResultHelper.ParamFail; result.StrCode = ResultHelper.ParamFailMsg + " ID:" + broadcastId + "的广播不存在"; return(result); } if (!string.IsNullOrEmpty(content)) { broadcast.BroadcastText = content; } broadcast.StartTime = startTime; broadcast.EndTime = endTime; manageLog.Remarks = "修改广播ID:" + broadcastId + ", 新内容:" + content; break; } } db.dt_ManageLog.Add(manageLog); var rowaffected = db.SaveChanges(); if (rowaffected > 0) { try { using (var client = new WebClient() { Encoding = Encoding.UTF8 }) { var broadcastModel = new { Target = "", GameID = liveId.ToString("0000"), Data = new { Type = "BroadCast", ID = broadcast.Id, Content = content, StartTime = startTime.ToString("yyyy-MM-dd HH:mm:ss"), EndTime = endTime.ToString("yyyy-MM-dd HH:mm:ss") } }; client.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded"; var data = "content=" + JsonConvert.SerializeObject(broadcastModel); var response = client.UploadString(Conf.WSUrl, "POST", data); var broadcastResult = JsonConvert.DeserializeObject <Result>(response.ToString()); if (broadcastResult.code == 1) { result.Code = ResultHelper.Success; result.StrCode = "發送成功"; } else { result.Code = -1; result.StrCode = "發送廣播時出錯"; } } } catch (Exception te) { result.Code = -1; result.StrCode = "發送廣播時出錯"; } } else { result.Code = ResultHelper.ParamFail; result.StrCode = "執行時出錯"; } } return(result); } catch (Exception ex) { Log.Error("setLiveBroadCast", "setLiveBroadCast", ex.Message.ToString()); result.Code = ResultHelper.ExecutingError; result.StrCode = ResultHelper.ExecutingErrorMsg; return(result); } }
public ResultInfoT <object> Post() { var result = new ResultInfoT <object>() { IsLogin = ResultHelper.IsLogin }; var request = HttpContext.Current.Request; var session = HttpContext.Current.Session; try { int managerId = (int)(session["ManagerId"] ?? -1); if (managerId < 0) { // 缺少Log紀錄 result.Code = ResultHelper.NotAuthorized; result.StrCode = ResultHelper.NotLoginMsg; result.IsLogin = ResultHelper.NotLogin; return(result); } var timeNow = DateTime.Now; var multiId = request.Form["ID"] ?? ""; if (string.IsNullOrEmpty(multiId) || !(new Regex(@"^(([\d]{1,}){1}|(([\d]{1,}\,){1,}([\d]{1,}){1}))$").IsMatch(multiId))) { result.Code = ResultHelper.ParamFail; result.StrCode = ResultHelper.ParamFailMsg; return(result); } var idList = multiId.Split(',').Select(o => Convert.ToInt32(o)).Distinct().OrderBy(o => o).ToList(); using (var db = new livecloudEntities()) { var manager = db.dt_Manager.Find(managerId); var UserBarrageNoSpeakList = db.dt_UserBarrageNoSpeak.Where(o => idList.Contains(o.id)).ToList(); foreach (var item in UserBarrageNoSpeakList) { var manageLog = new dt_ManageLog() { ManagerId = managerId, ManagerName = manager.user_name, ActionType = "delLiveNotSpeak", AddTime = timeNow, Remarks = "删除用戶禁言: " + item.identityid + "_" + item.UserName + "(ID:" + item.id + ")", IP = NetworkTool.GetClientIP(HttpContext.Current) }; db.dt_ManageLog.Add(manageLog); } db.dt_UserBarrageNoSpeak.RemoveRange(UserBarrageNoSpeakList); db.SaveChanges(); UpdateMsg.PostUpdate("dt_UserBarrageNoSpeak"); result.Code = ResultHelper.Success; result.StrCode = ResultHelper.SuccessMsg; } return(result); } catch (Exception ex) { Log.Error("DelManager", "DelManager", ex.Message.ToString()); result.Code = ResultHelper.ExecutingError; result.StrCode = ResultHelper.ExecutingErrorMsg; return(result); } }
public ResultInfoT <object> Post() { var result = new ResultInfoT <object>() { IsLogin = ResultHelper.IsLogin }; var request = HttpContext.Current.Request; var session = HttpContext.Current.Session; try { int managerId = (int)(session["ManagerId"] ?? -1); if (managerId < 0) { // 缺少Log紀錄 result.Code = ResultHelper.NotAuthorized; result.StrCode = ResultHelper.NotLoginMsg; result.IsLogin = ResultHelper.NotLogin; return(result); } var action = request.Form["Type"] ?? ""; int id = int.TryParse(request.Form["AnchorID"] ?? "-1", out id) ? id : -1; var name = request.Form["Name"] ?? ""; byte sex = byte.TryParse(request.Form["Sex"] ?? "", out sex) ? sex : (byte)255; byte age = byte.TryParse(request.Form["Age"] ?? "", out age) ? age : (byte)255; var city = request.Form["City"] ?? ""; int height = int.TryParse(request.Form["Height"] ?? "-1", out height) ? height : -1; int weight = int.TryParse(request.Form["Weight"] ?? "-1", out weight) ? weight : -1; var image = request.Form["Image"] ?? ""; var photo = request.Form["Photo"] ?? ""; var bwh = (request.Form["BWH"] ?? "").Replace(" ", ""); var now = DateTime.Now; ////驗證權限 //using (var db = new livecloudEntities()) //{ // var operationManager = db.dt_Manager.Find(managerId); // var operationManagerRole = Cache.Role.Where(o => o.Id == operationManager.admin_role).FirstOrDefault(); // if (operationManagerRole.DealerManage == false) // { // result.Code = ResultHelper.NotAuthorized; // result.StrCode = ResultHelper.NotAuthorizedMsg; // return result; // } //} switch (action.ToLower()) { case "add": { if (string.IsNullOrEmpty(name) || sex > 2 || age > 250 || string.IsNullOrEmpty(city) || height < 0 || weight < 0 || bwh.Split(',').Length != 3 || string.IsNullOrEmpty(image) || string.IsNullOrEmpty(photo)) { result.Code = ResultHelper.ParamFail; result.StrCode = ResultHelper.ParamFailMsg; return(result); } break; } case "edit": { if (id < 0 || (sex != (byte)255 && sex > 2) || (!string.IsNullOrEmpty(bwh) && bwh.Split(',').Length != 3)) { result.Code = ResultHelper.ParamFail; result.StrCode = ResultHelper.ParamFailMsg; return(result); } break; } default: result.Code = ResultHelper.ParamFail; result.StrCode = ResultHelper.ParamFailMsg; return(result); } var imgName = ""; var photoName = ""; if (image.Split(',').Length > 1) { var imgUploader = new ImageUploader(); image = HttpUtility.UrlDecode(image.Split(',')[1].Trim()).Replace(" ", "+"); string jsonString = imgUploader.SaveToImageServer(image, ImageUploader.AnchorImageBaseUri); imgName = JsonConvert.DeserializeObject <ImgServicesResponse>(jsonString).data.FirstOrDefault(); } if (photo.Split(',').Length > 1) { var imgUploader = new ImageUploader(); photo = HttpUtility.UrlDecode(photo.Split(',')[1].Trim()).Replace(" ", "+"); string jsonString = imgUploader.SaveToImageServer(photo, ImageUploader.AnchorImageBaseUri); photoName = JsonConvert.DeserializeObject <ImgServicesResponse>(jsonString).data.FirstOrDefault(); } using (var db = new livecloudEntities()) { var manageLog = new dt_ManageLog() { ManagerId = managerId, ManagerName = db.dt_Manager.Find(managerId).user_name, ActionType = "setAnchor", AddTime = now, IP = NetworkTool.GetClientIP(HttpContext.Current) }; var dupNameAnchor = action.ToLower() == "add" ? db.dt_dealer.Where(a => a.dealerName == name.Trim()).FirstOrDefault() : db.dt_dealer.Where(a => a.dealerName == name.Trim() & a.id != id).FirstOrDefault(); if (dupNameAnchor != null) { result.Code = ResultHelper.ParamFail; result.StrCode = "已存在相同名称的主播!"; return(result); } switch (action.ToLower()) { case "add": { //var dupNameAnchor = db.dt_dealer.Where(a=>a.dealerName == name.TrimEnd()).FirstOrDefault(); //if (dupNameAnchor != null) //{ // result.Code = ResultHelper.ParamFail; // result.StrCode = "已存在相同名称的主播!"; // return result; //} var anchor = new dt_dealer() { dealerName = name, sex = sex, age = age, area = city, height = height, weight = weight, bwh = bwh, add_time = now, update_time = now, img = imgName, img2 = photoName, imgStr = imgName, img2Str = photoName }; db.dt_dealer.Add(anchor); manageLog.Remarks = "添加主播信息:" + name; break; } case "edit": { var anchor = db.dt_dealer.Find(id); if (anchor == null) { result.Code = ResultHelper.ParamFail; result.StrCode = ResultHelper.ParamFailMsg + " ID:" + id + "的主播不存在"; return(result); } if (!string.IsNullOrEmpty(name)) { anchor.dealerName = name; } if (sex < (byte)255) { anchor.sex = sex; } if (age < (byte)255) { anchor.age = age; } if (!string.IsNullOrEmpty(city)) { anchor.area = city; } if (height >= 0m) { anchor.height = height; } if (weight >= 0m) { anchor.weight = weight; } if (!string.IsNullOrEmpty(bwh)) { anchor.bwh = bwh; } if (!string.IsNullOrEmpty(imgName)) { anchor.img = "Anchor/Image/" + imgName; anchor.imgStr = imgName; } if (!string.IsNullOrEmpty(photoName)) { anchor.img2 = "Anchor/Image/" + photoName; anchor.img2Str = photoName; } anchor.update_time = now; manageLog.Remarks = "修改主播信息:" + anchor.dealerName + "(ID:" + anchor.id + ")"; break; } } db.dt_ManageLog.Add(manageLog); db.SaveChanges(); } result.Code = ResultHelper.Success; result.StrCode = ResultHelper.SuccessMsg; return(result); } catch (Exception ex) { Log.Error("SetAnchor", "SetAnchor", ex.Message.ToString()); result.Code = ResultHelper.ExecutingError; result.StrCode = ResultHelper.ExecutingErrorMsg; return(result); } }
public ResultInfoT <object> Post() { var result = new ResultInfoT <object>() { IsLogin = ResultHelper.IsLogin }; var request = HttpContext.Current.Request; var session = HttpContext.Current.Session; try { int managerId = (int)(session["ManagerId"] ?? -1); if (managerId < 0) { // 缺少Log紀錄 result.Code = ResultHelper.NotAuthorized; result.StrCode = ResultHelper.NotLoginMsg; result.IsLogin = ResultHelper.NotLogin; return(result); } int id = int.TryParse(request.Form["ID"] ?? "", out id) ? id : -1; byte status = byte.TryParse(request.Form["Status"] ?? "", out status) ? status : (byte)255; var now = DateTime.Now; if (id <= 0 || status > (byte)1) { result.Code = ResultHelper.ParamFail; result.StrCode = ResultHelper.ParamFailMsg; return(result); } using (var db = new livecloudEntities()) { ////驗證權限 //var operationManager = db.dt_Manager.Find(managerId); //var operationManagerRole = Cache.Role.Where(o => o.Id == operationManager.admin_role).FirstOrDefault(); //if (operationManagerRole.DealerManage == false) //{ // result.Code = ResultHelper.NotAuthorized; // result.StrCode = ResultHelper.NotAuthorizedMsg; // return result; //} var manager = db.dt_Manager.Find(id); if (manager == null) { result.Code = ResultHelper.ParamFail; result.StrCode = "ID:" + id + "的管理员不存在!"; return(result); } manager.Status = status; var manageLog = new dt_ManageLog() { ManagerId = managerId, ManagerName = db.dt_Manager.Find(managerId).user_name, ActionType = "ManageisLock", AddTime = now, Remarks = ((status == (byte)0) ? "停用" : "启用") + "管理员:" + manager.user_name + "(ID:" + manager.id + ")", IP = NetworkTool.GetClientIP(HttpContext.Current) }; db.dt_ManageLog.Add(manageLog); db.SaveChanges(); result.Code = ResultHelper.Success; result.StrCode = ResultHelper.SuccessMsg; } return(result); } catch (Exception ex) { Log.Error("LockManager", "LockManager", ex.Message.ToString()); result.Code = ResultHelper.ExecutingError; result.StrCode = ResultHelper.ExecutingErrorMsg; return(result); } }
public ResultInfoT <object> Post() { var result = new ResultInfoT <object>() { IsLogin = ResultHelper.IsLogin }; var request = HttpContext.Current.Request; var session = HttpContext.Current.Session; var now = DateTime.Now; try { int managerId = (int)(session["ManagerId"] ?? -1); if (managerId < 0) { // 缺少Log紀錄 result.Code = ResultHelper.NotAuthorized; result.StrCode = ResultHelper.NotLoginMsg; result.IsLogin = ResultHelper.NotLogin; return(result); } int id = int.TryParse(request.Form["ID"] ?? "", out id) ? id : -1; if (id <= 0) { result.Code = ResultHelper.ParamFail; result.StrCode = ResultHelper.ParamFailMsg; return(result); } ////驗證權限 //using (var db = new livecloudEntities()) //{ // var operationManager = db.dt_Manager.Find(managerId); // var operationManagerRole = Cache.Role.Where(o => o.Id == operationManager.admin_role).FirstOrDefault(); // if (operationManagerRole.SystemBarrage == false) // { // result.Code = ResultHelper.NotAuthorized; // result.StrCode = ResultHelper.NotAuthorizedMsg; // return result; // } //} using (var db = new livecloudEntities()) { var sysBarrage = db.dt_SystemBarrage.Find(id); if (sysBarrage == null) { result.Code = ResultHelper.ParamFail; result.StrCode = "ID:" + id + "的系统弹幕不存在!"; return(result); } db.dt_SystemBarrage.Remove(sysBarrage); var manageLog = new dt_ManageLog() { ManagerId = managerId, ManagerName = db.dt_Manager.Find(managerId).user_name, ActionType = "delSystemBarrage", AddTime = now, Remarks = "删除系统弹幕ID:" + id, IP = NetworkTool.GetClientIP(HttpContext.Current) }; db.dt_ManageLog.Add(manageLog); db.SaveChanges(); result.Code = ResultHelper.Success; result.StrCode = ResultHelper.SuccessMsg; } return(result); } catch (Exception ex) { Log.Error("DelSentenceManage", "DelSentenceManage", ex.Message.ToString()); result.Code = ResultHelper.ExecutingError; result.StrCode = ResultHelper.ExecutingErrorMsg; return(result); } }
public ResultInfoT <object> Post() { var result = new ResultInfoT <object>() { IsLogin = ResultHelper.IsLogin }; var request = HttpContext.Current.Request; var session = HttpContext.Current.Session; try { int managerId = (int)(session["ManagerId"] ?? -1); if (managerId < 0) { // 缺少Log紀錄 result.Code = ResultHelper.NotAuthorized; result.StrCode = ResultHelper.NotLoginMsg; result.IsLogin = ResultHelper.NotLogin; return(result); } var action = request.Form["Type"] ?? ""; int id = int.TryParse(request.Form["Id"] ?? "-1", out id) ? id : -1; var ip = request.Form["Iplimit"] ?? ""; var remark = request.Form["Remark"] ?? ""; var now = DateTime.Now; ////驗證權限 using (var db = new livecloudEntities()) { var operationManager = db.dt_Manager.Find(managerId); var operationManagerRole = Cache.Role.Where(o => o.Id == operationManager.admin_role).FirstOrDefault(); if (operationManagerRole.AllowIp == false) { result.Code = ResultHelper.NotAuthorized; result.StrCode = ResultHelper.NotAuthorizedMsg; return(result); } } switch (action.ToLower()) { case "add": { if (string.IsNullOrEmpty(ip)) { result.Code = ResultHelper.ParamFail; result.StrCode = ResultHelper.ParamFailMsg; return(result); } break; } case "edit": { if (id < 0 || string.IsNullOrEmpty(ip)) { result.Code = ResultHelper.ParamFail; result.StrCode = ResultHelper.ParamFailMsg; return(result); } break; } default: result.Code = ResultHelper.ParamFail; result.StrCode = ResultHelper.ParamFailMsg; return(result); } using (var db = new livecloudEntities()) { var manageLog = new dt_ManageLog() { ManagerId = managerId, ManagerName = db.dt_Manager.Find(managerId).user_name, ActionType = "setAllowIp", AddTime = now, IP = NetworkTool.GetClientIP(HttpContext.Current) }; var dupIp = action.ToLower() == "add" ? db.dt_AllowAccessIPList.Where(a => a.Ip == ip.Trim()).FirstOrDefault() : db.dt_AllowAccessIPList.Where(a => a.Ip == ip.Trim() & a.Id != id).FirstOrDefault(); if (dupIp != null) { result.Code = ResultHelper.ParamFail; result.StrCode = "已存在相同名称的IP!"; return(result); } bool ipDicSingal = false; switch (action.ToLower()) { case "add": { var allowIp = new dt_AllowAccessIPList() { Ip = ip, Remark = remark, Enable = true, AddTime = now }; db.dt_AllowAccessIPList.Add(allowIp); manageLog.Remarks = "添加允許IP信息:" + ip; ipDicSingal = apiController.AddIpList(ip); break; } case "edit": { var allowIp = db.dt_AllowAccessIPList.Find(id); if (allowIp == null) { result.Code = ResultHelper.ParamFail; result.StrCode = ResultHelper.ParamFailMsg + " ID:" + id + "的IP不存在"; return(result); } ipDicSingal = apiController.EditIpList(allowIp.Ip, ip); if (!string.IsNullOrEmpty(ip)) { allowIp.Ip = ip; } if (!string.IsNullOrEmpty(remark)) { allowIp.Remark = remark; } allowIp.AddTime = now; manageLog.Remarks = "修改IP信息:" + allowIp.Ip + "(ID:" + allowIp.Id + ")"; break; } } db.dt_ManageLog.Add(manageLog); if (ipDicSingal) { db.SaveChanges(); } else { result.Code = ResultHelper.ExecutingError; result.StrCode = ResultHelper.ExecutingErrorMsg; return(result); } } result.Code = ResultHelper.Success; result.StrCode = ResultHelper.SuccessMsg; return(result); } catch (Exception ex) { Log.Error("SetAllowIp", "SetAllowIp", ex.Message.ToString()); result.Code = ResultHelper.ExecutingError; result.StrCode = ResultHelper.ExecutingErrorMsg; return(result); } }
public ResultInfoT <object> Post() { var result = new ResultInfoT <object>() { IsLogin = ResultHelper.IsLogin }; var request = HttpContext.Current.Request; var session = HttpContext.Current.Session; try { int managerId = (int)(session["ManagerId"] ?? -1); if (managerId < 0) { // 缺少Log紀錄 result.Code = ResultHelper.NotAuthorized; result.StrCode = ResultHelper.NotLoginMsg; result.IsLogin = ResultHelper.NotLogin; return(result); } int id = int.TryParse(request.Form["ID"] ?? "", out id) ? id : -1; var action = request.Form["Type"] ?? ""; var name = request.Form["Name"] ?? ""; var roleListJson = request.Form["RoleList"] ?? ""; var now = DateTime.Now; PermissionsList permissionsList = null; try { permissionsList = (string.IsNullOrEmpty(roleListJson)) ? null : JsonConvert.DeserializeObject <PermissionsList>(roleListJson); } catch (Exception jsonEx) { permissionsList = null; } switch (action.ToLower()) { case "add": { if (string.IsNullOrEmpty(name) || permissionsList == null) { result.Code = ResultHelper.ParamFail; result.StrCode = ResultHelper.ParamFailMsg; return(result); } break; } case "edit": { if (id <= 0) { result.Code = ResultHelper.ParamFail; result.StrCode = ResultHelper.ParamFailMsg; return(result); } break; } default: result.Code = ResultHelper.ParamFail; result.StrCode = ResultHelper.ParamFailMsg; return(result); } using (var db = new livecloudEntities()) { ////驗證權限(不確定是否為相應的欄位) //var operationManager = db.dt_Manager.Find(managerId); //var operationManagerRole = Cache.Role.Where(o => o.Id == operationManager.admin_role).FirstOrDefault(); //if (operationManagerRole.RoleManage == false) //{ // result.Code = ResultHelper.NotAuthorized; // result.StrCode = ResultHelper.NotAuthorizedMsg; // return result; //} var manageLog = new dt_ManageLog() { ManagerId = managerId, ManagerName = db.dt_Manager.Find(managerId).user_name, ActionType = "ManagerEdit", AddTime = now, IP = NetworkTool.GetClientIP(HttpContext.Current) }; if (!string.IsNullOrEmpty(name)) { var dupNameRole = action.ToLower() == "add" ? db.dt_ManagerRole.Where(a => a.RoleName == name.Trim()).FirstOrDefault() : db.dt_ManagerRole.Where(a => a.RoleName == name.Trim() & a.Id != id).FirstOrDefault(); if (dupNameRole != null) { result.Code = ResultHelper.ParamFail; result.StrCode = "已存在相同名称的角色!"; return(result); } } switch (action.ToLower()) { case "add": { var role = new dt_ManagerRole() { RoleName = name, LiveCmsManage = permissionsList.liveCmsManage.ToBoolByOnOffString(), DealerManage = permissionsList.AnchorManage.ToBoolByOnOffString(), DealerList = permissionsList.AnchorList.ToBoolByOnOffString(), DealerPost = permissionsList.AnchorPost.ToBoolByOnOffString(), DealerTime = permissionsList.AnchorTime.ToBoolByOnOffString(), LiveManage = permissionsList.liveManage.ToBoolByOnOffString(), VideoList = permissionsList.videoList.ToBoolByOnOffString(), BarrageManage = permissionsList.barrageManage.ToBoolByOnOffString(), SystemBarrage = permissionsList.systemBarrage.ToBoolByOnOffString(), WordsManage = permissionsList.wordsManage.ToBoolByOnOffString(), ManualReview = permissionsList.manualReview.ToBoolByOnOffString(), GiftManage = permissionsList.giftManage.ToBoolByOnOffString(), GiftList = permissionsList.giftList.ToBoolByOnOffString(), DealerTable = permissionsList.AnchorTable.ToBoolByOnOffString(), Manager = permissionsList.Manager.ToBoolByOnOffString(), ManagerList = permissionsList.managerList.ToBoolByOnOffString(), RoleManage = permissionsList.roleManage.ToBoolByOnOffString(), ManageLog = permissionsList.manageLog.ToBoolByOnOffString(), ShieldedRecord = permissionsList.shieldedRecord.ToBoolByOnOffString(), LiveNotSpeak = permissionsList.liveNotSpeak.ToBoolByOnOffString(), BlackWordManage = permissionsList.blackWordManage.ToBoolByOnOffString(), RealTimeBarrage = permissionsList.realTimeBarrage.ToBoolByOnOffString(), AllowIp = permissionsList.AllowIp.ToBoolByOnOffString(), AddTime = now }; db.dt_ManagerRole.Add(role); manageLog.Remarks = "添加角色:" + name; break; } case "edit": { var role = db.dt_ManagerRole.Find(id); if (role == null) { result.Code = ResultHelper.ParamFail; result.StrCode = "ID:" + id + "的角色不存在!"; return(result); } if (!string.IsNullOrEmpty(name)) { role.RoleName = name; } if (permissionsList != null) { if (!string.IsNullOrEmpty(permissionsList.liveCmsManage)) { role.LiveCmsManage = permissionsList.liveCmsManage.ToBoolByOnOffString(); } if (!string.IsNullOrEmpty(permissionsList.AnchorManage)) { role.DealerManage = permissionsList.AnchorManage.ToBoolByOnOffString(); } if (!string.IsNullOrEmpty(permissionsList.AnchorList)) { role.DealerList = permissionsList.AnchorList.ToBoolByOnOffString(); } if (!string.IsNullOrEmpty(permissionsList.AnchorPost)) { role.DealerPost = permissionsList.AnchorPost.ToBoolByOnOffString(); } if (!string.IsNullOrEmpty(permissionsList.AnchorTime)) { role.DealerTime = permissionsList.AnchorTime.ToBoolByOnOffString(); } if (!string.IsNullOrEmpty(permissionsList.liveManage)) { role.LiveManage = permissionsList.liveManage.ToBoolByOnOffString(); } if (!string.IsNullOrEmpty(permissionsList.videoList)) { role.VideoList = permissionsList.videoList.ToBoolByOnOffString(); } if (!string.IsNullOrEmpty(permissionsList.barrageManage)) { role.BarrageManage = permissionsList.barrageManage.ToBoolByOnOffString(); } if (!string.IsNullOrEmpty(permissionsList.systemBarrage)) { role.SystemBarrage = permissionsList.systemBarrage.ToBoolByOnOffString(); } if (!string.IsNullOrEmpty(permissionsList.sentenceManage)) { role.SentenceManage = permissionsList.sentenceManage.ToBoolByOnOffString(); } if (!string.IsNullOrEmpty(permissionsList.wordsManage)) { role.WordsManage = permissionsList.wordsManage.ToBoolByOnOffString(); } if (!string.IsNullOrEmpty(permissionsList.manualReview)) { role.ManualReview = permissionsList.manualReview.ToBoolByOnOffString(); } if (!string.IsNullOrEmpty(permissionsList.giftManage)) { role.GiftManage = permissionsList.giftManage.ToBoolByOnOffString(); } if (!string.IsNullOrEmpty(permissionsList.giftList)) { role.GiftList = permissionsList.giftList.ToBoolByOnOffString(); } if (!string.IsNullOrEmpty(permissionsList.AnchorTable)) { role.DealerTable = permissionsList.AnchorTable.ToBoolByOnOffString(); } if (!string.IsNullOrEmpty(permissionsList.Manager)) { role.Manager = permissionsList.Manager.ToBoolByOnOffString(); } if (!string.IsNullOrEmpty(permissionsList.managerList)) { role.ManagerList = permissionsList.managerList.ToBoolByOnOffString(); } if (!string.IsNullOrEmpty(permissionsList.roleManage)) { role.RoleManage = permissionsList.roleManage.ToBoolByOnOffString(); } if (!string.IsNullOrEmpty(permissionsList.manageLog)) { role.ManageLog = permissionsList.manageLog.ToBoolByOnOffString(); } if (!string.IsNullOrEmpty(permissionsList.shieldedRecord)) { role.ShieldedRecord = permissionsList.shieldedRecord.ToBoolByOnOffString(); } if (!string.IsNullOrEmpty(permissionsList.liveNotSpeak)) { role.LiveNotSpeak = permissionsList.liveNotSpeak.ToBoolByOnOffString(); } if (!string.IsNullOrEmpty(permissionsList.blackWordManage)) { role.BlackWordManage = permissionsList.blackWordManage.ToBoolByOnOffString(); } if (!string.IsNullOrEmpty(permissionsList.realTimeBarrage)) { role.RealTimeBarrage = permissionsList.realTimeBarrage.ToBoolByOnOffString(); } if (!string.IsNullOrEmpty(permissionsList.AllowIp)) { role.AllowIp = permissionsList.AllowIp.ToBoolByOnOffString(); } } manageLog.Remarks = "修改角色:" + name; break; } } db.dt_ManageLog.Add(manageLog); db.SaveChanges(); result.Code = ResultHelper.Success; result.StrCode = ResultHelper.SuccessMsg; } return(result); } catch (Exception ex) { Log.Error("SetRole", "SetRole", ex.Message.ToString()); result.Code = ResultHelper.ExecutingError; result.StrCode = ResultHelper.ExecutingErrorMsg; return(result); } }
public ResultInfoT <object> Post() { var result = new ResultInfoT <object>() { IsLogin = ResultHelper.IsLogin }; var request = HttpContext.Current.Request; var session = HttpContext.Current.Session; try { int managerId = (int)(session["ManagerId"] ?? -1); if (managerId < 0) { // 缺少Log紀錄 result.Code = ResultHelper.NotAuthorized; result.StrCode = ResultHelper.NotLoginMsg; result.IsLogin = ResultHelper.NotLogin; return(result); } int id = (int.TryParse(request.Form["BroadCastID"] ?? "", out id)) ? id : -1; var now = DateTime.Now; if (id <= 0) { result.Code = ResultHelper.ParamFail; result.StrCode = ResultHelper.ParamFailMsg; return(result); } using (var db = new livecloudEntities()) { //驗證權限 var operationManager = db.dt_Manager.Find(managerId); var operationManagerRole = Cache.Role.Where(o => o.Id == operationManager.admin_role).FirstOrDefault(); if (operationManagerRole.BarrageManage == false) { result.Code = ResultHelper.NotAuthorized; result.StrCode = ResultHelper.NotAuthorizedMsg; return(result); } var broadcast = db.dt_AdminBroadcastLog.Find(id); if (broadcast == null) { result.Code = ResultHelper.ParamFail; result.StrCode = ResultHelper.ParamFailMsg + " ID:" + id + "的广播不存在"; return(result); } broadcast.Status = 0; broadcast.EndTime = now; var manageLog = new dt_ManageLog() { ManagerId = managerId, ManagerName = db.dt_Manager.Find(managerId).user_name, ActionType = "RevokeLiveBroadCast", AddTime = now, Remarks = "撤消广播ID:" + id, IP = NetworkTool.GetClientIP(HttpContext.Current) }; db.dt_ManageLog.Add(manageLog); db.SaveChanges(); using (var client = new WebClient() { Encoding = Encoding.UTF8 }) { var broadcastModel = new { Target = "", GameID = broadcast.LiveId.ToString("0000"), Data = new { Type = "BroadCast", ID = broadcast.Id, Content = broadcast.BroadcastText, StartTime = broadcast.StartTime.ToString("yyyy-MM-dd HH:mm:ss"), EndTime = broadcast.EndTime.ToString("yyyy-MM-dd HH:mm:ss") } }; client.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded"; var data = "content=" + JsonConvert.SerializeObject(broadcastModel); var response = client.UploadString(Conf.WSUrl, "POST", data); var broadcastResult = JsonConvert.DeserializeObject <Result>(response.ToString()); if (broadcastResult.code == 1) { result.Code = ResultHelper.Success; result.StrCode = "發送成功"; } else { result.Code = -1; result.StrCode = "發送廣播時出錯"; } } result.Code = ResultHelper.Success; result.StrCode = ResultHelper.SuccessMsg; } return(result); } catch (Exception ex) { Log.Error("RevokeLiveBroadCast", "RevokeLiveBroadCast", ex.Message.ToString()); result.Code = ResultHelper.ExecutingError; result.StrCode = ResultHelper.ExecutingErrorMsg; return(result); } }
public ResultInfoT <object> Post() { var result = new ResultInfoT <object>() { IsLogin = ResultHelper.IsLogin }; var request = HttpContext.Current.Request; var session = HttpContext.Current.Session; var now = DateTime.Now; try { int managerId = (int)(session["ManagerId"] ?? -1); if (managerId < 0) { // 缺少Log紀錄 result.Code = ResultHelper.NotAuthorized; result.StrCode = ResultHelper.NotLoginMsg; result.IsLogin = ResultHelper.NotLogin; return(result); } string ids = request.Form["ID"] ?? ""; if (string.IsNullOrEmpty(ids) || !regex.IsMatch(ids)) { result.Code = ResultHelper.ParamFail; result.StrCode = ResultHelper.ParamFailMsg; return(result); } ////驗證權限 //using (var db = new livecloudEntities()) //{ // var operationManager = db.dt_Manager.Find(managerId); // var operationManagerRole = Cache.Role.Where(o => o.Id == operationManager.admin_role).FirstOrDefault(); // if (operationManagerRole.WordsManage == false) // { // result.Code = ResultHelper.NotAuthorized; // result.StrCode = ResultHelper.NotAuthorizedMsg; // return result; // } //} using (var db = new livecloudEntities()) { var idList = ids.Split(',').Select(i => int.Parse(i)).ToList(); var query = from w in db.dt_SensitiveWords where idList.Contains(w.id) select w; var removeList = db.dt_SensitiveWords.RemoveRange(query); var manageLog = new dt_ManageLog() { ManagerId = managerId, ManagerName = db.dt_Manager.Find(managerId).user_name, ActionType = "delWordsManage", AddTime = now, Remarks = "删除禁用敏感字词ID:" + ids, IP = NetworkTool.GetClientIP(HttpContext.Current) }; db.dt_ManageLog.Add(manageLog); db.SaveChanges(); UpdateMsg.PostUpdate("dt_SensitiveWords"); } result.Code = ResultHelper.Success; result.StrCode = ResultHelper.SuccessMsg; return(result); } catch (Exception ex) { Log.Error("DelWordsManage", "DelWordsManage", ex.Message.ToString()); result.Code = ResultHelper.ExecutingError; result.StrCode = ResultHelper.ExecutingErrorMsg; return(result); } }
public ResultInfoT <object> Post() { var result = new ResultInfoT <object>() { IsLogin = ResultHelper.IsLogin }; var request = HttpContext.Current.Request; var session = HttpContext.Current.Session; try { int managerId = (int)(session["ManagerId"] ?? -1); if (managerId < 0) { // 缺少Log紀錄 result.Code = ResultHelper.NotAuthorized; result.StrCode = ResultHelper.NotLoginMsg; result.IsLogin = ResultHelper.NotLogin; return(result); } var now = DateTime.Now; var liveId = request.Form["GameID"] ?? ""; var action = request.Form["Type"] ?? ""; var time = request.Form["Time"] ?? ""; var closeTitle = request.Form["CloseTitle"] ?? "暂停播放"; var closeContent = request.Form["CloseContent"] ?? "UU直播关闭中..."; DateTime nextStartTime; if (string.IsNullOrEmpty(liveId) || (action.ToLower() != "true" && action.ToLower() != "false") || (!string.IsNullOrEmpty(time) && !DateTime.TryParse(time, out nextStartTime))) { result.Code = ResultHelper.ParamFail; result.StrCode = ResultHelper.ParamFailMsg; return(result); } using (var db = new livecloudEntities()) { ////驗證權限 //var operationManager = db.dt_Manager.Find(managerId); //var operationManagerRole = Cache.Role.Where(o => o.Id == operationManager.admin_role).FirstOrDefault(); //if (operationManagerRole.LiveManage == false) //{ // result.Code = ResultHelper.NotAuthorized; // result.StrCode = ResultHelper.NotAuthorizedMsg; // return result; //} var live = db.dt_liveList.Where(l => l.liveId == liveId).FirstOrDefault(); if (live == null) { result.Code = ResultHelper.ParamFail; result.StrCode = ResultHelper.ParamFailMsg; return(result); } //開放後先不更新state等global時間到處理state live.state = (byte)0; live.update_time = now; live.CloseContent = (action.ToLower() == "true") ? "" : closeContent; live.CloseTitle = (action.ToLower() == "true") ? "" : closeTitle; if (!string.IsNullOrEmpty(time)) { live.stop_time = time; } else { //開放且不帶時間直接開啟 live.state = (action.ToLower() == "true") ? (byte)1 : (byte)0; } var manageLog = new dt_ManageLog() { ManagerId = managerId, ManagerName = db.dt_Manager.Find(managerId).user_name, ActionType = "setLiveSwitch", AddTime = now, IP = NetworkTool.GetClientIP(HttpContext.Current) }; manageLog.Remarks = "设置直播ID:+" + liveId + "状态为:" + ((action == "true") ? "启用" : "停用"); db.dt_ManageLog.Add(manageLog); db.SaveChanges(); result.Code = ResultHelper.Success; result.StrCode = ResultHelper.SuccessMsg; if (action.ToLower() == "false") { try { using (var client = new WebClient() { Encoding = Encoding.UTF8 }) { var broadcastModel = new { Target = "", GameID = liveId, Data = new { Type = "LiveType", CloseTitle = closeTitle ?? "暂停播放", CloseContent = closeContent ?? "UU直播关闭中..." } }; client.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded"; var data = "content=" + JsonConvert.SerializeObject(broadcastModel); var response = client.UploadString(Conf.WSUrl, "POST", data); var broadcastResult = JsonConvert.DeserializeObject <Result>(response.ToString()); if (broadcastResult.code == 1) { result.Code = ResultHelper.Success; result.StrCode = ResultHelper.SuccessMsg; } else { result.Code = -2; result.StrCode = "数据已储存, 发送广播时出错"; } } } catch (Exception te) { result.Code = -2; result.StrCode = "数据已储存, 发送广播时出错"; } } } return(result); } catch (Exception ex) { Log.Error("SetLiveSwitch", "SetLiveSwitch", ex.Message.ToString()); result.Code = ResultHelper.ExecutingError; result.StrCode = ResultHelper.ExecutingErrorMsg; return(result); } }
public ResultInfoT <object> Post() { var result = new ResultInfoT <object>() { IsLogin = ResultHelper.IsLogin }; var request = HttpContext.Current.Request; var session = HttpContext.Current.Session; try { int managerId = (int)(session["ManagerId"] ?? -1); if (managerId < 0) { // 缺少Log紀錄 result.Code = ResultHelper.NotAuthorized; result.StrCode = ResultHelper.NotLoginMsg; result.IsLogin = ResultHelper.NotLogin; return(result); } int id = int.TryParse(request.Form["ID"] ?? "-1", out id) ? id : -1; var userName = request.Form["UserName"] ?? ""; var password = request.Form["Password"] ?? ""; var realName = request.Form["RealName"] ?? ""; var adminRole = request.Form["AdminRole"] ?? ""; var action = request.Form["Type"] ?? ""; var now = DateTime.Now; ////驗證權限 //using (var db = new livecloudEntities()) //{ // var operationManager = db.dt_Manager.Find(managerId); // var operationManagerRole = Cache.Role.Where(o => o.Id == operationManager.admin_role).FirstOrDefault(); // if (operationManagerRole.Manager == false) // { // result.Code = ResultHelper.NotAuthorized; // result.StrCode = ResultHelper.NotAuthorizedMsg; // return result; // } //} switch (action.ToLower()) { case "add": { if (string.IsNullOrEmpty(userName) || string.IsNullOrEmpty(password) || string.IsNullOrEmpty(adminRole)) { result.Code = ResultHelper.ParamFail; result.StrCode = ResultHelper.ParamFailMsg; return(result); } break; } case "edit": { if (id <= 0) { result.Code = ResultHelper.ParamFail; result.StrCode = ResultHelper.ParamFailMsg; return(result); } //if (!string.IsNullOrEmpty(userName)) //{ // result.Code = ResultHelper.ParamFail; // result.StrCode = "不允许修改管理员帐户名称!"; // return result; //} break; } default: result.Code = ResultHelper.ParamFail; result.StrCode = ResultHelper.ParamFailMsg; return(result); } using (var db = new livecloudEntities()) { var manageLog = new dt_ManageLog() { ManagerId = managerId, ManagerName = db.dt_Manager.Find(managerId).user_name, ActionType = "ManagerEdit", AddTime = now, IP = NetworkTool.GetClientIP(HttpContext.Current) }; dt_ManagerRole role = null; if (!string.IsNullOrEmpty(adminRole)) { int roleId = int.TryParse(adminRole, out roleId) ? roleId : -1; role = (roleId > 0) ? db.dt_ManagerRole.Find(roleId) : db.dt_ManagerRole.Where(r => r.RoleName == adminRole).FirstOrDefault(); if (role == null) { result.Code = ResultHelper.ParamFail; result.StrCode = "找不到管理员角色ID:" + roleId + "的数据!"; return(result); } } switch (action.ToLower()) { case "add": { var dupNameManager = db.dt_Manager.Where(a => a.user_name == userName).FirstOrDefault(); if (dupNameManager != null) { result.Code = ResultHelper.ParamFail; result.StrCode = "已存在相同名称的管理员!"; return(result); } var manager = new dt_Manager() { user_name = userName, real_name = realName, password = password, admin_role = role.Id, add_time = now, Status = 1 }; db.dt_Manager.Add(manager); manageLog.Remarks = "新增管理员帐户:" + userName; break; } case "edit": { var manager = db.dt_Manager.Find(id); if (manager == null) { result.Code = ResultHelper.ParamFail; result.StrCode = "ID:" + id + "的管理员不存在!"; return(result); } if (!string.IsNullOrEmpty(realName)) { manager.real_name = realName; } if (!string.IsNullOrEmpty(password)) { manager.password = password; } if (role != null) { manager.admin_role = role.Id; } manageLog.Remarks = "修改管理员信息:" + manager.user_name + "(ID:" + manager.id + ")"; break; } } db.dt_ManageLog.Add(manageLog); db.SaveChanges(); } result.Code = ResultHelper.Success; result.StrCode = ResultHelper.SuccessMsg; return(result); } catch (Exception ex) { Log.Error("ManagerEdit", "ManagerEdit", ex.Message.ToString()); result.Code = ResultHelper.ExecutingError; result.StrCode = ResultHelper.ExecutingErrorMsg; return(result); } }
public ResultInfoT <object> Post() { var result = new ResultInfoT <object>() { IsLogin = ResultHelper.IsLogin }; var request = HttpContext.Current.Request; var session = HttpContext.Current.Session; try { int managerId = (int)(session["ManagerId"] ?? -1); if (managerId < 0) { // 缺少Log紀錄 result.Code = ResultHelper.NotAuthorized; result.StrCode = ResultHelper.NotLoginMsg; result.IsLogin = ResultHelper.NotLogin; return(result); } // 前端送入 string userName = request.Form["UserName"] ?? ""; string identityid = request.Form["IdentityId"] ?? ""; int duration = int.TryParse(request.Form["Duration"] ?? "0", out duration) ? duration : 0; string remark = request.Form["Remark"] ?? ""; int type = int.TryParse(request.Form["State"] ?? "0", out type) ? type : 0; // 自定義參數 string userNickName = ""; using (var db = new livecloudEntities()) { var query = from p in db.dt_UserBarrageNoSpeak where p.UserName == userName && p.Type == type select p; if (query.ToList().Count > 0 && CheckNoSpeak(query)) { result.Code = ResultHelper.ParamFail; result.StrCode = "此用户已存在"; return(result); } dt_UserBarrageNoSpeak UserBarrageNoSpeak = new dt_UserBarrageNoSpeak() { identityid = identityid, UserName = userName, UserNickName = string.IsNullOrEmpty(userNickName) ? "" : userNickName, Remark = remark, Type = type, Duration = duration, AddTime = DateTime.Now, OperateUser = db.dt_Manager.Find(managerId).user_name }; db.dt_UserBarrageNoSpeak.Add(UserBarrageNoSpeak); db.SaveChanges(); UpdateMsg.PostUpdate("dt_UserBarrageNoSpeak"); } result.Code = ResultHelper.Success; result.StrCode = ResultHelper.SuccessMsg; return(result); } catch (Exception ex) { Log.Error("SetAnchor", "SetAnchor", ex.Message.ToString()); result.Code = ResultHelper.ExecutingError; result.StrCode = ResultHelper.ExecutingErrorMsg; return(result); } }
private static void InitSystemBarrageStatistics() { if (!SystemBarrageStatisticsInitOK) { try { DateTime weekDate = DateTime.Now.AddDays(-7); using (var db = new livecloudEntities()) { db.Database.ExecuteSqlCommand("update dt_SystemBarrageLog set signal = 2 where add_time < @addTime and signal < 2", new SqlParameter[] { new SqlParameter("@addTime", weekDate) }); if (db.ChangeTracker.HasChanges()) { db.SaveChanges(); } db.Database.ExecuteSqlCommand("update dt_SystemBarrageLog set signal = 1 where add_time >= @addTime", new SqlParameter[] { new SqlParameter("@addTime", weekDate) }); if (db.ChangeTracker.HasChanges()) { db.SaveChanges(); } } using (var db = new livecloudEntities()) { var query = from o in db.dt_SystemBarrageLog where o.add_time > weekDate && o.signal == 1 group o by o.barrageId into g select new { barrageId = g.Key, count = g.Count() }; var sysbarrageStatisticsList = query.ToList(); foreach (var barrageStatis in sysbarrageStatisticsList) { var sysbarrage = db.dt_SystemBarrage.Find(barrageStatis.barrageId); if (sysbarrage != null) { sysbarrage.times = barrageStatis.count; } } if (db.ChangeTracker.HasChanges()) { db.SaveChanges(); } } } catch (Exception ex) { Log.Error("global", "UpdateSystemBarrageStatistics", ex.ToString()); } finally { SystemBarrageStatisticsInitOK = true; } } }
public ResultInfoT <object> Post() { var result = new ResultInfoT <object>() { IsLogin = ResultHelper.IsLogin }; var request = HttpContext.Current.Request; var session = HttpContext.Current.Session; try { int managerId = (int)(session["ManagerId"] ?? -1); if (managerId < 0) { // 缺少Log紀錄 result.Code = ResultHelper.NotAuthorized; result.StrCode = ResultHelper.NotLoginMsg; result.IsLogin = ResultHelper.NotLogin; return(result); } int id = int.TryParse(request.Form["ID"], out id) ? id : -1; var doLock = request.Form["State"] ?? ""; if (id <= 0 || (doLock.ToLower() != "true" && doLock.ToLower() != "false")) { result.Code = ResultHelper.ParamFail; result.StrCode = ResultHelper.ParamFailMsg; return(result); } using (var db = new livecloudEntities()) { //驗證權限 //var operationManager = db.dt_Manager.Find(managerId); //var operationManagerRole = Cache.Role.Where(o => o.Id == operationManager.admin_role).FirstOrDefault(); //if (operationManagerRole.DealerManage == false) //{ // result.Code = ResultHelper.NotAuthorized; // result.StrCode = ResultHelper.NotAuthorizedMsg; // return result; //} var sysBarrage = db.dt_SystemBarrage.Find(id); if (sysBarrage == null) { result.Code = ResultHelper.ParamFail; result.StrCode = "ID:" + id + "的系统弹幕不存在!"; return(result); } sysBarrage.state = (doLock.ToLower() == "true") ? (byte)1 : (byte)0; var manageLog = new dt_ManageLog() { ManagerId = managerId, ManagerName = db.dt_Manager.Find(managerId).user_name, ActionType = "setSystemBarrage", AddTime = DateTime.Now, Remarks = (doLock.ToLower() == "true") ? "启用" : "停用" + "系统弹幕ID:" + id, IP = NetworkTool.GetClientIP(HttpContext.Current) }; db.dt_ManageLog.Add(manageLog); db.SaveChanges(); result.Code = ResultHelper.Success; result.StrCode = ResultHelper.SuccessMsg; } return(result); } catch (Exception ex) { Log.Error("LockSystemBarrage", "LockSystemBarrage", ex.Message.ToString()); result.Code = ResultHelper.ExecutingError; result.StrCode = ResultHelper.ExecutingErrorMsg; return(result); } }