merge communication branch
This commit is contained in:
@@ -1,18 +1,14 @@
|
||||
using System.Diagnostics;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using Serilog;
|
||||
using Windows.ApplicationModel.Activation;
|
||||
using Windows.ApplicationModel.Background;
|
||||
using Windows.UI.Notifications;
|
||||
using Wino.Core;
|
||||
using Wino.Core.Domain;
|
||||
using Wino.Core.Domain.Enums;
|
||||
using Wino.Core.Domain.Interfaces;
|
||||
using Wino.Core.Domain.Models.MailItem;
|
||||
using Wino.Core.Domain.Models.Synchronization;
|
||||
using Wino.Core.UWP.Services;
|
||||
using Wino.Services;
|
||||
|
||||
#if NET8_0
|
||||
using CommunityToolkit.WinUI.Notifications;
|
||||
@@ -27,26 +23,23 @@ namespace Wino.Activation
|
||||
private const string BackgroundExecutionLogTag = "[BackgroundExecution] ";
|
||||
|
||||
private readonly IWinoRequestDelegator _winoRequestDelegator;
|
||||
private readonly IBackgroundSynchronizer _backgroundSynchronizer;
|
||||
private readonly INativeAppService _nativeAppService;
|
||||
private readonly IWinoRequestProcessor _winoRequestProcessor;
|
||||
private readonly IWinoSynchronizerFactory _winoSynchronizerFactory;
|
||||
private readonly IWinoServerConnectionManager _winoServerConnectionManager;
|
||||
private readonly IMailService _mailService;
|
||||
private ToastArguments _toastArguments;
|
||||
|
||||
BackgroundTaskDeferral _deferral;
|
||||
public BackgroundActivationHandler(IWinoRequestDelegator winoRequestDelegator,
|
||||
IBackgroundSynchronizer backgroundSynchronizer,
|
||||
INativeAppService nativeAppService,
|
||||
IWinoRequestProcessor winoRequestProcessor,
|
||||
IWinoSynchronizerFactory winoSynchronizerFactory,
|
||||
IWinoServerConnectionManager winoServerConnectionManager,
|
||||
IMailService mailService)
|
||||
{
|
||||
_winoRequestDelegator = winoRequestDelegator;
|
||||
_backgroundSynchronizer = backgroundSynchronizer;
|
||||
_nativeAppService = nativeAppService;
|
||||
_winoRequestProcessor = winoRequestProcessor;
|
||||
_winoSynchronizerFactory = winoSynchronizerFactory;
|
||||
_winoServerConnectionManager = winoServerConnectionManager;
|
||||
_mailService = mailService;
|
||||
}
|
||||
|
||||
@@ -90,38 +83,28 @@ namespace Wino.Activation
|
||||
{
|
||||
// We need to synchronize changes without reflection the UI changes.
|
||||
|
||||
var synchronizer = _winoSynchronizerFactory.GetAccountSynchronizer(mailItem.AssignedAccount.Id);
|
||||
// var synchronizer = _winoSynchronizerFactory.GetAccountSynchronizer(mailItem.AssignedAccount.Id);
|
||||
var prepRequest = new MailOperationPreperationRequest(action, mailItem);
|
||||
|
||||
var requests = await _winoRequestProcessor.PrepareRequestsAsync(prepRequest);
|
||||
|
||||
foreach (var request in requests)
|
||||
{
|
||||
synchronizer.QueueRequest(request);
|
||||
_winoServerConnectionManager.QueueRequest(request, mailItem.AssignedAccount.Id);
|
||||
|
||||
// synchronizer.QueueRequest(request);
|
||||
}
|
||||
|
||||
var options = new SynchronizationOptions()
|
||||
{
|
||||
Type = SynchronizationType.ExecuteRequests,
|
||||
AccountId = mailItem.AssignedAccount.Id
|
||||
};
|
||||
//var options = new SynchronizationOptions()
|
||||
//{
|
||||
// Type = SynchronizationType.ExecuteRequests,
|
||||
// AccountId = mailItem.AssignedAccount.Id
|
||||
//};
|
||||
|
||||
await synchronizer.SynchronizeAsync(options);
|
||||
//await synchronizer.SynchronizeAsync(options);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (taskName == BackgroundTaskService.BackgroundSynchronizationTimerTaskNameEx)
|
||||
{
|
||||
var watch = new Stopwatch();
|
||||
watch.Start();
|
||||
|
||||
// Run timer based background synchronization.
|
||||
|
||||
await _backgroundSynchronizer.RunBackgroundSynchronizationAsync(BackgroundSynchronizationReason.Timer);
|
||||
|
||||
watch.Stop();
|
||||
Log.Information($"{BackgroundExecutionLogTag}Background synchronization is completed in {watch.Elapsed.TotalSeconds} seconds.");
|
||||
}
|
||||
|
||||
instance.Canceled -= OnBackgroundExecutionCanceled;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user