private void ScavengeAppsOverQuota(SubInstance[] subs, int deploysToScavenge, out bool appExcluded) { appExcluded = false; DateTime time = DateTime.UtcNow - Constants.OnlineAppScavengingGracePeriod; using (ComponentStore.StoreTransactionContext context = new ComponentStore.StoreTransactionContext(this._compStore)) { for (int i = subs.Length - 1; (i >= 0) && (deploysToScavenge > 0); i--) { bool flag = false; bool flag2 = false; if (subs[i].SubState.PreviousBind != null) { if (subs[i].LastAccessTime >= time) { appExcluded = true; } else { flag = true; } deploysToScavenge--; } if (deploysToScavenge > 0) { if (subs[i].LastAccessTime >= time) { appExcluded = true; } else { flag2 = true; } deploysToScavenge--; } if (flag2 || flag) { SubscriptionStateInternal newState = new SubscriptionStateInternal(subs[i].SubState); if (flag2) { newState.IsInstalled = false; } else { newState.PreviousBind = null; } this._compStore.PrepareFinalizeSubscriptionState(context, subs[i].SubState, newState); } } this._compStore.SubmitStoreTransaction(context, null); } }
public void CleanOnlineAppCache() { System.Deployment.Internal.Isolation.IDefinitionAppId[] idArray; SubInstance[] instanceArray = this.CollectOnlineApps(out idArray); using (ComponentStore.StoreTransactionContext context = new ComponentStore.StoreTransactionContext(this._compStore)) { foreach (SubInstance instance in instanceArray) { SubscriptionStateInternal newState = new SubscriptionStateInternal(instance.SubState) { IsInstalled = false }; this._compStore.PrepareFinalizeSubscriptionState(context, instance.SubState, newState); } this._compStore.SubmitStoreTransaction(context, null); } instanceArray = this.CollectOnlineApps(out idArray); ulong privateSize = 0L; ulong sharedSize = 0L; if (idArray.Length > 0) { this._compStore.CalculateDeploymentsUnderQuota(idArray.Length, idArray, ulong.MaxValue, ref privateSize, ref sharedSize); } PersistOnlineAppQuotaUsageEstimate(privateSize); }