private async void btnRefresh_Click(object sender, RoutedEventArgs e)
 {
     if (!NetworkInterface.GetIsNetworkAvailable())
     {
         await new MessageDialog("İnternet bağlantınızı kontrol ediniz").ShowAsync();
     }
     else
     {
         this.LayoutRoot.ShowStatus("dersler güncelleniyor..");
         LessonRequests.LessonRequest.OnCompleted += GetLessons_Completed;
         LessonRequests.GetLessons(Database.TempData.Student.Id, Database.TempData.Student.Password, tempPeriod.Code, tempPeriod.YearCode);
     }
 }
Beispiel #2
0
        public async void Run(IBackgroundTaskInstance taskInstance)
        {
            deferral = taskInstance.GetDeferral();

            if (NetworkInterface.GetIsNetworkAvailable())
            {
                var saver = new DataSaver();
                saver.ReadCompleted = (json) =>
                {
                    obj = JObject.Parse(json);

                    Global.ApiUsername = obj["Settings"]["ApiUsername"].ToString();
                    Global.ApiPassword = obj["Settings"]["ApiPassword"].ToString();
                    if (Global.Invoke == null)
                    {
                        Global.Invoke = (action) => { action(); }
                    }
                    ;

                    currentStudent = JsonConvert.DeserializeObject <Student>(obj["Student"].ToString());

                    if (currentStudent != null)
                    {
                        var currentPeriod = currentStudent.Programs[0].Periods[0];

                        LessonRequests.LessonRequest.OnCompleted = GetLessons_Completed;
                        LessonRequests.GetLessons(currentStudent.Id, currentStudent.Password, currentPeriod.Code, currentPeriod.YearCode);
                    }
                };
                saver.ReadAsync("SavedData");
            }
            else
            {
                deferral.Complete();
            }
        }