public async static Task <R.Responses_Paged <TResponse> > AsPagedResult <TResponse>(this ICallback callback, Q.Queries_Paged <TResponse> query = null) where TResponse : class { var response = await callback.IsPaged <TResponse>(); return(new R.Responses_Paged <TResponse> { Records = response.Records.Select(x => x.ConvertTo <TResponse>()), Total = response.Total, ElapsedMs = response.ElapsedMs, SubscriptionId = query?.SubscriptionId, SubscriptionTime = query?.SubscriptionTime, }); }
public static void SubscribeWith <TResponse>(this ISubscriptionManager manager, R.Responses_Paged <TResponse> dto, Q.Queries_Paged <TResponse> query, String Session) { var key = query.GetCacheKey(); query.SubscriptionType = query.SubscriptionType ?? ChangeType.ALL; foreach (var record in dto.Records) { manager.Manage(record, key, query.SubscriptionId, query.SubscriptionType ?? ChangeType.ALL, TimeSpan.FromSeconds(query.SubscriptionTime ?? 3600), Session); } }
public static R.Responses_Paged <TResponse> AsSyncPagedResult <TResponse>(this ICallback callback, Q.Queries_Paged <TResponse> query = null) where TResponse : class { return(Task.Run(async() => { return await callback.AsPagedResult <TResponse>(); }).Result); }
public static async Task <R.Responses_Paged <TResponse> > ToOptimizedCachedAndSubscribedPagedResult <TResponse>(this IRequest request, Q.Queries_Paged <TResponse> query, ICacheClient cache, ISubscriptionManager manager, Func <Task <R.Responses_Paged <TResponse> > > factory) { var key = query.GetCacheKey(); var cached = cache.Get <R.Responses_Paged <TResponse> >(key); if (cached == null) { cached = await factory(); cache.Add(key, cached); } manager.SubscribeWith(cached, query, request.GetSessionId()); return(cached); }
public static R.Responses_Paged <TResponse> ToOptimizedCachedAndSubscribedPagedResult <TResponse>(this IRequest request, Q.Queries_Paged <TResponse> query, ICacheClient cache, ISubscriptionManager manager, Func <R.Responses_Paged <TResponse> > factory) { var result = request.ToOptimizedCachedResult(query, cache, () => { var response = factory(); return(response); }); manager.SubscribeWith(result, query, request.GetSessionId()); return(result); }
public static async Task <R.Responses_Paged <TResponse> > ToOptimizedCachedResult <TResponse>(this IRequest request, Q.Queries_Paged <TResponse> query, ICacheClient cache, Func <Task <R.Responses_Paged <TResponse> > > factory) { var key = query.GetCacheKey(); var cached = cache.Get <R.Responses_Paged <TResponse> >(key); if (cached == null) { cached = await factory(); cache.Add(key, cached); } return(cached); }
public static R.Responses_Paged <TResponse> ToOptimizedCachedResult <TResponse>(this IRequest request, Q.Queries_Paged <TResponse> query, ICacheClient cache, Func <R.Responses_Paged <TResponse> > factory) { var key = query.GetCacheKey(); var cached = cache.GetOrCreate(key, () => { var result = factory(); return(result); }); return(cached); }