Skip to content

Commit

Permalink
添加sql 执行的前缀语句和后缀语句功能
Browse files Browse the repository at this point in the history
  • Loading branch information
NoneDay committed May 15, 2024
1 parent c3e97c9 commit 80ac18b
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 39 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ server=ip地址;port=5432;uid=用户;pwd=口令;database=数据库;Pooling=true;
达梦 连接串 格式
Server=ip地址:端口; UserId=用户; PWD=口令;
高斯数据库,使用 pgsql 驱动,一定要带`No Reset On Close=true;` :
PORT=端口;searchpath=schema名称1,schema名称2;DATABASE=db_test;HOST=ip地址;PASSWORD=口令;USER ID=用户;No Reset On Close=true;
OceanBase (oracle模式)连接串 odbc格式示例:
Driver=Server=ip地址;Port=端口;Database=XIR_TRD;User=XIR_TRD@Xpia2C6G#obtest:1650773680;Password=口令;Option=3;
```

配置完毕后,按F5 刷新页面,点报表目录,正常的话,这是应该能看到所有的测试报表了
Expand Down
Binary file modified end/CellReport.dll
Binary file not shown.
6 changes: 3 additions & 3 deletions end/reportWeb/Controllers/DesignController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public async Task<IActionResult> Preview(String _content, String _ConnectionId,

foreach (var one in this.rpt_group.db_connection_list)
{
report_env.addDataSource(one.name, one.conn_str, one.db_type, "0");
report_env.addDataSource(one.name, one.conn_str, one.db_type, "0", one.sql_prefix, one.sql_suffix);
}
ParamDefineDataSet pds = report_env.getParamDefineDataSet();
foreach (var row in pds.Rows)
Expand Down Expand Up @@ -278,7 +278,7 @@ public async Task<IActionResult> Preview(String _content, String _ConnectionId,
}
await my_out_act();
}
report_env.logger.Debug($"输出用时{(DateTime.Now.Ticks - start) / 10000000.0}秒");
report_env.logger.Debug($"总用时{(DateTime.Now.Ticks - start) / 10000000.0}秒");
//if (String.IsNullOrEmpty(fresh_ds))
//{
//}
Expand Down Expand Up @@ -376,7 +376,7 @@ public async Task<IActionResult> exec_expr(String expr, String report_content)
report_env.logger = logger;
foreach (var one in this.rpt_group.db_connection_list)
{
report_env.addDataSource(one.name, one.conn_str, one.db_type, "0");
report_env.addDataSource(one.name, one.conn_str, one.db_type, "0", one.sql_prefix, one.sql_suffix);
}

var exec_result = exprFaced.calculate("{ " + expr + "\n}", cur_GroupMap, "当前脚本");
Expand Down
2 changes: 1 addition & 1 deletion end/reportWeb/Pages/ReportModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public async Task Page_Load()

foreach (var one in this.rpt_group.db_connection_list)
{
report_env.addDataSource(one.name, one.conn_str, one.db_type, "0");
report_env.addDataSource(one.name, one.conn_str, one.db_type, "0", one.sql_prefix, one.sql_suffix);
}
var exprFaced = report_env.getExprFaced();
exprFaced.addVariable("isPhone", isPhone);
Expand Down
8 changes: 7 additions & 1 deletion end/reportWeb/ReportDb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,11 @@ CREATE INDEX IF NOT EXISTS IX_Rpt_db_connection_grp_id ON Rpt_db_connection (
{
db.Statement("alter table Rpt_db_connection add column sql_prefix text");
};

if (0 == db.Select(" SELECT * FROM pragma_table_info('Rpt_db_connection') where name='sql_suffix'").Count())
{
db.Statement("alter table Rpt_db_connection add column sql_suffix text");
};

var rpt_config = db.Query("Rpt_config").First<Rpt_config>();
CellReport.util.KeyAndPassword.yan_zheng_zcm(rpt_config.zcm);

Expand Down Expand Up @@ -274,6 +278,8 @@ public class Rpt_db_connection
public string conn_str { get; set; }
public string test_conn_str { get; set; }
public string sql_prefix { get; set; }
public string sql_suffix { get; set; }

}
public class Rpt_config
{
Expand Down
9 changes: 1 addition & 8 deletions end/reportWeb/reportWeb.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,9 @@
<PackageReference Include="Microsoft.Data.SqlClient" Version="3.0.1" />
<PackageReference Include="Microsoft.Data.Sqlite" Version="6.0.7" />
<PackageReference Include="Microsoft.Data.Sqlite.Core" Version="6.0.7" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="6.0.7" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.IO.RecyclableMemoryStream" Version="2.3.2" />
<PackageReference Include="MySqlConnector" Version="2.3.5" />
<PackageReference Include="Npgsql" Version="6.0.0">
<TreatAsUsed>true</TreatAsUsed>
</PackageReference>
<PackageReference Include="Npgsql" Version="6.0.11" />
<PackageReference Include="Oracle.ManagedDataAccess.Core" Version="3.21.100" />
<PackageReference Include="Serilog.AspNetCore" Version="4.1.0" />
<PackageReference Include="Serilog.Expressions" Version="3.2.1">
Expand Down
26 changes: 1 addition & 25 deletions end/reportWeb/template.xml
Original file line number Diff line number Diff line change
Expand Up @@ -620,29 +620,5 @@ function 字典_${para.table}(){
}
]]>
</template_script>
<type_var_def>
Array,System.Array,
Math, System.Math,
Convert, System.Convert,
String, System.String,
DateTime, System.DateTime,
Date, System.DateOnly,
TimeSpan,System.TimeSpan,
DateTimeOffset, System.DateTimeOffset,
DateTimeKind, System.DateTimeKind,
Double, System.Double,
Decimal, System.Decimal,
Bool, System.Boolean,
Int, System.Int32,
Int64, System.Int64,
DynObject,System.Dynamic.ExpandoObject,
Guid,System.Guid,
Uri,System.Uri,
Exception,System.Exception,
Task,System.Threading.Tasks.Task,
RandomNumber,System.Security.Cryptography.RandomNumberGenerator,
Direction,CellReport.cell.Direction
CellProperty,CellReport.cell.Property
CellRange,CellReport.cell.CellRange
</type_var_def>

</template>
3 changes: 2 additions & 1 deletion front/src/views/rpt_design/manger.vue
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,8 @@ export default {
{type: 'input',label: '名称',span: 12,display: true,prop: 'name'},
{type: 'select',label: '类型',span: 12,display: true,prop: 'db_type',dicData:this.db_type_dict },
{type: 'input',label: '连接串',span: 24, cell: true,display: true,prop: 'conn_str'},
{type: 'textarea',label: 'sql前缀语句',span: 24, cell: true,display: true,prop: 'sql_prefix'}
{type: 'textarea',label: 'sql前缀语句(非select)',span: 24, cell: true,display: true,prop: 'sql_prefix'},
{type: 'textarea',label: 'sql后缀语句(非select)',span: 24, cell: true,display: true,prop: 'sql_suffix'}
]
}}
},
Expand Down

0 comments on commit 80ac18b

Please sign in to comment.