internal void Run() { try { //Allow restart from a previous failed run. CompleteIdsFromPriorRun = NodeFlowReader.LogReader(di); if (CompleteIdsFromPriorRun.Count > 0) { log.Log("Loaded completed nodes from prior run ('log.txt')"); } //Run nodes while (nodes.Count > 0) { var nodesToRun = FindNodesToRun(); foreach (var nodeToRun in nodesToRun) { //Run the node var task = RunNodeAsync(nodeToRun); nodes[nodeToRun] = task; } Task.WaitAny(nodes.Values.Where(x => x != null).ToArray()); //Look for errors in tasks foreach (var nodeTask in nodes.Where(x => x.Value != null)) { if (nodeTask.Value.Status == TaskStatus.Faulted) { nodeTask.Key.EndState = EndState.Error; log.NodeEnd(nodeTask.Key); throw new Exception(); } } } } catch (Exception) { log.Error(nodes); } finally { log.WriteToFile(); } }
static void Main(string[] args) { //You could host this on SharePoint and allow jobs to schedule //Note: "log.txt" and "metadata.txt" are reserved names within the folder. args = new string[3]; args[0] = "false"; //debug mode args[1] = ConMgr.Get(Db.Troponin); args[2] = @"C:\Users\VHACONHAUSER\Desktop\NodeFlowFolder"; var di = new DI() { Debug = args[0] == "true" ? true : false, ConnectionString = args[1], FolderPath = args[2] }; var nodes = NodeFlowReader.Load(di); NodeFlowReader.Validate(di); var nodeFlow = new NodeFlow(nodes, di); nodeFlow.Run(); }