示例#1
0
 // This method gets called by the runtime. Use this method to add services to the container.
 public void ConfigureServices(IServiceCollection services)
 {
     // Add framework services.
     services.AddMvc();
     services.AddMvcCore(option =>
     {
         JilFormatter.ReplaceFormatter(option);
     });
 }
示例#2
0
        public void RunReport(TenantInfo tenant, long reportId, string reportName)
        {
            using (tenant.GetTenantAdminContext( ))
                using (new MemoryGuard(2 * TenantHealthHelpers.OneGb, ClearSelectedCaches))
                    using (new MemoryGuard(3 * TenantHealthHelpers.OneGb, TenantHealthHelpers.ClearAllCaches))
                        using (new MemoryLogger(new KeyValuePair <string, object>("Tenant", tenant.TenantName), new KeyValuePair <string, object>("Report Id", reportId)))
                        {
                            ReportController controller = new ReportController( );

                            ReportSettings settings = new ReportSettings
                            {
                                RequireFullMetadata = true,
                                InitialRow          = 0,
                                PageSize            = 1,
                                SupportPaging       = true
                            };


                            HttpResponseMessage result = controller.RunReport(reportId, settings);

                            if (result == null)
                            {
                                throw new Exception("Null HttpResponseMessage");
                            }
                            if (result.StatusCode != HttpStatusCode.OK)
                            {
                                throw new Exception($"HttpStatusCode was {result.StatusCode}");
                            }
                            if (result.Content == null)
                            {
                                throw new Exception("Null HttpResponseMessage.Content");
                            }

                            Task <string> asyncTask = result.Content.ReadAsStringAsync( );
                            asyncTask.Wait( );
                            string responseString = asyncTask.Result;

                            ReportResult reportResult = JSON.Deserialize <ReportResult>(responseString, JilFormatter.GetDefaultOptions( ));

                            Assert.That(reportResult, Is.Not.Null, "result");
                            Assert.That(reportResult.Metadata, Is.Not.Null, "Metadata");
                            Assert.That(reportResult.Metadata.ReportColumns, Is.Not.Null, "ReportColumns");
                            Assert.That(reportResult.Metadata.ReportColumns.Count, Is.GreaterThan(0), "ReportColumns.Count");
                            Assert.That(reportResult.Metadata.InvalidReportInformation, Is.Not.Null, "InvalidReportInformation missing");
                            Assert.That(reportResult.Metadata.InvalidReportInformation ["nodes"], Is.Null, "Report has invalid nodes");
                            Assert.That(reportResult.Metadata.InvalidReportInformation ["columns"], Is.Null, "Report has invalid columns");
                            Assert.That(reportResult.Metadata.InvalidReportInformation ["conditions"], Is.Null, "Report has invalid conditions");
                        }
        }