コード例 #1
0
        /// <summary>
        /// Crée une instance de <see cref="ProjectExport"/>.
        /// </summary>
        /// <param name="context">Le contexte.</param>
        /// <param name="projectId">L'identifiant du projet.</param>
        /// <returns>Le <see cref="ProjectExport"/></returns>
        internal async Task <ProjectExport> CreateProjectExport(KsmedEntities context, int projectId)
        {
            var referentialsUsed = await SharedScenarioActionsOperations.GetReferentialsUse(context, projectId);

            await Queries.LoadAllReferentialsOfProject(context, projectId, referentialsUsed);

            var project = await context.Projects
                          .Include("Videos")
                          .Include("Referentials")
                          .FirstAsync(s => s.ProjectId == projectId);

            var scenarios = await context.Scenarios
                            .Where(s => s.ProjectId == projectId &&
                                   (s.NatureCode == KnownScenarioNatures.Initial || s.NatureCode == KnownScenarioNatures.Target || s.NatureCode == KnownScenarioNatures.Realized))
                            .ToArrayAsync();

            await Queries.LoadScenariosDetails(context, scenarios, referentialsUsed);

            return(new ProjectExport()
            {
                AppVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(),
                Project = project,
                ReferentialsStandard = ReferentialsHelper.GetAllReferentialsStandardUsed(project).ToArray(),
                ReferentialsProject = ReferentialsHelper.GetAllReferentialsProject(project).ToArray(),
            });
        }
コード例 #2
0
        public void GetActionsDurationsTest()
        {
            SampleData.ClearDatabaseThenImportDefaultProject();
            using (var ctx = KProcess.Ksmed.Data.ContextFactory.GetNewContext())
            {
                var lastScenario = ctx.Scenarios
                                   .Include("Actions")
                                   .OrderByDescending(s => s.ScenarioId)
                                   .First();

                var res = SharedScenarioActionsOperations.GetActionsBuildDurations(
                    KProcess.Ksmed.Data.ContextFactory.GetNewContext(),
                    new int[] { lastScenario.Actions[0].ActionId, lastScenario.Actions[1].ActionId });

                Assert.IsTrue(res.Any());
            }
        }
コード例 #3
0
        /// <summary>
        /// Charge les données globales relatives à la décomposition.
        /// </summary>
        private async Task LoadGlobalData()
        {
            var referentialsUsed = await SharedScenarioActionsOperations.GetReferentialsUse(_context, _projectId);

            _actions = await _context.KActions
                       .Include("Predecessors")
                       .Where(a => a.ScenarioId == _scenarioId)
                       .ToArrayAsync();

            await Queries.LoadActionsReferentials(_context, _actions, referentialsUsed);

            _video = await _context.Videos
                     .Include("DefaultResource")
                     .SingleAsync(v => v.VideoId == _videoId);

            _project = (await _context.Scenarios
                        .Include("Project")
                        .FirstAsync(s => s.ScenarioId == _scenarioId))
                       .Project;
        }
コード例 #4
0
        private void ImportActions()
        {
            // Trier les actions par WBS
            _actions = _import.ExportedVideoDecomposition.Actions.OrderBy(a => WBSHelper.GetParts(a.WBS), new WBSHelper.WBSComparer()).ToArray();

            // Actions
            var parents = new Dictionary <KAction, KAction>();

            // Faire une liste des parents
            foreach (var action in _actions)
            {
                var parent = WBSHelper.GetParent(action, _actions);
                if (parent != null)
                {
                    parents[action] = parent;
                }
            }

            foreach (var action in _actions)
            {
                action.ActionId = default(int);

                action.OriginalActionId = null;
                SharedScenarioActionsOperations.ApplyNewReduced(action, KnownActionCategoryTypes.I);

                // Réinitialiser les timings
                // Ils seront ensuite automatiquement recalculés en fonction des pred/succ
                action.BuildStart    = 0;
                action.BuildDuration = action.Duration;

                var parent = parents.ContainsKey(action) ? parents[action] : null;

                ActionsTimingsMoveManagement.InsertUpdateWBS(_targetScenario.Actions.ToArray(), action, parent, -1);
                _targetScenario.Actions.Add(action);
            }
        }