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.

143 lines
4.5 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
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
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
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
2 years ago
2 years ago
2 years ago
2 years ago
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Data.Common;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Text.Json;
  8. using System.Threading.Tasks;
  9. using Dapper;
  10. using Microsoft.Extensions.Configuration;
  11. using Npgsql;
  12. using Shentun.Utilities;
  13. namespace Shentun.Peis.PlugIns
  14. {
  15. public class ColumnReferencePlugInsBase : PlugInsBase,IColumnReferencePlugIns
  16. {
  17. protected string AppSql;
  18. private List<ColumnReferenceColumn> _columns;
  19. private List<ColumnReferenceColumn> _interfaceColumns;
  20. public ColumnReferencePlugInsBase(string parmValue):base(parmValue)
  21. {
  22. AppSql = InterfaceConfig.GetSection("App").GetSection("Sql").Value;
  23. var columns = InterfaceConfig.GetSection("App").GetSection("Columns").Value;
  24. string[]? columnArry;
  25. if (columns != null)
  26. {
  27. columns = columns.Replace(",", ",");
  28. columnArry = columns.Split(',');
  29. _columns = new List<ColumnReferenceColumn>();
  30. foreach (var column in columnArry)
  31. {
  32. var singleColumns = column.Split('=');
  33. if (singleColumns.Length == 2)
  34. {
  35. _columns.Add(new ColumnReferenceColumn()
  36. {
  37. Column = singleColumns[0],
  38. Name = singleColumns[1]
  39. });
  40. }
  41. }
  42. }
  43. columns = InterfaceConfig.GetSection("Interface").GetSection("Columns").Value;
  44. if(columns != null)
  45. {
  46. columns = columns.Replace(",", ",");
  47. columnArry = columns.Split(',');
  48. _interfaceColumns = new List<ColumnReferenceColumn>();
  49. foreach (var columnName in columnArry)
  50. {
  51. var singleColumns = columnName.Split('=');
  52. if (singleColumns.Length == 2)
  53. {
  54. _interfaceColumns.Add(new ColumnReferenceColumn()
  55. {
  56. Column = singleColumns[0],
  57. Name = singleColumns[1]
  58. });
  59. }
  60. }
  61. }
  62. }
  63. public virtual List<ColumnReferenceColumn> GetAppColumns()
  64. {
  65. if (_columns == null || _columns.Count() == 0)
  66. {
  67. return new List<ColumnReferenceColumn>()
  68. {
  69. new ColumnReferenceColumn()
  70. {
  71. Column = "Code",
  72. Name = "编码"
  73. },
  74. new ColumnReferenceColumn()
  75. {
  76. Column = "DisplayName",
  77. Name = "名称"
  78. }
  79. };
  80. }
  81. return _columns;
  82. }
  83. public virtual List<ColumnReferenceColumn> GetInterfaceColumns()
  84. {
  85. if (_interfaceColumns == null || _interfaceColumns.Count() == 0)
  86. {
  87. return new List<ColumnReferenceColumn>()
  88. {
  89. new ColumnReferenceColumn()
  90. {
  91. Column = "Code",
  92. Name = "编码"
  93. },
  94. new ColumnReferenceColumn()
  95. {
  96. Column = "DisplayName",
  97. Name = "名称"
  98. }
  99. };
  100. }
  101. return _interfaceColumns;
  102. }
  103. public virtual async Task<List<ColumnReferenceCodeValue>> GetAppCodeValuesAsync()
  104. {
  105. using (DbConnection conn = new NpgsqlConnection(AppConnctionStr))
  106. {
  107. var list = (await conn.QueryAsync<ColumnReferenceCodeValue>(AppSql)).ToList();
  108. return list;
  109. }
  110. }
  111. public virtual async Task<List<ColumnReferenceCodeValue>> GetInterfaceCodeValuesAsync()
  112. {
  113. return new List<ColumnReferenceCodeValue>()
  114. {
  115. };
  116. }
  117. public virtual async Task<List<ColumnReferenceFilterCodeValue>> GetAppFilterCodeValuesAsync()
  118. {
  119. throw new NotImplementedException();
  120. }
  121. public virtual string GetAppFilterColumnName()
  122. {
  123. return null;
  124. }
  125. }
  126. }