This commit is contained in:
@@ -28,10 +28,6 @@ Once that is done then can steam ahead on the biz objects but until I have the c
|
|||||||
IMMEDIATE ITEMS:
|
IMMEDIATE ITEMS:
|
||||||
================
|
================
|
||||||
|
|
||||||
|
|
||||||
- Search and search text indexing
|
|
||||||
- Update all the other routes to include search indexing (attachments, tags, taggroup)
|
|
||||||
|
|
||||||
- see if any other callers to name fetcher are in tight loops and could benefit from using the new Direct version
|
- see if any other callers to name fetcher are in tight loops and could benefit from using the new Direct version
|
||||||
|
|
||||||
- Schema: clean up all the LOOKAT items and verify the indexes are being used
|
- Schema: clean up all the LOOKAT items and verify the indexes are being used
|
||||||
|
|||||||
@@ -73,9 +73,7 @@ namespace AyaNova.Api.Controllers
|
|||||||
public async Task<IActionResult> GetDownloadToken()
|
public async Task<IActionResult> GetDownloadToken()
|
||||||
{
|
{
|
||||||
if (!serverState.IsOpen)
|
if (!serverState.IsOpen)
|
||||||
{
|
|
||||||
return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason));
|
return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason));
|
||||||
}
|
|
||||||
|
|
||||||
long lUserId = UserIdFromContext.Id(HttpContext.Items);
|
long lUserId = UserIdFromContext.Id(HttpContext.Items);
|
||||||
var u = await ct.User.FirstOrDefaultAsync(a => a.Id == lUserId);
|
var u = await ct.User.FirstOrDefaultAsync(a => a.Id == lUserId);
|
||||||
@@ -127,22 +125,15 @@ namespace AyaNova.Api.Controllers
|
|||||||
{
|
{
|
||||||
//Adapted from the example found here: https://docs.microsoft.com/en-us/aspnet/core/mvc/models/file-uploads#uploading-large-files-with-streaming
|
//Adapted from the example found here: https://docs.microsoft.com/en-us/aspnet/core/mvc/models/file-uploads#uploading-large-files-with-streaming
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (!serverState.IsOpen)
|
if (!serverState.IsOpen)
|
||||||
{
|
|
||||||
return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason));
|
return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason));
|
||||||
}
|
|
||||||
|
|
||||||
var returnList = new List<NameIdItem>();
|
var returnList = new List<NameIdItem>();
|
||||||
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (!MultipartRequestHelper.IsMultipartContentType(Request.ContentType))
|
if (!MultipartRequestHelper.IsMultipartContentType(Request.ContentType))
|
||||||
{
|
|
||||||
return BadRequest(new ApiErrorResponse(ApiErrorCode.INVALID_OPERATION, "FileUploadAttempt", $"Expected a multipart request, but got {Request.ContentType}"));
|
return BadRequest(new ApiErrorResponse(ApiErrorCode.INVALID_OPERATION, "FileUploadAttempt", $"Expected a multipart request, but got {Request.ContentType}"));
|
||||||
}
|
|
||||||
|
|
||||||
var uploadFormData = await ApiUploadProcessor.ProcessAttachmentUpload(HttpContext);
|
var uploadFormData = await ApiUploadProcessor.ProcessAttachmentUpload(HttpContext);
|
||||||
|
|
||||||
@@ -238,9 +229,13 @@ namespace AyaNova.Api.Controllers
|
|||||||
Id = v.Id
|
Id = v.Id
|
||||||
});
|
});
|
||||||
|
|
||||||
//Log
|
//EVENT LOG
|
||||||
EventLogProcessor.AddEntryToContextNoSave(new Event(UserId, attachToObject.ObjectId, attachToObject.ObjectType, AyaEvent.AttachmentCreate, v.DisplayFileName), ct);
|
EventLogProcessor.AddEntryToContextNoSave(new Event(UserId, attachToObject.ObjectId, attachToObject.ObjectType, AyaEvent.AttachmentCreate, v.DisplayFileName), ct);
|
||||||
ct.SaveChanges();
|
ct.SaveChanges();
|
||||||
|
|
||||||
|
//SEARCH INDEXING
|
||||||
|
Search.ProcessNewObjectKeywords(ct, UserLocaleIdFromContext.Id(HttpContext.Items), v.Id, AyaType.FileAttachment, v.DisplayFileName, v.DisplayFileName, v.Notes, v.StoredFileName);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -305,9 +300,13 @@ namespace AyaNova.Api.Controllers
|
|||||||
//this handles removing the file if there are no refs left and also the db record for the attachment
|
//this handles removing the file if there are no refs left and also the db record for the attachment
|
||||||
FileUtil.deleteFileAttachment(dbObj, ct);
|
FileUtil.deleteFileAttachment(dbObj, ct);
|
||||||
|
|
||||||
//Log
|
//Event log process delete
|
||||||
EventLogProcessor.AddEntryToContextNoSave(new Event(UserId, dbObj.AttachToObjectId, dbObj.AttachToObjectType, AyaEvent.AttachmentDelete, dbObj.DisplayFileName), ct);
|
EventLogProcessor.AddEntryToContextNoSave(new Event(UserId, dbObj.AttachToObjectId, dbObj.AttachToObjectType, AyaEvent.AttachmentDelete, dbObj.DisplayFileName), ct);
|
||||||
ct.SaveChanges();
|
ct.SaveChanges();
|
||||||
|
|
||||||
|
//Delete search index
|
||||||
|
Search.ProcessDeletedObjectKeywords(ct, dbObj.Id, AyaType.FileAttachment);
|
||||||
|
|
||||||
return NoContent();
|
return NoContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,14 +30,15 @@ namespace AyaNova.Biz
|
|||||||
Locale = 13,
|
Locale = 13,
|
||||||
UserOptions = 14,
|
UserOptions = 14,
|
||||||
TagGroup = 15,
|
TagGroup = 15,
|
||||||
TagGroupMap = 16
|
TagGroupMap = 16,
|
||||||
|
FileAttachment = 17
|
||||||
|
|
||||||
|
|
||||||
//NOTE: New objects added here need to also be added to the following classes:
|
//NOTE: New objects added here need to also be added to the following classes:
|
||||||
//AyaNova.Biz.BizObjectExistsInDatabase
|
//AyaNova.Biz.BizObjectExistsInDatabase
|
||||||
//AyaNova.Biz.BizObjectFactory
|
//AyaNova.Biz.BizObjectFactory
|
||||||
//AyaNova.Biz.BizRoles
|
//AyaNova.Biz.BizRoles
|
||||||
//AyaNova.Biz.BizObjectNameFetcher
|
//AyaNova.Biz.BizObjectNameFetcher && BizObjectNameFetcherDIRECT
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,6 +43,9 @@ namespace AyaNova.Biz
|
|||||||
return ct.Tag.Any(m => m.Id == id);
|
return ct.Tag.Any(m => m.Id == id);
|
||||||
case AyaType.TagGroup:
|
case AyaType.TagGroup:
|
||||||
return ct.TagGroup.Any(m => m.Id == id);
|
return ct.TagGroup.Any(m => m.Id == id);
|
||||||
|
case AyaType.FileAttachment:
|
||||||
|
return ct.FileAttachment.Any(m => m.Id == id);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -63,6 +63,8 @@ namespace AyaNova.Biz
|
|||||||
return ct.Tag.AsNoTracking().Where(m => m.Id == id).Select(m => m.Name).FirstOrDefault();
|
return ct.Tag.AsNoTracking().Where(m => m.Id == id).Select(m => m.Name).FirstOrDefault();
|
||||||
case AyaType.TagGroup:
|
case AyaType.TagGroup:
|
||||||
return ct.TagGroup.AsNoTracking().Where(m => m.Id == id).Select(m => m.Name).FirstOrDefault();
|
return ct.TagGroup.AsNoTracking().Where(m => m.Id == id).Select(m => m.Name).FirstOrDefault();
|
||||||
|
case AyaType.FileAttachment:
|
||||||
|
return ct.FileAttachment.AsNoTracking().Where(m => m.Id == id).Select(m => m.DisplayFileName).FirstOrDefault();
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new System.NotSupportedException($"AyaNova.BLL.BizObjectNameFetcher::Name type {aytype.ToString()} is not supported");
|
throw new System.NotSupportedException($"AyaNova.BLL.BizObjectNameFetcher::Name type {aytype.ToString()} is not supported");
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ namespace AyaNova.Biz
|
|||||||
internal static string Name(AyaType aytype, long id, System.Data.Common.DbCommand cmd)
|
internal static string Name(AyaType aytype, long id, System.Data.Common.DbCommand cmd)
|
||||||
{
|
{
|
||||||
string TABLE = string.Empty;
|
string TABLE = string.Empty;
|
||||||
|
string COLUMN = "name";
|
||||||
switch (aytype)
|
switch (aytype)
|
||||||
{
|
{
|
||||||
case AyaType.User:
|
case AyaType.User:
|
||||||
@@ -42,10 +43,14 @@ namespace AyaNova.Biz
|
|||||||
case AyaType.TagGroup:
|
case AyaType.TagGroup:
|
||||||
TABLE = "ataggroup";
|
TABLE = "ataggroup";
|
||||||
break;
|
break;
|
||||||
|
case AyaType.FileAttachment:
|
||||||
|
TABLE = "afileattachment";
|
||||||
|
COLUMN = "displayfilename";
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
throw new System.NotSupportedException($"AyaNova.BLL.BizObjectNameFetcher::Name type {aytype.ToString()} is not supported");
|
throw new System.NotSupportedException($"AyaNova.BLL.BizObjectNameFetcher::Name type {aytype.ToString()} is not supported");
|
||||||
}
|
}
|
||||||
cmd.CommandText = $"SELECT m.name FROM {TABLE} AS m WHERE m.id = {id} LIMIT 1";
|
cmd.CommandText = $"SELECT m.{COLUMN} FROM {TABLE} AS m WHERE m.id = {id} LIMIT 1";
|
||||||
using (var dr = cmd.ExecuteReader())
|
using (var dr = cmd.ExecuteReader())
|
||||||
return dr.Read() ? dr.GetString(0) : "UNKNOWN";
|
return dr.Read() ? dr.GetString(0) : "UNKNOWN";
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user