protected void ScenariosChanged(object sender, NotifyCollectionChangedEventArgs e) { var scenariosNew = (e.NewItems ?? new object[0]).Cast <Scenario>(); var scenariosOld = (e.OldItems ?? new object[0]).Cast <Scenario>(); lock (_scenariosInternal) { // Remove all. if (e.Action == NotifyCollectionChangedAction.Reset) { _scenariosInternal.Clear(); } // Remove individuals. else if (e.Action == NotifyCollectionChangedAction.Remove || e.Action == NotifyCollectionChangedAction.Replace) { foreach (var old in scenariosOld) { var oldRecord = _scenariosInternal .FirstOrDefault(o => o.Scenario == old); _scenariosInternal.Remove(oldRecord); } } // Add new. else if (e.Action == NotifyCollectionChangedAction.Add || e.Action == NotifyCollectionChangedAction.Replace) { foreach (var @new in scenariosNew) { @new.Workbench = this; FObservation evidence = @new.Evidence; InferenceQuery query = new InferenceQuery( @new.BayesianNetwork, evidence); query.WarmupSize = this.InferenceWarmupSize; query.ParticleSeparation = this.InferenceParticleSeparation; ScenarioRecord record = new ScenarioRecord( @new, query); _scenariosInternal.Add(record); } } } }
// http://officedeploycenter/api/Provoke.Highlights/Highlights/AddTestData public string AddTestData() { var highlightsScenario = new ScenarioRecord { Title = "Highlights", Description = "Setting up your own domain", }; _scenarioRepository.Create(highlightsScenario); _scenarioRepository.Flush(); var addYourDomainTask = new TaskRecord { ScenarioRecord = highlightsScenario, SortOrder = 1, Description = "Add your domain", }; _taskRepository.Create(addYourDomainTask); var verifyYourDomainTask = new TaskRecord { ScenarioRecord = highlightsScenario, SortOrder = 2, Description = "Verify your domain", }; _taskRepository.Create(verifyYourDomainTask); var defineDomainUseTask = new TaskRecord { ScenarioRecord = highlightsScenario, SortOrder = 3, Description = "Define domain use", }; _taskRepository.Create(defineDomainUseTask); var updateDnsTask = new TaskRecord { ScenarioRecord = highlightsScenario, SortOrder = 4, Description = "Update DNS records", }; _taskRepository.Create(updateDnsTask); _taskRepository.Flush(); var addDomainStep1 = new StepRecord { TaskRecord = addYourDomainTask, SortOrder = 1, TopPosition = 200, LeftPosition =300, Title = "White", Description = "In the Office 365 admin center, click 'Domains'.", Image = "/Media/Default/images/gettingStarted.png", }; _stepRepository.Create(addDomainStep1); var addDomainStep2 = new StepRecord { TaskRecord = addYourDomainTask, SortOrder = 2, TopPosition = 300, LeftPosition = 300, Title = "Yellow", Description = "Now click 'Add domain'.", Image = "/Media/Default/images/onboarding.png", }; _stepRepository.Create(addDomainStep2); var verifyYourDomainStep = new StepRecord { TaskRecord = verifyYourDomainTask, SortOrder = 1, TopPosition = 300, LeftPosition = 200, Title = "Red", Description = "Define how you'll use your domain (this is, stat the purpose for the domain) by selecting the Office 365 services you're planning to use: Exchange Online, Lync Online, SharePoint Online, or a combination.", Image = "/Media/Default/images/email.png", }; _stepRepository.Create(verifyYourDomainStep); var defineDomainUseStep1 = new StepRecord { TaskRecord = defineDomainUseTask, SortOrder = 1, TopPosition = 400, LeftPosition = 300, Title = "Blue", Description = "Define how you'll use your domain (this is, stat the purpose for the domain) by selecting the Office 365 services you're planning to use: Exchange Online, Lync Online, SharePoint Online, or a combination.", Image = "/Media/Default/images/assistance-1.png", Anchor = "http://anchor.com", }; _stepRepository.Create(defineDomainUseStep1); var updateDnsRecordsStep = new StepRecord { TaskRecord = updateDnsTask, SortOrder = 1, TopPosition = 300, LeftPosition = 400, Title = "Green", Description = "Update your DNS records at your hosting provider or domain registrar to point to these services in Office 365.", Image = "/Media/Default/images/management.png", }; _stepRepository.Create(updateDnsRecordsStep); return "Success"; }
protected void ScenariosChanged(object sender, NotifyCollectionChangedEventArgs e) { var scenariosNew = (e.NewItems ?? new object[0]).Cast<Scenario>(); var scenariosOld = (e.OldItems ?? new object[0]).Cast<Scenario>(); lock (_scenariosInternal) { // Remove all. if (e.Action == NotifyCollectionChangedAction.Reset) { _scenariosInternal.Clear(); } // Remove individuals. else if (e.Action == NotifyCollectionChangedAction.Remove || e.Action == NotifyCollectionChangedAction.Replace) { foreach (var old in scenariosOld) { var oldRecord = _scenariosInternal .FirstOrDefault(o => o.Scenario == old); _scenariosInternal.Remove(oldRecord); } } // Add new. else if (e.Action == NotifyCollectionChangedAction.Add || e.Action == NotifyCollectionChangedAction.Replace) { foreach (var @new in scenariosNew) { @new.Workbench = this; FObservation evidence = @new.Evidence; InferenceQuery query = new InferenceQuery( @new.BayesianNetwork, evidence); query.WarmupSize = this.InferenceWarmupSize; query.ParticleSeparation = this.InferenceParticleSeparation; ScenarioRecord record = new ScenarioRecord( @new, query); _scenariosInternal.Add(record); } } } }
private static List<TaskRecord> OrderSteps(ScenarioRecord result) { foreach (var task in result.Tasks) { task.Steps = task.Steps.OrderBy(s => s.SortOrder).ToList(); } return result.Tasks.OrderBy(t => t.SortOrder).ToList(); }