Global.asax.cs 29 KB

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