Bug Fixes: enrolment, assignment and search order

This commit is contained in:
Gary Sharp
2014-04-22 13:55:46 +10:00
parent 74df073b29
commit 3cf6d5475d
22 changed files with 310 additions and 127 deletions
@@ -9,11 +9,17 @@ namespace Disco.Models.Services.Searching
public class DeviceSearchResultItem : ISearchResultItem
{
private const string type = "Device";
private Lazy<string[]> LazyScoreValue;
public DeviceSearchResultItem()
{
this.LazyScoreValue = new Lazy<string[]>(BuildScoreValues, false);
}
public string Id { get; set; }
public string Type { get { return type; } }
public string Description { get { return string.Format("{0} ({1})", this.Id, this.ComputerName); } }
public string ScoreValue { get { return string.Format("{0} {1} {2} {3} {4}", this.Id, this.AssignedUserId != null ? this.AssignedUserId.Substring(0, this.AssignedUserId.IndexOf('\\')) : null, this.AssignedUserId, this.AssignedUserDisplayName, this.AssetNumber); } }
public string[] ScoreValues { get { return LazyScoreValue.Value; } }
public string AssetNumber { get; set; }
public string AssignedUserDescription
@@ -37,5 +43,28 @@ namespace Disco.Models.Services.Searching
public string DeviceProfileDescription { get; set; }
public int JobCount { get; set; }
public DateTime? DecommissionedDate { get; set; }
private string[] BuildScoreValues()
{
if (this.AssignedUserId == null)
{
return new string[] {
this.Id,
this.AssetNumber,
this.ComputerName
};
}
else
{
return new string[] {
this.Id,
this.AssetNumber,
this.ComputerName,
this.AssignedUserId.Substring(this.AssignedUserId.IndexOf('\\') + 1),
this.AssignedUserId,
this.AssignedUserDisplayName
};
}
}
}
}
@@ -11,6 +11,6 @@ namespace Disco.Models.Services.Searching
string Id { get; set; }
string Type { get; }
string Description { get; }
string ScoreValue { get; }
string[] ScoreValues { get; }
}
}
@@ -9,16 +9,43 @@ namespace Disco.Models.Services.Searching
public class JobSearchResultItem : ISearchResultItem
{
private const string type = "Job";
private Lazy<string[]> LazyScoreValue;
public JobSearchResultItem()
{
this.LazyScoreValue = new Lazy<string[]>(BuildScoreValues, false);
}
public virtual string Id { get; set; }
public string Type { get { return type; } }
public string Description { get { return string.Format("{0} ({1}; {2})", this.Id, this.UserId, this.DeviceSerialNumber); } }
public string ScoreValue { get { return string.Format("{0} {1} {2} {3} {4}", this.Id, this.UserId.Substring(0, this.UserId.IndexOf('\\')), this.UserId, this.DeviceSerialNumber, this.UserDisplayName); } }
public string[] ScoreValues { get { return LazyScoreValue.Value; } }
public string DeviceSerialNumber { get; set; }
public string UserId { get; set; }
public string UserFriendlyId { get; set; }
public string UserDisplayName { get; set; }
private string[] BuildScoreValues()
{
if (this.UserId == null)
{
return new string[] {
this.Id,
this.DeviceSerialNumber
};
}
else
{
return new string[] {
this.Id,
this.UserId.Substring(this.UserId.IndexOf('\\') + 1),
this.UserId,
this.UserDisplayName,
this.DeviceSerialNumber
};
}
}
}
}
@@ -9,16 +9,31 @@ namespace Disco.Models.Services.Searching
public class UserSearchResultItem : ISearchResultItem
{
private const string type = "User";
private Lazy<string[]> LazyScoreValue;
public UserSearchResultItem()
{
this.LazyScoreValue = new Lazy<string[]>(BuildScoreValues, false);
}
public string Id { get; set; }
public string Type { get { return type; } }
public string Description { get { return string.Format("{0} ({1})", this.DisplayName, this.Id); } }
public string ScoreValue { get { return string.Format("{0} {1} {2}", this.Id.Substring(0, this.Id.IndexOf('\\')), this.Id, this.DisplayName); } }
public string[] ScoreValues { get { return LazyScoreValue.Value; } }
public int AssignedDevicesCount { get; set; }
public string DisplayName { get; set; }
public string GivenName { get; set; }
public int JobCount { get; set; }
public string Surname { get; set; }
private string[] BuildScoreValues()
{
return new string[] {
this.Id.Substring(this.Id.IndexOf('\\') + 1),
this.Id,
this.DisplayName
};
}
}
}