forked from boldreports/aspnet-mvc-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Global.asax.cs
87 lines (82 loc) · 3.35 KB
/
Global.asax.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Http;
using System.Web.Mvc;
using System.Web.Optimization;
using System.Web.Routing;
using Bold.Licensing;
using BoldReports.Web;
using Newtonsoft.Json;
using BoldReports.Base.Logger;
using System.Reflection;
namespace ReportsMVCSamples
{
public class MvcApplication : System.Web.HttpApplication
{
protected void Application_Start()
{
System.Web.Helpers.AntiForgeryConfig.UniqueClaimTypeIdentifier = System.Security.Claims.ClaimTypes.NameIdentifier;
string License = File.ReadAllText(Server.MapPath("BoldLicense.txt"), Encoding.UTF8);
log4net.GlobalContext.Properties["LogPath"] = this.GetAppDataFolderPath();
BoldReports.Base.Logger.LogExtension.RegisterLog4NetConfig();
BoldLicenseProvider.RegisterLicense(License, bool.Parse(System.Configuration.ConfigurationManager.AppSettings["IsOfflineLicense"]));
ReportConfig.DefaultSettings = new ReportSettings()
{
MapSetting = this.GetMapSettings()
}.RegisterExtensions(this.GetDataExtension());
AreaRegistration.RegisterAllAreas();
GlobalConfiguration.Configure(WebApiConfig.Register);
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
}
private List<string> GetDataExtension()
{
var extensions = !string.IsNullOrEmpty(System.Configuration.ConfigurationManager.AppSettings["ExtAssemblies"]) ? System.Configuration.ConfigurationManager.AppSettings["ExtAssemblies"] : string.Empty;
try
{
var ExtNames = new List<string>(extensions.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries));
List<string> ExtCollections = new List<string>();
ExtNames.ForEach(Extension => ExtCollections.Add(System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "bin", Extension + ".dll")));
return ExtCollections;
}
catch (Exception ex)
{
LogExtension.LogError("Failed to Load Data Extension", ex, MethodBase.GetCurrentMethod());
}
return null;
}
public string GetAppDataFolderPath()
{
try
{
return System.IO.Path.GetFullPath(AppDomain.CurrentDomain.BaseDirectory );
}
catch
{
return null;
}
}
private BoldReports.Web.MapSetting GetMapSettings()
{
try
{
string basePath = HttpContext.Current.Server.MapPath("~/Scripts");
return new MapSetting()
{
ShapePath = basePath + "\\ShapeData\\",
MapShapes = JsonConvert.DeserializeObject<List<MapShape>>(System.IO.File.ReadAllText(basePath + "\\ShapeData\\mapshapes.txt"))
};
}
catch (Exception ex)
{
LogExtension.LogError("Failed to Load Map Settings", ex, MethodBase.GetCurrentMethod());
}
return null;
}
}
}