using DevadminDAL.DTO.ReportFormat; using DevadminDAL.Query.ReportFormat; using GB5Shared.DTO.Framework.Criteria; using GB5Shared.DTO.Framework.Login; using GB5Shared.QueryExecutor; using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using static GB5Shared.GB5Constant.Constant; namespace DevadminDAL.CustomCode.ReportFormat { public class ReportFormatDAL : IReportFormatDAL { private readonly IQueryExecutor _QueryExecutor; public ReportFormatDAL(IQueryExecutor queryExecutor) { _QueryExecutor = queryExecutor; } public async Task GetSelectListReportFormat(int FirstNumber, int MaxResult, CriteriaDTO CriteriaDTO, LoginDTO LoginDTO) { try { string SQL = string.Empty; switch (LoginDTO.DatabaseType) { case DBType.SQL: SQL = ReportFormatQB.GET_SELECTLIST_REPORTFORMAT_SQL; break; case DBType.PostGre: SQL = ReportFormatQB.GET_SELECTLIST_REPORTFORMAT_PG; break; case DBType.Oracle: SQL = ReportFormatQB.GET_SELECTLIST_REPORTFORMAT_ORACLE; break; case DBType.MySQL: SQL = ReportFormatQB.GET_SELECTLIST_REPORTFORMAT_MYSQL; break; default: throw new Exception("Unsupported database type"); } var Criteria = CriteriaParser.Parse(CriteriaDTO); string ReportFormatName = CriteriaParser.GetString(Criteria, "ReportFormatName"); var Parameters = new { firstnumber = FirstNumber, maxresult = MaxResult, reportformatname = string.IsNullOrWhiteSpace(ReportFormatName) ? null : ReportFormatName }; var Result = await _QueryExecutor.QueryAsync(LoginDTO, SQL, Parameters); string Json = JsonConvert.SerializeObject(Result); return Json; } catch (Exception) { throw; } } } }