//This will set the current launcher version within the installer manifest of the passed in installerDirectory
        public static void SetLauncherVersion(int newLauncherVersion, string installerDirectory)
        {
            var doc = XDocument.Load(installerDirectory + "InstallerManifest.xml");

            doc.Descendants().Single(p => p.Name == "LauncherVersion").Value = newLauncherVersion.ToString();
            SaveXmlDoc.saveManifestDoc(installerDirectory, doc);
        }
        //This will activate or deactivate a global lockout
        public static void SetLockoutStatus(bool enabled)
        {
            var doc = GetXmlDoc.GetBackEndXmlDoc(DTO.Enums.BackEndOrFrontEndEnum.BackEnd);

            doc.SelectSingleNode("//Lockout").InnerText = enabled.ToString();
            SaveXmlDoc.saveBackEndDoc(doc);
        }
Beispiel #3
0
        //This function creates the BackEndSettings.xml file with the passed in RolloutDirectory.
        //This function is only called through the back end installation process.
        public static void CreateBackEndSettingsXMLFile(string rolloutDirectory, string connectionString)
        {
            string      currentDirectory = Directory.GetCurrentDirectory() + "\\";
            XmlDocument doc = new XmlDocument();

            XmlDeclaration xmlDeclaration = doc.CreateXmlDeclaration("1.0", "UTF-8", null);
            XmlElement     root           = doc.DocumentElement;

            doc.InsertBefore(xmlDeclaration, root);

            XmlElement backEndSettings = doc.CreateElement("BackEndSettings");

            doc.AppendChild(backEndSettings);

            XmlElement installedDirectory = doc.CreateElement("InstalledDirectory");

            installedDirectory.AppendChild(doc.CreateTextNode(currentDirectory));
            backEndSettings.AppendChild(installedDirectory);

            XmlElement connectionStringElement = doc.CreateElement("ConnectionString");

            connectionStringElement.AppendChild(doc.CreateTextNode(connectionString));
            backEndSettings.AppendChild(connectionStringElement);

            XmlElement rolloutDirectoryElement = doc.CreateElement("RolloutDirectory");

            rolloutDirectoryElement.AppendChild(doc.CreateTextNode(rolloutDirectory));
            backEndSettings.AppendChild(rolloutDirectoryElement);

            SaveXmlDoc.saveBackEndSettingsDoc(doc);
        }
        //This will set the current Front End launcher version to the passed in int.
        public static void UpdateFrontEndLauncherVersion(int currentLauncherVersion)
        {
            var doc = GetXmlDoc.GetFrontEndXmlDoc();

            doc.SelectSingleNode("//LauncherVersion").InnerText = currentLauncherVersion.ToString();
            SaveXmlDoc.saveFrontEndDoc(doc);
        }
Beispiel #5
0
        //This creates a manifest file whenever the back end installs. This manifest file is used by the
        //Front end installer to know what files to copy.
        public static void CreateManifestXMLFile(string locationToPlaceManifest, List <DTO.InstallerItem> installerManifest)
        {
            var            doc            = new XmlDocument();
            XmlDeclaration xmlDeclaration = doc.CreateXmlDeclaration("1.0", "UTF-8", null);

            XmlElement root = doc.DocumentElement;

            doc.InsertBefore(xmlDeclaration, root);

            XmlElement topElement = doc.CreateElement("Base");

            doc.AppendChild(topElement);


            XmlElement launcherVersion = doc.CreateElement("LauncherVersion");

            launcherVersion.InnerText = "1";
            topElement.AppendChild(launcherVersion);

            XmlElement baseDoc = doc.CreateElement("InstallerManifest");

            topElement.AppendChild(baseDoc);

            //Add each item in the manifest to the XML document, stripping out the full path
            foreach (var item in installerManifest)
            {
                FileInfo   file        = new FileInfo(item.DestinationFilePath);
                XmlElement fileElement = doc.CreateElement("File");
                string     fileName    = item.DestinationFilePath.Replace(locationToPlaceManifest, "");
                fileElement.SetAttribute("RelativePath", file.Name);
                fileElement.SetAttribute("FullPath", file.FullName);
                baseDoc.AppendChild(fileElement);
            }
            SaveXmlDoc.saveManifestDoc(locationToPlaceManifest, doc);
        }
        /*This method is used to roll back the backend.xml file to a previous version.
         * 1. It will set a the current version to the number passed in for the specified UserType.
         * 2. It will remove all newer versions from the document of the specified UserType.
         * 3. It will then save the document.
         */
        public static void RollBackToVersionNumber(int versionToRollTo, DTO.Enums.UserTypeEnum userType)
        {
            var doc = GetXmlDoc.GetBackEndXmlDoc(DTO.Enums.BackEndOrFrontEndEnum.BackEnd);

            setCurrentVersionNumber(doc, versionToRollTo, userType);
            removeAllNewVersions(doc, versionToRollTo, userType);
            SaveXmlDoc.saveBackEndDoc(doc);
        }
        //This will set the current connection string in the backend.xml file.
        public static void UpdateConnectionString(string newConnectionString)
        {
            var backEndDoc         = GetXmlDoc.GetBackEndXmlDoc(DTO.Enums.BackEndOrFrontEndEnum.BackEnd);
            var backEndSettingsDoc = GetXmlDoc.GetSettingsDoc(DTO.Enums.BackEndOrFrontEndEnum.BackEnd);

            backEndDoc.SelectSingleNode("//ConnectionInfo").Attributes.GetNamedItem("ConnectionString").Value = newConnectionString;
            backEndSettingsDoc.SelectSingleNode("//ConnectionString").InnerText = newConnectionString;
            SaveXmlDoc.saveBackEndDoc(backEndDoc);
            SaveXmlDoc.saveBackEndSettingsDoc(backEndSettingsDoc);
        }
        //This is an important method for the FrontEnd. A DTO.RolloutInfo object is passed in and then this will
        //update the frontend.xml file for the user with that info.
        public static void UpdateFrontEndXml(DTO.RolloutInfo rollout)
        {
            var doc = GetXmlDoc.GetFrontEndXmlDoc();

            doc.SelectSingleNode("//LaunchFile").InnerText      = rollout.LaunchFile;
            doc.SelectSingleNode("//CurrentUserType").InnerText = rollout.UserTypeName;
            doc.SelectSingleNode("//CurrentVersion").InnerText  = rollout.RolloutVersionString;
            doc.SelectSingleNode("//CurrentZipPath").InnerText  = rollout.ZipPath;
            SaveXmlDoc.saveFrontEndDoc(doc);
        }
        //This will add the passed in file to the installer manifest within the passed in installerDirectory
        public static void AddFileToManifest(string installerDirectory, FileInfo file)
        {
            var doc       = XDocument.Load(installerDirectory + "InstallerManifest.xml");
            var sameFiles = doc.Descendants("File").Select(p => new FileInfo(p.Attribute("FullPath").Value)).Where(p => p.Name == file.Name);

            if (sameFiles.Count() == 0)
            {
                doc.Descendants().Single(p => p.Name == "InstallerManifest").Add(
                    new XElement("File",
                                 new XAttribute("RelativePath", file.FullName.Replace(installerDirectory, "")),
                                 new XAttribute("FullPath", file.FullName)));
                SaveXmlDoc.saveManifestDoc(installerDirectory, doc);
            }
        }
Beispiel #10
0
        //This method is ultimately called by FrontEndInstaller application. It creates the frontend.xml file
        //In the user's appDataDirectory. The Xml nodes are mostly empty except for the rollout directory and the
        //Uninstaller location. These are pre-populated because they are necessary from the start for
        //the front-end to operate.
        public static void CreateFrontEndXMLFile(string rolloutDirectory, string appDataDirectory, int currentLauncherVersion)
        {
            var            doc            = new XmlDocument();
            XmlDeclaration xmlDeclaration = doc.CreateXmlDeclaration("1.0", "UTF-8", null);

            XmlElement root = doc.DocumentElement;

            doc.InsertBefore(xmlDeclaration, root);

            XmlElement baseDoc = doc.CreateElement("FrontEndSettings");

            doc.AppendChild(baseDoc);

            XmlElement launcherVersion = doc.CreateElement("LauncherVersion");

            launcherVersion.InnerText = currentLauncherVersion.ToString();
            baseDoc.AppendChild(launcherVersion);

            XmlElement rolloutDirectoryEl = doc.CreateElement("RolloutDirectory");

            rolloutDirectoryEl.InnerText = rolloutDirectory;
            baseDoc.AppendChild(rolloutDirectoryEl);

            XmlElement uninstallLocation = doc.CreateElement("UninstallerLocation");

            uninstallLocation.InnerText = rolloutDirectory + "AccessLauncher.FeUninstaller.exe";
            baseDoc.AppendChild(uninstallLocation);

            XmlElement currentZipPath = doc.CreateElement("CurrentZipPath");

            baseDoc.AppendChild(currentZipPath);

            XmlElement launchFile = doc.CreateElement("LaunchFile");

            baseDoc.AppendChild(launchFile);

            XmlElement currentUserType = doc.CreateElement("CurrentUserType");

            baseDoc.AppendChild(currentUserType);

            XmlElement currentVersion = doc.CreateElement("CurrentVersion");

            baseDoc.AppendChild(currentVersion);

            SaveXmlDoc.saveFrontEndDoc(doc);
        }
        //This is a main function in the Back End tool. It takes a RolloutInfo object and with that info,
        //it creates a new rollout record.
        public static void AddRolloutRecord(DTO.RolloutInfo rollout)
        {
            var doc = GetXmlDoc.GetBackEndXmlDoc(DTO.Enums.BackEndOrFrontEndEnum.BackEnd);
            //Compare current connection string and date and resolve for latest string
            string  latestConnectionString = compareConnectionStrings(ref doc, rollout);
            XmlNode versionNode            = doc.SelectSingleNode("//Version[@value='" + rollout.RolloutVersionString + "']");

            //Check to see if a node for the current version exists
            if (versionNode != null)
            {
                //If a node for the current version exists, then check if a rollout node exists for the specified userType
                XmlNode rolloutNode = versionNode.SelectSingleNode("./" + rollout.UserTypeName);
                if (rolloutNode != null)
                {
                    //If a rollout node exists for the userType, then modify the values with the most up-to-date info.
                    rolloutNode = setRolloutAttributes(doc, rolloutNode, rollout);
                }
                else
                {
                    //If a rollout node does NOT exist for the userType, then create one.
                    versionNode.AppendChild(createRolloutNode(doc, rollout));
                }
            }
            //If a version node for the current version number does NOT exist, then create one with attributes set
            else
            {
                XmlNode    rolloutsNode   = doc.SelectSingleNode("//BackEnd/RollOuts");
                XmlElement newVersionNode = doc.CreateElement("Version");
                newVersionNode.SetAttribute("value", rollout.RolloutVersionString);
                newVersionNode.AppendChild(createRolloutNode(doc, rollout));
                rolloutsNode.AppendChild(newVersionNode);
            }
            //Compare current version number with highest listed version number. If current is less than highest, update current.
            ensureHighestVersionNumber(doc, rollout.UserTypeName);
            ensureLatestRolloutDate(doc, rollout.DateTimeStamp);
            //Create backup rollout document within zip folder
            XmlNode newRolloutNode = doc.SelectSingleNode("//Version[@value='" + rollout.RolloutVersionString + "']").SelectSingleNode("./" + rollout.UserTypeName);

            CreateXmlDoc.createBackupRolloutDocument(newRolloutNode, rollout.RolloutVersionNumber, latestConnectionString);
            SaveXmlDoc.saveBackEndDoc(doc);
        }
Beispiel #12
0
        //This creates an empty backend.xml file with
        public static void CreateBackEndXmlFileInRolloutDirectory()
        {
            //Creates the back end XML file that users will access. It is mostly empty except with some basic structure
            //and the current version number is set to 0.
            XmlDocument    doc            = new XmlDocument();
            XmlDeclaration xmlDeclaration = doc.CreateXmlDeclaration("1.0", "UTF-8", null);
            XmlElement     root           = doc.DocumentElement;

            doc.InsertBefore(xmlDeclaration, root);

            XmlElement BackEnd = doc.CreateElement("BackEnd");

            doc.AppendChild(BackEnd);

            XmlElement currentVersionsElement = doc.CreateElement("CurrentVersions");

            foreach (string name in Enum.GetNames(typeof(DTO.Enums.UserTypeEnum)))
            {
                currentVersionsElement.SetAttribute(name, "0");;
            }
            currentVersionsElement.SetAttribute("LatestDate", "");
            BackEnd.AppendChild(currentVersionsElement);

            XmlElement lockoutElement = doc.CreateElement("Lockout");

            lockoutElement.InnerText = false.ToString();
            BackEnd.AppendChild(lockoutElement);

            XmlElement rolloutsElement = doc.CreateElement("RollOuts");

            BackEnd.AppendChild(rolloutsElement);
            string connectionString = GetData.GetCurrentConnectionString(DTO.Enums.BackEndOrFrontEndEnum.BackEnd);

            XmlElement connectionInfoElement = doc.CreateElement("ConnectionInfo");

            connectionInfoElement.SetAttribute("ConnectionString", connectionString);
            connectionInfoElement.SetAttribute("ConnectionDateSet", DateTime.Now.ToString());
            BackEnd.AppendChild(connectionInfoElement);

            SaveXmlDoc.saveBackEndDoc(doc);
        }