//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 set the front end version number to zero, thus requiring that it be updated next launch. public static void SetFrontEndVersionToZero() { var doc = GetXmlDoc.GetFrontEndXmlDoc(); doc.SelectSingleNode("//CurrentVersion").InnerText = "0"; doc.Save(GetPath.GetSettingsXMLPath(DTO.Enums.BackEndOrFrontEndEnum.FrontEnd)); }
//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 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); }
/*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 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 will pull all the values from the frontend.xml file and put them into a DTO.RolloutInfo object. public static RolloutInfo GetFrontEndSettings() { RolloutInfo currentRollout = new RolloutInfo(); var doc = GetXmlDoc.GetFrontEndXmlDoc(); try { currentRollout.RolloutDirectory = doc.SelectSingleNode("//RolloutDirectory").InnerText; currentRollout.ZipPath = doc.SelectSingleNode("//CurrentZipPath").InnerText; currentRollout.LaunchFile = doc.SelectSingleNode("//LaunchFile").InnerText; currentRollout.UserTypeName = doc.SelectSingleNode("//CurrentUserType").InnerText; currentRollout.RolloutVersionString = doc.SelectSingleNode("//CurrentVersion").InnerText; currentRollout.UninstallerPath = doc.SelectSingleNode("//UninstallerLocation").InnerText; } catch (Exception) { throw new DTO.Exceptions.FrontEndNeedsUpdateException(); } return(currentRollout); }
//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 locate the rollout directory. This is a key method in all forms of this application. //If the rollout directory doesn't exist or if it cannot locate the rollout directory, this will //raise an exception, which can be evaluated higher up in the call chain. public static string GetRolloutDirectoryPath(DTO.Enums.BackEndOrFrontEndEnum whichEnd) { try { var doc = GetXmlDoc.GetSettingsDoc(whichEnd); string rolloutDirectoryPath = doc.SelectSingleNode("//RolloutDirectory").InnerText; if (rolloutDirectoryPath.Length == 0 || String.IsNullOrEmpty(rolloutDirectoryPath)) { throw new DTO.Exceptions.CouldNotLocateRolloutDirectoryException(); } return(rolloutDirectoryPath); } catch (Exception) { if (!File.Exists(GetSettingsXMLPath(whichEnd))) { throw new DTO.Exceptions.BackEndSettingsNotFoundException(); } else { throw; } } }
//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)); }
//This will get the current launcher version from the user's local front end. public static int GetFrontEndLauncherVersion() { var doc = GetXmlDoc.GetFrontEndXmlDoc(); return(int.Parse(doc.SelectSingleNode("//LauncherVersion").InnerText)); }
//This function will return just the uninstaller path from the front end settings. public static string GetUninstallerPath() { var doc = GetXmlDoc.GetFrontEndXmlDoc(); return(doc.SelectSingleNode("//UninstallerLocation").InnerText); }