private List <dtoModuleActionControl> GenerateActions(ModuleLink link, liteBaseCommunityFile item) { List <dtoModuleActionControl> actions = new List <dtoModuleActionControl>(); String serviceCode = link.DestinationItem.ServiceCode; Int32 IdModule = link.DestinationItem.ServiceID; Boolean allowDownload = View.AllowDownload(item.RepositoryItemType) && item.IsDownloadable && item.isFile; allowDownload = true; if (typeof(liteCommunityFile) != item.GetType()) { serviceCode = link.SourceItem.ServiceCode; IdModule = link.SourceItem.ServiceID; } String baseUrl = View.GetBaseUrl; int idCommunity = 0; if (item.CommunityOwner != null) { idCommunity = item.CommunityOwner.Id; } Boolean notSaveStat = (View.Display == DisplayActionMode.adminMode); switch (item.RepositoryItemType) { case RepositoryItemType.FileStandard: actions.Add(new dtoModuleActionControl(RootObject.DownloadFileFromModule(item.Id, (long)UserContext.CurrentUserID, UserContext.Language.Code, UserContext.WorkSessionID, View.ServiceID, idCommunity, link.Id, notSaveStat), StandardActionType.Play, true)); actions.Add(new dtoModuleActionControl(RootObject.DownloadFileFromModule(item.Id, (long)UserContext.CurrentUserID, UserContext.Language.Code, UserContext.WorkSessionID, View.ServiceID, idCommunity, link.Id, notSaveStat), StandardActionType.DownloadItem, true)); break; case RepositoryItemType.ScormPackage: if (typeof(liteModuleInternalFile) == item.GetType()) { liteModuleInternalFile internalFile = (liteModuleInternalFile)item; actions.Add(new dtoModuleActionControl(View.GetUrlForPlayScorm(link.Id, internalFile.Id, internalFile.UniqueID, idCommunity, link.SourceItem.ServiceID, internalFile.ServiceActionAjax, notSaveStat), StandardActionType.Play, true)); } else { actions.Add(new dtoModuleActionControl(View.GetUrlForPlayScorm(link.Id, item.Id, item.UniqueID, idCommunity, IdModule, notSaveStat), StandardActionType.Play, true)); } actions.Add(new dtoModuleActionControl(baseUrl + RootObject.EditScormPackageSettings(item.Id, link.Id, View.DestinationUrl, View.PreLoadedContentView), StandardActionType.EditMetadata, false)); actions.Add(new dtoModuleActionControl(baseUrl + RootObject.ManagementScormStatistics(item.Id, View.DestinationUrl, View.PreLoadedContentView), StandardActionType.ViewAdvancedStatistics, false)); actions.Add(new dtoModuleActionControl(baseUrl + RootObject.ManagementScormStatistics(item.Id, View.ForUserId, View.DestinationUrl, View.PreLoadedContentView), StandardActionType.ViewUserStatistics, false)); actions.Add(new dtoModuleActionControl(baseUrl + RootObject.UserScormStatistics(item.Id, View.DestinationUrl, View.PreLoadedContentView), StandardActionType.ViewPersonalStatistics, false)); if (allowDownload) { actions.Add(new dtoModuleActionControl(RootObject.DownloadFileFromModule(item.Id, (long)UserContext.CurrentUserID, UserContext.Language.Code, UserContext.WorkSessionID, View.ServiceID, idCommunity, link.Id, notSaveStat), StandardActionType.DownloadItem, true)); } break; case RepositoryItemType.Multimedia: case RepositoryItemType.VideoStreaming: if (typeof(liteModuleInternalFile) == item.GetType()) { liteModuleInternalFile internalFile = (liteModuleInternalFile)item; actions.Add(new dtoModuleActionControl(RootObject.PlayMultimediaFileFromModule(internalFile.Id, internalFile.UniqueID, UserContext.CurrentUserID, UserContext.Language.Code, notSaveStat, link.SourceItem.ServiceID, idCommunity, link.Id, internalFile.ServiceActionAjax, View.PreLoadedContentView), StandardActionType.Play, true)); } else { actions.Add(new dtoModuleActionControl(RootObject.PlayMultimediaFile(link.Id, item.Id, item.UniqueID, UserContext.CurrentUserID, UserContext.Language.Code, notSaveStat, View.PreLoadedContentView), StandardActionType.Play, true)); } actions.Add(new dtoModuleActionControl(baseUrl + RootObject.EditMultimediaFileSettings(item.Id, link.Id, View.DestinationUrl, View.PreLoadedContentView), StandardActionType.EditMetadata, false)); if (allowDownload) { actions.Add(new dtoModuleActionControl(RootObject.DownloadFileFromModule(item.Id, (long)UserContext.CurrentUserID, UserContext.Language.Code, UserContext.WorkSessionID, View.ServiceID, idCommunity, link.Id, notSaveStat), StandardActionType.DownloadItem, true)); } break; case RepositoryItemType.Folder: break; } actions.Where(a => a.LinkUrl.Contains("//")).ToList().ForEach(a => a.LinkUrl = a.LinkUrl.Replace("//", "/")); return(actions); }
private void DisplayDefaultAction(ModuleLink link, liteBaseCommunityFile item, DisplayActionMode display) { if (typeof(liteCommunityFile) == item.GetType()) { View.ServiceCode = link.DestinationItem.ServiceCode; View.ServiceID = link.DestinationItem.ServiceID; } else { View.ServiceCode = link.SourceItem.ServiceCode; View.ServiceID = link.SourceItem.ServiceID; } int idCommunity = 0; if (item.CommunityOwner != null) { idCommunity = item.CommunityOwner.Id; } Boolean notSaveStat = (display == DisplayActionMode.adminMode); switch (link.Action) { case (int)CoreModuleRepository.ActionType.CreateFolder: View.DisplayCreateFolder(item.Name); break; case (int)CoreModuleRepository.ActionType.UploadFile: View.DisplayUploadFile(item.Name); break; case (int)CoreModuleRepository.ActionType.DownloadFile: View.DisplayItem(item.DisplayName, RootObject.DownloadFileFromModule(item.Id, (long)UserContext.CurrentUserID, UserContext.Language.Code, UserContext.WorkSessionID, View.ServiceID, idCommunity, link.Id, notSaveStat), item.Extension, item.Size, item.RepositoryItemType); break; case (int)CoreModuleRepository.ActionType.PlayFile: View.ServiceCode = link.SourceItem.ServiceCode; View.ServiceID = link.SourceItem.ServiceID; String url = ""; if (typeof(liteModuleInternalFile) == item.GetType()) { liteModuleInternalFile internalFile = (liteModuleInternalFile)item; url = (internalFile.RepositoryItemType == RepositoryItemType.ScormPackage) ? View.GetUrlForPlayScorm(link.Id, internalFile.Id, internalFile.UniqueID, idCommunity, View.ServiceID, internalFile.ServiceActionAjax, notSaveStat) : View.GetUrlForMultimediaFile() + RootObject.PlayMultimediaFileFromModule(internalFile.Id, internalFile.UniqueID, UserContext.CurrentUserID, UserContext.Language.Code, notSaveStat, View.ServiceID, idCommunity, link.Id, internalFile.ServiceActionAjax, View.PreLoadedContentView); } else { url = (item.RepositoryItemType == RepositoryItemType.ScormPackage) ? View.GetUrlForPlayScorm(link.Id, item.Id, item.UniqueID, idCommunity, link.SourceItem.ServiceID, notSaveStat) : View.GetUrlForMultimediaFile() + RootObject.PlayMultimediaFile(link.Id, item.Id, item.UniqueID, UserContext.CurrentUserID, UserContext.Language.Code, notSaveStat, View.PreLoadedContentView); } View.DisplayPlayItem(item.Name, url, item.RepositoryItemType); break; case 0: View.DisplayFolder(item.Name); break; } }