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