using System.Net.Http; using System.Net.Http.Headers; using System.Net.Http.Json; using System.IO; using System.Text; using System.Text.Json; using System.Threading; using FrameworkDAL.DTO.Address; using FrameworkDAL.DTO.MessagingQueue; using FrameworkDAL.DTO.MMedge; using FrameworkDAL.DTO.ReportFormat; using FrameworkDAL.DTO.ReportViewer; using FrameworkDAL.Query.Report; using ReportViewDTO = GB5Shared.DTO.Report.ReportViewDTO; using GB5Shared.DTO.Framework.Criteria; using GB5Shared.DTO.Framework.DBLevelSetting; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.DTO.Framework.SuccessORError; using GB5Shared.DTO.Report; using GB5Shared.ExcelExport; using GB5Shared.GB5CommonFunction; using GB5Shared.GB5Exception; using GB5Shared.QueryExecutor; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using Omu.ValueInjecter.Utils; using static GB5Shared.GB5Constant.Constant; namespace FrameworkDAL.CustomCode.CommonReport { public class CommonReportDAL : ICommonReportDAL { private readonly IQueryExecutor IQueryExecutor; private readonly IExcelExport IExcelExport; private readonly IGB5CommonFunction CommonFunction; public CommonReportDAL(IQueryExecutor queryExecutor, IExcelExport ExcelExport, IGB5CommonFunction IGB5CommonFunction) { IQueryExecutor = queryExecutor; IExcelExport = ExcelExport; CommonFunction = IGB5CommonFunction; } public async Task GetReportFormat(int ReportFormatId, LoginDTO LoginDTO) { try { var parameters = new Dictionary { { "@ReportFormatId", ReportFormatId } }; string query = ReportQB.GETREPORTFORMAT; ReportFormatDTO reportFormat = await IQueryExecutor.QuerySingleAsync(LoginDTO, query, parameters); return reportFormat; } catch (Exception) { throw; } } public async Task GetReport(int ReportId, LoginDTO LoginDTO) { try { var parameters = new Dictionary { { "@ReportId", ReportId } }; string query = ReportQB.GETREPORT; ReportDTO report = await IQueryExecutor.QuerySingleAsync(LoginDTO, query, parameters); return report; } catch (Exception) { throw; } } public async Task> GetReportView(int ReportViewId, LoginDTO LoginDTO) { try { var parameters = new Dictionary { { "@ReportViewId", ReportViewId } }; string query = ReportQB.GETREPORTVIEW; List reportViews = (await IQueryExecutor.QueryAsync(LoginDTO, query, parameters)).ToList(); return reportViews; } catch (Exception) { throw; } } public async Task> GetStandardFields(string OuId, LoginDTO LoginDTO) { try { var parameters = new Dictionary { { "@ouid", OuId }, { "@clientid", LoginDTO.ClientId }, { "@baseuri", LoginDTO.BaseUri ?? "" } }; string query = ReportQB.GET_STANDARD_FIELDS_FOR_REPORT; List standardFields = (await IQueryExecutor.QueryAsync(LoginDTO, query, parameters)).ToList(); return standardFields; } catch (Exception) { throw; } } public async Task> GetReportViewField(int ReportViewId, int FieldIsDisplay, LoginDTO LoginDTO) { try { var parameters = new Dictionary { { "@ReportViewId", ReportViewId }, { "@FieldIsDisplay", FieldIsDisplay } }; string query = ReportQB.GET_REPORT_VIEW_FIELD; List reportViewFields = (await IQueryExecutor.QueryAsync(LoginDTO, query, parameters)).ToList(); return reportViewFields; } catch (Exception) { throw; } } public async Task GetReportViewMeta(int reportViewId, LoginDTO loginDTO, CancellationToken ct) { var parameters = new Dictionary { { "@ReportViewId", reportViewId } }; return await IQueryExecutor .QuerySingleAsync(loginDTO, ReportQB.GET_REPORT_VIEW_META, parameters, cancellationToken: ct) .ConfigureAwait(false); } public async Task> GetPivotFieldConfig(int reportViewId, LoginDTO loginDTO, CancellationToken ct) { var parameters = new Dictionary { { "@ReportViewId", reportViewId } }; return await IQueryExecutor .QueryAsync(loginDTO, ReportQB.GET_PIVOT_FIELD_CONFIG, parameters, cancellationToken: ct) .ConfigureAwait(false); } } }