public void Seed(DbContext dbContext) { var responsibleSubject1 = ResponsibleSubjectModelFactory.CreateEmployee("Hans", "Müller"); var responsibleSubject2 = ResponsibleSubjectModelFactory.CreateEmployee("Gabi", "Becker"); var responsibleGroup = ResponsibleSubjectModelFactory.CreateGroup("Praktikanten"); dbContext.Set <EmployeeGroup>() .Add(responsibleGroup); dbContext.Set <Employee>() .Add(responsibleSubject1); dbContext.Set <Employee>() .Add(responsibleSubject2); var assembly = Assembly.GetExecutingAssembly(); var creationDate = DateTime.Now; var measureCollection1 = new Collection <Measure>(); var measureCollection2 = new Collection <Measure>(); for (var i = 0; i < 10; i++) { var word = DocumentModelFactory.CreateDocument("doc1.docx", assembly.GetManifestResourceStream("OpenResKit.Measure.Resources.dummyword.docx")); var pdf = DocumentModelFactory.CreateDocument("pdf1.pdf", assembly.GetManifestResourceStream("OpenResKit.Measure.Resources.dummypdf.pdf")); var measureName = "Container leeren"; var description = "Der Container ist voll"; var evaluationText = "Das Leeren hat funktioniert"; var entryDate = DateTime.Now.AddDays(-i * 7 - 1); var dueDate = DateTime.Now.AddDays(-i * 7); var status = 2; var rating = 0.8; var priority = 0; var imageSource = ModelFactory.CreateImage(assembly.GetManifestResourceStream("OpenResKit.Measure.Resources.dummyImage1.jpg")); var measure = ModelFactory.CreateMeasure(measureName, description, evaluationText, entryDate, dueDate, responsibleSubject1, status, priority, creationDate, rating, imageSource, new Collection <Document> { word, pdf }); measureCollection1.Add(measure); } for (var i = 5; i < 10; i++) { var word = DocumentModelFactory.CreateDocument("doc1.docx", assembly.GetManifestResourceStream("OpenResKit.Measure.Resources.dummyword.docx")); var pdf = DocumentModelFactory.CreateDocument("pdf1.pdf", assembly.GetManifestResourceStream("OpenResKit.Measure.Resources.dummypdf.pdf")); var measureName = "Container leeren"; var description = "Der Container ist voll"; var dueDate = DateTime.Now.AddDays(-i * 7); var evaluationText = string.Empty; DateTime?entryDate = null; var status = 0; var ratig = 0.0; var priority = 1; var imageSource = ModelFactory.CreateImage(assembly.GetManifestResourceStream("OpenResKit.Measure.Resources.dummyImage2.jpg")); var measure = ModelFactory.CreateMeasure(measureName, description, evaluationText, entryDate, dueDate, responsibleSubject1, status, priority, creationDate, ratig, imageSource, new Collection <Document> { word, pdf }); measureCollection1.Add(measure); } for (var i = 0; i < 5; i++) { var measureName = "Stromzähler ablesen"; var description = "Stromzähler befindet sich im Keller"; var evaluationText = string.Empty; DateTime?entryDate = null; var dueDate = DateTime.Now.AddDays(-i * 3); var status = 0; var rating = 0.2; var priority = 2; var imageSource = ModelFactory.CreateImage(assembly.GetManifestResourceStream("OpenResKit.Measure.Resources.dummyImage3.jpg")); var measure = ModelFactory.CreateMeasure(measureName, description, evaluationText, entryDate, dueDate, responsibleSubject1, status, priority, creationDate, rating, imageSource, null); measureCollection2.Add(measure); } for (var i = 5; i < 10; i++) { var measureName = "Stromzähler ablesen"; var description = "Stromzähler befindet sich im Keller"; var evaluationText = "Das Ablesen war wegen dem ganzen Schmutz kaum möglich"; var entryDate = DateTime.Now.AddDays(-i * 30); var dueDate = DateTime.Now.AddDays(-i * 30); var status = 2; var rating = 0.4; var priority = 2; var measure = ModelFactory.CreateMeasure(measureName, description, evaluationText, entryDate, dueDate, responsibleSubject1, status, priority, creationDate, rating, null, null); measureCollection2.Add(measure); } var catalog1 = ModelFactory.CreateCatalog("Katalog 1", "Das ist Katalog 1", measureCollection1); var catalog2 = ModelFactory.CreateCatalog("Katalog 2", "Das ist Katalog 2", measureCollection2); dbContext.Set <Catalog>() .Add(catalog1); dbContext.Set <Catalog>() .Add(catalog2); dbContext.SaveChanges(); }
public void Seed(DbContext dbContext) { //var grabber = new NovaGrabber(); //foreach (Machine machine in grabber.getData()) //{ // dbContext.Set<Machine>().AddOrUpdate(machine); //} var responsibleSubject1 = ResponsibleSubjectModelFactory.CreateEmployee("Hans", "Müller"); var responsibleSubject2 = ResponsibleSubjectModelFactory.CreateEmployee("Gabi", "Becker"); var responsibleGroup = ResponsibleSubjectModelFactory.CreateGroup("Praktikanten"); dbContext.Set <EmployeeGroup>() .Add(responsibleGroup); dbContext.Set <Employee>() .Add(responsibleSubject1); dbContext.Set <Employee>() .Add(responsibleSubject2); var assembly = Assembly.GetExecutingAssembly(); var creationDate = DateTime.Now; var measureCollection1 = new List <EnergyMeasure>(); var measureCollection2 = new List <EnergyMeasure>(); for (var i = 0; i < 10; i++) { var word = DocumentModelFactory.CreateDocument("doc1.docx", assembly.GetManifestResourceStream("OpenResKit.Energy.Resources.dummyword.docx")); var pdf = DocumentModelFactory.CreateDocument("pdf1.pdf", assembly.GetManifestResourceStream("OpenResKit.Energy.Resources.dummypdf.pdf")); var measureName = "Container leeren"; var description = "Der Container ist voll"; var evaluationText = "Das Leeren hat funktioniert"; var entryDate = DateTime.Now.AddDays(-i * 7 - 1); var dueDate = DateTime.Now.AddDays(-i * 7); var status = 2; var rating = 0.8; var priority = 0; var imageSource = ModelFactory.CreateImage(assembly.GetManifestResourceStream("OpenResKit.Energy.Resources.dummyImage1.jpg")); var measure = ModelFactory.CreateMeasure(measureName, description, evaluationText, entryDate, dueDate, responsibleSubject1, status, priority, creationDate, rating, imageSource, new Collection <Document> { word, pdf }); measureCollection1.Add(measure); } for (var i = 5; i < 10; i++) { var word = DocumentModelFactory.CreateDocument("doc1.docx", assembly.GetManifestResourceStream("OpenResKit.Energy.Resources.dummyword.docx")); var pdf = DocumentModelFactory.CreateDocument("pdf1.pdf", assembly.GetManifestResourceStream("OpenResKit.Energy.Resources.dummypdf.pdf")); var measureName = "Container leeren"; var description = "Der Container ist voll"; var dueDate = DateTime.Now.AddDays(-i * 7); var evaluationText = string.Empty; DateTime?entryDate = null; var status = 0; var ratig = 0.0; var priority = 1; var imageSource = ModelFactory.CreateImage(assembly.GetManifestResourceStream("OpenResKit.Energy.Resources.dummyImage2.jpg")); var measure = ModelFactory.CreateMeasure(measureName, description, evaluationText, entryDate, dueDate, responsibleSubject1, status, priority, creationDate, ratig, imageSource, new Collection <Document> { word, pdf }); measureCollection1.Add(measure); } for (var i = 0; i < 5; i++) { var measureName = "Stromzähler ablesen"; var description = "Stromzähler befindet sich im Keller"; var evaluationText = string.Empty; DateTime?entryDate = null; var dueDate = DateTime.Now.AddDays(-i * 3); var status = 0; var rating = 0.2; var priority = 2; var imageSource = Measure.ModelFactory.CreateImage(assembly.GetManifestResourceStream("OpenResKit.Energy.Resources.dummyImage3.jpg")); var measure = ModelFactory.CreateMeasure(measureName, description, evaluationText, entryDate, dueDate, responsibleSubject1, status, priority, creationDate, rating, imageSource, null); measureCollection2.Add(measure); } for (var i = 5; i < 10; i++) { var measureName = "Stromzähler ablesen"; var description = "Stromzähler befindet sich im Keller"; var evaluationText = "Das Ablesen war wegen dem ganzen Schmutz kaum möglich"; var entryDate = DateTime.Now.AddDays(-i * 30); var dueDate = DateTime.Now.AddDays(-i * 30); var status = 2; var rating = 0.4; var priority = 2; var measure = ModelFactory.CreateMeasure(measureName, description, evaluationText, entryDate, dueDate, responsibleSubject1, status, priority, creationDate, rating, null, null); measureCollection2.Add(measure); } var subMeasure = new SubMeasure { IsCompleted = false, Name = "Test Untermaßnahme", ReleatedMeasure = measureCollection1[0], ResponsibleSubject = responsibleSubject1 }; dbContext.Set <SubMeasure>() .Add(subMeasure); var sgm = new ConsumerType { TypeName = "SGM" }; var auto = new ConsumerType { TypeName = "Automaten" }; var pc = new ConsumerType { TypeName = "PCs" }; var server = new ConsumerType { TypeName = "Server" }; dbContext.Set <ConsumerType>() .Add(sgm); dbContext.Set <ConsumerType>() .Add(auto); dbContext.Set <ConsumerType>() .Add(pc); dbContext.Set <ConsumerType>() .Add(server); var consumerGroupEdv = ModelFactory.CreateConsumerGroup("01 EDV"); consumerGroupEdv.ConsumerTypes.Add(pc); consumerGroupEdv.ConsumerTypes.Add(server); var consumerGroupAnlagen = ModelFactory.CreateConsumerGroup("02 Anlagen"); consumerGroupAnlagen.ConsumerTypes.Add(auto); consumerGroupAnlagen.ConsumerTypes.Add(sgm); dbContext.Set <ConsumerGroup>() .Add(consumerGroupEdv); dbContext.Set <ConsumerGroup>() .Add(consumerGroupAnlagen); dbContext.SaveChanges(); var distributorvi = ModelFactory.CreateDistributor("Verteiler Villa"); var distributorA = ModelFactory.CreateDistributor("Verteiler Gebäude A"); var distributorSchiene = ModelFactory.CreateDistributor("Stromschine 1"); dbContext.Set <Distributor>() .Add(distributorvi); dbContext.Set <Distributor>() .Add(distributorA); dbContext.Set <Distributor>() .Add(distributorSchiene); var auto1 = ModelFactory.CreateConsumer("Automat 1", distributorA, consumerGroupAnlagen, auto); var auto2 = ModelFactory.CreateConsumer("Automat 2", distributorA, consumerGroupAnlagen, auto); var sgm1 = ModelFactory.CreateConsumer("Spritzgußmaschine 1", distributorA, consumerGroupAnlagen, sgm); var sgm2 = ModelFactory.CreateConsumer("Spritzgußmaschine 2", distributorSchiene, consumerGroupAnlagen, sgm); var sgm3 = ModelFactory.CreateConsumer("Spritzgußmaschine 3", distributorSchiene, consumerGroupAnlagen, sgm); var sgm4 = ModelFactory.CreateConsumer("Spritzgußmaschine 4", distributorSchiene, consumerGroupAnlagen, sgm); dbContext.Set <Consumer>() .Add(auto1); dbContext.Set <Consumer>() .Add(auto2); dbContext.Set <Consumer>() .Add(sgm1); dbContext.Set <Consumer>() .Add(sgm2); dbContext.Set <Consumer>() .Add(sgm3); dbContext.Set <Consumer>() .Add(sgm4); dbContext.SaveChanges(); }
public void Seed(DbContext dbContext) { var responsibleSubject1 = ResponsibleSubjectModelFactory.CreateEmployee("Shawn", "Steinfeger", "1"); var responsibleSubject2 = ResponsibleSubjectModelFactory.CreateGroup("Test"); var measure1 = ModelFactory.CreateMeasure("Das und Das müssen gemacht werden", 0, responsibleSubject1, null, 1, DateTime.Now, DateTime.Now.AddDays(10), "Maßnahme1"); var measure2 = ModelFactory.CreateMeasure("Das und Das müssen gemacht werden2", 1, responsibleSubject2, null, 2, DateTime.Now, DateTime.Now.AddDays(25), "Maßnahme2"); var measures1 = new Collection <Approval_Measure>(); measures1.Add(measure1); var measures2 = new Collection <Approval_Measure>(); measures2.Add(measure2); dbContext.Set <Approval_Measure>().Add(measure1); dbContext.Set <Approval_Measure>().Add(measure2); var conditionInspection1 = ModelFactory.CreateConditionInspection(true, "Alles Ok", measures1, DateTime.Now /*, inspection2, auxillaryCondition1*/); var conditionInspection2 = ModelFactory.CreateConditionInspection(false, "Nicht alles ok", measures2, DateTime.Now /*, inspection1, auxillaryCondition2*/); var conditionInspection3 = ModelFactory.CreateConditionInspection(true, "AllesO Ok2", null, DateTime.Now /*, inspection1, auxillaryCondition2*/); dbContext.Set <ConditionInspection>().Add(conditionInspection1); dbContext.Set <ConditionInspection>().Add(conditionInspection2); dbContext.Set <ConditionInspection>().Add(conditionInspection3); var conditionInspections1 = new Collection <ConditionInspection>(); conditionInspections1.Add(conditionInspection1); var conditionInspections2 = new Collection <ConditionInspection>(); conditionInspections2.Add(conditionInspection2); conditionInspections2.Add(conditionInspection3); var conditionInspections3 = new Collection <ConditionInspection>(); conditionInspections3.Add(conditionInspection1); conditionInspections3.Add(conditionInspection3); var auxillaryCondition1 = ModelFactory.CreateAuxillaryCondition("Wert muss unter 20 mg bleiben", "WHG §5", false, conditionInspections1); var auxillaryCondition2 = ModelFactory.CreateAuxillaryCondition("Wert muss unter 50 mg bleiben", "WHG §6", true, conditionInspections2); var auxillaryConditions = new Collection <AuxillaryCondition>(); auxillaryConditions.Add(auxillaryCondition1); auxillaryConditions.Add(auxillaryCondition2); var date = DateTime.Now.AddYears(-1); var series = SeriesModelFactory.CreateSeries("Kontrolle", date, date.AddMinutes(30), date.AddDays(91), true, false, false, 1, 1, 13, new DayOfWeek[0]); var inspection1 = ModelFactory.CreateInspection(conditionInspections1, DateTime.Now, DateTime.Now.AddHours(1), responsibleSubject2, series, 0); var series2 = SeriesModelFactory.CreateSeries("Kontrolle2", date, date.AddMinutes(30), date.AddDays(91), true, true, false, 1, 1, 13, new DayOfWeek[1]); var inspection2 = ModelFactory.CreateInspection(conditionInspections2, DateTime.Now, DateTime.Now.AddHours(1), responsibleSubject1, series2, 2); //dbContext.Set<ConditionInspection>().Add(conditionInspection2); //dbContext.Set<ConditionInspection>().Add(conditionInspection3); dbContext.Set <Approval_Inspection>().Add(inspection1); dbContext.Set <Approval_Inspection>().Add(inspection2); dbContext.Set <AuxillaryCondition>().Add(auxillaryCondition1); dbContext.Set <AuxillaryCondition>().Add(auxillaryCondition2); //dbContext.Set<Approval_Inspection>().Add(inspection2); var permission1 = ModelFactory.CreatePermission("Genehmigung 1", "Das ist eine Genehmigung.", true, 1, "AH-101", DateTime.Now, DateTime.Now, DateTime.Now, auxillaryConditions); var permission2 = ModelFactory.CreatePermission("Genehmigung 2", "Das ist eine Genehmigung.", true, 0, "AH-102", DateTime.Now, DateTime.Now, DateTime.Now, null); var permission3 = ModelFactory.CreatePermission("Genehmigung 3", "Das ist eine Genehmigung.", false, 2, "AH-103", DateTime.Now, DateTime.Now, DateTime.Now, null); dbContext.Set <Permission>().Add(permission1); dbContext.Set <Permission>().Add(permission2); dbContext.Set <Permission>().Add(permission3); var permissionCollection1 = new Collection <Permission>(); permissionCollection1.Add(permission1); permissionCollection1.Add(permission2); var permissionCollection2 = new Collection <Permission>(); permissionCollection2.Add(permission2); permissionCollection2.Add(permission3); var substance1 = ModelFactory.CreateSubstance("Wasser", "H2O", 1, 0, "0,1,2", "Abdichten", 2); var substance2 = ModelFactory.CreateSubstance("Kohlenstoffdioxid", "CO2", 0, 1, "3", "Gasmaske und abdichten", 1); var substanceList1 = new Collection <Substance>(); substanceList1.Add(substance1); substanceList1.Add(substance2); var plant1 = ModelFactory.CreatePlant("Anlage 1", "Das ist eine Anlage", "Anlage 1", permissionCollection1, substanceList1); var plant2 = ModelFactory.CreatePlant("Anlage 2", "Das ist auch eine Anlage", "Anlage 2", permissionCollection2, null); dbContext.Set <Plant>().Add(plant1); dbContext.Set <Plant>().Add(plant2); dbContext.Set <Employee>().Add(responsibleSubject1); dbContext.Set <EmployeeGroup>().Add(responsibleSubject2); dbContext.SaveChanges(); }