예제 #1
0
 public ActionResult Index()
 {
     LogHelp.Debug("Debug");
     LogHelp.Info("Info");
     LogHelp.Error("Error");
     return(View());
 }
예제 #2
0
 public override void OnException(ExceptionContext filterContext)
 {
     base.OnException(filterContext);
     //处理错误消息,将其跳转到一个页面
     LogHelp.Debug(filterContext.Exception.ToString());
     //页面跳转到错误页面
     filterContext.HttpContext.Response.Redirect("/Home/Index");
 }
예제 #3
0
        public JsonResult Login(Login login)
        {
            Response <object> result = new Response <object>()
            {
                code = Convert.ToInt32(Status.Failed)
            };
            var count = SqlDapperHelper.ReturnT <int>("select count(1) from [User] where Phone=@Phone and Password=@Password", login);

            if (count > 0)
            {
                result.code = Convert.ToInt32(Status.Succeed);
                result.msg  = "登录成功";
                Login tokens = SqlDapperHelper.ReturnT <Login>("select * from [User] where Phone=@Phone and Password=@Password", login);

                try
                {
                    //存redis
                    RedisManager.redisHelp.SetValue("Login", JsonConvert.SerializeObject(tokens));
                }
                catch (Exception ex)
                {
                    LogHelp.Error(ex);
                }


                try
                {
                    //登录加密保存信息

                    //var token = AESEncrypt(JsonConvert.SerializeObject(tokens));
                    // Convert.ToBase64String(Encode(Encoding.UTF8.GetBytes(password)));

                    var token = Convert.ToBase64String(AESEncrypt(JsonConvert.SerializeObject(tokens)));
                    //SignIn(tokens, true).Wait();

                    //登录成功,信息加入MQ

                    PushMQ.SendMQ(tokens, Key.PushMQUserKey);
                }
                catch (Exception ex)
                {
                    LogHelp.Error(ex);
                }
                return(Json(new { result }));
            }

            //测试日志
            LogHelp.Debug("登录失败:账号" + login.Phone + "  密码:" + login.Password);
            result.msg = "登录失败";
            return(Json(new { result }));
        }
예제 #4
0
파일: EMonster.cs 프로젝트: Tiaoyu/TServer
        /// <summary>
        /// Entity更新逻辑
        /// 用于做一些定时操作
        /// </summary>
        public override void Update()
        {
            Program.TimerManager.Insert(50, 50, int.MaxValue, null, (obj) =>
            {
                // 根据当前AI状态进行不同逻辑
                switch (AIState)
                {
                // 巡逻 在出生点一定范围内随机一个位置移动
                case EAIState.PATROL:
                    //log.Debug($"i'm monster, i'm in partrol, my position is ({Position.x},{Position.y}).");
                    foreach (var target in this.Sight.SetInSightEntity)
                    {
                        if (this.Dungeon.GridSystem.GetDistanceFromTwoPosition(target.Position, this.BirthPosition) > AutoAttackDistance)
                        {
                            continue;
                        }
                        if (EEntity.IsRole(target.Id))
                        {
                            TargetId = target.Id;
                            AIState  = EAIState.ATTACK;
                            this.Movement.IsNavAuto = false;
                            log.Debug($"i'm monster, i'm in partrol, i found a target({target.Id}, ready to attcck.");
                            break;
                        }
                    }

                    if (TargetId == 0)
                    {
                        if (this.Movement.IsNavAuto)
                        {
                            NavMove();
                        }
                        else
                        {
                            // 巡逻时在自己出生点一定距离内随机一个位置寻路
                            SMove.Instance.OnEntityNavAuto(this, SUtilities.GetRandomInt((int)BirthPosition.x - 25, (int)BirthPosition.x + 25), SUtilities.GetRandomInt((int)BirthPosition.y - 25, (int)BirthPosition.y + 25));
                            log.Debug($"i'm monster, i'm in partrol.");
                        }
                    }

                    break;

                // 攻击
                case EAIState.ATTACK:
                    if (this.Dungeon.DicEntity.TryGetValue(TargetId, out var entity))
                    {
                        //log.Debug($"i'm monster, i'm in attack, target is {TargetId},  my position is ({Position.x},{Position.y}), target position is ({entity.Position.x},{entity.Position.y}).");
                        if (this.Movement.IsNavAuto)
                        {
                            NavMove();
                        }
                        else
                        {
                            log.Debug($"i'm monster, i'm in attack, target is {TargetId}");
                            SMove.Instance.OnEntityNavAuto(this, entity.Position.x, entity.Position.y);
                        }

                        //目标超出索敌范围 切换为寻路状态
                        if (this.Dungeon.GridSystem.GetDistanceFromTwoPosition(entity.Position, this.BirthPosition) > this.LeaveCombatDistance)
                        {
                            TargetId = 0;
                            AIState  = EAIState.PATROL;
                            log.Debug($"i'm monster, i'm in attack, but target({TargetId}) is lost.");
                        }
                    }
                    else
                    {
                        TargetId = 0;
                        AIState  = EAIState.PATROL;
                        log.Debug($"i'm monster, i'm in attack, but target({TargetId}) is lost.");
                    }
                    break;

                // 逃跑
                case EAIState.FLEE:
                    log.Debug($"i'm monster, i'm in flee.");
                    break;

                // 预警
                case EAIState.INVESTIGATE:
                    log.Debug($"i'm monster, i'm in investigate.");
                    break;
                }
            });
        }
예제 #5
0
파일: SLogin.cs 프로젝트: Tiaoyu/TServer
 public void Register(Guid guid, C2SRegister pack)
 {
     log.Debug($"Guid:{guid} --- {pack.Name} register, passwordis {pack.Password}.");
 }