Exemple #1
0
        private void UpdateAuthor()
        {
            var sw = Stopwatch.StartNew();
            List<table_articles> listArticles = new List<table_articles>();
            List<table_inproceedings> listInproceedings = new List<table_inproceedings>();

            List<table_phdthesis> listPhdthesis = new List<table_phdthesis>();
            List<table_proceedings> listProceedings = new List<table_proceedings>();
            List<table_www> listWWWs = new List<table_www>();
            int start = Convert.ToInt32(txtAuthorIDStart.Text);
            int end = Convert.ToInt32(txtAuthorIDEnd.Text);

            using (dblpData dataDBLP = new dblpData())
            {
                if (chkUpdateAll.Checked)
                {
                    listWWWs = dataDBLP.table_www.Where(a => a.ID >= start && a.ID <= end && a.COUNT == 1).ToList();
                }
                else
                {
                    listWWWs = dataDBLP.table_www.Where(a => a.ID >= start && a.ID <= end && a.COUNT == 1 && (a.inproceedings_count == 0 || a.inproceedings_count == null)).ToList();
                }
                    //listWWWs = dataDBLP.table_www.Where(a => a.ID == 49).ToList();

                listWWWs.AsParallel().ForAll(w => AssignAuthorPaperList(w, ref listAs, ref listIs, ref listCs));
                dataDBLP.SaveChanges();
            }
            sw.Stop();

               Console.WriteLine("Total: {0}:{1}:{2}", sw.Elapsed.Hours, sw.Elapsed.Minutes, sw.Elapsed.Seconds);
               // running on worker thread
               if (this.IsHandleCreated)
               {
               this.Invoke((MethodInvoker)delegate
               {
                   txtMsg.Text += string.Format("Total: {0}:{1}:{2}", sw.Elapsed.Hours, sw.Elapsed.Minutes, sw.Elapsed.Seconds);

                   dgvAuthors.Invoke((MethodInvoker)delegate
                   {
                       dgvAuthors.DataSource = listAs;
                       dgvAuthors.Refresh();

                   });
                   dgvInproceedings.Invoke((MethodInvoker)delegate
                   {
                       dgvInproceedings.DataSource = listIs;
                       dgvInproceedings.Refresh();
                       dgvConferences.Refresh();
                       dgvConferences.DataSource = listCs;
                   });
                   dgvConferences.Invoke((MethodInvoker)delegate
                   {
                       dgvConferences.DataSource = listCs;
                       dgvConferences.Refresh();
                   });
               });

               }
               MessageBox.Show("Done");
        }
Exemple #2
0
        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);
                }
            }
        }
Exemple #3
0
 private void BuildInproceedings(Dictionary<InproceedingsDBLP, int> inProceedingToId)
 {
     dblpData dataDBLP = new dblpData();
     dblp_inproceedings inproceeding;
     foreach (InproceedingsDBLP a in inProceedingToId.Keys)
     {
         inproceeding = new dblp_inproceedings()
         {
             key = a.Key,
             title = a.Title,
             id = inProceedingToId[a],
             authors = string.Join("|", a.Authors),
             count = a.Authors.Count,
             conference = a.Conference,
             conference_id = a.ConferenceID
         };
         dataDBLP.dblp_inproceedings.Add(inproceeding);
     }
     dataDBLP.SaveChanges();
 }
Exemple #4
0
 private void BuildConference(Dictionary<ConferenceDBLP, int> ConferenceToId)
 {
     dblpData dataDBLP = new dblpData();
     dblp_conference conference;
     foreach (ConferenceDBLP a in ConferenceToId.Keys)
     {
         conference = new dblp_conference()
         {
             name = a.Name,
             id = ConferenceToId[a],
             inproceedings = string.Join("|", a.Inproceedings),
             count = a.Inproceedings.Count,
         };
         dataDBLP.dblp_conference.Add(conference);
     }
     dataDBLP.SaveChanges();
 }
Exemple #5
0
 private void BuildAuthorToId(Dictionary<AuthorDBLP, int> authorToId)
 {
     dblpData dataDBLP = new dblpData();
     dblp_author author;
     foreach(AuthorDBLP a in authorToId.Keys){
         author = new dblp_author()
         {
             name = a.Name,
             id = authorToId[a],
             inproceedings = string.Join("|", a.Inproceedings),
             count = a.Inproceedings.Count
         };
         dataDBLP.dblp_author.Add(author);
     }
     dataDBLP.SaveChanges();
 }
Exemple #6
0
        private void AssignAuthorPaperList(table_www w, ref List<AuthorDBLP> listAuthors, ref  List<InproceedingsDBLP> listInDBLP,
            ref List<ConferenceDBLP> listConferences)
        {
            List<table_inproceedings> listIns = new List<table_inproceedings>();
            AuthorDBLP authorDBLP = null;
            string author = w.author_keys;
            var sw = Stopwatch.StartNew();
            var id = w.ID;
            using (dblpData dataDBLP = new dblpData())
            {
                try
                {
                    if (dataDBLP.table_inproceedings.Count() > 0)
                    {
                        List<table_inproceedings> listI = dataDBLP.table_inproceedings.Where(
                                a => a.author_keys.Contains(author + "|") || a.author_keys.EndsWith(author)).ToList();
                        if (listI.Count > 0)
                        {
                            listIns = listIns.Union(listI).ToList();
                            var inproceedings =
                                from l in listIns select new InproceedingsDBLP(l.ID, l.KEY, l.TITLE, l.BOOKTITLE, Convert.ToString(l.YEAR), l.author_keys, (int)l.COUNT, 0);
                            var conferences =
                               from l in listIns.GroupBy(i => i.BOOKTITLE).Select(
                                   g => new
                                   {
                                       key = g.Key,
                                       count = g.Count(),
                                       inproceedings = g.Aggregate(string.Empty, (x, i) => x + "|" + i.ID)
                                   })
                               select new ConferenceDBLP(l.key, (int)l.count, l.inproceedings);
                            lock (lock_w)
                            {
                                listInDBLP = listInDBLP.Union(inproceedings).ToList();
                                listConferences.AddRange(conferences);
                            }
                            table_www www = dataDBLP.table_www.Where(a => a.ID == id).FirstOrDefault();
                            www.inproceedings_count = w.inproceedings_count = listIns.Count;
                            authorDBLP = new AuthorDBLP()
                            {
                                Id = id,
                                CountInproceedings = listIns.Count,
                                InproceedingsID = www.inproceedings_key = w.inproceedings_key = listIns.Aggregate("", (x, y) => x + "|" + y.ID),
                                CurrentValue = 0,
                                OldValue = 0
                            };
                            dataDBLP.SaveChanges();
                            listAuthors.Add(authorDBLP);
                        }

                        sw.Stop();
                        // running on worker thread
                        if (this.IsHandleCreated)
                        {
                            this.Invoke((MethodInvoker)delegate
                            {
                                txtMsg.Text += string.Format("wwwID -{0} -{1}: {2:F2}s\r\n", id, author, sw.Elapsed.TotalSeconds);

                                if (txtMsg.Text.Length > 10000)
                                    txtMsg.Text = "";
                            });
                        }
                        else
                        {
                            Thread.CurrentThread.Abort();
                        }
                        Console.WriteLine("wwwID -{0} -{1}: {2:F2}s\r\n", id, author, sw.Elapsed.TotalSeconds);
                    }
                }
                catch (Exception ex)
                {
                    // running on worker thread
                    if (this.IsHandleCreated)
                    {
                        this.Invoke((MethodInvoker)delegate
                        {
                            txtMsg.Text += string.Format("wwwID - {0} - {1} - msg:{2}\r\n", id, author, ex.StackTrace);// runs on UI thread
                        });
                    }
                    else
                    {
                        Thread.CurrentThread.Abort();
                    }
                    Console.WriteLine("wwwID -{0} -{1}: {2:F2}s\r\n", id, author, sw.Elapsed.TotalSeconds);
                }
            }
            this.Invoke((MethodInvoker)delegate
            {
                dgvAuthors.Invoke((MethodInvoker)delegate
                {
                    dgvAuthors.DataSource = listAs;
                    dgvAuthors.Refresh();

                });
                dgvInproceedings.Invoke((MethodInvoker)delegate
                {
                    dgvInproceedings.DataSource = listIs;
                    dgvInproceedings.Refresh();
                });
                dgvConferences.Invoke((MethodInvoker)delegate
                {
                    dgvConferences.DataSource = listCs;
                    dgvConferences.Refresh();
                });
            });
        }