Beispiel #1
0
        public static IExtendedBuffer CreateExtendedBuffer(NexusDataType dataType, int length)
        {
            var type = typeof(ExtendedBuffer <>).MakeGenericType(new Type[] { NexusUtilities.GetTypeFromNexusDataType(dataType) });

            return((IExtendedBuffer)Activator.CreateInstance(type, length));
        }
Beispiel #2
0
        private void AggregateProject(ClaimsPrincipal user,
                                      string databaseFolderPath,
                                      string projectId,
                                      DateTime date,
                                      AggregationSetup setup,
                                      AggregationInstruction instruction,
                                      CancellationToken cancellationToken)
        {
            foreach (var(registration, aggregationChannels) in instruction.DataReaderToAggregationsMap)
            {
                using var dataReader = _databaseManager.GetDataReader(user, registration);

                // find reader configurations
                foreach (var configuration in setup.ReaderConfigurations
                         .Where(configuration => configuration.ProjectId == projectId))
                {
                    var tmpRegistration = new DataReaderRegistration()
                    {
                        RootPath     = configuration.DataReaderRootPath,
                        DataReaderId = configuration.DataReaderId
                    };

                    if (dataReader.Registration.Equals(tmpRegistration))
                    {
                        dataReader.OptionalParameters = configuration.Parameters;
                        break;
                    }
                }

                // get files
                if (!dataReader.IsDataOfDayAvailable(projectId, date))
                {
                    return;
                }

                // project
                var container = _databaseManager.Database.ProjectContainers.FirstOrDefault(container => container.Id == projectId);

                if (container == null)
                {
                    throw new Exception($"The requested project '{projectId}' could not be found.");
                }

                var targetDirectoryPath = Path.Combine(databaseFolderPath, "DATA", WebUtility.UrlEncode(container.Id), date.ToString("yyyy-MM"), date.ToString("dd"));

                // for each channel
                foreach (var aggregationChannel in aggregationChannels)
                {
                    cancellationToken.ThrowIfCancellationRequested();

                    try
                    {
                        var dataset = aggregationChannel.Channel.Datasets.First();

                        NexusUtilities.InvokeGenericMethod(this, nameof(this.OrchestrateAggregation),
                                                           BindingFlags.Instance | BindingFlags.NonPublic,
                                                           NexusUtilities.GetTypeFromNexusDataType(dataset.DataType),
                                                           new object[]
                        {
                            targetDirectoryPath,
                            dataReader,
                            dataset,
                            aggregationChannel.Aggregations,
                            date,
                            setup.Force,
                            cancellationToken
                        });
                    }
                    catch (TaskCanceledException)
                    {
                        throw;
                    }
                    catch (Exception ex)
                    {
                        _logger.LogError(ex.GetFullMessage());
                    }
                }
            }
        }