Skip to content

Commit 006dd80

Browse files
committed
Updated DeployClient application to use new response structure.
1 parent d7de78e commit 006dd80

File tree

2 files changed

+42
-17
lines changed

2 files changed

+42
-17
lines changed

DeployClient/API.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public static void AddPackageAsync(string sessionGuid, Stream stream, string fil
9292
}
9393
}
9494

95-
public static bool Install(string sessionGuid, out Dictionary<string, dynamic> response)
95+
public static bool Install(string sessionGuid, out SortedList<string, dynamic> response)
9696
{
9797
string endpoint = string.Format("Remote/Install?sessionGuid={0}", sessionGuid);
9898

@@ -112,7 +112,7 @@ public static bool Install(string sessionGuid, out Dictionary<string, dynamic> r
112112
{
113113
success = true;
114114
string json = httpResponse.Content.ReadAsStringAsync().Result;
115-
response = jsonSer.Deserialize<Dictionary<string, dynamic>>(json);
115+
response = jsonSer.Deserialize<SortedList<string, dynamic>>(json);
116116
}
117117
}
118118
catch (Exception ex)

DeployClient/Program.cs

+40-15
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ static void Main(string[] args)
145145
JavaScriptSerializer jsonSer = new JavaScriptSerializer();
146146

147147
// Start.
148-
Dictionary<string, dynamic> results = null;
148+
SortedList<string, dynamic> results = null;
149149

150150
if (!API.Install(sessionGuid, out results))
151151
{
@@ -172,19 +172,16 @@ static void Main(string[] args)
172172
if (response.ContainsKey("Response"))
173173
{
174174
// Yes, get the response.
175-
results = jsonSer.Deserialize<Dictionary<string, dynamic>>(response["Response"]);
175+
results = jsonSer.Deserialize<SortedList<string, dynamic>>(response["Response"]);
176176
}
177177

178178
// As long as we have something.
179179
if (status != -1 && results != null)
180-
{
181-
// Get the installed and failed lists.
182-
ArrayList installed = results.ContainsKey("Installed") ? results["Installed"] : null;
183-
ArrayList failed = results.ContainsKey("Failed") ? results["Failed"] : null;
184-
185-
// Give some feedback on it, only if it's changed.
186-
string print = string.Format("\t{0} module archives processed, {0}/{1} succeeded.", installed.Count + failed.Count, installed.Count);
180+
{
181+
// Build feedback.
182+
string print = BuildUpdateString(results);
187183

184+
// Same as previous feedback?
188185
if (print != previousPrint)
189186
{
190187
WriteLine(print);
@@ -204,15 +201,14 @@ static void Main(string[] args)
204201
}
205202
else
206203
{
207-
// Get the installed and failed lists.
208-
ArrayList installed = results.ContainsKey("Installed") ? results["Installed"] : null;
209-
ArrayList failed = results.ContainsKey("Failed") ? results["Failed"] : null;
204+
// Build feedback.
205+
string print = BuildUpdateString(results);
210206

211-
// Give some feedback on it.
212-
WriteLine(string.Format("\t{0} module archives processed, {0}/{1} succeeded.", installed.Count + failed.Count, installed.Count));
213-
207+
// Print feedback.
208+
WriteLine(print);
214209
}
215210

211+
// Finished install.
216212
WriteLine(string.Format("Finished installation in {0} ms.", (DateTime.Now - installStartTime).TotalMilliseconds));
217213
ReadLine();
218214
}
@@ -227,6 +223,35 @@ static void Main(string[] args)
227223
}
228224
}
229225

226+
private static string BuildUpdateString(SortedList<string, dynamic> results)
227+
{
228+
// Get counts.
229+
int attempted = 0;
230+
int succeeded = 0;
231+
int failed = 0;
232+
233+
foreach (KeyValuePair<string, dynamic> kvp in results)
234+
{
235+
Dictionary<string, dynamic> module = kvp.Value;
236+
237+
if (module.ContainsKey("Attempted") && (bool)module["Attempted"])
238+
{
239+
attempted++;
240+
241+
if (module.ContainsKey("Success") && (bool)module["Success"])
242+
{
243+
succeeded++;
244+
}
245+
else
246+
{
247+
failed++;
248+
}
249+
}
250+
}
251+
252+
return string.Format("\t{0}/{1} module archives processed, {2}/{0} succeeded.", attempted, results.Count, succeeded);
253+
}
254+
230255
private static void WriteException(Exception ex, int maxDepth = 10, int depth = 0)
231256
{
232257
WriteLine(ex.Message);

0 commit comments

Comments
 (0)