using Learun.DataBase.Repository;
using Learun.Util;
using System;
using System.Collections.Generic;
using System.Text;
namespace Learun.Application.OA.Email.EmailConfig
{
///
/// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
/// Copyright (c) 2013-2017
/// 创建人:陈彬彬
/// 日 期:2018.06.04
/// 描 述:邮件配置管理
///
public class EmailConfigService : RepositoryFactory
{
#region 获取数据
///
/// 获取配置信息
///
/// 关键词
///
public IEnumerable GetConfigList(string queryJson)
{
try
{
var strSql = new StringBuilder();
strSql.Append("SELECT * FROM LR_EmailConfig");
return this.BaseRepository().FindList(strSql.ToString());
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowServiceException(ex);
}
}
}
///
/// 获取邮件配置实体
///
/// 主键
///
public EmailConfigEntity GetConfigEntity(string keyValue)
{
try
{
return this.BaseRepository().FindEntity(t => t.F_CreatorUserId == keyValue);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowServiceException(ex);
}
}
}
///
/// 获取当前有效邮件配置实体
///
/// 主键
///
public EmailConfigEntity GetCurrentConfig()
{
try
{
return this.BaseRepository().FindEntity(t => t.F_EnabledMark == 1);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowServiceException(ex);
}
}
}
#endregion
#region 提交数据
///
/// 删除
///
/// 主键
public void DeleteEntity(string keyValue)
{
try
{
this.BaseRepository().Delete(t => t.F_Id == keyValue);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowServiceException(ex);
}
}
}
///
/// 保存(新增、修改)
///
/// 主键值
/// 邮件配置实体
///
public void SaveConfigEntity(string keyValue, EmailConfigEntity configEntity)
{
try
{
if (!string.IsNullOrEmpty(keyValue))
{
configEntity.Modify(keyValue);
this.BaseRepository().Update(configEntity);
}
else
{
configEntity.Create();
this.BaseRepository().Insert(configEntity);
}
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowServiceException(ex);
}
}
}
#endregion
}
}