public AppInfos GetByAppId(string appkey)
        {
            if (_cacheManager.IsSet(appkey))
            {
                return(_cacheManager.Get <AppInfos>(appkey));
            }
            var appinfo = _dbQuery.QuerySingle <AppInfos>("SELECT AppKey,AppSecret FROM dbo.AppInfos WHERE AppKey =@appkey", new { appkey = appkey });

            _cacheManager.Set(appkey, appinfo, BaseConfig.CacheWeek);

            return(appinfo);
        }
 public bool UpdateSurveyStyle(SurveyDirectory model)
 {
     if (model != null)
     {
         bool rst = true;
         if (model.SurveyDetail != null)
         {
             model.SurveyDetail.SurveyNote = Utils.HtmlEncode(Utils.UrlDecode(model.SurveyDetail.SurveyNote));
             rst = _surveyDetailServices.Update(model.SurveyDetail);
         }
         if (model.SurveyStyle != null)
         {
             var existStyle  = _dbQuery.QuerySingle <SurveyStyle>("SELECT * FROM dbo.SurveyStyle WHERE DirId = @dirid and IsValid =1", new { dirid = model.Id });
             var sourceStyle = _dbQuery.QuerySingle <SurveyStyle>("SELECT * FROM dbo.SurveyStyle WHERE id = @id and IsValid =1", new { id = model.SurveyStyle.Id });
             if (existStyle != null)
             {
                 sourceStyle.Id    = existStyle.Id;
                 sourceStyle.DirId = model.Id;
                 var updateRst = _surveyStyleServices.Update(sourceStyle);
                 rst = rst || updateRst;
             }
             else
             {
                 sourceStyle.DirId = model.Id;
                 var istrst = _surveyStyleServices.Insert(sourceStyle);
                 rst = rst || istrst > 0;
             }
         }
         if (rst)
         {
             if (_cacheManager.IsSet(string.Format(SurveyConfig.DIRDETAILSTYLE, model.Id)))
             {
                 _cacheManager.Remove(string.Format(SurveyConfig.DIRDETAILSTYLE, model.Id));
             }
         }
         return(rst);
     }
     return(false);
 }
 public SurveyDetail GetBySurveyId(int surveyid)
 {
     return(_dbQuery.QuerySingle <SurveyDetail>("SELECT * FROM dbo.SurveyDetail WHERE DirId =@dirid", new { dirid = surveyid }));
 }
Esempio n. 4
0
        /// <summary>
        /// 如果没有token则新增,如果有则查询返回
        /// </summary>
        /// <param name="users"></param>
        /// <returns></returns>
        public UsersSsoTokens GetUserToken(Users users)
        {
            string encrypttoken = Encrypt.MD5Java(string.Format("{0}|{1}", users.Uid, Guid.NewGuid()));

            return(_dbQuery.QuerySingle <UsersSsoTokens>("IF NOT EXISTS ( SELECT StId FROM UsersSsoTokens WHERE Uid = @uid AND IsValid = 1 ) BEGIN INSERT INTO dbo.UsersSsoTokens( Uid, Token, CreateDate, IsValid ) VALUES ( @uid, @token, GETDATE(), 1 ); SELECT * FROM dbo.UsersSsoTokens WHERE Uid = @uid AND IsValid=1 END ELSE SELECT * FROM dbo.UsersSsoTokens WHERE Uid = @uid AND IsValid = 1;", new { uid = users.Uid, token = encrypttoken }));
        }
Esempio n. 5
0
 public UserSnsRelation Get(string openid, long uid)
 {
     return(_dbQuery.QuerySingle <UserSnsRelation>(
                "SELECT * FROM dbo.UserSnsRelation WHERE OpenId = @OpenId AND Uid = @Uid AND IsValid =1",
                new { OpenId = openid, Uid = uid }));
 }
 public Users GetByUsername(string username)
 {
     return(_dbQuery.QuerySingle <Users>("SELECT top 1 * FROM dbo.Users WHERE IsValid =1 AND UserName =@username", new { username = username }));
 }