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); } }
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); } 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["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); } 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; 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); } 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 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); } 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); } 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.NotLogin }; var request = HttpContext.Current.Request; var session = HttpContext.Current.Session; try { var pwd = request.Form["Password"] ?? ""; var userName = request.Form["Username"] ?? ""; //缺少正則檢查 if (string.IsNullOrEmpty(userName) || string.IsNullOrEmpty(pwd)) { result.Code = ResultHelper.ParamFail; result.StrCode = ResultHelper.ParamFailMsg; return(result); } //缺少已登入檢查 using (livecloudEntities db = new Models.livecloudEntities()) { var manager = db.dt_Manager .Where(m => m.user_name == userName && m.password == pwd) .FirstOrDefault(); //缺少檢查管理員帳號是否已停用 if (manager == null) // || manager.Status != 1) { result.Code = ResultHelper.ParamFail; result.StrCode = "帐户或密码错误"; return(result); } if (manager.Status == (byte)0) { result.Code = ResultHelper.ParamFail; result.StrCode = "帐户已被停用"; return(result); } var role = db.dt_ManagerRole .Where(r => r.Id == manager.admin_role) .FirstOrDefault(); if (role == null) { throw new Exception("找不到 管理員ID:" + manager.id + " 對應的角色權限ID:" + manager.admin_role + " 的訊息"); } var manageLog = new dt_ManageLog() { ManagerId = manager.id, ManagerName = manager.user_name, ActionType = "Login", AddTime = DateTime.Now, Remarks = "登入成功", IP = NetworkTool.GetClientIP(HttpContext.Current) }; db.dt_ManageLog.Add(manageLog); db.SaveChanges(); session["ManagerId"] = manager.id; session["ManagerName"] = manager.user_name; session["RoleId"] = manager.admin_role; result.Code = ResultHelper.Success; result.StrCode = "登录成功"; result.IsLogin = ResultHelper.IsLogin; result.BackData = new GetRoleInfoBodyData() { barrageManage = role.BarrageManage.ToOnOff(), AnchorList = role.DealerList.ToOnOff(), AnchorManage = role.DealerManage.ToOnOff(), AnchorPost = role.DealerPost.ToOnOff(), AnchorTable = role.DealerTable.ToOnOff(), AnchorTime = role.DealerTime.ToOnOff(), giftList = role.GiftList.ToOnOff(), giftManage = role.GiftManage.ToOnOff(), livecmsManage = role.LiveCmsManage.ToOnOff(), liveManage = role.LiveManage.ToOnOff(), manageLog = role.ManageLog.ToOnOff(), Manager = role.Manager.ToOnOff(), managerList = role.ManagerList.ToOnOff(), manualReview = role.ManualReview.ToOnOff(), roleManage = role.RoleManage.ToOnOff(), systemBarrage = role.SystemBarrage.ToOnOff(), videoList = role.VideoList.ToOnOff(), wordsManage = role.WordsManage.ToOnOff(), sentenceManage = role.SentenceManage.ToOnOff(), shieldedRecord = role.ShieldedRecord.ToOnOff(), liveNotSpeak = role.LiveNotSpeak.ToOnOff(), blackWordManage = role.BlackWordManage.ToOnOff(), realTimeBarrage = role.RealTimeBarrage.ToOnOff() }; } return(result); } catch (Exception ex) { Log.Error("Login", "Login", ex.Message.ToString()); result.Code = ResultHelper.ExecutingError; result.StrCode = ResultHelper.ExecutingErrorMsg; result.IsLogin = ResultHelper.NotLogin; 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; 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); } }