Created
September 15, 2013 16:18
-
-
Save seankearon/6572130 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Main() | |
{ | |
var file = @"C:\Users\Me\Desktop\Certificates.txt"; | |
var a = JObject.Parse(File.ReadAllText(file)); | |
var cert = a["Certificates"][0]; | |
// Get the UIDs for the existing boards and circuits. | |
var boards = cert["Boards"].Select (x => (Guid)x["UniqueId"]).ToArray(); | |
var circuits = cert["Boards"].SelectMany (x => x["Circuits"]).Select (x => (Guid)x["UniqueId"]).ToArray(); | |
var changes = new List<string>(); | |
foreach (var board in cert["Boards"]) | |
{ | |
var designation = (string)board["Designation"]; | |
var supplyBoard = (Guid)board["SupplyBoard"]; | |
var supplyCircuit = (Guid)board["SupplyCircuit"]; | |
if (supplyBoard != Guid.Empty && !boards.Contains(supplyBoard)) | |
{ | |
board["SupplyBoard"] = Guid.Empty; | |
board["SupplyIsOriginOfInstallation"] = true; | |
changes.Add("Set supply to origin for " + designation); | |
} | |
if (supplyCircuit != Guid.Empty && !circuits.Contains(supplyCircuit)) | |
{ | |
board["SupplyCircuit"] = Guid.Empty; | |
board["SupplyIsOriginOfInstallation"] = true; | |
changes.Add("Set supply to origin for " + designation); | |
} | |
} | |
File.WriteAllText(file, a.ToString()); | |
changes.Dump("Changes"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment