FunctionConfig.cs 15 KB

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