Esempio n. 1
0
        private static void addLatestRolloutToCache(ObjectCache cache, DTO.Enums.UserTypeEnum userType, DTO.Enums.BackEndOrFrontEndEnum whichEnd)
        {
            CacheItemPolicy policy = new CacheItemPolicy()
            {
                SlidingExpiration = TimeSpan.FromSeconds(10)
            };
            var rollout = new DTO.RolloutInfo();

            rollout.UserType = userType;
            var    doc            = GetXmlDoc.GetBackEndXmlDoc(DTO.Enums.BackEndOrFrontEndEnum.FrontEnd);
            string currentVersion = doc.SelectSingleNode("//CurrentVersions").Attributes.GetNamedItem(rollout.UserTypeName).Value;

            rollout.Connection.ConnectionString = GetData.GetCurrentConnectionString(whichEnd);
            rollout.Connection.DateSet          = DateTime.Parse(doc.SelectSingleNode("//ConnectionInfo").Attributes.GetNamedItem("ConnectionDateSet").Value);
            rollout.DateTimeStamp = rollout.Connection.DateSet.Value;
            XmlNode rolloutNode = doc.SelectSingleNode("//Version[@value='" + currentVersion + "']/" + Enum.GetName(typeof(DTO.Enums.UserTypeEnum), userType));

            try
            {
                string launchFile = rolloutNode.Attributes.GetNamedItem("LaunchFile").Value;
                rollout.LaunchFile = launchFile;
                string zipPath = rolloutNode.Attributes.GetNamedItem("FullZipPath").Value;
                rollout.ZipPath = zipPath;
            }
            catch (NullReferenceException)
            {
                throw new DTO.Exceptions.CouldNotFindValueException();
            }
            rollout.RolloutVersionString = currentVersion;

            cache.Set("LatestRollout", rollout, policy);
        }
Esempio n. 2
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);
        }