示例#1
0
        static void Main(string[] args)
        {
            Console.Title = "FFLogs Downloader";

            var cacheHandler  = new FFLogsCacheHandler();
            var api           = new FFLogsAPI(new ApiKeyCredentials(), cacheHandler);
            var authenticated = false;

            while (!authenticated)
            {
                if (File.Exists("ApiKey.txt"))
                {
                    ((ApiKeyCredentials)api.Credentials).ApiKey = File.ReadAllText("ApiKey.txt");

                    try
                    {
                        api.GetClasses();
                        authenticated = true;
                        break;
                    }
                    catch (Exception) { }
                }

                Console.Write("API Key: ");
                ((ApiKeyCredentials)api.Credentials).ApiKey = Console.ReadLine();

                try
                {
                    api.GetClasses();
                    authenticated = true;
                }
                catch (Exception) { }
            }

            Console.Clear();

            var zones   = api.GetZones();
            var classes = api.GetClasses();
            var metrics = new[] { "dps", "hps" };

            if (File.Exists("FFLogs.csv"))
            {
                try
                {
                    File.Delete("FFLogs.csv");
                }
                catch (Exception)
                {
                    Console.WriteLine("FFLogs.csv is open in another program, please close it and try again!");
                }
            }

            var builder = new StringBuilder();

            builder.Append("Patch,Region,Server,Player Name,Job,Zone,Encounter,Encounter Frozen,Encounter Start Time,Encounter Duration,Metric,Value\n");

            foreach (var zone in zones)
            {
                CurrentItemFrozen = zone.Frozen;

                foreach (var encounter in zone.Encounters)
                {
                    foreach (var metric in metrics)
                    {
                        foreach (var fClass in classes)
                        {
                            foreach (var spec in fClass.Specs)
                            {
                                var page = 1;

                                var rankings = new EncounterRankings(0, true, 0, new List <EncounterRanking>());

                                while (rankings.HasMorePages)
                                {
                                    Console.WriteLine("Downloading " + spec.Name + " - " + metric.ToUpper() + " - " + encounter.Name + " - Page " + page);

                                    rankings = api.GetRankingsByEncounterId(encounter.Id, metric: metric, classParameter: fClass.Id, spec: spec.Id, page: page);

                                    foreach (var ranking in rankings.Rankings)
                                    {
                                        builder.Append(ranking.Patch);
                                        builder.Append(",");
                                        builder.Append(ranking.Region);
                                        builder.Append(",");
                                        builder.Append(ranking.Server);
                                        builder.Append(",");
                                        builder.Append(ranking.Name);
                                        builder.Append(",");
                                        builder.Append(spec.Name);
                                        builder.Append(",");
                                        builder.Append(zone.Name);
                                        builder.Append(",");
                                        builder.Append(encounter.Name);
                                        builder.Append(",");
                                        builder.Append(zone.Frozen);
                                        builder.Append(",");
                                        builder.Append(DateTimeOffset.FromUnixTimeMilliseconds((long)ranking.StartTime));
                                        builder.Append(",");
                                        builder.Append(TimeSpan.FromMilliseconds((double)ranking.Duration));
                                        builder.Append(",");
                                        builder.Append(metric.ToUpper());
                                        builder.Append(",");
                                        builder.Append(ranking.Total);
                                        builder.Append("\n");
                                    }

                                    page++;
                                }
                            }
                        }
                        cacheHandler.FlushCache();
                    }
                }
            }

            File.WriteAllText("FFLogs.csv", builder.ToString());
        }
示例#2
0
        public async Task GetEncounterRankingsAsync()
        {
            EncounterRankings result = await FFLogsClient.GetEncounterRankingsAsync(69);

            Assert.AreEqual(5.2, result.Rankings.FirstOrDefault()?.Patch);
        }