FunctionConfig.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  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 = "Site",
  133. Description = "Baustellen",
  134. ImageUrl = "~/Content/Images/function-Site-32.png",
  135. IsMenuMember = true,
  136. Plugin = "System"
  137. },
  138. new Function
  139. {
  140. Name = "Site-Sites",
  141. Description = "Baustellenliste",
  142. ImageUrl = "~/Content/Images/function-Site-Sites-32.png",
  143. GroupName = "Site",
  144. RouteName = "GreenTree.Nachtragsmanagement.Web.Site.Sites",
  145. IsMenuMember = true,
  146. Plugin = "System",
  147. BaseWidth = 1100,
  148. MinWidth = 800,
  149. BaseHeight = 650,
  150. MinHeight = 500,
  151. AllowMaximize = true,
  152. MaximizedOnStart = true
  153. },
  154. new Function
  155. {
  156. Name = "Site-Sites-Edit",
  157. Description = "Baustellen editieren",
  158. GroupName = "Site-Sites",
  159. IsMenuMember = false,
  160. Plugin = "System"
  161. },
  162. new Function
  163. {
  164. Name = "Site-Sites-Delete",
  165. Description = "Baustellen löschen",
  166. GroupName = "Site-Sites",
  167. IsMenuMember = false,
  168. Plugin = "System"
  169. },
  170. new Function
  171. {
  172. Name = "Deviation",
  173. Description = "Vertragsabweichungen",
  174. ImageUrl = "~/Content/Images/function-Deviation-32.png",
  175. IsMenuMember = true,
  176. Plugin = "System"
  177. },
  178. new Function
  179. {
  180. Name = "Deviation-Deviations",
  181. Description = "Vertragsabweichungsliste",
  182. ImageUrl = "~/Content/Images/function-Deviation-Deviations-32.png",
  183. GroupName = "Deviation",
  184. RouteName = "GreenTree.Nachtragsmanagement.Web.Deviation.Deviations",
  185. IsMenuMember = true,
  186. Plugin = "System",
  187. BaseWidth = 1000,
  188. MinWidth = 800,
  189. BaseHeight = 650,
  190. MinHeight = 500,
  191. AllowMaximize = true,
  192. MaximizedOnStart = true
  193. },
  194. new Function
  195. {
  196. Name = "Deviation-Deviations-Edit",
  197. Description = "Vertragsabweichungen editieren",
  198. GroupName = "Deviation-Deviations",
  199. IsMenuMember = false,
  200. Plugin = "System"
  201. },
  202. new Function
  203. {
  204. Name = "Deviation-Claims",
  205. Description = "VA-Stammdaten",
  206. ImageUrl = "~/Content/Images/function-Deviation-Claims-32.png",
  207. GroupName = "Deviation",
  208. RouteName = "GreenTree.Nachtragsmanagement.Web.Deviation.Claims",
  209. IsMenuMember = true,
  210. Plugin = "System",
  211. BaseWidth = 1000,
  212. MinWidth = 600,
  213. BaseHeight = 500,
  214. MinHeight = 350,
  215. AllowMaximize = true
  216. },
  217. new Function
  218. {
  219. Name = "Deviation-Claims-Edit",
  220. Description = "VA-Stammdaten editieren",
  221. GroupName = "Deviation-Claims",
  222. IsMenuMember = false,
  223. Plugin = "System"
  224. },
  225. new Function
  226. {
  227. Name = "Appendix",
  228. Description = "Nachträge",
  229. ImageUrl = "~/Content/Images/function-Appendix-32.png",
  230. IsMenuMember = true,
  231. Plugin = "System"
  232. },
  233. new Function
  234. {
  235. Name = "Appendix-Appendices",
  236. Description = "Nachtragsliste",
  237. ImageUrl = "~/Content/Images/function-Appendix-Appendices-32.png",
  238. GroupName = "Appendix",
  239. RouteName = "GreenTree.Nachtragsmanagement.Web.Appendix.Appendices",
  240. IsMenuMember = true,
  241. Plugin = "System",
  242. BaseWidth = 1100,
  243. MinWidth = 800,
  244. BaseHeight = 650,
  245. MinHeight = 500,
  246. AllowMaximize = true,
  247. MaximizedOnStart = true
  248. },
  249. new Function
  250. {
  251. Name = "Appendix-Appendices-Edit",
  252. Description = "Nachträge editieren",
  253. GroupName = "Appendix-Appendices",
  254. IsMenuMember = false,
  255. Plugin = "System"
  256. },
  257. new Function
  258. {
  259. Name = "Appendix-Claims",
  260. Description = "NT-Stammdaten",
  261. ImageUrl = "~/Content/Images/function-Appendix-Claims-32.png",
  262. GroupName = "Appendix",
  263. RouteName = "GreenTree.Nachtragsmanagement.Web.Appendix.Claims",
  264. IsMenuMember = true,
  265. Plugin = "System",
  266. BaseWidth = 800,
  267. MinWidth = 600,
  268. BaseHeight = 500,
  269. MinHeight = 350,
  270. AllowMaximize = true
  271. },
  272. new Function
  273. {
  274. Name = "Appendix-Claims-Edit",
  275. Description = "NT-Stammdaten editieren",
  276. GroupName = "Appendix-Claims",
  277. IsMenuMember = false,
  278. Plugin = "System"
  279. },
  280. };
  281. }
  282. }
  283. }