mirror of
https://github.com/xcp-ng/xenadmin.git
synced 2025-01-20 23:39:51 +01:00
Fixed issue where the settings from previous installations were not imported. Added more documentation.
Signed-off-by: Konstantina Chremmou <konstantina.chremmou@citrix.com>
This commit is contained in:
parent
2c18b7c7ed
commit
bae03aff8b
@ -69,15 +69,30 @@ namespace XenAdmin
|
||||
private static Dictionary<string, string> VNCPasswords = new Dictionary<string, string>();
|
||||
|
||||
/// <summary>
|
||||
/// MSDN info regarding the path to the user.config file is somewhat confusing. It turns out
|
||||
/// it is not in Application.UserAppDataPath as stated on http://msdn.microsoft.com/en-us/library/8eyb2ct1.aspx
|
||||
/// but rather in a location like BasePath\CompanyName\AppName_EvidenceType_EvidenceHash\Version as described on
|
||||
/// MSDN info regarding the path to the user.config file is somewhat confusing.
|
||||
/// It turns out it is not in Application.UserAppDataPath as stated on
|
||||
/// http://msdn.microsoft.com/en-us/library/8eyb2ct1.aspx. As described on
|
||||
/// http://stackoverflow.com/questions/1075204/when-using-a-settings-settings-file-in-net-where-is-the-config-actually-stored
|
||||
/// and on http://msdn.microsoft.com/en-us/library/ms379611.aspx.
|
||||
/// Trying to retrieve the filename at the places where this method's caller caught the ConfigurationErrorsException
|
||||
/// returns null, so this one has to be called.
|
||||
/// and on http://msdn.microsoft.com/en-us/library/ms379611.aspx, it is
|
||||
/// ProfileDirectory\CompanyName\AppName_EvidenceType_EvidenceHash\Version\user.config
|
||||
/// where
|
||||
/// - ProfileDirectory: either the roaming profile directory or the local one.
|
||||
/// Settings are stored by default in the local user.config file. To store a
|
||||
/// setting in the roaming user.config file, you need to mark the setting with
|
||||
/// the SettingsManageabilityAttribute with SettingsManageability set to Roaming.
|
||||
/// - CompanyName: typically the string specified by the AssemblyCompanyAttribute
|
||||
/// (with the caveat that the string is escaped and truncated as necessary, and if
|
||||
/// not specified on the assembly, we have a fallback procedure).
|
||||
/// - AppName: typically the string specified by the AssemblyProductAttribute
|
||||
/// (same caveats as for company name).
|
||||
/// - EvidenceType and EvidenceHash: information derived from the app domain evidence
|
||||
/// to provide proper app domain and assembly isolation.
|
||||
/// - Version: typically the version specified in the AssemblyVersionAttribute.
|
||||
/// This is required to isolate different versions of the app deployed side by side.
|
||||
/// - The file name is always simply 'user.config
|
||||
/// Trying to retrieve the filename at the places where this method's caller caught
|
||||
/// the ConfigurationErrorsException returns null, so this one has to be called.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static string GetUserConfigPath()
|
||||
{
|
||||
try
|
||||
@ -642,7 +657,7 @@ namespace XenAdmin
|
||||
// <Profile Directory>\<Company Name>\<App Name>_<Evidence Type>_<Evidence Hash>\<Version>\user.config
|
||||
// Get a previous user.config file by enumerating through all the folders in <Profile Directory>\<Company Name>
|
||||
|
||||
var currentConfigFolder = new DirectoryInfo(Settings.GetUserConfigPath()).Parent;
|
||||
var currentConfigFolder = new DirectoryInfo(GetUserConfigPath()).Parent;
|
||||
|
||||
var companyFolder = currentConfigFolder?.Parent?.Parent;
|
||||
if (companyFolder == null)
|
||||
@ -651,11 +666,14 @@ namespace XenAdmin
|
||||
FileInfo previousConfig = null;
|
||||
Version previousVersion = null;
|
||||
Version currentVersion = Program.Version;
|
||||
var appDomainName = AppDomain.CurrentDomain.FriendlyName;
|
||||
|
||||
foreach (var subDir in companyFolder.GetDirectories("*" + appDomainName + "*", SearchOption.AllDirectories))
|
||||
var directories = companyFolder.GetDirectories($"{BrandManager.BrandConsoleNoSpace}*");
|
||||
|
||||
foreach (var dir in directories)
|
||||
{
|
||||
foreach (var file in subDir.GetFiles("user.config", SearchOption.AllDirectories))
|
||||
var configFiles = dir.GetFiles("user.config", SearchOption.AllDirectories);
|
||||
|
||||
foreach (var file in configFiles)
|
||||
{
|
||||
var configFolderName = Path.GetFileName(Path.GetDirectoryName(file.FullName));
|
||||
if (configFolderName != null)
|
||||
|
Loading…
Reference in New Issue
Block a user