Exemple #1
0
 public static void RemoveSubscriptionShellExposure(SubscriptionState subState)
 {
     using (subState.SubscriptionStore.AcquireStoreWriterLock())
     {
         DefinitionIdentity subscriptionId = subState.SubscriptionId;
         bool flag = false;
         ShellExposure.ShellExposureInformation exposureInformation = ShellExposure.ShellExposureInformation.CreateShellExposureInformation(subscriptionId);
         if (exposureInformation == null)
         {
             flag = true;
         }
         else
         {
             for (int index = 1; index <= 2; ++index)
             {
                 try
                 {
                     ShellExposure.RemoveShortcuts(exposureInformation);
                     break;
                 }
                 catch (DeploymentException ex)
                 {
                     Logger.AddInternalState("Remove shortcut entries Failed: " + exposureInformation.ApplicationShortcutPath + "," + exposureInformation.SupportShortcutPath + "," + exposureInformation.DesktopShortcutPath + "," + exposureInformation.ApplicationFolderPath + "," + exposureInformation.ApplicationRootFolderPath);
                     if (index < 2)
                     {
                         Thread.Sleep(1000);
                     }
                     else if (!(ex.InnerException is UnauthorizedAccessException))
                     {
                         throw;
                     }
                 }
             }
         }
         ShellExposure.RemoveArpEntry(subscriptionId);
         if (flag)
         {
             throw new DeploymentException(ExceptionTypes.Subscription, Resources.GetString("Ex_ShortcutRemovalFailureDueToInvalidPublisherProduct"));
         }
     }
 }
Exemple #2
0
        private static void UpdateShortcuts(SubscriptionState subState, ref ShellExposure.ShellExposureInformation shellExposureInformation)
        {
            string      str = string.Format("{0}#{1}", (object)subState.DeploymentProviderUri.AbsoluteUri, (object)subState.SubscriptionId.ToString());
            Description effectiveDescription = subState.EffectiveDescription;

            if (shellExposureInformation != null)
            {
                bool flag1 = true;
                bool flag2 = true;
                bool flag3 = true;
                bool flag4 = true;
                if (string.Compare(effectiveDescription.FilteredPublisher, shellExposureInformation.AppVendor, StringComparison.Ordinal) == 0)
                {
                    flag1 = false;
                    if (Utilities.CompareWithNullEqEmpty(effectiveDescription.FilteredSuiteName, shellExposureInformation.AppSuiteName, StringComparison.Ordinal) == 0)
                    {
                        flag2 = false;
                        if (string.Compare(effectiveDescription.FilteredProduct, shellExposureInformation.AppProduct, StringComparison.Ordinal) == 0)
                        {
                            flag3 = false;
                            if (string.Compare(str, shellExposureInformation.ShortcutAppId, StringComparison.Ordinal) == 0)
                            {
                                flag4 = false;
                            }
                        }
                    }
                }
                if (!flag1 && !flag2 && (!flag3 && !flag4) && System.IO.File.Exists(shellExposureInformation.ApplicationShortcutPath))
                {
                    Logger.AddInternalState("Shortcut folder and files are not updated and application shortcut file already exists: " + shellExposureInformation.ApplicationShortcutPath);
                    return;
                }
                if (flag3)
                {
                    ShellExposure.UnpinShortcut(shellExposureInformation.ApplicationShortcutPath);
                    ShellExposure.MoveDeleteFile(shellExposureInformation.ApplicationShortcutPath);
                    ShellExposure.MoveDeleteFile(shellExposureInformation.SupportShortcutPath);
                    ShellExposure.MoveDeleteFile(shellExposureInformation.DesktopShortcutPath);
                    Logger.AddInternalState("Shortcut files deleted:" + shellExposureInformation.ApplicationShortcutPath + "," + shellExposureInformation.SupportShortcutPath + "," + shellExposureInformation.DesktopShortcutPath);
                }
                if (flag2)
                {
                    Logger.AddInternalState("Attempt deleting shortcut folder:" + shellExposureInformation.ApplicationFolderPath);
                    ShellExposure.MoveDeleteEmptyFolder(shellExposureInformation.ApplicationFolderPath);
                }
                if (flag1)
                {
                    Logger.AddInternalState("Attempt deleting shortcut root folder:" + shellExposureInformation.ApplicationRootFolderPath);
                    ShellExposure.MoveDeleteEmptyFolder(shellExposureInformation.ApplicationRootFolderPath);
                }
                if (flag1 | flag2 | flag3)
                {
                    shellExposureInformation = ShellExposure.ShellExposureInformation.CreateShellExposureInformation(effectiveDescription.FilteredPublisher, effectiveDescription.FilteredSuiteName, effectiveDescription.FilteredProduct, str);
                }
                else
                {
                    Logger.AddInternalState("Shortcut app id has changed. Old value=" + shellExposureInformation.ShortcutAppId + ",New value=" + str);
                    shellExposureInformation.ShortcutAppId = str;
                }
            }
            else
            {
                shellExposureInformation = ShellExposure.ShellExposureInformation.CreateShellExposureInformation(effectiveDescription.FilteredPublisher, effectiveDescription.FilteredSuiteName, effectiveDescription.FilteredProduct, str);
            }
            try
            {
                Logger.AddInternalState("Create the shortcut directory : " + shellExposureInformation.ApplicationFolderPath);
                Directory.CreateDirectory(shellExposureInformation.ApplicationFolderPath);
                ShellExposure.GenerateAppShortcut(subState, shellExposureInformation);
                ShellExposure.GenerateSupportShortcut(subState, shellExposureInformation);
            }
            catch (Exception ex)
            {
                ShellExposure.RemoveShortcuts(shellExposureInformation);
                throw;
            }
        }