| | |
| | | { |
| | | private readonly IHttpContextAccessor _http; |
| | | private readonly string _userCode, _userGuid, _orgFids; |
| | | |
| | | private readonly string _customTag = "客户模板"; |
| | | public ReportController(IHttpContextAccessor httpContextAccessor) |
| | | { |
| | | _http = httpContextAccessor; |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 根据报表参数读取报表名字 |
| | | /// 根据报表参数读取报表名字(对应的存储过程) |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | private string _rptGetParameterName(string str) |
| | |
| | | m.zb = new List<dynamic>(); |
| | | m.mx1 = new List<dynamic>(); |
| | | m.mx2 = new List<dynamic>(); |
| | | var sbSql = new StringBuilder(); |
| | | var _blDate = false; |
| | | try |
| | | { |
| | |
| | | if (_blDate == false) |
| | | return ReturnDto<dynamic>.QuickReturn(m, ReturnCode.Default, |
| | | "读取失败,没有初始化模板!"); |
| | | //读数据 |
| | | //如果是设计模式,退出 |
| | | if (isDesign == 1) |
| | | { |
| | | return ReturnDto<dynamic>.QuickReturn(m, ReturnCode.Success, "读取成功!"); |
| | | } |
| | | //读需要打印的数据,用来填充模板 |
| | | if (_rptParameter.StartsWith(_customTag)) |
| | | rptParameterName = "rpt_hgm"; |
| | | var dset = new DataSet(); |
| | | using (var conn = new SqlConnection(DbHelperSQL.strConn)) |
| | | { |
| | |
| | | } |
| | | } |
| | | conn.Close(); |
| | | } |
| | | if (isDesign == 1) |
| | | { |
| | | return ReturnDto<dynamic>.QuickReturn(m, ReturnCode.Success, "读取成功!"); |
| | | } |
| | | //0是状态,1是主表,2是明细表,3是明细表 |
| | | if (dset.Tables[0].Rows[0]["msgState"].ToString() == "-1") |
| | |
| | | return ReturnDto<dynamic>.QuickReturn(m, ReturnCode.Success, "操作成功!"); |
| | | } |
| | | |
| | | |
| | | #region MyRegion |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | |
| | | [RequestMethod(RequestMethods.POST)] |
| | | public ReturnDto<List<dynamic>> GetTemplateList([FromBody] dynamic model) |
| | | { |
| | | string keyType = model.keyType; |
| | | |
| | | List<dynamic> lst = new List<dynamic>(); |
| | | System.Text.StringBuilder sbSql = new StringBuilder(); |
| | | sbSql.Append("select [GUID],[REPORT_TYPE],[REPORT_NAME] from [dbo].[SYS_REPORT_TEMPLATE] order by [REPORT_NAME] asc"); |
| | | if (keyType == "客户模板") |
| | | { |
| | | sbSql.Append("select [GUID],[REPORT_TYPE],[REPORT_NAME] from [dbo].[SYS_REPORT_TEMPLATE] where REPORT_TYPE like '" + _customTag + "%' "); |
| | | sbSql.Append(" union all select [GUID],[REPORT_TYPE],[REPORT_NAME] from [dbo].[SYS_REPORT_TEMPLATE] where REPORT_TYPE='rpt_hgm' order by REPORT_TYPE asc"); |
| | | } |
| | | else |
| | | sbSql.Append("select [GUID],[REPORT_TYPE],[REPORT_NAME] from [dbo].[SYS_REPORT_TEMPLATE] order by [REPORT_TYPE] desc"); |
| | | var dset = new DataSet(); |
| | | try |
| | | { |
| | |
| | | return ReturnDto<List<dynamic>>.QuickReturn(lst, ReturnCode.Success, |
| | | "读取成功!"); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 加入 |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | [RequestMethod(RequestMethods.POST)] |
| | | public ReturnDto<int?> AddModel([FromBody] dynamic model) |
| | | { |
| | | string reportName = model.reportName; |
| | | string reportType = _customTag + DateTime.Now.ToString("MMddHHmmff"); |
| | | int rtnInt = (int)ReturnCode.Default; |
| | | using (var conn = new SqlConnection(DbHelperSQL.strConn)) |
| | | { |
| | | using (var cmd = new SqlCommand("[prc_report_edt]", conn)) |
| | | { |
| | | try |
| | | { |
| | | conn.Open(); |
| | | cmd.CommandType = CommandType.StoredProcedure; |
| | | SqlParameter[] parameters = |
| | | { |
| | | new("@outGuid", SqlDbType.NVarChar, 100), |
| | | new("@outMsg", SqlDbType.NVarChar, 300), |
| | | new("@edtUserGuid", _userGuid), |
| | | //new("@rptData", rptData), |
| | | new("@rptType", reportType), |
| | | new("@reportName", reportName) |
| | | }; |
| | | parameters[0].Direction = ParameterDirection.Output; |
| | | parameters[1].Direction = ParameterDirection.Output; |
| | | foreach (var parameter in parameters) |
| | | cmd.Parameters.Add(parameter); |
| | | rtnInt = cmd.ExecuteNonQuery(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | LogHelper.Debug(ToString(), |
| | | "AddModel error:" + ex.Message); |
| | | } |
| | | finally |
| | | { |
| | | conn.Close(); |
| | | } |
| | | } |
| | | } |
| | | if (rtnInt > 0) |
| | | return ReturnDto<int>.QuickReturn(default(int?), ReturnCode.Success, "操作成功!"); |
| | | else |
| | | return ReturnDto<int>.QuickReturn(default(int?), ReturnCode.Exception, "操作失败,请重试!"); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 移出 |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | [RequestMethod(RequestMethods.POST)] |
| | | public ReturnDto<int?> DeleteModel([FromBody] dynamic model) |
| | | { |
| | | string guid = model.guid; |
| | | int rtnInt = (int)ReturnCode.Default; |
| | | if (guid.ToUpper() == "AF1105F3-1CFA-4E48-BE07-6EC3A184918C".ToUpper()) |
| | | { |
| | | return ReturnDto<int>.QuickReturn(default(int?), ReturnCode.Exception, "操作失败,默认模版,不能删除!"); |
| | | } |
| | | try |
| | | { |
| | | StringBuilder strSql = new StringBuilder(); |
| | | strSql.Append(" delete from SYS_REPORT_TEMPLATE "); |
| | | strSql.Append(" where guid='" + guid + "'"); |
| | | rtnInt = DbHelperSQL.ExecuteSql(strSql.ToString()); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | LogHelper.Debug(this.ToString(), "DeleteModel error:" + ex.Message); |
| | | rtnInt = (int)ReturnCode.Exception; |
| | | return ReturnDto<int>.QuickReturn(default(int?), ReturnCode.Exception, "操作失败," + ex.Message); |
| | | } |
| | | if (rtnInt > 0) |
| | | return ReturnDto<int>.QuickReturn(default(int?), ReturnCode.Success, "操作成功!"); |
| | | else |
| | | return ReturnDto<int>.QuickReturn(default(int?), ReturnCode.Exception, "操作失败,请重试!"); |
| | | } |
| | | #endregion |
| | | |
| | | } |