public async Task <HttpResponseMessage> GetPunchReport(string source) { PunchReportParam param = JsonConvert.DeserializeObject <PunchReportParam>(source); ResponseModel result = await ReportDal.Instance.GetPunchReport(param); return(Request.CreateResponse(HttpStatusCode.OK, result)); }
internal async Task <ResponseModel> GetPunchReport(PunchReportParam parameters) { ResponseModel response = new ResponseModel(); List <PunchReport> result = new List <PunchReport>(); using (IDbConnection conn = _dbConnection.Connection) { DynamicParameters param = new DynamicParameters(); param.Add("@ShowOnlyMissingTime", parameters.showonlymissingtime, DbType.Boolean); param.Add("@IncludeWeekEnds", parameters.includeweekends, DbType.Boolean); string userIds = string.Empty; if (parameters.userids != null && parameters.userids.Count > 0) { userIds = string.Join(",", parameters.userids); param.Add("@UserIds", userIds, DbType.String); } if (!string.IsNullOrWhiteSpace(parameters.fromdate)) { param.Add("@FromDate", parameters.fromdate, DbType.String); } if (!string.IsNullOrWhiteSpace(parameters.todate)) { param.Add("@ToDate", parameters.todate, DbType.String); } dynamic data = await conn.QueryAsync <PunchReport>(Constants.StoredProcedure.GETPUNCHREPORT, param, null, null, CommandType.StoredProcedure); result = (List <PunchReport>)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> GetPunchReportFile(string sourceParam) { HttpResponse response = HttpContext.Current.Response; List <PunchReport> reportData = new List <PunchReport>(); string userids = string.Empty; PunchReportParam source = JsonConvert.DeserializeObject <PunchReportParam>(sourceParam); var reportResponse = await ReportDal.Instance.GetPunchReport(source); if (reportResponse.Output != null) { reportData = (List <PunchReport>)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\\PunchReport.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("ShowOnlyMissingTime", source.showonlymissingtime.ToString())); parameters.Add(new ReportParameter("IncludeWeekEnds", source.includeweekends.ToString())); parameters.Add(new ReportParameter("FromDate", source.fromdate)); parameters.Add(new ReportParameter("ToDate", source.todate)); lr.SetParameters(parameters); lr.DataSources.Clear(); lr.DataSources.Add(new ReportDataSource("DsPunchReport", 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, "PunchReport_", source.reporttype); return(new HttpResponseMessage(HttpStatusCode.OK)); } catch (Exception ex) { return(new HttpResponseMessage(HttpStatusCode.InternalServerError)); } }