Пример #1
0
        public async Task <PagedResultDto <ReportParameterOutputDto> > GetReportParameters()
        {
            var entities = await _ReportParameterManager.GetAllReportParametersAsync();

            var listDto = entities.MapTo <List <ReportParameterOutputDto> >();

            return(new PagedResultDto <ReportParameterOutputDto>(
                       listDto.Count,
                       listDto
                       ));
        }
Пример #2
0
        public async Task <List <DataSet> > GetDataSource(long template_Id, Dictionary <string, string> dicParameters)
        {
            var entityParameters = await _ReportParameterManager.GetAllReportParametersAsync();

            var parameters = entityParameters.Where(d => d.Template_Id == template_Id).OrderBy(d => d.Id);

            var entityDataSources = await _ReportDataSourceManager.GetAllReportDataSourcesAsync();

            var dataSources = entityDataSources.Where(d => d.Template_Id == template_Id).OrderBy(d => d.Id);

            List <DataSet> listDs = new List <DataSet>();

            foreach (var dataSource in dataSources)
            {
                string sql  = dataSource.CommandText;
                string conn = ConfigurationManager.ConnectionStrings[dataSource.ConnkeyName].ConnectionString;

                //List<string> resultP = GetParamsBySql(sql);
                List <string> resultP = GetParamsByStr(dataSource.DataParams);

                OracleParameter[] paras = new OracleParameter[resultP.Count];
                for (int i = 0; i < resultP.Count; i++)
                {
                    var dataParam = parameters.Where(p => p.ParameterName.ToUpper() == resultP[i].ToUpper());
                    if (dataParam.Count() == 0)
                    {
                        continue;
                    }

                    #region 判断类型
                    switch (dataParam.First().ParamterType)
                    {
                    case 1:
                        paras[i] = new OracleParameter
                        {
                            ParameterName = resultP[i],
                            Value         = dicParameters[resultP[i]]
                        };
                        break;

                    case 2:
                        paras[i] = new OracleParameter
                        {
                            ParameterName = resultP[i],
                            Value         = Convert.ToInt32(dicParameters[resultP[i]])
                        };
                        break;

                    case 3:
                        paras[i] = new OracleParameter
                        {
                            ParameterName = resultP[i],
                            Value         = Convert.ToDecimal(dicParameters[resultP[i]])
                        };
                        break;

                    case 4:
                        paras[i] = new OracleParameter
                        {
                            ParameterName = resultP[i],
                            Value         = Convert.ToDateTime(dicParameters[resultP[i]])
                        };
                        break;

                    case 5:
                        paras[i] = new OracleParameter
                        {
                            ParameterName = resultP[i],
                            Value         = Convert.ToBoolean(dicParameters[resultP[i]])
                        };
                        break;

                    case 6:
                        paras[i] = new OracleParameter
                        {
                            ParameterName = resultP[i],
                            Value         = new Guid(dicParameters[resultP[i]])
                        };
                        break;

                    default:
                        paras[i] = new OracleParameter
                        {
                            ParameterName = resultP[i],
                            Value         = dicParameters[resultP[i]]
                        };
                        break;
                    }
                    #endregion
                }
                var dataSet = OracleDbHelper.ExecuteDataset(conn,
                                                            sql,
                                                            dataSource.CommandType == 1 ? System.Data.CommandType.Text : System.Data.CommandType.StoredProcedure,
                                                            paras);
                dataSet.Tables[0].TableName = "dt_" + dataSource.TableName;
                dataSet.DataSetName         = "ds_" + dataSource.TableName;
                listDs.Add(dataSet);
            }
            return(await Task.FromResult(listDs));
        }