Global.asax.cs 32 KB

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