private void Validate() { if (!this._stateIsValid) { this.state = this._subStore.GetSubscriptionStateInternal(this); this._stateIsValid = true; } }
private static void ResetUpdateSkippedState(SubscriptionStateInternal newState) { newState.UpdateSkippedDeployment = null; newState.UpdateSkipTime = DateTime.MinValue; }
private void PrepareUpdateSkipTime(StoreTransactionContext storeTxn, SubscriptionState subState, System.Deployment.Application.DefinitionIdentity updateSkippedDeployment, DateTime updateSkipTime) { SubscriptionStateInternal newState = new SubscriptionStateInternal(subState) { UpdateSkippedDeployment = updateSkippedDeployment, UpdateSkipTime = updateSkipTime }; this.PrepareFinalizeSubscriptionState(storeTxn, subState, newState); }
private void PrepareSetSubscriptionState(StoreTransactionContext storeTxn, SubscriptionState subState, SubscriptionStateInternal newState) { this.PrepareFinalizeSubscription(storeTxn, subState, newState); this.PrepareSetSubscriptionProperties(storeTxn, subState, newState); this.PrepareRemoveOrphanedDeployments(storeTxn, subState, newState); }
private void PrepareSetSubscriptionProperties(StoreTransactionContext storeTxn, SubscriptionState subState, SubscriptionStateInternal newState) { Logger.AddInternalState("Changing Subscription Properties:"); Logger.AddInternalState("Old subscription state = " + subState.ToString()); Logger.AddInternalState("New subscription state = " + newState.ToString()); SubscriptionStateVariable[] variableArray = new SubscriptionStateVariable[] { new SubscriptionStateVariable("IsShellVisible", newState.IsShellVisible, subState.IsShellVisible), new SubscriptionStateVariable("PreviousBind", newState.PreviousBind, subState.PreviousBind), new SubscriptionStateVariable("PendingBind", newState.PendingBind, subState.PendingBind), new SubscriptionStateVariable("ExcludedDeployment", newState.ExcludedDeployment, subState.ExcludedDeployment), new SubscriptionStateVariable("PendingDeployment", newState.PendingDeployment, subState.PendingDeployment), new SubscriptionStateVariable("DeploymentProviderUri", newState.DeploymentProviderUri, subState.DeploymentProviderUri), new SubscriptionStateVariable("MinimumRequiredVersion", newState.MinimumRequiredVersion, subState.MinimumRequiredVersion), new SubscriptionStateVariable("LastCheckTime", newState.LastCheckTime, subState.LastCheckTime), new SubscriptionStateVariable("UpdateSkippedDeployment", newState.UpdateSkippedDeployment, subState.UpdateSkippedDeployment), new SubscriptionStateVariable("UpdateSkipTime", newState.UpdateSkipTime, subState.UpdateSkipTime), new SubscriptionStateVariable("AppType", (ushort) newState.appType, (ushort) subState.appType), new SubscriptionStateVariable("CurrentBind", newState.CurrentBind, subState.CurrentBind) }; ArrayList list = new ArrayList(); foreach (SubscriptionStateVariable variable in variableArray) { if ((!subState.IsInstalled || !variable.IsUnchanged) || !newState.IsInstalled) { list.Add(new System.Deployment.Internal.Isolation.StoreOperationMetadataProperty(Constants.DeploymentPropertySet, variable.PropertyName, newState.IsInstalled ? ToPropertyString(variable.NewValue) : null)); } } if (list.Count > 0) { System.Deployment.Internal.Isolation.StoreOperationMetadataProperty[] setProperties = (System.Deployment.Internal.Isolation.StoreOperationMetadataProperty[]) list.ToArray(typeof(System.Deployment.Internal.Isolation.StoreOperationMetadataProperty)); System.Deployment.Application.DefinitionAppId id = new System.Deployment.Application.DefinitionAppId(new System.Deployment.Application.DefinitionIdentity[] { subState.SubscriptionId }); storeTxn.Add(new System.Deployment.Internal.Isolation.StoreOperationSetDeploymentMetadata(id.ComPointer, this.InstallReference, setProperties)); } }
private void PrepareSetPendingDeployment(StoreTransactionContext storeTxn, SubscriptionState subState, System.Deployment.Application.DefinitionIdentity deployId, DateTime checkTime) { SubscriptionStateInternal newState = new SubscriptionStateInternal(subState) { PendingDeployment = deployId, LastCheckTime = checkTime }; if ((newState.PendingDeployment != null) && !newState.PendingDeployment.Equals(subState.UpdateSkippedDeployment)) { ResetUpdateSkippedState(newState); } this.PrepareFinalizeSubscriptionState(storeTxn, subState, newState); }
private void PrepareRollbackSubscription(StoreTransactionContext storeTxn, SubscriptionState subState) { SubscriptionStateInternal newState = new SubscriptionStateInternal(subState) { ExcludedDeployment = subState.CurrentBind.DeploymentIdentity, CurrentBind = subState.PreviousBind, PreviousBind = null }; this.PrepareFinalizeSubscriptionState(storeTxn, subState, newState); }
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); } }
private void PrepareRemoveOrphanedDeployments(StoreTransactionContext storeTxn, SubscriptionState subState, SubscriptionStateInternal newState) { ArrayList list = new ArrayList(); list.Add(subState.CurrentBind); list.Add(subState.PreviousBind); list.Add(subState.PendingBind); list.Remove(newState.CurrentBind); list.Remove(newState.PreviousBind); list.Remove(newState.PendingBind); foreach (System.Deployment.Application.DefinitionAppId id in list) { if (id != null) { this.PrepareRemoveDeployment(storeTxn, subState, id); } } }
private void PrepareFinalizeSubscriptionState(StoreTransactionContext storeTxn, SubscriptionState subState, SubscriptionStateInternal newState) { FinalizeSubscriptionState(newState); this.PrepareSetSubscriptionState(storeTxn, subState, newState); }
private void PrepareFinalizeSubscription(StoreTransactionContext storeTxn, SubscriptionState subState, SubscriptionStateInternal newState) { if (newState.IsInstalled && ((!subState.IsInstalled || (newState.IsShellVisible != subState.IsShellVisible)) || !newState.CurrentBind.Equals(subState.CurrentBind))) { System.Deployment.Application.DefinitionAppId deployAppId = newState.CurrentBind.ToDeploymentAppId(); if (newState.IsShellVisible) { this.PrepareInstallUninstallDeployment(storeTxn, deployAppId, true); } else { this.PreparePinUnpinDeployment(storeTxn, deployAppId, true); } } }
private SubscriptionStateInternal PrepareCommitDeploymentState(StoreTransactionContext storeTxn, SubscriptionState subState, CommitApplicationParams commitParams) { System.Deployment.Application.DefinitionAppId appId = commitParams.AppId; AssemblyManifest deployManifest = commitParams.DeployManifest; SubscriptionStateInternal newState = new SubscriptionStateInternal(subState); if (commitParams.IsConfirmed) { newState.IsInstalled = true; newState.IsShellVisible = deployManifest.Deployment.Install; newState.DeploymentProviderUri = (deployManifest.Deployment.ProviderCodebaseUri != null) ? deployManifest.Deployment.ProviderCodebaseUri : commitParams.DeploySourceUri; if (deployManifest.Deployment.MinimumRequiredVersion != null) { newState.MinimumRequiredVersion = deployManifest.Deployment.MinimumRequiredVersion; } if (!appId.Equals(subState.CurrentBind)) { newState.CurrentBind = appId; newState.PreviousBind = (newState.IsShellVisible && !subState.IsShellVisible) ? null : subState.CurrentBind; } newState.PendingBind = null; newState.PendingDeployment = null; newState.ExcludedDeployment = null; newState.appType = commitParams.appType; ResetUpdateSkippedState(newState); } else { newState.PendingBind = appId; newState.PendingDeployment = appId.DeploymentIdentity; if (!newState.PendingDeployment.Equals(subState.UpdateSkippedDeployment)) { ResetUpdateSkippedState(newState); } } newState.LastCheckTime = commitParams.TimeStamp; FinalizeSubscriptionState(newState); return newState; }
public SubscriptionStateInternal GetSubscriptionStateInternal(System.Deployment.Application.DefinitionIdentity subId) { SubscriptionStateInternal internal2 = new SubscriptionStateInternal { IsInstalled = this.IsSubscriptionInstalled(subId) }; if (internal2.IsInstalled) { System.Deployment.Application.DefinitionAppId appId = new System.Deployment.Application.DefinitionAppId(new System.Deployment.Application.DefinitionIdentity[] { subId }); internal2.IsShellVisible = this.GetPropertyBoolean(appId, "IsShellVisible"); internal2.CurrentBind = this.GetPropertyDefinitionAppId(appId, "CurrentBind"); internal2.PreviousBind = this.GetPropertyDefinitionAppId(appId, "PreviousBind"); internal2.PendingBind = this.GetPropertyDefinitionAppId(appId, "PendingBind"); internal2.ExcludedDeployment = this.GetPropertyDefinitionIdentity(appId, "ExcludedDeployment"); internal2.PendingDeployment = this.GetPropertyDefinitionIdentity(appId, "PendingDeployment"); internal2.DeploymentProviderUri = this.GetPropertyUri(appId, "DeploymentProviderUri"); internal2.MinimumRequiredVersion = this.GetPropertyVersion(appId, "MinimumRequiredVersion"); internal2.LastCheckTime = this.GetPropertyDateTime(appId, "LastCheckTime"); internal2.UpdateSkippedDeployment = this.GetPropertyDefinitionIdentity(appId, "UpdateSkippedDeployment"); internal2.UpdateSkipTime = this.GetPropertyDateTime(appId, "UpdateSkipTime"); internal2.appType = this.GetPropertyAppType(appId, "AppType"); if (internal2.CurrentBind == null) { throw new InvalidDeploymentException(Resources.GetString("Ex_NoCurrentBind")); } internal2.CurrentDeployment = internal2.CurrentBind.DeploymentIdentity; internal2.CurrentDeploymentManifest = this.GetAssemblyManifest(internal2.CurrentDeployment); internal2.CurrentDeploymentSourceUri = this.GetPropertyUri(internal2.CurrentBind, "DeploymentSourceUri"); internal2.CurrentApplication = internal2.CurrentBind.ApplicationIdentity; internal2.CurrentApplicationManifest = this.GetAssemblyManifest(internal2.CurrentBind.ApplicationIdentity); internal2.CurrentApplicationSourceUri = this.GetPropertyUri(internal2.CurrentBind, "ApplicationSourceUri"); System.Deployment.Application.DefinitionIdentity identity = (internal2.PreviousBind != null) ? internal2.PreviousBind.DeploymentIdentity : null; internal2.RollbackDeployment = ((identity != null) && ((internal2.MinimumRequiredVersion == null) || (identity.Version >= internal2.MinimumRequiredVersion))) ? identity : null; if (internal2.PreviousBind == null) { return internal2; } try { internal2.PreviousApplication = internal2.PreviousBind.ApplicationIdentity; internal2.PreviousApplicationManifest = this.GetAssemblyManifest(internal2.PreviousBind.ApplicationIdentity); } catch (Exception exception) { if (ExceptionUtility.IsHardException(exception)) { throw; } Logger.AddInternalState("Exception thrown for GetAssemblyManifest in GetSubscriptionStateInternal: " + exception.GetType().ToString() + ":" + exception.Message); internal2.PreviousBind = null; internal2.RollbackDeployment = null; internal2.PreviousApplication = null; internal2.PreviousApplicationManifest = null; } } return internal2; }
private static void FinalizeSubscriptionState(SubscriptionStateInternal newState) { if (!newState.IsInstalled) { newState.Reset(); } else { System.Deployment.Application.DefinitionAppId currentBind = newState.CurrentBind; System.Deployment.Application.DefinitionIdentity deploymentIdentity = currentBind.DeploymentIdentity; System.Deployment.Application.DefinitionAppId previousBind = newState.PreviousBind; if ((previousBind != null) && previousBind.Equals(currentBind)) { newState.PreviousBind = (System.Deployment.Application.DefinitionAppId) (previousBind = null); } System.Deployment.Application.DefinitionIdentity identity2 = (previousBind != null) ? previousBind.DeploymentIdentity : null; System.Deployment.Application.DefinitionIdentity excludedDeployment = newState.ExcludedDeployment; if ((excludedDeployment != null) && (excludedDeployment.Equals(deploymentIdentity) || excludedDeployment.Equals(identity2))) { newState.ExcludedDeployment = (System.Deployment.Application.DefinitionIdentity) (excludedDeployment = null); } System.Deployment.Application.DefinitionIdentity pendingDeployment = newState.PendingDeployment; if ((pendingDeployment != null) && (pendingDeployment.Equals(deploymentIdentity) || pendingDeployment.Equals(excludedDeployment))) { newState.PendingDeployment = (System.Deployment.Application.DefinitionIdentity) (pendingDeployment = null); } System.Deployment.Application.DefinitionAppId pendingBind = newState.PendingBind; if ((pendingBind != null) && (!pendingBind.DeploymentIdentity.Equals(pendingDeployment) || pendingBind.Equals(previousBind))) { newState.PendingBind = (System.Deployment.Application.DefinitionAppId) (pendingBind = null); } } }
private void PrepareRemoveSubscription(StoreTransactionContext storeTxn, SubscriptionState subState) { SubscriptionStateInternal newState = new SubscriptionStateInternal(subState) { IsInstalled = false }; this.PrepareFinalizeSubscriptionState(storeTxn, subState, newState); }
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); }