-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMachine.cs
More file actions
173 lines (154 loc) · 6.77 KB
/
Copy pathMachine.cs
File metadata and controls
173 lines (154 loc) · 6.77 KB
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
using Newtonsoft.Json.Linq;
using System;
using System.Linq;
namespace KLC_Ex {
public class Machine {
public enum AgentStatus {
Down = 0,
Online = 1,
UserActive = 11,
UserIdle = 12
}
public enum OSProfile {
Other, Server, Mac
}
public string Guid { get; private set; }
public int Status { get; private set; }
public AgentStatus DisplayStatus { get; private set; }
public string OSType { get; private set; }
public OSProfile OSTypeProfile { get; private set; }
public string AgentName { get; private set; }
public string ComputerName { get; private set; }
public string UserCurrent { get; private set; }
public string UserLast { get; private set; }
public string DisplayUser { get; private set; }
public DateTime CheckInFirst { get; private set; }
public DateTime CheckInLast { get; private set; }
public bool CheckInLastMonth { get; private set; }
public DateTime RebootLast { get; private set; }
public bool RebootLastWeek { get; private set; }
public string AgentVersion { get; private set; }
public string AgentNameOnly { get; private set; }
public string MachineGroup { get; private set; }
public string MachineGroupReverse { get; private set; }
public string DomainWorkgroup { get; private set; }
public bool OneClickAccess { get; private set; }
public string SystemSerialNumber { get; private set; }
public string IPAddress { get; private set; }
public string DefaultGateway { get; private set; }
public string DNSServer1 { get; private set; }
public string DNSServer2 { get; private set; }
public string DHCPServer { get; private set; }
public string ConnectionGatewayIP { get; private set; }
public string MacAddr { get; private set; }
public int MachineShowToolTip { get; private set; }
public string MachineToolTipBadge { get; private set; }
public string MachineNote { get; private set; }
public string MachineNoteLink { get; private set; }
public enum Badge
{
Blank,
Note,
FlagRed,
FlagBlue,
FlagGreen,
FlagYellow,
Recycle,
Clock,
Location,
StarYellow,
StarGreen,
StarBlue,
StarRed,
UsePrivate,
MagnifyGlass,
PhoneOrange,
PhoneBlue,
Documentation,
FilingCabinetBlue,
UnknownArrowGreen,
Envelope,
PencilOrange,
PencilBlue,
SpeechBubble,
PersonYellow
};
public Machine(JObject child) {
Guid = (string)child["AgentId"];
Status = (int)child["Online"];
OSType = (string)child["OSType"];
if (OSType == "Mac OS X")
OSTypeProfile = OSProfile.Mac;
else if (OSType.StartsWith("20"))
OSTypeProfile = OSProfile.Server;
else
OSTypeProfile = OSProfile.Other;
AgentName = (string)child["AgentName"];
ComputerName = (string)child["ComputerName"];
UserCurrent = (string)child["CurrentUser"];
UserLast = (string)child["LastLoggedInUser"];
if (child["FirstCheckIn"] != null && child["FirstCheckIn"].Type != JTokenType.Null)
{
CheckInFirst = (DateTime)child["FirstCheckIn"];
}
if (child["LastCheckInTime"] != null && child["LastCheckInTime"].Type != JTokenType.Null) {
CheckInLast = (DateTime)child["LastCheckInTime"];
if ((DateTime.Now - CheckInLast).TotalDays < 32)
CheckInLastMonth = true;
}
if (child["LastRebootTime"] != null && child["LastRebootTime"].Type != JTokenType.Null) {
RebootLast = (DateTime)child["LastRebootTime"];
if ((DateTime.Now - RebootLast).TotalDays < 8)
RebootLastWeek = true;
}
AgentVersion = (string)child["AgentVersion"];
AgentNameOnly = AgentName.Split('.')[0];
MachineGroup = (string)child["MachineGroup"];
MachineGroupReverse = string.Join(".", MachineGroup.Split('.').Reverse());
DomainWorkgroup = (string)child["DomainWorkgroup"];
//Added 2022-03-04
OneClickAccess = (bool)child["OneClickAccess"];
if (OneClickAccess)
{
if (OSType == "Mac OS X" || DomainWorkgroup.Contains("(dc)"))
OneClickAccess = false;
}
SystemSerialNumber = (string)child["SystemSerialNumber"];
IPAddress = (string)child["IPAddress"];
DefaultGateway = (string)child["DefaultGateway"];
DNSServer1 = (string)child["DNSServer1"];
DNSServer2 = (string)child["DNSServer2"];
DHCPServer = (string)child["DHCPServer"];
ConnectionGatewayIP = (string)child["ConnectionGatewayIP"];
MacAddr = (string)child["MacAddr"];
//txtMachines.AppendText(string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}\t{6}\r\n", agentStatus, agentOS, agentName, agentUser, agentCheckInLast, agentRebootLast, agentVersion));
DisplayUser = (UserCurrent == "" ? UserLast : UserCurrent);
DisplayStatus = (AgentStatus)Status;
//if(Status == 1 && UserCurrent != "") //No longer required
//DisplayStatus = AgentStatus.UserActive;
if (child["ShowToolTip"].ToString().Length > 0)
MachineShowToolTip = (int)child["ShowToolTip"];
MachineNote = (string)child["ToolTipNotes"];
if (MachineNote == null)
MachineNote = "";
else
{
if (MachineNote.Trim() == "")
{
MachineShowToolTip = 0;
}
else
{
MachineNote = MachineNote.Trim().Replace(" ", " ");
string[] links = MachineNote.Split("\t\n ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries).Where(s => s.StartsWith("http://") || s.StartsWith("https://") || s.StartsWith("www.")).ToArray();
if (links != null && links.Length > 0)
{
MachineNoteLink = links[0];
MachineNote = MachineNote.Replace(MachineNoteLink, "").Trim();
}
}
}
MachineToolTipBadge = (MachineShowToolTip > 0 ? Enum.GetName(typeof(Badge), MachineShowToolTip) : "");
}
}
}