Exemplo n.º 1
0
 private async Task AddAllToDos()
 {
     foreach (var sche in MyToDos)
     {
         var result = await PostHelper.AddSchedule(LocalSettingHelper.GetValue("sid"), sche.Content, sche.IsDone? "1" : "0", SelectedCate.ToString());
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// 从离线模式注册/登录后,同步所有
 /// </summary>
 /// <returns></returns>
 private async Task AddAllOfflineToDos()
 {
     foreach (var sche in AllToDos)
     {
         var result = await CloudService.AddToDoAsync(sche.Content, sche.IsDone? "1" : "0", SelectedCate.ToString());
     }
 }
Exemplo n.º 3
0
        private async Task AddToDo()
        {
            //离线模式
            if (App.isInOfflineMode || App.IsNoNetwork)
            {
                NewToDo.ID       = Guid.NewGuid().ToString();
                NewToDo.Category = this.SelectedCate;

                //0 for insert,1 for add
                if (LocalSettingHelper.GetValue("AddMode") == "0")
                {
                    MyToDos.Insert(0, NewToDo);
                }
                else
                {
                    MyToDos.Add(NewToDo);
                }
                await SerializerHelper.SerializerToJson <ObservableCollection <ToDo> >(MyToDos, SerializerFileNames.ToDoFileName);

                Messenger.Default.Send(new GenericMessage <ObservableCollection <ToDo> >(MyToDos), MessengerTokens.UpdateTile);

                NewToDo = new ToDo();

                IsLoading = Visibility.Collapsed;
            }
            else if (App.IsNoNetwork)
            {
                //TO DO: Store the schedule in SendingQueue
            }
            else
            {
                //在线模式
                var result = await PostHelper.AddSchedule(LocalSettingHelper.GetValue("sid"), NewToDo.Content, "0", SelectedCate.ToString());

                if (!string.IsNullOrEmpty(result))
                {
                    ToDo newSchedule = ToDo.ParseJsonTo(result);

                    if (LocalSettingHelper.GetValue("AddMode") == "0")
                    {
                        MyToDos.Insert(0, newSchedule);
                        UpdateDisplayList(SelectedCate);
                    }
                    else
                    {
                        MyToDos.Add(newSchedule);
                        UpdateDisplayList(SelectedCate);
                    }

                    await PostHelper.SetMyOrder(LocalSettingHelper.GetValue("sid"), ToDo.GetCurrentOrderString(MyToDos));

                    NewToDo = new ToDo();

                    Messenger.Default.Send(new GenericMessage <ObservableCollection <ToDo> >(MyToDos), MessengerTokens.UpdateTile);

                    IsLoading = Visibility.Collapsed;


                    await SerializerHelper.SerializerToJson <ObservableCollection <ToDo> >(MyToDos, SerializerFileNames.ToDoFileName);
                }
            }
        }