public async Task <HttpResponseMessage> GetProfileSearchReport(string source) { ProfileSearchReportParam param = JsonConvert.DeserializeObject <ProfileSearchReportParam>(source); ResponseModel result = await ReportDal.Instance.GetProfileSearchReport(param); return(Request.CreateResponse(HttpStatusCode.OK, result)); }
internal async Task <ResponseModel> GetProfileSearchReport(ProfileSearchReportParam parameters) { ResponseModel response = new ResponseModel(); List <ProfileSearchReport> result = new List <ProfileSearchReport>(); using (IDbConnection conn = _dbConnection.Connection) { DynamicParameters param = new DynamicParameters(); string userIds = string.Empty; if (parameters.userids != null && parameters.userids.Count > 0) { userIds = string.Join(",", parameters.userids); } if (!string.IsNullOrWhiteSpace(userIds)) { param.Add("@UserIds", userIds, DbType.String); } if (!string.IsNullOrWhiteSpace(parameters.jobcode)) { param.Add("@JobCode", parameters.jobcode, DbType.String); } if (!string.IsNullOrWhiteSpace(parameters.title)) { param.Add("@Title", parameters.title, DbType.String); } if (!string.IsNullOrWhiteSpace(parameters.location)) { param.Add("@Location", parameters.location, DbType.String); } if (!string.IsNullOrWhiteSpace(parameters.searcheddate)) { param.Add("@SearchedDate", parameters.searcheddate, DbType.String); } if (parameters.lastdays != -1) { param.Add("@LastDays", parameters.lastdays, DbType.Int32); } dynamic data = await conn.QueryAsync <ProfileSearchReport>(Constants.StoredProcedure.GETPROFILESEACHRREPORT, param, null, null, CommandType.StoredProcedure); result = (List <ProfileSearchReport>)data; response.ResultStatus = result.Count > 0 ? Constants.ResponseResult.SUCCESS : Constants.ResponseResult.NODATA; response.Output = result; response.OutputCount = result.Count; } return(response); }
public async Task <HttpResponseMessage> GetProfileSearchReportFile(string sourceParam) { HttpResponse response = HttpContext.Current.Response; List <ProfileSearchReport> reportData = new List <ProfileSearchReport>(); string userids = string.Empty; ProfileSearchReportParam source = JsonConvert.DeserializeObject <ProfileSearchReportParam>(sourceParam); var reportResponse = await ReportDal.Instance.GetProfileSearchReport(source); if (reportResponse.Output != null) { reportData = (List <ProfileSearchReport>)reportResponse.Output; } /* Follow the below URL, so report will work. * https://stackoverflow.com/questions/38902037/ssrs-report-definition-is-newer-than-server?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa */ try { byte[] bytes; Warning[] warnings; string[] streamids; string mimeType, encoding, extension; LocalReport lr = new LocalReport(); lr.ReportPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Reports\\ProfileSearchReport.rdlc"); if (source.userids != null && source.userids.Count > 0) { userids = string.Join(",", source.userids); } List <ReportParameter> parameters = new List <ReportParameter>(); parameters.Add(new ReportParameter("UserIds", userids)); parameters.Add(new ReportParameter("JobCode", source.jobcode)); parameters.Add(new ReportParameter("Title", source.title)); parameters.Add(new ReportParameter("Location", source.location)); parameters.Add(new ReportParameter("SearchedDate", source.searcheddate)); parameters.Add(new ReportParameter("LastDays", source.lastdays.ToString())); lr.SetParameters(parameters); lr.DataSources.Clear(); lr.DataSources.Add(new ReportDataSource("DsProfileSearchReport", reportData)); lr.Refresh(); /* < PageWidth > 8.5in</ PageWidth > < PageHeight > 11in</ PageHeight > */ string deviceInfo = @"<DeviceInfo> <OutputFormat>EMF</OutputFormat> <PageWidth>11.5in</PageWidth> <PageHeight>8.5in</PageHeight> <MarginTop>0.25in</MarginTop> <MarginLeft>0.15in</MarginLeft> <MarginRight>0.15in</MarginRight> <MarginBottom>0.25in</MarginBottom> </DeviceInfo>"; if (source.reporttype == "excel") { bytes = lr.Render("EXCELOPENXML", deviceInfo, out mimeType, out encoding, out extension, out streamids, out warnings); } else { bytes = lr.Render("pdf", deviceInfo, out mimeType, out encoding, out extension, out streamids, out warnings); } generateFile(response, bytes, "ProfileSearchReport_", source.reporttype); return(new HttpResponseMessage(HttpStatusCode.OK)); } catch (Exception ex) { return(new HttpResponseMessage(HttpStatusCode.InternalServerError)); } }