-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.xaml.cs
70 lines (60 loc) · 2.17 KB
/
App.xaml.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
using CAR;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Timers;
using System.Windows;
namespace RemoteProcedure
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
protected override void OnStartup(StartupEventArgs e)
{
var userController = new UserController();
userController.Initialize();
var timer = new Timer();
timer.Interval = 25000;
timer.Elapsed += OnTimedEvent;
timer.AutoReset = true;
timer.Enabled = true;
}
private void OnTimedEvent(object sender, ElapsedEventArgs e)
{
if (ApplicationState.GetValue<bool>("IsImpolite")) return;
var context = new CarContext();
var userInfo = ApplicationState.GetValue<UserMetadata>("Metadata");
long badgeNum = userInfo.BadgeNumber;
var user = context.Users.Where(u => u.USER_PIV_BADGE_NUM == badgeNum);
if (user.Any())
{
var curUser = user.First();
var apo = context.Pcos.Where(u => u.APO_PCO_PIV_BADGE_NUM == curUser.APO_PCO_PIV_BADGE_NUM);
if (curUser.OUTSTANDING_ASSET.HasValue
&& curUser.OUTSTANDING_ASSET.Value)
{
if ((apo?.First().CAN_SEND_REMINDER ?? true) && curUser.LAST_REMINDER != null && curUser.LAST_REMINDER < DateTime.Now)
{
Current.Dispatcher.BeginInvoke((Action)OnMainThread);
ApplicationState.SetValue("IsImpolite", true);
}
else
Current.Dispatcher.BeginInvoke((Action)OpenPoliteReminder);
}
}
}
private void OpenPoliteReminder()
{
new RemoteCall().Show();
}
private void OnMainThread()
{
new ImpoliteReminder().Show();
}
}
}