Global.asax.cs 33 KB

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