CalDavSynchronizer.Implementation.Events.DuplicateEventCleaner.DeleteDuplicates C# (CSharp) Метод

DeleteDuplicates() приватный Метод

private DeleteDuplicates ( ) : System.Threading.Tasks.Task
Результат System.Threading.Tasks.Task
    private async Task DeleteDuplicates()
    {
      var appointmentIdsWithIdenticalHashCode = GetAppointmentIdsWithIdenticalHashCode();

      if (appointmentIdsWithIdenticalHashCode.Length == 0)
        return;


      var relationsById = _entityRelationDataAccess.LoadEntityRelationData().ToDictionary(r => r.AtypeId);

      foreach (var ids in appointmentIdsWithIdenticalHashCode)
      {
        var appointments = await GetAppointments(ids);
        if (appointments.Length > 1)
        {
          try
          {
            var appointmentToKeep = appointments[0];
            var appointmentToKeepData = GetDuplicationRelevantData(appointmentToKeep.Inner);
            foreach (var appointmentToDelete in appointments.Skip(1))
            {
              if (GetDuplicationRelevantData(appointmentToDelete.Inner).Equals(appointmentToKeepData))
              {
                s_logger.Info($"Deleting duplicate of '{appointmentToKeep.Inner.EntryID}'");
                await DeleteAppointment(appointmentToDelete, relationsById);
              }
            }
          }
          finally
          {
            _outlookRepository.Cleanup(appointments);
          }
        }
      }
      _entityRelationDataAccess.SaveEntityRelationData(relationsById.Values.ToList());
    }