【发布时间】:2021-08-23 21:46:32
【问题描述】:
需要一些关于如何在经过一定时间后抛出 TimeoutException 以及将数据发送到我的 fireStore 数据库的方法仍未完成的建议,原因是互联网丢失或任何其他意外问题。
使用 f-Miyu 的 Plugin.CloudFirestore 插件。
向服务器发送数据的代码。
public async Task BackUpNotes(UserNotes n)
{
await CrossCloudFirestore.Current.Instance.Collection(FTxts.Notes).Document(n.ID)
.SetAsync(new {
n.ID,
n.Title,
n.Details,
n.CreatedDate,
n.IsStarred,
n.LastEditDate,
});
}
//调用这里
private async Task BackUpNotes()
{
if (IsBusy) return;
IsBusy = true;
int c = 0;
var answer = await Application.Current.MainPage.DisplayAlert("Confirmation", "Back Up Current Notes?", "Yes", "No");
if (answer)
{
foreach (var item in NotesCollection)
{
await CloudService.CS.BackUpNotes(item);
item.IsBackedUp = true;
await PlannerDataService.UpdateNote(item);
c++;
ToastMessageShort($"{c}/{NotesCollection.Count} Saved");
}
await GetNotes();
}
IsBusy = false;
}
【问题讨论】: