private static IList <Scenario> FetchScenariosFromDataFile(string dataFileLocation) { IList <Scenario> scenarios; XmlSerializer reader = new XmlSerializer(typeof(ScenariosData)); using (StreamReader file = new StreamReader(dataFileLocation)) { ScenariosData overview = (ScenariosData)reader.Deserialize(file); scenarios = overview.Scenarios; } return(scenarios); }
/// <summary> /// Méthode appelée lors du chargement /// </summary> protected override async Task OnLoading() { var projectId = ServiceBus.Get <IProjectManagerService>().CurrentProject.ProjectId; var prepareService = ServiceBus.Get <IPrepareService>(); _currentProject = await prepareService.GetProject(projectId); CurrentProjectInfo = prepareService.GetProjectSync(projectId); IsCurrentUserAdmin = Security.SecurityContext.HasCurrentUserRole(Security.KnownRoles.Administrator) && Security.SecurityContext.HasCurrentLicenseFeature(Security.Activation.ActivationFeatures.All); IsCurrentUserExporter = Security.SecurityContext.HasCurrentUserRole(Security.KnownRoles.Exporter) && Security.SecurityContext.HasCurrentLicenseFeature(Security.Activation.ActivationFeatures.All); IsRunningReadOnlyVersion = Security.SecurityContext.HasCurrentLicenseFeature(Security.Activation.ActivationFeatures.ReadOnly); ShowSpinner(); try { ScenariosData data = await ServiceBus.Get <IPrepareService>().GetScenarios(_currentProject.ProjectId); LoadScenarios(data); var current = ServiceBus.Get <IProjectManagerService>().CurrentScenario; if (current != null) { CurrentScenario = Scenarios.First(s => s.ScenarioId == current.Id); } HideSpinner(); } catch (Exception e) { base.OnError(e); } }
private void GetScenarios(int scenarioId) { var service = new PrepareService(); var mre = new System.Threading.ManualResetEvent(false); ScenariosData data = null; Exception e = null; service.GetScenarios(scenarioId, d => { data = d; mre.Set(); }, ex => { e = ex; mre.Set(); }); mre.WaitOne(); // Pour l'instant vérifie qu'aucune exception n'a été levée AssertExt.IsExceptionNull(e); }
public void BulkScenarioCloneTests() { SampleData.ClearDatabaseThenImportDefaultProject(); var service = new PrepareService(); int[] projectIds; using (var context = KProcess.Ksmed.Data.ContextFactory.GetNewContext()) { projectIds = context.Projects.Select(p => p.ProjectId).ToArray(); } foreach (var pid in projectIds) { var mre = new System.Threading.ManualResetEvent(false); Exception e = null; ScenariosData data = null; service.GetScenarios(pid, d => { data = d; mre.Set(); }, ex => { e = ex; mre.Set(); }); mre.WaitOne(); AssertExt.IsExceptionNull(e); Assert.IsNotNull(data); foreach (var scenario in data.Scenarios.Where(s => s.NatureCode != KnownScenarioNatures.Realized)) { if (scenario.NatureCode == KnownScenarioNatures.Target && scenario.Actions.Any(a => !a.IsReduced)) { // Il s'agit d'un vieux projet. Tous les actions d'un scénario cible doivent aujourd'hui avoir une partie réduite continue; } mre.Reset(); Scenario newScenario = null; service.CreateScenario(pid, scenario, true, s => { newScenario = s; mre.Set(); }, ex => { e = ex; mre.Set(); }); mre.WaitOne(); AssertExt.IsExceptionNull(e); Assert.IsNotNull(newScenario); // Vérification de l'intégrité du scénario ActionsTimingsMoveManagement.DebugCheckAllWBS(EnumerableExt.Concat(newScenario)); // Vérifier qu'il n'y ai pas de tâche avec un temps process nul if (scenario.NatureCode != KnownScenarioNatures.Initial && newScenario.Actions.Any(a => a.BuildDuration <= 0)) { Assert.Fail("Une action a un temps invalide"); } } } }