using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Net.Http; using System.Web.Http; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using AIAHTML5.ADMIN.API.Models; using System.Web.Http.Cors; using System.Web.Cors; using AIAHTML5.Server.Constants; using log4net; using System.Text; using AIAHTML5.ADMIN.API.Entity; namespace AIAHTML5.ADMIN.API.Controllers { //[EnableCors(origins: "http://localhost:4200", headers: "*", methods: "*")] [RoutePrefix("Report")] public class ReportController : ApiController { AIADatabaseV5Entities dbContext = new AIADatabaseV5Entities(); [Route("GetUsageReport")] [HttpGet] public IHttpActionResult GetUsageReport(string sFromDate, string sToDate, string sAccoutNumber, string sZip, int iState, int iCountry, string sortColumn, string sortOrder, int pageNo, int pageLength) { var spRecordCount = new System.Data.Objects.ObjectParameter("recordCount", 0); var lstUsageReport = dbContext.usp_GetUsageReport(sFromDate, sToDate, sAccoutNumber, sZip, iState, iCountry, sortColumn, sortOrder, pageNo, pageLength, spRecordCount).ToList(); return Ok(new { UserUsage = lstUsageReport, RecordCount = spRecordCount.Value }); //return Ok(lstUsageReport); } [Route("GetCustomerSummeryReport")] [HttpGet] public IHttpActionResult GetCustomerSummeryReport(string sAccoutNumber, string sLicenseeFullName, Nullable iStartPrice, Nullable iEndPrice, int iLicenseType, int iAccountType, string sZip, int iState, int iCountry, string sortColumn, string sortOrder, int pageNo, int pageLength) { var spRecordCount = new System.Data.Objects.ObjectParameter("recordCount", 0); var lstCustomerSummeryReport = dbContext.usp_GetCustomerSummary(sAccoutNumber, sLicenseeFullName, iStartPrice, iEndPrice, (byte)iLicenseType, (byte)iAccountType, sZip, iState, iCountry, sortColumn, sortOrder, pageNo, pageLength, spRecordCount).ToList(); return Ok(new { CustomerSummery = lstCustomerSummeryReport, RecordCount = spRecordCount.Value }); //return Ok(lstCustomerSummeryReport); } [Route("GetExpiringSubscriptionReport")] [HttpGet] public IHttpActionResult GetExpiringSubscriptionReport(string sFromDate, string sToDate, decimal iStartPrice, decimal iEndPrice, int iLicenseTypeId, int iAccountTypeId, string sZip, int iStateId, int iCountryId, string sortColumn, string sortOrder, int pageNo, int pageLength) { var spRecordCount = new System.Data.Objects.ObjectParameter("recordCount", 0); var lstExpiringSubscriptionReport = dbContext.usp_GetExpiringLicenses(sFromDate, sToDate, iStartPrice, iEndPrice, (byte)iLicenseTypeId, (byte)iAccountTypeId, sZip, iStateId, iCountryId, sortColumn, sortOrder, pageNo, pageLength, spRecordCount).ToList(); return Ok(new { ExpiringSubscription = lstExpiringSubscriptionReport, RecordCount = spRecordCount.Value }); } [Route("GetSubscriptionReport")] [HttpGet] public IHttpActionResult GetSubscriptionReport(string sFromDate, string sToDate, decimal icStartPrice, decimal icEndPrice, int iLicenseTypeId, int iAccountTypeId, string sZip, int iStateId, int iCountryId, string sortColumn, string sortOrder, int pageNo, int pageLength) { var spRecordCount = new System.Data.Objects.ObjectParameter("recordCount", 0); var lstExpiringSubscriptionReport = dbContext.usp_GetSubscribedLicenses(sFromDate, sToDate, icStartPrice, icEndPrice, (byte)iLicenseTypeId, (byte)iAccountTypeId, sZip, iStateId, iCountryId, sortColumn, sortOrder, pageNo, pageLength, spRecordCount).ToList(); return Ok(new { Subscription = lstExpiringSubscriptionReport, RecordCount = spRecordCount.Value }); } [Route("GetSubscriptionCancellationReport")] [HttpGet] public IHttpActionResult GetSubscriptionCancellationReport(string sFromDate, string sToDate, decimal icStartPrice, decimal icEndPrice, int iLicenseTypeId, int iAccountTypeId, string sZip, int iStateId, int iCountryId, string sortColumn, string sortOrder, int pageNo, int pageLength) { var spRecordCount = new System.Data.Objects.ObjectParameter("recordCount", 0); var lstExpiringSubscriptionReport = dbContext.usp_GetCancelledLicenses(sFromDate, sToDate, icStartPrice, icEndPrice, (byte)iLicenseTypeId, (byte)iAccountTypeId, sZip, iStateId, iCountryId, sortColumn, sortOrder, pageNo, pageLength, spRecordCount).ToList(); return Ok(new { SubscriptionCancel = lstExpiringSubscriptionReport, RecordCount = spRecordCount.Value }); } [Route("GetNetAdSummaryReport")] [HttpGet] public IHttpActionResult GetNetAdSummaryReport(string sFromDate, string sToDate, decimal iStartPrice, decimal iEndPrice, int iLicenseTypeId,string sortColumn, string sortOrder, int pageNo, int pageLength) { try { var spRecordCount = new System.Data.Objects.ObjectParameter("recordCount", 0); var lstNetAdSummaryReport = dbContext.usp_GetNetAdSummaryReport(sFromDate, sToDate, iStartPrice, iEndPrice, (byte)iLicenseTypeId, sortColumn, sortOrder, pageNo, pageLength, spRecordCount).ToList(); return Ok(new { NetAdSubscriptionList = lstNetAdSummaryReport, RecordCount = spRecordCount.Value }); } catch (Exception ex) { return Ok(ex.Message.ToString()); } } [Route("GetSiteLicenseUsageReport")] [HttpGet] public IHttpActionResult GetSiteLicenseUsageReport(string sFromDate, string sToDate, string sAccountNumber, int iEdition, int iloginTypeId, string sortColumn, string sortOrder, int pageNo, int pageLength) { try { var spRecordCount = new System.Data.Objects.ObjectParameter("recordCount", 0); var lstSiteLicenseUsageReport = dbContext.usp_GetSiteLicenseUsageReports(sFromDate, sToDate, sAccountNumber, (byte)iEdition, (byte)iloginTypeId, sortColumn, sortOrder, pageNo, pageLength, spRecordCount).ToList(); return Ok(new { SiteLicenseUsageList = lstSiteLicenseUsageReport, RecordCount = spRecordCount.Value }); } catch (Exception ex) { return Ok(ex.Message.ToString()); } } [Route("GetDiscountReport")] [HttpGet] public IHttpActionResult GetDiscountReport(string sFromDate, string sToDate, int iDiscountCode, string sAccountNumber, string sortColumn, string sortOrder, int pageNo, int pageLength) { try { var spRecordCount = new System.Data.Objects.ObjectParameter("recordCount", 0); var lstDiscountReport = dbContext.usp_GetDiscountReport(sFromDate, sToDate, iDiscountCode, sAccountNumber, sortColumn, sortOrder, pageNo, pageLength, spRecordCount).ToList(); return Ok(new { DiscountReportList = lstDiscountReport, RecordCount = spRecordCount.Value }); } catch (Exception ex) { return Ok(ex.Message.ToString()); } } [Route("GetImageExportReport")] [HttpGet] public IHttpActionResult GetImageExportReport(string sFromDate, string sToDate, string sAccountNumber, string sortColumn, string sortOrder, int pageNo, int pageLength) { try { if (sAccountNumber == null) sAccountNumber = string.Empty; var spRecordCount = new System.Data.Objects.ObjectParameter("recordCount", 0); var lstImageExportReport = dbContext.usp_GetExportedImageDetails(sFromDate, sToDate, sAccountNumber, sortColumn, sortOrder, pageNo, pageLength, spRecordCount).ToList(); return Ok(new { ImageExportList = lstImageExportReport, RecordCount = spRecordCount.Value }); } catch (Exception ex) { return Ok(ex.Message.ToString()); } } } }