/// <inheritdoc /> public IEnumerable <ITaskRuntimeInfo> GetPending(bool includePollingQueueTasks) { Trace.WriteLine("ENTER: Getting runtime information for pending tasks ({0} polling queue tasks).".FormatInvariant(includePollingQueueTasks ? "include" : "without")); List <ITaskRuntimeInfo> result = this.GetAll(RedisTaskRuntimeInfoRepository.PendingTasksList); if (includePollingQueueTasks) { var listKeys = this.provider.SearchKeys(RedisTaskRuntimeInfoRepository.PendingTasksList + "$*"); List <string> entityIds = new List <string>(); using (IRedisPipeline pipeline = this.provider.CreatePipeline()) { foreach (string listKey in listKeys) { pipeline.GetList(listKey, values => entityIds.AddRange(values)); } pipeline.Flush(); } result.AddRange(this.GetAll(entityIds).Where(t => t.Status == TaskStatus.Pending)); } Trace.WriteLine("EXIT: Return runtime information for {0} pending tasks ({1} polling queue tasks).".FormatInvariant(result.Count, includePollingQueueTasks ? "include" : "without")); return(result); }
private Dictionary <TaskStatus, IEnumerable <ITaskRuntimeInfo> > GetAllByType(params string[] listKeys) { List <string> entityIds = new List <string>(); using (IRedisPipeline pipeline = this.provider.CreatePipeline()) { foreach (string listKey in listKeys) { pipeline.GetList(listKey, values => entityIds.AddRange(values)); } pipeline.Flush(); } Dictionary <TaskStatus, IEnumerable <ITaskRuntimeInfo> > result = new Dictionary <TaskStatus, IEnumerable <ITaskRuntimeInfo> >(); using (IRedisPipeline pipeline = this.provider.CreatePipeline()) { foreach (string entityId in entityIds) { string entityKey = RedisTaskRuntimeInfoRepository.GetEntityKey(entityId); pipeline.GetHash(entityKey, values => { if (values.Count > 0) { ITaskRuntimeInfo taskInfo = RedisTaskRuntimeInfoRepository.Convert(values); IEnumerable <ITaskRuntimeInfo> collection; if (!result.TryGetValue(taskInfo.Status, out collection)) { collection = new List <ITaskRuntimeInfo>(); result.Add(taskInfo.Status, collection); } ((ICollection <ITaskRuntimeInfo>)collection).Add(taskInfo); } }); } pipeline.Flush(); } return(result); }