FunctionConfig.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407
  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-Edit-Comment",
  176. Description = "Baustellen Kommentar editieren",
  177. GroupName = "Site-Sites",
  178. IsMenuMember = false,
  179. Plugin = "System"
  180. },
  181. new Function
  182. {
  183. Name = "Site-Sites-Delete",
  184. Description = "Baustellen löschen",
  185. GroupName = "Site-Sites",
  186. IsMenuMember = false,
  187. Plugin = "System"
  188. },
  189. new Function
  190. {
  191. Name = "Deviation",
  192. Description = "Vertragsabweichungen",
  193. ImageUrl = "~/Content/Images/function-Deviation-32.png",
  194. IsMenuMember = true,
  195. Plugin = "System"
  196. },
  197. new Function
  198. {
  199. Name = "Deviation-Deviations",
  200. Description = "Vertragsabweichungsliste",
  201. ImageUrl = "~/Content/Images/function-Deviation-Deviations-32.png",
  202. GroupName = "Deviation",
  203. RouteName = "GreenTree.Nachtragsmanagement.Web.Deviation.Deviations",
  204. IsMenuMember = true,
  205. Plugin = "System",
  206. BaseWidth = 1000,
  207. MinWidth = 800,
  208. BaseHeight = 650,
  209. MinHeight = 500,
  210. AllowMaximize = true,
  211. MaximizedOnStart = true
  212. },
  213. new Function
  214. {
  215. Name = "Deviation-Deviations-Edit",
  216. Description = "Vertragsabweichungen editieren",
  217. GroupName = "Deviation-Deviations",
  218. IsMenuMember = false,
  219. Plugin = "System"
  220. },
  221. new Function
  222. {
  223. Name = "Deviation-Deviations-Edit-Comment",
  224. Description = "Vertragsabweichungen Kommentar editieren",
  225. GroupName = "Deviation-Deviations",
  226. IsMenuMember = false,
  227. Plugin = "System"
  228. },
  229. new Function
  230. {
  231. Name = "Deviation-Claims",
  232. Description = "VA-Stammdaten",
  233. ImageUrl = "~/Content/Images/function-Deviation-Claims-32.png",
  234. GroupName = "Deviation",
  235. RouteName = "GreenTree.Nachtragsmanagement.Web.Deviation.Claims",
  236. IsMenuMember = true,
  237. Plugin = "System",
  238. BaseWidth = 1000,
  239. MinWidth = 600,
  240. BaseHeight = 500,
  241. MinHeight = 350,
  242. AllowMaximize = true,
  243. MaximizedOnStart = false
  244. },
  245. new Function
  246. {
  247. Name = "Deviation-Claims-Edit",
  248. Description = "VA-Stammdaten editieren",
  249. GroupName = "Deviation-Claims",
  250. IsMenuMember = false,
  251. Plugin = "System"
  252. },
  253. new Function
  254. {
  255. Name = "Appendix",
  256. Description = "Nachträge",
  257. ImageUrl = "~/Content/Images/function-Appendix-32.png",
  258. IsMenuMember = true,
  259. Plugin = "System"
  260. },
  261. new Function
  262. {
  263. Name = "Appendix-Appendices",
  264. Description = "Nachtragsliste",
  265. ImageUrl = "~/Content/Images/function-Appendix-Appendices-32.png",
  266. GroupName = "Appendix",
  267. RouteName = "GreenTree.Nachtragsmanagement.Web.Appendix.Appendices",
  268. IsMenuMember = true,
  269. Plugin = "System",
  270. BaseWidth = 1100,
  271. MinWidth = 800,
  272. BaseHeight = 650,
  273. MinHeight = 500,
  274. AllowMaximize = true,
  275. MaximizedOnStart = true
  276. },
  277. new Function
  278. {
  279. Name = "Appendix-Appendices-Edit",
  280. Description = "Nachträge editieren",
  281. GroupName = "Appendix-Appendices",
  282. IsMenuMember = false,
  283. Plugin = "System"
  284. },
  285. new Function
  286. {
  287. Name = "Appendix-Appendices-Edit-Comment",
  288. Description = "Nachträge Kommentar editieren",
  289. GroupName = "Appendix-Appendices",
  290. IsMenuMember = false,
  291. Plugin = "System"
  292. },
  293. new Function
  294. {
  295. Name = "Appendix-Claims",
  296. Description = "NT-Stammdaten",
  297. ImageUrl = "~/Content/Images/function-Appendix-Claims-32.png",
  298. GroupName = "Appendix",
  299. RouteName = "GreenTree.Nachtragsmanagement.Web.Appendix.Claims",
  300. IsMenuMember = true,
  301. Plugin = "System",
  302. BaseWidth = 800,
  303. MinWidth = 600,
  304. BaseHeight = 500,
  305. MinHeight = 350,
  306. AllowMaximize = true,
  307. MaximizedOnStart = false
  308. },
  309. new Function
  310. {
  311. Name = "Appendix-Claims-Edit",
  312. Description = "NT-Stammdaten editieren",
  313. GroupName = "Appendix-Claims",
  314. IsMenuMember = false,
  315. Plugin = "System"
  316. },
  317. new Function
  318. {
  319. Name = "Misc",
  320. Description = "Sonstiges",
  321. ImageUrl = "~/Content/Images/function-Misc-32.png",
  322. IsMenuMember = true,
  323. Plugin = "System"
  324. },
  325. new Function
  326. {
  327. Name = "Misc-MailNotifications",
  328. Description = "Benachrichtigungen",
  329. ImageUrl = "~/Content/Images/function-Misc-MailNotifications-32.png",
  330. GroupName = "Misc",
  331. RouteName = "GreenTree.Nachtragsmanagement.Web.Misc.MailNotifications",
  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-MailNotifications-Edit",
  344. Description = "Benachrichtigungen editieren",
  345. GroupName = "Misc-MailNotifications",
  346. IsMenuMember = false,
  347. Plugin = "System"
  348. },
  349. new Function
  350. {
  351. Name = "Misc-Logs",
  352. Description = "Logs",
  353. ImageUrl = "~/Content/Images/function-Misc-Logs-32.png",
  354. GroupName = "Misc",
  355. RouteName = "GreenTree.Nachtragsmanagement.Web.Misc.Logs",
  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-Logs-Delete",
  368. Description = "Logs löschen",
  369. GroupName = "Misc-Logs",
  370. IsMenuMember = false,
  371. Plugin = "System"
  372. },
  373. new Function
  374. {
  375. Name = "Misc-ConfigItems",
  376. Description = "Einstellungen",
  377. ImageUrl = "~/Content/Images/function-Misc-ConfigItems-32.png",
  378. GroupName = "Misc",
  379. RouteName = "GreenTree.Nachtragsmanagement.Web.Misc.ConfigItems",
  380. IsMenuMember = true,
  381. Plugin = "System",
  382. BaseWidth = 900,
  383. MinWidth = 700,
  384. BaseHeight = 550,
  385. MinHeight = 450,
  386. AllowMaximize = true,
  387. MaximizedOnStart = true
  388. },
  389. new Function
  390. {
  391. Name = "Misc-ConfigItems-Edit",
  392. Description = "Einstellungen ändern",
  393. GroupName = "Misc-ConfigItems",
  394. IsMenuMember = false,
  395. Plugin = "System"
  396. }
  397. };
  398. }
  399. }
  400. }