Exemplo n.º 1
0
        public static RescueData Deserialize(RescueDataRaw raw)
        {
            var result = new RescueData();

            result.notes       = raw.notes;
            result.row_headers = raw.row_headers;
            result.rows        = new List <RescueDataEntry>();

            foreach (var list in raw.rows)
            {
                var entry = new RescueDataEntry()
                {
                    Rank             = Int32.Parse(list[0]),
                    TimeSpentSeconds = Int32.Parse(list[1]),
                    NumberOfPeople   = Int32.Parse(list[2]),
                    Activity         = list[3],
                    Category         = list[4],
                    Productivity     = Int32.Parse(list[5]),
                };

                result.rows.Add(entry);
            }

            return(result);
        }
Exemplo n.º 2
0
        public void Refresh()
        {
            // TODO: thread web request
            var web = new WebClient();
            var str = web.DownloadString(_url);

            var a = str.IndexOf('{');
            var b = str.LastIndexOf('}');

            var json = str.Substring(a, b - a + 1);

            //var obj = JsonConvert.DeserializeObject<Dictionary<string, object>>(json);

            var raw  = JsonConvert.DeserializeObject <RescueDataRaw>(json);
            var data = RescueData.Deserialize(raw);

            _json = json;
            _raw  = raw;
            _data = data;
        }
Exemplo n.º 3
0
        public static RescueData Deserialize(RescueDataRaw raw)
        {
            var result = new RescueData();

            result.notes = raw.notes;
            result.row_headers = raw.row_headers;
            result.rows = new List<RescueDataEntry>();

            foreach (var list in raw.rows)
            {
                var entry = new RescueDataEntry() {
                    Rank = Int32.Parse(list[0]),
                    TimeSpentSeconds = Int32.Parse(list[1]),
                    NumberOfPeople = Int32.Parse(list[2]),
                    Activity = list[3],
                    Category = list[4],
                    Productivity = Int32.Parse(list[5]),
                };

                result.rows.Add(entry);
            }

            return result;
        }
Exemplo n.º 4
0
        public void Refresh()
        {
            // TODO: thread web request
            var web = new WebClient();
            var str = web.DownloadString(_url);

            var a = str.IndexOf('{');
            var b = str.LastIndexOf('}');

            var json = str.Substring(a, b - a + 1);

            //var obj = JsonConvert.DeserializeObject<Dictionary<string, object>>(json);

            var raw = JsonConvert.DeserializeObject<RescueDataRaw>(json);
            var data = RescueData.Deserialize(raw);

            _json = json;
            _raw = raw;
            _data = data;
        }