Beispiel #1
0
        public ActionResult PreviewParameterModal(long id)
        {
            var parametes = _ParameterAppService.GetReportParametersByTemplate(new Abp.Application.Services.Dto.EntityDto {
                Id = Convert.ToInt32(id)
            }).Result;

            StringBuilder html = new StringBuilder();

            foreach (var item in parametes.Items)
            {
                if (item.UiType == (int)ReportDefine.UiTypes.日期型)
                {
                    html.AppendFormat("<div class=\"form-group form-md-line-input no-hint\">");
                    html.AppendFormat("<input type=\"text\" name=\"{0}\" class=\"form-control date-picker\" required>", item.ParameterName);
                    html.AppendFormat("<label>{0}</label>", item.LabelName);
                    html.AppendFormat("</div>");
                }
                else if (item.UiType == (int)ReportDefine.UiTypes.日期时间型)
                {
                    html.AppendFormat("<div class=\"form-group form-md-line-input no-hint\">");
                    html.AppendFormat("<input type=\"text\" name=\"{0}\" class=\"form-control date-time-picker\" required>", item.ParameterName);
                    html.AppendFormat("<label>{0}</label>", item.LabelName);
                    html.AppendFormat("</div>");
                }
                else if (item.UiType == (int)ReportDefine.UiTypes.拉框 &&
                         !string.IsNullOrWhiteSpace(item.DynamicDataSource) &&
                         !string.IsNullOrWhiteSpace(item.DynamicSql))
                {
                    string conn = ConfigurationManager.ConnectionStrings[item.DynamicDataSource].ConnectionString;

                    var table = OracleDbHelper.ExecuteDataset(conn, item.DynamicSql, System.Data.CommandType.Text).Tables[0];

                    html.AppendFormat("<div class=\"form-group\">");
                    html.AppendFormat("<label for=\"{0}\">{1}</label>", item.ParameterName, item.LabelName);
                    html.AppendFormat("<select id=\"{0}\" name=\"{1}\" class=\"form-control bs-select\" data-live-search=\"true\">", item.ParameterName, item.ParameterName);
                    foreach (DataRow row in table.Rows)
                    {
                        html.AppendFormat("<option data-icon=\"{0}\" value=\"{1}\")><i class=\"{2}\"></i>{3}</option>",
                                          row["value"].ToString(),
                                          row["value"].ToString(),
                                          row["value"].ToString(),
                                          row["text"].ToString());
                    }
                    html.AppendFormat("</select>");
                }
                else
                {
                    html.AppendFormat("<div class=\"form-group form-md-line-input no-hint\">");
                    html.AppendFormat("<input type=\"text\" name=\"{0}\" class=\"form-control\">", item.ParameterName);
                    html.AppendFormat("<label>{0}</label>", item.LabelName);
                    html.AppendFormat("</div>");
                }
            }
            ViewBag.FormHtml = html.ToString();
            ViewBag.Id       = id;

            return(PartialView("_PreviewParameterModal"));
        }
Beispiel #2
0
        /// <summary>
        /// 获取列
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        private DataColumnCollection GetColumnsByDataSource(ReportDataSourceInputDto input)
        {
            string sql  = input.CommandText;
            string conn = ConfigurationManager.ConnectionStrings[input.ConnkeyName].ConnectionString;

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

            OracleParameter[] paras = new OracleParameter[resultP.Count];
            for (int i = 0; i < resultP.Count; i++)
            {
                paras[i] = new OracleParameter {
                    ParameterName = resultP[i], Value = ""
                };
            }
            var table = OracleDbHelper.ExecuteDataset(conn,
                                                      sql,
                                                      input.CommandType == 1 ? System.Data.CommandType.Text : System.Data.CommandType.StoredProcedure,
                                                      paras);

            return(table.Tables[0].Columns);
        }
Beispiel #3
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));
        }