Global.asax.cs 29 KB

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