private List <ScheduleEntry> GetScheduleEntriesForService(ScheduleEntries entriesInStore, Service service)
        {
            List <ScheduleEntry> entries   = new List <ScheduleEntry>();
            ServiceStartTimeKey  start_key = new ServiceStartTimeKey(service, new DateTime(0));
            long id = service.Id;

            using (StoredObjectsEnumerator <ScheduleEntry> enumerator = entriesInStore.GetStoredObjectsEnumerator())
            {
                if (enumerator.Seek(start_key, SeekType.AfterEQ))
                {
                    do
                    {
                        ScheduleEntry entry = enumerator.Current;
                        if (entry.Service == null)
                        {
                            Util.Trace(TraceLevel.Error, "Schedule entry with no service assignment: {0}", entry);
                            continue;
                        }
                        if (entry.Service.Id != id)
                        {
                            break;
                        }
                        entries.Add(entry);
                    } while (enumerator.MoveNext());
                }
            }
            return(entries);
        }
        private ScheduleEntry SmartFindStartScheduleEntry(StoredObjectsEnumerator <ScheduleEntry> enumerator, ScheduleEntry entryToMerge)
        {
            ScheduleEntry       current = null;
            ServiceStartTimeKey key     = new ServiceStartTimeKey(entryToMerge.Service, entryToMerge.StartTime - TimeSpan.FromSeconds(1));

            if (enumerator.Seek(key, SeekType.BeforeEQ))
            {
                current = enumerator.Current;
                if (current.Service == null || current.Service.Id != entryToMerge.Service.Id ||
                    current.EndTime < entryToMerge.StartTime + TimeSpan.FromSeconds(1))
                {
                    current = this.NextScheduleEntryForService(enumerator, entryToMerge.Service.Id);
                }
                return(current);
            }
            enumerator.Reset();
            return(this.NextScheduleEntryForService(enumerator, entryToMerge.Service.Id));
        }
 private ScheduleEntry SmartFindStartScheduleEntry(StoredObjectsEnumerator<ScheduleEntry> enumerator, ScheduleEntry entryToMerge)
 {
     ScheduleEntry current = null;
     ServiceStartTimeKey key = new ServiceStartTimeKey(entryToMerge.Service, entryToMerge.StartTime - TimeSpan.FromSeconds(1));
     if (enumerator.Seek(key, SeekType.BeforeEQ))
     {
         current = enumerator.Current;
         if (current.Service == null || current.Service.Id != entryToMerge.Service.Id ||
             current.EndTime < entryToMerge.StartTime + TimeSpan.FromSeconds(1))
         {
             current = this.NextScheduleEntryForService(enumerator, entryToMerge.Service.Id);
         }
         return current;
     }
     enumerator.Reset();
     return this.NextScheduleEntryForService(enumerator, entryToMerge.Service.Id);
 }
        private List<ScheduleEntry> GetScheduleEntriesForService(ScheduleEntries entriesInStore, Service service)
        {
            List<ScheduleEntry> entries = new List<ScheduleEntry>();
            ServiceStartTimeKey start_key = new ServiceStartTimeKey(service, new DateTime(0));
            long id = service.Id;
            using (StoredObjectsEnumerator<ScheduleEntry> enumerator = entriesInStore.GetStoredObjectsEnumerator())
            {
                if (enumerator.Seek(start_key, SeekType.AfterEQ))
                {
                    do
                    {
                        ScheduleEntry entry = enumerator.Current;
                        if (entry.Service == null)
                        {
                            Util.Trace(TraceLevel.Error, "Schedule entry with no service assignment: {0}", entry);
                            continue;
                        }
                        if (entry.Service.Id != id) break;
                        entries.Add(entry);
                    } while (enumerator.MoveNext());

                }
            }
            return entries;
        }