-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
142 lines (112 loc) · 4.73 KB
/
Program.cs
File metadata and controls
142 lines (112 loc) · 4.73 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
using JollyWizard.Quantower.CLI.IndicatorDeploy.Helpers;
using Helpers = JollyWizard.Quantower.CLI.IndicatorDeploy.Helpers;
using Setup = JollyWizard.Quantower.Setup;
static void sectionBreak(String? message = null)
{
Console.WriteLine("--------------------------------------------\n");
if (message is not null) Console.WriteLine(message);
Console.WriteLine("Press [Enter] to continue, or [Close Window] or [Ctrl+C] to exit.");
Console.ReadKey();
Console.WriteLine("\n--------------------------------------------\n");
};
/*
* If we don't have the value stored we are going to try to add it via auto-detect.
*/
if (Setup.EnvironmentConfig.Values.QuantowerRoot is null)
{
Console.WriteLine("$(QuantowerRoot) value is not detected. ");
Console.WriteLine("Ensure Quantower is running to auto-detect.");
Console.WriteLine("Value will be saved for future uses.");
sectionBreak();
bool success = Setup.EnvironmentConfig.Setup.RootPath();
if (!success)
{
sectionBreak("QuantowerRoot Detection failed. Deployment Aborted.");
Environment.Exit(-1);
}
else
{
Console.WriteLine($"\tSuccess\n\tDetected Path := {Setup.EnvironmentConfig.Values.QuantowerRoot}");
}
sectionBreak();
}
try
{
String? CustomIndicatorsPath = Setup.Utils.DetectCustomIndicatorsPath() ?? Setup.QuantowerPaths.ConvertRootToCustomIndicators(Setup.EnvironmentConfig.Values.QuantowerRoot);
if (CustomIndicatorsPath == null) throw new Exception("User Indicator Path detection failed.");
if (!Directory.Exists(CustomIndicatorsPath)) throw new Exception(" User Indicator path does not exist: \n\t" + CustomIndicatorsPath);
Console.WriteLine($"Custom Indicator Install Directory: {CustomIndicatorsPath}\n");
sectionBreak("The indicator directory will now open.");
if (!JollyWizard.SystemHelpers.FolderBrowser.ExploreIfExists(CustomIndicatorsPath))
{
throw new Exception("Failed to browse target folder.");
}
}
catch (Exception e)
{
Console.Error.WriteLine("{0} | {1}", "EXCEPTION ERROR: ", e.Message);
sectionBreak("Deployment Aborted");
Environment.Exit(-2);
}
/*
* Copy the files with diagnostics.
*/
try
{
List<String> configFiles = Helpers.Utils.DetectQidConfigFiles();
Console.WriteLine($"The following Deployment Files have been loaded:\n");
foreach (String configFilePath in configFiles)
{
Console.WriteLine($"\t{configFilePath}");
}
Console.WriteLine();
Console.WriteLine("Loading Plans.");
List<CopyPlan> plans = configFiles.SelectMany(configFilePath => Helpers.Utils.ProcessConfigFile(configFilePath)).ToList();
Console.WriteLine($"Plan Count: {plans.Count} \n");
sectionBreak("Plan Diagnostics To Follow:");
foreach (CopyPlan plan in plans)
{
Console.WriteLine($"Plan Definition:\n\t{plan}\n");
Console.WriteLine("Sources Filter Matches:\n");
foreach (String path in plan.SourcesAbsolutePaths ?? new())
{
Console.WriteLine($"\t\t{path}");
}
Console.WriteLine("\n");
Console.WriteLine("\nRelative Paths:\n");
foreach (String path in plan.SourcesRelativePaths ?? new())
{
Console.WriteLine($"\tSource\t{path}");
Console.WriteLine($"\tTarget\t{plan.OutputRelativePath(path)}");
Console.WriteLine();
}
Console.WriteLine("\nCopy Orders:\n");
foreach (CopyOrder co in plan.CreateCopyOrders())
{
Console.WriteLine($"\tSource\t{co.SourcePath}");
if (!co.IsSourceAvailable())
Console.WriteLine("\t*Does Not Exist*");
Console.WriteLine($"\tTarget\t{co.TargetPath}");
if (co.IsTargetConflict())
Console.WriteLine("\t\t*Conflict*");
Console.WriteLine();
}
sectionBreak("Proceed with copy operations?");
foreach (CopyOrder co in plan.CreateCopyOrders())
{
Console.WriteLine($"\tSource\t{co.SourcePath}");
if (!co.IsSourceAvailable())
Console.WriteLine("\t*Does Not Exist*");
Console.WriteLine($"\tTarget\t{co.TargetPath}");
if (co.IsTargetConflict())
Console.WriteLine("\t\t*Conflict*");
bool result = co.Execute(Force:true);
String resultMessage = result ? "Success" : "Fail" ;
Console.WriteLine($"\tCOPY RESULT: {resultMessage}");
Console.WriteLine();
}
}
}
catch (Exception e) { Console.Error.WriteLine("{0}", e.Message); }
Console.WriteLine("PROGRAM COMPLETE");
Console.ReadLine();