using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using System.Data;
using Com.StellmanGreene.PubMed;
namespace Com.StellmanGreene.SocialNetworking
{
///
/// Take a colleague and star and look up all second degree stars
///
public class SecondDegreeStars
{
///
/// Setnb of the colleague whose second degree stars are being found
///
public readonly string ColleagueSetnb;
///
/// Setnb of the first degree star
///
public readonly string FirstDegreeStarSetnb;
///
/// Setnbs of the second degree stars
///
public readonly ArrayList Setnbs;
///
/// Find the second degree stars and populate the object
///
/// Database object
/// Setnb of the colleague
/// Name of the first-degree database
/// Setnb of the 1st degree star
/// Name of the second-degree database
public SecondDegreeStars(Database DB, string ColleagueSetnb, string FirstDegreeDB, string FirstDegreeStarSetnb, string SecondDegreeDB)
{
this.ColleagueSetnb = ColleagueSetnb;
this.FirstDegreeStarSetnb = FirstDegreeStarSetnb;
Setnbs = new ArrayList();
// Retrieve the second degree star Setnbs (sorted)
ArrayList Parameters = new ArrayList();
Parameters.Add(Database.Parameter(FirstDegreeStarSetnb));
DataTable Results = DB.ExecuteQuery(
@"SELECT DISTINCT Setnb
FROM " + SecondDegreeDB + @".StarColleagues
WHERE StarSetnb = ?
ORDER BY Setnb ASC", Parameters);
// Process the second degree stars
for (int Row = 0; Row < Results.Rows.Count; Row++)
{
DataRow SecondDegreeRow = Results.Rows[Row];
string SecondDegreeStarSetnb = SecondDegreeRow["Setnb"].ToString();
if (SecondDegreeStarSetnb != ColleagueSetnb)
Setnbs.Add(SecondDegreeStarSetnb);
}
// Make sure the setnbs are sorted
Setnbs.Sort();
}
}
}