public static string ReturnLocationAlias(string locationName, out string errorMessage) { errorMessage = null; string alias; try { string page, menu, sub1, sub2, tab, locName; string fileNameFullPath, searchString, nextSearchString, endSearchString, strInFile; Location location = LocationUtility.ReturnLocation(locationName, out errorMessage); if (!string.IsNullOrEmpty(errorMessage)) { return(null); } //--------------- Page ---------------- fileNameFullPath = "C:\\git_cjonasl\\Leander\\Solutions\\Nr1\\WebApplication1\\Views\\Shared\\_LayoutTopLevel.cshtml"; searchString = string.Format("<li id=\"page{0}\"><a href=\"javascript: window.jonas.newLocation({0}, 0, 0, 0, 1, false)\">", location.Page.ToString()); nextSearchString = " "; endSearchString = "</a></li>"; if (!Utility.GetStringInFile(fileNameFullPath, searchString, nextSearchString, endSearchString, out page, out errorMessage)) { return(null); } //--------------- Menu ---------------- if (location.Menu != 0) { fileNameFullPath = string.Format("C:\\git_cjonasl\\Leander\\Solutions\\Nr1\\WebApplication1\\Views\\Main\\_Layout{0}.cshtml", location.Page.ToString()); searchString = string.Format("<span class='title' data-location='Menu{0}'", location.Menu.ToString()); nextSearchString = ">"; endSearchString = "</span>"; if (!Utility.GetStringInFile(fileNameFullPath, searchString, nextSearchString, endSearchString, out menu, out errorMessage)) { return(null); } } else { menu = "0"; } //--------------- Sub1 ---------------- if (location.Sub1 != 0) { fileNameFullPath = string.Format("C:\\git_cjonasl\\Leander\\Solutions\\Nr1\\WebApplication1\\Views\\Main\\_Layout{0}.cshtml", location.Page.ToString()); searchString = string.Format("<span class='title' data-location='Menu{0}Sub{1}'", location.Menu.ToString(), location.Sub1.ToString()); nextSearchString = ">"; endSearchString = "</span>"; if (!Utility.GetStringInFile(fileNameFullPath, searchString, nextSearchString, endSearchString, out sub1, out errorMessage)) { return(null); } } else { sub1 = "0"; } //--------------- Sub2 ---------------- if (location.Sub2 != 0) { fileNameFullPath = string.Format("C:\\git_cjonasl\\Leander\\Solutions\\Nr1\\WebApplication1\\Views\\Main\\_Layout{0}.cshtml", location.Page.ToString()); searchString = string.Format("<span class='title' data-location='Menu{0}Sub{1}Sub{2}'", location.Menu.ToString(), location.Sub1.ToString(), location.Sub2.ToString()); nextSearchString = ">"; endSearchString = "</span>"; if (!Utility.GetStringInFile(fileNameFullPath, searchString, nextSearchString, endSearchString, out sub2, out errorMessage)) { return(null); } } else { sub2 = "0"; } //--------------- Tab ---------------- fileNameFullPath = string.Format("C:\\git_cjonasl\\Leander\\Solutions\\Nr1\\WebApplication1\\Tab\\{0}.txt", locationName); if (System.IO.File.Exists(fileNameFullPath)) { tab = Utility.ReturnFileContents(fileNameFullPath); } else { tab = string.Format("Tab{0}", location.Tab.ToString()); } if (menu == "0") { alias = string.Format("{0}-Dashboard-{1}", page, tab); } else { locName = string.Format("{0}{1}{2}{3}{4}", page, menu, sub1, sub2, tab); if (locationName == locName) { alias = ""; //Do not return an alias name if it is same as default } else { alias = string.Format("{0}-{1}-{2}-{3}-{4}", page, menu, sub1, sub2, tab); } } } catch (Exception e) { errorMessage = string.Format("ERROR!! An Exception occured in method ReturnLocationAlias! e.Message: {0}", e.Message); return(null); } return(alias); }
public static ArrayList ReturnActualLocations(bool isDefaultLocation, out string errorMessage, out ArrayList sortAliasDefaultLocations) { errorMessage = null; sortAliasDefaultLocations = new ArrayList(); ArrayList arrayList = new ArrayList(); try { string locationName, locationNameSortAlias; int index1, index2; string[] v; if (isDefaultLocation) { v = Directory.GetFiles(_folderTextForDefaultLocations); } else { v = GetNonDefaultLocations(out errorMessage); } if (!string.IsNullOrEmpty(errorMessage)) { return(null); } for (int i = 0; i < v.Length; i++) { if (isDefaultLocation) { index1 = v[i].LastIndexOf("\\"); index2 = v[i].Length - 4; if (!v[i].EndsWith(".txt")) { errorMessage = string.Format("ERROR!! The method \"ReturnActualDefaultLocatioins\" found that the following file does not end with\".txt\" as expected: {0}", v[i]); return(null); } locationName = v[i].Substring(1 + index1, index2 - index1 - 1); } else { locationName = v[i]; } if (!LocationUtility.LocationNameIsCorrect(locationName, out locationNameSortAlias, out errorMessage)) { return(null); } arrayList.Add(locationName); sortAliasDefaultLocations.Add(locationNameSortAlias); } } catch (Exception e) { errorMessage = string.Format("ERROR!! An Exception occured in method ReturnActualLocations! e.Message:\r\n{0}", e.Message); return(null); } return(arrayList); }