public CacheMethod(MethodInfo method, CacheOperation operation) { Method = method ?? throw new ArgumentNullException(nameof(method)); Operation = operation; var returnType = method.ReturnType; if (returnType.IsGenericType) { returnType = returnType.GetGenericTypeDefinition(); } if (typeof(Task) == method.ReturnType || typeof(ValueTask) == method.ReturnType) { AsyncType = returnType; ValueType = typeof(void); } else if (typeof(Task <>) == returnType || typeof(ValueTask <>) == returnType) { AsyncType = returnType; ValueType = method.ReturnType.GetGenericArguments()[0]; } else { ValueType = method.ReturnType; } WarpedValue = ValueType.IsGenericType && ValueType.GetGenericTypeDefinition() == typeof(ICacheResult <>); }
/// <summary> /// 重置密码 /// </summary> /// <param name="user"></param> /// <returns></returns> public ResultModel <object> ResetUserPassword(U_User user) { ResultModel <object> msg = new ResultModel <object>(); var list = CacheOperation <List <dynamic> > .GetCache(user.E_Mail); if (list == null) { msg.Code = 2001; msg.Message = "验证码已过期"; return(msg); } if (list != user.AuthCode) { msg.Code = 2001; msg.Message = "验证码错误"; return(msg); } user.PassWord = EncryptOperation.MD5HashHex(user.PassWord); var result = new U_UserDAL().ResetUserPassword(user); if (result > 0) { msg.Message = "修改成功"; return(msg); } else { msg.Code = 2001; msg.Message = "修改失败"; return(msg); } }
/// <summary> /// 注册 /// </summary> /// <param name="user"></param> /// <returns></returns> public ResultModel <object> Register(U_User user) { ResultModel <object> msg = new ResultModel <object>(); var list = CacheOperation <List <dynamic> > .GetCache(user.E_Mail); if (list == null) { msg.Code = 2001; msg.Message = "验证码已过期"; return(msg); } if (list != user.AuthCode) { msg.Code = 2001; msg.Message = "验证码错误"; return(msg); } user.UserCode = new CreateEmpCode().GetRandomEmpCode(2, 4); var result = new U_UserDAL().Register(user); if (result > 0) { msg.Message = "注册成功"; return(msg); } else { msg.Code = 2001; msg.Message = "注册失败"; return(msg); } }
protected void CacheLogContext(CacheOperation operation, string key, Action action) { CacheLogContext(operation, key, () => { action(); return(0); }); }
public CacheMethod(MethodInfo method, CacheOperation operation) { Method = method ?? throw new ArgumentNullException(nameof(method)); Operation = operation; #if BuildTask var returnType = method.ReturnType; if (returnType.IsGenericInstance) { returnType = returnType.GetElementType(); } if (method.ReturnType.IsType <Task>() || method.ReturnType.IsType <ValueTask>()) { AsyncType = returnType; ValueType = CacheTypeResolver.Void; } else if (returnType.IsType(typeof(Task <>)) || returnType.IsType(typeof(ValueTask <>))) { AsyncType = returnType; ValueType = ((GenericInstanceType)method.ReturnType).GenericArguments[0]; } else { ValueType = method.ReturnType; } WarpedValue = ValueType.IsGenericInstance && ValueType.GetElementType().IsType("NetCache.ICacheResult`1, NetCache.Core"); #else var returnType = method.ReturnType; if (returnType.IsGenericType) { returnType = returnType.GetGenericTypeDefinition(); } if (typeof(Task) == method.ReturnType || typeof(ValueTask) == method.ReturnType) { AsyncType = returnType; ValueType = typeof(void); } else if (typeof(Task <>) == returnType || typeof(ValueTask <>) == returnType) { AsyncType = returnType; ValueType = method.ReturnType.GetGenericArguments()[0]; } else { ValueType = method.ReturnType; } WarpedValue = ValueType.IsGenericType && ValueType.GetGenericTypeDefinition() == typeof(ICacheResult <>); #endif }
protected T CacheLogContext <T>(CacheOperation operation, string key, Func <T> action) { try { return(action()); } catch (Exception e) { _logger.CacheOperationFailed(operation, key, e); } finally { _logger.CacheOperationRequested(operation, key); } return(default);
public static ActionType ToActionType(CacheOperation operation) { switch (operation) { case CacheOperation.Copy: return(ActionType.Copy); case CacheOperation.Download: return(ActionType.Download); case CacheOperation.Extract: return(ActionType.Extract); default: throw new ArgumentOutOfRangeException(nameof(operation), operation, null); } }
/// <summary> /// Creates a new instance of the <see cref="CacheAcquireBeginEventArgs"/> class. /// </summary> public CacheAcquireBeginEventArgs(string packageOrContainerId, string payloadId, CacheOperation operation, string source) { this.packageOrContainerId = packageOrContainerId; this.payloadId = payloadId; this.operation = operation; this.source = source; }
/// <summary> Constructor. </summary> /// <param name="operation"> The operation. </param> /// <param name="cacheKey"> The cache key. </param> /// <param name="resourceKey"> The resource key. </param> public CacheEventArgs(CacheOperation operation, string cacheKey, string resourceKey) { Operation = operation; CacheKey = cacheKey; ResourceKey = resourceKey; }
public static FluentCacheException CachingFailed(CacheOperation operation, StackExchange.Redis.RedisException redisException) { return(new FluentCacheException("Caching failed while communicating with Redis. See inner exception for details", operation, redisException)); }
internal static void CacheOperationFailed(this ILogger <IDistributedCacheService> logger, CacheOperation operation, string key, Exception ex) { _cacheOperationFailed(logger, operation, key, ex); }
internal static void CacheOperationRequested(this ILogger <IDistributedCacheService> logger, CacheOperation operation, string key) { _cacheOperationRequested(logger, operation, key, null); }
/// <summary> /// Constructs a new instance with the specified message, operation, and inner exception /// </summary> public FluentCacheException(string message, CacheOperation operation, Exception innerException) : base(message, innerException) { Operation = operation; }
/// <summary>ctor</summary> /// <param name="operation">Cache operation</param> public CacheMethodAttribute(CacheOperation operation) => Operation = operation;
public CacheEventArgs(CacheOperation cacheOperation, int entityId) { EntityId = entityId; Operation = cacheOperation; }
Result IBootstrapperApplication.OnCacheAcquireBegin(string wzPackageOrContainerId, string wzPayloadId, CacheOperation operation, string wzSource) { CacheAcquireBeginEventArgs args = new CacheAcquireBeginEventArgs(wzPackageOrContainerId, wzPayloadId, operation, wzSource); this.OnCacheAcquireBegin(args); return args.Result; }
//Probably Obsolote, we don't know if developers use it. protected bool UpdateEventCache(Actor actor, byte evCode, object data, CacheOperation cacheOp, ref string msg) { // cache operations for the actor event cache currently only working with hashtable data Hashtable eventData; if (data == null || data is Hashtable) { eventData = (Hashtable)data; } else { msg = string.Format("Cache operation '{0}' requires a Hashtable as event data.", cacheOp); return false; } switch (cacheOp) { case CacheOperation.MergeCache: this.ActorEventCache.MergeEvent(actor.ActorNr, evCode, eventData); return true; case CacheOperation.RemoveCache: this.ActorEventCache.RemoveEvent(actor.ActorNr, evCode); return true; case CacheOperation.ReplaceCache: this.ActorEventCache.ReplaceEvent(actor.ActorNr, evCode, eventData); return true; default: msg = string.Format("Unknown cache operation '{0}'.", cacheOp); return false; } }
public CacheOperationException(Exception innerException, CacheOperation operation) : base("Local memory cache exception detected. See InnerException.", innerException) { CacheOperation = operation; }