示例#1
0
        private dtoContainerQuota CalculateRepositoryMaxSize(String filePath, DiskSettings settings, Boolean overrideQuota, long usedSize = 0)
        {
            dtoContainerQuota item = new dtoContainerQuota();

            item.UsedSize = usedSize;
            try
            {
                if (!String.IsNullOrEmpty(filePath))
                {
                    item.DiskSize = -1;
                }
                ulong space = 0;
                if (!String.IsNullOrEmpty(filePath))
                {
                    File.ContentOf.DriveFreeBytes(filePath, out space);
                    item.DiskSize = (long)space;
                }
                if (settings != null)
                {
                    item.Initialize(settings, overrideQuota, usedSize);
                }
            }
            catch (Exception ex)
            {
            }
            return(item);
        }
示例#2
0
        private void InitializeView(long idFolder, RepositoryIdentifier identifier, ModuleRepository module, liteRepositorySettings settings, litePerson uploader)
        {
            Boolean           admin = module.ManageItems || module.Administration;
            dtoContainerQuota quota = Service.FolderGetHomeAvailableSize(View.GetRepositoryDiskPath(), settings, module, identifier);

            View.AllowUploadToFolder = false;
            View.AllowUpload         = (quota != null && quota.HasAllowedSpace() && (module.Administration || module.ManageItems || module.UploadFile));
            List <dtoNodeFolderItem> folders       = Service.GetFoldersForUpload(View.GetRepositoryDiskPath(), idFolder, UserContext.CurrentUserID, identifier, module, View.GetUnknownUserName(), View.GetRootFolderFullname());
            dtoNodeFolderItem        currentFolder = (idFolder == 0 ? null : folders.Where(f => f.Id == idFolder).FirstOrDefault());

            if (quota != null)
            {
                View.AllowUploadToFolder = (quota.HasAllowedSpace() && (module.Administration || module.ManageItems || module.UploadFile || (currentFolder != null && currentFolder.Selectable && Service.FolderAllowUpload(idFolder) && module.ViewItemsList)));
            }
            View.LoadFolderSelector(identifier, idFolder, (idFolder == 0 || currentFolder.Id == 0) ? View.GetRootFolderFullname() : currentFolder.Name, quota, folders);
        }
示例#3
0
        public dtoContainerQuota FolderGetHomeAvailableSize(String filePath, liteRepositorySettings settings, ModuleRepository module, RepositoryIdentifier identifier)
        {
            dtoContainerQuota container = null;

            try
            {
                IEnumerable <liteRepositoryItem> query = GetQuery(identifier);
                long usedSize = query.Where(i => i.Deleted == BaseStatusDeleted.None).Select(i => i.Size + i.DeletedSize + i.VersionsSize).DefaultIfEmpty(0).Sum();
                usedSize          += query.Where(i => i.Deleted == BaseStatusDeleted.Manual).Select(i => i.DeletedSize).DefaultIfEmpty(0).Sum();
                container          = CalculateRepositoryMaxSize(filePath, settings, IsValidAdministrator(UC.CurrentUserID));
                container.UsedSize = usedSize;
            }
            catch (Exception ex)
            {
            }
            return(container);
        }