private void ParseInproceedings(int year) { int global_conference_id = 0; dicInproceedings.Clear(); dicConferences.Clear(); dicStringConferences.Clear(); GC.Collect(); GC.WaitForPendingFinalizers(); string prefex_saved = "\\"; Parallel.ForEach(fileInproceedings, x => { int fileindex = x.Name.LastIndexOf('.'); fileindex = Convert.ToInt32(x.Name.Substring(fileindex - 1, 1)); // Parse the file IEnumerable<string> lines; lines = File.ReadLines(Path.GetFullPath(x.DirectoryName + prefex_saved + x.Name)); int curline = 0; Parallel.ForEach(lines, l => { InproceedingsDBLP inproceeding = InproceedingsDBLP.CreateFromLine(l, curline, fileindex, year); if (inproceeding != null) { lock (lock_inproceeding) { dicInproceedings.Add(inproceeding.Id, inproceeding); } if (chkSaveConference.Checked) { lock (lock_conference) { string[] keys = inproceeding.Key.Split('/'); string conf_key = keys.Length > 1 ? keys[1] : keys[0]; if (dicStringConferences.ContainsKey(conf_key)) { ConferenceDBLP conference = dicStringConferences[conf_key]; conference.InproceedingsID += "|" + inproceeding.Id; conference.CountInproceedings++; } else { inproceeding.ConferenceID = global_conference_id; ConferenceDBLP conference = new ConferenceDBLP(conf_key, inproceeding.Conference, 1, inproceeding.Id.ToString(), global_conference_id); global_conference_id++; dicConferences.Add(conference.Id, conference); dicStringConferences.Add(conf_key, conference); } } } } curline++; if (curline % 100000 == 0) { this.Invoke((MethodInvoker)delegate { txtMsgLog.Text += (string.Format("Line Index= {0} - File index={1} - {2} \r\n", curline, fileindex, x.Name)); txtMsgLog.SelectionStart = txtMsgLog.Text.Length; txtMsgLog.ScrollToCaret(); if (txtMsgLog.Text.Length > 1000) { txtMsgLog.Text = ""; } }); } }); }); }
private void LoadDataFromDB() { using (dblpData dataDBLP = new dblpData()) { List<dblp_author> listAuthors = dataDBLP.dblp_author.ToList(); List<dblp_conference> listConferences = dataDBLP.dblp_conference.ToList(); List<dblp_inproceedings> listInproceedings = dataDBLP.dblp_inproceedings.ToList(); listAs.Clear(); listIs.Clear(); listCs.Clear(); AuthorDBLP aDBLP; foreach (dblp_author a in listAuthors) { aDBLP = new AuthorDBLP() { OldValue = 0, CurrentValue = Convert.ToInt32(txtStartValue.Text), Id = a.id, Name = a.name, CountInproceedings = a.count == null ? 0 : (int)a.count, Inproceedings = new List<int>() }; foreach (string id in a.inproceedings.TrimStart('|').Split('|')) { aDBLP.Inproceedings.Add(Convert.ToInt32(id)); } aDBLP.InproceedingsID = aDBLP.Inproceedings.Aggregate("", (cur, next) => cur + "|" + next); listAs.Add(aDBLP); } InproceedingsDBLP iDBLP; foreach (dblp_inproceedings i in listInproceedings) { iDBLP = new InproceedingsDBLP() { Id = i.id, Title = i.title, Key = i.key, Year = i.year, Pages = i.pages, Crossref = i.crossref, Conference = i.conference, AuthorsID = "", ConferenceID = i.conference_id == null ? 0 : (int)i.conference_id, CountAuthors = i.count == null ? 0 : (int)i.count, Authors = new List<int>() }; foreach (string id in i.authors.TrimStart('|').Split('|')) { iDBLP.Authors.Add(Convert.ToInt32(id)); } iDBLP.AuthorsID = iDBLP.Authors.Aggregate("", (cur, next) => cur + "|" + next); listIs.Add(iDBLP); } ConferenceDBLP cDBLP; foreach (dblp_conference c in listConferences) { cDBLP = new ConferenceDBLP() { Id = c.id, Name = c.name, CountInproceedings = c.count == null ? 0 : (int)c.count, Inproceedings = new List<int>() }; foreach (string id in c.inproceedings.TrimStart('|').Split('|')) { cDBLP.Inproceedings.Add(Convert.ToInt32(id)); } cDBLP.InproceedingsID = cDBLP.Inproceedings.Aggregate("", (cur, next) => cur + "|" + next); listCs.Add(cDBLP); } } }