CheckResultServices.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. using SCC.Common;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Data;
  5. using System.Data.SqlClient;
  6. using System.Linq;
  7. using System.Text;
  8. namespace SCC.Services
  9. {
  10. public class CheckResultServices
  11. {
  12. /// <summary>
  13. /// 执行校验结果
  14. /// </summary>
  15. /// <param name="tablename">表名</param>
  16. /// <param name="result">校验结果key为期号 value为结果 1为成功0为失败</param>
  17. /// <returns></returns>
  18. public int ExecuteResult(string tablename, Dictionary<int, int> result)
  19. {
  20. try
  21. {
  22. if (result.Count == 0) return 1;
  23. var resultok = result.Where(w => w.Value == 1).Select(w => w.Key).ToArray();
  24. var resultall = result.Select(w => w.Key).ToArray(); ;
  25. string okstr = string.Join(",", resultok);
  26. string allstr = string.Join(",", resultall);
  27. string sql = string.Format(ResultSQL, tablename, okstr, allstr);
  28. int rt = SqlHelper.ExecuteNonQuery(CommandType.Text, sql, null);
  29. return rt;
  30. }
  31. catch (Exception ee)
  32. {
  33. return -2;
  34. }
  35. }
  36. private string ResultSQL = @"update {0} set IsChecked=1 ,IsPassed=( case when Term in({1}) then 1 else 0 end) where Term in ({2})";
  37. }
  38. }