public ScenarioGroupDetail Add(ScenarioGroup parent) { ScenarioGroupDetail detail = new ScenarioGroupDetail(); detail.Default(Context.UserName); ScenarioGroup scenarioGroup = new ScenarioGroup(); scenarioGroup.Default(Context.UserName); if (Context.ScenarioGroups.Local.Count() > 0) scenarioGroup.ScenarioGroupID = Context.ScenarioGroups.Local.Max(x => x.ScenarioGroupID) + 1; else scenarioGroup.ScenarioGroupID = 1; Context.ScenarioGroups.Add(scenarioGroup); scenarioGroup.ScenarioGroupDetails.Add(detail); detail.ScenarioGroup = scenarioGroup; detail.ScenarioGroupID = scenarioGroup.ScenarioGroupID; if (parent != null) { detail.ScenarioGroupParent = parent; detail.ScenarioGroupParentID = parent.ScenarioGroupDetail.ScenarioGroupID; } detail.Name = "Scenario Group Name"; return detail; }
//returns false, if a move is not possible public bool Move(ScenarioGroupDetail detail, ScenarioGroup newParent) { //detail.ScenarioGroupID = newParent.ScenarioGroupID; ScenarioGroup checkParent = newParent; //check for circular reference while ((checkParent != null) && (checkParent != detail.ScenarioGroup)) { checkParent = checkParent.ScenarioGroupDetail.ScenarioGroupParent; } //circular reference check failed - abort movement if (checkParent == detail.ScenarioGroup) return false; detail.ScenarioGroupParent = newParent; detail.ScenarioGroupParentID = newParent.ScenarioGroupID; //reset the values - we have new version, which is unapproved //it will be finalised during save if (detail.Status == EntityStatus.Approved) detail.Default(Context.UserName); return true; }
public bool CheckIfScenarioIsWithoutErrors(ScenarioGroup[] groups) { for (int i = 0; i < groups.Length; i++) { ScenarioGroup scgroup = groups[i]; if (scgroup.startPoint == START_POINT.FROM_CURRENT_END) { PlayerController tempPC = null; for (int j = 1; j < scgroup.items.Length; j++) { if(scgroup.items[j] != null) { if(scgroup.items[j].animControllerName != null && (SceneStorage.Instance.namedControllers.ContainsKey(scgroup.items[j].animControllerName))) { tempPC = SceneStorage.Instance.namedControllers[scgroup.items[j].animControllerName]; if( tempPC.animation[tempPC.GetCorrectName(scgroup.items[j].animName)] == null) return false; } else return false; } else return false; } } } return true; }
internal static void AddScenarioGroups(ScenarioGeneratorModel context) { DateTime now = context.AsOfDate; ScenarioGroup sg = new ScenarioGroup() { StartTime = now.AddDays(-100), EndTime = DateTime.MaxValue, CreatedAt = now, CreatedBy = "A", ApprovedAt = now.AddDays(-100), ApprovedBy = "B", Latest = true }; context.ScenarioGroups.Add(sg); ScenarioGroupDetail sgd; sgd = new ScenarioGroupDetail() { Name = "Macro (v1)", StartTime = now.AddDays(-100), EndTime = now.AddDays(-50), CreatedAt = now.AddDays(-120), CreatedBy = "A", ApprovedAt = now.AddDays(-100), ApprovedBy = "B", ModifiedAt = now.AddDays(-110), ModifiedBy = "C", Latest = false }; sg.ScenarioGroupDetails.Add(sgd); sgd = new ScenarioGroupDetail() { Name = "Macro (v2)", StartTime = now.AddDays(-50), EndTime = now.AddDays(-20), CreatedAt = now.AddDays(-75), CreatedBy = "A", ApprovedAt = now.AddDays(-50), ApprovedBy = "B", ModifiedAt = now.AddDays(-60), ModifiedBy = "C", Latest = false }; sg.ScenarioGroupDetails.Add(sgd); sgd = new ScenarioGroupDetail() { Name = "Macro (v3)", StartTime = now.AddDays(-20), EndTime = DateTime.MaxValue, CreatedAt = now.AddDays(-30), CreatedBy = "A", ApprovedAt = now.AddDays(-20), ApprovedBy = "B", ModifiedAt = now.AddDays(-35), ModifiedBy = "C", Latest = false }; sg.ScenarioGroupDetails.Add(sgd); sgd = new ScenarioGroupDetail() { Name = "Macro", StartTime = DateTime.MinValue, EndTime = DateTime.MaxValue, CreatedAt = now.AddDays(-10), CreatedBy = "A", ModifiedAt = now.AddDays(-5), ModifiedBy = "C", Latest = true }; sg.ScenarioGroupDetails.Add(sgd); ScenarioGroup sgc = new ScenarioGroup() { StartTime = now.AddDays(-80), EndTime = DateTime.MaxValue, CreatedAt = now, CreatedBy = "A", ApprovedAt = now.AddDays(-80), ApprovedBy = "B", Latest = true }; context.ScenarioGroups.Add(sgc); sgd = new ScenarioGroupDetail() { Name = "Cyprus Contagion (v1)", StartTime = now.AddDays(-80), EndTime = now.AddDays(-40), CreatedAt = now.AddDays(-80), CreatedBy = "A", ApprovedAt = now.AddDays(-80), ApprovedBy = "B", ModifiedAt = now.AddDays(-80), ModifiedBy = "C", Latest = false }; sgc.ScenarioGroupDetails.Add(sgd); sgd.ScenarioGroupParent = sg; sgd = new ScenarioGroupDetail() { Name = "Cyprus Contagion (v2)", StartTime = now.AddDays(-40), EndTime = now.AddDays(-10), CreatedAt = now.AddDays(-50), CreatedBy = "A", ApprovedAt = now.AddDays(-40), ApprovedBy = "B", ModifiedAt = now.AddDays(-45), ModifiedBy = "C", Latest = false }; sgc.ScenarioGroupDetails.Add(sgd); sgd.ScenarioGroupParent = sg; sgd = new ScenarioGroupDetail() { Name = "Cyprus Contagion (v3)", StartTime = now.AddDays(-10), EndTime = DateTime.MaxValue, CreatedAt = now.AddDays(-20), CreatedBy = "A", ApprovedAt = now.AddDays(-10), ApprovedBy = "B", ModifiedAt = now.AddDays(-12), ModifiedBy = "C", Latest = false }; sgc.ScenarioGroupDetails.Add(sgd); sgd.ScenarioGroupParent = sg; sgd = new ScenarioGroupDetail() { Name = "Cyprus Contagion", StartTime = DateTime.MinValue, EndTime = DateTime.MaxValue, CreatedAt = now.AddDays(-5), CreatedBy = "A", ModifiedAt = now.AddDays(-3), ModifiedBy = "C", Latest = true }; sgc.ScenarioGroupDetails.Add(sgd); sgd.ScenarioGroupParent = sg; sgc = new ScenarioGroup() { StartTime = now.AddDays(-55), EndTime = DateTime.MaxValue, CreatedAt = now, CreatedBy = "A", ApprovedAt = now.AddDays(-55), ApprovedBy = "B", Latest = true }; context.ScenarioGroups.Add(sgc); sgd = new ScenarioGroupDetail() { Name = "Double Dip Recession (v1)", StartTime = now.AddDays(-55), EndTime = now.AddDays(-17), CreatedAt = now.AddDays(-80), CreatedBy = "A", ApprovedAt = now.AddDays(-55), ApprovedBy = "B", ModifiedAt = now.AddDays(-80), ModifiedBy = "C", ScenarioGroupParent = sg, Latest = false }; sgc.ScenarioGroupDetails.Add(sgd); sgd.ScenarioGroupParent = sg; sgd = new ScenarioGroupDetail() { Name = "Double Dip Recession", StartTime = now.AddDays(-17), EndTime = DateTime.MaxValue, CreatedAt = now.AddDays(-50), CreatedBy = "A", ApprovedAt = now.AddDays(-17), ApprovedBy = "B", ModifiedAt = now.AddDays(-18), ModifiedBy = "C", ScenarioGroupParent = sg, Latest = true }; sgc.ScenarioGroupDetails.Add(sgd); sgd.ScenarioGroupParent = sg; sgc = new ScenarioGroup() { StartTime = now.AddDays(-25), EndTime = DateTime.MaxValue, CreatedAt = now, CreatedBy = "A", ApprovedAt = now.AddDays(-55), ApprovedBy = "B", Latest = true }; context.ScenarioGroups.Add(sgc); sgd = new ScenarioGroupDetail() { Name = "Euro Breaks Up", StartTime = now.AddDays(-25), EndTime = DateTime.MaxValue, CreatedAt = now.AddDays(-80), CreatedBy = "A", ModifiedAt = now.AddDays(-18), ModifiedBy = "C", Latest = true }; sgc.ScenarioGroupDetails.Add(sgd); sgd.ScenarioGroupParent = sg; sgc = new ScenarioGroup() { StartTime = DateTime.MinValue, EndTime = DateTime.MaxValue, CreatedAt = now.AddDays(-80), CreatedBy = "A", Latest = true }; context.ScenarioGroups.Add(sgc); sgd = new ScenarioGroupDetail() { Name = "Eurozone Crisis", StartTime = DateTime.MinValue, EndTime = DateTime.MaxValue, CreatedAt = now.AddDays(-80), CreatedBy = "A", Latest = true }; sgc.ScenarioGroupDetails.Add(sgd); context.SaveChanges(); }
public void TestSaveNewScenarioGroup() { string name = "New Scenario Group"; ScenarioGroup main; ScenarioGroupDetail detail; using (var context = new ScenarioGeneratorModel(UserName, Connection)) { main = new ScenarioGroup(); main.Default(UserName); context.ScenarioGroups.Add(main); detail = new ScenarioGroupDetail(); detail.Default(UserName); detail.Name = name; main.ScenarioGroupDetails.Add(detail); context.SaveChanges(); } using (var context = new ScenarioGeneratorModel(UserName, Connection)) { context.Database.Log = s => System.Diagnostics.Debug.WriteLine(s); Assert.AreEqual(1, context.ScenarioGroupDetails.Where(x => x.Name == name).Count()); detail = context.ScenarioGroupDetails.Where(x => x.Name == name).FirstOrDefault(); main = detail.ScenarioGroup; Assert.AreEqual(name, detail.Name); Assert.AreEqual(true, detail.Latest); Assert.AreEqual(DateTime.MinValue, detail.StartTime); Assert.AreEqual(DateTime.MaxValue, detail.EndTime); Assert.AreEqual(EntityStatus.Unapproved, detail.Status); Assert.AreEqual(true, main.Latest); Assert.AreEqual(DateTime.MinValue, main.StartTime); Assert.AreEqual(DateTime.MaxValue, main.EndTime); Assert.AreEqual(DateTime.MaxValue, main.EndTime); Assert.AreEqual(EntityStatus.Unapproved, main.Status); } }
public void GetData(ScenarioGroup[] _groups, System.Action _endCallback = null) { groups = _groups; endCallback = _endCallback; }
public void WorkWithScenarios(ScenarioGroup[] groups, System.Action endCallback = null) { base.GetData(groups, endCallback); StartCoroutine("WorkWithScenario"); // SceneAnimationController.Instance.CallWorkWithScenario(); }