EvaluationSensitiveWordServices.cs 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Transactions;
  6. using EMIS.Entities;
  7. using EMIS.ViewModel;
  8. using EMIS.ViewModel.EvaluationManage.EvaluationSetting;
  9. using EMIS.DataLogic.Repositories;
  10. namespace EMIS.CommonLogic.EvaluationManage.EvaluationSetting
  11. {
  12. public class EvaluationSensitiveWordServices : BaseServices, IEvaluationSensitiveWordServices
  13. {
  14. public ParameterRepository ParameterRepository { get; set; }
  15. /// <summary>
  16. /// 查询对应的敏感词信息EvaluationSensitiveWordView
  17. /// </summary>
  18. /// <returns></returns>
  19. public EvaluationSensitiveWordView GetEvaluationSensitiveWordView()
  20. {
  21. var evaluationSensitiveWordView = new EvaluationSensitiveWordView();
  22. var parameter = ParameterRepository.GetSingle(x => x.ParameterTypeID == (int)CF_ParameterType.EvaluationSensitiveWord);
  23. if (parameter != null)
  24. {
  25. evaluationSensitiveWordView.EvaluationSensitiveWordID = parameter.ParameterID;
  26. evaluationSensitiveWordView.ParameterTypeID = parameter.ParameterTypeID;
  27. evaluationSensitiveWordView.Value = parameter.Value;
  28. evaluationSensitiveWordView.RecordStatus = parameter.RecordStatus;
  29. }
  30. return evaluationSensitiveWordView;
  31. }
  32. /// <summary>
  33. /// 敏感词保存
  34. /// </summary>
  35. /// <param name="evaluationSensitiveWordView"></param>
  36. public void EvaluationSensitiveWordSave(EvaluationSensitiveWordView evaluationSensitiveWordView)
  37. {
  38. try
  39. {
  40. var parameterInList = new List<CF_Parameter>();
  41. var newParameter = new CF_Parameter();
  42. newParameter.ParameterID = Guid.NewGuid();
  43. newParameter.ParameterTypeID = (int)CF_ParameterType.EvaluationSensitiveWord;
  44. newParameter.Value = evaluationSensitiveWordView.Value;
  45. this.SetNewStatus(newParameter);
  46. parameterInList.Add(newParameter);
  47. using (TransactionScope ts = new TransactionScope())
  48. {
  49. UnitOfWork.Delete<CF_Parameter>(x => x.ParameterTypeID == (int)CF_ParameterType.EvaluationSensitiveWord);
  50. UnitOfWork.BulkInsert(parameterInList);
  51. ts.Complete();
  52. }
  53. }
  54. catch (Exception ex)
  55. {
  56. throw new Exception(ex.Message);
  57. }
  58. }
  59. }
  60. }