Example #1
0
        private async void Button_Click_1(object sender, RoutedEventArgs e)
        {
            string parsedStream;
            StorageFolder tempFolder = ApplicationData.Current.LocalFolder;
            StorageFile file = await tempFolder.GetFileAsync("pontos.json");

            var buffer = await FileIO.ReadBufferAsync(file);
            using (var dr = DataReader.FromBuffer(buffer))
            {
                var bytes1251 = new Byte[buffer.Length];
                dr.ReadBytes(bytes1251);

                parsedStream = Encoding.GetEncoding("ISO-8859-1").GetString(bytes1251, 0, bytes1251.Length);
            }
            JsonClass lm = JsonConvert.DeserializeObject<JsonClass>(parsedStream);

            List<Pluviometro> lstUp = new List<Pluviometro>();

            foreach (Placemark item in lm.Placemark)
            {
                Pluviometro pv = new Pluviometro();
                string[] str = item.name.Split('-');
                string[] strRaio = item.LookAt.range.Split('.');
                pv.idEstacao = Convert.ToInt32(str[0].Substring(str[0].Length - 2));
                pv.nomeLocal = str[1];
                pv.raio = Convert.ToInt32(strRaio[0]);
                pv.latLng = new ParseGeoPoint(Convert.ToDouble(item.LookAt.latitude), Convert.ToDouble(item.LookAt.longitude));

                lstUp.Add(pv);
            }

            await lstUp.SaveAllAsync();
        }       
    static void sendHeroDataToParse(Dictionary<string, string> saveData, string heroId)
    {
        List<ParseObject> dataObj = new List<ParseObject> ();

        foreach (KeyValuePair<string,string> pair in saveData) {
            ParseObject PO = new ParseObject(TABLE_NAME);
            PO[HERO_ID_COLUMN] = heroId;
            PO[ATTRIBUTE_NAME_COLUMN] = pair.Key;
            PO[ATTRIBUTE_VALUE_COLUMN] = pair.Value;
            dataObj.Add(PO);

        }
        dataObj.SaveAllAsync ();
    }