//using FrameworkDAL.CustomCode.Module; //using FrameworkDAL.DTO.Module; //using GB5Shared.DTO.Framework.Login; //using GB5Shared.DTO.Framework.ResponseStandard; //using FrameworkSL.Middleware.ResponseStandard; //using GB5Shared.DTO.Framework.SuccessORError; //using Microsoft.AspNetCore.Mvc; //using GB5Shared.DaprCache; //using static GB5Shared.GB5Constant.Constant; //using FrameworkBLL.TRModule; //using System.Diagnostics; //namespace FrameworkSL.Controllers.Module //{ // [ApiController] // [Route("[controller]")] // public class ModuleService : ControllerBase // { // private readonly IModuleDAL _ModuleDAL; // private readonly Dapr.Client.DaprClient _daprClient; // private readonly ITRModuleBLL _ModuleBLL; // public ModuleService(IModuleDAL ModuleDAL, Dapr.Client.DaprClient daprClient, ITRModuleBLL ITRModuleBLL) // { // _ModuleDAL = ModuleDAL; // _daprClient = daprClient; // _ModuleBLL = ITRModuleBLL; // } // [HttpGet("GetModuleList")] // public async Task> GetModuleList([FromHeader(Name = "Login")] string loginDtoJson) // { // CacheKeyGeneration Key = new(); // using (var activity = ActivitySource.StartActivity("API.Module.List.Get", ActivityKind.Server)) // { // try // { // var LoginDTO = Newtonsoft.Json.JsonConvert.DeserializeObject(loginDtoJson); // // Set useful tags for observability // activity?.SetTag("Module", "ModuleList"); // activity?.SetTag("Operation", "Get"); // activity?.SetTag("UserName", LoginDTO?.UserName ?? "unknown"); // activity?.AddEvent(new ActivityEvent("DAL.Module.List.Cache.Check")); // string key = Key.KeyGeneration(null!, EntityConstant.MENU, CacheKeyLevel.ROLE_LEVEL, LoginDTO!); // string CachedJson = await _daprClient.GetStateAsync("statestore", key); // if (CachedJson == null) // { // activity?.AddEvent(new ActivityEvent("DAL.Module.List.Cache.Miss")); // var result = await _ModuleDAL.GetModuleList(LoginDTO!); // if (result == null || !result.Any()) // { // activity?.SetStatus(ActivityStatusCode.Ok, "No Data Found"); // return await FrameworkSL.Middleware.ResponseStandard.Response.CreateEmptyResponse("No Data Found", 404); // } // var metadata = new Dictionary // { // { "ttlInSeconds", "60" } // }; // await _daprClient.SaveStateAsync("statestore", key, result, metadata: metadata); // activity?.AddEvent(new ActivityEvent("DAL.Module.List.Cache.Saved")); // return await FrameworkSL.Middleware.ResponseStandard.Response.CreateSuccessResponse(result); // } // activity?.AddEvent(new ActivityEvent("DAL.Module.List.Cache.Hit")); // return await FrameworkSL.Middleware.ResponseStandard.Response.CreateSuccessResponseEnumerable(CachedJson!); // } // catch (Exception ex) // { // activity?.SetStatus(ActivityStatusCode.Error, ex.Message); // activity?.SetTag("exception.message", ex.Message); // activity?.SetTag("exception.stacktrace", ex.StackTrace ?? "no stack"); // return await FrameworkSL.Middleware.ResponseStandard.Response.CreateExceptionError(ex, ex.Message, 500); // } // } // } // /// // /// GetTRModule Based on LanguageId and ModuleId // /// // /// // /// // /// // /// // private static readonly ActivitySource ActivitySource = new ActivitySource("FrameworkSL"); // //[HttpGet("GetTRModule")] // //public async Task> GetTRModule(int ModuleId, [FromHeader(Name = "Login")] string loginDtoJson) // //{ // // using (var activity = ActivitySource.StartActivity("API.TR.Module.Get", ActivityKind.Server)) // // { // // try // // { // // var LoginDTO = Newtonsoft.Json.JsonConvert.DeserializeObject(loginDtoJson); // // activity?.SetTag("module", "translation"); // // activity?.SetTag("operation", "get"); // // activity?.SetTag("ModuleId", ModuleId); // // activity?.SetTag("UserName", LoginDTO?.UserName ?? "unknown"); // // activity?.AddEvent(new ActivityEvent("BLL.Module.Get.Start")); // // var result = await _ModuleBLL.GetTranslationModule(ModuleId, LoginDTO!); // // activity?.AddEvent(new ActivityEvent("BLL.Module.Get.Success")); // // return await FrameworkSL.Middleware.ResponseStandard.Response.CreateSuccessResponse(result); // // } // // catch (Exception ex) // // { // // activity?.SetStatus(ActivityStatusCode.Error, ex.Message); // // activity?.SetTag("exception.message", ex.Message); // // activity?.SetTag("exception.stacktrace", ex.StackTrace ?? "no stack"); // // return await FrameworkSL.Middleware.ResponseStandard.Response.CreateExceptionError(ex, ex.Message, 500); // // } // // } // //} // } //}