RelationClass.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using MySystem.BsModels;
  5. namespace MySystem
  6. {
  7. public class RelationClass
  8. {
  9. public static string GetColInfo(string key)
  10. {
  11. using (WebCMSEntities db = new WebCMSEntities())
  12. {
  13. Col item = db.Col.FirstOrDefault(m => m.ColId == key);
  14. if (item != null)
  15. {
  16. return item.ColName;
  17. }
  18. }
  19. return "";
  20. }
  21. public static string GetColInfo(int key)
  22. {
  23. using (BsModels.WebCMSEntities db = new BsModels.WebCMSEntities())
  24. {
  25. BsModels.Col item = db.Col.FirstOrDefault(m => m.Id == key);
  26. if (item != null)
  27. {
  28. return item.ColName;
  29. }
  30. }
  31. return "";
  32. }
  33. public static string GetMsgTemplateInfo(int key)
  34. {
  35. using (WebCMSEntities db = new WebCMSEntities())
  36. {
  37. MsgTemplate item = db.MsgTemplate.FirstOrDefault(m => m.Id == key);
  38. if (item != null)
  39. {
  40. return item.Title;
  41. }
  42. }
  43. return "";
  44. }
  45. public static string GetMsgPlacardInfo(int key)
  46. {
  47. using (WebCMSEntities db = new WebCMSEntities())
  48. {
  49. MsgPlacard item = db.MsgPlacard.FirstOrDefault(m => m.Id == key);
  50. if (item != null)
  51. {
  52. return item.Title;
  53. }
  54. }
  55. return "";
  56. }
  57. public static string GetColList(string keys)
  58. {
  59. string[] IdList = keys.Split(',');
  60. List<int> List = new List<int>();
  61. foreach (string key in IdList)
  62. {
  63. List.Add(int.Parse(key));
  64. }
  65. string result = "";
  66. using (WebCMSEntities db = new WebCMSEntities())
  67. {
  68. var items = db.Col.Select(m => new { m.Id, m.ColName }).Where(m => List.Contains(m.Id));
  69. foreach (var item in items)
  70. {
  71. result += item.ColName + ",";
  72. }
  73. }
  74. return result.TrimEnd(',');
  75. }
  76. public static string GetPageUpdateInfoList(string keys)
  77. {
  78. string[] ModulePathList = keys.Split(',');
  79. List<string> List = new List<string>();
  80. foreach (string key in ModulePathList)
  81. {
  82. List.Add(key);
  83. }
  84. string result = "";
  85. using (WebCMSEntities db = new WebCMSEntities())
  86. {
  87. var items = db.PageUpdateInfo.Select(m => new { m.ModulePath, m.Title }).Where(m => List.Contains(m.ModulePath));
  88. foreach (var item in items)
  89. {
  90. result += item.Title + ",";
  91. }
  92. }
  93. return result.TrimEnd(',');
  94. }
  95. public static string GetSysAdminRoleInfo(int key)
  96. {
  97. using (BsModels.WebCMSEntities db = new BsModels.WebCMSEntities())
  98. {
  99. BsModels.SysAdminRole item = db.SysAdminRole.FirstOrDefault(m => m.Id == key);
  100. if (item != null)
  101. {
  102. return item.Name;
  103. }
  104. }
  105. return "";
  106. }
  107. public static string GetSysAdminRoleNewInfo(int key)
  108. {
  109. using (BsModels.WebCMSEntities db = new BsModels.WebCMSEntities())
  110. {
  111. BsModels.SysAdminRoleNew item = db.SysAdminRoleNew.FirstOrDefault(m => m.Id == key);
  112. if (item != null)
  113. {
  114. return item.Name;
  115. }
  116. }
  117. return "";
  118. }
  119. }
  120. }