Ejemplo n.º 1
0
        //var groups = scenario.ScenarioGroups;
        //var sc = scenario.Scenarios;
        //DateTime now = DateTime.UtcNow;
        //        try
        //        {
        //            AddGroups1(groups, now);
        //scenario.SaveChanges();
        //            AddGroups2(groups, now);
        //scenario.SaveChanges();
        //            //AddScenarios(sc, now);
        //        }
        //        catch (DbEntityValidationException dbEx)
        //        {
        //            foreach (var validationErrors in dbEx.EntityValidationErrors)
        //            {
        //                Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", validationErrors.Entry.Entity.GetType().Name, validationErrors.Entry.State);
        //                foreach (var validationError in validationErrors.ValidationErrors)
        //                {
        //                    Console.WriteLine("Property: {0} Error: {1}", validationError.PropertyName, validationError.ErrorMessage);
        //                }
        //            }
        //        }
        //        Console.WriteLine("*****Scenario Group List*****");
        //        foreach (ScenarioGroup item in groups)
        //        {
        //            Console.WriteLine(item.ScenarioGroupID);
        //            foreach (ScenarioGroupDetail item2 in item.ScenarioGroupDetails)
        //            {
        //                Console.WriteLine(item2.ScenarioGroupDetailID + " " + item2.Name);
        //            }
        //        }
        static void AddGroups1(DbSet<ScenarioGroup> root, DateTime now)
        {
            ScenarioGroup sg = new ScenarioGroup();
            sg.StartTime = now.AddDays(-100);
            sg.EndTime = DateTime.MaxValue;
            sg.CreatedBy = "me";
            sg.CreatedAt = now;
            root.Add(sg);

            ScenarioGroupDetail sgd = new ScenarioGroupDetail();
            sgd.Name = "Test 2-1";
            sgd.StartTime = now.AddDays(-100);
            sgd.EndTime = now.AddDays(-50);
            sgd.CreatedBy = "me";
            sgd.CreatedAt = now.AddDays(-50);
            //sgd.ScenarioGroup = sg;
            sg.ScenarioGroupDetails.Add(sgd);

            sgd = new ScenarioGroupDetail();
            sgd.Name = "Test 2-2";
            sgd.StartTime = now.AddDays(-50);
            sgd.EndTime = now.AddDays(-20);
            sgd.CreatedBy = "me";
            sgd.CreatedAt = now.AddDays(-20);
            //sgd.ScenarioGroup = sg;
            sg.ScenarioGroupDetails.Add(sgd);

            sgd = new ScenarioGroupDetail();
            sgd.Name = "Test 2-3";
            sgd.StartTime = now.AddDays(-20);
            sgd.EndTime = DateTime.MaxValue;
            sgd.CreatedBy = "me";
            sgd.CreatedAt = now.AddDays(-20);
            //sgd.ScenarioGroup = sg;
            sg.ScenarioGroupDetails.Add(sgd);
        }
Ejemplo n.º 2
0
        static void AddGroups2(DbSet<ScenarioGroup> root, DateTime now)
        {
            ScenarioGroup sg1 = root.Find(2);

            ScenarioGroup sg = new ScenarioGroup();
            sg.StartTime = now.AddDays(-80);
            sg.EndTime = DateTime.MaxValue;
            sg.CreatedBy = "me";
            sg.CreatedAt = now;
            root.Add(sg);

            ScenarioGroupDetail sgd = new ScenarioGroupDetail();
            sgd.Name = "Test-Child-2";
            sgd.StartTime = now.AddDays(-80);
            sgd.EndTime = now.AddDays(-40);
            sgd.CreatedBy = "me";
            sgd.CreatedAt = now.AddDays(-40);
            sg.ScenarioGroupDetails.Add(sgd);

            sgd = new ScenarioGroupDetail();
            sgd.Name = "Test-Child-2";
            sgd.StartTime = now.AddDays(-40);
            sgd.EndTime = now.AddDays(-20);
            sgd.CreatedBy = "me";
            sgd.CreatedAt = now.AddDays(-20);
            sg.ScenarioGroupDetails.Add(sgd);

            sgd = new ScenarioGroupDetail();
            sgd.Name = "Test-Child-2";
            sgd.StartTime = now.AddDays(-20);
            sgd.EndTime = DateTime.MaxValue;
            sgd.CreatedBy = "me";
            sgd.CreatedAt = now.AddDays(-20);
            sg.ScenarioGroupDetails.Add(sgd);
        }
Ejemplo n.º 3
0
        //static void AddGroups3(DbSet<ScenarioGroup> root, DateTime now)
        //{
        //    ScenarioGroup sg = new ScenarioGroup();
        //    sg.Name = "Test-Child2";
        //    sg.ScenarioGroupID = 2;
        //    sg.ScenarioGroupParentID = 1;
        //    sg.StartTime = now.AddDays(-80);
        //    sg.EndTime = DateTime.MaxValue;
        //    sg.CreatedBy = "me";
        //    sg.TimeStamp = now.AddDays(-80);
        //    root.Add(sg);
        //}
        static void AddScenarios(DbSet<ScenarioGroup> setScenarioGroup, DbSet<Scenario> setScenario, DateTime now)
        {
            ScenarioGroup sg = new ScenarioGroup();
            sg.StartTime = now.AddDays(-80);
            sg.EndTime = DateTime.MaxValue;
            sg.CreatedBy = "me";
            sg.CreatedAt = now;
            setScenarioGroup.Add(sg);

            ScenarioGroupDetail sgd = new ScenarioGroupDetail();
            sgd.Name = "Test-Child-2";
            sgd.StartTime = now.AddDays(-80);
            sgd.EndTime = DateTime.MaxValue;
            sgd.CreatedBy = "me";
            sgd.CreatedAt = now;
            sg.ScenarioGroupDetails.Add(sgd);

            Scenario s = new Scenario();
            s.StartTime = now.AddDays(-80);
            s.EndTime = DateTime.MaxValue;
            s.CreatedBy = "me";
            s.CreatedAt = now;
            setScenario.Add(s);

            ScenarioDetail sd = new ScenarioDetail();
            sd.Name = "Scenario A";
            sd.StartTime = now.AddDays(-80);
            sd.EndTime = DateTime.MaxValue;
            sd.CreatedBy = "me";
            sd.CreatedAt = now;
            s.ScenarioDetails.Add(sd);

            Scenario s2 = new Scenario();
            s.StartTime = now.AddDays(-80);
            s.EndTime = DateTime.MaxValue;
            s.CreatedBy = "me";
            s.CreatedAt = now;
            setScenario.Add(s2);

            ScenarioDetail sd2 = new ScenarioDetail();
            sd.Name = "Derive from A";
            sd.StartTime = now.AddDays(-80);
            sd.EndTime = DateTime.MaxValue;
            sd.CreatedBy = "me";
            sd.CreatedAt = now;
            s2.ScenarioDetails.Add(sd2);

            s.DerivedScenarios.Add(s2);
        }