예제 #1
0
    public static StackData GetFlairData(Guid associationId)
    {
        var stackAuthClient = new StackAuthClient(new UrlClient(), new JsonProtocol());
        var associatedUsers = stackAuthClient.GetAssociatedUsers(associationId);

        associatedUsers = associatedUsers.OrderByDescending(au => au.Reputation).Where(au => au.Site.State != SiteState.Linked_Meta);
        int            totalRep = associatedUsers.Sum(ai => ai.Reputation);
        string         html     = "";
        AssociatedUser topUser  = associatedUsers.First();

        StackData data = new StackData()
        {
            DisplayHash = topUser.EmailHash,
            DisplayId   = topUser.Id,
            DisplayName = topUser.DisplayName,
            DisplayUrl  = topUser.Site.SiteUrl,
            Sites       = (from u in associatedUsers select new StackSiteData()
            {
                SiteName = u.Site.Name, SiteState = u.Site.State, Reputation = u.Reputation, Url = u.Site.SiteUrl, UserId = u.Id, IsMod = u.Type == UserType.Moderator, Badges = Utility.GetBadgeCounts(u.Site, u.Id)
            }).ToList(),
            //TotalBadges = GetBadgeCounts(associatedUsers),
        };

        return(data);
    }
 public void GetAssociatedUsers()
 {
     var client = new StackAuthClient();
     var response = client.GetAssociatedUsers(new Guid("e58345f5-0f7b-4261-b449-3959c596f91f"));
     Assert.Greater(response.Items.Count, 1);
     Assert.IsNotNull(response.Items.First(s => s.OnSite.SiteUrl == "http://stackapps.com"));
 }
 public void GetSites()
 {
     var client = new StackAuthClient();
     var response = client.GetSites();
     Assert.Greater(response.Items.Count,1);
     Assert.IsNotNull(response.Items.First(s => s.SiteUrl == "http://stackoverflow.com"));
 }
예제 #4
0
 public static Guid GetAssociationId(int userID, StackSite site)
 {
     var stackAuthClient = new StackAuthClient(new UrlClient(), new JsonProtocol());
     var sites = stackAuthClient.GetSites();
     var siteClient = new StackyClient(version, apiKey, sites.Where(s => s.Name == site.Name).Single(), new UrlClient(), new JsonProtocol());
     var associationId = siteClient.GetUser(userID).AssociationId;
     return associationId;
 }
예제 #5
0
    public static Guid GetAssociationId(int userID, StackSite site)
    {
        var stackAuthClient = new StackAuthClient(new UrlClient(), new JsonProtocol());
        var sites           = stackAuthClient.GetSites();
        var siteClient      = new StackyClient(version, apiKey, sites.Where(s => s.Name == site.Name).Single(), new UrlClient(), new JsonProtocol());
        var associationId   = siteClient.GetUser(userID).AssociationId;

        return(associationId);
    }
예제 #6
0
파일: Program.cs 프로젝트: lfoust/stacky
        static void Main(string[] args)
        {
            var client = new StackAuthClient("1.1", new UrlClient(), new JsonProtocol());
            var sites  = client.GetSites(pageSize: 100);

            foreach (var site in sites)
            {
                Console.WriteLine(site.MainSite.Name);
            }
            Console.ReadLine();
        }
예제 #7
0
        private static IEnumerable<Site> GetSites()
        {
            var stackAuthClient = new StackAuthClient(new UrlClient(), new JsonProtocol());
            var sites = stackAuthClient.GetSites().Where(s => s.State != SiteState.Linked_Meta);
            var siteCreation = new Dictionary<DateTime, Site>();
            foreach (var site in sites) {
                var siteClient = new StackyClient(cfg.Default.ApiVersion, cfg.Default.ApiKey, site, new UrlClient(), new JsonProtocol());
                var user = siteClient.GetUser(-1);
                siteCreation.Add(user.CreationDate, site);
            }
            sites = siteCreation.OrderBy(s => s.Key).Select(s => s.Value);

            return sites;
        }
예제 #8
0
파일: Program.cs 프로젝트: tms/StackFlair
        private static IEnumerable <Site> GetSites()
        {
            var stackAuthClient = new StackAuthClient(new UrlClient(), new JsonProtocol());
            var sites           = stackAuthClient.GetSites().Where(s => s.State != SiteState.Linked_Meta);
            var siteCreation    = new Dictionary <DateTime, Site>();

            foreach (var site in sites)
            {
                var siteClient = new StackyClient(cfg.Default.ApiVersion, cfg.Default.ApiKey, site, new UrlClient(), new JsonProtocol());
                var user       = siteClient.GetUser(-1);
                siteCreation.Add(user.CreationDate, site);
            }
            sites = siteCreation.OrderBy(s => s.Key).Select(s => s.Value);

            return(sites);
        }
예제 #9
0
    public static StackData GetFlairData(Guid associationId)
    {
        var stackAuthClient = new StackAuthClient(new UrlClient(), new JsonProtocol());
        var associatedUsers = stackAuthClient.GetAssociatedUsers(associationId);
        associatedUsers = associatedUsers.OrderByDescending(au => au.Reputation).Where(au => au.Site.State != SiteState.Linked_Meta);
        int totalRep = associatedUsers.Sum(ai => ai.Reputation);
        string html = "";
        AssociatedUser topUser = associatedUsers.First();

        StackData data = new StackData() {
            DisplayHash = topUser.EmailHash,
            DisplayId = topUser.Id,
            DisplayName = topUser.DisplayName,
            DisplayUrl = topUser.Site.SiteUrl,
            Sites = (from u in associatedUsers select new StackSiteData() { SiteName = u.Site.Name, SiteState = u.Site.State, Reputation = u.Reputation, Url = u.Site.SiteUrl, UserId = u.Id, IsMod = u.Type == UserType.Moderator, Badges = Utility.GetBadgeCounts(u.Site, u.Id) }).ToList(),
            //TotalBadges = GetBadgeCounts(associatedUsers),
        };
        return data;
    }
예제 #10
0
 public IntegrationTest()
 {
     Client     = new StackyClient(Version, ApiKey, hostSite, urlClient, protocol);
     AuthClient = new StackAuthClient(urlClient, protocol);
 }
예제 #11
0
 public IntegrationTest()
 {
     Client      = new StackyClient(Version, ApiKey, Sites.StackOverflow, new UrlClient(), new JsonProtocol());
     ClientAsync = new StackyClientAsync(Version, ApiKey, Sites.StackOverflow.ApiEndpoint, new UrlClientAsync(), new JsonProtocol());
     AuthClient  = new StackAuthClient(Version, new UrlClient(), new JsonProtocol());
 }
예제 #12
0
 public IntegrationTest()
 {
     Client = new StackyClient(Version, ApiKey, hostSite, urlClient, protocol);
     AuthClient = new StackAuthClient(urlClient, protocol);
 }
예제 #13
0
 public IntegrationTest()
 {
     Client = new StackyClient(Version, ApiKey, Sites.StackOverflow, new UrlClient(), new JsonProtocol());
     ClientAsync = new StackyClientAsync(Version, ApiKey, Sites.StackOverflow.ApiEndpoint, new UrlClientAsync(), new JsonProtocol());
     AuthClient = new StackAuthClient(new UrlClient(), new JsonProtocol());
 }