纽威
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
2.6 KiB

2 years ago
  1. using ICSSoft.Common;
  2. using ICSSoft.Entity;
  3. using Newtonsoft.Json;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Data;
  7. using System.Data.SqlClient;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. namespace ICSSoft.DataProject
  12. {
  13. /// <summary>
  14. /// 齐套验证服务
  15. /// </summary>
  16. public class ICSCompleteVerificationService
  17. {
  18. private static log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
  19. private static string connString = System.Configuration.ConfigurationManager.AppSettings["ConnStr"];
  20. private static string ERPDB = System.Configuration.ConfigurationManager.AppSettings["ERPDB"];
  21. DataTable table = null;
  22. SqlConnection conn = new System.Data.SqlClient.SqlConnection(connString);
  23. string sql = string.Empty;
  24. string sqlInfo = string.Empty;
  25. VerificationMethod verification = new VerificationMethod();
  26. /// <summary>
  27. /// 获取齐套状态值
  28. /// </summary>
  29. /// <returns></returns>
  30. /// <exception cref="Exception"></exception>
  31. public static CompleteVerification GetSuitVerifyModel()
  32. {
  33. using (SqlConnection conn = new System.Data.SqlClient.SqlConnection(connString))
  34. {
  35. conn.Open();
  36. SqlCommand cmd = new SqlCommand();
  37. SqlTransaction sqlTran = conn.BeginTransaction();
  38. cmd.Transaction = sqlTran;
  39. cmd.Connection = conn;
  40. try
  41. {
  42. string sql = @"SELECT Code,Name,Enable,WorkPoint FROM [dbo].[ICSConfiguration] WHERE Code='CompleteVerification'";
  43. DataTable table = DBHelper.SQlReturnData(sql, cmd);
  44. string json = JsonConvert.SerializeObject(table);
  45. List<CompleteVerification> model = JsonConvert.DeserializeObject<List<CompleteVerification>>(json);
  46. cmd.Transaction.Commit();
  47. return model[0];
  48. }
  49. catch (Exception ex)
  50. {
  51. if (cmd.Transaction != null)
  52. cmd.Transaction.Rollback();
  53. log.Error(ex.Message);
  54. throw new Exception(ex.Message);
  55. }
  56. finally
  57. {
  58. if (conn.State == ConnectionState.Open)
  59. {
  60. conn.Close();
  61. }
  62. conn.Dispose();
  63. }
  64. }
  65. }
  66. }
  67. }