/// <summary>
 /// 获取数据源
 /// </summary>
 private void GetDataSourceList()
 {
     try
     {
         this.DataSourceList = new List<DataSource>();
         IList<DataSourceDTO> dataSource = BuildWordInstance.GetDataSource((int)this.templateTypeID);
         if (dataSource != null)
         {
             foreach (var ds in dataSource)
             {
                 this.DataSourceList.Add(
                     new DataSource(ds.FSQ_DB_NAME, ds.DATA_SOURCE_NAME, ds.DATA_SOURCE_NAME, false,
                         ds.SQL_CONTENT, this)
                     );
             }
         }
          
     }
     catch {
         System.Console.Write("获取数据源报错");
     }
 }
Exemple #2
0
        /// <summary>
        /// 从CacheData获取,不存在则根据SQL变量创建
        /// </summary>
        /// <returns>数据</returns>
        public DataTable GetDataTable()
        {

            DataTable dt = new DataTable();
            try
            {
                string cacheKey = string.Format("{0}_{1}", this.DBName, this.DataSourceName);
                dt = this.docTemplateType.CacheData.Tables[cacheKey];
                if (dt == null && this.sql.IndexOf("@") == -1)
                {
                    dt = BuildWordInstance.GetDataSource(this.DBName, this.sql);
                    dt.TableName = cacheKey;
                    this.docTemplateType.CacheData.Tables.Add(dt);
                }
            }
            catch
            {
                System.Console.Write(this.DataSourceName + "的数据源取值异常");
                throw;
            }

            return dt;
        }