private Complaints GetComplaintsById(long id, Model.Token token, SYS_USER u)
        {
            int t = 0;
            IEnumerable <Complaints> data = null;
            Complaints result             = null;

            try
            {
                if (token.UserTypes.Contains("customer"))
                {
                    data = QueryForCreator(null, u.USERNAME, 1, int.MaxValue, out t);
                }
                else if (token.UserTypes.Contains("installer"))
                {
                    data = _repository.QueryComplaintsForInstaller(id, u.USERNAME, u.LICNO, 1, 1, out t);
                }

                if (t > 0)
                {
                    result = _repository.AllIncluding(x => x.ComplaintsProcessing, x => x.CustomerReviews).FirstOrDefault(x => x.Key == id);
                }
            }
            catch (Exception exc)
            {
                throw;
            }

            return(result);
        }
Exemplo n.º 2
0
 public HttpResponseMessage UpdateToken(Model.Token Model)
 {
     if (Model != null && ModelState.IsValid)
     {
         _TokenBusinessLogic.Update(Model);
         return(ReturnSuccessMessage());
     }
     else
     {
         return(ReturnModelValidFailMessage(ModelState, Model));
     }
 }
Exemplo n.º 3
0
        protected static string addtoken()
        {
            string url  = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=wxd38d20377fa76818&secret=bfb5355bf94bc8f76ab3a3ba52223c54";
            string json = JsonGet(url);
            //通过access_token和openid拉取用户信息
            JsonData jsonData = JsonMapper.ToObject(json);
            //拉取信息
            string access_token = jsonData["access_token"].ToString();

            Model.Token model = new Model.Token();
            model.TokenCode = access_token;
            model.Date      = DateTime.Now;
            model.SXDate    = DateTime.MaxValue;
            BLL.Token.Add(model);
            return(access_token);
        }
Exemplo n.º 4
0
 public HttpResponseMessage AddToken(Model.Token Model)
 {
     if (Model != null && ModelState.IsValid)
     {
         if (_TokenBusinessLogic.FindByField("TokenId", Model.TokenId) != null)
         {
             return(ReturnIsExistsMessage("TokenId"));
         }
         _TokenBusinessLogic.Add(Model);
         return(ReturnSuccessMessage());
     }
     else
     {
         return(ReturnModelValidFailMessage(ModelState, Model));
     }
 }
Exemplo n.º 5
0
 // <summary>
 /// 得到一个对象实体
 /// </summary>
 public static string GetToken()
 {
     Model.Token tk = DAL.Token.GetModel();
     if (tk == null)             //第一次请求tk
     {
         return(addtoken());
     }
     else
     {
         if (tk.Date.AddMinutes(100) <= DateTime.Now)                 //超时重新获取
         {
             return(addtoken());
         }
         else
         {
             return(tk.TokenCode);
         }
     }
 }
Exemplo n.º 6
0
        public async override Task <BitJwtToken> LocalLogin(LocalAuthenticationContext context, CancellationToken cancellationToken)
        {
            if (string.IsNullOrEmpty(context.UserName) || string.IsNullOrEmpty(context.Password))
            {
                throw new BadRequestException("InvalidUserNameAndOrPassword");
            }

            User user = await DbContext.Users.SingleOrDefaultAsync(u => u.UserName.ToLower() == context.UserName.ToLower(), cancellationToken);

            if (user == null)
            {
                throw new BadRequestException("InvalidUserNameAndOrPassword");
            }

            if (!HashUtility.VerifyHash(context.Password, user.Password))
            {
                throw new BadRequestException("InvalidUserNameAndOrPassword");
            }

            var token = new Model.Token {
                IP = "", LoggedInDateTime = System.DateTimeOffset.UtcNow, UserId = user.Id
            };

            DbContext.Set <Model.Token>().Add(token);

            await DbContext.SaveChangesAsync();

            return(new BitJwtToken
            {
                UserId = user.Id.ToString(),
                Claims = new Dictionary <string, string>
                {
                    { "TokenId", token.Id.ToString() }
                }
            });
        }