-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
63 lines (51 loc) · 2.51 KB
/
Program.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
namespace ColleagueTracker
{
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
class Program
{
static void Main(string[] args)
{
// Read and validate configurations
ColleagueTrackerConfig config = ColleagueTrackerConfig.GetConfig();
if(config.Teams == null || config.Teams.Count == 0)
{
Console.WriteLine("No configurations found. Create <ColleagueTracker> section in ColleagueTracker.exe.config and try again.");
return;
}
ADServices.LdapPath = config.LdapPath;
ADServices.AlternativeLdapPath = config.AlternativeLdapPath != null && config.AlternativeLdapPath.Length > 0 ? config.AlternativeLdapPath : null;
ADServices.AlternativeLdapPath2 = config.AlternativeLdapPath2 != null && config.AlternativeLdapPath2.Length > 0 ? config.AlternativeLdapPath2 : null;
Stopwatch sw = new Stopwatch(); sw.Start();
// Process each of the configurations
List<UserInfo> teamMembers = new List<UserInfo>();
foreach (TeamConfigurationElement item in config.Teams)
{
Console.ForegroundColor = ConsoleColor.Cyan;
Console.WriteLine();
Console.Write("Team '{0}' ", item.Name);
Console.ForegroundColor = ConsoleColor.Gray;
// get all direct reports of the different managers
string[] managers = item.Managers.Split(',');
foreach (string manager in managers)
{
teamMembers.AddRange(ADServices.GetDirectReports(manager));
}
teamMembers = teamMembers.OrderBy(m => m.Manager).ToList();
Console.WriteLine();
Console.WriteLine("Team '{0}' has {1} members.", item.Name, teamMembers.Count);
// now check the deltas
string userFilename = string.Format("users_{0}.json", item.Name);
string deltasFilename = string.Format("deltas_{0}.json", item.Name);
int changes = UserStore.StoreAndCompare(userFilename, deltasFilename, teamMembers);
Console.WriteLine("Number of changes: {0}", changes);
teamMembers.Clear();
}
sw.Stop();
Console.WriteLine("\nDone. Elapsed time: {0} seconds. Press any key.", sw.ElapsedMilliseconds/1000);
Console.ReadLine();
}
}
}