コード例 #1
0
ファイル: MainViewModel.cs プロジェクト: karthikb351/vitinfo2
        void DownloadComplete(object sender, DownloadStringCompletedEventArgs e)
        {
            try
            {
                List<String> data = new List<String>();
                AppSettings dat = new AppSettings();
                string jData = e.Result.ToString();
                int count = 0;
                if (jData.Contains("valid%"))
                {
                    jData = jData.Substring(6);
                    JsonTextReader reader = new JsonTextReader(new System.IO.StringReader(jData));
                    JArray root = JArray.Load(reader);
                    foreach (JObject j in root)
                    {
                        data.Add("BREAK" + count); count += 1;
                        data.Add((string)j["code"]); //0
                        data.Add((string)j["title"]); //1
                        data.Add((string)j["type"]); //2
                        data.Add((string)j["slot"]); //3
                        data.Add((string)j["attended"]); //4
                        data.Add((string)j["conducted"]); //5
                        data.Add((string)j["percentage"]); //6
                        data.Add((string)j["regdate"]); //7
                        data.Add((string)j["classnbr"]); //8
                        JArray details = (JArray)j["details"];
                        for (int i = 0; i < details.Count; i++) { data.Add(details[i].ToString()); }
                    }
                    dat.StoreSetting("NUMBEROFSUBJECTS", Convert.ToString(count - 1));
                    dat.saveList("ATTENDANCE", data);

                }

                Deployment.Current.Dispatcher.BeginInvoke(() =>
                {
                    reloadData();
                });

            }
            catch (Exception k)
            {
                Debug.WriteLine(k.Message);
                Deployment.Current.Dispatcher.BeginInvoke(() =>
                {
                    reloadData();
                });
            }
        }