| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- using Lottomat.Application.Entity.SystemManage;
- using Lottomat.Application.IService.SystemManage;
- using Lottomat.Application.Service.SystemManage;
- using System;
- using System.Collections.Generic;
- using System.Data.Common;
- using System.Data.SqlClient;
- namespace Lottomat.Application.Busines.SystemManage
- {
- /// <summary>
- /// 版 本 1.0
- /// Copyright (c) 2016-2017
- /// 创建人:赵轶
- /// 日 期:2015.11.18 11:02
- /// 描 述:数据库连接管理
- /// </summary>
- public class DataBaseLinkBLL
- {
- private IDataBaseLinkService service = new DataBaseLinkService();
- #region 获取数据
- /// <summary>
- /// 库连接列表
- /// </summary>
- /// <returns></returns>
- public IEnumerable<DataBaseLinkEntity> GetList()
- {
- return service.GetList();
- }
- /// <summary>
- /// 库连接实体
- /// </summary>
- /// <param name="keyValue">主键值</param>
- /// <returns></returns>
- public DataBaseLinkEntity GetEntity(string keyValue)
- {
- return service.GetEntity(keyValue);
- }
- #endregion
- #region 提交数据
- /// <summary>
- /// 删除库连接
- /// </summary>
- /// <param name="keyValue">主键</param>
- public void RemoveForm(string keyValue)
- {
- try
- {
- service.RemoveForm(keyValue);
- }
- catch (Exception)
- {
- throw;
- }
- }
- /// <summary>
- /// 保存库连接表单(新增、修改)
- /// </summary>
- /// <param name="keyValue">主键值</param>
- /// <param name="databaseLinkEntity">库连接实体</param>
- /// <returns></returns>
- public void SaveForm(string keyValue, DataBaseLinkEntity databaseLinkEntity)
- {
- try
- {
- #region 测试连接数据库
- DbConnection dbConnection = null;
- string ServerAddress = "";
- switch (databaseLinkEntity.DbType)
- {
- case "SqlServer":
- dbConnection = new SqlConnection(databaseLinkEntity.DbConnection);
- ServerAddress = dbConnection.DataSource;
- break;
- default:
- break;
- }
- dbConnection.Close();
- databaseLinkEntity.ServerAddress = ServerAddress;
- #endregion
- service.SaveForm(keyValue, databaseLinkEntity);
- }
- catch (Exception)
- {
- throw;
- }
- }
- #endregion
- }
- }
|