Beispiel #1
0
        async Task IUploadable.Upload()
        {
            var memoID = await NetHelper.AddMemo(userID, memo);

            memo.MemoID = memoID;
            DBHelper.UpdateMemo(memo);
        }
Beispiel #2
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);
                NotificationHelper.AddTileNotification();

                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);

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