Ejemplo n.º 1
0
        /// <summary>
        /// 校验用户ticket信息
        /// </summary>
        /// <param name="encryptTicket"></param>
        /// <returns></returns>
        private bool ValidateUserTicket(string encryptTicket)
        {
            var userTicket     = FormsAuthentication.Decrypt(encryptTicket);
            var userTicketData = userTicket.UserData;

            string userName = userTicketData.Substring(0, userTicketData.IndexOf(":"));
            string password = userTicketData.Substring(userTicketData.IndexOf(":") + 1);

            var pUserBL = new TW.Platform.BL.UserBL();

            return(pUserBL.VerifyBCLoginUser(userName, password));
            //检查用户名、密码是否正确,验证是合法用户
            //var isQuilified = CheckUser(userName, password);
            //return true;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 执行方法并捕获错误
        /// </summary>
        /// <param name="pInterface"></param>
        /// <param name="action"></param>
        protected HttpResponseMessage ExecuteTryCatch <VModel>(Func <VModel> action)
        {
            CActionResult pActionResult;

            try
            {
#if DEBUG
                //调试模式下,自动注册
                var pUserBL = new TW.Platform.BL.UserBL();
                pUserBL.VerifyBCLoginUser("mark", "504");
#endif

                var vm = action.Invoke();
                pActionResult = new CActionResult()
                {
                    ok = true, message = "", data = vm
                };
                return(Request.CreateResponse(HttpStatusCode.OK, pActionResult));
            }
            catch (Exception ex)
            {
                //转换异常
                var pEGResult = EGExceptionOperator.ConvertException(ex);
                //转换Action结果
                pActionResult = new CActionResult()
                {
                    ok = false, message = pEGResult.Message, data = null
                };
                //写入日志
                if (pEGResult.IsLog)
                {
                    Logger.Log4Net.Info(string.Format("异常代码:{0};异常信息:{1}", pEGResult.ExCode, pEGResult.Message));
                }

                //消息不为空时,确保异常消息返回前端
                if (pEGResult.StCode == null)
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, pActionResult));
                }
                else
                {
                    return(Request.CreateResponse((HttpStatusCode)pEGResult.StCode.Value, pActionResult));
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 读取数据库用户表数据,判断用户密码是否匹配
        /// </summary>
        /// <param name="name"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        internal bool ValidateUserLogin(string name, string password)
        {
            var pUserBL = new TW.Platform.BL.UserBL();

            return(pUserBL.VerifyBCLoginUser(name, password));
        }