コード例 #1
0
 /// <summary>
 /// Overrides to response html content when accessing the "http://host/api/barcode" url in the browser.
 /// </summary>
 /// <param name="re">The request parameters</param>
 /// <returns>The barcode image</returns>
 public override IActionResult Get([FromQuery] BarCodeRequest re)
 {
     if (C1Controller.IsIntroductionRequest(this))
     {
         return(C1Controller.GetIntroductionPageResult(this, GetBarcode()));
     }
     return(base.Get(re));
 }
コード例 #2
0
 /// <summary>
 /// Overrides to response html content when accessing the "http://host/api/report" url in the browser.
 /// </summary>
 /// <returns>The html content.</returns>
 public override IActionResult GetCatalogInfo(string path, bool recursive = false)
 {
     if (C1Controller.IsIntroductionRequest(this))
     {
         return(C1Controller.GetIntroductionPageResult(this, GetReport()));
     }
     return(base.GetCatalogInfo(path, recursive));
 }
コード例 #3
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();

            app.UseStaticFiles();

            // do not change the name of defaultCulture
            var defaultCulture = "en-US";
            IList <CultureInfo> supportedCultures = new List <CultureInfo>
            {
                new CultureInfo(defaultCulture)
            };

            app.UseRequestLocalization(new RequestLocalizationOptions
            {
                DefaultRequestCulture = new RequestCulture(defaultCulture),
                SupportedCultures     = supportedCultures,
                SupportedUICultures   = supportedCultures
            });

            app.UseMvc();

            // Anything unhandled
            app.Run(context =>
            {
                var defaultPage = PageTemplate.IsJPCulture ? "/default.ja.html" : "/default.html";
                context.Response.Redirect(context.Request.PathBase + defaultPage);
                return(Task.FromResult(0));
            });

            app.UseStorageProviders()
            .AddDiskStorage("ExcelRoot", Path.Combine(env.WebRootPath, "ExcelRoot"))
            .AddDiskStorage("PdfRoot", Path.Combine(env.WebRootPath, "PdfRoot"));

            var ssrsUrl      = Configuration["AppSettings:SsrsUrl"];
            var ssrsUserName = Configuration["AppSettings:SsrsUserName"];
            var ssrsPassword = Configuration["AppSettings:SsrsPassword"];

            app.UseReportProviders()
            .AddFlexReportDiskStorage("ReportsRoot", Path.Combine(env.WebRootPath, "ReportsRoot"))
            .AddSsrsReportHost("c1ssrs", ssrsUrl, new System.Net.NetworkCredential(ssrsUserName, ssrsPassword));

            var oneDriveAccessToken = Configuration["AppSettings:OneDriveAccessToken"];

            app.UseStorageProviders().AddOneDriveStorage("OneDrive", oneDriveAccessToken);

            string[] scopes          = { DriveService.Scope.Drive };
            string   applicationName = "C1WebApi";

            // Azure storage
            app.UseStorageProviders().AddAzureStorage("Azure", Configuration["AppSettings:AzureStorageConnectionString"]);

            // please uncomment this line when you want to test GoogleDrive service.
            // Google storage
            //app.UseStorageProviders().AddGoogleDriveStorage("GoogleDrive", GetUserCredential(scopes), applicationName);

            // Dropbox storage
            app.UseStorageProviders().AddDropBoxStorage("DropBox", Configuration["AppSettings:DropBoxStorageAccessToken"], applicationName);

            // AWS storage
            var    aWSAccessToken = Configuration["AppSettings:AWSStorageAccessToken"];
            var    secretKey      = Configuration["AppSettings:AWSStorageSecretKey"];
            var    bucketName     = Configuration["AppSettings:AWSStorageBucketName"];
            string region         = "us-east-1";

            app.UseStorageProviders().AddAWSStorage("AWS", aWSAccessToken, secretKey, bucketName, region);

            app.UseDataProviders()
            .AddItemsSource("Sales", () => Sale.GetData(10).ToList())
            .AddItemsSource("Orders", () => CustomerOrder.GetOrderData(20).ToList())
            .Add("Nwind", new SqlDataProvider(GetConnectionString(env)));

            var dataPath = Path.Combine(env.WebRootPath, "Data");

            app.UseDataEngineProviders()
            .AddDataEngine("complex10", () =>
            {
                return(ProductData.GetData(100000));
            })
            .AddDataEngine("complex50", () =>
            {
                return(ProductData.GetData(500000));
            })
            .AddDataEngine("complex100", () =>
            {
                return(ProductData.GetData(1000000));
            })
            .AddDataSource("dataset10", () => ProductData.GetData(100000).ToList())
            .AddDataSource("dataset50", () => ProductData.GetData(500000).ToList())
            .AddDataSource("dataset100", () => ProductData.GetData(1000000).ToList())
            .AddCube("cube",
                     @"Data Source=http://ssrs.componentone.com/OLAP/msmdpump.dll;Provider=msolap;Initial Catalog=AdventureWorksDW2012Multidimensional",
                     "Adventure Works");

            C1Controller.CacheDataEngineDataKey(app);
        }