mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 12:36:31 +00:00
splitting python complete
This commit is contained in:
@@ -94,6 +94,7 @@ public class AnnotationService : IAnnotationService
|
||||
await SaveAnnotationInner(
|
||||
msg.CreatedDate,
|
||||
msg.OriginalMediaName,
|
||||
msg.Name,
|
||||
msg.Time,
|
||||
JsonConvert.DeserializeObject<List<Detection>>(msg.Detections) ?? [],
|
||||
msg.Source,
|
||||
@@ -136,16 +137,16 @@ public class AnnotationService : IAnnotationService
|
||||
public async Task<Annotation> SaveAnnotation(AnnotationImage a, CancellationToken ct = default)
|
||||
{
|
||||
a.Time = TimeSpan.FromMilliseconds(a.Milliseconds);
|
||||
return await SaveAnnotationInner(DateTime.UtcNow, a.OriginalMediaName, a.Time, a.Detections.ToList(),
|
||||
return await SaveAnnotationInner(DateTime.UtcNow, a.OriginalMediaName, a.Name, a.Time, a.Detections.ToList(),
|
||||
SourceEnum.AI, new MemoryStream(a.Image), _api.CurrentUser.Role, _api.CurrentUser.Email, token: ct);
|
||||
}
|
||||
|
||||
//Manual
|
||||
public async Task<Annotation> SaveAnnotation(string originalMediaName, TimeSpan time, List<Detection> detections, Stream? stream = null, CancellationToken token = default) =>
|
||||
await SaveAnnotationInner(DateTime.UtcNow, originalMediaName, time, detections, SourceEnum.Manual, stream,
|
||||
public async Task<Annotation> SaveAnnotation(string originalMediaName, string annotationName, TimeSpan time, List<Detection> detections, Stream? stream = null, CancellationToken token = default) =>
|
||||
await SaveAnnotationInner(DateTime.UtcNow, originalMediaName, annotationName, time, detections, SourceEnum.Manual, stream,
|
||||
_api.CurrentUser.Role, _api.CurrentUser.Email, token: token);
|
||||
|
||||
private async Task<Annotation> SaveAnnotationInner(DateTime createdDate, string originalMediaName, TimeSpan time,
|
||||
private async Task<Annotation> SaveAnnotationInner(DateTime createdDate, string originalMediaName, string annotationName, TimeSpan time,
|
||||
List<Detection> detections, SourceEnum source, Stream? stream,
|
||||
RoleEnum userRole,
|
||||
string createdEmail,
|
||||
@@ -153,21 +154,20 @@ public class AnnotationService : IAnnotationService
|
||||
CancellationToken token = default)
|
||||
{
|
||||
var status = AnnotationStatus.Created;
|
||||
var fName = originalMediaName.ToTimeName(time);
|
||||
var annotation = await _dbFactory.RunWrite(async db =>
|
||||
{
|
||||
var ann = await db.Annotations
|
||||
.LoadWith(x => x.Detections)
|
||||
.FirstOrDefaultAsync(x => x.Name == fName, token: token);
|
||||
.FirstOrDefaultAsync(x => x.Name == annotationName, token: token);
|
||||
|
||||
await db.Detections.DeleteAsync(x => x.AnnotationName == fName, token: token);
|
||||
await db.Detections.DeleteAsync(x => x.AnnotationName == annotationName, token: token);
|
||||
|
||||
if (ann != null) //Annotation is already exists
|
||||
{
|
||||
status = AnnotationStatus.Edited;
|
||||
|
||||
var annotationUpdatable = db.Annotations
|
||||
.Where(x => x.Name == fName)
|
||||
.Where(x => x.Name == annotationName)
|
||||
.Set(x => x.Source, source);
|
||||
|
||||
if (userRole.IsValidator() && source == SourceEnum.Manual)
|
||||
@@ -188,7 +188,7 @@ public class AnnotationService : IAnnotationService
|
||||
ann = new Annotation
|
||||
{
|
||||
CreatedDate = createdDate,
|
||||
Name = fName,
|
||||
Name = annotationName,
|
||||
OriginalMediaName = originalMediaName,
|
||||
Time = time,
|
||||
ImageExtension = Constants.JPG_EXT,
|
||||
@@ -264,6 +264,6 @@ public class AnnotationService : IAnnotationService
|
||||
public interface IAnnotationService
|
||||
{
|
||||
Task<Annotation> SaveAnnotation(AnnotationImage a, CancellationToken ct = default);
|
||||
Task<Annotation> SaveAnnotation(string originalMediaName, TimeSpan time, List<Detection> detections, Stream? stream = null, CancellationToken token = default);
|
||||
Task<Annotation> SaveAnnotation(string originalMediaName, string annotationName, TimeSpan time, List<Detection> detections, Stream? stream = null, CancellationToken token = default);
|
||||
Task ValidateAnnotations(List<string> annotationNames, bool fromQueue = false, CancellationToken token = default);
|
||||
}
|
||||
Reference in New Issue
Block a user