1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Transactions;
- using EMIS.Entities;
- using EMIS.ViewModel;
- using EMIS.ViewModel.EvaluationManage.EvaluationSetting;
- using EMIS.DataLogic.Repositories;
- namespace EMIS.CommonLogic.EvaluationManage.EvaluationSetting
- {
- public class EvaluationSensitiveWordServices : BaseServices, IEvaluationSensitiveWordServices
- {
- public ParameterRepository ParameterRepository { get; set; }
- /// <summary>
- /// 查询对应的敏感词信息EvaluationSensitiveWordView
- /// </summary>
- /// <returns></returns>
- public EvaluationSensitiveWordView GetEvaluationSensitiveWordView()
- {
- var evaluationSensitiveWordView = new EvaluationSensitiveWordView();
- var parameter = ParameterRepository.GetSingle(x => x.ParameterTypeID == (int)CF_ParameterType.EvaluationSensitiveWord);
- if (parameter != null)
- {
- evaluationSensitiveWordView.EvaluationSensitiveWordID = parameter.ParameterID;
- evaluationSensitiveWordView.ParameterTypeID = parameter.ParameterTypeID;
- evaluationSensitiveWordView.Value = parameter.Value;
- evaluationSensitiveWordView.RecordStatus = parameter.RecordStatus;
- }
- return evaluationSensitiveWordView;
- }
- /// <summary>
- /// 敏感词保存
- /// </summary>
- /// <param name="evaluationSensitiveWordView"></param>
- public void EvaluationSensitiveWordSave(EvaluationSensitiveWordView evaluationSensitiveWordView)
- {
- try
- {
- var parameterInList = new List<CF_Parameter>();
- var newParameter = new CF_Parameter();
- newParameter.ParameterID = Guid.NewGuid();
- newParameter.ParameterTypeID = (int)CF_ParameterType.EvaluationSensitiveWord;
- newParameter.Value = evaluationSensitiveWordView.Value;
- this.SetNewStatus(newParameter);
- parameterInList.Add(newParameter);
- using (TransactionScope ts = new TransactionScope())
- {
- UnitOfWork.Delete<CF_Parameter>(x => x.ParameterTypeID == (int)CF_ParameterType.EvaluationSensitiveWord);
- UnitOfWork.BulkInsert(parameterInList);
- ts.Complete();
- }
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- }
- }
|