public void InitView(dtoDisplayItemRepository item, String currentUrl, int IdModule, int IdCommunity, int idAction, ItemDisplayView view, ItemDisplayMode mode, ItemDescriptionDisplayMode descriptionDisplay, ItemAvailableCommand commands)
        {
            View.DisplayView            = view;
            View.DisplayMode            = mode;
            View.DescriptionDisplayMode = descriptionDisplay;
            View.AvailableCommands      = commands;
            if (item == null || item.File == null)
            {
                View.DisplayUnknownItem();
            }
            // codice file cancellato
            //else if (={}
            else if (UserContext.isAnonymous)
            {
                View.DisplayItemName(item);
            }
            else
            {
                switch (item.File.RepositoryItemType)
                {
                case RepositoryItemType.ScormPackage:
                case RepositoryItemType.FileStandard:
                case RepositoryItemType.None:
                    View.DisplayItem(item, currentUrl, IdModule, IdCommunity, idAction);
                    break;

                case RepositoryItemType.Folder:
                    View.DisplayFolder(item, View.FolderNavigationUrl, IdModule, IdCommunity, idAction);
                    break;

                case RepositoryItemType.VideoStreaming:
                    View.DisplayItem(item, currentUrl, IdModule, IdCommunity, idAction);
                    break;

                case RepositoryItemType.Multimedia:
                    MultimediaFileTransfer fileTransfer = Service.GetMultimediaFileTransfer(item.File);
                    String url = "";
                    if (fileTransfer == null || fileTransfer.DefaultDocument == null)
                    {
                        item.Permission.Play = false;
                    }
                    else
                    {
                        url = fileTransfer.DefaultDocument.Fullname;
                    }
                    View.DisplayMultimediaItem(item, currentUrl, url, IdModule, IdCommunity, idAction);
                    break;

                default:
                    break;
                }
            }
        }
        public void InitView()
        {
            int  IdUser      = UserContext.CurrentUserID;
            int  idCommunity = UserContext.CurrentCommunityID;
            long IdLink      = View.PreloadedIdLink;
            long IdFile      = View.PreloadedIdFile;

            View.BackUrl = View.PreloadedBackUrl;
            View.IdFile  = IdFile;
            View.IdLink  = IdLink;
            View.AllowSetDefaultDocument = false;
            BaseCommunityFile item = Service.GetItem(IdFile);

            if (item != null && item.CommunityOwner != null)
            {
                idCommunity = item.CommunityOwner.Id;
            }
            if (UserContext.isAnonymous)
            {
                View.SendToSessionExpiredPage(idCommunity, UserContext.Language.Code);
            }
            else if (item == null)
            {
                View.LoadFileNotExist();
            }
            else if (item.RepositoryItemType == RepositoryItemType.Multimedia)
            {
                RepositoryItemPermission permissions = new RepositoryItemPermission();
                if (IdLink == 0 || item.GetType() == typeof(CommunityFile))
                {
                    CoreModuleRepository module = null;
                    if (item.CommunityOwner == null)
                    {
                        module = CoreModuleRepository.CreatePortalmodule(UserContext.UserTypeID);
                    }
                    else if (!item.IsInternal)
                    {
                        module = new CoreModuleRepository(CurrentManager.GetModulePermission(IdUser, item.CommunityOwner.Id, ModuleID));
                    }
                    else
                    {
                        module = new CoreModuleRepository();
                    }
                    if (Service.HasPermissionToSeeRepositoryItem(item.Id, module.Administration, module.Administration, IdUser))
                    {
                        permissions = new dtoDisplayItemRepository(item, module, IdUser, module.Administration).Permission;
                    }
                }
                else
                {
                    ModuleLink link = Service.GetModuleLink(IdLink);
                    permissions = View.GetModuleLinkPermission(link.SourceItem.CommunityID, IdUser, link);
                }
                if (permissions.EditSettings)
                {
                    MultimediaFileTransfer multimedia = Service.GetMultimediaFileTransfer(item);
                    if (multimedia == null)
                    {
                        View.LoadFileNotExist();
                    }
                    else if (multimedia.MultimediaIndexes.Count == 0)
                    {
                        View.LoadFileWithoutIndex(item);
                    }
                    else
                    {
                        View.AllowSetDefaultDocument = permissions.EditSettings;
                        View.LoadTree(item, (from m in multimedia.MultimediaIndexes select m.Fullname.Replace(item.UniqueID.ToString() + "\\", "")).ToList(), (multimedia.DefaultDocument == null) ? "" : multimedia.DefaultDocument.Fullname.Replace(item.UniqueID.ToString() + "\\", ""));
                    }
                }
                else
                {
                    View.LoadFileNoPermission();
                }
            }
            else
            {
                View.LoadInvalidFileType(item);
            }
        }
Exemplo n.º 3
0
        public void InitView(String plattformId)
        {
            long idLink = View.PlayerIdLink;
            int  IdUser = UserContext.CurrentUserID;

            if (UserContext.isAnonymous)
            {
                View.SendToSessionExpiredPage(View.PlayerIdCommunity, View.PreloadedLanguage);
            }
            else
            {
                Guid playUniqueSessionId = Guid.NewGuid();
                View.PlayUniqueSessionId = playUniqueSessionId;
                String playSessionId = plattformId + "_" + playUniqueSessionId.ToString();
                View.PlaySessionId = playSessionId;

                Boolean           allowPlay = false;
                BaseCommunityFile item      = Service.GetItem(View.PlayerIdFile);
                if (item == null)
                {
                    View.LoadFileNotExist();
                }
                else
                {
                    if (idLink == 0 && View.PlayerIdModule == ModuleID)
                    {
                        int idCommunity = View.PlayerIdCommunity;
                        if (item.CommunityOwner != null && idCommunity == 0)
                        {
                            idCommunity            = item.CommunityOwner.Id;
                            View.PlayerIdCommunity = idCommunity;
                        }
                        allowPlay = HasPermissionForRepository(item, IdUser, idCommunity, View.PlayerIdModule);
                    }
                    else if (idLink > 0)
                    {
                        allowPlay = lm.Comol.Core.DomainModel.PermissionHelper.CheckPermissionSoft((long)CoreModuleRepository.Base2Permission.DownloadFile, View.GetPermissionToLink(IdUser, idLink, item, View.PlayerIdCommunity));
                    }

                    if (!allowPlay)
                    {
                        View.LoadFileNoPermission();
                    }
                    else if (item.RepositoryItemType == DomainModel.Repository.RepositoryItemType.FileStandard && item.RepositoryItemType == DomainModel.Repository.RepositoryItemType.Folder)
                    {
                        View.InvalidFileTypeToPlay(item.RepositoryItemType);
                    }
                    else if (Service.GetItemTransferStatus(item.UniqueID) == DomainModel.Repository.TransferStatus.Completed)
                    {
                        //if (item.RepositoryItemType== DomainModel.Repository.RepositoryItemType.ScormPackage)
                        Boolean autoEvaluate = (from l in CurrentManager.GetIQ <ModuleLink>() where l.Id == idLink && l.AutoEvaluable select l.Id).Any() && View.PlayerSavingStatistics;

                        if (View.PlayerSavingStatistics)
                        {
                            Service.SaveUserAccessToFile(playSessionId, IdUser, item, idLink);
                        }
                        switch (item.RepositoryItemType)
                        {
                        case DomainModel.Repository.RepositoryItemType.ScormPackage:
                            View.LoadFileIntoPlayer(playSessionId, View.PlayerWorkingSessionID, item.UniqueID, IdUser, idLink, item.Id, item.RepositoryItemType);
                            break;

                        case DomainModel.Repository.RepositoryItemType.Multimedia:
                            MultimediaFileTransfer fileTransfer = Service.GetMultimediaFileTransfer(item);
                            if (fileTransfer == null || fileTransfer.DefaultDocument == null)
                            {
                                View.InvalidFileTypeToPlay(item.RepositoryItemType);
                            }
                            else
                            {
                                View.LoadMultimediaFileIntoPlayer(playSessionId, View.PlayerWorkingSessionID, item.UniqueID, IdUser, idLink, item.Id, fileTransfer.DefaultDocumentPath.Replace("\\", "/"));
                                if (autoEvaluate)
                                {
                                    View.SaveLinkEvaluation(idLink, IdUser);
                                }
                            }
                            break;
                        }
                    }
                    else
                    {
                        View.LoadFileNoReadyToPlay(item.RepositoryItemType, Service.GetItemTransferStatus(item.UniqueID));
                    }
                }
            }
        }