Fix: Device Ext/AD Cleanup
This commit is contained in:
@@ -123,7 +123,7 @@ namespace Disco.BI.Extensions
|
||||
dbContext.Devices.Add(d2);
|
||||
if (!string.IsNullOrEmpty(d.AssignedUserId))
|
||||
{
|
||||
User u = UserBI.UserCache.GetUser(d.AssignedUserId, dbContext);
|
||||
User u = UserBI.UserCache.GetUser(d.AssignedUserId, dbContext, true);
|
||||
d2.AssignDevice(dbContext, u);
|
||||
}
|
||||
|
||||
@@ -148,7 +148,7 @@ namespace Disco.BI.Extensions
|
||||
AssignedDate = DateTime.Now
|
||||
};
|
||||
dbContext.DeviceUserAssignments.Add(newDua);
|
||||
|
||||
|
||||
d.AssignedUserId = u.Id;
|
||||
d.AssignedUser = u;
|
||||
}
|
||||
@@ -163,10 +163,7 @@ namespace Disco.BI.Extensions
|
||||
var adMachineAccount = Interop.ActiveDirectory.ActiveDirectory.GetMachineAccount(d.ComputerName);
|
||||
if (adMachineAccount != null)
|
||||
{
|
||||
if (newDua == null)
|
||||
adMachineAccount.SetDescription(string.Empty);
|
||||
else
|
||||
adMachineAccount.SetDescription(d);
|
||||
adMachineAccount.SetDescription(d);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -62,13 +62,11 @@ namespace Disco.BI.Interop.ActiveDirectory
|
||||
using (DirectoryEntry machineDE = new DirectoryEntry(account.Path))
|
||||
{
|
||||
PropertyValueCollection descriptionProp = machineDE.Properties["description"];
|
||||
bool flag = descriptionProp.Count > 0;
|
||||
if (flag)
|
||||
if (descriptionProp.Count > 0)
|
||||
{
|
||||
descriptionProp.Clear();
|
||||
}
|
||||
flag = !string.IsNullOrEmpty(Description);
|
||||
if (flag)
|
||||
if (!string.IsNullOrEmpty(Description))
|
||||
{
|
||||
descriptionProp.Add(Description);
|
||||
}
|
||||
@@ -78,25 +76,21 @@ namespace Disco.BI.Interop.ActiveDirectory
|
||||
public static void SetDescription(this ActiveDirectoryMachineAccount account, Device Device)
|
||||
{
|
||||
System.Text.StringBuilder descriptionBuilder = new System.Text.StringBuilder();
|
||||
bool flag = Device.AssignedUserId != null;
|
||||
if (flag)
|
||||
|
||||
if (Device.AssignedUserId != null)
|
||||
{
|
||||
descriptionBuilder.Append(Device.AssignedUser.Id);
|
||||
descriptionBuilder.Append(" (");
|
||||
descriptionBuilder.Append(Device.AssignedUser.DisplayName);
|
||||
descriptionBuilder.Append("); ");
|
||||
descriptionBuilder.Append(Device.AssignedUser.Id).Append(" (").Append(Device.AssignedUser.DisplayName).Append("); ");
|
||||
}
|
||||
flag = Device.DeviceModelId.HasValue;
|
||||
if (flag)
|
||||
|
||||
if (Device.DeviceModelId.HasValue)
|
||||
{
|
||||
descriptionBuilder.Append(Device.DeviceModel.Description);
|
||||
descriptionBuilder.Append("; ");
|
||||
descriptionBuilder.Append(Device.DeviceModel.Description).Append("; ");
|
||||
}
|
||||
descriptionBuilder.Append(Device.DeviceProfile.Description);
|
||||
descriptionBuilder.Append("; ");
|
||||
|
||||
descriptionBuilder.Append(Device.DeviceProfile.Description).Append(";");
|
||||
|
||||
string description = descriptionBuilder.ToString().Trim();
|
||||
flag = (description.Length > 1024);
|
||||
if (flag)
|
||||
if (description.Length > 1024)
|
||||
{
|
||||
description = description.Substring(0, 1024);
|
||||
}
|
||||
|
||||
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.2.0225.1951")]
|
||||
[assembly: AssemblyFileVersion("1.2.0225.1951")]
|
||||
[assembly: AssemblyVersion("1.2.0304.2046")]
|
||||
[assembly: AssemblyFileVersion("1.2.0304.2046")]
|
||||
|
||||
Reference in New Issue
Block a user