| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.Http;
- using System.Web.Mvc;
- using System.Web.Routing;
- using GreenTree.Nachtragsmanagement.Web.Framework;
- using GreenTree.Nachtragsmanagement.Core.Domain;
- using System.Reflection;
- using GreenTree.Nachtragsmanagement.Core;
- using Autofac;
- using GreenTree.Nachtragsmanagement.Web.Framework.Mvc.Routes;
- using GreenTree.Nachtragsmanagement.Web.App_Start;
- using System.Web.Optimization;
- using FluentValidation.Mvc;
- using GreenTree.Nachtragsmanagement.Web.Validation;
- using GreenTree.Nachtragsmanagement.Services.User;
- using GreenTree.Nachtragsmanagement.Data;
- using GreenTree.Nachtragsmanagement.Core.Domain.Misc;
- using GreenTree.Nachtragsmanagement.Core.Domain.User;
- using GreenTree.Nachtragsmanagement.Core.Domain.Deviation;
- using GreenTree.Nachtragsmanagement.Services.Deviation;
- using GreenTree.Nachtragsmanagement.Core.Domain.Site;
- using GreenTree.Nachtragsmanagement.Core.Domain.Appendix;
- using GreenTree.Nachtragsmanagement.Services.Appendix;
- using GreenTree.Nachtragsmanagement.Services.Site;
- namespace GreenTree.Nachtragsmanagement.Web
- {
- // Note: For instructions on enabling IIS6 or IIS7 classic mode,
- // visit http://go.microsoft.com/?LinkId=9394801
- public class MvcApplication : System.Web.HttpApplication
- {
- protected void Application_Start()
- {
- AreaRegistration.RegisterAllAreas();
- GlobalConfiguration.Configure(WebApiConfig.Register);
- FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
- RouteConfig.RegisterRoutes(RouteTable.Routes);
- BundleConfig.RegisterBundles(BundleTable.Bundles);
-
- ModelBinders.Binders.DefaultBinder = new DevExpress.Web.Mvc.DevExpressEditorsBinder();
- ApplicationContext.InitApplication();
- ApplicationContext.InitPluginRoutes(RouteTable.Routes);
- FunctionConfig.RegisterFunctions();
- FluentValidationModelValidatorProvider.Configure(provider =>
- {
- provider.ValidatorFactory = new AppendixValidatorFactory();
- });
- DevExpress.Web.ASPxWebControl.CallbackError += Application_Error;
- GenerateTestData();
- }
- protected void Application_Error(object sender, EventArgs e)
- {
- Exception exception = System.Web.HttpContext.Current.Server.GetLastError();
- //TODO: Handle Exception
- }
- #region Test
- private void GenerateTestData()
- {
- // Get services
- var userService = Singleton<IContainer>.Instance.Resolve<IUserService>();
- var deviationService = Singleton<IContainer>.Instance.Resolve<IDeviationService>();
- var appendixService = Singleton<IContainer>.Instance.Resolve<IAppendixService>();
- var siteService = Singleton<IContainer>.Instance.Resolve<ISiteService>();
- var dbContext = Singleton<IContainer>.Instance.Resolve<IDbContext>();
- try
- {
- // Check if test data is already created
- var isTestDataGeneratedEntity = dbContext.Get<DbContextSpec>().FirstOrDefault(d => d.Name == "IsTestDataGenerated");
- if (isTestDataGeneratedEntity != null && Convert.ToBoolean(isTestDataGeneratedEntity.Value))
- return;
- // Create roles
- var r1 = new Role
- {
- Description = "Administrator",
- Level = 100
- };
- userService.InsertRole(r1);
- var r2 = new Role
- {
- Description = "Kaufmann",
- Level = 10
- };
- userService.InsertRole(r2);
- var r3 = new Role
- {
- Description = "Nachtragsmanager",
- Level = 10
- };
- userService.InsertRole(r3);
- var r4 = new Role
- {
- Description = "Bauleiter",
- Level = 10
- };
- userService.InsertRole(r4);
- // Create users
- var u1 = new User
- {
- Forename = "Arne",
- Lastname = "Diekmann",
- CustomNumber = "a.diekmann",
- MailAddress = "a.diekmann@greentreestudios.de",
- Password = StaticHelper.GetMD5Hash("14595809")
- };
- userService.InsertUser(u1);
- var u2 = new User
- {
- Forename = "Rocco",
- Lastname = "Lavella",
- CustomNumber = "r.lavella",
- MailAddress = "lavella@schweerbau.de",
- Password = StaticHelper.GetMD5Hash("lavella")
- };
- userService.InsertUser(u2);
- var u3 = new User
- {
- Forename = "Felix",
- Lastname = "Bramstedt",
- CustomNumber = "f.bramstedt",
- MailAddress = "bramstedt@schweerbau.de",
- Password = StaticHelper.GetMD5Hash("bramstedt")
- };
- userService.InsertUser(u3);
- var u4 = new User
- {
- Forename = "Kletus",
- Lastname = "Lingemann",
- CustomNumber = "k.lingemann",
- MailAddress = "lingemann@schweerbau.de",
- Password = StaticHelper.GetMD5Hash("lingemann")
- };
- userService.InsertUser(u4);
- var u5 = new User
- {
- Forename = "Max",
- Lastname = "Moede",
- CustomNumber = "m.moede",
- MailAddress = "moede@schweerbau.de",
- Password = StaticHelper.GetMD5Hash("moede")
- };
- userService.InsertUser(u5);
- var u6 = new User
- {
- Forename = "Max",
- Lastname = "Dammeier",
- CustomNumber = "m.dammeier",
- MailAddress = "dammeier@schweerbau.de",
- Password = StaticHelper.GetMD5Hash("dammeier")
- };
- userService.InsertUser(u6);
- var u7 = new User
- {
- Forename = "Max",
- Lastname = "Poppe",
- CustomNumber = "m.poppe",
- MailAddress = "poppe@schweerbau.de",
- Password = StaticHelper.GetMD5Hash("poppe")
- };
- userService.InsertUser(u7);
- var u8 = new User
- {
- Forename = "Max",
- Lastname = "Lehmann",
- CustomNumber = "m.lehmann",
- MailAddress = "lehmann@schweerbau.de",
- Password = StaticHelper.GetMD5Hash("poppe")
- };
- userService.InsertUser(u8);
- var u9 = new User
- {
- Forename = "Max",
- Lastname = "Wernecke",
- CustomNumber = "m.wernecke",
- MailAddress = "wernecke@schweerbau.de",
- Password = StaticHelper.GetMD5Hash("wernecke")
- };
- userService.InsertUser(u9);
- // Add users to roles
- u1.Roles.Add(r1);
- u2.Roles.Add(r1);
- u3.Roles.Add(r1);
- u4.Roles.Add(r3);
- u4.Roles.Add(r3);
- u5.Roles.Add(r4);
- u7.Roles.Add(r4);
- u6.Roles.Add(r2);
- u9.Roles.Add(r2);
- // Get all functions and add them to the admin role
- var allFunctions = userService.GetAllFunctions();
- r1.SetFunctions(allFunctions);
- userService.UpdateRole(r1);
- // Get all appendix manager function and add them to the apendix manager / merchant role
- var deviationFunctions = allFunctions
- .Where(f => f.Name.StartsWith("Deviation"));
- foreach (var function in deviationFunctions)
- {
- r2.Functions.Add(function);
- r3.Functions.Add(function);
- r4.Functions.Add(function);
- }
- var appendixFunctions = allFunctions
- .Where(f => f.Name.StartsWith("Appendix"));
- foreach (var function in appendixFunctions)
- {
- r2.Functions.Add(function);
- r3.Functions.Add(function);
- r4.Functions.Add(function);
- }
- userService.UpdateRole(r2);
- userService.UpdateRole(r3);
- userService.UpdateRole(r4);
- // Create appendix base data
- var categories = new[]
- {
- new Category { Description = "RPM" },
- new Category { Description = "RM" },
- new Category { Description = "Stopftechnik" },
- new Category { Description = "Umbauzug" },
- new Category { Description = "Logistik" },
- new Category { Description = "Oberbau" },
- new Category { Description = "Erdbau" },
- new Category { Description = "Kabeltiefbau" },
- new Category { Description = "Entwässerung" },
- new Category { Description = "Sonstiges" }
- };
- foreach (var category in categories)
- appendixService.InsertCategory(category);
- var states = new[]
- {
- new State { Description = "Offen" },
- new State { Description = "Erinnerung Verhandlung" },
- new State { Description = "Verhandelt" },
- new State { Description = "Erledigt / Entfällt" }
- };
- foreach (var state in states)
- appendixService.InsertState(state);
- var appendices = new[]
- {
- new Appendix
- {
- CustomNumber = "3",
- Description = "Lückenschluss Weiche 523",
- State = states[0],
- StateId = states[0].Id,
- CategoryValues =
- {
- new CategoryValue { Category = categories[2], CategoryId = categories[2].Id, Value = 44000 },
- new CategoryValue { Category = categories[3], CategoryId = categories[3].Id, Value = 30000 },
- },
- Value = Convert.ToDecimal(74833.6),
- NegotiationValue = 70000,
- OfferingDate = new DateTime(2016, 12, 20),
- Comment = "hier 3 % NA enthalten = Delta zu iTWO = 77148,04€, Abgabeddatum per Mail, Post später"
- },
- new Appendix
- {
- CustomNumber = "6",
- Description = "Erschwerniss masch. Gleisbau ZEB 22",
- State = states[0],
- StateId = states[0].Id,
- CategoryValues =
- {
- new CategoryValue { Category = categories[0], CategoryId = categories[0].Id, Value = 43000 }
- },
- Value = Convert.ToDecimal(43514.35),
- NegotiationValue = 40000,
- OfferingDate = new DateTime(2016, 12, 20),
- 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"
- },
- new Appendix
- {
- CustomNumber = "1",
- Description = "Umsetzen von Haufwerken",
- State = states[0],
- StateId = states[0].Id,
- CategoryValues =
- {
- new CategoryValue { Category = categories[9], CategoryId = categories[9].Id, Value = 2500 }
- },
- Value = Convert.ToDecimal(2549.18),
- NegotiationValue = 2000,
- OfferingDate = new DateTime(2017, 2, 2),
- Comment = "Beginn der Frist der Nachtragsprüfung 16.02.17"
- },
- new Appendix
- {
- CustomNumber = "2",
- Description = "Nichtbereitstellung der Ladevorrichtung",
- State = states[0],
- StateId = states[0].Id,
- CategoryValues =
- {
- new CategoryValue { Category = categories[4], CategoryId = categories[4].Id }
- },
- Value = Convert.ToDecimal(23738.06),
- NegotiationValue = 20000,
- OfferingDate = new DateTime(2017, 2, 3),
- Comment = "Aufmaße noch nicht erstellt"
- }
- };
- foreach (var appendix in appendices)
- appendixService.InsertAppendix(appendix);
- // Create site base data
- var sites = new[]
- {
- new Site
- {
- CustomNumber = "2101000",
- Description = "POS Nord Kaiserslautern Los 19-21",
- Appendices =
- {
- appendices[0],
- appendices[1]
- },
- Finished = false,
- Start = new DateTime(2016, 1, 1),
- Users =
- {
- u4,
- u5,
- u6
- }
- },
- new Site
- {
- CustomNumber = "211200",
- Description = "GE Geisenheim-Rüdesheim",
- Appendices =
- {
- appendices[2],
- appendices[3]
- },
- Finished = false,
- Start = new DateTime(2016, 1, 1),
- Users =
- {
- u7,
- u8,
- u9
- }
- }
- };
- foreach (var site in sites)
- siteService.InsertSite(site);
- // Create deviation base data
- var kinds = new[]
- {
- new Kind { Shortance = "MK", Description = "Mehrkosten" },
- new Kind { Shortance = "BH", Description = "Behinderung" },
- new Kind { Shortance = "BD", Description = "Bedenken" }
- };
- foreach (var kind in kinds)
- deviationService.InsertKind(kind);
- var disturbances = new[]
- {
- new Disturbance { Description = "RPM" },
- new Disturbance { Description = "RM" },
- new Disturbance { Description = "Stopftechnik" },
- new Disturbance { Description = "Umbauzug" },
- new Disturbance { Description = "Logistik" },
- new Disturbance { Description = "Oberbau" },
- new Disturbance { Description = "Erdbau" },
- new Disturbance { Description = "Kabeltiefbau" },
- new Disturbance { Description = "Entwässerung" },
- new Disturbance { Description = "Sonstiges" }
- };
- foreach (var disturbance in disturbances)
- deviationService.InsertDisturbance(disturbance);
- var statuses = new[]
- {
- new Status { Description = "Standard" },
- new Status { Description = "Entfällt" },
- new Status { Description = "Strittig" },
- new Status { Description = "Abr. über HLV" }
- };
- foreach (var status in statuses)
- deviationService.InsertStatus(status);
- var deviations = new[]
- {
- new Deviation
- {
- CustomNumber = "1",
- Description = "Mehrleistung Stopfen",
- Kind = kinds[0],
- KindId = kinds[0].Id,
- DisturbanceValues =
- {
- new DisturbanceValue { Disturbance = disturbances[2], DisturbanceId = disturbances[2].Id, Value = 40000 }
- },
- Status = statuses[0],
- StatusId = statuses[0].Id,
- Value = 40000,
- Percentage = 100,
- Appendix = appendices[0],
- AppendixId = appendices[0].Id,
- AppendixDate = appendices[0].OfferingDate
- },
- new Deviation
- {
- CustomNumber = "2",
- Description = "Bodenausbau konventionell",
- Kind = kinds[0],
- KindId = kinds[0].Id,
- DisturbanceValues =
- {
- new DisturbanceValue { Disturbance = disturbances[6], DisturbanceId = disturbances[6].Id, Value = 30000 }
- },
- Status = statuses[1],
- StatusId = statuses[1].Id,
- Value = 30000,
- Percentage = 0,
- Appendix = appendices[0],
- AppendixId = appendices[0].Id,
- AppendixDate = appendices[0].OfferingDate
- },
- new Deviation
- {
- CustomNumber = "3",
- Description = "Einbau PSS im Weichenbereich",
- Kind = kinds[0],
- KindId = kinds[0].Id,
- DisturbanceValues =
- {
- new DisturbanceValue { Disturbance = disturbances[6], DisturbanceId = disturbances[6].Id, Value = 2000 }
- },
- Status = statuses[0],
- StatusId = statuses[0].Id,
- Value = 2000,
- Percentage = 100,
- Appendix = appendices[1],
- AppendixId = appendices[1].Id,
- AppendixDate = appendices[1].OfferingDate
- },
- new Deviation
- {
- CustomNumber = "4",
- Description = "Hindernisse bei der PLV mit RPM",
- Kind = kinds[1],
- KindId = kinds[1].Id,
- DisturbanceValues =
- {
- new DisturbanceValue { Disturbance = disturbances[0], DisturbanceId = disturbances[0].Id, Value = 40000 }
- },
- Status = statuses[2],
- StatusId = statuses[2].Id,
- Value = 40000,
- Percentage = 30,
- Site = sites[0],
- SiteId = sites[0].Id
- },
- new Deviation
- {
- CustomNumber = "1",
- Description = "Umsetzen von Haufwerken",
- Kind = kinds[0],
- KindId = kinds[0].Id,
- DisturbanceValues =
- {
- new DisturbanceValue { Disturbance = disturbances[6], DisturbanceId = disturbances[6].Id, Value = 2500 }
- },
- Status = statuses[0],
- StatusId = statuses[0].Id,
- Value = 2500,
- Percentage = 100,
- Appendix = appendices[2],
- AppendixId = appendices[2].Id,
- AppendixDate = appendices[2].OfferingDate
- },
- new Deviation
- {
- CustomNumber = "2",
- Description = "Nichtbereitsstellung der Ladevorrichtung Nr. 1",
- Kind = kinds[0],
- KindId = kinds[0].Id,
- DisturbanceValues =
- {
- new DisturbanceValue { Disturbance = disturbances[5], DisturbanceId = disturbances[5].Id, Value = 10000 }
- },
- Status = statuses[0],
- StatusId = statuses[0].Id,
- Value = 10000,
- Percentage = 100,
- Appendix = appendices[3],
- AppendixId = appendices[3].Id,
- AppendixDate = appendices[3].OfferingDate
- },
- new Deviation
- {
- CustomNumber = "5",
- Description = "Nichtbereitsstellung der Ladevorrichtung Nr. 2",
- Kind = kinds[0],
- KindId = kinds[0].Id,
- DisturbanceValues =
- {
- new DisturbanceValue { Disturbance = disturbances[5], DisturbanceId = disturbances[5].Id, Value = 10000 }
- },
- Status = statuses[3],
- StatusId = statuses[3].Id,
- Value = 10000,
- Percentage = 110,
- Appendix = appendices[3],
- AppendixId = appendices[3].Id,
- AppendixDate = appendices[3].OfferingDate
- },
- new Deviation
- {
- CustomNumber = "6",
- Description = "Verspannung Los 2",
- Kind = kinds[0],
- KindId = kinds[0].Id,
- DisturbanceValues =
- {
- new DisturbanceValue { Disturbance = disturbances[5], DisturbanceId = disturbances[5].Id, Value = 6000 }
- },
- Status = statuses[2],
- StatusId = statuses[2].Id,
- Value = 6000,
- Percentage = 50,
- Site = sites[1],
- SiteId = sites[1].Id
- }
- };
- foreach (var deviation in deviations)
- deviationService.InsertDeviation(deviation);
- }
- finally
- {
- // Create DbContecSpecification object
- var db1 = new DbContextSpec
- {
- Name = "IsTestDataGenerated",
- Value = "True"
- };
- dbContext.Get<DbContextSpec>().Add(db1);
- dbContext.SaveChanges();
- }
- }
- #endregion
- }
- }
|