RowStructure.cs 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. using Microsoft.Extensions.Configuration;
  2. using Newtonsoft.Json.Linq;
  3. using SuperAdmin.Controllers;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Web;
  8. namespace SuperAdmin.Models.Object
  9. {
  10. public class RowStructure
  11. {
  12. public String id { get; set; }
  13. public String parent_id { get; set; }
  14. public String sv_id { get; set; }
  15. public String code { get; set; }
  16. public String name { get; set; }
  17. public String[] names { get; set; }
  18. public String name_global { get; set; }
  19. public String name_global1 { get; set; }
  20. public String name_global2 { get; set; }
  21. public String name_local { get; set; }
  22. public String description { get; set; }
  23. public String[] descriptions { get; set; }
  24. public String description_global { get; set; }
  25. public String description_global1 { get; set; }
  26. public String description_global2 { get; set; }
  27. public String description_local { get; set; }
  28. public String introduction { get; set; }
  29. public String[] introductions { get; set; }
  30. public String introduction_global { get; set; }
  31. public String introduction_global1 { get; set; }
  32. public String introduction_global2 { get; set; }
  33. public String introduction_local { get; set; }
  34. public String icon { get; set; }
  35. public String logo { get; set; }
  36. public String realIcon { get; set; }
  37. public String realLogo { get; set; }
  38. public String content { get; set; }
  39. public String[] contents { get; set; }
  40. public String content_global { get; set; }
  41. public String content_global1 { get; set; }
  42. public String content_global2 { get; set; }
  43. public String content_type { get; set; }
  44. public String created_date { get; set; }
  45. public String update_date { get; set; }
  46. public String from_date { get; set; }
  47. public String to_date { get; set; }
  48. public String province_id { get; set; }
  49. public String topic_id { get; set; }
  50. public String level { get; set; }
  51. public String is_read { get; set; }
  52. // 1 publish - 0 draft
  53. public String status { get; set; }
  54. // to determine showing or not
  55. public String is_show { get; set; }
  56. // to distinguish (1) admin and (0) user
  57. public String permission { get; set; }
  58. public String note { get; set; }
  59. // enews
  60. public String service_id { get; set; }
  61. public RowStructure() { }
  62. public RowStructure(IConfiguration configuration, string json) : this(configuration, JObject.Parse(json))
  63. { }
  64. public RowStructure(IConfiguration configuration, JObject jObject)
  65. {
  66. if (jObject != null)
  67. {
  68. id = (string)jObject["ID"];
  69. parent_id = (string)jObject["PARENT_ID"];
  70. sv_id = (string)jObject["SV_ID"];
  71. code = (string)jObject["CODE"];
  72. name = (string)jObject["NAME"];
  73. name_global = (string)jObject["NAME_GLOBAL"];
  74. name_global1 = (string)jObject["NAME_GLOBAL1"];
  75. name_global2 = (string)jObject["NAME_GLOBAL2"];
  76. name_local = (string)jObject["NAME_LOCAL"];
  77. names = new string[] { name_local, name_global, name_global1, name_global2 };
  78. description = (string)jObject["DESCRIPTION"];
  79. description_global = (string)jObject["DESCRIPTION_GLOBAL"];
  80. description_global1 = (string)jObject["DESCRIPTION_GLOBAL1"];
  81. description_global2 = (string)jObject["DESCRIPTION_GLOBAL2"];
  82. description_local = (string)jObject["DESCRIPTION_LOCAL"];
  83. descriptions = new string[] { description_local, description_global, description_global1, description_global2 };
  84. introduction = (string)jObject["INTRODUCTION"];
  85. introduction_global = (string)jObject["INTRODUCTION_GLOBAL"];
  86. introduction_global1 = (string)jObject["INTRODUCTION_GLOBAL1"];
  87. introduction_global2 = (string)jObject["INTRODUCTION_GLOBAL2"];
  88. introduction_local = (string)jObject["INTRODUCTION_LOCAL"];
  89. introductions = new string[] { introduction_local, introduction_global, introduction_global1, introduction_global2 };
  90. level = (string)jObject["LEVEL"];
  91. permission = (string)jObject["TYPE"];
  92. String img = (string)jObject["ICON"];
  93. icon = img == null || img == "" ? "" : configuration.GetSection(UtilsController.Constant.PATH_CONTENT).Value + "/" + img;
  94. realIcon = (string)jObject["ICON"];
  95. img = (string)jObject["LOGO"];
  96. logo = img == null || img == "" ? "" : configuration.GetSection(UtilsController.Constant.PATH_CONTENT).Value + "/" + img;
  97. realLogo = img;
  98. content = (string)jObject["CONTENT"];
  99. content_global = (string)jObject["CONTENT_GLOBAL"];
  100. content_global1 = (string)jObject["CONTENT_GLOBAL1"];
  101. content_global2 = (string)jObject["CONTENT_GLOBAL2"];
  102. content_type = (string)jObject["CONTENT_TYPE"];
  103. contents = new string[] { content, content_global, content_global1, content_global2 };
  104. from_date = (string)jObject["FROM_DATE"];
  105. to_date = (string)jObject["TO_DATE"];
  106. created_date = (string)jObject["CREATED_DATE"];
  107. update_date = (string)jObject["UPDATE_DATE"];
  108. province_id = (string)jObject["PROVINCE_ID"];
  109. topic_id = (string)jObject["TOPIC_ID"];
  110. is_read = (string)jObject["IS_READ"];
  111. status = (string)jObject["STATUS"];
  112. is_show = (string)jObject["IS_SHOW"];
  113. note = (string)jObject["NOTE"];
  114. }
  115. }
  116. //public RowStructure(IConfiguration configuration, JObject jObject, int type)
  117. //{
  118. // if (jObject != null)
  119. // {
  120. // if (type == UtilsController.Constant.DATA_TYPE_ONE)
  121. // {
  122. // id = (string)jObject["id"];
  123. // parent_id = (string)jObject["parent_id"];
  124. // sv_id = (string)jObject["service_id"];
  125. // code = (string)jObject["code"];
  126. // name = (string)jObject["name"];
  127. // name_global = (string)jObject["name_global"];
  128. // name_local = (string)jObject["name_local"];
  129. // description = (string)jObject["description"];
  130. // description_global = (string)jObject["description_global"];
  131. // description_local = (string)jObject["description_local"];
  132. // introduction = (string)jObject["introduction"];
  133. // introduction_global = (string)jObject["introduction_global"];
  134. // introduction_local = (string)jObject["introduction_local"];
  135. // level = (string)jObject["level"];
  136. // permission = (string)jObject["TYPE"];
  137. // icon = configuration.GetSection(UtilsController.Constant.PATH_CONTENT).Value + (string)jObject["icon"];
  138. // logo = configuration.GetSection(UtilsController.Constant.PATH_CONTENT).Value + (string)jObject["logo"];
  139. // realIcon = (string)jObject["icon"];
  140. // realLogo = (string)jObject["logo"];
  141. // content = (string)jObject["content"];
  142. // content_type = (string)jObject["content_type"];
  143. // from_date = (string)jObject["from_date"];
  144. // to_date = (string)jObject["to_date"];
  145. // created_date = (string)jObject["create_date"];
  146. // update_date = (string)jObject["update_date"];
  147. // province_id = (string)jObject["province_id"];
  148. // topic_id = (string)jObject["topic_id"];
  149. // is_read = (string)jObject["is_read"];
  150. // status = (string)jObject["status"];
  151. // is_show = (string)jObject["is_show"];
  152. // note = (string)jObject["note"];
  153. // }
  154. // }
  155. //}
  156. public object Clone()
  157. {
  158. return this.MemberwiseClone();
  159. }
  160. }
  161. public class RowStructures
  162. {
  163. public List<RowStructure> data { get; set; }
  164. public RowStructures() { }
  165. public RowStructures(IConfiguration configuration, string json) : this(configuration, JObject.Parse(json)) { }
  166. public RowStructures(IConfiguration configuration, JObject jObject)
  167. {
  168. if (jObject != null)
  169. {
  170. var list = jObject["listNews"];
  171. //var dataTypeOne = jObject["dataTypeOne"];
  172. if (list != null && list.HasValues)
  173. {
  174. data = new List<RowStructure>();
  175. JArray a = (JArray)list;
  176. foreach (JObject o in a.Children<JObject>())
  177. {
  178. data.Add(new RowStructure(configuration, o));
  179. }
  180. }
  181. //else if (dataTypeOne != null && dataTypeOne.HasValues)
  182. //{
  183. // data = new List<RowStructure>();
  184. // JArray a = (JArray)dataTypeOne;
  185. // foreach (JObject o in a.Children<JObject>())
  186. // {
  187. // data.Add(new RowStructure(configuration, o));
  188. // }
  189. //}
  190. }
  191. }
  192. }
  193. }