Ejemplo n.º 1
0
        private bool BindCoreWithAppId(bool blocking, ref FileStream refTransaction, ref string productName)
        {
            SubscriptionState subscriptionState = this._subStore.GetSubscriptionState(this._bindAppId.DeploymentIdentity.ToSubscriptionId());

            if (!subscriptionState.IsInstalled)
            {
                throw new InvalidDeploymentException(Resources.GetString("Ex_BindAppIdNotInstalled"));
            }
            if (!this._bindAppId.Equals((object)subscriptionState.CurrentBind))
            {
                throw new InvalidDeploymentException(Resources.GetString("Ex_BindAppIdNotCurrrent"));
            }
            if (!blocking && this._cancellationPending)
            {
                return(true);
            }
            long transactionId;

            refTransaction = this._subStore.AcquireReferenceTransaction(out transactionId);
            bool flag = this._subStore.CheckAndReferenceApplication(subscriptionState, this._bindAppId, transactionId);
            ActivationDescription activationDescription = new ActivationDescription();

            activationDescription.SetDeploymentManifest(subscriptionState.CurrentDeploymentManifest, subscriptionState.CurrentDeploymentSourceUri, (string)null);
            Logger.SetDeploymentManifest(this._log, subscriptionState.CurrentDeploymentManifest);
            activationDescription.IsUpdate = this._isupdate;
            activationDescription.SetApplicationManifest(subscriptionState.CurrentApplicationManifest, subscriptionState.CurrentApplicationSourceUri, (string)null);
            Logger.SetApplicationManifest(this._log, subscriptionState.CurrentApplicationManifest);
            Logger.SetApplicationUrl(this._log, subscriptionState.CurrentApplicationSourceUri);
            activationDescription.AppId = new DefinitionAppId(activationDescription.ToAppCodebase(), new DefinitionIdentity[2]
            {
                activationDescription.DeployManifest.Identity,
                activationDescription.AppManifest.Identity
            });
            if (!blocking && this._cancellationPending)
            {
                return(true);
            }
            Description effectiveDescription = subscriptionState.EffectiveDescription;

            productName  = effectiveDescription.Product;
            this._cached = flag;
            Logger.AddInternalState(this._log, "_cached=" + this._cached.ToString());
            Logger.AddInternalState(this._log, "_isupdate=" + this._isupdate.ToString());
            this._referenceTransaction = refTransaction;
            this._actCtx  = DeploymentManager.ConstructActivationContextFromStore(activationDescription.AppId);
            this._actDesc = activationDescription;
            return(false);
        }
Ejemplo n.º 2
0
 private bool BindCore(bool blocking, ref TempFile tempDeploy, ref TempDirectory tempAppDir, ref FileStream refTransaction, ref string productName)
 {
     try
     {
         if (this._deploySource == (Uri)null)
         {
             return(this.BindCoreWithAppId(blocking, ref refTransaction, ref productName));
         }
         Uri deploySource = this._deploySource;
         this._state = DeploymentProgressState.DownloadingDeploymentInformation;
         Logger.AddInternalState(this._log, "Internal state=" + (object)this._state);
         AssemblyManifest      assemblyManifest1 = DownloadManager.DownloadDeploymentManifest(this._subStore, ref deploySource, out tempDeploy, blocking ? (IDownloadNotification)null : (IDownloadNotification)this, this._downloadOptions);
         string                path    = tempDeploy.Path;
         ActivationDescription actDesc = new ActivationDescription();
         actDesc.SetDeploymentManifest(assemblyManifest1, deploySource, path);
         Logger.SetDeploymentManifest(this._log, assemblyManifest1);
         actDesc.IsUpdate = this._isupdate;
         if (actDesc.DeployManifest.Deployment == null)
         {
             throw new InvalidDeploymentException(ExceptionTypes.InvalidManifest, Resources.GetString("Ex_NotDeploymentOrShortcut"));
         }
         if (!blocking && this._cancellationPending)
         {
             return(true);
         }
         long transactionId;
         refTransaction = this._subStore.AcquireReferenceTransaction(out transactionId);
         SubscriptionState subscriptionState = this._subStore.GetSubscriptionState(actDesc.DeployManifest);
         if (actDesc.DeployManifest.Deployment.Install && actDesc.DeployManifest.Deployment.ProviderCodebaseUri == (Uri)null && (subscriptionState != null && subscriptionState.DeploymentProviderUri != (Uri)null) && !subscriptionState.DeploymentProviderUri.Equals((object)deploySource))
         {
             throw new DeploymentException(ExceptionTypes.DeploymentUriDifferent, string.Format((IFormatProvider)CultureInfo.CurrentUICulture, Resources.GetString("Ex_DeploymentUriDifferentExText"), new object[3]
             {
                 (object)actDesc.DeployManifest.Description.FilteredProduct,
                 (object)deploySource.AbsoluteUri,
                 (object)subscriptionState.DeploymentProviderUri.AbsoluteUri
             }));
         }
         DefinitionAppId appId;
         try
         {
             appId = new DefinitionAppId(actDesc.ToAppCodebase(), new DefinitionIdentity[2]
             {
                 actDesc.DeployManifest.Identity,
                 new DefinitionIdentity(actDesc.DeployManifest.MainDependentAssembly.Identity)
             });
         }
         catch (COMException ex)
         {
             throw new InvalidDeploymentException(ExceptionTypes.InvalidManifest, Resources.GetString("Ex_IdentityIsNotValid"), (Exception)ex);
         }
         catch (SEHException ex)
         {
             throw new InvalidDeploymentException(ExceptionTypes.InvalidManifest, Resources.GetString("Ex_IdentityIsNotValid"), (Exception)ex);
         }
         Logger.AddInternalState(this._log, "expectedAppId=" + appId.ToString());
         bool flag1 = this._subStore.CheckAndReferenceApplication(subscriptionState, appId, transactionId);
         if (flag1 && appId.Equals((object)subscriptionState.CurrentBind))
         {
             Logger.AddInternalState(this._log, "Application is found in store and it is the CurrentBind. Binding with appid.");
             this._bindAppId = appId;
             return(this.BindCoreWithAppId(blocking, ref refTransaction, ref productName));
         }
         if (flag1)
         {
             Logger.AddInternalState(this._log, "Application is found in store but it is not the CurrentBind.");
         }
         else
         {
             Logger.AddInternalState(this._log, "Application is not found in store.");
         }
         if (!blocking && this._cancellationPending)
         {
             return(true);
         }
         this._state = DeploymentProgressState.DownloadingApplicationInformation;
         Logger.AddInternalState(this._log, "Internal state=" + (object)this._state);
         tempAppDir = this._subStore.AcquireTempDirectory();
         Uri              appSourceUri;
         string           appManifestPath;
         AssemblyManifest assemblyManifest2 = DownloadManager.DownloadApplicationManifest(actDesc.DeployManifest, tempAppDir.Path, actDesc.DeploySourceUri, blocking ? (IDownloadNotification)null : (IDownloadNotification)this, this._downloadOptions, out appSourceUri, out appManifestPath);
         AssemblyManifest.ReValidateManifestSignatures(actDesc.DeployManifest, assemblyManifest2);
         Logger.SetApplicationManifest(this._log, assemblyManifest2);
         Logger.SetApplicationUrl(this._log, appSourceUri);
         actDesc.SetApplicationManifest(assemblyManifest2, appSourceUri, appManifestPath);
         actDesc.AppId = new DefinitionAppId(actDesc.ToAppCodebase(), new DefinitionIdentity[2]
         {
             actDesc.DeployManifest.Identity,
             actDesc.AppManifest.Identity
         });
         bool flag2 = this._subStore.CheckAndReferenceApplication(subscriptionState, actDesc.AppId, transactionId);
         if (!blocking && this._cancellationPending)
         {
             return(true);
         }
         Description effectiveDescription = actDesc.EffectiveDescription;
         productName  = effectiveDescription.Product;
         this._cached = flag2;
         Logger.AddInternalState(this._log, "_cached=" + this._cached.ToString());
         Logger.AddInternalState(this._log, "_isupdate=" + this._isupdate.ToString());
         this._tempApplicationDirectory = tempAppDir;
         this._tempDeployment           = tempDeploy;
         this._referenceTransaction     = refTransaction;
         this._actCtx  = DeploymentManager.ConstructActivationContext(actDesc);
         this._actDesc = actDesc;
     }
     catch (Exception ex)
     {
         this.LogError(Resources.GetString("Ex_FailedToDownloadManifest"), ex);
         Logger.AddInternalState(this._log, "Exception thrown in  BindCore(): " + ex.GetType().ToString() + " : " + ex.Message + "\r\n" + ex.StackTrace);
         throw;
     }
     return(false);
 }
 private ActivationDescription ProcessOrFollowShortcut(string shortcutFile, ref string errorPageUrl, out TempFile deployFile)
 {
     DefinitionIdentity identity;
     Uri uri;
     deployFile = null;
     Logger.AddMethodCall("ProcessOrFollowShortcut(shortcutFile=" + shortcutFile + ",errorPageUrl=" + errorPageUrl + ") called.");
     string str = shortcutFile;
     string activationParameter = null;
     int index = shortcutFile.IndexOf('|', 0);
     if (index > 0)
     {
         str = shortcutFile.Substring(0, index);
         if ((index + 1) < shortcutFile.Length)
         {
             activationParameter = shortcutFile.Substring(index + 1);
         }
     }
     Logger.AddInternalState("shortcutParameter=" + activationParameter);
     ShellExposure.ParseAppShortcut(str, out identity, out uri);
     SubscriptionState subscriptionState = this._subStore.GetSubscriptionState(identity);
     ActivationDescription description = null;
     if (subscriptionState.IsInstalled && subscriptionState.IsShellVisible)
     {
         Logger.AddInternalState("Application family is already installed and Shell Visible.");
         this.PerformDeploymentUpdate(ref subscriptionState, ref errorPageUrl);
         if (activationParameter == null)
         {
             this.Activate(subscriptionState.CurrentBind, subscriptionState.CurrentApplicationManifest, null, false);
             return description;
         }
         this.Activate(subscriptionState.CurrentBind, subscriptionState.CurrentApplicationManifest, activationParameter, true);
         return description;
     }
     Uri sourceUri = uri;
     Logger.AddInternalState("Application family is not installed or is not Shell-Visible.  Try to deploy it from the deployment provider specified in the shortcut : " + sourceUri);
     Logger.AddInternalState("Start processing deployment manifest.");
     AssemblyManifest manifest = DownloadManager.DownloadDeploymentManifest(this._subStore, ref sourceUri, out deployFile);
     Logger.AddInternalState("Processing of deployment manifest has successfully completed.");
     if (manifest.Description != null)
     {
         errorPageUrl = manifest.Description.ErrorReportUrl;
     }
     if (!manifest.Deployment.Install)
     {
         throw new DeploymentException(ExceptionTypes.Activation, Resources.GetString("Ex_ShortcutRefOnlineOnly"));
     }
     description = new ActivationDescription();
     description.SetDeploymentManifest(manifest, sourceUri, deployFile.Path);
     description.IsUpdate = false;
     description.ActType = ActivationType.InstallViaShortcut;
     return description;
 }
 private ActivationDescription ProcessOrFollowExtension(Uri associatedFile, string textualSubId, string deploymentProviderUrlFromExtension, ref string errorPageUrl, out TempFile deployFile)
 {
     deployFile = null;
     Logger.AddMethodCall(string.Concat(new object[] { "ProcessOrFollowExtension(", associatedFile, ",", textualSubId, ",", deploymentProviderUrlFromExtension, ",", errorPageUrl, ") called." }));
     DefinitionIdentity subId = new DefinitionIdentity(textualSubId);
     SubscriptionState subscriptionState = this._subStore.GetSubscriptionState(subId);
     ActivationDescription description = null;
     if (subscriptionState.IsInstalled && subscriptionState.IsShellVisible)
     {
         Logger.AddInternalState("Application family is already installed and Shell Visible.");
         this.PerformDeploymentUpdate(ref subscriptionState, ref errorPageUrl);
         this.Activate(subscriptionState.CurrentBind, subscriptionState.CurrentApplicationManifest, associatedFile.AbsoluteUri, true);
         return description;
     }
     Logger.AddInternalState("Application family is not installed or is not Shell-Visible.  Try to deploy it from the deployment provider specified in the extension : " + deploymentProviderUrlFromExtension);
     if (string.IsNullOrEmpty(deploymentProviderUrlFromExtension))
     {
         throw new DeploymentException(ExceptionTypes.Activation, string.Format(CultureInfo.CurrentUICulture, Resources.GetString("Ex_FileAssociationNoDpUrl"), new object[] { textualSubId }));
     }
     Uri sourceUri = new Uri(deploymentProviderUrlFromExtension);
     Logger.AddInternalState("Start processing deployment manifest.");
     AssemblyManifest manifest = DownloadManager.DownloadDeploymentManifest(this._subStore, ref sourceUri, out deployFile);
     if (manifest.Description != null)
     {
         errorPageUrl = manifest.Description.ErrorReportUrl;
     }
     Logger.AddInternalState("Processing of deployment manifest has successfully completed.");
     if (!manifest.Deployment.Install)
     {
         throw new DeploymentException(ExceptionTypes.Activation, Resources.GetString("Ex_FileAssociationRefOnline"));
     }
     description = new ActivationDescription();
     description.SetDeploymentManifest(manifest, sourceUri, deployFile.Path);
     description.IsUpdate = false;
     description.ActType = ActivationType.InstallViaFileAssociation;
     return description;
 }
 private void PerformDeploymentUpdate(ref SubscriptionState subState, ref string errorPageUrl)
 {
     DeploymentUpdate deploymentUpdate = subState.CurrentDeploymentManifest.Deployment.DeploymentUpdate;
     bool flag = (deploymentUpdate != null) && deploymentUpdate.BeforeApplicationStartup;
     Logger.AddPhaseInformation(Resources.GetString("PhaseLog_DeploymentUpdateCheck"));
     Logger.AddMethodCall("PerformDeploymentUpdate called.");
     Logger.AddInternalState(string.Concat(new object[] { "UpdateOnStart=", flag.ToString(), ",PendingDeployment=", subState.PendingDeployment }));
     if (flag || ((subState.PendingDeployment != null) && !SkipUpdate(subState, subState.PendingDeployment)))
     {
         using (TempFile file = null)
         {
             AssemblyManifest manifest;
             Uri deploymentProviderUri = subState.DeploymentProviderUri;
             try
             {
                 Logger.AddInternalState("Start processing deployment manifest for update check : " + deploymentProviderUri);
                 manifest = DownloadManager.DownloadDeploymentManifest(this._subStore, ref deploymentProviderUri, out file);
                 Logger.AddInternalState("End processing deployment manifest.");
                 if (manifest.Description != null)
                 {
                     errorPageUrl = manifest.Description.ErrorReportUrl;
                 }
             }
             catch (DeploymentDownloadException exception)
             {
                 Logger.AddErrorInformation(exception, Resources.GetString("Upd_UpdateCheckDownloadFailed"), new object[] { subState.SubscriptionId.ToString() });
                 return;
             }
             if (this._ui.SplashCancelled())
             {
                 throw new DownloadCancelledException();
             }
             if ((!SkipUpdate(subState, manifest.Identity) && (this._subStore.CheckUpdateInManifest(subState, deploymentProviderUri, manifest, subState.CurrentDeployment.Version) != null)) && !manifest.Identity.Equals(subState.ExcludedDeployment))
             {
                 Logger.AddInternalState("Update available in the deployment server.");
                 ActivationDescription actDesc = new ActivationDescription();
                 actDesc.SetDeploymentManifest(manifest, deploymentProviderUri, file.Path);
                 actDesc.IsUpdate = true;
                 actDesc.IsRequiredUpdate = false;
                 actDesc.ActType = ActivationType.UpdateViaShortcutOrFA;
                 if ((manifest.Deployment.MinimumRequiredVersion != null) && (manifest.Deployment.MinimumRequiredVersion.CompareTo(subState.CurrentDeployment.Version) > 0))
                 {
                     actDesc.IsRequiredUpdate = true;
                 }
                 this.CheckDeploymentProviderValidity(actDesc, subState);
                 this.ConsumeUpdatedDeployment(ref subState, actDesc);
             }
         }
     }
 }
 private void PerformDeploymentActivation(Uri activationUri, bool isShortcut, string textualSubId, string deploymentProviderUrlFromExtension, BrowserSettings browserSettings, ref string errorPageUrl)
 {
     TempFile deployFile = null;
     Logger.AddMethodCall("PerformDeploymentActivation called.");
     try
     {
         ActivationDescription description;
         string shortcutFile = null;
         Uri uri = null;
         bool flag = false;
         this._subStore = SubscriptionStore.CurrentUser;
         this._subStore.RefreshStorePointer();
         Uri sourceUri = activationUri;
         bool flag2 = false;
         if (textualSubId != null)
         {
             Logger.AddInternalState("Activating through file association.");
             flag2 = true;
             description = this.ProcessOrFollowExtension(activationUri, textualSubId, deploymentProviderUrlFromExtension, ref errorPageUrl, out deployFile);
             if (description == null)
             {
                 return;
             }
         }
         else if (isShortcut)
         {
             Logger.AddInternalState("Activating through shortcut.");
             shortcutFile = activationUri.LocalPath;
             description = this.ProcessOrFollowShortcut(shortcutFile, ref errorPageUrl, out deployFile);
             if (description == null)
             {
                 return;
             }
         }
         else
         {
             SubscriptionState state;
             Logger.AddInternalState("Activating through deployment manifest.");
             Logger.AddInternalState("Start processing deployment manifest.");
             AssemblyManifest deploymentManifest = DownloadManager.DownloadDeploymentManifestBypass(this._subStore, ref sourceUri, out deployFile, out state, null, null);
             if ((browserSettings != null) && (deployFile != null))
             {
                 browserSettings.Validate(deployFile.Path);
             }
             if (deploymentManifest.Description != null)
             {
                 errorPageUrl = deploymentManifest.Description.ErrorReportUrl;
             }
             description = new ActivationDescription();
             if (state != null)
             {
                 shortcutFile = null;
                 description.SetApplicationManifest(state.CurrentApplicationManifest, null, null);
                 description.AppId = state.CurrentBind;
                 Logger.AddInternalState("Running from the store. Bypass further downloads and verifications.");
                 flag = true;
             }
             else
             {
                 shortcutFile = deployFile.Path;
             }
             Logger.SetDeploymentManifest(deploymentManifest);
             Logger.AddPhaseInformation(Resources.GetString("PhaseLog_ProcessingDeploymentManifestComplete"));
             Logger.AddInternalState("Processing of deployment manifest has successfully completed.");
             description.SetDeploymentManifest(deploymentManifest, sourceUri, shortcutFile);
             description.IsUpdate = false;
             description.ActType = ActivationType.InstallViaDotApplication;
             uri = activationUri;
         }
         if (this._ui.SplashCancelled())
         {
             throw new DownloadCancelledException();
         }
         if (description.DeployManifest.Deployment == null)
         {
             throw new DeploymentException(ExceptionTypes.Activation, Resources.GetString("Ex_NotDeploymentOrShortcut"));
         }
         bool flag3 = false;
         SubscriptionState subscriptionState = this._subStore.GetSubscriptionState(description.DeployManifest);
         this.CheckDeploymentProviderValidity(description, subscriptionState);
         if (!flag)
         {
             Logger.AddInternalState("Could not find application in store. Continue with downloading application manifest.");
             flag3 = this.InstallApplication(ref subscriptionState, description);
             Logger.AddPhaseInformation(Resources.GetString("PhaseLog_InstallationComplete"));
             Logger.AddInternalState("Installation of application has successfully completed.");
         }
         else
         {
             this._subStore.SetLastCheckTimeToNow(subscriptionState);
         }
         if ((description.DeployManifest.Deployment.DisallowUrlActivation && !isShortcut) && (!activationUri.IsFile || activationUri.IsUnc))
         {
             if (flag3)
             {
                 this._ui.ShowMessage(Resources.GetString("Activation_DisallowUrlActivationMessageAfterInstall"), Resources.GetString("Activation_DisallowUrlActivationCaptionAfterInstall"));
             }
             else
             {
                 this._ui.ShowMessage(Resources.GetString("Activation_DisallowUrlActivationMessage"), Resources.GetString("Activation_DisallowUrlActivationCaption"));
             }
         }
         else if (flag2)
         {
             this.Activate(description.AppId, description.AppManifest, activationUri.AbsoluteUri, true);
         }
         else if (isShortcut)
         {
             string activationParameter = null;
             int index = shortcutFile.IndexOf('|', 0);
             if ((index > 0) && ((index + 1) < shortcutFile.Length))
             {
                 activationParameter = shortcutFile.Substring(index + 1);
             }
             if (activationParameter == null)
             {
                 this.Activate(description.AppId, description.AppManifest, null, false);
             }
             else
             {
                 this.Activate(description.AppId, description.AppManifest, activationParameter, true);
             }
         }
         else
         {
             this.Activate(description.AppId, description.AppManifest, uri.AbsoluteUri, false);
         }
     }
     finally
     {
         if (deployFile != null)
         {
             deployFile.Dispose();
         }
     }
 }