public static List <IResultSummary> RunQuery(string query, NeoQueryData data, IDriver driver, bool showstats, bool showprogressdots) { List <IResultSummary> summaries = new List <IResultSummary>(); ISession session; int itemscount = 0; if (string.IsNullOrWhiteSpace(data.ScanID)) { data.ScanID = NeoWriter.ScanID; } if (string.IsNullOrWhiteSpace(data.ScannerID)) { data.ScannerID = NeoWriter.ScannerID; } if (data.Properties != null) { while (data.Properties.Count > 1000) { NeoQueryData subdata = new NeoQueryData(); subdata.ScanID = data.ScanID; subdata.ScannerID = data.ScannerID; subdata.Properties = ListExtensions.ListPop <object>(data.Properties, 1000); itemscount += subdata.Properties.Count; IStatementResult subresult; using (session = driver.Session()) { subresult = session.WriteTransaction(tx => tx.Run(query, subdata)); } if (subresult?.Summary != null) { summaries.Add(subresult.Summary); } if (showprogressdots) { Console.Write("."); } } } IStatementResult result; using (session = driver.Session()) { if (data.Properties != null) { itemscount += data.Properties.Count; } result = session.WriteTransaction(tx => tx.Run(query, data)); } if (result?.Summary != null) { summaries.Add(result.Summary); } Console.WriteLine(); if (showstats) { int nodescreated = 0; int nodesdeleted = 0; int relscreated = 0; int relsdeleted = 0; int propsset = 0; foreach (IResultSummary summary in summaries) { nodescreated += summary.Counters.NodesCreated; nodesdeleted += summary.Counters.NodesDeleted; relscreated += summary.Counters.RelationshipsCreated; relsdeleted += summary.Counters.RelationshipsDeleted; propsset += summary.Counters.PropertiesSet; } string[] sumvals = { string.Empty, $"Done, processed {itemscount.ToString()} items", nodescreated.ToString(), relscreated.ToString(), nodesdeleted.ToString(), relsdeleted.ToString(), propsset.ToString() }; ConsoleWriter.WriteLine(Tabs, sumvals); } return(summaries); }
public static void WriteHeaders() { string[] headervals = { "Description", string.Empty, "(n)+", "[r]+", "(n)-", "[r]-", "Properties set" }; ConsoleWriter.WriteLine(Tabs, headervals); }