public liteRepositorySettings SettingsGetDefault(lm.Comol.Core.FileRepository.Domain.RepositoryType type, Int32 idCommunity = -1) { liteRepositorySettings result = null; switch (type) { case RepositoryType.Portal: result = SettingsGetDefault(SettingsGet(s => s.Deleted == DomainModel.BaseStatusDeleted.None && s.Status == ItemStatus.Active && (s.Type == SettingsType.Istance || s.Type == SettingsType.Portal))); break; default: if (idCommunity == -1) { idCommunity = UC.CurrentCommunityID; } Int32 idOrganization = Manager.GetIdOrganizationFromCommunity(idCommunity); result = SettingsGetDefault(SettingsGet(s => s.Deleted == DomainModel.BaseStatusDeleted.None && s.Status == ItemStatus.Active && (s.Type == SettingsType.Istance || s.Type == SettingsType.Portal || (s.Type == SettingsType.Organization && s.IdOrganization == idOrganization) || (s.Type == SettingsType.Community && s.IdCommunity == idCommunity)))); break; } return(result); }
/// <summary> /// SOLO file SCORM! /// SOLO comunità! /// ToDo: Generalizzare! /// </summary> /// <returns></returns> /// <remarks> /// In futuro: generalizzare... /// </remarks> public dtoScormFileListResponse GetCommunityScormFiles() { dtoScormFileListResponse response = new dtoScormFileListResponse(); response.Success = false; int communityId = (base.UC.CurrentCommunityID > 0) ? base.UC.CurrentCommunityID : base.UC.WorkingCommunityID; int personId = base.UC.CurrentUserID; //da \lm.Comol.Core.BaseModules\FileRepository\Presentation\Repository\Presentation\RepositoryPresenter.vb //IList<Domain.dtoFile> files = new List<dtoFile>(); lm.Comol.Core.FileRepository.Domain.RepositoryType type = RepositoryType.Community; if (communityId <= 0) { response.Files = null; response.ErrorInfo = GenericError.InvalidDataInput; return(response); } ModuleRepository module = RepService.GetPermissions(type, communityId, personId); //--> Old version error. if (module.ViewRepository) { Boolean isAdmin = module.ManageItems || module.Administration; //Boh, forse non serve... //int userTypeId = Manager.GetIdProfileType(personId); int userRoleId = Manager.GetSubscriptionIdRole(personId, communityId, true); IList <Int64> frItemIds = (from liteItemAssignments a in Manager.GetIQ <liteItemAssignments>() where (a.IdCommunity == communityId && ( ((a.Type == AssignmentType.role && a.IdRole == userRoleId) || (a.Type == AssignmentType.person && a.IdPerson == personId) || a.Type == AssignmentType.community) && a.Permissions > 0)) select a.IdItem).Distinct().ToList(); try { response.Files = (from RepositoryItem r in Manager.GetAll <RepositoryItem>(ri => ri.IsFile && frItemIds.Contains(ri.Id) && ri.Type == ItemType.ScormPackage && ri.Deleted == BaseStatusDeleted.None && (isAdmin || ri.IsVisible) ) select new dtoFile { Id = r.Id, LastUpdate = r.ModifiedOn.ToString(), LastVersionId = r.IdVersion, Name = r.Name, Extension = r.Extension, TotalDownload = r.Downloaded, Path = "--", TotalPlay = GetFilePlay(r.Id, communityId) } ).ToList(); } catch (Exception ex) { response.Files = null; response.ErrorInfo = GenericError.Internal; response.ServiceErrorCode = 100; string exception = ex.ToString(); //debug only } response.Success = true; response.ErrorInfo = GenericError.None; return(response); //AssignmentType.person //AssignmentType.role //AssignmentType.community //List<dtoDisplayRepositoryItem> items = RepService.GetAvailableRepositoryItems( // settings, // idCurrentUser, // type, // idCommunity, // View.GetUnknownUserName(), // View.GetFolderTypeTranslation(), // View.GetTypesTranslations(), // module, // admin, // admin); //// => //List<dtoRepositoryItem> fItems = RepService.GetFullRepository(identifier, unknownUser, useCache); //var query = Manager.GetIQ<liteRepositoryItem>(); //query = // query.Where( // i => !i.IsInternal && !i.IsVirtual && i.Repository != null); //query = // query.Where( // i => i.Repository.Type == RepositoryType.Community && i.Repository.IdCommunity == communityId); //List<dtoRepositoryItem> results = // items.Where(i => (father == null && i.IdFolder == 0) || (father != null && father.Id == i.IdFolder)) // .OrderBy(i => i.IsFile) // .ThenBy(i => i.Name) // .Select(i => new dtoRepositoryItem( // i, // father, // users.Where(o => o.Id == i.IdOwner).FirstOrDefault(), // users.Where(o => o.Id == i.IdModifiedBy).FirstOrDefault(), // unknownUser) // { // Path = (father == null) ? "/" : father.Path + father.Name + "/" // }) // .ToList(); //results.Where( // i => i.Type == ItemType.Folder) // .ToList() // .ForEach(i => i.Children = CreateNodes(items, i, users, unknownUser)); } else { response.Files = null; response.ErrorInfo = GenericError.NoServicePermission; return(response); } //return null; }