Пример #1
0
        /// <summary>
        /// Forwards from start page handler.
        /// It can go to:
        /// 0 - ComponentsPage, if everything is fine
        /// 1 - BlockPage, if an error occured, like initial requirements (.NET) are not there
        /// </summary>
        /// <param name="currentPage">The current page.</param>
        /// <returns>Page to move to</returns>
        public static Page ForwardFromStartPageHandler(Page currentPage)
        {
            string nextPageChoices = currentPage.NextPageArgument;

            string[] pageChoices = nextPageChoices.Split(new char[] { ',' });

            // default to go to the ComponentsPage.
            Page pageToReturn = PageRegistry.Instance.GetPage(pageChoices[0]);

            // There is a reason to block
            if (PropertyBagDictionary.Instance.PropertyExists(PropertyBagConstants.BlockReason))
            {
                SetupLogger.LogError("ForwardFromStartPageHandler: We need to block");
                pageToReturn = PageRegistry.Instance.GetPage(pageChoices[1]);
            }

            return(pageToReturn);
        }
Пример #2
0
        /// <summary>
        /// Forwards from AddRemoveComponents page.
        /// It can go to:
        /// 0 - EulaPage, if we are on the install path
        /// 1 - ARPRemoveDatabasePage, if we are on the uninstall path and we are uninstalling server
        /// 2 - ARPRemoveWAPDatabasePage, if we are on the uninstall path and we are uninstalling extension
        /// </summary>
        /// <param name="currentPage">The current page.</param>
        /// <returns>Page to move to</returns>
        public static Page ForwardFromAddRemoveComponentsPageHandler(Page currentPage)
        {
            string nextPageChoices = currentPage.NextPageArgument;

            string[] pageChoices = nextPageChoices.Split(new char[] { ',' });

            // Check to see if the length is correct
            if (pageChoices.Length != 3)
            {
                SetupLogger.LogError("ForwardFromAddRemoveComponentsPageHandler: Invalid XML description for Page");
                SetupLogger.LogError("XML Was {0}:", nextPageChoices);
                SetupLogger.LogError("XML should have been like: FirstPage,SecondPage,ThirdPage");
                throw new ArgumentException(currentPage.ToString());
            }
            String EulaPage = pageChoices[0];
            String ARPRemoveDatabasePage    = pageChoices[1];
            String ARPRemoveWAPDatabasePage = pageChoices[2];

            // default to go to the EulaPage
            Page pageToReturn = PageRegistry.Instance.GetPage(EulaPage);

            // Check if we are on the uninstall path
            if (PropertyBagDictionary.Instance.PropertyExists(PropertyBagConstants.Uninstall))
            {
                if (PropertyBagDictionary.Instance.PropertyExists(PropertyBagConstants.Server))
                {
                    SetupLogger.LogInfo("ForwardFromAddRemoveComponentsPageHandler: Move to Remove Database Page");
                    pageToReturn = PageRegistry.Instance.GetPage(ARPRemoveDatabasePage);
                }
                else
                {
                    SetupLogger.LogInfo("ForwardFromAddRemoveComponentsPageHandler: Move to Remove WAP database Page");
                    pageToReturn = PageRegistry.Instance.GetPage(ARPRemoveWAPDatabasePage);
                }
            }
            else
            {
                SetupLogger.LogInfo("ForwardFromAddRemoveComponentsPageHandler: Move to Eula Page");
                pageToReturn = PageRegistry.Instance.GetPage(EulaPage);
            }

            return(pageToReturn);
        }
Пример #3
0
        /// <summary>
        /// Page Skipper for Forward or Backward Navigation
        /// </summary>
        /// <param name="currentPage">The current page</param>
        /// <param name="isForward">if set to <c>true</c>, looks up the forward page arguments</param>
        /// <returns>The page to navigate to</returns>
        private static Page SkipPageHandler(Page currentPage, bool isForward)
        {
            // Get the page choices
            string pageArgument =
                isForward ? currentPage.NextPageArgument : currentPage.PreviousPageArgument;

            string[] pageChoices = pageArgument.Split(new char[] { ',' });

            // Check to see if the length is reasonable
            // This is our best guess at a reasonable length.  It the
            // code becomes more complex than this it will be unreadable.
            if (pageChoices.Length > 10)
            {
                SetupLogger.LogError("SkipPageHandler: Invalid XML: Exceeded arbitrary length of 10 choices.  Fix length or adjust hardcode in the function");
                throw new ArgumentException(currentPage.ToString());
            }

            // Browse the provided list of pages until we find one for which there is no
            // SkipXXXXX property existing in the bag
            Page foundPage = null;

            for (int pageIndex = 0; pageIndex < pageChoices.Length; ++pageIndex)
            {
                Page   page         = PageRegistry.Instance.GetPage(pageChoices[pageIndex]);
                string pageImplName = page.PageUI.GetType().Name;
                string propertyName = string.Format("Skip{0}", pageImplName);
                if (!PropertyBagDictionary.Instance.PropertyExists(propertyName))
                {
                    foundPage = page;
                    break;
                }
            }

            // No page found: Trace and throw
            if (null == foundPage)
            {
                SetupLogger.LogError("SkipPageHandler: Cant find a page to navigate to");
                throw new ArgumentException(currentPage.ToString());
            }

            return(foundPage);
        }
Пример #4
0
        private static bool ConsumeArgument(CommandlineArgument commandlineArgument, String argument, String parameter, bool throwOnDuplicate = true)
        {
            foreach (String marker in CommandlineParameterMarkers)
            {
                int comparison = String.Compare(argument, marker + parameter, true);
                if (comparison == 0)
                {
                    if (commandlineArgument.Valid == true)
                    {
                        SetupLogger.LogError("Argument {0} already set", argument);
                        if (throwOnDuplicate)
                        {
                            throw new Exception(String.Format("The parameter {0} is already specified.", argument));
                        }
                    }

                    return(true);
                }
            }

            return(false);
        }
        public Dictionary <string, object[]> PortAvailable(string svrName, Dictionary <string, List <string> > commands)
        {
            Dictionary <string, object[]> dictionary = new Dictionary <string, object[]>();
            DateTime d = DateTime.UtcNow.ToLocalTime();

            foreach (KeyValuePair <string, List <string> > keyValuePair in commands)
            {
                string value   = keyValuePair.Value[0];
                string text    = keyValuePair.Value[1];
                string text2   = keyValuePair.Value[2];
                int    timeout = 0;
                try
                {
                    if (text2.Length > 0)
                    {
                        timeout = Convert.ToInt32(text2);
                    }
                    if (text.Length > 0 && text != "TCP")
                    {
                        throw new ArgumentException();
                    }
                    int portNum = Convert.ToInt32(value);
                    d = DateTime.UtcNow.ToLocalTime();
                    object[] value2 = new object[]
                    {
                        (DateTime.UtcNow.ToLocalTime() - d).TotalMilliseconds.ToString(),
                        this.VerifyPort(svrName, portNum, text, timeout).ToString()
                    };
                    dictionary.Add(keyValuePair.Key, value2);
                }
                catch (Exception e)
                {
                    SetupLogger.LogError(e);
                    throw;
                }
            }
            return(dictionary);
        }
Пример #6
0
 // Token: 0x0600014D RID: 333 RVA: 0x000078D8 File Offset: 0x00005AD8
 public void StartFileCopying()
 {
     SetupLogger.Log(Strings.StartFileCopying);
     this.cancelFileCopy  = false;
     this.TotalFileCopied = 0;
     this.CopyFiles();
     if (this.cancelFileCopy)
     {
         try
         {
             this.DeleteTempFiles();
         }
         catch (Exception e)
         {
             SetupLogger.LogError(e);
         }
         this.FileCopierCancelEvent();
     }
     else
     {
         this.FileCopierCompletedEvent();
     }
     SetupLogger.Log(Strings.FileCopyingFinished);
 }
        // Token: 0x06000054 RID: 84 RVA: 0x0000387C File Offset: 0x00001A7C
        private void FileCopierUpdatesStatus(object message)
        {
            if (base.InvokeRequired)
            {
                base.Invoke(new CopyFilesPage.UpdateFileCopyingStatus(this.FileCopierUpdatesStatus), new object[]
                {
                    message
                });
                return;
            }
            string text = null;

            if (message is ILocalizedString)
            {
                text = message.ToString();
                SetupLogger.Log((LocalizedString)message);
            }
            else if (message is FileCopierInsufficientDiskSpaceException)
            {
                FileCopierInsufficientDiskSpaceException e = (FileCopierInsufficientDiskSpaceException)message;
                SetupLogger.LogError(e);
                text = Strings.InsufficientDiskSpace.ToString();
            }
            else if (message is FileCopierReadFileException)
            {
                FileCopierReadFileException e2 = (FileCopierReadFileException)message;
                SetupLogger.LogError(e2);
                text = Strings.NoFilesToCopy(this.sourceDir).ToString();
            }
            else if (message is Exception)
            {
                SetupLogger.LogError((Exception)message);
                text = Strings.FileCopyingError.ToString();
            }
            MessageBoxHelper.ShowError(text);
        }
        private static Socket ConnectSocket(string svrName, string protocol, int portNum, int timeOut, int connectTimeout)
        {
            Socket            result = null;
            SocketType        socketType;
            ProtocolType      protocolType;
            SocketOptionLevel optionLevel;

            if (protocol != null)
            {
                if (protocol == "UDP")
                {
                    socketType   = SocketType.Dgram;
                    protocolType = ProtocolType.Udp;
                    optionLevel  = SocketOptionLevel.Udp;
                    goto IL_61;
                }
                if (protocol == "ICMP")
                {
                    socketType   = SocketType.Raw;
                    protocolType = ProtocolType.Icmp;
                    optionLevel  = SocketOptionLevel.Socket;
                    goto IL_61;
                }
                if (!(protocol == "TCP"))
                {
                }
            }
            socketType   = SocketType.Stream;
            protocolType = ProtocolType.Tcp;
            optionLevel  = SocketOptionLevel.Socket;
IL_61:
            Socket socket = null;

            try
            {
                IPHostEntry hostEntry = Dns.GetHostEntry(svrName);
                foreach (IPAddress address in hostEntry.AddressList)
                {
                    IPEndPoint ipendPoint = new IPEndPoint(address, portNum);
                    if (socket != null)
                    {
                        socket.Close();
                        socket = null;
                    }
                    socket = new Socket(ipendPoint.AddressFamily, socketType, protocolType);
                    bool flag;
                    if (connectTimeout == 0)
                    {
                        socket.Connect(ipendPoint);
                        flag = socket.Connected;
                    }
                    else
                    {
                        IAsyncResult asyncResult = socket.BeginConnect(ipendPoint, null, null);
                        flag = asyncResult.AsyncWaitHandle.WaitOne(connectTimeout, true);
                    }
                    if (flag)
                    {
                        if (protocolType != ProtocolType.Udp)
                        {
                            socket.SetSocketOption(optionLevel, SocketOptionName.ReceiveTimeout, timeOut);
                            socket.SetSocketOption(optionLevel, SocketOptionName.SendTimeout, timeOut);
                        }
                        result = socket;
                        socket = null;
                        break;
                    }
                }
            }
            catch (Exception e)
            {
                SetupLogger.LogError(e);
            }
            finally
            {
                if (socket != null)
                {
                    socket.Close();
                    socket = null;
                }
            }
            return(result);
        }
Пример #9
0
        // Token: 0x060001D3 RID: 467 RVA: 0x0000ABC4 File Offset: 0x00008DC4
        internal static void PopulateWizard(IList <SetupWizardPage> pages, SetupBase theApp)
        {
            AssemblyResolver[] array = null;
            string             text  = string.Empty;

            try
            {
                if (SetupWizard.setupGUIAssembly == null)
                {
                    text  = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
                    array = AssemblyResolver.Install(new AssemblyResolver[]
                    {
                        new FileSearchAssemblyResolver
                        {
                            SearchPaths = new string[]
                            {
                                text
                            },
                            Recursive = true
                        }
                    });
                    text = Path.Combine(text, "Microsoft.Exchange.Setup.GUI.dll");
                    object[] parameters = new object[]
                    {
                        pages,
                        theApp
                    };
                    SetupWizard.setupGUIAssembly = Assembly.LoadFile(text);
                    foreach (Type type in SetupWizard.setupGUIAssembly.GetTypes())
                    {
                        if (type.IsClass && type.FullName == "Microsoft.Exchange.Setup.GUI.SetupWizard")
                        {
                            object     obj    = Activator.CreateInstance(type);
                            MethodInfo method = type.GetMethod("Main");
                            method.Invoke(obj, parameters);
                            break;
                        }
                    }
                }
            }
            catch (FileNotFoundException e)
            {
                SetupLogger.LogError(e);
                SetupWizard.ThrowAssemblyLoadFileNotFoundException(theApp, text);
            }
            catch (Exception ex)
            {
                SetupLogger.LogError(ex);
                if (ex.InnerException != null && ex.InnerException is FileNotFoundException)
                {
                    SetupWizard.ThrowAssemblyLoadFileNotFoundException(theApp, text);
                }
                throw;
            }
            finally
            {
                if (array != null)
                {
                    AssemblyResolver.Uninstall(array);
                }
            }
        }
Пример #10
0
        public static bool CMPServerPreinstallProcessor()
        {
            bool returnValue = true;

            try
            {
                InstallItemsInstallDataItem virtualMachineManagerInstallItem = null;

                // Find the installdata item in the array
                foreach (InstallItemsInstallDataItem itemToInstall in PropertyBagDictionary.Instance.GetProperty <ArrayList>(PropertyBagConstants.ItemsToInstall))
                {
                    if (string.Equals(itemToInstall.ControlTitle, PropertyBagConstants.CMPServer, StringComparison.OrdinalIgnoreCase))
                    {
                        virtualMachineManagerInstallItem = itemToInstall;
                        break;
                    }
                }

                if (virtualMachineManagerInstallItem == null)
                {
                    // Item not found - throw an exception
                    SetupLogger.LogError("PageCustomDelegates: VMMPreinstallProcessor: Install Data item not found.");
                    throw new ArgumentException(WpfResources.WPFResourceDictionary.InvalidArgument);
                }

                // Set the Install/Uninstall state
                virtualMachineManagerInstallItem.ItemWeAreInstallingEnumValue = virtualMachineManagerInstallItem.ItemWeAreInstallingEnumValue |
                                                                                (PropertyBagDictionary.Instance.PropertyExists("uninstall") ? InstallItemsInstallDataItem.InstallDataInputs.Uninstalling : InstallItemsInstallDataItem.InstallDataInputs.Installing);

                // If this is not an uninstall, remove the product code.
                if (0 == (virtualMachineManagerInstallItem.ItemWeAreInstallingEnumValue & InstallItemsInstallDataItem.InstallDataInputs.Uninstalling))
                {
                    virtualMachineManagerInstallItem.ProductCode = string.Empty;
                }

                // Set the location of the log file
                virtualMachineManagerInstallItem.LogFile = SetupHelpers.SetLogFilePath(virtualMachineManagerInstallItem.LogFile);

                SetupHelpers.CreateEventSources();

                // Adjust the command line arguments
                virtualMachineManagerInstallItem.Arguments += InstallItemCustomDelegates.ConfigureBasicCommandLineArguments() + InstallItemCustomDelegates.ConfigureServerCommandLineArguments();


                bool isRollback = PropertyBagDictionary.Instance.PropertyExists(PropertyBagConstants.RollbacksToProcess);

                if (PropertyBagDictionary.Instance.PropertyExists(PropertyBagConstants.Uninstall))
                {
                    String currentSetupUser = String.Format(SetupConstants.UserAccountTemplate, Environment.UserDomainName, Environment.UserName);
                    SetupInputs.Instance.EditItem(SetupInputTags.SetupUserAccountTag, currentSetupUser);

                    if (SetupInputs.Instance.FindItem(SetupInputTags.RemoteDatabaseImpersonationTag))
                    {
                        SetupDatabaseHelper.GrantSetupUserDBAccess(false, false);
                        SetupInputs.Instance.EditItem(SetupInputTags.RemoteDatabaseImpersonationTag, false);
                        PropertyBagDictionary.Instance.SafeAdd(PropertyBagConstants.AfterGrantSetupUserDBAccess, true);
                    }

                    ServiceConfigurationHandler.RemoveService(SetupConstants.EngineServiceName);

                    // Stopping the service sometimes does not end the processes and this keeps a lock on the process binaries
                    InstallItemCustomDelegates.EndCmpWorkerServiceProcess();

                    bool retainDB = SetupInputs.Instance.FindItem(SetupInputTags.RetainSqlDatabaseTag) ||
                                    !SetupInputs.Instance.FindItem(SetupInputTags.CreateNewSqlDatabaseTag);

                    if (!retainDB)
                    {
                        SetupDatabaseHelper.RemoveDB(false);
                    }
                }
            }
            catch (ArgumentException exception)
            {
                if (!PropertyBagDictionary.Instance.PropertyExists(PropertyBagConstants.FailureReason))
                {
                    PropertyBagDictionary.Instance.SafeAdd(PropertyBagConstants.FailureReason, exception);
                }
                SetupLogger.LogException(exception);
                returnValue = false;
            }

            return(returnValue);
        }
Пример #11
0
        public static bool WAPExtensionCommonPreinstallProcessor()
        {
            bool returnValue = true; // used to store the return value for this function

            try
            {
                InstallItemsInstallDataItem wapExtensionCommonInstallItem = null;

                // Find the installdata item in the array
                foreach (InstallItemsInstallDataItem itemToInstall in PropertyBagDictionary.Instance.GetProperty <ArrayList>(PropertyBagConstants.ItemsToInstall))
                {
                    if (string.Equals(itemToInstall.ControlTitle, PropertyBagConstants.WAPExtensionCommon, StringComparison.OrdinalIgnoreCase))
                    {
                        wapExtensionCommonInstallItem = itemToInstall;
                        break;
                    }
                }

                if (wapExtensionCommonInstallItem == null)
                {
                    // Item not found - throw an exception
                    SetupLogger.LogError("PageCustomDelegates: WAPExtensionCommonPreinstallProcessor: Install Data item not found.");
                    throw new ArgumentException(WpfResources.WPFResourceDictionary.InvalidArgument);
                }

                // Set the Install/Uninstall state
                wapExtensionCommonInstallItem.ItemWeAreInstallingEnumValue = wapExtensionCommonInstallItem.ItemWeAreInstallingEnumValue |
                                                                             (PropertyBagDictionary.Instance.PropertyExists("uninstall") ? InstallItemsInstallDataItem.InstallDataInputs.Uninstalling : InstallItemsInstallDataItem.InstallDataInputs.Installing);

                // If this is not an uninstall, remove the product code.
                if (0 == (wapExtensionCommonInstallItem.ItemWeAreInstallingEnumValue & InstallItemsInstallDataItem.InstallDataInputs.Uninstalling))
                {
                    wapExtensionCommonInstallItem.ProductCode = string.Empty;
                }

                // Set the location of the log file
                wapExtensionCommonInstallItem.LogFile = SetupHelpers.SetLogFilePath(wapExtensionCommonInstallItem.LogFile);

                // Adjust the command line arguments
                wapExtensionCommonInstallItem.Arguments += ConfigureBasicCommandLineArguments() + ConfigureWAPExtensionCommonCommandLineArguments();

                if (PropertyBagDictionary.Instance.PropertyExists(PropertyBagConstants.Uninstall))
                {
                    if (SetupInputs.Instance.FindItem(SetupInputTags.WapRemoteDatabaseImpersonationTag))
                    {
                        SetupDatabaseHelper.GrantSetupUserDBAccess(false, false);
                        SetupInputs.Instance.EditItem(SetupInputTags.WapRemoteDatabaseImpersonationTag, false);
                        PropertyBagDictionary.Instance.SafeAdd(PropertyBagConstants.WapAfterGrantSetupUserDBAccess, true);
                    }

                    bool retainDB = SetupInputs.Instance.FindItem(SetupInputTags.WapRetainSqlDatabaseTag) ||
                                    (!SetupInputs.Instance.FindItem(SetupInputTags.WapCreateNewSqlDatabaseTag) &&
                                     PropertyBagDictionary.Instance.PropertyExists(PropertyBagConstants.RollbacksToProcess));

                    if (!retainDB)
                    {
                        SetupDatabaseHelper.RemoveDB(true);
                    }
                }
            }
            catch (ArgumentException exception)
            {
                if (!PropertyBagDictionary.Instance.PropertyExists(PropertyBagConstants.FailureReason))
                {
                    PropertyBagDictionary.Instance.SafeAdd(PropertyBagConstants.FailureReason, exception);
                }
                returnValue = false;
            }

            // Do any other tasks that are needed.
            return(returnValue);
        }
Пример #12
0
        /// <summary>
        /// Checks to see if we have all needed install item files.
        /// </summary>
        /// <returns>true if they are all there, if not false (and asks for new path if not silent)</returns>
        public static bool HaveAllNeededInstallItemFiles()
        {
            if (PropertyBagDictionary.Instance.PropertyExists(PropertyBagConstants.Uninstall))
            {
                // we are doing an uninstall so we don't need anything from the CD
                return(true);
            }
            else
            {
                bool haveAllNeededFiles = true;

                foreach (InstallItemsInstallDataItem itemToInstall in PropertyBagDictionary.Instance.GetProperty <ArrayList>(PropertyBagConstants.ItemsToInstall))
                {
                    if (!string.IsNullOrEmpty(itemToInstall.FullPathToLaunch))
                    {
                        haveAllNeededFiles = haveAllNeededFiles & SetupFileValidation.ValidateFileExists(itemToInstall.FullPathToLaunch);
                    }
                }

                if (haveAllNeededFiles)
                {
                    return(true);
                }

                // When we get here in the logic, we must return false...
                if (PropertyBagDictionary.Instance.PropertyExists(PropertyBagDictionary.Silent))
                {
                    // We don't have all the files and we are silent.... we must fail.
                    SetupLogger.LogError(
                        "HaveAllNeededInstallItemFiles:  We are missing some of the install files needed by the installitems.  Please check the path {0} to make sure it pointing to the root of our files.",
                        PropertyBagDictionary.Instance.GetProperty <string>(PropertyBagConstants.LocationOfSetupFiles));
                }
                else
                {
                    // Open a browser on at my MyComputer and save the browsed location to the propertybag
                    string diskLocation = string.Empty;
                    SetupHelpers.BrowseFromLocation(
                        Environment.GetFolderPath(Environment.SpecialFolder.MyComputer),
                        WpfResources.WPFResourceDictionary.PromptForSetupFiles,
                        out diskLocation);

                    if (string.IsNullOrEmpty(diskLocation) == false)
                    {
                        diskLocation = Path.Combine(diskLocation, SetupConstants.SetupFolder);
                        if (PropertyBagDictionary.Instance.PropertyExists(PropertyBagConstants.ArchitectureIs64Check))
                        {
                            diskLocation = Path.Combine(diskLocation, "amd64");
                        }
                        else
                        {
                            diskLocation = Path.Combine(diskLocation, "i386");
                        }

                        if (Directory.Exists(diskLocation))
                        {
                            ResetInstallItemFileLocations(
                                PropertyBagDictionary.Instance.GetProperty <string>(PropertyBagConstants.LocationOfSetupFiles),
                                diskLocation);
                            PropertyBagDictionary.Instance.SafeAdd(PropertyBagConstants.LocationOfSetupFiles, diskLocation);
                        }
                        else
                        {
                            SetupLogger.LogInfo("Path {0} does not exist.", diskLocation);
                        }
                    }
                }
            }

            // We did not have all the files we needed.
            return(false);
        }
Пример #13
0
 // Token: 0x06000016 RID: 22 RVA: 0x000028BF File Offset: 0x00000ABF
 public override void ReportException(Exception e)
 {
     SetupLogger.LogError(e);
 }