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.

66 lines
2.3 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. using Dapper;
  2. using Microsoft.Data.SqlClient;
  3. using Npgsql;
  4. using Oracle.ManagedDataAccess.Client;
  5. using Shentun.Utilities;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Data.Common;
  9. using System.Linq;
  10. using System.Text;
  11. using System.Threading.Tasks;
  12. namespace Shentun.Peis.PlugIns
  13. {
  14. public class ColumnReferencePlugInsDbBase: ColumnReferencePlugInsBase
  15. {
  16. protected string InterfaceSql;
  17. protected string InterfaceDbType;
  18. protected string? InterfaceConnctionStr;
  19. public ColumnReferencePlugInsDbBase(string parmValue):base(parmValue)
  20. {
  21. InterfaceSql = InterfaceConfig.GetSection("Interface").GetSection("Sql").Value;
  22. InterfaceDbType = InterfaceConfig.GetSection("Interface").GetSection("DbType").Value;
  23. InterfaceConnctionStr = InterfaceConfig.GetSection("Interface").GetSection("ConnectionStrings").Value;
  24. }
  25. protected DbConnection CreateInterfaceDbConnect()
  26. {
  27. DbConnection conn ;
  28. if (string.IsNullOrWhiteSpace(InterfaceConnctionStr))
  29. {
  30. throw new ArgumentException("数据连接设置中的DbType不能为空");
  31. }
  32. InterfaceDbType = InterfaceDbType.ToLower();
  33. if (InterfaceDbType == "sqlserver")
  34. {
  35. conn = new SqlConnection(InterfaceConnctionStr);
  36. }
  37. else if (InterfaceDbType == "postgres")
  38. {
  39. conn = new NpgsqlConnection(InterfaceConnctionStr);
  40. }
  41. else if (InterfaceDbType == "oracle")
  42. {
  43. conn = new OracleConnection(InterfaceConnctionStr);
  44. }
  45. else
  46. {
  47. throw new ArgumentException("数据连接设置中的DbType不支持");
  48. }
  49. return conn;
  50. }
  51. public override async Task<List<ColumnReferenceCodeValue>> GetInterfaceCodeValuesAsync()
  52. {
  53. using (DbConnection conn = CreateInterfaceDbConnect())
  54. {
  55. var list = (await conn.QueryAsync<ColumnReferenceCodeValue>(InterfaceSql)).ToList();
  56. foreach (var item in list)
  57. {
  58. item.SimpleCode = LanguageConverter.GetPYSimpleCode(item.DisplayName);
  59. }
  60. return list;
  61. }
  62. }
  63. }
  64. }