FunctionConfig.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. using Autofac;
  2. using GreenTree.Nachtragsmanagement.Core;
  3. using GreenTree.Nachtragsmanagement.Core.Domain.User;
  4. using GreenTree.Nachtragsmanagement.Services.User;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Linq;
  8. using System.Web;
  9. namespace GreenTree.Nachtragsmanagement.Web.App_Start
  10. {
  11. public class FunctionConfig
  12. {
  13. /// <summary>
  14. /// Registers all system functions provided by the base system
  15. /// </summary>
  16. public static void RegisterFunctions()
  17. {
  18. var userService = Singleton<IContainer>.Instance.Resolve<IUserService>();
  19. var systemFunctions = AllSystemFunctions();
  20. foreach (var function in systemFunctions)
  21. {
  22. var existingFunction = userService.GetFunctionByName(function.Name);
  23. if (existingFunction != null)
  24. {
  25. var equals =
  26. existingFunction.Description == function.Description &&
  27. existingFunction.ImageUrl == function.ImageUrl &&
  28. existingFunction.GroupName == function.GroupName &&
  29. existingFunction.RouteName == function.RouteName &&
  30. existingFunction.IsMenuMember == function.IsMenuMember &&
  31. existingFunction.Plugin == function.Plugin &&
  32. existingFunction.BaseWidth == function.BaseWidth &&
  33. existingFunction.MinWidth == function.MinWidth &&
  34. existingFunction.BaseHeight == function.BaseHeight &&
  35. existingFunction.MinHeight == function.MinHeight &&
  36. existingFunction.AllowMaximize == function.AllowMaximize;
  37. if (!equals)
  38. {
  39. existingFunction.Description = function.Description;
  40. existingFunction.ImageUrl = function.ImageUrl;
  41. existingFunction.GroupName = function.GroupName;
  42. existingFunction.RouteName = function.RouteName;
  43. existingFunction.IsMenuMember = function.IsMenuMember;
  44. existingFunction.Plugin = function.Plugin;
  45. existingFunction.BaseWidth = function.BaseWidth;
  46. existingFunction.MinWidth = function.MinWidth;
  47. existingFunction.BaseHeight = function.BaseHeight;
  48. existingFunction.MinHeight = function.MinHeight;
  49. existingFunction.AllowMaximize = function.AllowMaximize;
  50. userService.UpdateFunction(existingFunction);
  51. }
  52. }
  53. else
  54. userService.InsertFunction(function);
  55. }
  56. }
  57. private static Function[] AllSystemFunctions()
  58. {
  59. return new[]
  60. {
  61. new Function
  62. {
  63. Name = "Administration",
  64. Description = "Administration",
  65. ImageUrl = "~/Content/Images/function-Administration-32.png",
  66. IsMenuMember = true,
  67. Plugin = "System"
  68. },
  69. new Function
  70. {
  71. Name = "Administration-Users",
  72. Description = "Benutzerverwaltung",
  73. ImageUrl = "~/Content/Images/function-Administration-Users-32.png",
  74. GroupName = "Administration",
  75. RouteName = "GreenTree.Nachtragsmanagement.Web.Administration.Users",
  76. IsMenuMember = true,
  77. Plugin = "System",
  78. BaseWidth = 900,
  79. MinWidth = 600,
  80. BaseHeight = 600,
  81. MinHeight = 400,
  82. AllowMaximize = true
  83. },
  84. new Function
  85. {
  86. Name = "Administration-Users-Edit",
  87. Description = "Benutzer editieren",
  88. GroupName = "Administration-Users",
  89. IsMenuMember = false,
  90. Plugin = "System"
  91. },
  92. new Function
  93. {
  94. Name = "Administration-Roles",
  95. Description = "Rollenverwaltung",
  96. ImageUrl = "~/Content/Images/function-Administration-Roles-32.png",
  97. GroupName = "Administration",
  98. RouteName = "GreenTree.Nachtragsmanagement.Web.Administration.Roles",
  99. IsMenuMember = true,
  100. Plugin = "System",
  101. BaseWidth = 800,
  102. MinWidth = 600,
  103. BaseHeight = 500,
  104. MinHeight = 400,
  105. AllowMaximize = true
  106. },
  107. new Function
  108. {
  109. Name = "Administration-Roles-Edit",
  110. Description = "Rollen editieren",
  111. GroupName = "Administration-Roles",
  112. IsMenuMember = false,
  113. Plugin = "System"
  114. },
  115. new Function
  116. {
  117. Name = "Administration-Plugins",
  118. Description = "Pluginverwaltung",
  119. ImageUrl = "~/Content/Images/function-Administration-Plugins-32.png",
  120. GroupName = "Administration",
  121. RouteName = "GreenTree.Nachtragsmanagement.Web.Administration.Plugins",
  122. IsMenuMember = true,
  123. Plugin = "System",
  124. BaseWidth = 800,
  125. MinWidth = 500,
  126. BaseHeight = 450,
  127. MinHeight = 300,
  128. AllowMaximize = true
  129. },
  130. new Function
  131. {
  132. Name = "Deviation",
  133. Description = "Vertragsabweichungen",
  134. ImageUrl = "~/Content/Images/function-Deviation-32.png",
  135. IsMenuMember = true,
  136. Plugin = "System"
  137. },
  138. new Function
  139. {
  140. Name = "Deviation-Deviations",
  141. Description = "Vertragsabweichungsliste",
  142. ImageUrl = "~/Content/Images/function-Deviation-Deviations-32.png",
  143. GroupName = "Deviation",
  144. RouteName = "GreenTree.Nachtragsmanagement.Web.Deviation.Deviations",
  145. IsMenuMember = true,
  146. Plugin = "System",
  147. BaseWidth = 1000,
  148. MinWidth = 800,
  149. BaseHeight = 650,
  150. MinHeight = 500,
  151. AllowMaximize = true
  152. },
  153. new Function
  154. {
  155. Name = "Deviation-Deviations-Edit",
  156. Description = "Vertragsabweichungen editieren",
  157. GroupName = "Deviation-Deviations",
  158. IsMenuMember = false,
  159. Plugin = "System"
  160. },
  161. new Function
  162. {
  163. Name = "Deviation-Claims",
  164. Description = "Stammdaten",
  165. ImageUrl = "~/Content/Images/function-Deviation-Claims-32.png",
  166. GroupName = "Deviation",
  167. RouteName = "GreenTree.Nachtragsmanagement.Web.Deviation.Claims",
  168. IsMenuMember = true,
  169. Plugin = "System",
  170. BaseWidth = 1000,
  171. MinWidth = 600,
  172. BaseHeight = 500,
  173. MinHeight = 350,
  174. AllowMaximize = true
  175. },
  176. new Function
  177. {
  178. Name = "Deviation-Claims-Edit",
  179. Description = "Stammdaten editieren",
  180. GroupName = "Deviation-Claims",
  181. IsMenuMember = false,
  182. Plugin = "System"
  183. },
  184. new Function
  185. {
  186. Name = "Appendix",
  187. Description = "Nachträge",
  188. ImageUrl = "~/Content/Images/function-Appendix-32.png",
  189. IsMenuMember = true,
  190. Plugin = "System"
  191. },
  192. new Function
  193. {
  194. Name = "Appendix-Appendices",
  195. Description = "Nachtragsliste",
  196. ImageUrl = "~/Content/Images/function-Appendix-Appendices-32.png",
  197. GroupName = "Appendix",
  198. RouteName = "GreenTree.Nachtragsmanagement.Web.Appendix.Appendices",
  199. IsMenuMember = true,
  200. Plugin = "System",
  201. BaseWidth = 1100,
  202. MinWidth = 800,
  203. BaseHeight = 650,
  204. MinHeight = 500,
  205. AllowMaximize = true
  206. },
  207. new Function
  208. {
  209. Name = "Appendix-Appendices-Edit",
  210. Description = "Nachträge editieren",
  211. GroupName = "Appendix-Appendices",
  212. IsMenuMember = false,
  213. Plugin = "System"
  214. },
  215. new Function
  216. {
  217. Name = "Appendix-Categories",
  218. Description = "Kategorien",
  219. ImageUrl = "~/Content/Images/function-Appendix-Categories-32.png",
  220. GroupName = "Appendix",
  221. RouteName = "GreenTree.Nachtragsmanagement.Web.Appendix.Categories",
  222. IsMenuMember = true,
  223. Plugin = "System",
  224. BaseWidth = 500,
  225. MinWidth = 400,
  226. BaseHeight = 350,
  227. MinHeight = 300,
  228. AllowMaximize = true
  229. },
  230. new Function
  231. {
  232. Name = "Appendix-Categories-Edit",
  233. Description = "Kategorien editieren",
  234. GroupName = "Appendix-Categories",
  235. IsMenuMember = false,
  236. Plugin = "System"
  237. },
  238. new Function
  239. {
  240. Name = "Site",
  241. Description = "Baustellen",
  242. ImageUrl = "~/Content/Images/function-Site-32.png",
  243. IsMenuMember = true,
  244. Plugin = "System"
  245. },
  246. new Function
  247. {
  248. Name = "Site-Sites",
  249. Description = "Baustellenliste",
  250. ImageUrl = "~/Content/Images/function-Site-Sites-32.png",
  251. GroupName = "Site",
  252. RouteName = "GreenTree.Nachtragsmanagement.Web.Site.Sites",
  253. IsMenuMember = true,
  254. Plugin = "System",
  255. BaseWidth = 1100,
  256. MinWidth = 800,
  257. BaseHeight = 650,
  258. MinHeight = 500,
  259. AllowMaximize = true
  260. },
  261. new Function
  262. {
  263. Name = "Site-Sites-Edit",
  264. Description = "Baustellen editieren",
  265. GroupName = "Site-Sites",
  266. IsMenuMember = false,
  267. Plugin = "System"
  268. },
  269. };
  270. }
  271. }
  272. }