public static void UploadCity(Stream cityFileStream, string filename, string serverRoot, string username)
        {
            // Parse city file (quick-parse, does not fetch all information).
            var parser = new CityParser();
            City parserCity = parser.ParseCityFile(cityFileStream);

            createCityFileDirectory(serverRoot);
            storeCity(parserCity, username, generateCityFilepath(username, filename, serverRoot), cityFileStream);
        }
Example #2
0
        static void Main()
        {
            CityParser parser = new CityParser();

            City ourCity = parser.ParseBinaryFile("C:\\Users\\Owner\\Desktop\\CitiesSC2000\\dustropolis.sc2");
            //City ourCity = parser.ParseBinaryFile("C:\\Users\\Owner\\Desktop\\CitiesSC2000\\new city.sc2");
            //City ourCity = parser.ParseBinaryFile("C:\\Users\\Owner\\Desktop\\CitiesSC2000\\dustropolis.sc2");
            //City ourCity = parser.ParseBinaryFile("C:\\Users\\Owner\\Desktop\\CitiesSC2000\\altTest2.sc2");
            //City ourCity = parser.ParseBinaryFile("C:\\Users\\Owner\\Desktop\\CitiesSC2000\\zoneTest.sc2");
            //City ourCity = parser.ParseBinaryFile("C:\\Users\\Owner\\Desktop\\CitiesSC2000\\underground_test.sc2");
        }
    public static DataTable ScoreCities(int rankingId, int ruleSetId)
    {
        CityParser parser = new CityParser();

        // Fetch rule set formula for scoring.
        string formula = LoadRuleSet(ruleSetId)[RuleSetKeys.Formula];

        using (var db = new DatabaseContext())
        {
            List<RankingMember> rankingMembers = getRankingMembers(rankingId, db);

            CityInfo city;
            RankingMember rankingMember;
            for (int i = 0; i < rankingMembers.Count; i++)
            {
                rankingMember = rankingMembers[i];
                city = getCity(rankingMember.CityInfoId, db);

                // Score city!
                rankingMember = scoreCity(rankingMember, city, formula, db);
            }
            db.SaveChanges();
        }

        return constructRankingMemberTable(rankingId);
    }