public async Task LoadHyperTags() { if (this.HyperStore == null) { return; } TagsAreBeingLoaded = true; var findArgs = new FindHyperDocumentsArgs(typeof(HyperTag)); var conditions = await MetaDataSetHelper.GenerateFilterFromMetaDataSetAsync(HyperStore, _metadataSet); findArgs.DescriptorConditions.AddCondition(conditions.Result); findArgs.Skip = PageSize * (PageNumber - 1); findArgs.Limit = PageSize; var docs = await HyperStore.ExecuteAsync(findArgs); var hyperTags = new List <HyperTag>(); foreach (var doc in docs) { hyperTags.Add(doc.GetPayload <HyperTag>()); } HyperTags.Value = hyperTags; TagsAreBeingLoaded = false; RaiseNotify(nameof(HyperTags)); }
private async Task ApplyFilterConditions(FindHyperDocumentsArgs mainArgs, HyperMetadataSet id) { var conditions = await MetaDataSetHelper.GenerateFilterFromMetaDataSetAsync(_netStore, id); if (conditions.Value != null) { mainArgs.DescriptorConditions.AddCondition(conditions.Value); } }
public async Task LoadTotalPages() { var countArgs = new CountHyperDocumentsArgs(typeof(HyperTag)); var conditions = await MetaDataSetHelper.GenerateFilterFromMetaDataSetAsync(HyperStore, this._metadataSet); countArgs.DescriptorConditions.AddCondition(conditions.Result); var totalTags = await CountHyperDocumentsArgs.CountAsync <HyperTag>(this.HyperStore, countArgs); TotalPages.Value = (int)(totalTags % PageSize == 0 ? totalTags / PageSize : totalTags / PageSize + 1); RaiseNotify(nameof(TotalPages)); }
private async Task ApplyFilterConditions <T>(ScopeHyperDocumentsArgs <T> mainArgs) { var conditions = await MetaDataSetHelper.GenerateFilterFromMetaDataSetAsync(_hyperStore, _metadataSet); mainArgs.DescriptorConditions.AddCondition(conditions.Result); //hyper tag ids condition var hyperTagIdscondition = new MultiScopeCondition(AndOr.Or); foreach (var id in _metadataSet.HyperTagIds ?? new HyperDocumentId[] { }) { hyperTagIdscondition.AddCondition("_id", id.Id); } if (hyperTagIdscondition.ConditionsCount > 0) { mainArgs.DocumentConditions.AddCondition(hyperTagIdscondition); } //if (tagFilterConditions != null) //{ // mainArgs.DocumentConditions.AddCondition(tagFilterConditions); //} }
public async Task RunGenerationAsync(DateTime?from, DateTime?to) { _keepWorking = true; _ctSource = new CancellationTokenSource(); var source = new TaskCompletionSource <bool>(); _completionTask = source.Task; try { _frames = new ConcurrentFixedSizeQueue <List <HeatPoint> >(int.MaxValue); ProtectOriginalMetadataSet(); if (from.HasValue) { _metadataSet.FromDate = from; } if (to.HasValue) { _metadataSet.ToDate = to; } await CountTagsTotalAsync(); if (this.TotalCountProp.Value == 0) { _lastImage = await GetFirstImageForMetadatasetAssetAsync(from); ImageProp.Value = _lastImage.Data; PertcantageProcessedUpdated?.Invoke(100); } var batchSize = 100; var batchesNum = Math.Ceiling((double)TotalCountProp.Value / batchSize); batchesNum = Math.Min(batchesNum, _settings.NumberOfBatchesToProcess); var hyperIds = new List <HyperId>(); for (int i = 0; i < batchesNum; i++) { StatusProp.Value = $"Processing batch {(i + 1)} out of {batchesNum}..."; if (!_keepWorking || _ct.IsCancellationRequested) { return; } var skip = batchSize * i; var findArgs = new FindHyperDocumentsArgs(typeof(HyperTag)) { Skip = skip, Limit = batchSize }; var conditions = await MetaDataSetHelper.GenerateFilterFromMetaDataSetAsync(_hyperStore, _metadataSet); findArgs.DescriptorConditions.AddCondition(conditions.Result); //hyper tag ids condition var hyperTagIdscondition = new MultiScopeCondition(AndOr.Or); foreach (var id in _metadataSet.HyperTagIds ?? new HyperDocumentId[] { }) { hyperTagIdscondition.AddCondition("_id", id.Id); } if (hyperTagIdscondition.ConditionsCount > 0) { findArgs.DocumentConditions.AddCondition(hyperTagIdscondition); } var tagDocs = await _hyperStore.ExecuteAsync(findArgs) ?? new HyperDocument[0]; if (!_keepWorking || _ct.IsCancellationRequested) { return; } var tags = tagDocs.Select(it => it.GetPayload <HyperTag>()).ToArray(); var grouppedBySlice = tags.GroupBy(it => { var item = it.GetElement <IHyperTagHyperIds>(); return(item.HyperId); }).ToArray(); if (!_keepWorking || _ct.IsCancellationRequested) { return; } if (_width == 0 || _height == 0) { var hyperId = grouppedBySlice.First().Key; await UpdateImageDataAsync(hyperId); _globalMatrix = new uint[_height, _width]; ImageProp.Value = _lastImage.Data; if (!_keepWorking || _ct.IsCancellationRequested) { return; } } grouppedBySlice = grouppedBySlice.OrderBy(x => x.Key).ToArray(); // Group by asset first? var groupedByFragment = grouppedBySlice.GroupBy(x => x.Key.FragmentId.Value).ToArray(); foreach (var group in groupedByFragment) { var sliceGroupsOfFragment = group.ToArray(); foreach (var sliceTags in sliceGroupsOfFragment) { await _pauseResetEvent.WaitAsync(); var framePoints = new List <HeatPoint>(); foreach (var tag in sliceTags) { // TODO: Reintegrate RealImage processing logic if (_settings.RenderingMode == RenderingMode.Masks || _settings.RenderingMode == RenderingMode.RealImage) { var tagExtraction = ProcessMaskedTag(tag); if (tagExtraction != null) { ProcessMaskOverlapsIntoMatrix(tagExtraction.Image, tagExtraction.Rect); } } else if (_settings.RenderingMode == RenderingMode.LowerPointOfGeometry) { ProcessGeometryTag(tag, framePoints); } } _frames.Enqueue(framePoints); } if (!_keepWorking || _ct.IsCancellationRequested) { return; } } _lastHyperId = grouppedBySlice.Last().Key; await RerenderAsync(); var tagDocsCount = tagDocs.Count(); ItemsProcessed.Value += tagDocsCount; PertcantageLabel.Value = ((double)100 * ItemsProcessed.Value / TotalCountProp.Value).ToString("0.00", System.Globalization.CultureInfo.InvariantCulture) + "%"; PertcantageProcessedUpdated?.Invoke(100 * tagDocsCount / (double)TotalCountProp.Value); } } catch (Exception ex) { Logger.Instance.Error(this.GetType(), nameof(RunGenerationAsync), ex.Message); } finally { source.SetResult(true); } }
private async Task InitializeMetadatasetEdgeDates() { FilterState.Value.HeatMapMinDate.Value = this.FilterState.Value.MetadataSetMinDate; FilterState.Value.HeatMapMaxDate.Value = this.FilterState.Value.MetadataSetMaxDate; if (_metadataSet != null) { var findArgs = new FindHyperDocumentsArgs(typeof(HyperTag)); var conditions = await MetaDataSetHelper.GenerateFilterFromMetaDataSetAsync(HyperStore, _metadataSet); findArgs.DescriptorConditions.AddCondition(conditions.Result); findArgs.Limit = 1; findArgs.OrderByFields = new OrderByField[] { new OrderByField() { Ascending = true, DescriptorField = true, FieldName = "Elements.UniversalTime" } }; var results = await HyperStore.ExecuteAsync(findArgs); if (results?.Length > 0 == false) { return; } var earliestTag = results[0].GetPayload <HyperTag>(); var earliestDate = earliestTag.GetUniversalDateTimeFromElements(); var lastTagFindArgs = new FindHyperDocumentsArgs(typeof(HyperTag)); lastTagFindArgs.DescriptorConditions.AddCondition(conditions.Result); lastTagFindArgs.OrderByFields = new OrderByField[] { new OrderByField() { Ascending = false, DescriptorField = true, FieldName = "Elements.UniversalTime" } }; lastTagFindArgs.Limit = 1; var latestTag = (await HyperStore.ExecuteAsync(lastTagFindArgs))[0].GetPayload <HyperTag>(); var latestDate = latestTag.GetUniversalDateTimeFromElements(); this.FilterState.Value.MetadataSetMinDate.Value = earliestDate.Value; if (this.FilterState.Value.FilterMinDate.Value == null) { this.FilterState.Value.HeatMapMinDate.Value = earliestDate.Value; } this.FilterState.Value.MetadataSetMaxDate.Value = latestDate.Value; if (FilterState.Value.FilterMaxDate.Value == null) { this.FilterState.Value.HeatMapMaxDate.Value = latestDate.Value; } this.OnMetadatasetEdgeDatesUpdated?.Invoke(earliestDate.Value, latestDate.Value); } }