Bug Fix: User Attachment Refs, AD Group Domain

User Attachments updated in the DataStore to reflect new UserId (which
includes the domain); AD Groups were using DnsName instead of
NetBiosName.
This commit is contained in:
Gary Sharp
2014-04-11 19:56:17 +10:00
parent 3238a916a2
commit e984221c95
14 changed files with 156 additions and 77 deletions
+25 -1
View File
@@ -388,7 +388,7 @@ DELETE [Users] WHERE [Id]=@IdExisting;";
throw new InvalidOperationException("Unable to determine the Domains NetBIOS Name");
// MIGRATE SETTINGS
// Authorization Roles
foreach (var authRole in Database.AuthorizationRoles.Where(ar => ar.SubjectIds != null).ToList())
{
@@ -413,6 +413,30 @@ DELETE [Users] WHERE [Id]=@IdExisting;";
}
Database.SaveChanges();
// MIGRATE Document Templates
var dataStoreLocation = Database.ConfigurationItems.Where(ci => ci.Scope == "System" && ci.Key == "DataStoreLocation").Select(ci => ci.Value).FirstOrDefault();
if (!string.IsNullOrWhiteSpace(dataStoreLocation) && System.IO.Directory.Exists(dataStoreLocation))
{
string filePrefix = string.Format("{0}_", netBiosName);
var userAttachmentsDirectory = System.IO.Path.Combine(dataStoreLocation, "UserAttachments");
if (System.IO.Directory.Exists(userAttachmentsDirectory))
{
var files = System.IO.Directory.EnumerateFiles(userAttachmentsDirectory, "*.*", System.IO.SearchOption.AllDirectories)
.Where(p => !p.StartsWith(filePrefix, StringComparison.InvariantCultureIgnoreCase) && (p.EndsWith("_thumb.jpg") || p.EndsWith("_file"))).ToList();
foreach (var file in files)
{
try
{
var renameFile = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(file), string.Concat(filePrefix, System.IO.Path.GetFileName(file)));
System.IO.File.Move(file, renameFile);
}
catch (Exception) { /* Ignore Errors */ }
}
}
}
// MIGRATE DEVICES
foreach (var device in Database.Devices.Where(d => d.DeviceDomainId != null && !d.DeviceDomainId.Contains(@"\")).ToList())
{