Пример #1
0
        /// <summary>
        /// Retrieve all the headers that needs to be displayed in the grid
        /// </summary>
        /// <param name="project"></param>
        /// <param name="serviceReferentials"></param>
        /// <param name="includeOnlyReferentialsAndCustom"></param>
        /// <returns></returns>
        public static async Task <Dictionary <string, string> > GetHeaders(
            int processId,
            IReferentialsService referentialsService,
            bool includeOnlyReferentialsAndCustom = false)
        {
            var LocalizedStrings = DependencyResolver.Current.GetService <ILocalizationManager>();

            var documentationReferentials = await referentialsService.GetDocumentationReferentials(processId);

            var headers = !includeOnlyReferentialsAndCustom ? new Dictionary <string, string>
            {
                [nameof(PublishedAction.WBS)]               = "Id",
                [nameof(PublishedAction.Label)]             = LocalizedStrings.GetString("Grid_LabelHeaderText"),
                [nameof(PublishedAction.Thumbnail)]         = LocalizedStrings.GetString("Grid_ThumbnailHeaderText"),
                [nameof(PublishedAction.Duration)]          = LocalizedStrings.GetString("Grid_DurationHeaderText"),
                [nameof(PublishedAction.PublishedResource)] = LocalizedStrings.GetString("Grid_PublishedResourceHeaderText")
            } : new Dictionary <string, string>();

            foreach (var docRef in documentationReferentials.Where(_ => _.IsEnabled))
            {
                switch (docRef.ReferentialId)
                {
                case ProcessReferentialIdentifier.Category:
                    headers.Add(nameof(PublishedAction.PublishedActionCategory),
                                docRef.Label);
                    break;

                case ProcessReferentialIdentifier.Skill:
                    headers.Add(docRef.ReferentialId.ToString(),
                                docRef.Label);
                    break;

                case ProcessReferentialIdentifier.Ref1:
                case ProcessReferentialIdentifier.Ref2:
                case ProcessReferentialIdentifier.Ref3:
                case ProcessReferentialIdentifier.Ref4:
                case ProcessReferentialIdentifier.Ref5:
                case ProcessReferentialIdentifier.Ref6:
                case ProcessReferentialIdentifier.Ref7:
                    headers.Add(docRef.ReferentialId.ToString().Insert(3, "s"),
                                docRef.Label);
                    break;

                case ProcessReferentialIdentifier.CustomTextLabel:
                    headers.Add(nameof(PublishedAction.CustomTextValue), docRef.Label);
                    break;

                case ProcessReferentialIdentifier.CustomTextLabel2:
                    headers.Add(nameof(PublishedAction.CustomTextValue2), docRef.Label);
                    break;

                case ProcessReferentialIdentifier.CustomTextLabel3:
                    headers.Add(nameof(PublishedAction.CustomTextValue3), docRef.Label);
                    break;

                case ProcessReferentialIdentifier.CustomTextLabel4:
                    headers.Add(nameof(PublishedAction.CustomTextValue4), docRef.Label);
                    break;

                case ProcessReferentialIdentifier.CustomNumericLabel:
                    headers.Add(nameof(PublishedAction.CustomNumericValue), docRef.Label);
                    break;

                case ProcessReferentialIdentifier.CustomNumericLabel2:
                    headers.Add(nameof(PublishedAction.CustomNumericValue2), docRef.Label);
                    break;

                case ProcessReferentialIdentifier.CustomNumericLabel3:
                    headers.Add(nameof(PublishedAction.CustomNumericValue3), docRef.Label);
                    break;

                case ProcessReferentialIdentifier.CustomNumericLabel4:
                    headers.Add(nameof(PublishedAction.CustomNumericValue4), docRef.Label);
                    break;
                }
            }

            return(headers);
        }
Пример #2
0
        /// <summary>
        /// Show more information about an action
        /// Routing create to be able to access as: /Action/Id
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task <ActionResult> Details(int?PublishModeFilter, int?id, bool computeReadNext = false, bool partial = false)
        {
            if (!id.HasValue)
            {
                return(HttpNotFound());
            }

            var action = await _prepareService.GetPublishedAction(id.Value);

            if (action == null)
            {
                return(HttpNotFound());
            }

            var publication = await _prepareService.GetLightPublication(action.Publication.PublicationId);

            ViewBag.ComputeReadNext   = computeReadNext;
            ViewBag.publishModeFilter = PublishModeFilter.Value;

            // TODO : Faire le calcul du chemin critique en incluant les tâches des sous-process
            // Change to normal WBS order (alphanumeric)
            //if (computeReadNext)
            //{
            //    var tempCriticalPath = publication.PublishedActions.CriticalPath(p => p.Successors, p => p.BuildFinish - p.BuildStart);
            //    var criticalPath = new List<PublishedAction>();
            //    for (int i = tempCriticalPath.Count(); i > 0; i--)
            //        criticalPath.Add(tempCriticalPath.ElementAt(i - 1));

            //    var nextActionIndex = criticalPath.IndexOf(criticalPath.First(u => u.PublishedActionId == id)) + 1;
            //    ViewBag.NextAction = nextActionIndex >= criticalPath.Count ? 0 : criticalPath[nextActionIndex].PublishedActionId;

            //}


            var actionIndex = action.Publication.PublishedActions.OrderBy(a => a, new WBSComparer()).Select(p => p.PublishedActionId).ToList().IndexOf(action.PublishedActionId);
            var previousId  = actionIndex - 1 >= 0 ? action.Publication.PublishedActions.OrderBy(a => a, new WBSComparer()).Select(p => p.PublishedActionId).ToList().ElementAtOrDefault(actionIndex - 1) : 0;
            var nextId      = action.Publication.PublishedActions.OrderBy(a => a, new WBSComparer()).Select(p => p.PublishedActionId).ToList().ElementAtOrDefault(actionIndex + 1);

            var localizations             = action.Publication.Localizations.ToDictionary(k => k.ResourceKey, v => v.Value);
            var documentationReferentials = await _referentialsService.GetDocumentationReferentials(action.Publication.ProcessId);

            localizations = ActionMapper.UpdateLocalizationLabelForDetail(localizations, documentationReferentials);
            var visibleColumns = ActionMapper.GetDetailDispositions(action.Publication, (PublishModeEnum)PublishModeFilter.Value);
            var values         = new Dictionary <string, ActionColumnViewModel>();
            var actionHeaders  = ActionMapper.GetDetailColumnHeader(visibleColumns, localizations);

            if (computeReadNext)
            {
                ViewBag.NextAction = nextId;
            }

            foreach (var setting in visibleColumns)
            {
                (List <RefsCollection> refs, List <CustomLabel> customLabel) = ActionMapper.BuildReferenceAndCustomLabel(action, localizations);
                var attribute = ReflectionHelper.GetPropertyValue(action, setting);
                values.Add(setting, ActionMapper.GetPublishedActionAttributes(action, attribute, setting, setting, localizations, refs, customLabel));
            }

            //Populate Action detail dispositions
            var detailsDisposition = new List <string>();

            if ((PublishModeEnum)PublishModeFilter.Value == PublishModeEnum.Formation)
            {
                if (publication.Formation_ActionDisposition.IsNotNullNorEmpty())
                {
                    detailsDisposition = publication.Formation_ActionDisposition.Split(',').ToList();
                }
            }
            else if ((PublishModeEnum)PublishModeFilter.Value == PublishModeEnum.Inspection)
            {
                if (publication.Inspection_ActionDisposition.IsNotNullNorEmpty())
                {
                    detailsDisposition = publication.Inspection_ActionDisposition.Split(',').ToList();
                }
            }



            var model = new GenericActionViewModel
            {
                ActionHeaders  = actionHeaders,
                ActionId       = action.PublishedActionId,
                Label          = action.Label,
                ColumnValues   = values,
                VideoExtension = action.CutVideo != null?MimeMapping.GetMimeMapping(action.CutVideo.Extension) : null,
                                     VideoHash                 = action.CutVideo?.Hash,
                                     VideoExt                  = action.CutVideo?.Extension,
                                     ProcessId                 = action.Publication.ProcessId,
                                     ProcessLabel              = action.Publication.Process.Label,
                                     PublicationVersion        = action.Publication.Version,
                                     PublicationVersionIsMajor = action.Publication.IsMajor,
                                     PreviousActionId          = previousId,
                                     NextActionId              = nextId,
                                     IsKeyTask                 = action.IsKeyTask,
                                     PublishModeFilter         = PublishModeFilter.Value,
                                     DetailActionDispositions  = detailsDisposition
            };

            if (partial)
            {
                return(PartialView(model));
            }

            return(View(model));
        }