static List <Voter> GetListOfVoters(Tps tps, string province = "")
        {
            WebClient client = new WebClient();
            string    url    = GetListOfPemilihUrl.Replace("{{tps}}", tps.tps);

            url = url.Replace("{{namapropinsi}}", tps.namaPropinsi);
            url = url.Replace("{{namakabupaten}}", tps.namaKabKota);
            url = url.Replace("{{namakecamatan}}", tps.namaKecamatan);
            url = url.Replace("{{namakelurahan}}", tps.namaKelurahan);

            string s = "";

            s = client.DownloadString(url);

            RootData rootData = JsonConvert.DeserializeObject <RootData>(s);

            s = JsonConvert.SerializeObject(rootData.data);

            List <Voter> voters = JsonConvert.DeserializeObject <List <Voter> >(s);

            if (province.Length > 0)
            {
                foreach (Voter voter in voters)
                {
                    voter.birthProvince = province;
                }
            }
            return(voters);
        }
 static string ReplaceFilename(string filename, Tps tps)
 {
     filename = filename.Replace("{namapropinsi}", tps.namaPropinsi);
     filename = filename.Replace("{namakabupaten}", tps.namaKabKota);
     filename = filename.Replace("{namakecamatan}", tps.namaKecamatan);
     filename = filename.Replace("{namakelurahan}", tps.namaKelurahan);
     filename = filename.Replace("{tps}", tps.tps);
     filename = filename.Replace(" ", "");
     return(filename);
 }
Exemple #3
0
 public McServerStatus ToMessage()
 {
     return(new McServerStatus
            (
                name: Name,
                memory: Memory,
                memorymax: MemoryMax,
                storage: Storage,
                storagemax: StorageMax,
                players: Players.ToArray(),
                playercount: PlayerCount,
                playermax: PlayerMax,
                tps: Tps.ToDictionary(),
                status: Status,
                activeTime: ActiveTime
            ));
 }