Refactored `EmployeeUploadPicture.cshtml.cs` to improve readability, maintainability, and modularity. Introduced `_httpClientFactory` for HTTP requests and added `SendEmbeddingsToApi` for Python API integration. Enhanced employee-related operations, including activation, image handling, and settings management. Added `IFaceEmbeddingService` interface and implemented it in `FaceEmbeddingService` to manage face embeddings. Integrated with a Python API for generating, refining, deleting, and retrieving embeddings. Included robust error handling and detailed logging. Improved code structure, reduced duplication, and added comments for better debugging and future development. Add face embedding integration for employee management Introduced `IFaceEmbeddingService` and its implementation to manage face embeddings via a Python API. Integrated embedding generation into `EmployeeApplication` and `EmployeeUploadPictureModel`, enabling image uploads, embedding creation, and validation. Refactored `EmployeeUploadPictureModel` for clarity, adding methods to handle image processing, API interactions, and employee activation/deactivation with embedding checks. Enhanced error handling, logging, and user feedback. Removed legacy code and updated dependencies to include `IHttpClientFactory` and `IFaceEmbeddingService`. Added localized error messages and improved maintainability by streamlining code.
25 lines
1.1 KiB
C#
25 lines
1.1 KiB
C#
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace _0_Framework.Application.FaceEmbedding;
|
|
|
|
public interface IFaceEmbeddingService
|
|
{
|
|
Task<OperationResult> GenerateEmbeddingsAsync(long employeeId, long workshopId, string employeeFullName, string picture1Path, string picture2Path);
|
|
Task<OperationResult> GenerateEmbeddingsFromStreamAsync(long employeeId, long workshopId, string employeeFullName, Stream picture1Stream, Stream picture2Stream);
|
|
Task<OperationResult> RefineEmbeddingAsync(long employeeId, long workshopId, float[] embedding, float confidence, Dictionary<string, object> metadata = null);
|
|
Task<OperationResult> DeleteEmbeddingAsync(long employeeId, long workshopId);
|
|
Task<OperationResult<FaceEmbeddingResponse>> GetEmbeddingAsync(long employeeId, long workshopId);
|
|
}
|
|
|
|
public class FaceEmbeddingResponse
|
|
{
|
|
public long EmployeeId { get; set; }
|
|
public long WorkshopId { get; set; }
|
|
public string EmployeeFullName { get; set; }
|
|
public float[] Embedding { get; set; }
|
|
public float Confidence { get; set; }
|
|
public Dictionary<string, object> Metadata { get; set; }
|
|
}
|