public async Task Initialize(ContentContext context) { context.Database.EnsureCreated(); if (context.UserContentDetails.Any()) { Console.WriteLine("Db connected"); // DB has been seeded } if (context.UserFileDetails.Any()) { Console.WriteLine("Db connected"); // DB has been seeded } foreach (var s in context.UserContentDetails) { Console.WriteLine(s.Content); } context.SaveChanges(); foreach (var s in context.UserContentDetails) { if (s.IsGraphCreated == false) { var query = context.Database.ExecuteSqlCommand("UPDATE UserContentDetails SET IsGraphCreated=1 where ContentId=" + s.ContentId + ""); string html = RemoveHTMLTags(s.Content).ToLower(); ProcessRepositories(html, s.ContentId).Wait(); } } context.SaveChanges(); foreach (var s in context.UserFileDetails) { string finaldoc; if (s.IsGraphCreated == false) { var query = context.Database.ExecuteSqlCommand("UPDATE UserFileDetails SET IsGraphCreated=1 where FileId=" + s.FileId + ""); //context.SaveChanges(); await DownloadFile(s.FileName); if (s.FileType == "application/pdf") { ReadPDF objreadpdf = new ReadPDF(); finaldoc = objreadpdf.Readpdf(s.FileName); string html = RemoveHTMLTags(finaldoc).ToLower(); ProcessRepositories(html, s.ContentId).Wait(); } if (s.FileType == "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet") { ReadExcel objreadexcel = new ReadExcel(); finaldoc = objreadexcel.Readexcel(s.FileName); string html = RemoveHTMLTags(finaldoc).ToLower(); ProcessRepositories(html, s.ContentId).Wait(); } if (s.FileType == "text/plain") { ReadText objreadtext = new ReadText(); finaldoc = objreadtext.Readtext(s.FileName); string html = RemoveHTMLTags(finaldoc).ToLower(); ProcessRepositories(html, s.ContentId).Wait(); } if (s.FileType == "application/vnd.openxmlformats-officedocument.presentationml.presentation") { ReadPPT objreadppt = new ReadPPT(); finaldoc = objreadppt.Readppt(s.FileName); string html = RemoveHTMLTags(finaldoc).ToLower(); ProcessRepositories(html, s.ContentId).Wait(); } if (s.FileType == "application/vnd.openxmlformats-officedocument.wordprocessingml.document") { ReadDocx objreaddocx = new ReadDocx(); finaldoc = objreaddocx.Readdocx(s.FileName); string html = RemoveHTMLTags(finaldoc).ToLower(); ProcessRepositories(html, s.ContentId).Wait(); } context.SaveChanges(); } } }