Example #1
0
        private void updateFilesWizard_btnNext_Click(object sender, EventArgs e)
        {
            Logger.EnteringMethod();
            updateFilesWizard.Hide();
            if (updateFilesWizard.FileType == FrmUpdateFilesWizard.UpdateType.WindowsInstaller)
            {
                MsiReader.MsiReader msiReader = new MsiReader.MsiReader();
                msiReader.MsiFilePath = updateFilesWizard.UpdateFileName;
                string msiCode        = msiReader.GetProductCode();
                string MsiVendorName  = msiReader.GetManufacturer();
                string MsiProductName = msiReader.GetProductName();
                Logger.Write("Msi Code : " + msiCode);
                Logger.Write("Msi Vendor : " + MsiVendorName);
                Logger.Write("MSi Product : " + MsiProductName);
                if (!string.IsNullOrEmpty(msiCode))
                {
                    try
                    {
                        Clipboard.SetText(msiCode);
                    }
                    catch (Exception) { }

                    if (!CreatingSupersedingUpdate)
                    {
                        updateIsInstalledRulesWizard.InitializeUpdateLevelwithXml("<msiar:MsiProductInstalled ProductCode=\"" + msiCode + "\"/>");
                        updateIsInstallableRulesWizard.InitializeUpdateLevelwithXml("<lar:Not><msiar:MsiProductInstalled ProductCode=\"" + msiCode + "\"/></lar:Not>");
                    }
                    else
                    {
                        updateIsInstalledRulesWizard.InitializeWithXml("<msiar:MsiProductInstalled ProductCode=\"" + msiCode + "\"/>", Sdp.IsInstalled, true);
                        updateIsInstallableRulesWizard.InitializeWithXml("<lar:Not><msiar:MsiProductInstalled ProductCode=\"" + msiCode + "\"/></lar:Not>", Sdp.IsInstallable, true);
                    }
                }
                bool foundVendor = false;

                if (InferFromMsiProperties && !CreatingSupersedingUpdate)
                {
                    foreach (Company company in _companies.Values)
                    {
                        if (company.CompanyName.ToLower() == MsiVendorName.ToLower())
                        {
                            Logger.Write("Vendor found : " + company.CompanyName);
                            updateInformationsWizard.InitializeVendorName(company.CompanyName);
                            foundVendor = true;
                            break;
                        }
                    }
                    if (!foundVendor)
                    {
                        updateInformationsWizard.InitializeVendorName(MsiVendorName);
                    }
                }
                if (!CreatingSupersedingUpdate)
                {
                    updateInformationsWizard.Title = MsiProductName;
                }
                RemoveTransformsCommand();
                if (updateFilesWizard.HaveMSTFile)
                {
                    Logger.Write("Have MST file ! ");
                    string command = string.Empty;
                    command = "TRANSFORMS=";
                    foreach (string file in updateFilesWizard.AdditionnalFileName)
                    {
                        if (file.ToLower().EndsWith(".mst"))
                        {
                            command += "\"" + GetShortFile(file) + "\";";
                        }
                    }
                    if (command.EndsWith(";"))
                    {
                        command = command.Substring(0, command.Length - 1);
                    }
                    updateInformationsWizard.CommandLine = (updateInformationsWizard.CommandLine != string.Empty) ? command + " " + updateInformationsWizard.CommandLine : command;
                }
            }
            else
            {
                if (!CreatingSupersedingUpdate)
                {
                    updateIsInstalledRulesWizard.InitializeUpdateLevelwithXml("");
                    updateIsInstallableRulesWizard.InitializeUpdateLevelwithXml("");
                }
                else
                {
                    updateIsInstalledRulesWizard.InitializeUpdateLevelwithXml(Sdp.IsInstalled);
                    updateIsInstallableRulesWizard.InitializeUpdateLevelwithXml(Sdp.IsInstallable);
                }
            }
            InitializeInformationsWizard();
        }