예제 #1
0
        private string GetBlockWords(livecloudEntities db, string fullContent)
        {
            var sWords = db.dt_SensitiveWords
                         .Where(o => fullContent.Contains(o.content) && o.state == 0)
                         .FirstOrDefault();

            if (sWords != null)
            {
                return(sWords.content);
            }

            var black = db.dt_SensitiveSentences
                        .Where(o => fullContent == o.content && o.state == 0)
                        .FirstOrDefault();

            if (black != null)
            {
                return(black.content);
            }

            sWords = db.dt_SensitiveWords
                     .Where(o => fullContent.Contains(o.content) && o.state == 1)
                     .FirstOrDefault();

            if (sWords != null)
            {
                return(sWords.content);
            }

            return("");
        }
예제 #2
0
        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);
            }
        }
예제 #3
0
        /// <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);
                }

                using (var db = new livecloudEntities())
                {
                    var roleList = db.dt_ManagerRole.ToList();

                    var totalCount = roleList.Count;

                    result.BackData = roleList.OrderBy(r => r.Id).Select(r => new
                    {
                        ID   = r.Id,
                        Name = r.RoleName,
                        Time = r.AddTime.ToString("yyyy-MM-dd HH:mm:ss")
                    }).ToList();

                    result.Code    = ResultHelper.Success;
                    result.StrCode = ResultHelper.SuccessMsg;
                }

                return(result);
            }
            catch (Exception ex)
            {
                Log.Error("GetRoleList", "GetRoleList", ex.Message.ToString());
                result.Code    = ResultHelper.ExecutingError;
                result.StrCode = ResultHelper.ExecutingErrorMsg;
                return(result);
            }
        }
예제 #5
0
        protected void Application_Start()
        {
            GlobalConfiguration.Configure(WebApiConfig.Register);

            using (var db = new livecloudEntities())
            {
                // var SSS = (from dd in db.dt_liveList select dd);
                StaticTables.sdt_SensitiveSentences = (from p in db.dt_SensitiveSentences select p).ToList();
                StaticTables.sdt_SensitiveWords     = (from p in db.dt_SensitiveWords select p).ToList();
                StaticTables.sdt_UserBarrageNoSpeak = (from p in db.dt_UserBarrageNoSpeak select p).ToList();
                StaticTables.sdt_BlackWords         = (from p in db.dt_BlackWords select p).ToList();
            }

            ProcessBlockLogEmptyData();
        }
예제 #6
0
 /// <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();
             }
         }
     }
 }
예제 #7
0
        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();
                }
            }
        }
예제 #8
0
        public IHttpActionResult Post()
        {
            var request = HttpContext.Current.Request;

            try
            {
                var liveId = request.Form["LiveId"] ?? "";

                if (string.IsNullOrEmpty(liveId))
                {
                    return(BadRequest());
                }

                using (var db = new livecloudEntities())
                {
                    var live = db.dt_liveList.Where(s => s.liveId == liveId).FirstOrDefault();

                    if (live == null)
                    {
                        return(BadRequest());
                    }

                    var status = new LiveStatusModel();

                    status.LiveId       = liveId;
                    status.Status       = live.state;
                    status.CloseContent = (live.state == (byte)1) ? "" : live.CloseContent;
                    status.CloseTitle   = (live.state == (byte)1) ? "" : live.CloseTitle;

                    return(Ok(status));
                }
            }
            catch (Exception e)
            {
                Log.Error("LiveStatus", "LiveStatus 出錯", e.Message);
                //return BadRequest("LIVE_" + e.Message);
                return(InternalServerError());
            }
        }
        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 liveId    = request.Form["GameID"] ?? "";
                int pageIndex = int.TryParse(request.Form["PageIndex"] ?? "", out pageIndex) ? pageIndex : 0;
                int pageSize  = int.TryParse(request.Form["PageSize"] ?? "", out pageSize) ? pageSize : 20;
                var now       = DateTime.Now;


                if (pageIndex < 0 || pageSize <= 0)
                {
                    result.Code    = ResultHelper.ParamFail;
                    result.StrCode = ResultHelper.ParamFailMsg;
                    return(result);
                }

                // 可以考慮做快取
                using (var db = new livecloudEntities())
                {
                    var query = from b in db.dt_AdminBroadcastLog
                                select b;

                    int intLiveId = int.TryParse(liveId, out intLiveId) ? intLiveId : -1;

                    if (!string.IsNullOrEmpty(liveId))
                    {
                        query = query.Where(b => b.LiveId == intLiveId);
                    }

                    int totalCount = query.Count();

                    var list = query
                               .OrderByDescending(b => b.SendTime)
                               .Skip(pageIndex * pageSize)
                               .Take(pageSize)
                               .ToList();

                    var managerList = db.dt_Manager.ToList();

                    result.DataCount = totalCount;

                    // 要確認TrimEnd等等的動作必要性
                    result.BackData = list.Select(b => new
                    {
                        BroadCastID = b.Id,
                        GameID      = b.LiveId.ToString("0000"),
                        StartTime   = b.StartTime.ToString("yyyy-MM-dd HH:mm:ss"),
                        EndTime     = b.EndTime.ToString("yyyy-MM-dd HH:mm:ss"),
                        Content     = b.BroadcastText,
                        Staff       = managerList.Where(m => m.id == b.ManagerId).FirstOrDefault().user_name,
                        State       = (b.Status == 0) ? 0 :
                                      (b.StartTime <now && b.EndTime> now) ? 1 :
                                      2
                    }).ToList();

                    result.Code    = ResultHelper.Success;
                    result.StrCode = ResultHelper.SuccessMsg;
                }

                return(result);
            }
            catch (Exception ex)
            {
                Log.Error("GetLiveBroadCastList", "GetLiveBroadCastList", ex.Message.ToString());
                result.Code    = ResultHelper.ExecutingError;
                result.StrCode = ResultHelper.ExecutingErrorMsg;
                return(result);
            }
        }
예제 #11
0
        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 bool Post()
        {
            bool flog    = false;
            var  request = HttpContext.Current.Request;

            try
            {
                String Msg     = request.Form["msg"] ?? "";
                int    o_count = 0;
                string o_json  = "";
                int    n_count = 0;
                string n_json  = "";

                using (var db = new livecloudEntities())
                {
                    switch (Msg)
                    {
                    case "dt_SensitiveSentences":
                        o_count = StaticTables.sdt_SensitiveSentences.Count();
                        db.Configuration.LazyLoadingEnabled = false;
                        StaticTables.sdt_SensitiveSentences = db.dt_SensitiveSentences.AsNoTracking().ToList()
                                                              .OrderByDescending(s => s.id).ToList();
                        n_count = StaticTables.sdt_SensitiveSentences.Count();
                        break;

                    case "dt_SensitiveWords":
                        o_count = StaticTables.sdt_SensitiveWords.Count();
                        db.Configuration.LazyLoadingEnabled = false;
                        StaticTables.sdt_SensitiveWords     = db.dt_SensitiveWords.AsNoTracking().ToList()
                                                              .OrderByDescending(p => p.id).ToList();
                        n_count = StaticTables.sdt_SensitiveWords.Count();
                        break;

                    case "dt_UserBarrageNoSpeak":
                        o_count = StaticTables.sdt_UserBarrageNoSpeak.Count();
                        db.Configuration.LazyLoadingEnabled = false;
                        StaticTables.sdt_UserBarrageNoSpeak = db.dt_UserBarrageNoSpeak.AsNoTracking().ToList()
                                                              .OrderByDescending(p => p.id).ToList();
                        n_count = StaticTables.sdt_UserBarrageNoSpeak.Count();
                        break;

                    case "dt_BlackWords":
                        o_count = StaticTables.sdt_BlackWords.Count();
                        db.Configuration.LazyLoadingEnabled = false;
                        StaticTables.sdt_BlackWords         = db.dt_BlackWords.AsNoTracking().ToList()
                                                              .OrderByDescending(p => p.id).ToList();
                        n_count = StaticTables.sdt_BlackWords.Count();
                        break;
                    }

                    Log.CreateErrorLogTxt("RedisSubscribeUpdateStatic", Msg, "RedisSubscribeGetMsg Time: " + DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"), Msg + "\r\n old:" + o_count + " \r\n\r\n new:" + n_count + "");
                }
                flog = true;
            }
            catch (Exception ex)
            {
                flog = false;
                Log.Error("UpdateStaticController", "UpdateStaticController.Post", ex.ToString());
            }
            return(flog);
        }
        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 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);
                }

                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);
                }

                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);
            }
        }
예제 #18
0
        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;
                byte state     = byte.TryParse(request.Form["State"] ?? "", out state) ? state : (byte)255; //类型, 黑名单|白名单  ,为空时全部
                int  pageSize  = int.TryParse(request.Form["PageSize"] ?? "", out pageSize) ? pageSize : 20;
                int  pageIndex = int.TryParse(request.Form["PageIndex"] ?? "", out pageIndex) ? pageIndex : 0;
                var  content   = request.Form["Content"] ?? "";

                var      startTimeString = request.Form["StartTime"] ?? "";
                var      endTimeString   = request.Form["EndTime"] ?? "";
                DateTime startTime;
                DateTime endTime;

                if (pageSize <= 0 || pageIndex < 0)
                {
                    result.Code    = ResultHelper.ParamFail;
                    result.StrCode = ResultHelper.ParamFailMsg;
                    return(result);
                }

                using (var db = new livecloudEntities())
                {
                    var query = from s in db.dt_SensitiveSentences
                                select s;

                    if (state < 255)
                    {
                        query = query.Where(w => w.state == state);
                    }

                    if (!string.IsNullOrEmpty(content))
                    {
                        query = query.Where(o => o.content.Contains(content));
                    }

                    if (!string.IsNullOrEmpty(startTimeString) && DateTime.TryParse(startTimeString, out startTime))
                    {
                        query = query.Where(o => o.addtime >= startTime);
                    }

                    if (!string.IsNullOrEmpty(endTimeString) && DateTime.TryParse(endTimeString, out endTime))
                    {
                        endTime = endTime.AddDays(1);
                        query   = query.Where(o => o.addtime < endTime);
                    }

                    result.DataCount = query.Count();

                    var sentenceList = query
                                       .OrderByDescending(w => w.id)
                                       .Skip(pageSize * pageIndex)
                                       .Take(pageSize)
                                       .ToList();

                    result.BackData = sentenceList.Select(w => new
                    {
                        ID      = w.id,
                        Content = w.content,
                        State   = w.state,
                        AddTime = w.addtime.ToString("yyyy-MM-dd HH:mm:ss"),
                        Staff   = w.adminname,
                        Remark  = w.remark
                    }).ToList();
                }

                result.Code    = ResultHelper.Success;
                result.StrCode = ResultHelper.SuccessMsg;

                return(result);
            }
            catch (Exception ex)
            {
                Log.Error("GetSentenceManageList", "GetSentenceManageList", 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 roleId = int.TryParse(request.Form["ID"].ToString(), out roleId) ? roleId : -1;

                // 檢查參數
                if (roleId <= 0)
                {
                    result.Code    = ResultHelper.ParamFail;
                    result.StrCode = ResultHelper.ParamFailMsg;
                    return(result);
                }

                using (var db = new livecloudEntities())
                {
                    var role = db.dt_ManagerRole.Find(roleId);

                    if (role == null)
                    {
                        result.Code    = ResultHelper.ParamFail;
                        result.StrCode = ResultHelper.ParamFailMsg + " ID:" + roleId + "的角色不存在";
                        return(result);
                    }

                    var roleData = new
                    {
                        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(),
                        AllowIp         = role.AllowIp.ToOnOff()
                    };

                    result.BackData = new
                    {
                        Id       = roleId,
                        RoleName = role.RoleName,
                        BodyData = roleData
                    };

                    result.Code    = ResultHelper.Success;
                    result.StrCode = ResultHelper.SuccessMsg;
                }

                return(result);
            }
            catch (Exception ex)
            {
                Log.Error("GetRoleInfo", "GetRoleInfo", 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;
                int state     = int.TryParse(request.Form["State"] ?? "", out state) ? state : -1; //全部""|黑名单0|禁用词1 | 人工审核2
                int pageSize  = int.TryParse(request.Form["PageSize"] ?? "", out pageSize) ? pageSize : 20;
                int pageIndex = int.TryParse(request.Form["PageIndex"] ?? "", out pageIndex) ? pageIndex : 0;

                var userName     = request.Form["UserName"] ?? "";
                var userNickName = request.Form["UserNickName"] ?? "";

                var      startTimeString = request.Form["StartTime"] ?? "";
                var      endTimeString   = request.Form["EndTime"] ?? "";
                DateTime startTime;
                DateTime endTime;

                if (pageSize <= 0 || pageIndex < 0)
                {
                    result.Code    = ResultHelper.ParamFail;
                    result.StrCode = ResultHelper.ParamFailMsg;
                    return(result);
                }

                using (var db = new livecloudEntities())
                {
                    var query = from s in db.ChatMessageBlockLog
                                select s;

                    if (!string.IsNullOrEmpty(userName))
                    {
                        query = query.Where(s => s.UserName == userName);
                    }

                    if (!string.IsNullOrEmpty(userNickName))
                    {
                        query = query.Where(s => s.UserNickName == userNickName);
                    }

                    if (state >= 0)
                    {
                        query = query.Where(s => s.State == state);
                    }
                    else
                    {
                        // 狀態為全部時,去除"人工審核"
                        query = query.Where(s => s.State != 2);
                    }

                    if (!string.IsNullOrEmpty(startTimeString) && DateTime.TryParse(startTimeString, out startTime))
                    {
                        query = query.Where(o => o.Time >= startTime);
                    }

                    if (!string.IsNullOrEmpty(endTimeString) && DateTime.TryParse(endTimeString, out endTime))
                    {
                        endTime = endTime.AddDays(1);
                        query   = query.Where(o => o.Time < endTime);
                    }

                    var totalCount = query.Count();

                    var tempList = query
                                   .OrderByDescending(s => s.Id)
                                   .Skip(pageSize * pageIndex)
                                   .Take(pageSize)
                                   .ToList();

                    result.DataCount = totalCount;
                    result.BackData  = tempList.Select(s => new
                    {
                        ID           = s.Id,
                        UserName     = s.UserName,
                        UserNickName = s.UserNickName ?? "",
                        State        = s.State,
                        ShieldedWord = s.BlockWords,
                        Content      = s.Content,
                        Time         = s.Time.ToString("yyyy-MM-dd HH:mm:ss")
                    }).ToList();
                }

                result.Code    = ResultHelper.Success;
                result.StrCode = ResultHelper.SuccessMsg;

                return(result);
            }
            catch (Exception ex)
            {
                Log.Error("GetShieldedRecord", "GetShieldedRecord", ex.Message.ToString());
                result.Code    = ResultHelper.ExecutingError;
                result.StrCode = ResultHelper.ExecutingErrorMsg;
                return(result);
            }
        }
예제 #21
0
        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);
                }

                //驗證權限
                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);
                    }
                }

                int id        = int.TryParse(request.Form["Id"] ?? "", out id) ? id : -1;
                var allowIp   = request.Form["Iplimit"] ?? "";
                var remark    = request.Form["Remark"] ?? "";
                int pageIndex = int.TryParse(request.Form["PageIndex"] ?? "", out pageIndex) ? pageIndex : 0;
                int pageSize  = int.TryParse(request.Form["PageSize"] ?? "", out pageSize) ? pageSize : 10;

                if (pageIndex < 0 || pageSize <= 0)
                {
                    result.Code    = ResultHelper.ParamFail;
                    result.StrCode = ResultHelper.ParamFailMsg;
                    return(result);
                }

                // 可以考慮做快取
                using (var db = new livecloudEntities())
                {
                    var query = from a in db.dt_AllowAccessIPList
                                select a;

                    if (id > 0)
                    {
                        query = query.Where(o => o.Id == id);
                    }

                    if (!string.IsNullOrEmpty(allowIp))
                    {
                        query = query.Where(o => o.Ip == allowIp.Trim());
                    }

                    int totalCount = query.Count();

                    var list = query
                               .OrderBy(a => a.Id)
                               .Skip(pageIndex * pageSize)
                               .Take(pageSize)
                               .ToList();

                    result.Code      = ResultHelper.Success;
                    result.StrCode   = ResultHelper.SuccessMsg;
                    result.DataCount = totalCount;
                    // 要確認TrimEnd等等的動作必要性
                    result.BackData = list.Select(a => new
                    {
                        Id      = a.Id,
                        Iplimit = a.Ip.ToString(),
                        Remark  = a.Remark?.TrimEnd(),
                        AddTime = a.AddTime?.ToString("yyyy-MM-dd HH:mm:ss")
                    }).ToList();
                }

                return(result);
            }
            catch (Exception ex)
            {
                Log.Error("GetAllowIpList", "GetAllowIpList", ex.Message.ToString());
                result.Code    = ResultHelper.ExecutingError;
                result.StrCode = ResultHelper.ExecutingErrorMsg;
                return(result);
            }
        }
예제 #22
0
        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;
                }
            }
        }
예제 #23
0
        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);
                }

                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 query = from m in db.dt_Manager
                                join r in db.dt_ManagerRole
                                on m.admin_role equals r.Id
                                where m.admin_role != 2
                                orderby m.id ascending
                                select new
                    {
                        m.id,
                        m.user_name,
                        m.real_name,
                        m.add_time,
                        m.Status,
                        r.RoleName
                    };

                    var managerList = query.ToList().Select(o => new ManagerList()
                    {
                        ID        = o.id,
                        UserName  = o.user_name,
                        RealName  = o.real_name,
                        AdminRole = o.RoleName,
                        AddTime   = o.add_time.ToString("yyyy-MM-dd HH:mm:ss"),
                        Status    = o.Status
                    }).ToList();

                    result.BackData = managerList;

                    result.Code    = ResultHelper.Success;
                    result.StrCode = ResultHelper.SuccessMsg;
                }

                return(result);
            }
            catch (Exception ex)
            {
                Log.Error("ManagerList", "ManagerList", ex.Message.ToString());
                result.Code    = ResultHelper.ExecutingError;
                result.StrCode = ResultHelper.ExecutingErrorMsg;
                return(result);
            }
        }
예제 #25
0
        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"] ?? "";
                string   content   = request.Form["Content"] ?? "";
                int      pageIndex = int.TryParse(request.Form["PageIndex"] ?? "", out pageIndex) ? pageIndex : 0;
                int      pageSize  = int.TryParse(request.Form["PageSize"] ?? "", out pageSize) ? pageSize : 20;
                DateTime now       = DateTime.Now;

                if (pageIndex < 0 || pageSize <= 0)
                {
                    result.Code    = ResultHelper.ParamFail;
                    result.StrCode = ResultHelper.ParamFailMsg;
                    return(result);
                }

                using (var db = new livecloudEntities())
                {
                    var query = from b in db.dt_BlackWords
                                select b;

                    if (!string.IsNullOrEmpty(content))
                    {
                        query = query.Where(b => b.content.Contains(content));
                    }

                    int totalCount = query.Count();

                    var list = query
                               .OrderByDescending(b => b.addtime)
                               .Skip(pageIndex * pageSize)
                               .Take(pageSize)
                               .ToList();

                    var managerList = db.dt_Manager.ToList();

                    result.DataCount = totalCount;

                    // 要確認TrimEnd等等的動作必要性
                    result.BackData = list.Select(b => new
                    {
                        ID      = b.id,
                        Content = b.content.ToString(),
                        AddTime = b.addtime.ToString("yyyy-MM-dd HH:mm:ss"),
                        Staff   = b.adminname.ToString(),
                        Remark  = b.remark.ToString()
                    }).ToList();

                    result.Code    = ResultHelper.Success;
                    result.StrCode = ResultHelper.SuccessMsg;
                }

                return(result);
            }
            catch
            {
                return(result);
            }
        }
예제 #26
0
        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 actionType = request.Form["Type"] ?? "";
                int pageSize   = int.TryParse(request.Form["PageSize"] ?? "", out pageSize) ? pageSize : 10;
                int pageIndex  = int.TryParse(request.Form["PageIndex"] ?? "", out pageIndex) ? pageIndex : 0;
                ////驗證權限
                //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.ManageLog == false)
                //    {
                //        result.Code = ResultHelper.NotAuthorized;
                //        result.StrCode = ResultHelper.NotAuthorizedMsg;
                //        return result;
                //    }
                //}

                if (pageSize <= 0 || pageIndex < 0)
                {
                    result.Code    = ResultHelper.ParamFail;
                    result.StrCode = ResultHelper.ParamFailMsg;
                    return(result);
                }


                using (var db = new livecloudEntities())
                {
                    var query = from o in db.dt_ManageLog
                                select o;

                    if (!string.IsNullOrEmpty(userName))
                    {
                        query = query.Where(o => o.ManagerName == userName);
                    }

                    if (!string.IsNullOrEmpty(actionType))
                    {
                        query = query.Where(o => o.ActionType == actionType);
                    }

                    var totalCount = query.Count();

                    var list = query
                               .OrderByDescending(o => o.Id)
                               .Skip(pageIndex * pageSize)
                               .Take(pageSize)
                               .ToList()
                               .Select(o => new ManageLog()
                    {
                        IP       = o.IP,
                        ID       = o.Id,
                        Mark     = o.Remarks,
                        Time     = o.AddTime.ToString("yyyy-MM-dd HH:mm:ss"),
                        Type     = o.ActionType,
                        UserName = o.ManagerName
                    })
                               .ToList();

                    result.DataCount = totalCount;
                    result.BackData  = list;

                    result.Code    = ResultHelper.Success;
                    result.StrCode = ResultHelper.SuccessMsg;
                }

                return(result);
            }
            catch (Exception ex)
            {
                Log.Error("ManageLog", "ManageLog", 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;

                if (id <= 0)
                {
                    result.Code    = ResultHelper.ParamFail;
                    result.StrCode = ResultHelper.ParamFailMsg;
                    return(result);
                }

                using (var db = new livecloudEntities())
                {
                    var manager = db.dt_Manager.Find(id);

                    if (manager == null)
                    {
                        result.Code    = ResultHelper.ParamFail;
                        result.StrCode = ResultHelper.ParamFailMsg + " ID:" + id + "的管理员不存在";
                        return(result);
                    }

                    result.BackData = new GetManager()
                    {
                        ID          = manager.id,
                        UserName    = manager.user_name,
                        RealName    = manager.real_name,
                        AdminRoleID = manager.admin_role
                    };
                    result.Code    = ResultHelper.Success;
                    result.StrCode = ResultHelper.SuccessMsg;
                }

                return(result);
            }
            catch (Exception ex)
            {
                Log.Error("GetManager", "GetManager", ex.Message.ToString());
                result.Code    = ResultHelper.ExecutingError;
                result.StrCode = ResultHelper.ExecutingErrorMsg;
                return(result);
            }
        }
예제 #28
0
        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);
            }
        }
예제 #29
0
        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);
            }
        }
예제 #30
0
        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);
            }
        }