blob: c680f4b908956f563f020ba96f52ef41b3f2303c (
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
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
|
using System;
using System.Data.Entity;
using System.Linq;
using Tango.BL;
using Tango.BL.Entities;
using Tango.Core.DI;
using Tango.Integration.Operation;
using Tango.PMR.Diagnostics;
using Tango.PPC.Common;
using Tango.PPC.Common.Application;
using Tango.PPC.Common.Connection;
using Tango.PPC.Common.Notifications;
using Tango.Settings;
using Tango.SharedUI;
namespace Tango.PPC.UI.Dialogs
{
public class GeneralInformationViewVM : DialogViewVM
{
[TangoInject]
public IMachineProvider MachineProvider { get; set; }
[TangoInject]
public IPPCApplicationManager ApplicationManager { get; set; }
private PPCSettings _settings;
/// <summary>
/// Gets the main PPC settings.
/// </summary>
public PPCSettings Settings
{
get
{
if (_settings == null)
{
_settings = SettingsManager.Default.GetOrCreate<PPCSettings>();
}
return _settings;
}
private set { _settings = value; }
}
public Site CurrentSite { get; set; }
public String SiteName
{
get { return CurrentSite == null ? "" : CurrentSite.Name; }
}
public GeneralInformationViewVM( IMachineProvider provider, IPPCApplicationManager appManager)
{
MachineProvider = provider;
ApplicationManager = appManager;
InitSite();
}
public async void InitSite()
{
if (CurrentSite == null)
{
var machine = MachineProvider.Machine;
if (machine != null && !String.IsNullOrEmpty(machine.SiteGuid))
{
using (ObservablesContext db = ObservablesContext.CreateDefault())
{
var site = (await db.Sites.Where(x => x.Guid == machine.SiteGuid).ToListAsync()).FirstOrDefault();
CurrentSite = site;
RaisePropertyChanged(nameof(SiteName));
}
}
}
}
}
}
|