葡萄城报表AR13升级到ar16版本

根据橙子君的文章和activereports 教程修改如下

  首先去掉licenses.licx文件,新建或打开报表文件时,会自动生成这个新文件。

  

然后删掉webservice1.asmx引用,这个用不上了。

    

  

  

   2.第二部是下载WebSamples16工程,地址GitHub - activereports/WebSamples16: Samples for ActiveReports Web Components

3.通过nuget引入需要的库,这个不变

   Microsoft.Owin.Host.SystemWeb

   Gcef.Data.DataEngine

   GrapeCity.ActiveReports.Aspnet.Viewer  根据电脑安装的版本选择

4.接下来从下来的实例工程中复制几个我们需要的文件,也可以将ClientApp文件夹复制过来,生成项目的时候自动下载。

找到这个工程,放在我们原来删除的地方就好了。

这两个文件,复制到力软框架下。

需要依赖的东西都准备好了。

5.添加启动类

代码为

 
  1. using GrapeCity.ActiveReports;
  2. using GrapeCity.ActiveReports.Aspnet.Viewer;
  3. using GrapeCity.ActiveReports.PageReportModel;
  4. using GrapeCity.ActiveReports.Rendering;
  5. using Learun.Application.TwoDevelopment.LR_CodeDemo;
  6. using Microsoft.Owin;
  7. using Owin;
  8. using System.Collections.Generic;
  9. using System.Data;
  10. using System.IO;
  11. using System.Reflection;
  12. [assembly: OwinStartup(typeof(Learun.Application.Web.Startup1))]
  13. namespace Learun.Application.Web
  14. {
  15. public class Startup1
  16. {
  17. public static string EmbeddedReportsPrefix = "Learun.Application.Web";
  18. public void Configuration(IAppBuilder app)
  19. {
  20. app.UseReporting(settings =>
  21. {
  22. settings.UseCompression = true;
  23. settings.UseCustomStore(GetReport);//使用UseCustomStore来自定义一些需要的值
  24. //settings.UseFileStore(new DirectoryInfo(String.Format(@"{0}.\Reports\", HttpRuntime.AppDomainAppPath)));
  25. settings.LocateDataSource = GetData;
  26. });
  27. }
  28. public object GetReport(string P)//获取报表名称和报表参数,进行一个对应的报表名称和参数的分割
  29. {
  30. var plist = P.Split('|');
  31. string reportName = plist[0];//报表名称;
  32. PageReport rep = new PageReport();
  33. string path = Assembly.GetExecutingAssembly().CodeBase.Replace("bin/Learun.Application.Web.DLL", "Reports/").Replace("file:///", "");
  34. //string path = System.Web.Hosting.HostingEnvironment.MapPath("~/");
  35. rep.Load(new FileInfo(path + reportName));
  36. int num = 0;
  37. foreach (var item in plist)
  38. {
  39. if (num > 0)
  40. {
  41. AddReportPara("param" + num, item, rep);
  42. }
  43. num++;
  44. }
  45. return rep.Report;
  46. }
  47. /// <summary>
  48. /// 报表参数添加
  49. /// </summary>
  50. /// <param name="name">参数名</param>
  51. /// <param name="value">参数值</param>
  52. /// <param name="rp">报表体</param>
  53. private void AddReportPara(string name, string value, PageReport rep)
  54. {
  55. //如果没有值,报表不会自动运行,所以不能加
  56. if (string.IsNullOrEmpty(value.Trim()))
  57. {
  58. return;
  59. }
  60. Dictionary<string, string> dicParas = new Dictionary<string, string>();
  61. foreach (var item in rep.Report.ReportParameters)
  62. {
  63. if (!dicParas.ContainsKey(item.Name))
  64. {
  65. dicParas.Add(item.Name, item.DefaultValue.Values[0].Expression);
  66. }
  67. }
  68. if (!dicParas.ContainsKey(name))
  69. {
  70. ReportParameter para = new ReportParameter();
  71. para.Name = name;
  72. para.Prompt = name;
  73. para.UsedInQuery = ReportParameterUsedInQuery.True;
  74. para.DataType = ReportParameterDataType.String;
  75. para.DefaultValue.Values.Add(value.Trim());
  76. rep.Report.ReportParameters.Add(para);
  77. }
  78. }
  79. /// <summary>
  80. /// 自定义数据源
  81. /// </summary>
  82. /// <param name="args">报表数据参数</param>
  83. /// <returns></returns>
  84. public object GetData(LocateDataSourceArgs args)
  85. {
  86. Dictionary<string, string> dcFilter = new Dictionary<string, string>();
  87. DataTable dtData = new DataTable();
  88. string name = args.Report.Name.ToString();
  89. string dataSource = args.DataSet.Query.DataSourceName;
  90. string dataSet = args.DataSet.Name;
  91. switch (name)
  92. {
  93. case "制程工单.rdlx":
  94. if (args.Report.ReportParameters.Count > 0) {
  95. var id = args.Report.ReportParameters[0].DefaultValue.Values[0].Expression;
  96. WorkOrderIBLL workOrderIBLL = new WorkOrderBLL();
  97. dtData = workOrderIBLL.GetPrintItem(id);
  98. }
  99. break;
  100. }
  101. return dtData;
  102. }
  103. }
  104. }

 

  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta name=”renderer” content=”webkit|ie-comp|ie-stand” />
  5. <meta name="viewport" content="width=device-width, initial-scale=1" />
  6. <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  7. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  8. <meta name="renderer" content="webkit">
  9. <link rel="icon" href="~/favicon.ico">
  10. <title>@ViewBag.Title|力软信息|快速开发平台|Learun敏捷开发框架</title>
  11. <link href="~/Content/font/css/font-awesome.min.css" rel="stylesheet" />
  12. <link href="~/Content/bootstrap/bootstrap.min.css" rel="stylesheet" />
  13. <script src="~/Content/jquery/jquery-1.10.2.min.js"></script>
  14. <script src="~/Content/fonts/bootstrap-3.0.0.js"></script>
  15. @*<link href="~/Content/fontGity/css/materialdesignicons.min.css" rel="stylesheet" />*@
  16. <link href="~/Content/GrapeCity/jsViewer.min.css" rel="stylesheet" />
  17. <script src="~/Content/GrapeCity/jsViewer.min.js"></script>
  18. <script>
  19. function request(d) { for (var c = location.search.slice(1).split("&"), a = 0; a < c.length; a++) { var b = c[a].split("="); if (b[0] == d) if ("undefined" == unescape(b[1])) break; else return unescape(b[1]) } return "" };
  20. </script>
  21. <style>
  22. div.page {
  23. margin: auto;
  24. }
  25. #singleView {
  26. position: relative !important;
  27. }
  28. /*.btn-toolbar .btn-group {
  29. clear:left;
  30. display:inline-block;
  31. }
  32. .ar-viewer .toolbar {
  33. display: flex;
  34. justify-content: flex-end;
  35. flex-direction: row;
  36. text-align:right;
  37. }*/
  38. </style>
  39. </head>
  40. <body class="@Learun.Util.Net.Browser @Learun.Util.WebHelper.GetUITheme()">
  41. @RenderBody()
  42. </body>
  43. </html>

  

  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta name=”renderer” content=”webkit|ie-comp|ie-stand” />
  5. <meta name="viewport" content="width=device-width, initial-scale=1" />
  6. <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  7. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  8. <meta name="renderer" content="webkit">
  9. <link rel="icon" href="~/favicon.ico">
  10. <title>@ViewBag.Title|力软信息|快速开发平台|Learun敏捷开发框架</title>
  11. <meta name=”renderer” content=”webkit|ie-comp|ie-stand” />
  12. <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  13. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  14. <meta name="viewport" content="width=device-width, initial-scale=1" />
  15. <link rel="icon" href="~/favicon.ico">
  16. <link href="~/Content/font/css/font-awesome.min.css" rel="stylesheet" />
  17. <link href="~/Content/bootstrap/bootstrap.min.css" rel="stylesheet" />
  18. <script src="~/Content/jquery/jquery-1.10.2.min.js"></script>
  19. <script src="~/Content/fonts/bootstrap-3.0.0.js"></script>
  20. @*<link href="~/Content/fontGity/css/materialdesignicons.min.css" rel="stylesheet" />*@
  21. <link href="~/Content/GrapeCity/jsViewer.min.css" rel="stylesheet" />
  22. <script src="~/Content/GrapeCity/jsViewer.min.js"></script>
  23. <script>
  24. function request(d) { for (var c = location.search.slice(1).split("&"), a = 0; a < c.length; a++) { var b = c[a].split("="); if (b[0] == d) if ("undefined" == unescape(b[1])) break; else return unescape(b[1]) } return "" };
  25. </script>
  26. @Html.AppendCssFile(
  27. "/Views/LR_Content/style/lr-common.css",
  28. "/Views/LR_Content/plugin/scroll/scroll.css",
  29. "/Views/LR_Content/style/lr-iframe-index.css",
  30. "/Views/LR_Content/plugin/layout/lr-layout.css",
  31. "/Views/LR_Content/plugin/tree/lr-tree.css",
  32. "/Views/LR_Content/plugin/select/lr-select.css",
  33. "/Views/LR_Content/plugin/timeline/lr-timeline.css",
  34. "/Views/LR_Content/plugin/formselect/lr-formselect.css",
  35. "/Views/LR_Content/plugin/custmerquery/lr-custmerquery.css",
  36. "/Views/LR_Content/plugin/date/lr-datepicker.css",
  37. "/Views/LR_Content/plugin/grid/jfgrid.css")
  38. <script src="~/Content/laydate/laydate.js"></script>
  39. @Html.SetCurrentUrl()
  40. </head>
  41. <body class="@Learun.Util.Net.Browser @Learun.Util.WebHelper.GetUITheme()">
  42. @RenderBody()
  43. @Html.AppendJsFile(
  44. "/Views/LR_Content/plugin/resize/resize.js",
  45. "/Views/LR_Content/plugin/mousewheel/mousewheel.js",
  46. "/Views/LR_Content/plugin/scroll/scroll.js",
  47. "/Views/LR_Content/plugin/layout/lr-layout.js",
  48. "/Views/LR_Content/plugin/tree/lr-tree.js",
  49. "/Views/LR_Content/plugin/select/lr-select.js",
  50. "/Views/LR_Content/plugin/timeline/lr-timeline.js",
  51. "/Views/LR_Content/plugin/formselect/lr-formselect.js",
  52. "/Views/LR_Content/plugin/custmerquery/lr-custmerquery.js",
  53. "/Views/LR_Content/plugin/date/lr-datepicker.js",
  54. "/Views/LR_Content/script/lr-validator.js",
  55. "/Views/LR_Content/script/lr-authorize.js",
  56. "/Views/LR_Content/script/lr-excel.js",
  57. "/Views/LR_Content/script/lr-form.js",
  58. "/Views/LR_Content/plugin/grid/jfgrid.js"
  59. )
  60. <script>
  61. $(function () {
  62. $('#lr_layout').lrLayout();
  63. // 翻译指定标签
  64. $('.lrlg').each(function () {
  65. var $this = $(this);
  66. top.learun.language.get($this.text(), function (text) {
  67. $this.text(text);
  68. });
  69. });
  70. // 翻译表单标题
  71. $('.lr-form-item-title').each(function () {
  72. var $this = $(this);
  73. var $font = $this.find('font');
  74. $font.remove();
  75. top.learun.language.get($this.text(), function (text) {
  76. if ($font.length > 0) {
  77. $this.html(text + '<font face="宋体">*</font>');
  78. }
  79. else {
  80. $this.text(text);
  81. }
  82. });
  83. });
  84. // input placeholder 翻译
  85. $('input[placeholder]').each(function () {
  86. var $this = $(this);
  87. var _text = $this.attr('placeholder');
  88. top.learun.language.get(_text, function (text) {
  89. $this.attr('placeholder', text);
  90. });
  91. });
  92. top.learun.httpAsync('GET', top.$.rootUrl + '/LR_SystemModule/Module/GetAuthorizeButtonColumnList', { url: lrCurrentUrl }, function (data) {
  93. lrModuleButtonList = data.btns;
  94. lrModuleColumnList = data.cols;
  95. lrModule = data.module;
  96. window.lrModuleForms = data.forms;
  97. if (!!window.bootstrap) {
  98. bootstrap(jQuery, top.learun);
  99. }
  100. });
  101. });
  102. </script>
  103. </body>
  104. </html>

  

 
  1. /* * 版 本 Learun-ADMS V7.0.3 力软敏捷开发框架(http://www.learun.cn)
  2. * Copyright (c) 2013-2018 上海力软信息技术有限公司
  3. * 创建人:超级管理员
  4. * 日 期:2019-03-14 15:17
  5. * 描 述:报表文件管理
  6. */
  7. var refreshGirdData;
  8. var fileId;
  9. var keyValue;
  10. var bootstrap = function ($, learun) {
  11. "use strict";
  12. var viewer
  13. var page = {
  14. init: function () {
  15. //page.initGird();
  16. page.bind();
  17. },
  18. bind: function () {
  19. // 初始化左侧树形数据
  20. $('#dataTree').lrtree({
  21. url: top.$.rootUrl + '/LR_ReportModule/RptManage/GetDetailTree',
  22. nodeClick: function (item) {
  23. //type = item.value;
  24. $('#titleinfo').text(item.text);
  25. if (item.id.length > 20) {
  26. fileId = item.value;
  27. keyValue = item.id;
  28. page.show(item.value);
  29. }
  30. }
  31. });
  32. //$('#multiple_condition_query').lrMultipleQuery(function (queryJson) {
  33. // page.search(queryJson);
  34. //}, 180, 400);
  35. $('#F_Type').lrDataItemSelect({ code: 'ReportSort' });
  36. // 刷新
  37. $('#lr_refresh').on('click', function () {
  38. location.reload();
  39. });
  40. // 新增
  41. $('#lr_add').on('click', function () {
  42. learun.layerForm({
  43. id: 'form',
  44. title: '新增',
  45. url: top.$.rootUrl + '/LR_ReportModule/RptManage/Form',
  46. width: 600,
  47. height: 400,
  48. callBack: function (id) {
  49. return top[id].acceptClick(page.init());
  50. }
  51. });
  52. });
  53. // 编辑
  54. $('#lr_edit').on('click', function () {
  55. //var keyValue = $('#gridtable').jfGridValue('F_Id');
  56. if (learun.checkrow(keyValue)) {
  57. learun.layerForm({
  58. id: 'form',
  59. title: '编辑',
  60. url: top.$.rootUrl + '/LR_ReportModule/RptManage/Form?keyValue=' + keyValue,
  61. width: 600,
  62. height: 400,
  63. callBack: function (id) {
  64. return top[id].acceptClick(page.init());
  65. }
  66. });
  67. }
  68. });
  69. // 删除
  70. $('#lr_delete').on('click', function () {
  71. //var keyValue = $('#gridtable').jfGridValue('F_Id');
  72. if (learun.checkrow(keyValue)) {
  73. learun.layerConfirm('是否确认删除该项!', function (res) {
  74. if (res) {
  75. learun.deleteForm(top.$.rootUrl + '/LR_ReportModule/RptManage/DeleteForm', { keyValue: keyValue }, function () {
  76. page.init();
  77. });
  78. }
  79. });
  80. }
  81. });
  82. // 打印
  83. $('#lr_print').on('click', function () {
  84. //var reportId = $('#gridtable').jfGridValue('F_File');
  85. learun.frameTab.open({ F_ModuleId: 'report', F_Icon: 'fa magic', F_FullName: fileId, F_UrlAddress: '/LR_ReportModule/RptManage/Report?reportId=' + encodeURI(encodeURI(fileId)) });
  86. //learun.layerForm({
  87. // id: 'form',
  88. // title: '预览',
  89. // url: top.$.rootUrl + '/LR_ReportModule/RptManage/Report?reportId=' + encodeURI(encodeURI(reportId)),
  90. // width: 1024,
  91. // height: 768,
  92. // callBack: function (id) {
  93. // // return top[id].acceptClick(refreshGirdData);
  94. // }
  95. //});
  96. });
  97. viewer = GrapeCity.ActiveReports.JSViewer.create({
  98. element: '#viewerContainer',
  99. availableExports: ['Xml', 'Pdf', 'Excel'],
  100. reportService: {
  101. url: top.$.rootUrl + '/api/reporting'
  102. }
  103. });
  104. },
  105. show: function (reportId) {
  106. viewer.openReport(reportId);
  107. },
  108. // 初始化列表
  109. initGird: function () {
  110. $('#gridtable').lrAuthorizeJfGrid({
  111. url: top.$.rootUrl + '/LR_ReportModule/RptManage/GetPageList',
  112. headData: [
  113. { label: "报表编码", name: "F_Code", width: 100, align: "left" },
  114. { label: "报表名称", name: "F_Name", width: 100, align: "left" },
  115. {
  116. label: "报表类型", name: "F_Type", width: 100, align: "left",
  117. formatterAsync: function (callback, value, row, op, $cell) {
  118. learun.clientdata.getAsync('dataItem', {
  119. key: value,
  120. code: 'ReportSort',
  121. callback: function (_data) {
  122. callback(_data.text);
  123. }
  124. });
  125. }
  126. },
  127. { label: "排序", name: "F_SortCode", width: 100, align: "left" },
  128. { label: "报表文件", name: "F_File", width: 100, align: "left" },
  129. { label: "备注", name: "F_Description", width: 100, align: "left" },
  130. ],
  131. mainId: 'F_Id',
  132. isPage: true
  133. });
  134. page.search();
  135. },
  136. search: function (param) {
  137. param = param || {};
  138. $('#gridtable').jfGridSet('reload', { queryJson: JSON.stringify(param) });
  139. }
  140. };
  141. refreshGirdData = function () {
  142. $('#gridtable').jfGridSet('reload');
  143. };
  144. page.init();
  145. }

 

 
  1. /* * 版 本 Learun-ADMS V7.0.3 力软敏捷开发框架(http://www.learun.cn)
  2. * Copyright (c) 2013-2018 上海力软信息技术有限公司
  3. * 创建人:超级管理员
  4. * 日 期:2019-03-14 15:17
  5. * 描 述:报表文件管理
  6. */
  7. $(function () {
  8. var reportId = request('reportId');
  9. //var isPrint = request('isPrint');
  10. reportId = decodeURI(reportId);
  11. var viewer = GrapeCity.ActiveReports.JSViewer.create({
  12. element: '#viewerContainer',
  13. reportID: reportId,
  14. availableExports: ['Xml', 'Pdf', 'Excel'],
  15. reportService: {
  16. url: top.$.rootUrl + '/api/reporting'
  17. },
  18. //documentLoaded: function () {
  19. // if (isPrint == '1') {
  20. // setTimeout(function () {
  21. // viewer.print();
  22. // }, 100);
  23. // }
  24. //}
  25. });
  26. });

  橙子君的原文需要手动删除的配置选项,现更换为activereports的升级工具自动删除,引用也不用删除,在安装GrapeCity.ActiveReports.Aspnet.Viewer,会自动安装更新引用,并自动安装依赖,ActiveReports.ReportService.asmx文件也不需要手工删除,升级工具会自动删除。

另外报表文件也会自动更新。

 大部分是作者原图,我没有这个框架,不能截图,哪位有?让我有机会验证一下。

原文在此力软敏捷框架7.0.6 葡萄城报表升级到ar14版本 (bbsmax.com)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

农户的空间

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值