在后台更新TodoTask



我有一个应用程序,用来跟踪活动。为了将这些活动与Microsoft Outlook日历同步,我使用以下代码为每个活动创建一个TodoTask:

public async Task<bool> AddCallToCalendar(ActivityModels.Call call)
{
var user = await _graphClient.Me.Request().Select("MailboxSettings").GetAsync();
var userTimeZone = user.MailboxSettings.TimeZone;
var todoTask = new TodoTask
{
DueDateTime = new DateTimeTimeZone
{
DateTime = call.Date.ToString("o"),
TimeZone = userTimeZone,
ODataType = null
},

IsReminderOn = true,
ReminderDateTime = new DateTimeTimeZone
{
DateTime = call.Date.AddMinutes(-15.0).ToString("o"),
TimeZone = userTimeZone,
ODataType = null
},
Importance = GetImportance(call.Activity.Priority),
Title = call.Activity.Subject,
LinkedResources = new TodoTaskLinkedResourcesCollectionPage()
{
new LinkedResource
{
WebUrl = $"https://example.com/activities/call/{call.Id}", 
ApplicationName = "Name",
DisplayName = "Name",
ODataType = null
}
},
ODataType = null
};
var todoLists = await _graphClient.Me.Todo.Lists.Request().GetAsync();
var defaultList = todoLists.Where(x => x.WellknownListName == WellknownListName.DefaultList).First();
try
{
await _graphClient.Me.Todo.Lists[defaultList.Id].Tasks.Request().AddAsync(todoTask);
return true;
}
catch (ServiceException ex)
{
return false;
}
}

上面的代码运行良好,但我面临的挑战是如何更新这个TodoTask。我想在后台进行更新,因为当前登录的用户可能有大量TodoTasks,搜索它们可能会影响性能。我知道Task.ReadWrite当前不支持应用程序权限,这将使在后台搜索和更新TodoTasks成为可能。有人知道怎么做吗?

感谢您的精彩想法/建议。

是,为了创建守护程序应用程序或后台进程,您需要具有应用程序权限(特定于您的场景(。不幸的是,目前它还不可用,我也看不到任何其他解决方法。所以我建议你考虑向微软提交用户语音,或者更好地支持现有的用户语音,这样他们就可以实现它

最新更新