initial source commit
This commit is contained in:
@@ -0,0 +1,89 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using Disco.Data.Repository;
|
||||
|
||||
namespace Disco.Web
|
||||
{
|
||||
public static class AppConfig
|
||||
{
|
||||
public static bool InitializeDatabase()
|
||||
{
|
||||
// Modified Connection Factory
|
||||
System.Data.Entity.Database.DefaultConnectionFactory = new DiscoDatabaseConnectionFactory(System.Data.Entity.Database.DefaultConnectionFactory);
|
||||
|
||||
if (Disco.Data.Repository.DiscoDatabaseConnectionFactory.DiscoDataContextConnectionString == null)
|
||||
{
|
||||
// Database Connection String not configured - Trigger 'Install'
|
||||
return false;
|
||||
}
|
||||
|
||||
// Migrate Database
|
||||
Disco.Data.Migrations.DiscoDataMigrator.MigrateLatest(true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void InitalizeEnvironment()
|
||||
{
|
||||
using (var dbContext = new DiscoDataContext())
|
||||
{
|
||||
// Initialize Logging
|
||||
Disco.Services.Logging.LogContext.Initalize(dbContext, DiscoApplication.SchedulerFactory);
|
||||
|
||||
// Load Organisation Name
|
||||
DiscoApplication.OrganisationName = dbContext.DiscoConfiguration.OrganisationName;
|
||||
DiscoApplication.MultiSiteMode = dbContext.DiscoConfiguration.MultiSiteMode;
|
||||
|
||||
// Setup Global Proxy
|
||||
DiscoApplication.SetGlobalProxy(dbContext.DiscoConfiguration.ProxyAddress,
|
||||
dbContext.DiscoConfiguration.ProxyPort,
|
||||
dbContext.DiscoConfiguration.ProxyUsername,
|
||||
dbContext.DiscoConfiguration.ProxyPassword);
|
||||
|
||||
// Initialize Expressions
|
||||
BI.Expressions.Expression.InitializeExpressions();
|
||||
|
||||
// Initialize Warranty Providers Plugins
|
||||
Disco.Services.Plugins.Plugins.InitalizePlugins(dbContext);
|
||||
|
||||
// Initialize Scheduled Tasks
|
||||
Disco.Services.Tasks.ScheduledTasks.InitalizeScheduledTasks(dbContext, DiscoApplication.SchedulerFactory);
|
||||
|
||||
// Schedule Immediate Check for Update (if a new version was installed, never updated, last updated over 2 days ago)
|
||||
var currentVersion = Disco.BI.Interop.Community.UpdateCheck.CurrentDiscoVersion();
|
||||
if (dbContext.DiscoConfiguration.InstalledDatabaseVersion == null ||
|
||||
dbContext.DiscoConfiguration.InstalledDatabaseVersion != currentVersion ||
|
||||
dbContext.DiscoConfiguration.UpdateLastCheck == null ||
|
||||
dbContext.DiscoConfiguration.UpdateLastCheck.ResponseTimestamp < DateTime.Now.AddDays(-2))
|
||||
{
|
||||
Disco.BI.Interop.Community.UpdateCheckTask.ScheduleNow();
|
||||
dbContext.DiscoConfiguration.InstalledDatabaseVersion = currentVersion;
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
|
||||
// Setup Attachment Monitor
|
||||
DiscoApplication.DocumentDropBoxMonitor = new BI.DocumentTemplateBI.Importer.DocumentDropBoxMonitor(dbContext, DiscoApplication.SchedulerFactory, HttpContext.Current.Cache);
|
||||
}
|
||||
DiscoApplication.DocumentDropBoxMonitor.StartWatching();
|
||||
DiscoApplication.DocumentDropBoxMonitor.ScheduleCurrentFiles(10);
|
||||
}
|
||||
|
||||
public static void DisposeEnvironment()
|
||||
{
|
||||
if (DiscoApplication.DocumentDropBoxMonitor != null)
|
||||
DiscoApplication.DocumentDropBoxMonitor.Dispose();
|
||||
|
||||
if (DiscoApplication.SchedulerFactory != null)
|
||||
{
|
||||
foreach (var item in DiscoApplication.SchedulerFactory.AllSchedulers.ToArray())
|
||||
{
|
||||
item.Shutdown(false);
|
||||
}
|
||||
}
|
||||
|
||||
Disco.Services.Logging.SystemLog.LogUninitialized();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
using System.IO;
|
||||
using System.Web;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Disco.Web.Extensions.MvcExtensions.Bundles;
|
||||
|
||||
namespace Disco.Web
|
||||
{
|
||||
public class BundleConfig
|
||||
{
|
||||
public static void RegisterBundles()
|
||||
{
|
||||
// Styles - Site Core
|
||||
BundleTable.Add(new Bundle("~/Style/Site", Links.ClientSource.Style.BundleSite_min_css));
|
||||
|
||||
// Styles - Targeted
|
||||
BundleTable.Add(new Bundle("~/Style/Config", Links.ClientSource.Style.Config_min_css));
|
||||
BundleTable.Add(new Bundle("~/Style/Device", Links.ClientSource.Style.Device_min_css));
|
||||
BundleTable.Add(new Bundle("~/Style/Dialog", Links.ClientSource.Style.Dialog_min_css));
|
||||
BundleTable.Add(new Bundle("~/Style/Job", Links.ClientSource.Style.Job_min_css));
|
||||
BundleTable.Add(new Bundle("~/Style/User", Links.ClientSource.Style.User_min_css));
|
||||
BundleTable.Add(new Bundle("~/Style/Credits", Links.ClientSource.Style.Credits_min_css));
|
||||
BundleTable.Add(new Bundle("~/Style/InitialConfig", Links.ClientSource.Style.InitialConfig_min_css));
|
||||
BundleTable.Add(new Bundle("~/Style/jQueryUI/dynatree", Links.ClientSource.Style.jQueryUI.dynatree.ui_dynatree_min_css));
|
||||
BundleTable.Add(new Bundle("~/Style/Shadowbox", Links.ClientSource.Style.Shadowbox_min_css));
|
||||
BundleTable.Add(new Bundle("~/Style/Timeline", Links.ClientSource.Style.Timeline_min_css));
|
||||
|
||||
// Styles - Public Targeted
|
||||
BundleTable.Add(new Bundle("~/Style/Public/UserHeldDevices", Links.ClientSource.Style.Public.UserHeldDevices_min_css));
|
||||
BundleTable.Add(new Bundle("~/Style/Public/UserHeldDevicesNoticeboard", Links.ClientSource.Style.Public.UserHeldDevicesNoticeboard_min_css));
|
||||
|
||||
|
||||
// Scripts - Core
|
||||
#if DEBUG
|
||||
BundleTable.Add(new Bundle("~/ClientScripts/Core", Links.ClientSource.Scripts.Core_js));
|
||||
#else
|
||||
BundleTable.Add(new Bundle("~/ClientScripts/Core", Links.ClientSource.Scripts.Core_min_js));
|
||||
#endif
|
||||
|
||||
// Scripts - Modules
|
||||
#if DEBUG
|
||||
foreach (FileInfo f in new DirectoryInfo(HttpContext.Current.Server.MapPath("~/ClientSource/Scripts/Modules")).EnumerateFiles("*.js", SearchOption.TopDirectoryOnly))
|
||||
BundleTable.Add(new Bundle(string.Format("~/ClientScripts/Modules/{0}", f.Name.Substring(0, f.Name.Length - 3)), f.FullName));
|
||||
#else
|
||||
foreach (FileInfo f in new DirectoryInfo(HttpContext.Current.Server.MapPath("~/ClientSource/Scripts/Modules")).EnumerateFiles("*.min.js", SearchOption.TopDirectoryOnly))
|
||||
BundleTable.Add(new Bundle(string.Format("~/ClientScripts/Modules/{0}", f.Name.Substring(0, f.Name.Length - 7)), f.FullName));
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
|
||||
namespace Disco.Web
|
||||
{
|
||||
public class FilterConfig
|
||||
{
|
||||
public static void RegisterGlobalFilters(GlobalFilterCollection filters)
|
||||
{
|
||||
//filters.Add(new HandleErrorAttribute());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.WebPages;
|
||||
using RazorGenerator.Mvc;
|
||||
|
||||
[assembly: WebActivator.PostApplicationStartMethod(typeof(Disco.Web.App_Start.RazorGeneratorMvcStart), "Start")]
|
||||
|
||||
namespace Disco.Web.App_Start {
|
||||
public static class RazorGeneratorMvcStart {
|
||||
public static void Start() {
|
||||
var engine = new PrecompiledMvcEngine(typeof(RazorGeneratorMvcStart).Assembly) {
|
||||
#if DEBUG
|
||||
UsePhysicalViewsIfNewer = true
|
||||
#else
|
||||
UsePhysicalViewsIfNewer = false
|
||||
#endif
|
||||
};
|
||||
|
||||
ViewEngines.Engines.Insert(0, engine);
|
||||
|
||||
// StartPage lookups are done by WebPages.
|
||||
VirtualPathFactoryManager.RegisterVirtualPathFactory(engine);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Routing;
|
||||
|
||||
namespace Disco.Web
|
||||
{
|
||||
public class RouteConfig
|
||||
{
|
||||
public static void RegisterInstallRoutes(RouteCollection routes)
|
||||
{
|
||||
// Install Route
|
||||
routes.MapRoute(
|
||||
name: "InitialConfig", // Route name
|
||||
url: "{controller}/{action}/{id}", // URL with parameters
|
||||
defaults: new { controller = "InitialConfig", action = "Index", id = UrlParameter.Optional }, // Parameter defaults
|
||||
namespaces: new string[] { "Disco.Web.Controllers" } // Controllers Namespace Only
|
||||
);
|
||||
}
|
||||
|
||||
public static void RegisterRoutes(RouteCollection routes)
|
||||
{
|
||||
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
|
||||
|
||||
// Device Route
|
||||
routes.MapRoute(
|
||||
name: "Device", // Route name
|
||||
url: "Device/{action}/{id}", // URL with parameters
|
||||
defaults: new { controller = "Device", action = "Index", id = UrlParameter.Optional }, // Parameter defaults
|
||||
namespaces: new string[] { "Disco.Web.Controllers" } // Controllers Namespace Only
|
||||
);
|
||||
// Search Route
|
||||
routes.MapRoute(
|
||||
name: "SearchQuery",
|
||||
url: "Search/Query/{SearchQuery}",
|
||||
defaults: new { controller = "Search", action = "Query", SearchQuery = UrlParameter.Optional }
|
||||
);
|
||||
// User Route
|
||||
routes.MapRoute(
|
||||
name: "User", // Route name
|
||||
url: "User/{action}/{id}", // URL with parameters
|
||||
defaults: new { controller = "User", action = "Index", id = UrlParameter.Optional }, // Parameter defaults
|
||||
namespaces: new string[] { "Disco.Web.Controllers" } // Controllers Namespace Only
|
||||
);
|
||||
|
||||
// Plugin Resources Route
|
||||
routes.MapRoute(
|
||||
name: "Plugin_Resources", // Route name
|
||||
url: "Plugin/{PluginId}/Resources/{*res}", // URL with parameters
|
||||
defaults: new { controller = "PluginWebHandler", action = "Resource" }, // Parameter defaults
|
||||
namespaces: new string[] { "Disco.Web.Controllers" } // Controllers Namespace Only
|
||||
);
|
||||
// Plugin Route
|
||||
routes.MapRoute(
|
||||
name: "Plugin", // Route name
|
||||
url: "Plugin/{PluginId}/{PluginAction}", // URL with parameters
|
||||
defaults: new { controller = "PluginWebHandler", action = "Index" }, // Parameter defaults
|
||||
namespaces: new string[] { "Disco.Web.Controllers" } // Controllers Namespace Only
|
||||
);
|
||||
|
||||
// Job Route
|
||||
routes.MapRoute(
|
||||
name: "Job", // Route name
|
||||
url: "{controller}/{action}/{id}", // URL with parameters
|
||||
defaults: new { controller = "Job", action = "Index", id = UrlParameter.Optional }, // Parameter defaults
|
||||
namespaces: new string[] { "Disco.Web.Controllers" } // Controllers Namespace Only
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web.Http;
|
||||
|
||||
namespace Disco.Web
|
||||
{
|
||||
public static class WebApiConfig
|
||||
{
|
||||
public static void Register(HttpConfiguration config)
|
||||
{
|
||||
// Migrate to WebAPI Eventually...
|
||||
|
||||
|
||||
//config.Routes.MapHttpRoute(
|
||||
// name: "DefaultApi",
|
||||
// routeTemplate: "api/{controller}/{id}",
|
||||
// defaults: new { id = RouteParameter.Optional }
|
||||
//);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user