//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);
        }
        /*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 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);
        }
示例#5
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);
        }