Пример #1
0
        private async void LoadMemos()
        {
            IList <Memo> memos = new List <Memo>();

            try
            {
                // from server-end
                var temp = await NetHelper.GetAllMemos(Preference.GetUserID());

                memos = MemoSort.SortByTime(temp);
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.Message);
                // from local DB
                var temp = DBHelper.GetAllMemo();
                memos = MemoSort.SortByTime(temp);
            }

            foreach (var memo in memos)
            {
                var memoBlock = new MemoView(memo);
                memoBlock.Holding     += OnChoose;
                memoBlock.RightTapped += OnChoose;
                memoList.Children.Add(memoBlock);
            }
        }
Пример #2
0
        void IBackgroundTask.Run(IBackgroundTaskInstance taskInstance)
        {
            var deferral = taskInstance.GetDeferral();

            var allMemos = DBHelper.GetAllMemo();

            var memos = MemoSort.SortByTime(allMemos);

            NotificationHelper.RefreshTiles(memos);

            Debug.WriteLine("==============fire TileRefresher.");

            deferral.Complete();
        }
Пример #3
0
        private async void onSave(object sender, RoutedEventArgs e)
        {
            modifyingMemo.Title = titleTB.Text;
            var ds = timeDP.Date;
            var ts = timeTP.Time;

            modifyingMemo.Time    = new DateTime(ds.Year, ds.Month, ds.Day, ts.Hours, ts.Minutes, ts.Seconds, DateTimeKind.Local).ToUniversalTime();
            modifyingMemo.Content = contentTB.Text;

            Frame rootFrame = Window.Current.Content as Frame;

            if (type == OperateType.ADD || type == OperateType.SNAP)
            {
                // sync in server-end
                try
                {
                    var memoID = await NetHelper.AddMemo(Preference.GetUserID(), modifyingMemo);

                    modifyingMemo.MemoID = memoID;
                }
                catch (COMException)
                {
                    UnsyncQueue.Instance.Enqueue(new AddMemoOperation(Preference.GetUserID(), modifyingMemo));
                    modifyingMemo.MemoID = MemoIDGenerator.Generate(Preference.GetUserID());
                }

                // save in local DB
                DBHelper.AddMemo(modifyingMemo);

                // add notification
                NotificationHelper.AddToastToSchedule(modifyingMemo);

                // update tiles
                NotificationHelper.RefreshTiles(MemoSort.SortByTime(DBHelper.GetAllMemo()));

                rootFrame.Navigate(typeof(MainPage));
            }
            else if (type == OperateType.MODIFY)
            {
                // sync in server-end
                try
                {
                    await NetHelper.ModifyMemo(modifyingMemo);
                }
                catch (COMException)
                {
                    UnsyncQueue.Instance.Enqueue(new ModifyMemoOperation(modifyingMemo));
                }

                // save in local DB
                DBHelper.UpdateMemo(modifyingMemo);

                // add notification
                NotificationHelper.RemoveToastFromSchedule(modifyingMemo);
                NotificationHelper.AddToastToSchedule(modifyingMemo);

                // update tiles
                NotificationHelper.RefreshTiles(MemoSort.SortByTime(DBHelper.GetAllMemo()));

                rootFrame.Navigate(typeof(MainPage));
            }
        }