public void AddLinksToStorage() { //Trace.WriteLine($"ADD LINKS TO DB. StorageContext.constr={StorageContext.constr.ConnectionString}"); try { LinkDBFormatConverter linkConverter = new LinkDBFormatConverter(linkList, format: true); //Trace.WriteLine($"linkConverter CREATED!!"); //Trace.WriteLine($"linkList.Count: {linkList.Count} result.count: {linkConverter.Result.Count}"); using (var storage = new StorageContext(StorageContext.constr)) { foreach (var link in linkConverter.Result) { //Trace.WriteLine(link.ToText()); storage.links.AddIfNotExists(link, l => l.toText == link.toText); } storage.SaveChanges(); } } catch (Exception ex) { Trace.WriteLine(ex.Message); throw; } }
public void processPackage(string inputFilePath) { #region ANTLR4 necessary stuff var input = new AntlrInputStream(new StreamReader(inputFilePath)); var lexer = new PlSqlLexer(input); var tokens = new CommonTokenStream(lexer); var parser = new PlSqlParser(tokens); PlSqlParser.Create_package_bodyContext context1 = parser.create_package_body(); ParseTreeWalker walker = new ParseTreeWalker(); var bListener = new BODYlistener(); walker.Walk(bListener, context1); #endregion //you can start making changes from this point var converter = new JoinLinksConverter(bListener.joinsList); var uniqueLinks = converter.MakeUniqueLinksList(); using (var storage = new StorageContext(StorageContext.constr)) { Dictionary <string, string> linkToText = new Dictionary <string, string>(); foreach (var link in storage.links.ToList()) { linkToText.Add(link.toText, ""); } List <Link> linkListToConvert = new List <Link>(); linkListToConvert.AddRange(uniqueLinks.Where(link => dbObjectNames.ContainsKey(link.firstTable) && dbObjectNames.ContainsKey(link.secondTable) && !linkToText.ContainsKey(link.ToText()))); LinkDBFormatConverter linkConverter = new LinkDBFormatConverter(linkListToConvert); foreach (var link in linkConverter.Result) { storage.links.Add(link); } storage.SaveChanges(); } }