/// <summary> /// Load the list of <see cref="PartitionArchive"/> entries that are enabled. /// </summary> /// <returns>The list of <see cref="PartitionArchive"/> instances from the persistant store</returns> private static IList <PartitionArchive> LoadEnabledPartitionArchives() { using (IReadContext readContext = PersistentStoreRegistry.GetDefaultStore().OpenReadContext()) { IPartitionArchiveEntityBroker broker = readContext.GetBroker <IPartitionArchiveEntityBroker>(); PartitionArchiveSelectCriteria criteria = new PartitionArchiveSelectCriteria(); criteria.Enabled.EqualTo(true); return(broker.Find(criteria)); } }
public void RunApplication(string[] args) { using (IUpdateContext updateContext = PersistentStore.OpenUpdateContext(UpdateContextSyncMode.Flush)) { IPartitionArchiveEntityBroker partitionBroker = updateContext.GetBroker <IPartitionArchiveEntityBroker>(); PartitionArchiveSelectCriteria partitionCriteria = new PartitionArchiveSelectCriteria(); partitionCriteria.Enabled.EqualTo(true); partitionCriteria.ReadOnly.EqualTo(false); PartitionArchive activePartition = partitionBroker.FindOne(partitionCriteria); if (activePartition == null) { Platform.Log(LogLevel.Error, "No active ArchivePartition were found."); return; } partitionCriteria.ReadOnly.EqualTo(true); IList <ServerEntityKey> partitionKeys = new List <ServerEntityKey>(); foreach (PartitionArchive partition in partitionBroker.Find(partitionCriteria)) { partitionKeys.Add(partition.Key); } IArchiveQueueEntityBroker queueBroker = updateContext.GetBroker <IArchiveQueueEntityBroker>(); ArchiveQueueSelectCriteria queueCriteria = new ArchiveQueueSelectCriteria(); queueCriteria.ArchiveQueueStatusEnum.In(new ArchiveQueueStatusEnum[] { ArchiveQueueStatusEnum.Failed, ArchiveQueueStatusEnum.Pending }); queueCriteria.PartitionArchiveKey.In(partitionKeys); ArchiveQueueUpdateColumns queueColumns = new ArchiveQueueUpdateColumns() { PartitionArchiveKey = activePartition.Key, ArchiveQueueStatusEnum = ArchiveQueueStatusEnum.Pending, ProcessorId = "", ScheduledTime = Platform.Time }; if (queueBroker.Update(queueCriteria, queueColumns)) { updateContext.Commit(); } } }