public HistoryData(string date)
        {
            if (date != "")
            {
                // init
                SubjectHistoryData = new List <SubjectHistoryData>();

                var data = StudentData.ParseJSON((string)localSettings.Values[date]);
                Date = data["date"].ToString();
                JArray historyDataArray = (JArray)data["subjects"];

                foreach (JObject historyDataItem in historyDataArray)
                {
                    string            subject     = historyDataItem["name"].ToString();
                    List <PeroidItem> peroidItems = new List <PeroidItem>();

                    JArray peroidArray = (JArray)historyDataItem["peroids"];
                    foreach (JObject peroidItem in peroidArray)
                    {
                        peroidItems.Add(new PeroidItem((string)peroidItem["time"], (int)peroidItem["percent"]));
                    }

                    SubjectHistoryData.Add(new SubjectHistoryData(subject, peroidItems));
                }
            }
        }
Exemple #2
0
 public AttendanceItem(JObject data)
 {
     Code                = data["code"].ToString();
     Description         = data["description"].ToString();
     Date                = data["date"].ToString();
     Date                = Date.Substring(0, Date.IndexOf(" "));
     Peroid              = data["period"].ToString();
     Name                = data["name"].ToString();
     DisplayName         = Name;
     Color               = StudentData.GetColor(Code);
     SmallTextFontWeight = FontWeights.Normal;
 }
        public static async Task <string> Refresh()
        {
            string studata    = "";
            string studataOld = "";

            // get account info
            ApplicationDataContainer account = ApplicationData.Current.LocalSettings;
            string username = (string)account.Values["UsrName"];
            string password = (string)account.Values["Passwd"];

            // kissing
            try { studata = await Kissing(username, password, false); } catch (Exception) { }

            // bad network or server error
            if (studata == "")
            {
                return("error");
            }

            // save studata
            else
            {
                // move previous studata to old
                studataOld = await GetStudentData(NewOrOld.New);
                await SaveStudentData(studataOld, NewOrOld.Old);

                // save current studata to new
                await SaveStudentData(studata, NewOrOld.New);

                // clear history
                for (int i = subjects.Count; i >= 1; i--)
                {
                    subjects.RemoveAt(i - 1);
                }
                for (int j = attendances.Count; j >= 1; j--)
                {
                    attendances.RemoveAt(j - 1);
                }

                // new StudentData
                StudentData studentData = new StudentData(ParseJSON(studata), ParseJSON(studataOld));

                if (DisabledMsgDialog != null)
                {
                    await DisabledMsgDialog.ShowAsync();
                }

                return("okey dokey");
            }
        }
Exemple #4
0
 public AssignmentItem(JObject data)
 {
     Name                = data["name"].ToString();
     DisplayName         = data["name"].ToString();
     Date                = data["date"].ToString();
     Date                = Date.Substring(0, Date.IndexOf(" "));
     Percentage          = data["percent"].ToString();
     Score               = data["score"].ToString();
     MaximumScore        = data["pointsPossible"].ToString();
     MaximumScore        = MaximumScore.Substring(0, MaximumScore.IndexOf("."));
     LetterGrade         = data["letterGrade"].ToString();
     Category            = data["category"].ToString();
     IncludeInFinalGrade = data["includeInFinalGrade"].ToString();
     Weight              = data["weight"].ToString();
     Terms               = data["terms"].ToObject <string[]>();
     IsNew               = false;
     LargeTextFontWeight = FontWeights.SemiLight;
     SmallTextFontWeight = FontWeights.Normal;
     Color               = StudentData.GetColor(LetterGrade);
 }
Exemple #5
0
        public Peroid(string time, JObject data)
        {
            Time        = time;
            Percent     = data["percent"].ToString();
            Percent     = Percent.Substring(0, Percent.IndexOf("."));
            LetterGrade = data["letter"].ToString();
            Eval        = data["eval"].ToString();
            IsActive    = false;
            Color       = StudentData.GetColor(LetterGrade);

            DateTime Genesis = new DateTime(1970, 1, 1, 0, 0, 0, 0, System.DateTimeKind.Utc);

            Date = Genesis.AddSeconds((double)data["startDate"]).ToLocalTime();

            if (data["comment"].ToString() == null)
            {
                Comment = "--";
            }
            else
            {
                Comment = data["comment"].ToString();
            }
        }