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 PrepareRemoveSubscription(StoreTransactionContext storeTxn, SubscriptionState subState) { SubscriptionStateInternal newState = new SubscriptionStateInternal(subState) { IsInstalled = false }; this.PrepareFinalizeSubscriptionState(storeTxn, subState, newState); }
internal void RemoveApplicationInstance(SubscriptionState subState, System.Deployment.Application.DefinitionAppId appId) { using (StoreTransactionContext context = new StoreTransactionContext(this)) { this.PrepareRemoveDeployment(context, subState, appId); this.SubmitStoreTransaction(context, subState); } }
private void SubmitStoreTransaction(StoreTransactionContext storeTxn, SubscriptionState subState) { CodeMarker_Singleton.Instance.CodeMarker(CodeMarkerEvent.perfPersisterWriteStart); storeTxn.Add(new System.Deployment.Internal.Isolation.StoreOperationScavenge(false)); System.Deployment.Internal.Isolation.StoreTransactionOperation[] operations = storeTxn.Operations; if (operations.Length > 0) { uint[] rgDispositions = new uint[operations.Length]; int[] rgResults = new int[operations.Length]; try { uint num; this._store.Transact(operations, rgDispositions, rgResults); this._stateMgr.Scavenge(0, out num); } catch (DirectoryNotFoundException exception) { throw new DeploymentException(ExceptionTypes.ComponentStore, Resources.GetString("Ex_TransactDirectoryNotFoundException"), exception); } catch (ArgumentException exception2) { throw new DeploymentException(ExceptionTypes.ComponentStore, Resources.GetString("Ex_StoreOperationFailed"), exception2); } catch (UnauthorizedAccessException exception3) { throw new DeploymentException(ExceptionTypes.ComponentStore, Resources.GetString("Ex_StoreOperationFailed"), exception3); } catch (IOException exception4) { throw new DeploymentException(ExceptionTypes.ComponentStore, Resources.GetString("Ex_StoreOperationFailed"), exception4); } finally { CodeMarker_Singleton.Instance.CodeMarker(CodeMarkerEvent.perfPersisterWriteEnd); Logger.AddTransactionInformation(operations, rgDispositions, rgResults); } if (subState != null) { subState.Invalidate(); } } }
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 PrepareStageDeploymentComponent(StoreTransactionContext storeTxn, SubscriptionState subState, CommitApplicationParams commitParams) { System.Deployment.Application.DefinitionAppId id = commitParams.AppId.ToDeploymentAppId(); string deployManifestPath = commitParams.DeployManifestPath; storeTxn.Add(new System.Deployment.Internal.Isolation.StoreOperationStageComponent(id.ComPointer, deployManifestPath)); this.PrepareSetDeploymentProperties(storeTxn, commitParams.AppId, commitParams); }
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 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 PrepareCommitApplication(StoreTransactionContext storeTxn, SubscriptionState subState, CommitApplicationParams commitParams) { System.Deployment.Application.DefinitionAppId appId = commitParams.AppId; SubscriptionStateInternal newState = null; if (commitParams.CommitDeploy) { newState = this.PrepareCommitDeploymentState(storeTxn, subState, commitParams); if ((commitParams.IsConfirmed && appId.Equals(newState.CurrentBind)) || (!commitParams.IsConfirmed && appId.Equals(newState.PendingBind))) { this.PrepareStageDeploymentComponent(storeTxn, subState, commitParams); } } if (commitParams.CommitApp) { this.PrepareStageAppComponent(storeTxn, commitParams); if (!commitParams.DeployManifest.Deployment.Install && (commitParams.appType != AppType.CustomHostSpecified)) { storeTxn.ScavengeContext.AddOnlineAppToCommit(appId, subState); } } if (commitParams.CommitDeploy) { this.PrepareSetSubscriptionState(storeTxn, subState, newState); } }
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 void CommitApplication(SubscriptionState subState, CommitApplicationParams commitParams) { try { using (StoreTransactionContext context = new StoreTransactionContext(this)) { this.PrepareCommitApplication(context, subState, commitParams); this.SubmitStoreTransactionCheckQuota(context, subState); } } catch (COMException exception) { if (exception.ErrorCode == -2147024784) { throw new DeploymentException(ExceptionTypes.DiskIsFull, Resources.GetString("Ex_StoreOperationFailed"), exception); } if (exception.ErrorCode == -2147023590) { throw new DeploymentException(ExceptionTypes.ComponentStore, Resources.GetString("Ex_InplaceUpdateOfApplicationAttempted"), exception); } throw; } }
public void CleanOnlineAppCache() { using (StoreTransactionContext context = new StoreTransactionContext(this)) { context.ScavengeContext.CleanOnlineAppCache(); } }
private void SubmitStoreTransactionCheckQuota(StoreTransactionContext storeTxn, SubscriptionState subState) { storeTxn.ScavengeContext.CalculateSizesPreTransact(); this.SubmitStoreTransaction(storeTxn, subState); storeTxn.ScavengeContext.CalculateSizesPostTransact(); storeTxn.ScavengeContext.CheckQuotaAndScavenge(); }
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 PrepareFinalizeSubscriptionState(StoreTransactionContext storeTxn, SubscriptionState subState, SubscriptionStateInternal newState) { FinalizeSubscriptionState(newState); this.PrepareSetSubscriptionState(storeTxn, subState, newState); }
private void PrepareSetDeploymentProperties(StoreTransactionContext storeTxn, System.Deployment.Application.DefinitionAppId appId, CommitApplicationParams commitParams) { string str = null; string str2 = null; string str3 = null; if (commitParams != null) { str = ToPropertyString(commitParams.DeploySourceUri); str2 = ToPropertyString(commitParams.AppSourceUri); if ((commitParams.IsUpdateInPKTGroup && (commitParams.Trust == null)) && commitParams.IsFullTrustRequested) { str3 = ToPropertyString(commitParams.IsFullTrustRequested); } else if (commitParams.IsUpdate && (commitParams.Trust == null)) { str3 = null; } else if (commitParams.appType == AppType.CustomHostSpecified) { str3 = null; } else { str3 = ToPropertyString(commitParams.Trust.DefaultGrantSet.PermissionSet.IsUnrestricted()); } } System.Deployment.Internal.Isolation.StoreOperationMetadataProperty[] setProperties = new System.Deployment.Internal.Isolation.StoreOperationMetadataProperty[] { new System.Deployment.Internal.Isolation.StoreOperationMetadataProperty(Constants.DeploymentPropertySet, "DeploymentSourceUri", str), new System.Deployment.Internal.Isolation.StoreOperationMetadataProperty(Constants.DeploymentPropertySet, "ApplicationSourceUri", str2), new System.Deployment.Internal.Isolation.StoreOperationMetadataProperty(Constants.DeploymentPropertySet, "IsFullTrust", str3) }; storeTxn.Add(new System.Deployment.Internal.Isolation.StoreOperationSetDeploymentMetadata(appId.ComPointer, this.InstallReference, setProperties)); }
private void PrepareInstallFile(StoreTransactionContext storeTxn, System.Deployment.Application.Manifest.File file, System.Deployment.Application.DefinitionAppId appId, System.Deployment.Application.DefinitionIdentity asmId, string asmPayloadPath) { string srcFile = Path.Combine(asmPayloadPath, file.NameFS); string name = file.Name; storeTxn.Add(new System.Deployment.Internal.Isolation.StoreOperationStageComponentFile(appId.ComPointer, (asmId != null) ? asmId.ComPointer : null, name, srcFile)); }
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 PrepareInstallPrivateAssembly(StoreTransactionContext storeTxn, DependentAssembly privAsm, System.Deployment.Application.DefinitionAppId appId, string appPayloadPath) { string codebaseFS = privAsm.CodebaseFS; string path = Path.Combine(appPayloadPath, codebaseFS); string directoryName = Path.GetDirectoryName(path); AssemblyManifest manifest = new AssemblyManifest(path); System.Deployment.Application.DefinitionIdentity asmId = manifest.Identity; string rawXmlFilePath = manifest.RawXmlFilePath; if (rawXmlFilePath == null) { rawXmlFilePath = path + ".genman"; asmId = ManifestGenerator.GenerateManifest(privAsm.Identity, manifest, rawXmlFilePath); } storeTxn.Add(new System.Deployment.Internal.Isolation.StoreOperationStageComponent(appId.ComPointer, asmId.ComPointer, rawXmlFilePath)); foreach (System.Deployment.Application.Manifest.File file in manifest.Files) { this.PrepareInstallFile(storeTxn, file, appId, asmId, directoryName); } }
private void PrepareStageAppComponent(StoreTransactionContext storeTxn, CommitApplicationParams commitParams) { System.Deployment.Application.DefinitionAppId appId = commitParams.AppId; AssemblyManifest appManifest = commitParams.AppManifest; string appManifestPath = commitParams.AppManifestPath; string appPayloadPath = commitParams.AppPayloadPath; string appGroup = commitParams.AppGroup; if (appGroup == null) { if (appManifestPath == null) { throw new ArgumentNullException("commitParams"); } storeTxn.Add(new System.Deployment.Internal.Isolation.StoreOperationStageComponent(appId.ComPointer, appManifestPath)); } foreach (System.Deployment.Application.Manifest.File file in appManifest.GetFilesInGroup(appGroup, true)) { this.PrepareInstallFile(storeTxn, file, appId, null, appPayloadPath); } foreach (DependentAssembly assembly in appManifest.GetPrivateAssembliesInGroup(appGroup, true)) { this.PrepareInstallPrivateAssembly(storeTxn, assembly, appId, appPayloadPath); } }
private void PreparePinUnpinDeployment(StoreTransactionContext storeTxn, System.Deployment.Application.DefinitionAppId deployAppId, bool isPin) { if (isPin) { storeTxn.Add(new System.Deployment.Internal.Isolation.StoreOperationPinDeployment(deployAppId.ComPointer, this.InstallReference)); } else { storeTxn.Add(new System.Deployment.Internal.Isolation.StoreOperationUnpinDeployment(deployAppId.ComPointer, this.InstallReference)); } }
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 PrepareRemoveDeployment(StoreTransactionContext storeTxn, SubscriptionState subState, System.Deployment.Application.DefinitionAppId appId) { System.Deployment.Application.DefinitionAppId deployAppId = appId.ToDeploymentAppId(); if (subState.IsShellVisible) { this.PrepareInstallUninstallDeployment(storeTxn, deployAppId, false); } else { this.PreparePinUnpinDeployment(storeTxn, deployAppId, false); } this.PrepareSetDeploymentProperties(storeTxn, appId, null); storeTxn.ScavengeContext.AddDeploymentToUnpin(deployAppId, subState); ApplicationTrust.RemoveCachedTrust(appId); }
public void RollbackSubscription(SubscriptionState subState) { try { using (StoreTransactionContext context = new StoreTransactionContext(this)) { this.PrepareRollbackSubscription(context, subState); this.SubmitStoreTransactionCheckQuota(context, subState); } } catch (COMException exception) { if (exception.ErrorCode == -2147024784) { throw new DeploymentException(ExceptionTypes.DiskIsFull, Resources.GetString("Ex_StoreOperationFailed"), exception); } throw; } }
public void SetUpdateSkipTime(SubscriptionState subState, System.Deployment.Application.DefinitionIdentity updateSkippedDeployment, DateTime updateSkipTime) { try { using (StoreTransactionContext context = new StoreTransactionContext(this)) { this.PrepareUpdateSkipTime(context, subState, updateSkippedDeployment, updateSkipTime); this.SubmitStoreTransaction(context, subState); } } catch (COMException exception) { if (exception.ErrorCode == -2147024784) { throw new DeploymentException(ExceptionTypes.DiskIsFull, Resources.GetString("Ex_StoreOperationFailed"), exception); } throw; } }