Bug Fixes: enrolment, assignment and search order
This commit is contained in:
@@ -114,8 +114,16 @@ namespace Disco.Web.Areas.API.Controllers
|
||||
}
|
||||
|
||||
[DiscoAuthorize(Claims.Device.Actions.AssignUser)]
|
||||
public virtual ActionResult UpdateAssignedUserId(string id, string AssignedUserId = null, bool redirect = false)
|
||||
public virtual ActionResult UpdateAssignedUserId(string id, string AssignedUserId = null, string AssignedUserDomain = null, bool redirect = false)
|
||||
{
|
||||
if (AssignedUserId != null && !AssignedUserId.Contains('\\'))
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(AssignedUserDomain))
|
||||
AssignedUserId = string.Format(@"{0}\{1}", ActiveDirectory.Context.PrimaryDomain.NetBiosName, AssignedUserId);
|
||||
else
|
||||
AssignedUserId = string.Format(@"{0}\{1}", AssignedUserDomain, AssignedUserId);
|
||||
}
|
||||
|
||||
return Update(id, pAssignedUserId, AssignedUserId, redirect);
|
||||
}
|
||||
|
||||
@@ -361,6 +369,9 @@ namespace Disco.Web.Areas.API.Controllers
|
||||
[DiscoAuthorize(Claims.Device.Show)]
|
||||
public virtual ActionResult LastNetworkLogonDate(string id)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(id))
|
||||
throw new ArgumentNullException("id", "The Device Serial Number is required");
|
||||
|
||||
var device = Database.Devices.Find(id);
|
||||
if (device == null)
|
||||
{
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using Disco.BI.Extensions;
|
||||
using Disco.Models.Repository;
|
||||
using Disco.Services.Authorization;
|
||||
using Disco.Services.Interop.ActiveDirectory;
|
||||
using Disco.Services.Users;
|
||||
using Disco.Services.Web;
|
||||
using System;
|
||||
@@ -287,7 +288,7 @@ namespace Disco.Web.Areas.API.Controllers
|
||||
}
|
||||
|
||||
[DiscoAuthorize(Claims.Config.DocumentTemplate.UndetectedPages)]
|
||||
public virtual ActionResult ImporterUndetectedDataIdLookup(string id, string term, int limitCount = 20)
|
||||
public virtual ActionResult ImporterUndetectedDataIdLookup(string id, string term, int limitCount = ActiveDirectory.DefaultSearchResultLimit)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(id) && !string.IsNullOrWhiteSpace(term))
|
||||
{
|
||||
@@ -330,7 +331,7 @@ namespace Disco.Web.Areas.API.Controllers
|
||||
results = Disco.Services.Searching.Search.SearchJobsTable(Database, term, limitCount, false).Items.Select(sr => Models.DocumentTemplate.ImporterUndetectedDataIdLookupModel.FromSearchResultItem(sr)).ToArray();
|
||||
break;
|
||||
case DocumentTemplate.DocumentTemplateScopes.User:
|
||||
results = Disco.Services.Searching.Search.SearchUsers(Database, term, limitCount).Select(sr => Models.DocumentTemplate.ImporterUndetectedDataIdLookupModel.FromSearchResultItem(sr)).ToArray();
|
||||
results = Disco.Services.Searching.Search.SearchUsers(Database, term, false, limitCount).Select(sr => Models.DocumentTemplate.ImporterUndetectedDataIdLookupModel.FromSearchResultItem(sr)).ToArray();
|
||||
break;
|
||||
default:
|
||||
results = null;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Disco.Models.Services.Searching;
|
||||
using Disco.Services.Authorization;
|
||||
using Disco.Services.Interop.ActiveDirectory;
|
||||
using Disco.Services.Searching;
|
||||
using Disco.Services.Web;
|
||||
using System;
|
||||
@@ -13,7 +14,7 @@ namespace Disco.Web.Areas.API.Controllers
|
||||
public partial class SearchController : AuthorizedDatabaseController
|
||||
{
|
||||
[DiscoAuthorizeAny(Claims.Job.Search, Claims.Device.Search, Claims.User.Search)]
|
||||
public virtual ActionResult QuickQuery(string Term, int Limit = 15)
|
||||
public virtual ActionResult QuickQuery(string Term, int Limit = ActiveDirectory.DefaultSearchResultLimit)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(Term))
|
||||
throw new ArgumentNullException("Term", "The search query term is required");
|
||||
@@ -36,20 +37,35 @@ namespace Disco.Web.Areas.API.Controllers
|
||||
break;
|
||||
case '@': // User Only
|
||||
if (Authorization.Has(Claims.User.Search))
|
||||
results = results.Concat(Search.SearchUsers(Database, Term.Substring(1), Limit));
|
||||
results = results.Concat(Search.SearchUsers(Database, Term.Substring(1), false, Limit));
|
||||
break;
|
||||
default: // Search All
|
||||
if (Authorization.Has(Claims.Job.Search))
|
||||
results = results.Concat(Search.SearchJobs(Database, Term, Limit));
|
||||
if (Authorization.Has(Claims.User.Search))
|
||||
results = results.Concat(Search.SearchUsers(Database, Term, Limit));
|
||||
results = results.Concat(Search.SearchUsers(Database, Term, false, Limit));
|
||||
if (Authorization.Has(Claims.Device.Search))
|
||||
results = results.Concat(Search.SearchDevices(Database, Term, Limit));
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
results = results.OrderByDescending(i => i.ScoreValue.Score(Term)).Take(Limit);
|
||||
results = results.OrderByDescending(i => i.ScoreValues.Score(Term)).Take(Limit);
|
||||
|
||||
return Json(results, JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
|
||||
[DiscoAuthorize(Claims.User.Search)]
|
||||
public virtual ActionResult UsersUpstream(string Term, int Limit = 15)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(Term))
|
||||
throw new ArgumentNullException("Term", "The search query term is required");
|
||||
if (Term.Length < 2)
|
||||
throw new ArgumentException("The search query term must be at least two characters", "Term");
|
||||
if (Limit < 1)
|
||||
throw new ArgumentException("The search query limit cannot be less than 1", "Limit");
|
||||
|
||||
var results = Search.SearchUsersUpstream(Database, Term, false, Limit);
|
||||
|
||||
return Json(results, JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
|
||||
@@ -12,12 +12,6 @@ namespace Disco.Web.Areas.API.Controllers
|
||||
{
|
||||
public partial class UserController : AuthorizedDatabaseController
|
||||
{
|
||||
[DiscoAuthorize(Claims.User.Search)]
|
||||
public virtual ActionResult UpstreamUsers(string term)
|
||||
{
|
||||
return Json(Disco.Services.Searching.Search.SearchUsersUpstream(term), JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
|
||||
#region User Attachements
|
||||
|
||||
[DiscoAuthorize(Claims.User.ShowAttachments)]
|
||||
|
||||
Reference in New Issue
Block a user