This repository was archived by the owner on Feb 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
92 lines (86 loc) · 3.54 KB
/
Program.cs
File metadata and controls
92 lines (86 loc) · 3.54 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
using BoxFileLoader.Box;
using BoxFileLoader.FileSystem;
using System;
using System.Collections.Generic;
using System.Diagnostics;
namespace BoxFileLoader
{
internal class Program
{
private static void Main(string[] args)
{
var stopwatch = new Stopwatch();
try
{
Console.WriteLine("BoxFileLoader application");
Console.WriteLine("Starting on " + DateTime.Now.ToLongTimeString());
if (args.Length == 0)
{
HelpInformation.Intro();
return;
}
var access = new Access(new AccessConfig());
if (args[0].Equals("init", StringComparison.OrdinalIgnoreCase) && HelpInformation.Init(args))
{
var parentFolderId = access.GetFolderId(args[1]);
var names = new FileReader().Read(args[2]);
foreach (var name in names)
{
access.Init(name, parentFolderId, args[3]);
Console.WriteLine("Wrote to " + name);
}
}
else if (args[0].Equals("unlock", StringComparison.OrdinalIgnoreCase) && HelpInformation.Unlock(args))
{
var parentFolderId = access.GetFolderId(args[1]);
var folders = access.GetFolderIds(parentFolderId);
var submissionFolderIds = new Dictionary<string, string>();
foreach (var folder in folders)
{
Console.WriteLine("Getting information for folder " + folder.Name);
submissionFolderIds.Add(access.GetFolderName(folder.Id, "Submissions"), folder.Name);
}
Console.WriteLine("Unlocking folders");
stopwatch.Start();
foreach (var id in submissionFolderIds)
{
_ = access.UnlockById(id.Key, id.Value);
}
}
else if (args[0].Equals("lock", StringComparison.OrdinalIgnoreCase) && HelpInformation.Lock(args))
{
var parentFolderId = access.GetFolderId(args[1]);
var folders = access.GetFolderIds(parentFolderId);
var submissionFolderIds = new List<string>();
foreach (var folder in folders)
{
Console.WriteLine("Getting information for folder " + folder.Name);
submissionFolderIds.Add(access.GetFolderName(folder.Id, "Submissions"));
}
Console.WriteLine("Locking folders");
stopwatch.Start();
foreach (var id in submissionFolderIds)
{
_ = access.LockById(id);
}
}
else
{
HelpInformation.Intro();
}
}
catch (Exception e)
{
Console.WriteLine(e);
}
finally
{
stopwatch.Stop();
Console.WriteLine("Ending on " + DateTime.Now.ToLongTimeString());
Console.WriteLine("Duration: " + stopwatch.Elapsed.TotalSeconds + " seconds");
Console.WriteLine("Press enter to continue....");
Console.ReadLine();
}
}
}
}