public ObservableCollection<Student> GetStaffSupervisions(Researcher researcher)
 {
     if (researcher is Staff)
     {
         var staff = researcher as Staff;
         return new ObservableCollection<Student>(staff.Supervisions);
     }
     return new ObservableCollection<Student>();
 }
예제 #2
0
 public IEnumerable<Publication> FetchBasicPublicationDetails(Researcher r)
 {
     var publications = new List<Publication>();
     MySqlDataReader rdr = null;
     try
     {
         conn.Open();
         MySqlCommand cmd = new MySqlCommand("select p.* from publication p join researcher_publication rp on p.doi=rp.doi where rp.researcher_id=?id order by year desc, title", conn);
         cmd.Parameters.AddWithValue("id", r.Id);
         rdr = cmd.ExecuteReader();
         while (rdr.Read())
         {
             publications.Add(new Publication
                 {
                     DOI = rdr.GetString(0),
                     Title = rdr.GetString(1),
                     Authors = rdr.GetString(2),
                     Year = rdr.GetString(3),
                     Type = (OutputType)Enum.Parse(typeof(OutputType), rdr.GetString(4)),
                     CiteAs = rdr.GetString(5),
                     Available = rdr.GetDateTime(6)
                 });
         }
     }
     catch (MySqlException e)
     {
         throw new Exception("loading staff", e);
     }
     finally
     {
         if (rdr != null)
         {
             rdr.Close();
         }
         if (conn != null)
         {
             conn.Close();
         }
     }
     return publications;
 }
예제 #3
0
 public Researcher CompleteResearcherDetails(Researcher r)
 {
     return null;
 }
예제 #4
0
 private void PopulateResearcher(MySqlDataReader rdr, Researcher researcher)
 {
     researcher.Id = rdr.GetInt32("id");
     researcher.GivenName = rdr.GetString("given_name");
     researcher.FamilyName = rdr.GetString("family_name");
     researcher.Title = rdr.GetString("title");
     researcher.Unit = rdr.GetString("unit");
     researcher.Campus = rdr.GetString("campus");
     researcher.PhotoUrl = rdr.GetString("photo");
     researcher.Email = rdr.GetString("email");
     researcher.utas_start = rdr.GetDateTime("utas_start");
     researcher.current_start = rdr.GetDateTime("current_start");
 }
예제 #5
0
        public Researcher FetchFullResearcherDetails(Researcher researcher)
        {
            MySqlDataReader rdr = null;
            bool isEmpty = true;
            try
            {
                conn.Open();

                MySqlCommand cmd = new MySqlCommand("select * from researcher where id=?id", conn);
                cmd.Parameters.AddWithValue("id", researcher.Id);

                using (rdr = cmd.ExecuteReader())
                {

                    if (rdr.Read())
                    {
                        if (researcher is Student)
                        {
                            var student = researcher as Student;
                            student.Degree = rdr.GetString("degree");
                            student.Supervisor = new Staff { Id = rdr.GetInt32("supervisor_id") };
                        }
                        else
                        {
                            var staff = researcher as Staff;
                            staff.currentLevel = (EmploymentLevel)Enum.Parse(typeof(EmploymentLevel), rdr.GetString("level"));
                        }
                        PopulateResearcher(rdr, researcher);
                        isEmpty = false;
                    }
                }

                if (isEmpty) return null;

                if (researcher is Student)
                {
                    var student = researcher as Student;
                    cmd = new MySqlCommand("select * from researcher where id=?id", conn);
                    cmd.Parameters.AddWithValue("id", student.Supervisor.Id);
                    using (rdr = cmd.ExecuteReader())
                    {
                        if (rdr.Read())
                        {
                            PopulateStaff(rdr, student.Supervisor);
                        }
                    }
                }
                else
                {
                    var staff = researcher as Staff;
                    cmd = new MySqlCommand("select * from researcher where supervisor_id=?id", conn);
                    cmd.Parameters.AddWithValue("id", staff.Id);
                    using (rdr = cmd.ExecuteReader())
                    {
                        staff.Supervisions.Clear();
                        while (rdr.Read())
                        {
                            var student = new Student();
                            PopulateStudent(rdr, student);
                            student.Supervisor = staff;
                            staff.Supervisions.Add(student);
                        }
                    }
                }

                cmd = new MySqlCommand("select * from position where id=?id order by start", conn);
                cmd.Parameters.AddWithValue("id", researcher.Id);
                using (rdr = cmd.ExecuteReader())
                {

                    researcher.AllPositions.Clear();
                    while (rdr.Read())
                    {
                        researcher.AllPositions.Add(new Position
                        {
                            Level = (EmploymentLevel)Enum.Parse(typeof(EmploymentLevel), rdr.GetString("level")),
                            start = rdr.IsDBNull(rdr.GetOrdinal("start")) ? (DateTime?)null : rdr.GetDateTime("start"),
                            end = rdr.IsDBNull(rdr.GetOrdinal("end")) ? (DateTime?)null : rdr.GetDateTime("end")
                        });
                    }
                }

                cmd = new MySqlCommand("select p.* from publication p join researcher_publication rp on p.doi=rp.doi where rp.researcher_id=?id order by year desc, title", conn);
                cmd.Parameters.AddWithValue("id", researcher.Id);
                using (rdr = cmd.ExecuteReader())
                {
                    researcher.AllPublications.Clear();
                    while (rdr.Read())
                    {
                        var id = rdr.GetString(4);
                        researcher.AllPublications.Add(new Publication
                        {
                            DOI = rdr.GetString(0),
                            Title = rdr.GetString(1),
                            Authors = rdr.GetString(2),
                            Year = rdr.GetString(3),
                            Type = (OutputType)Enum.Parse(typeof(OutputType), rdr.GetString(4)),
                            CiteAs = rdr.GetString(5),
                            Available = rdr.GetDateTime(6),
                            Age = DateTime.Now.Subtract(rdr.GetDateTime(6)).Days.ToString() + " Days"

                        });

                    }
                }
            }
            catch (MySqlException e)
            {
                throw new Exception("loading staff", e);
            }
            finally
            {
                if (rdr != null)
                {
                    rdr.Close();
                }
                if (conn != null)
                {
                    conn.Close();
                }
            }

            return researcher;
        }
 public Researcher LoadReseacherDetails(Researcher researcher)
 {
     if (researcher == null) return null;
     return adapter.FetchFullResearcherDetails(researcher);
 }
 public ObservableCollection<dynamic> GetCumulativeCount(Researcher researcher)
 {
     if (researcher == null) return new ObservableCollection<dynamic>();
     var cumulativeCount = researcher.AllPublications.GroupBy(x => x.Year).Select(x => new { year = x.FirstOrDefault().Year, count = x.Count() }).OrderBy(x=>x.year);
     return new ObservableCollection<dynamic>(cumulativeCount);
 }