/// <summary> /// 预览报表列表 /// </summary> /// <param name="enumStr"></param> /// <returns></returns> public async Task <(IEnumerable <dynamic> CurrentPage, int?Total)> PreviewResultListAsync(PreviewResultInSqlStrRequest request, ReportThemeModel themeModel, List <ReportConditionModel> conditionList, List <ReportConditionModel> columnList) { var sqlStr = themeModel.SQLStr; string sqlTotalNum = $"SELECT count(1) FROM ({sqlStr}) __t limit 1"; sqlStr = $@"{sqlStr} limit {(request.PageIndex - 1) * request.PageSize},{request.PageSize}"; var parameters = new DynamicParameters(); foreach (var item in request.PreviewConditionInfoList) { parameters.Add(item.FieldCodeValueString.Replace("@", ""), item.FieldValue); } var stopwatch = new Stopwatch(); using (var conn = MySqlHelper.CreateConnection(mysqlReportConn)) { stopwatch.Start(); var currentPage = await conn.QueryAsync <dynamic>(sqlStr, parameters); var total = await conn.QueryFirstOrDefaultAsync <int?>(sqlTotalNum, parameters); stopwatch.Stop(); if (stopwatch.ElapsedMilliseconds / 1000 > 50) { Logger.Info($"报表SQL执行耗时:{stopwatch.ElapsedMilliseconds / 1000 } 秒"); } return(currentPage, total); } }
static void Main(string[] args) { MySqlHelper.CreateConnection(); MySqlTransaction tx = conn.BeginTransaction(); try { MySqlHelper.ExecuteNonQuery(conn, "Update t_accounts Set Amount=Amount-1000 where Number='0001'"); string s = null; s.ToLower(); MySqlHelper.ExecuteNonQuery(conn, "Update t_accounts Set Amount=Amount+1000 where Number='0002'"); tx.Commit(); } catch (Exception ex) { tx.Rollback(); } }