コード例 #1
0
ファイル: RobotThread.cs プロジェクト: cool8868/H5Nball
        public RobotResponse StopRobot(Guid managerId)
        {
            CrossrobotManagerEntity crossRobotManager = null;
            var code = StopCrossRobotManager(managerId, out crossRobotManager);

            if (code != MessageCode.Success)
            {
                return(ResponseHelper.Create <RobotResponse>(code));
            }
            var response = ResponseHelper.CreateSuccess <RobotResponse>();

            return(RobotCore.BuildRobotResponse(response, crossRobotManager));
        }
コード例 #2
0
ファイル: RobotThread.cs プロジェクト: cool8868/H5Nball
        /// <summary>
        /// 启动机器人
        /// </summary>
        /// <param name="siteId"></param>
        /// <param name="managerId"></param>
        /// <returns></returns>
        public RobotResponse StartRobot(string siteId, Guid managerId)
        {
            var manager = ManagerCore.Instance.GetManager(managerId, false, siteId);

            if (manager == null)
            {
                return(ResponseHelper.Create <RobotResponse>(MessageCode.MissManager));
            }
            if (manager.Level < RobotLevel)
            {
                return(ResponseHelper.Create <RobotResponse>(MessageCode.LackofManagerLevel));
            }
            if (!CheckManagerVip(manager))
            {
                return(ResponseHelper.Create <RobotResponse>(MessageCode.LackofVipLevel));
            }

            var crossRobotManager = CrossrobotManagerMgr.GetById(managerId);

            if (crossRobotManager == null)
            {
                crossRobotManager = RobotCore.BuildCrossRobotManager(siteId, managerId);
                SetHookStatus(crossRobotManager, true);
                if (!CrossrobotManagerMgr.Insert(crossRobotManager))
                {
                    return(ResponseHelper.Create <RobotResponse>(MessageCode.FailUpdate));
                }
            }
            else
            {
                if (!GetHookStatus(crossRobotManager))
                {
                    SetHookStatus(crossRobotManager, true);
                    if (!CrossrobotManagerMgr.Update(crossRobotManager))
                    {
                        return(ResponseHelper.Create <RobotResponse>(MessageCode.FailUpdate));
                    }
                }
            }
            if (!_crossRobotManagerDic.ContainsKey(managerId))
            {
                _crossRobotManagerDic.TryAdd(managerId, crossRobotManager);
            }
            var response = ResponseHelper.CreateSuccess <RobotResponse>();

            return(RobotCore.BuildRobotResponse(response, crossRobotManager));
        }