Exemple #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);
        }
Exemple #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;
        }
Exemple #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;
        }
Exemple #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;
        }