public T GetValue <T>()
 {
     if (this._originalValue != null)
     {
         return(JsonSerializerManager.JsonDeserialize <T>(this._originalValue));
     }
     return(BinarySerializerManager.BinaryDeSerialize <T>(this._originalRawValue));
 }
Exemple #2
0
 public T GetKey <T>()
 {
     if (this._originalKey != null)
     {
         return(JsonSerializerManager.JsonDeserialize <T>(this._originalKey));
     }
     return(BinarySerializerManager.BinaryDeSerialize <T>(this._originalRawKey));
 }
        public bool IsAuthenticate(string token, out IdentityInfo identityInfo)
        {
            identityInfo = null;
            string cacheString;

            if (cacheManager.RawIsSet(_cache_distribute_token_key, out cacheString, token))
            {
                if (this._identityInfoType == null)
                {
                    this._identityInfoType = CreateIdentityInfo().GetType();
                }
                identityInfo = (IdentityInfo)JsonSerializerManager.JsonDeserialize(cacheString, this._identityInfoType);
                string touchValue;
                if (!cacheManager.RawIsSet(_cache_distribute_token_touch_key, out touchValue, token))
                {
                    cacheManager.RawSet(_cache_distribute_token_key, cacheString, _identity_distribute_expire_minutes, token);
                    cacheManager.Set(_cache_distribute_token_touch_key, 1, _identity_distribute_expire_minutes - 5, token);
                }
                return(true);
            }
            return(false);
        }
Exemple #4
0
 public static T FromJsonString <T>(this string jsonData)
 {
     return(JsonSerializerManager.JsonDeserialize <T>(jsonData));
 }
Exemple #5
0
        private static InkeyResult <string> GetRedisResult(string actionType, string sType, string vType, string cacheResult, FormatObjcet formart, List <string> pValueList)
        {
            InkeyResult <string> result = new InkeyResult <string>();
            bool sJsonType    = sType == "JSON";
            var  cacheManager = new RedisManager(new CacheManagerActionCacheKeyFormat());
            var  flag         = false;

            switch (actionType)
            {
            case "View":
                flag = cacheManager.Exists(formart.Key, pValueList.ToArray());
                if (!flag)
                {
                    result.Code = InkeyErrorCodes.CommonBusinessFailure;
                    result.Desc = "未设置缓存值";
                    return(result);
                }
                if (sJsonType)
                {
                    result.Data = cacheManager.GetOriginalValue(formart.Key, pValueList.ToArray());
                }
                else
                {
                    if (string.IsNullOrEmpty(vType))
                    {
                        result.Code = InkeyErrorCodes.CommonBusinessFailure;
                        result.Desc = "值类型未设置";
                        return(result);
                    }
                    Type type = Type.GetType(vType);
                    if (type == null)
                    {
                        result.Code = InkeyErrorCodes.CommonBusinessFailure;
                        result.Desc = "值类型未定义,类型:" + vType;
                        return(result);
                    }
                    byte[] oValue = cacheManager.RawGetOriginalValue(formart.Key, pValueList.ToArray());
                    object value  = BinarySerializerManager.BinaryDeSerialize(oValue);
                    result.Data = value.ToJsonString();
                }
                break;

            case "Update":
                flag = cacheManager.Exists(formart.Key, pValueList.ToArray());
                if (!flag)
                {
                    result.Code = InkeyErrorCodes.CommonBusinessFailure;
                    result.Desc = "未设置缓存值";
                    return(result);
                }
                if (sJsonType)
                {
                    flag = cacheManager.OriginalValueAdd(formart.Key, cacheResult, pValueList.ToArray());
                    if (!flag)
                    {
                        result.Code = InkeyErrorCodes.CommonBusinessFailure;
                        result.Desc = "更新失败";
                        return(result);
                    }
                }
                else
                {
                    if (string.IsNullOrEmpty(vType))
                    {
                        result.Code = InkeyErrorCodes.CommonBusinessFailure;
                        result.Desc = "值类型未设置";
                        return(result);
                    }
                    Type type = Type.GetType(vType);
                    if (type == null)
                    {
                        result.Code = InkeyErrorCodes.CommonBusinessFailure;
                        result.Desc = "值类型未定义,类型:" + vType;
                        return(result);
                    }
                    var oValue = JsonSerializerManager.JsonDeserialize(cacheResult, type);
                    if (oValue == null)
                    {
                        result.Code = InkeyErrorCodes.CommonBusinessFailure;
                        result.Desc = "json格式错误,类型:" + vType;
                        return(result);
                    }
                    else
                    {
                        var value = BinarySerializerManager.BinarySerialize(oValue);
                        flag = cacheManager.RawOriginalValueAdd(formart.Key, value, pValueList.ToArray());
                        if (!flag)
                        {
                            result.Code = InkeyErrorCodes.CommonBusinessFailure;
                            result.Desc = "更新失败";
                            return(result);
                        }
                    }
                }
                result.Code = InkeyErrorCodes.CommonBusinessFailure;    //前端需要弹出提示,所有设置这个值
                result.Desc = "更新成功";
                break;

            case "Delete":
                flag = cacheManager.Remove(formart.Key, pValueList.ToArray());
                if (!flag)
                {
                    result.Code = InkeyErrorCodes.CommonBusinessFailure;
                    result.Desc = "缓存移除失败";
                    return(result);
                }
                break;
            }
            return(result);
        }