DeviceManager/DeviceRepair.DataAccess/SysCommon/EmailConfigDa.cs
2024-08-02 10:52:45 +08:00

50 lines
1.4 KiB
C#

using DeviceRepair.DataAccess.Data;
using DeviceRepair.Models.Common;
using DeviceRepair.Utils;
using NLog;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
namespace DeviceRepair.DataAccess.SysCommon
{
public class EmailConfigDa : BaseDa
{
private static readonly Logger log = LogManager.GetCurrentClassLogger();
public EmailConfigDa(IDictionary<string, string> apiParams) : base(apiParams)
{
}
public DataSet GetDatas()
{
DataSet dsDatas = new DataSet("Datas");
try
{
if (!ApiParameters.ContainsKey("ModuleCode"))
{
throw new ArgumentException($"邮件模块编码不能为空!");
}
string ModuleCode = ApiParameters["ModuleCode"]?.Trim();
SysEmailConfigInfo Datas = devMain.Queryable<SysEmailConfigInfo>().First(x => x.MuduleCode == ModuleCode);
DataTable table = Datas.toDataTable<SysEmailConfigInfo>();
dsDatas.Tables.Add(table);
return dsDatas;
}
catch (SqlException sqlEx)
{
throw sqlEx;
}
catch (Exception ex)
{
log.Error(ex);
throw ex;
}
}
}
}