// GET: Admin/ReportParam/Edit/5 public ActionResult Edit(int?id, int rptId) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ReportParam reportParam = ContextPerRequest.CurrentData.ReportParams.Find(id); ReportParamViewModel model = new ReportParamViewModel(); if (reportParam == null) { return(HttpNotFound()); } else { model.DisplayOrder = reportParam.DisplayOrder ?? 0; model.DropSQL = reportParam.DropSQL; model.ParamDescription = string.Empty; model.ParamName = reportParam.ParamName; model.ParamTitle = reportParam.ParamTitle; model.ParamTypeList = null; model.ParamWidth = reportParam.ParamWidth ?? 0; model.ReportID = reportParam.ReportID; model.ReportParamID = reportParam.ReportParamID; model.ReportParamTypeID = reportParam.ReportParamTypeID; } return(View(model)); }
public Common.Data.JsonData Add(ReportParam model) { //添加举报项 DateTime time = DateTime.Now; ReportEnumDetail detail = new ReportEnumDetail() { Report = new List <ReportEnumRec>(), ReportContainerNote = new List <ReporterAndNote>() }; Common.Data.JsonData json = new Common.Data.JsonData() { Result = true }; try { bool writeReportNote = false; if (!string.IsNullOrEmpty(model.Note)) { detail.Note = new ReportNote() { UINote = model.Note, CreateTime = time }; reportRepository.SaveNote(detail.Note); writeReportNote = true; } foreach (Guid item in model.Ids) { ReportEnumRec rec = new ReportEnumRec() { ReportEnum = model.ReportType, BeenReporterId = item, CreateTime = time }; detail.Report.Add(rec); if (writeReportNote) {//填写了举报信息描述 ReporterAndNote rn = new ReporterAndNote() { CreateTime = time, ReportNoteId = detail.Note.Id, ReportId = rec.Id }; detail.ReportContainerNote.Add(rn); } } //举报的对象入库 reportRepository.SaveReported(detail.Report); if (writeReportNote) { reportRepository.SaveReportedAndNote(detail.ReportContainerNote); } //关联举报的对象 json.Data = detail; json.Success = true; } catch (Exception ex) { json.Message = ex.Message; } return(json); }
public ActionResult DeleteConfirmed(int id, int rptId) { ReportParam reportParam = ContextPerRequest.CurrentData.ReportParams.Find(id); ContextPerRequest.CurrentData.ReportParams.Remove(reportParam); ContextPerRequest.CurrentData.SaveChanges(); return(RedirectToAction("Edit", "Report", new { id = reportParam.ReportID })); // return RedirectToAction("Index"); }
/// <summary> /// 获取文件全路径 /// </summary> /// <param name="param"></param> /// <returns></returns> protected string GetFileFullName(ReportParam param) { string reportPath = fileRootPath; string fileName = manualFileName; string fileFullName = Path.Combine(reportPath, fileName); string renameFilename = GetNewPathForDupes(fileFullName); return(renameFilename); }
/// <summary> /// 获取报表编号: 6位结构物Id + 6位监测因素Id + 2位报表日期类型 + (创建时间 - “1970-01-01”经过的毫秒数) /// </summary> /// <param name="param"></param> /// <returns></returns> protected string GetFileId(ReportParam param) { var sb = new StringBuilder(50); sb.AppendFormat("{0:D6}", param.StructId); sb.AppendFormat("-{0:D6}", param.FactorId); sb.AppendFormat("-{0:D2}", param.RptType); sb.Append("-").Append((long)(Convert.ToDateTime(param.Date) - new DateTime(1970, 1, 1)).TotalMilliseconds); return(sb.ToString()); }
public ActionResult Edit([Bind(Include = "ReportParamID,ReportID,ReportParamTypeID,ParamName,ParamTitle,ParamWidth,DisplayOrder,DropSQL")] ReportParam reportParam) { if (ModelState.IsValid) { ContextPerRequest.CurrentData.Entry(reportParam).State = EntityState.Modified; ContextPerRequest.CurrentData.SaveChanges(); return(RedirectToAction("Index")); } return(RedirectToAction("Edit", "Report", new { id = reportParam.ReportID })); // return View(reportParam); }
private ActionResult Processing_Bank(int claim, PaymentMode payment) { ActionResult result4; if (payment == null) { throw new ArgumentNullException("payment"); } PaymentBeforeProcessingResult result = BookingProvider.BeforePaymentProcessing(UrlLanguage.CurrentLanguage, payment.paymentparam); if (result == null) { throw new Exception("cannot get payment details"); } if (!result.success) { throw new Exception("payment details fail"); } try { List <ReportParam> list = new List <ReportParam>(); ReportParam item = new ReportParam { Name = "vClaimList", Value = claim.ToString() }; list.Add(item); string str = ConfigurationManager.AppSettings["report_PrintInvoice"]; if (string.IsNullOrEmpty(str)) { throw new Exception("report_PrintInvoice is empty"); } ReportResult result2 = ReportServer.BuildReport(str, ReportFormat.pdf, list.ToArray()); if (result2 == null) { throw new Exception("report data is empty"); } MemoryStream fileStream = new MemoryStream(result2.Content); FileStreamResult result3 = new FileStreamResult(fileStream, "application/pdf") { FileDownloadName = string.Format("invoice_{0}.pdf", claim) }; result4 = result3; } catch (Exception exception) { Tracing.ServiceTrace.TraceEvent(TraceEventType.Error, 0, exception.ToString()); throw; } return(result4); }
// GET: Admin/ReportParam/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ReportParam reportParam = ContextPerRequest.CurrentData.ReportParams.Find(id); if (reportParam == null) { return(HttpNotFound()); } return(View(reportParam)); }
public JsonResult GetDetail([FromBody] ReportParam param) { var sql = @"select ua.Answer as UserAnswer,qb.*,u.ID as UserId,u.Name as UserName from UserAnswer ua inner join QuestionBank qb on ua.QuestionId=qb.ID inner join [User] u on u.ID = ua.UserId where ua.UserId=" + param.id; var list = DataAcccessHelper.Query <UserAnswerDetailModel>(sql, param); var userInfo = DataAcccessHelper.QueryFirst <User>("select * from [user] where id =" + param.id, param); return(Json(new ResponseModel <object> { RspCode = RspCode.C0000, Body = new { list, userInfo } })); }
public ActionResult Report() { ViewBag.Message = ""; ReportParam objmodel = new ReportParam(); objmodel.StartDate = DateTime.Now.AddMonths(-1).Date; objmodel.EndDate = DateTime.Now.Date; using (rdlcdbEntities obj = new rdlcdbEntities()) { objmodel.EmployeesList = obj.Employees.ToList(); objmodel.EmpName = "kiran"; objmodel.EmployeesList.Add(new Employee() { Id = -1, Name = "All Employee" }); } return(View(objmodel)); }
public ActionResult Create([Bind(Include = "ReportParamID,ReportID,ReportParamTypeID,ParamName,ParamTitle,ParamWidth,DisplayOrder,DropSQL")] ReportParamViewModel reportParam) { if (ModelState.IsValid) { ReportParam param = new ReportParam { DisplayOrder = reportParam.DisplayOrder, DropSQL = reportParam.DropSQL, ParamName = reportParam.ParamName, ParamTitle = reportParam.ParamTitle, ParamWidth = reportParam.ParamWidth, ReportID = reportParam.ReportID, ReportParamTypeID = reportParam.ReportParamTypeID }; ContextPerRequest.CurrentData.ReportParams.Add(param); ContextPerRequest.CurrentData.SaveChanges(); return(RedirectToAction("Edit", "Report", new { id = reportParam.ReportID })); } return(View(reportParam)); }
private ActionResult BuildVoucher(int claimId) { ActionResult result3; try { List <ReportParam> list = new List <ReportParam>(); ReportParam item = new ReportParam { Name = "vClaimList", Value = claimId.ToString() }; list.Add(item); string str = ConfigurationManager.AppSettings["report_PrintVoucher"]; if (string.IsNullOrEmpty(str)) { throw new Exception("report_PrintVoucher is empty"); } ReportResult result = ReportServer.BuildReport(str, ReportFormat.pdf, list.ToArray()); if (result == null) { throw new Exception("report data is empty"); } MemoryStream fileStream = new MemoryStream(result.Content); FileStreamResult result2 = new FileStreamResult(fileStream, "application/pdf") { FileDownloadName = string.Format("voucher_{0}.pdf", claimId) }; result3 = result2; } catch (Exception exception) { Tracing.ServiceTrace.TraceEvent(TraceEventType.Error, 0, exception.ToString()); throw; } return(result3); }
public JsonResult GetResult([FromBody] ReportParam param) { var where = new StringBuilder(" where 1=1 "); if (!string.IsNullOrWhiteSpace(param.name)) { where.Append(" and name = @name "); } var sql = @" select u.ID as UserId,u.Name as UserName,us.Score,us.CreateTime,us.UpdateTime FROM [WaterSupplySecurity].[dbo].[UserScore] us inner join [dbo].[User] u on u.ID = us.UserID " + where.ToString(); var result = DataAcccessHelper.Query <UserReportModel>(sql, param); var response = result.Skip((param.pageIndex - 1) * param.pageSize).Take(param.pageSize).ToList(); return(Json(new ResponseModel <object> { RspCode = RspCode.C0000, Body = response, Page = new PageModel { TotalCount = result.Count(), PageSize = param.pageSize } })); }
public JsonResult SignAccount(ReportParam param) { Common.Data.JsonData json = IocMvcFactoryHelper.GetInterface <IReportEnumDataService>().Add(param); return(Json(json)); }
public DataResult Document(ReportParam param) { paramModel = param; if (param.grfUrl != null) { // 从指定的 URL 地址载入报表模板数据 loadGrf = report.LoadFromURL(param.grfUrl); } else { // 从字符串中载入报表模板数据 loadGrf = report.LoadFromStr(param.grfStr); } if (!loadGrf) { return(request.Error("载入报表文件出错,请检查报表模板数据是否正确!")); } if (param.grfDataUrl != null) { // 从指定的 URL 地址载入报表明细数据 loadData = report.LoadDataFromURL(param.grfDataUrl); } else { // 从 XML 或 JSON 文字串中载入报表明细记录集数据,数据应符合约定的形式。 loadData = report.LoadDataFromXML(paramModel.grfData); } if (!loadData) { return(request.Error("载入报表数据出错,请检查报表数据地址是否正确!")); } //确定导出数据类型及数据的ContentType GenerateInfo.Build(param.type, "png"); IGRBinaryObject ResultDataObject; if (GenerateInfo.IsGRD) { ResultDataObject = report.GenerateDocumentData(); } else { IGRExportOption ExportOption = report.PrepareExport(GenerateInfo.ExportType); if (GenerateInfo.ExportType == GRExportType.gretIMG) { IGRE2IMGOption E2IMGOption = ExportOption.AsE2IMGOption; E2IMGOption.ImageType = GenerateInfo.ImageType; E2IMGOption.AllInOne = true; //所有页产生在一个图像文件中 E2IMGOption.DPI = param.dpi; //指定导出图像的分辨率DPI E2IMGOption.DrawPageBox = false; //指定是否在导出的图像上绘制一个页边框 //E2IMGOption.VertGap = 20; //页之间设置20个像素的间距 } else if (GenerateInfo.ExportType == GRExportType.gretPDF) { IGRE2PDFOption E2PDFOption = ExportOption.AsE2PDFOption; E2PDFOption.AnsiTextMode = false; //指定是否将文本数据编码为ANSI字符方式 E2PDFOption.Compressed = false; //指定是否对 PDF 页面数据进行压缩 } ResultDataObject = report.ExportToBinaryObject(); report.UnprepareExport(); } object Data = ResultDataObject.SaveToVariant(); string DocumentData = Convert.ToBase64String((byte[])Data); return(request.Succes(DocumentData, "生成数据成功")); }
private ActionResult BuildVoucher(int claimId) { ActionResult result3; try { List<ReportParam> list = new List<ReportParam>(); ReportParam item = new ReportParam { Name = "vClaimList", Value = claimId.ToString() }; list.Add(item); string str = ConfigurationManager.AppSettings["report_PrintVoucher"]; if (string.IsNullOrEmpty(str)) { throw new Exception("report_PrintVoucher is empty"); } ReportResult result = ReportServer.BuildReport(str, ReportFormat.pdf, list.ToArray()); if (result == null) { throw new Exception("report data is empty"); } MemoryStream fileStream = new MemoryStream(result.Content); FileStreamResult result2 = new FileStreamResult(fileStream, "application/pdf") { FileDownloadName = string.Format("voucher_{0}.pdf", claimId) }; result3 = result2; } catch (Exception exception) { Tracing.ServiceTrace.TraceEvent(TraceEventType.Error, 0, exception.ToString()); throw; } return result3; }
public bool Update(ReportParam entity) { throw new NotImplementedException(); }
public List <ReportParam> QueryWhere(ReportParam model) { throw new NotImplementedException(); }
/// <summary> /// 重建报表结构 /// </summary> /// <param name="id"></param> /// <param name="SQL"></param> /// <param name="msg"></param> /// <returns></returns> public static Report RebuildReport(decimal id, decimal dbID, string SQL, out string msg) { Report report, reportdb; report = new Report(); report.Columns = new List <ReportColumn>(); report.Params = new List <ReportParam>(); report.SqlCommand = SQL; string tmpSql = Regex.Replace(SQL, REGEX_PARAMS_2, "NULL");//将所有参数设置为null,获取表结构 try { string tarConn; short dbType; if (DatabaseBLL.GetConnectionString(dbID, out tarConn, out dbType, out msg) != 1) { throw new Exception(msg); } using (IDAL dal = DALBuilder.CreateDAL(tarConn, dbType)) { //获取SQL语句中的Column DataSet ds = dal.Select(tmpSql.Replace('\r', ' ').Replace('\n', ' '));//替换掉回车、换行符 if (ds.Tables.Count != 1) { throw new Exception("错误:查询结果必须只有一个结果表"); } else { for (int i = 0; i < ds.Tables[0].Columns.Count; i++) { ReportColumn column = new ReportColumn() { ReportID = id, ColumnCode = ds.Tables[0].Columns[i].ColumnName, OrderIndex = i + 1 }; switch (ds.Tables[0].Columns[i].DataType.Name) { case "Int16": case "Int32": case "Int64": case "Decimal": case "Float": column.ColumnType = 1; break; case "String": column.ColumnType = 0; break; case "Datetime": column.ColumnType = 2; break; default: column.ColumnType = 0; break; } report.Columns.Add(column); } } } //获取SQL语句中的Param MatchCollection pms = Regex.Matches(SQL, REGEX_PARAMS); foreach (Match m in pms) { //获取SQL语句中的参数 report.Params.Add(new ReportParam() { ReportID = id, ParamCode = m.Value }); } if (id != 0) { //获取到数据库report report.ID = id; reportdb = GetReport(id); report.Enabled = reportdb.Enabled; //两个report进行比较 //比较params foreach (ReportParam rp in report.Params) { IEnumerable <ReportParam> dbrps = reportdb.Params.Where(p => p.ParamCode == rp.ParamCode); if (dbrps.Count() == 0) { continue; } ReportParam dbrp = dbrps.First(); rp.ParamInputType = dbrp.ParamInputType; rp.ParamItems = dbrp.ParamItems; rp.ParamName = dbrp.ParamName; rp.ParamType = dbrp.ParamType; } //比较columns foreach (ReportColumn rc in report.Columns) { IEnumerable <ReportColumn> dbclms = reportdb.Columns.Where(c => c.ColumnCode == rc.ColumnCode); if (dbclms.Count() == 0) { //数据库中原本不存在 continue; } ReportColumn dbclm = dbclms.First(); rc.ColumnName = dbclm.ColumnName; rc.Sortabled = report.CommandHasOrderby?false:dbclm.Sortabled;//如果含有OrderBy 则不允许排序 rc.Sumabled = dbclm.Sumabled; } } msg = "success"; return(report); } catch (Exception ex) { msg = ex.Message; return(null); } }
private ActionResult Processing_Bank(int claim, PaymentMode payment) { ActionResult result4; if (payment == null) { throw new ArgumentNullException("payment"); } PaymentBeforeProcessingResult result = BookingProvider.BeforePaymentProcessing(UrlLanguage.CurrentLanguage, payment.paymentparam); if (result == null) { throw new Exception("cannot get payment details"); } if (!result.success) { throw new Exception("payment details fail"); } try { List<ReportParam> list = new List<ReportParam>(); ReportParam item = new ReportParam { Name = "vClaimList", Value = claim.ToString() }; list.Add(item); string str = ConfigurationManager.AppSettings["report_PrintInvoice"]; if (string.IsNullOrEmpty(str)) { throw new Exception("report_PrintInvoice is empty"); } ReportResult result2 = ReportServer.BuildReport(str, ReportFormat.pdf, list.ToArray()); if (result2 == null) { throw new Exception("report data is empty"); } MemoryStream fileStream = new MemoryStream(result2.Content); FileStreamResult result3 = new FileStreamResult(fileStream, "application/pdf") { FileDownloadName = string.Format("invoice_{0}.pdf", claim) }; result4 = result3; } catch (Exception exception) { Tracing.ServiceTrace.TraceEvent(TraceEventType.Error, 0, exception.ToString()); throw; } return result4; }
public ReportHandParam(ReportParam reportParam, string stringValue) { ReportParam = reportParam; StringValue = stringValue; }
public void GenerateReport(ReportParam rp) { LocalReport lr = new LocalReport(); string path = Path.Combine(Server.MapPath("~/Report"), "mainreport.rdlc"); if (System.IO.File.Exists(path)) { lr.ReportPath = path; } EmployeeModelService objEmpModelService = new EmployeeModelService(); var cm = objEmpModelService.GetEmployeeInfo(rp.EmpListID); var data = cm.FirstOrDefault(x => x.Id == rp.EmpListID); var employeename = data == null ? "All" : data.Name; string filename = employeename + "_" + rp.StartDate.ToString("yyyyMMdd") + "_" + rp.EndDate.ToString("yyyyMMdd") + ".zip"; using (var compressedFileStream = new MemoryStream()) { //Create an archive and store the stream in memory. using (var zipArchive = new ZipArchive(compressedFileStream, ZipArchiveMode.Update, false)) { foreach (var user in cm.Select(x => new { id = x.Id, name = x.Name }).Distinct()) { //Create a zip entry for each attachment var zipEntry = zipArchive.CreateEntry(user.name + ".pdf"); var dataset = cm.Where(x => x.Id == user.id).ToList(); ReportDataSource rd = new ReportDataSource("DataSet1", dataset); lr.SetParameters(new ReportParameter("startdate", rp.StartDate.ToString())); lr.SetParameters(new ReportParameter("enddate", rp.EndDate.ToString())); lr.DataSources.Clear(); lr.DataSources.Add(rd); lr.SubreportProcessing += new SubreportProcessingEventHandler(Lr_SubreportProcessing);; string reportType = "PDF"; string mimeType; string encoding; string fileNameExtension; Warning[] warning; string[] streams; byte[] renderedBytes; renderedBytes = lr.Render( reportType, null, out mimeType, out encoding, out fileNameExtension, out streams, out warning); //Get the stream of the attachment using (var originalFileStream = new MemoryStream(renderedBytes)) { using (var zipEntryStream = zipEntry.Open()) { //Copy the attachment stream to the zip entry stream originalFileStream.CopyTo(zipEntryStream); } } } } sendOutZIP(compressedFileStream.ToArray(), filename); } }
/// <summary> /// 在服务器上存储报表文件 /// </summary> /// <param name="context"></param> /// <param name="reportInfo"> 报表记录信息 </param> /// <param name="param">报表参数</param> /// <returns></returns> protected bool AddNewFileToServer(HttpContext context, ReportInfo reportInfo, ReportParam param) { HttpFileCollection files = HttpContext.Current.Request.Files; try { var fileFullName = GetFileFullName(param); var flag = CreateMultiDirectory(fileRootPath); if (flag) { files[0].SaveAs(fileFullName); } } catch (Exception e) { throw e; } return(AddNewFileToDb(context, reportInfo)); }