Exemple #1
0
        /// <summary>
        /// Get document from folder
        /// </summary>
        /// <param name="folder"></param>
        /// <param name="logs"></param>
        public DocumentModel(DirectoryInfo folder, IEnumerable <ProtectedDocumentLogModel> logs = null)
            : this()
        {
            var mediaPath = folder.FullName.ToRelativePath(EzCMSContants.ProtectedDocumentPath);

            Text         = folder.FullName.GetPathName();
            DocumentType = ProtectedDocumentEnums.DocumentType.Folder;
            Data         = new DocumentReport
            {
                Id               = mediaPath.ToIdStringByHash(),
                Path             = mediaPath.GetUniqueLink(),
                IsRead           = false,
                DataIcon         = string.Empty,
                HasChildren      = folder.GetFiles().Any() || folder.GetDirectories().Any(),
                LastModified     = DateTimeUtilities.ToDateTimeFormat(folder.LastWriteTimeUtc),
                LastWriteTimeUtc = folder.LastWriteTimeUtc,
                TotalFiles       = folder.GetFiles().Count(),
                TotalFolders     = folder.GetDirectories().Count()
            };

            if (logs != null)
            {
                Data.TotalRead =
                    folder.GetFiles()
                    .Count(
                        f => logs.Any(l => l.Path.Equals(f.FullName.ToRelativePath(EzCMSContants.ProtectedDocumentPath), StringComparison.CurrentCultureIgnoreCase)));
            }

            Data.TotalNotRead = Data.TotalFiles - Data.TotalRead;
        }
Exemple #2
0
        /// <summary>
        /// Get document from file
        /// </summary>
        /// <param name="file"></param>
        /// <param name="logs"></param>
        /// <param name="mappings"></param>
        public DocumentModel(FileInfo file, IEnumerable <ProtectedDocumentLogModel> logs = null, IEnumerable <DocumentClassMapping> mappings = null)
            : this()
        {
            var mediaPath = file.FullName.ToRelativePath(EzCMSContants.ProtectedDocumentPath);

            Text         = file.FullName.GetPathName();
            DocumentType = ProtectedDocumentEnums.DocumentType.Item;
            Data         = new DocumentReport
            {
                Id = mediaPath.ToIdStringByHash(),
                //Path = string.Format("{0}{1}", mediaPath.GetUniqueLink(), mediaPath.GetExtension()),
                Path             = mediaPath.GetUniqueLink(),
                Mime             = mediaPath.GetMimeMapping(),
                Extension        = mediaPath.GetExtension(),
                IsRead           = logs == null || logs.Any(l => l.Path.Equals(mediaPath)),
                HasChildren      = false,
                DataIcon         = GetImageClass(mappings, file.FullName),
                LastModified     = DateTimeUtilities.ToDateTimeFormat(file.LastWriteTimeUtc),
                LastWriteTimeUtc = file.LastWriteTimeUtc
            };
        }