private async Task <ReportData> GetReportDataAsync() { var provider = new ReportDataProvider(); var data = await provider.GetReportDataAsync(Report.ReportId); return(data); }
public async Task VerifyTestDownloadAndSerialization(string reportId) { var provider = new ReportDataProvider(); var result = await provider.GetReportDataAsync(reportId); Assert.That(result, Is.Not.Null, "Report data sollte nicht null sein."); }
public async Task LoadAsync() { var reportProvider = new ReportDataProvider(); LoaderText = "Daten werden geladen ..."; var reportData = await CachingLoader.GetCachedOrLoadAsync(async() => await reportProvider.GetReportDataAsync(ReportId), false, "Cache", "Reports", $"{ReportId}.json"); ReportData = reportData; LoaderText = $"{reportData.fights.Length} Kämpfe enthalten."; }
private DataTable GetGoalsData(Guid contactId) { ReportDataProvider reportDataProvider = this.GetReportDataProvider(); Assert.IsNotNull((object)reportDataProvider, "provider should not be null"); return(reportDataProvider.GetData("collection", new ReportDataQuery(this.goalsQueryBuilder.Build()) { Parameters = { { "@contactId", (object)contactId } } }, new CachingPolicy() { NoCache = true }).GetDataTable()); }
public MessageReportController(IEmailLandingPagesRepository emailLandingPagesRepository, IContactsStatesRepository contactsStatesRepository, IMessageStatisticsService messageStatisticsService, SortParameterFactory sortParameterFactory) { Assert.ArgumentNotNull(emailLandingPagesRepository, "emailLandingPagesRepository"); Assert.ArgumentNotNull(contactsStatesRepository, "contactsStatesRepository"); Assert.ArgumentNotNull(sortParameterFactory, "sortParameterFactory"); this.emailLandingPagesRepository = emailLandingPagesRepository; this.contactsStatesRepository = contactsStatesRepository; this.messageStatisticsService = messageStatisticsService; this.sortParameterFactory = sortParameterFactory; this.bestPagesMappings = new Dictionary <string, string>(); this.bestPagesMappings.Add("ValuePerVisit", "Most Relevant"); this.bestPagesMappings.Add("Value", "Most Valuable"); this.bestPagesMappings.Add("Visits", "Most Clicked"); this.bestPagesMappings.Add("Attention", "Most Attention"); this.bestPagesMappings.Add("Potential", "Most Potential"); ItemUtilExt itemUtilExt = CoreFactory.Instance.GetItemUtilExt(); ReportDataProvider reportDataProvider = Sitecore.Configuration.Factory.CreateObject("reporting/dataProvider", true) as ReportDataProvider; this.contactsStatesDataSource = new Sitecore.Support.Modules.EmailCampaign.Statistics.DataSources.ContactsStatesDataSource(EcmFactory.GetDefaultFactory(), CoreFactory.Instance, new ReportDataProviderExt(reportDataProvider, itemUtilExt), RecipientRepository.GetDefaultInstance()); }
private async Task LoadImplAsync(IProgress <string> progress, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); await Task.Delay(2000); cancellationToken.ThrowIfCancellationRequested(); var provider = new ReportDataProvider(); progress.Report($"Kampfdaten für {BossName} werden geladen."); var reportData = await provider.GetReportDataAsync(ReportId); var matchingFights = reportData.fights.Where(d => d.name.ToUpper() == BossName.ToUpper()).ToList(); progress.Report($"{matchingFights.Count} Kämpfe gefunden."); await Task.Delay(1000); cancellationToken.ThrowIfCancellationRequested(); var templates = Configuration.Templates.ToList(); progress.Report($"{templates.Count} Auswertungsfelder gefunden."); await Task.Delay(1000); Dictionary <string, object> tokenValueByPlayer = new Dictionary <string, object>(); Dictionary <string, DynamicGridCell> cellByPlayer = new Dictionary <string, DynamicGridCell>(); var players = new HashSet <string>(reportData.friendlies.Select(s => s.name)); foreach (var player in players) { var playerCell = new DynamicGridCell(); playerCell["Spieler"] = player; cellByPlayer.Add(player, playerCell); } foreach (var template in templates) { tokenValueByPlayer.Clear(); cancellationToken.ThrowIfCancellationRequested(); var parser = ParserFactory.GetParser(template.ParserTypeName); parser.SetTemplate(template.Template); // var warcraftLogsContentParser = new GenericDamageTakenParser(); // await warcraftLogsContentParser.GetResultsAsync(new FightContextData()); // parser = warcraftLogsContentParser; foreach (var fight in matchingFights) { cancellationToken.ThrowIfCancellationRequested(); var fightContext = new FightContextData() { Fight = fight, ReportId = ReportId }; await parser.ApplyResultMappingAsync(cancellationToken, fightContext, tokenValueByPlayer, template.FieldWildcard); } foreach (var playerWithTokenValue in tokenValueByPlayer) { cancellationToken.ThrowIfCancellationRequested(); DynamicGridCell cell; if (cellByPlayer.TryGetValue(playerWithTokenValue.Key, out cell)) { cell[template.FieldWildcard] = playerWithTokenValue.Value; } } } var cells = new List <KeyValuePair <string, DynamicGridCell> >(); foreach (var cell in cellByPlayer) { cells.Add(cell); } await Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(() => ResultData.AddRange(cells.Select(s => s.Value)))); }
public HealthStatus ProcessAlerts(IDevice device, IEnumerable<Alert> alerts) { HealthStatus formerStatus = device.CurrentStatus; HealthStatus retval = device.CurrentStatus; var alertStatusEvents = new List<AlertStatusChangeEvent>(); if (alerts.Any()) { using ( var ctx = ContextRegistry.NamedContextsFor( ContextRegistry.CreateNamed(ContextRegistry.Kind, UnikContextTypes.UnikTenantContextResourceKind))) { var batches = alerts.InBatchesOf(50); foreach (var batch in batches) { //using (var dc = DocumentStoreLocator.ContextualResolve()) //{ foreach (var it in batch) { int matchHash = it.CreateMatchHash(); /* var matches = dc.Query<Alert>().Where(a => a.MatchHash == matchHash && a.Status != AlertStatus.Closed); */ var querySpecification = new QuerySpecification() { Where = new Filter { Rules = new Comparison[] { new Comparison { Data = matchHash, Field = "MatchHash", Test = Test.Equal }, new Comparison { Data = AlertStatus.Closed, Field = "Status", Test = Test.NotEqual } } } }; var matches = ReportDataProvider.GetFromRepository<Alert>(querySpecification); bool isDuplicate = false; foreach (var candidate in matches) { if (candidate.RelatedDevice == it.RelatedDevice && it.Kind == candidate.Kind && it.AlertHealthLevel == candidate.AlertHealthLevel) { isDuplicate = true; break; } } if (!isDuplicate) { it.MatchHash = matchHash; if (it.AlertHealthLevel > retval) { retval = it.AlertHealthLevel; device.CurrentStatus = retval; alertStatusEvents.Add(new AlertStatusChangeEvent { Identifier = it.Identifier, AlertHealthLevel = it.AlertHealthLevel, AlertTitle = it.AlertTitle, Kind = it.Kind, KindDesc = it.Kind.EnumName().SpacePascalCase(), DeviceTags = it.Tags, Message = it.Message, RelatedDevice = it.RelatedDevice, RelatedDeviceName = it.RelatedDeviceName, Resolved = false, TimeGenerated = it.TimeGenerated, StaleAlertTime = (it.AlertHealthLevel == HealthStatus.Red) ? it.TimeGenerated + TimeSpan.FromHours(6.0) : it.TimeGenerated + TimeSpan.FromHours(24.0), LongestAssignmentTime = TimeSpan.FromSeconds(0.0) }); } ReportDataProvider.StoreInRepository<Alert>(it); //dc.Store(it); } } //dc.SaveChanges(); //} } } } if (formerStatus != retval) { using ( var ctx = ContextRegistry.NamedContextsFor(ContextRegistry.CreateNamed(ContextRegistry.Kind, UnikContextTypes. UnikWarehouseContextResourceKind))) { //using (var dc = DocumentStoreLocator.ContextualResolve()) //{ var deviceHealthChangeEvt = new DeviceHealthStatusEvent { DeviceId = device.Id, DeviceName = device.Name, From = formerStatus, To = retval, DeviceTags = device.Tags, DeviceTagHashes = DeviceHealthStatusEvent.ConvertTagsToHashs(device.Tags), TimeChanged = DateTime.UtcNow }; //dc.Store(deviceHealthChangeEvt); ReportDataProvider.StoreInRepository<DeviceHealthStatusEvent>(deviceHealthChangeEvt); var batches = alertStatusEvents.InBatchesOf(50); foreach (var batch in batches) { foreach (var se in batch) { //dc.Store(se); ReportDataProvider.StoreInRepository<AlertStatusChangeEvent>(se); } //dc.SaveChanges(); } //} } } return retval; }