123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- using SqlSugar;
- using System;
- using System.Configuration;
- namespace WMS.Core
- {
- public class SysDbInfo: ConfigurationSection
- {
- /// <summary>
- /// 获取配置信息
- /// </summary>
- /// <returns></returns>
- public static SysDbInfo GetConfig()
- {
- return GetConfig("databaseconfig");
- }
-
- /// <summary>
- /// 获取配置信息
- /// </summary>
- /// <param name="sectionName">xml节点名称</param>
- /// <returns></returns>
- public static SysDbInfo GetConfig(string sectionName)
- {
- var t = ConfigurationManager.GetSection(sectionName);
- SysDbInfo section = (SysDbInfo)t;
- if (section == null)
- throw new ConfigurationErrorsException("Section " + sectionName + " is not found.");
- return section;
- }
- /// <summary>
- /// 数据库连接名
- /// </summary>
- [ConfigurationProperty("DbSetNo", IsRequired = false, DefaultValue = "BaseDB")]
- public string DbSetNo
- {
- get
- {
- return base["DbSetNo"].ToString();
- }
- set
- {
- base["DbSetNo"] = value;
- }
- }
- /// <summary>
- /// 数据库连接字符串
- /// </summary>
- [ConfigurationProperty("ConnectionString", IsRequired = false)]
- public string ConnectionString
- {
- get
- {
- return base["ConnectionString"].ToString();
- }
- set
- {
- base["ConnectionString"] = value;
- }
- }
- /// <summary>
- /// 必填, 数据库类型
- /// </summary>
- [ConfigurationProperty("DataBaseType", IsRequired = false, DefaultValue = DbType.SqlServer)]
- public DbType DataBaseType
- {
- get
- {
- return (DbType)base["DataBaseType"];
-
- }
- set
- {
- base["DataBaseType"] = value;
- }
- }
- /// <summary>
- /// 默认SystemTable, 字段信息读取, 如:该属性是不是主键,是不是标识列等等信息
- /// </summary>
- [ConfigurationProperty("InitKey", IsRequired = false, DefaultValue = InitKeyType.SystemTable)]
- public InitKeyType InitKey
- {
- get
- {
- return (InitKeyType)base["InitKey"];
- }
- set
- {
- base["InitKey"] = value;
- }
- }
- /// <summary>
- /// 默认false, 时候知道关闭数据库连接, 设置为true无需使用using或者Close操作
- /// </summary>
- [ConfigurationProperty("IsAutoCloseConn", IsRequired = false, DefaultValue=true)]
- public bool IsAutoCloseConn
- {
- get
- {
- return (bool)base["IsAutoCloseConn"];
- }
- set
- {
- base["IsAutoCloseConn"] = value;
- }
- }
- }
- }
|