Пример #1
0
        public async Task <ReportDefinition> LoadReportDefinitionAsync(string name)
        {
            ReportDefinition reportDefinition = await this.Cache.GetOrCreateAsync($"ReportingService:LoadReportDefinitionAsync:{name}", async (entry) =>
            {
                entry.AbsoluteExpirationRelativeToNow = this.Options.DefinitionTimeToLive;
                foreach (var repository in this.Repositories)
                {
                    reportDefinition = await repository.LoadReportDefinitionAsync(name);
                    if (null != reportDefinition)
                    {
                        this.FixFilterDefinitions(reportDefinition.Filters);
                        this.FixFieldDefinitions(reportDefinition.Output);
                        return(reportDefinition);
                    }
                }

                return(null);
            });

            /*
             * need to return the clone of the definition since multiple clients might be
             * accessing the cached instance and modifying it state
             * by cloning we make sure each client gets its own copy of the definition
             */
            return(reportDefinition?.Clone() ?? throw new InvalidOperationException());
        }