Exemple #1
0
        private void StartTaskSyncTask(TaskSyncProfile syncProfile)
        {
            lock (LockerObject)
            {
                if (IsSettingsLoading)
                {
                    MessageService.ShowMessageAsync("Unable to do the operation as settings are loading.");
                    return;
                }

                IsSyncInProgress     = true;
                IsSettingsVisible    = false;
                syncProfile.LastSync = DateTime.Now;
                ShowNotification(true);
                UpdateStatus(StatusHelper.GetMessage(SyncStateEnum.SyncStarted, syncProfile.LastSync));
                UpdateStatus(StatusHelper.GetMessage(SyncStateEnum.Line));
                UpdateStatus(StatusHelper.GetMessage(SyncStateEnum.Profile, syncProfile.Name));
                UpdateStatus(StatusHelper.GetMessage(SyncStateEnum.Line));
                var syncMetric = new SyncMetric
                {
                    StartTime             = syncProfile.LastSync.GetValueOrDefault(),
                    ProfileName           = syncProfile.Name,
                    CalendarSyncDirection = syncProfile.SyncDirection.ToString()
                };
                SyncSummary.SyncMetrics.Add(syncMetric);
                var result = SyncStartService.SyncNow(syncProfile, syncMetric, SyncCallback);
                OnSyncCompleted(syncProfile, syncMetric, result);
            }
        }
Exemple #2
0
 public void Shutdown()
 {
     if (IsPeriodicSyncStarted)
     {
         SyncStartService.Stop(OnTimerElapsed);
     }
 }
Exemple #3
0
        private async Task StartPeriodicSync()
        {
            if (IsPeriodicSyncStarted)
            {
                SyncStartService.Stop(OnTimerElapsed);
                IsPeriodicSyncStarted = false;

                UpdateStatus($"Periodic Sync Stopped : {DateTime.Now}");
                UpdateStatus(StatusHelper.GetMessage(SyncStateEnum.LogSeparator));
            }
            else
            {
                var result = await SyncStartService.Start(OnTimerElapsed);

                if (result)
                {
                    foreach (var syncProfile in ScheduledSyncProfiles)
                    {
                        if (syncProfile.IsSyncEnabled && syncProfile.SyncFrequency != null)
                        {
                            syncProfile.NextSync = syncProfile.SyncFrequency.GetNextSyncTime(DateTime.Now);
                        }
                    }

                    IsPeriodicSyncStarted = true;
                    UpdateStatus($"Periodic Sync Started : {DateTime.Now}");
                    UpdateStatus(StatusHelper.GetMessage(SyncStateEnum.LogSeparator));
                }
            }
        }