private void ProcessNewlyChanges(DateTime?lastSyncDate) { var lastSyncronizationDate = LastSyncDates.FirstOrDefault(); if (lastSyncDate == null || lastSyncronizationDate == null || !lastSyncronizationDate.GetValue().HasValue || lastSyncronizationDate.GetValue().Value.AddMinutes(_storageRepository.GetProfile <BugzillaProfile>().SynchronizationInterval) < DateTime.Now) { var dateValue = GetSyncDate(lastSyncDate); var synchronizationTime = DateTime.Now; int[] changedIds; if (TryGetChangedIds(dateValue, out changedIds)) { if (changedIds.Length > 0) { _logger.InfoFormat("{0} changed bugs found", changedIds.Length); } LastSyncDates.ReplaceWith(new BugTracking.ImportToTp.LastSyncDate(synchronizationTime)); ProcessChangedBugIds(changedIds); } else { FailedSyncDates.ReplaceWith(new FailedSyncDate(dateValue)); } } }
private DateTime?GetSyncDate(DateTime?lastSyncDate) { if (lastSyncDate == null) { return(null); } var lastFailedDate = FailedSyncDates.FirstOrDefault(); var lastSyncronizationDate = LastSyncDates.FirstOrDefault(); return(lastFailedDate != null?lastFailedDate.GetValue() : (lastSyncronizationDate != null ? lastSyncronizationDate.GetValue() : lastSyncDate)); }