Ejemplo n.º 1
0
        private void SetDataCheckHandlers()
        {
            CheckButton.Click += (object sender, RoutedEventArgs e) =>
            {
                OpenFileDialog openFileDialog = new OpenFileDialog();
                openFileDialog.Filter      = "CSV files (*.csv)|*.csv|All files (*.*)|*.*";
                openFileDialog.Multiselect = false;
                if (openFileDialog.ShowDialog() == true)
                {
                    try
                    {
                        var list    = new List <Data>();
                        var dataRaw = File.ReadAllLines(openFileDialog.FileName).Select(line => line.Split(';'));
                        foreach (var row in dataRaw)
                        {
                            var data = new Data
                            {
                                Faculty         = row[0],
                                Chair           = row[1],
                                LastName        = row[2],
                                FirstName       = row[3],
                                MiddleName      = row[4],
                                Orcid           = row[5],
                                GoogleHIndexOld = int.Parse(row[6])
                            };

                            var researchers = unitOfWork.Researchers.Find(item =>
                                                                          item.FirstName.ToLower() == data.FirstName.ToLower() &&
                                                                          item.MiddleName.ToLower() == data.MiddleName.ToLower() &&
                                                                          item.LastName.ToLower() == data.LastName.ToLower() &&
                                                                          item.Chair.ChairName.ToLower() == data.Chair.ToLower() &&
                                                                          item.Chair.Faculty.FacultyName.ToLower() == data.Faculty.ToLower());

                            if (researchers.Count() == 0)
                            {
                                ResearcherSaver.SaveResearcher(data.Faculty, data.Chair,
                                                               data.FirstName, data.MiddleName, data.LastName, data.Orcid, unitOfWork);
                                data.GoogleHIndex = new FullResearcher(unitOfWork.Researchers.Find(item =>
                                                                                                   item.FirstName.ToLower() == data.FirstName.ToLower() &&
                                                                                                   item.MiddleName.ToLower() == data.MiddleName.ToLower() &&
                                                                                                   item.LastName.ToLower() == data.LastName.ToLower() &&
                                                                                                   item.Chair.ChairName.ToLower() == data.Chair.ToLower() &&
                                                                                                   item.Chair.Faculty.FacultyName.ToLower() == data.Faculty.ToLower()).First(), unitOfWork).GoogleHIndex;
                            }
                            else
                            {
                                data.GoogleHIndex = new FullResearcher(researchers.First(), unitOfWork).GoogleHIndex;
                            }

                            list.Add(data);
                        }
                        DataList.ItemsSource = list;
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.InnerException.Message + " Файл містить дані в недопустимому форматі\nДопустимий формат:" +
                                        " факультет;кафедра;Прізвище;ім'я;по-батькові;id;індекс Гірша"
                                        , "Неправильний файл", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                    }
                }
            };
            DownloadButton.Click += (object sender, RoutedEventArgs e) =>
            {
                OpenFileDialog openFileDialog = new OpenFileDialog();
                openFileDialog.Filter      = "CSV files (*.csv)|*.csv|All files (*.*)|*.*";
                openFileDialog.Multiselect = false;
                if (openFileDialog.ShowDialog() == true)
                {
                    try
                    {
                        var dataRaw = File.ReadAllLines(openFileDialog.FileName).Select(line => line.Split(';'));
                        foreach (var row in dataRaw)
                        {
                            var data = new Data
                            {
                                Faculty         = row[0],
                                Chair           = row[1],
                                LastName        = row[2],
                                FirstName       = row[3],
                                MiddleName      = row[4],
                                Orcid           = row[5],
                                GoogleHIndexOld = int.Parse(row[6])
                            };

                            ResearcherSaver.SaveResearcher(data.Faculty, data.Chair,
                                                           data.FirstName, data.MiddleName, data.LastName, data.Orcid, unitOfWork);
                            //string message = "qwer";

                            //DialogWindow dialogWindow = new DialogWindow(message);
                            //dialogWindow.Show();
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message + " Файл містить дані в недопустимому форматі\nДопустимий формат:" +
                                        " факультет;кафедра;Прізвище;ім'я;по-батькові;id;індекс Гірша"
                                        , "Неправильний файл", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                    }
                }
            };
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            var         t          = WebSocket.Driver;
            IUnitOfWork unitOfWork = new EFUnitOfWork();
            Stopwatch   stopwatch  = new Stopwatch();

            stopwatch.Start();
            ResearcherSaver.SaveResearcher("fiot3", "asoiu4", "Yuri", "M", "Gordienko", "0000-0002-7700-5649", unitOfWork);
            stopwatch.Stop();
            Console.WriteLine("all: " + stopwatch.Elapsed.TotalSeconds + " seconds");
            //var pub = unitOfWork.Publications.Find(item => item.AccountPublications.Any(ui => ui.Account.ResearcherAccounts.Any(y => y.Researcher.Chair.Faculty.FacultyName == "fiot")));
            ////Stopwatch stopwatch = new Stopwatch();
            //Console.WriteLine(DateIndex.GetIndex(new I10Index(), pub, DateTime.MinValue, DateTime.MaxValue));
            stopwatch.Restart();
            Researcher researchery = GoogleSchoolarParser.GetResearcherAsync("5Ih2GqMAAAAJ");

            //researchery.Save(unitOfWork);
            stopwatch.Stop();
            //Console.WriteLine("google: " + stopwatch.Elapsed.TotalSeconds + " seconds");

            stopwatch.Restart();
            Researcher researcherq = PublonsParser.GetResearcherAsync("2379217");

            //researcherq.Save(unitOfWork);
            stopwatch.Stop();
            //Console.WriteLine(stopwatch.Elapsed.TotalSeconds + " seconds");

            stopwatch.Restart();
            Researcher researcherw = ScopusParser.GetResearcherAsync("7101756666");

            //researcherw.Save(unitOfWork);
            stopwatch.Stop();
            //Console.WriteLine(stopwatch.Elapsed.TotalSeconds + " seconds");

            stopwatch.Restart();
            researchery = GoogleSchoolarParser.GetResearcherAsync("5Ih2GqMAAAAJ");
            //researchery.Save(unitOfWork);
            stopwatch.Stop();
            //Console.WriteLine(stopwatch.Elapsed.TotalSeconds + " seconds");

            stopwatch.Restart();
            researcherq = PublonsParser.GetResearcherAsync("2379217");
            //researcherq.Save(unitOfWork);
            stopwatch.Stop();
            //Console.WriteLine(stopwatch.Elapsed.TotalSeconds + " seconds");

            stopwatch.Restart();
            researcherw = ScopusParser.GetResearcherAsync("7101756666");
            //researcherw.Save(unitOfWork);
            stopwatch.Stop();
            //Console.WriteLine(stopwatch.Elapsed.TotalSeconds + " seconds");

            stopwatch.Restart();
            researchery = GoogleSchoolarParser.GetResearcherAsync("5Ih2GqMAAAAJ");
            //researchery.Save(unitOfWork);
            stopwatch.Stop();
            //Console.WriteLine(stopwatch.Elapsed.TotalSeconds + " seconds");

            stopwatch.Restart();
            researcherq = PublonsParser.GetResearcherAsync("2379217");
            //researcherq.Save(unitOfWork);
            stopwatch.Stop();
            //Console.WriteLine(stopwatch.Elapsed.TotalSeconds + " seconds");

            stopwatch.Restart();
            researcherw = ScopusParser.GetResearcherAsync("7101756666");
            //researcherw.Save(unitOfWork);
            stopwatch.Stop();
            Console.WriteLine(stopwatch.Elapsed.TotalSeconds + " seconds");

            stopwatch.Restart();
            researchery = GoogleSchoolarParser.GetResearcherAsync("5Ih2GqMAAAAJ");
            //researchery.Save(unitOfWork);
            stopwatch.Stop();
            Console.WriteLine(stopwatch.Elapsed.TotalSeconds + " seconds");

            stopwatch.Restart();
            researcherq = PublonsParser.GetResearcherAsync("2379217");
            //researcherq.Save(unitOfWork);
            stopwatch.Stop();
            Console.WriteLine(stopwatch.Elapsed.TotalSeconds + " seconds");

            stopwatch.Restart();
            researcherw = ScopusParser.GetResearcherAsync("7101756666");
            //researcherw.Save(unitOfWork);
            stopwatch.Stop();
            Console.WriteLine(stopwatch.Elapsed.TotalSeconds + " seconds");

            Console.WriteLine("====================");
            Console.ReadKey();
        }