aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.Web/TangoWebApplication.cs
blob: 137942071ea2f95d99447b5d2f312f69b2991d19 (plain)
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;
using System.Web.Http;
using System.Web.Http.Filters;
using System.Web.Mvc;
using Tango.Core;
using Tango.Logging;
using Tango.Web.Logging;

namespace Tango.Web
{
    public class TangoWebApplication : HttpApplication
    {
        //Create filter
        public class LogExceptionFilterAttribute : ExceptionFilterAttribute
        {
            public override void OnException(HttpActionExecutedContext context)
            {
                LogManager.Default.Log(context.Exception);
            }
        }

        protected virtual void Application_Start()
        {
            LogManager.Default.Categories.Add(LogCategory.Debug);
            LogManager.Default.RegisterLogger(new AzureCloudLogger());
            GlobalConfiguration.Configuration.Filters.Add(new LogExceptionFilterAttribute());

            SynchronizedObservableCollectionConfig.DisableSynchronization = true;

            LogManager.Default.Log("Application Started!");
        }

        protected void Application_Error(object sender, EventArgs e)
        {
            Exception exception = Server.GetLastError();
            if (exception != null)
            {
                LogManager.Default.Log(exception, "Global Exception!");
            }
        }
    }
}
w"> _isEnabled; public bool IsEnabled { get { return _isEnabled; } set { _isEnabled = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); } } private T _state; public T State { get { return _state; } set { _state = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); } } private void MachineOperator_StatusChanged(object sender, MachineStatuses e) { InvalidateRelayCommands(); } public MaintenanceCommand() { TangoIOC.Default.Inject(this); IsEnabled = true; Command = new RelayCommand(Execute, CanExecute); } protected virtual bool CanExecute() { if (!IsEnabled) return false; if (MachineProvider == null) return false; if (!MachineProvider.MachineOperator.CanPrint) return false; return true; } private void Execute() { OnExecute(); } protected abstract void OnExecute(); } }