//This is an overloaded method. This function will return the current rollout version number for the specified UserType, //from the perspective of whichever end of the application the user is calling from. public static int GetCurrentRolloutVersionNumber(DTO.Enums.BackEndOrFrontEndEnum whichEnd, DTO.Enums.UserTypeEnum userType) { string userTypeName = Enum.GetName(typeof(DTO.Enums.UserTypeEnum), userType); return(int.Parse(GetXmlDoc.GetBackEndXmlDoc(whichEnd).SelectSingleNode("//CurrentVersions") .Attributes.GetNamedItem(userTypeName).Value)); }
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); }
//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 will acquire the date of the most recent rollout. public static DateTime GetMostRecentRolloutDate(DTO.Enums.BackEndOrFrontEndEnum whichEnd) { var doc = GetXmlDoc.GetBackEndXmlDoc(whichEnd); try { string dateString = doc.SelectSingleNode("//CurrentVersions").Attributes.GetNamedItem("LatestDate").Value; if (string.IsNullOrEmpty(dateString)) { throw new DTO.Exceptions.CouldNotFindValueException(); } return(DateTime.Parse(dateString)); } catch (Exception) { throw new DTO.Exceptions.CouldNotFindValueException(); } }
public static string GetCurrentConnectionString(DTO.Enums.BackEndOrFrontEndEnum whichEnd) { XmlDocument doc = null; string connString = ""; switch (whichEnd) { case AccessLauncher.DTO.Enums.BackEndOrFrontEndEnum.BackEnd: doc = GetXmlDoc.GetSettingsDoc(whichEnd); connString = doc.SelectSingleNode("//ConnectionString").InnerText; break; case AccessLauncher.DTO.Enums.BackEndOrFrontEndEnum.FrontEnd: doc = GetXmlDoc.GetBackEndXmlDoc(whichEnd); connString = doc.SelectSingleNode("//ConnectionInfo").Attributes.GetNamedItem("ConnectionString").Value; break; } return(connString); }
//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); }
//This will return true if a global application lock is enabled. Otherwise, it will return false. public static bool LockoutIsEnabled(DTO.Enums.BackEndOrFrontEndEnum whichEnd) { var doc = GetXmlDoc.GetBackEndXmlDoc(whichEnd); return(bool.Parse(doc.SelectSingleNode("//Lockout").InnerText)); }