FunctionConfig.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383
  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. MaximizedOnStart = true
  84. },
  85. new Function
  86. {
  87. Name = "Administration-Users-Edit",
  88. Description = "Benutzer editieren",
  89. GroupName = "Administration-Users",
  90. IsMenuMember = false,
  91. Plugin = "System"
  92. },
  93. new Function
  94. {
  95. Name = "Administration-Roles",
  96. Description = "Rollenverwaltung",
  97. ImageUrl = "~/Content/Images/function-Administration-Roles-32.png",
  98. GroupName = "Administration",
  99. RouteName = "GreenTree.Nachtragsmanagement.Web.Administration.Roles",
  100. IsMenuMember = true,
  101. Plugin = "System",
  102. BaseWidth = 800,
  103. MinWidth = 600,
  104. BaseHeight = 500,
  105. MinHeight = 400,
  106. AllowMaximize = true,
  107. MaximizedOnStart = true
  108. },
  109. new Function
  110. {
  111. Name = "Administration-Roles-Edit",
  112. Description = "Rollen editieren",
  113. GroupName = "Administration-Roles",
  114. IsMenuMember = false,
  115. Plugin = "System"
  116. },
  117. new Function
  118. {
  119. Name = "Administration-Plugins",
  120. Description = "Pluginverwaltung",
  121. ImageUrl = "~/Content/Images/function-Administration-Plugins-32.png",
  122. GroupName = "Administration",
  123. RouteName = "GreenTree.Nachtragsmanagement.Web.Administration.Plugins",
  124. IsMenuMember = true,
  125. Plugin = "System",
  126. BaseWidth = 800,
  127. MinWidth = 500,
  128. BaseHeight = 450,
  129. MinHeight = 300,
  130. AllowMaximize = true,
  131. MaximizedOnStart = true
  132. },
  133. new Function
  134. {
  135. Name = "Administration-Plugins-Edit",
  136. Description = "Plugins installieren / deinstallieren",
  137. GroupName = "Administration-Plugins",
  138. IsMenuMember = false,
  139. Plugin = "System"
  140. },
  141. new Function
  142. {
  143. Name = "Site",
  144. Description = "Baustellen",
  145. ImageUrl = "~/Content/Images/function-Site-32.png",
  146. IsMenuMember = true,
  147. Plugin = "System"
  148. },
  149. new Function
  150. {
  151. Name = "Site-Sites",
  152. Description = "Baustellenliste",
  153. ImageUrl = "~/Content/Images/function-Site-Sites-32.png",
  154. GroupName = "Site",
  155. RouteName = "GreenTree.Nachtragsmanagement.Web.Site.Sites",
  156. IsMenuMember = true,
  157. Plugin = "System",
  158. BaseWidth = 1100,
  159. MinWidth = 800,
  160. BaseHeight = 650,
  161. MinHeight = 500,
  162. AllowMaximize = true,
  163. MaximizedOnStart = true
  164. },
  165. new Function
  166. {
  167. Name = "Site-Sites-Edit",
  168. Description = "Baustellen editieren",
  169. GroupName = "Site-Sites",
  170. IsMenuMember = false,
  171. Plugin = "System"
  172. },
  173. new Function
  174. {
  175. Name = "Site-Sites-Delete",
  176. Description = "Baustellen löschen",
  177. GroupName = "Site-Sites",
  178. IsMenuMember = false,
  179. Plugin = "System"
  180. },
  181. new Function
  182. {
  183. Name = "Deviation",
  184. Description = "Vertragsabweichungen",
  185. ImageUrl = "~/Content/Images/function-Deviation-32.png",
  186. IsMenuMember = true,
  187. Plugin = "System"
  188. },
  189. new Function
  190. {
  191. Name = "Deviation-Deviations",
  192. Description = "Vertragsabweichungsliste",
  193. ImageUrl = "~/Content/Images/function-Deviation-Deviations-32.png",
  194. GroupName = "Deviation",
  195. RouteName = "GreenTree.Nachtragsmanagement.Web.Deviation.Deviations",
  196. IsMenuMember = true,
  197. Plugin = "System",
  198. BaseWidth = 1000,
  199. MinWidth = 800,
  200. BaseHeight = 650,
  201. MinHeight = 500,
  202. AllowMaximize = true,
  203. MaximizedOnStart = true
  204. },
  205. new Function
  206. {
  207. Name = "Deviation-Deviations-Edit",
  208. Description = "Vertragsabweichungen editieren",
  209. GroupName = "Deviation-Deviations",
  210. IsMenuMember = false,
  211. Plugin = "System"
  212. },
  213. new Function
  214. {
  215. Name = "Deviation-Claims",
  216. Description = "VA-Stammdaten",
  217. ImageUrl = "~/Content/Images/function-Deviation-Claims-32.png",
  218. GroupName = "Deviation",
  219. RouteName = "GreenTree.Nachtragsmanagement.Web.Deviation.Claims",
  220. IsMenuMember = true,
  221. Plugin = "System",
  222. BaseWidth = 1000,
  223. MinWidth = 600,
  224. BaseHeight = 500,
  225. MinHeight = 350,
  226. AllowMaximize = true,
  227. MaximizedOnStart = false
  228. },
  229. new Function
  230. {
  231. Name = "Deviation-Claims-Edit",
  232. Description = "VA-Stammdaten editieren",
  233. GroupName = "Deviation-Claims",
  234. IsMenuMember = false,
  235. Plugin = "System"
  236. },
  237. new Function
  238. {
  239. Name = "Appendix",
  240. Description = "Nachträge",
  241. ImageUrl = "~/Content/Images/function-Appendix-32.png",
  242. IsMenuMember = true,
  243. Plugin = "System"
  244. },
  245. new Function
  246. {
  247. Name = "Appendix-Appendices",
  248. Description = "Nachtragsliste",
  249. ImageUrl = "~/Content/Images/function-Appendix-Appendices-32.png",
  250. GroupName = "Appendix",
  251. RouteName = "GreenTree.Nachtragsmanagement.Web.Appendix.Appendices",
  252. IsMenuMember = true,
  253. Plugin = "System",
  254. BaseWidth = 1100,
  255. MinWidth = 800,
  256. BaseHeight = 650,
  257. MinHeight = 500,
  258. AllowMaximize = true,
  259. MaximizedOnStart = true
  260. },
  261. new Function
  262. {
  263. Name = "Appendix-Appendices-Edit",
  264. Description = "Nachträge editieren",
  265. GroupName = "Appendix-Appendices",
  266. IsMenuMember = false,
  267. Plugin = "System"
  268. },
  269. new Function
  270. {
  271. Name = "Appendix-Claims",
  272. Description = "NT-Stammdaten",
  273. ImageUrl = "~/Content/Images/function-Appendix-Claims-32.png",
  274. GroupName = "Appendix",
  275. RouteName = "GreenTree.Nachtragsmanagement.Web.Appendix.Claims",
  276. IsMenuMember = true,
  277. Plugin = "System",
  278. BaseWidth = 800,
  279. MinWidth = 600,
  280. BaseHeight = 500,
  281. MinHeight = 350,
  282. AllowMaximize = true,
  283. MaximizedOnStart = false
  284. },
  285. new Function
  286. {
  287. Name = "Appendix-Claims-Edit",
  288. Description = "NT-Stammdaten editieren",
  289. GroupName = "Appendix-Claims",
  290. IsMenuMember = false,
  291. Plugin = "System"
  292. },
  293. new Function
  294. {
  295. Name = "Misc",
  296. Description = "Sonstiges",
  297. ImageUrl = "~/Content/Images/function-Misc-32.png",
  298. IsMenuMember = true,
  299. Plugin = "System"
  300. },
  301. new Function
  302. {
  303. Name = "Misc-MailNotifications",
  304. Description = "Benachrichtigungen",
  305. ImageUrl = "~/Content/Images/function-Misc-MailNotifications-32.png",
  306. GroupName = "Misc",
  307. RouteName = "GreenTree.Nachtragsmanagement.Web.Misc.MailNotifications",
  308. IsMenuMember = true,
  309. Plugin = "System",
  310. BaseWidth = 900,
  311. MinWidth = 700,
  312. BaseHeight = 550,
  313. MinHeight = 450,
  314. AllowMaximize = true,
  315. MaximizedOnStart = true
  316. },
  317. new Function
  318. {
  319. Name = "Misc-MailNotifications-Edit",
  320. Description = "Benachrichtigungen editieren",
  321. GroupName = "Misc-MailNotifications",
  322. IsMenuMember = false,
  323. Plugin = "System"
  324. },
  325. new Function
  326. {
  327. Name = "Misc-Logs",
  328. Description = "Logs",
  329. ImageUrl = "~/Content/Images/function-Misc-Logs-32.png",
  330. GroupName = "Misc",
  331. RouteName = "GreenTree.Nachtragsmanagement.Web.Misc.Logs",
  332. IsMenuMember = true,
  333. Plugin = "System",
  334. BaseWidth = 900,
  335. MinWidth = 700,
  336. BaseHeight = 550,
  337. MinHeight = 450,
  338. AllowMaximize = true,
  339. MaximizedOnStart = true
  340. },
  341. new Function
  342. {
  343. Name = "Misc-Logs-Delete",
  344. Description = "Logs löschen",
  345. GroupName = "Misc-Logs",
  346. IsMenuMember = false,
  347. Plugin = "System"
  348. },
  349. new Function
  350. {
  351. Name = "Misc-ConfigItems",
  352. Description = "Einstellungen",
  353. ImageUrl = "~/Content/Images/function-Misc-ConfigItems-32.png",
  354. GroupName = "Misc",
  355. RouteName = "GreenTree.Nachtragsmanagement.Web.Misc.ConfigItems",
  356. IsMenuMember = true,
  357. Plugin = "System",
  358. BaseWidth = 900,
  359. MinWidth = 700,
  360. BaseHeight = 550,
  361. MinHeight = 450,
  362. AllowMaximize = true,
  363. MaximizedOnStart = true
  364. },
  365. new Function
  366. {
  367. Name = "Misc-ConfigItems-Edit",
  368. Description = "Einstellungen ändern",
  369. GroupName = "Misc-ConfigItems",
  370. IsMenuMember = false,
  371. Plugin = "System"
  372. }
  373. };
  374. }
  375. }
  376. }