Global.asax.cs 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.Http;
  6. using System.Web.Mvc;
  7. using System.Web.Routing;
  8. using GreenTree.Nachtragsmanagement.Web.Framework;
  9. using GreenTree.Nachtragsmanagement.Core.Domain;
  10. using System.Reflection;
  11. using GreenTree.Nachtragsmanagement.Core;
  12. using Autofac;
  13. using GreenTree.Nachtragsmanagement.Web.Framework.Mvc.Routes;
  14. using GreenTree.Nachtragsmanagement.Web.App_Start;
  15. using System.Web.Optimization;
  16. using FluentValidation.Mvc;
  17. using GreenTree.Nachtragsmanagement.Web.Validation;
  18. using GreenTree.Nachtragsmanagement.Services.User;
  19. using GreenTree.Nachtragsmanagement.Data;
  20. using GreenTree.Nachtragsmanagement.Core.Domain.Misc;
  21. using GreenTree.Nachtragsmanagement.Core.Domain.User;
  22. using GreenTree.Nachtragsmanagement.Core.Domain.Deviation;
  23. using GreenTree.Nachtragsmanagement.Services.Deviation;
  24. using GreenTree.Nachtragsmanagement.Core.Domain.Site;
  25. using GreenTree.Nachtragsmanagement.Core.Domain.Appendix;
  26. using GreenTree.Nachtragsmanagement.Services.Appendix;
  27. using GreenTree.Nachtragsmanagement.Services.Site;
  28. using GreenTree.Nachtragsmanagement.Core.Plugins;
  29. using GreenTree.Nachtragsmanagement.Services.Configuration;
  30. using GreenTree.Nachtragsmanagement.Core.Domain.Config;
  31. using GreenTree.Nachtragsmanagement.Services.Misc;
  32. using GreenTree.Nachtragsmanagement.Services.Scheduling;
  33. using GreenTree.Nachtragsmanagement.Services.Logging;
  34. using GreenTree.Nachtragsmanagement.Web.Extensions;
  35. namespace GreenTree.Nachtragsmanagement.Web
  36. {
  37. // Note: For instructions on enabling IIS6 or IIS7 classic mode,
  38. // visit http://go.microsoft.com/?LinkId=9394801
  39. public class MvcApplication : System.Web.HttpApplication
  40. {
  41. protected void Application_Start()
  42. {
  43. try
  44. {
  45. AreaRegistration.RegisterAllAreas();
  46. GlobalConfiguration.Configure(WebApiConfig.Register);
  47. FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
  48. RouteConfig.RegisterRoutes(RouteTable.Routes);
  49. BundleConfig.RegisterBundles(BundleTable.Bundles);
  50. ModelBinders.Binders.DefaultBinder = new DevExpress.Web.Mvc.DevExpressEditorsBinder();
  51. ApplicationContext.InitApplication();
  52. ApplicationContext.InitPluginRoutes(RouteTable.Routes);
  53. var logger = Singleton<IContainer>.Instance.Resolve<ILogger>();
  54. FunctionConfig.RegisterFunctions();
  55. FluentValidationModelValidatorProvider.Configure(provider =>
  56. {
  57. provider.ValidatorFactory = new AppendixValidatorFactory();
  58. });
  59. var notificationScheduler = Singleton<IContainer>.Instance.Resolve<INotificationScheduler>();
  60. if (notificationScheduler != null)
  61. notificationScheduler.Start();
  62. GridViewSettingsHelper._configurationService = Singleton<IContainer>.Instance.Resolve<IConfigurationService>();
  63. logger.Information("Anwendung erfolgreich gestartet.");
  64. }
  65. catch (Exception ex)
  66. {
  67. var logger = Singleton<IContainer>.Instance.Resolve<ILogger>();
  68. if (logger != null)
  69. logger.Fatal("Fehler bei Start der Anwendung.", ex, null);
  70. }
  71. DevExpress.Web.ASPxWebControl.CallbackError += Application_Error;
  72. //GenerateTestData();
  73. }
  74. /// <summary>
  75. /// Event handler for general exceptions
  76. /// </summary>
  77. /// <param name="sender"></param>
  78. /// <param name="e"></param>
  79. protected void Application_Error(object sender, EventArgs e)
  80. {
  81. var logger = Singleton<IContainer>.Instance.Resolve<ILogger>();
  82. var exception = HttpContext.Current.Server.GetLastError();
  83. if (logger != null)
  84. logger.Error("Allgemeiner Fehler aufgetreten.", exception, null);
  85. }
  86. #region Test
  87. /// <summary>
  88. /// Generates test data for testing the application
  89. /// </summary>
  90. private void GenerateTestData()
  91. {
  92. // Get services
  93. var userService = Singleton<IContainer>.Instance.Resolve<IUserService>();
  94. var deviationService = Singleton<IContainer>.Instance.Resolve<IDeviationService>();
  95. var appendixService = Singleton<IContainer>.Instance.Resolve<IAppendixService>();
  96. var siteService = Singleton<IContainer>.Instance.Resolve<ISiteService>();
  97. var configurationService = Singleton<IContainer>.Instance.Resolve<IConfigurationService>();
  98. var miscService = Singleton<IContainer>.Instance.Resolve<IMiscService>();
  99. var dbContext = Singleton<IContainer>.Instance.Resolve<IDbContext>();
  100. try
  101. {
  102. // Check if test data is already created
  103. var isTestDataGeneratedEntity = dbContext.Get<DbContextSpec>().FirstOrDefault(d => d.Name == "IsTestDataGenerated");
  104. if (isTestDataGeneratedEntity != null && Convert.ToBoolean(isTestDataGeneratedEntity.Value))
  105. return;
  106. // Create roles
  107. var r1 = new Role
  108. {
  109. Description = "Administrator",
  110. Level = 100,
  111. SeeOnlyAssigned = false
  112. };
  113. userService.InsertRole(r1);
  114. var r2 = new Role
  115. {
  116. Description = "Kaufmann",
  117. Level = 10,
  118. SeeOnlyAssigned = true
  119. };
  120. userService.InsertRole(r2);
  121. var r3 = new Role
  122. {
  123. Description = "Nachtragsmanager",
  124. Level = 10,
  125. SeeOnlyAssigned = false
  126. };
  127. userService.InsertRole(r3);
  128. var r4 = new Role
  129. {
  130. Description = "Bauleiter",
  131. Level = 10,
  132. SeeOnlyAssigned = true
  133. };
  134. userService.InsertRole(r4);
  135. // Create users
  136. var u1 = new User
  137. {
  138. Forename = "Arne",
  139. Lastname = "Diekmann",
  140. CustomNumber = "a.diekmann",
  141. MailAddress = "a.diekmann@greentreestudios.de",
  142. Password = StaticHelper.GetMD5Hash("14595809")
  143. };
  144. userService.InsertUser(u1);
  145. var u2 = new User
  146. {
  147. Forename = "Rocco",
  148. Lastname = "Lavella",
  149. CustomNumber = "r.lavella",
  150. MailAddress = "lavella@schweerbau.de",
  151. Password = StaticHelper.GetMD5Hash("lavella")
  152. };
  153. userService.InsertUser(u2);
  154. var u3 = new User
  155. {
  156. Forename = "Felix",
  157. Lastname = "Bramstedt",
  158. CustomNumber = "f.bramstedt",
  159. MailAddress = "bramstedt@schweerbau.de",
  160. Password = StaticHelper.GetMD5Hash("bramstedt")
  161. };
  162. userService.InsertUser(u3);
  163. var u4 = new User
  164. {
  165. Forename = "Kletus",
  166. Lastname = "Lingemann",
  167. CustomNumber = "k.lingemann",
  168. MailAddress = "lingemann@schweerbau.de",
  169. Password = StaticHelper.GetMD5Hash("lingemann")
  170. };
  171. userService.InsertUser(u4);
  172. var u5 = new User
  173. {
  174. Forename = "Max",
  175. Lastname = "Moede",
  176. CustomNumber = "m.moede",
  177. MailAddress = "moede@schweerbau.de",
  178. Password = StaticHelper.GetMD5Hash("moede")
  179. };
  180. userService.InsertUser(u5);
  181. var u6 = new User
  182. {
  183. Forename = "Max",
  184. Lastname = "Dammeier",
  185. CustomNumber = "m.dammeier",
  186. MailAddress = "dammeier@schweerbau.de",
  187. Password = StaticHelper.GetMD5Hash("dammeier")
  188. };
  189. userService.InsertUser(u6);
  190. var u7 = new User
  191. {
  192. Forename = "Max",
  193. Lastname = "Poppe",
  194. CustomNumber = "m.poppe",
  195. MailAddress = "poppe@schweerbau.de",
  196. Password = StaticHelper.GetMD5Hash("poppe")
  197. };
  198. userService.InsertUser(u7);
  199. var u8 = new User
  200. {
  201. Forename = "Max",
  202. Lastname = "Lehmann",
  203. CustomNumber = "m.lehmann",
  204. MailAddress = "lehmann@schweerbau.de",
  205. Password = StaticHelper.GetMD5Hash("poppe")
  206. };
  207. userService.InsertUser(u8);
  208. var u9 = new User
  209. {
  210. Forename = "Max",
  211. Lastname = "Wernecke",
  212. CustomNumber = "m.wernecke",
  213. MailAddress = "wernecke@schweerbau.de",
  214. Password = StaticHelper.GetMD5Hash("wernecke")
  215. };
  216. userService.InsertUser(u9);
  217. // Add users to roles
  218. u1.Roles.Add(r1);
  219. u2.Roles.Add(r1);
  220. u3.Roles.Add(r1);
  221. u4.Roles.Add(r3);
  222. u8.Roles.Add(r3);
  223. u5.Roles.Add(r4);
  224. u7.Roles.Add(r4);
  225. u6.Roles.Add(r2);
  226. u9.Roles.Add(r2);
  227. // Get all functions and add them to the admin role
  228. var allFunctions = userService.GetAllFunctions();
  229. r1.SetFunctions(allFunctions);
  230. userService.UpdateRole(r1);
  231. // Get all appendix manager function and add them to the apendix manager / merchant role
  232. var deviationFunctions = allFunctions
  233. .Where(f => f.Name.StartsWith("Deviation"));
  234. foreach (var function in deviationFunctions)
  235. {
  236. r2.Functions.Add(function);
  237. r3.Functions.Add(function);
  238. r4.Functions.Add(function);
  239. }
  240. var appendixFunctions = allFunctions
  241. .Where(f => f.Name.StartsWith("Appendix"));
  242. foreach (var function in appendixFunctions)
  243. {
  244. r2.Functions.Add(function);
  245. r3.Functions.Add(function);
  246. r4.Functions.Add(function);
  247. }
  248. var siteFunctions = allFunctions
  249. .Where(f => f.Name.StartsWith("Site") && f.Name != "Site-Sites-Delete");
  250. foreach (var function in siteFunctions)
  251. {
  252. r2.Functions.Add(function);
  253. r3.Functions.Add(function);
  254. r4.Functions.Add(function);
  255. }
  256. userService.UpdateRole(r2);
  257. userService.UpdateRole(r3);
  258. userService.UpdateRole(r4);
  259. // Create appendix base data
  260. var categories = new[]
  261. {
  262. new Category { Description = "RPM" },
  263. new Category { Description = "RM" },
  264. new Category { Description = "Stopftechnik" },
  265. new Category { Description = "Umbauzug" },
  266. new Category { Description = "Logistik" },
  267. new Category { Description = "Oberbau" },
  268. new Category { Description = "Erdbau" },
  269. new Category { Description = "Kabeltiefbau" },
  270. new Category { Description = "Entwässerung" },
  271. new Category { Description = "Sonstiges" }
  272. };
  273. foreach (var category in categories)
  274. appendixService.InsertCategory(category);
  275. var states = new[]
  276. {
  277. new State { Description = "Offen", IsDefault = true, HexColor = "#FFFFFF" },
  278. new State { Description = "Erinnerung Verhandlung", IsDefault = false, HexColor = "#FF817F" },
  279. new State { Description = "Verhandelt", IsDefault = false, HexColor = "#E5E5E5" },
  280. new State { Description = "Erledigt / Entfällt", IsDefault = false, HexColor = "#8ECC8E" }
  281. };
  282. foreach (var state in states)
  283. appendixService.InsertState(state);
  284. var appendices = new[]
  285. {
  286. new Appendix
  287. {
  288. CustomNumber = "3",
  289. Description = "Lückenschluss Weiche 523",
  290. State = states[0],
  291. StateId = states[0].Id,
  292. CategoryValues =
  293. {
  294. new CategoryValue { Category = categories[2], CategoryId = categories[2].Id, Value = 44000 },
  295. new CategoryValue { Category = categories[3], CategoryId = categories[3].Id, Value = 30000 },
  296. },
  297. Value = Convert.ToDecimal(74833.6),
  298. Percentage = (decimal)0.5,
  299. NegotiationValue = 70000,
  300. OfferingDate = new DateTime(2016, 12, 20),
  301. Comment = "hier 3 % NA enthalten = Delta zu iTWO = 77148,04€, Abgabeddatum per Mail, Post später"
  302. },
  303. new Appendix
  304. {
  305. CustomNumber = "6",
  306. Description = "Erschwerniss masch. Gleisbau ZEB 22",
  307. State = states[0],
  308. StateId = states[0].Id,
  309. CategoryValues =
  310. {
  311. new CategoryValue { Category = categories[0], CategoryId = categories[0].Id, Value = 43000 }
  312. },
  313. Value = Convert.ToDecimal(43514.35),
  314. Percentage = (decimal)0.5,
  315. NegotiationValue = 40000,
  316. OfferingDate = new DateTime(2016, 12, 20),
  317. Comment = "Teilweise Abrechnung über HLV in Höhe von 5322,12€ (nicht in Summe oben enthalten) hier 3 % NA enthalten = Delta zu iTWO = 44860,15€ Abgabeddatum per Mail, Post später"
  318. },
  319. new Appendix
  320. {
  321. CustomNumber = "1",
  322. Description = "Umsetzen von Haufwerken",
  323. State = states[0],
  324. StateId = states[0].Id,
  325. CategoryValues =
  326. {
  327. new CategoryValue { Category = categories[9], CategoryId = categories[9].Id, Value = 2500 }
  328. },
  329. Value = Convert.ToDecimal(2549.18),
  330. Percentage = (decimal)0.5,
  331. NegotiationValue = 2000,
  332. OfferingDate = new DateTime(2017, 2, 2),
  333. Comment = "Beginn der Frist der Nachtragsprüfung 16.02.17"
  334. },
  335. new Appendix
  336. {
  337. CustomNumber = "2",
  338. Description = "Nichtbereitstellung der Ladevorrichtung",
  339. State = states[0],
  340. StateId = states[0].Id,
  341. CategoryValues =
  342. {
  343. new CategoryValue { Category = categories[4], CategoryId = categories[4].Id }
  344. },
  345. Value = Convert.ToDecimal(23738.06),
  346. Percentage = (decimal)0.5,
  347. NegotiationValue = 20000,
  348. OfferingDate = new DateTime(2017, 2, 3),
  349. Comment = "Aufmaße noch nicht erstellt"
  350. }
  351. };
  352. foreach (var appendix in appendices)
  353. appendixService.InsertAppendix(appendix);
  354. // Create site base data
  355. var sites = new[]
  356. {
  357. new Site
  358. {
  359. CustomNumber = "2101000",
  360. Description = "POS Nord Kaiserslautern Los 19-21",
  361. Appendices =
  362. {
  363. appendices[0],
  364. appendices[1]
  365. },
  366. Finished = false,
  367. Start = new DateTime(2016, 1, 1),
  368. Users =
  369. {
  370. u4,
  371. u5,
  372. u6
  373. }
  374. },
  375. new Site
  376. {
  377. CustomNumber = "211200",
  378. Description = "GE Geisenheim-Rüdesheim",
  379. Appendices =
  380. {
  381. appendices[2],
  382. appendices[3]
  383. },
  384. Finished = false,
  385. Start = new DateTime(2016, 1, 1),
  386. Users =
  387. {
  388. u7,
  389. u8,
  390. u9
  391. }
  392. }
  393. };
  394. foreach (var site in sites)
  395. siteService.InsertSite(site);
  396. // Create deviation base data
  397. var kinds = new[]
  398. {
  399. new Kind { Shortance = "MK", Description = "Mehrkosten", IsDefault = true },
  400. new Kind { Shortance = "BH", Description = "Behinderung", IsDefault = false },
  401. new Kind { Shortance = "BD", Description = "Bedenken", IsDefault = false }
  402. };
  403. foreach (var kind in kinds)
  404. deviationService.InsertKind(kind);
  405. var disturbances = new[]
  406. {
  407. new Disturbance { Description = "RPM" },
  408. new Disturbance { Description = "RM" },
  409. new Disturbance { Description = "Stopftechnik" },
  410. new Disturbance { Description = "Umbauzug" },
  411. new Disturbance { Description = "Logistik" },
  412. new Disturbance { Description = "Oberbau" },
  413. new Disturbance { Description = "Erdbau" },
  414. new Disturbance { Description = "Kabeltiefbau" },
  415. new Disturbance { Description = "Entwässerung" },
  416. new Disturbance { Description = "Sonstiges" }
  417. };
  418. foreach (var disturbance in disturbances)
  419. deviationService.InsertDisturbance(disturbance);
  420. var statuses = new[]
  421. {
  422. new Status { Description = "Standard", IsDefault = true },
  423. new Status { Description = "Entfällt", IsDefault = false },
  424. new Status { Description = "Strittig", IsDefault = false },
  425. new Status { Description = "Abr. über HLV", IsDefault = false }
  426. };
  427. foreach (var status in statuses)
  428. deviationService.InsertStatus(status);
  429. var deviations = new[]
  430. {
  431. new Deviation
  432. {
  433. CustomNumber = "1",
  434. Description = "Mehrleistung Stopfen",
  435. Kind = kinds[0],
  436. KindId = kinds[0].Id,
  437. DisturbanceValues =
  438. {
  439. new DisturbanceValue { Disturbance = disturbances[2], DisturbanceId = disturbances[2].Id, Value = 40000 }
  440. },
  441. Status = statuses[0],
  442. StatusId = statuses[0].Id,
  443. Value = 40000,
  444. Percentage = 1,
  445. ReceiptDate = new DateTime(2016, 8, 1),
  446. Appendix = appendices[0],
  447. AppendixId = appendices[0].Id,
  448. AppendixDate = appendices[0].OfferingDate
  449. },
  450. new Deviation
  451. {
  452. CustomNumber = "2",
  453. Description = "Bodenausbau konventionell",
  454. Kind = kinds[0],
  455. KindId = kinds[0].Id,
  456. DisturbanceValues =
  457. {
  458. new DisturbanceValue { Disturbance = disturbances[6], DisturbanceId = disturbances[6].Id, Value = 30000 }
  459. },
  460. Status = statuses[1],
  461. StatusId = statuses[1].Id,
  462. Value = 30000,
  463. Percentage = 0,
  464. ReceiptDate = new DateTime(2016, 8, 10),
  465. Appendix = appendices[0],
  466. AppendixId = appendices[0].Id,
  467. AppendixDate = appendices[0].OfferingDate
  468. },
  469. new Deviation
  470. {
  471. CustomNumber = "3",
  472. Description = "Einbau PSS im Weichenbereich",
  473. Kind = kinds[0],
  474. KindId = kinds[0].Id,
  475. DisturbanceValues =
  476. {
  477. new DisturbanceValue { Disturbance = disturbances[6], DisturbanceId = disturbances[6].Id, Value = 2000 }
  478. },
  479. Status = statuses[0],
  480. StatusId = statuses[0].Id,
  481. Value = 2000,
  482. Percentage = 1,
  483. ReceiptDate = new DateTime(2016, 8, 15),
  484. Appendix = appendices[1],
  485. AppendixId = appendices[1].Id,
  486. AppendixDate = appendices[1].OfferingDate
  487. },
  488. new Deviation
  489. {
  490. CustomNumber = "4",
  491. Description = "Hindernisse bei der PLV mit RPM",
  492. Kind = kinds[1],
  493. KindId = kinds[1].Id,
  494. DisturbanceValues =
  495. {
  496. new DisturbanceValue { Disturbance = disturbances[0], DisturbanceId = disturbances[0].Id, Value = 40000 }
  497. },
  498. Status = statuses[2],
  499. StatusId = statuses[2].Id,
  500. Value = 40000,
  501. Percentage = (decimal)0.3,
  502. ReceiptDate = new DateTime(2016, 8, 20),
  503. Site = sites[0],
  504. SiteId = sites[0].Id
  505. },
  506. new Deviation
  507. {
  508. CustomNumber = "1",
  509. Description = "Umsetzen von Haufwerken",
  510. Kind = kinds[0],
  511. KindId = kinds[0].Id,
  512. DisturbanceValues =
  513. {
  514. new DisturbanceValue { Disturbance = disturbances[6], DisturbanceId = disturbances[6].Id, Value = 2500 }
  515. },
  516. Status = statuses[0],
  517. StatusId = statuses[0].Id,
  518. Value = 2500,
  519. Percentage = 1,
  520. ReceiptDate = new DateTime(2017, 1, 5),
  521. Appendix = appendices[2],
  522. AppendixId = appendices[2].Id,
  523. AppendixDate = appendices[2].OfferingDate
  524. },
  525. new Deviation
  526. {
  527. CustomNumber = "2",
  528. Description = "Nichtbereitsstellung der Ladevorrichtung Nr. 1",
  529. Kind = kinds[0],
  530. KindId = kinds[0].Id,
  531. DisturbanceValues =
  532. {
  533. new DisturbanceValue { Disturbance = disturbances[5], DisturbanceId = disturbances[5].Id, Value = 10000 }
  534. },
  535. Status = statuses[0],
  536. StatusId = statuses[0].Id,
  537. Value = 10000,
  538. Percentage = 1,
  539. ReceiptDate = new DateTime(2017, 1, 7),
  540. Appendix = appendices[3],
  541. AppendixId = appendices[3].Id,
  542. AppendixDate = appendices[3].OfferingDate
  543. },
  544. new Deviation
  545. {
  546. CustomNumber = "5",
  547. Description = "Nichtbereitsstellung der Ladevorrichtung Nr. 2",
  548. Kind = kinds[0],
  549. KindId = kinds[0].Id,
  550. DisturbanceValues =
  551. {
  552. new DisturbanceValue { Disturbance = disturbances[5], DisturbanceId = disturbances[5].Id, Value = 10000 }
  553. },
  554. Status = statuses[3],
  555. StatusId = statuses[3].Id,
  556. Value = 10000,
  557. Percentage = 1,
  558. ReceiptDate = new DateTime(2017, 1, 10),
  559. Appendix = appendices[3],
  560. AppendixId = appendices[3].Id,
  561. AppendixDate = appendices[3].OfferingDate
  562. },
  563. new Deviation
  564. {
  565. CustomNumber = "6",
  566. Description = "Verspannung Los 2",
  567. Kind = kinds[0],
  568. KindId = kinds[0].Id,
  569. DisturbanceValues =
  570. {
  571. new DisturbanceValue { Disturbance = disturbances[5], DisturbanceId = disturbances[5].Id, Value = 6000 }
  572. },
  573. Status = statuses[2],
  574. StatusId = statuses[2].Id,
  575. Value = 6000,
  576. Percentage = (decimal)0.5,
  577. ReceiptDate = new DateTime(2017, 1, 12),
  578. Site = sites[1],
  579. SiteId = sites[1].Id
  580. }
  581. };
  582. foreach (var deviation in deviations)
  583. deviationService.InsertDeviation(deviation);
  584. // Create config base data
  585. var configItems = new[]
  586. {
  587. new ConfigItem
  588. {
  589. Name = "GreenTree.Nachtragsmanagement.AppendixNotificationPlugin.ProcessNegotiationDate.AgeDays",
  590. TypeFullName = "System.Int32",
  591. Value = "56",
  592. Description =
  593. "Die Anzahl der Tage ab dem Angebotstermin eines Nachtrags, damit er bei der Überprüfung des " +
  594. "Verhandlungsdatums mit berücksichtigt werden soll"
  595. },
  596. new ConfigItem
  597. {
  598. Name = "GreenTree.Nachtragsmanagement.AppendixNotificationPlugin.ProcessNegotiationDate.StateSet",
  599. TypeFullName = "System.Int32",
  600. Value = states[1].Id.ToString(),
  601. Description =
  602. "Die ID des Nachtragsstatus, auf den der Nachtrag gesetzt wird, nachdem er bei der Überprüfung des " +
  603. "Verhandlungsdatums geprüft wurde"
  604. },
  605. new ConfigItem
  606. {
  607. Name = "GreenTree.Nachtragsmanagement.AppendixNotificationPlugin.ProcessNegotiationDate.Interval",
  608. TypeFullName = "System.Int32",
  609. Value = "2",
  610. Description =
  611. "Der Wocheninterval, in dem weitere Benachrichtigungen über nicht verhandelte Nachträge gesendet werden " +
  612. "soll"
  613. },
  614. new ConfigItem
  615. {
  616. Name = "GreenTree.Nachtragsmanagement.AppendixNotificationPlugin.ProcessNegotiationProtocol.AgeDays",
  617. TypeFullName = "System.Int32",
  618. Value = "14",
  619. Description =
  620. "Die Anzahl der Tage ab dem Verhandlungstermin eines Nachtrags, damit er bei der Überprüfung des " +
  621. "Protokolls mit berücksichtigt werden soll"
  622. },
  623. new ConfigItem
  624. {
  625. Name = "GreenTree.Nachtragsmanagement.AppendixNotificationPlugin.ProcessNegotiationProtocol.StateCondition",
  626. TypeFullName = "System.Int32",
  627. Value = states[2].Id.ToString(),
  628. Description =
  629. "Die ID des Nachtragsstatus, den ein Nachtrag haben muss, damit er bei der Überprüfung des " +
  630. "Verhandlungsprotokolls mit berücksichtigt werden soll"
  631. },
  632. new ConfigItem
  633. {
  634. Name = "GreenTree.Nachtragsmanagement.AppendixNotificationPlugin.ProcessNegotiationProtocol.Interval",
  635. TypeFullName = "System.Int32",
  636. Value = "2",
  637. Description =
  638. "Der Wocheninterval, in dem weitere Benachrichtigungen über die Nachträge ohne Protokoll gesendet werden " +
  639. "soll"
  640. },
  641. new ConfigItem
  642. {
  643. Name = "GreenTree.Nachtragsmanagement.DeviationNotificationPlugin.ProcessDeviationReceipt.AgeDaysLevel1",
  644. TypeFullName = "System.Int32",
  645. Value = "40",
  646. Description =
  647. "Die Anzahl der Tage ab dem Einreichungsdatum einer Vertragsabweichung, die bei der Überprüfung der " +
  648. "Zuordnung eines Nachtrags, erreicht sein muss (Stufe 1)"
  649. },
  650. new ConfigItem
  651. {
  652. Name = "GreenTree.Nachtragsmanagement.DeviationNotificationPlugin.ProcessDeviationReceipt.AgeDaysLevel2",
  653. TypeFullName = "System.Int32",
  654. Value = "60",
  655. Description =
  656. "Die Anzahl der Tage ab dem Einreichungsdatum einer Vertragsabweichung, die bei der Überprüfung der " +
  657. "Zuordnung eines Nachtrags, erreicht sein muss (Stufe 2)"
  658. },
  659. };
  660. foreach (var configItem in configItems)
  661. configurationService.InsertConfigItem(configItem);
  662. // Create notification base data
  663. var notifications = new[]
  664. {
  665. new MailNotification
  666. {
  667. CronExpression = "0 0 6 ? * MON *",
  668. NotificationPluginSystemName = "GreenTree.Nachtragsmanagement.AppendixNotificationPlugin",
  669. NotificationJobSystemName = "GreenTree.Nachtragsmanagement.AppendixNotificationPlugin.ProcessNegotiationDate",
  670. Users =
  671. {
  672. u1
  673. }
  674. }
  675. };
  676. foreach (var notification in notifications)
  677. miscService.InsertMailNotification(notification);
  678. }
  679. finally
  680. {
  681. // Create DbContecSpecification object
  682. var db1 = new DbContextSpec
  683. {
  684. Name = "IsTestDataGenerated",
  685. Value = "True"
  686. };
  687. dbContext.Get<DbContextSpec>().Add(db1);
  688. dbContext.SaveChanges();
  689. }
  690. }
  691. #endregion
  692. }
  693. }