public static DTOBase Create(DirInfo directory, WebDavRoot root) { if (directory == null) { throw new ArgumentNullException("directory"); } if (root == null) { throw new ArgumentNullException("root"); } RootDTO response = new RootDTO() { Mime = "directory", Dirs = directory.HasSubDirectories ? (byte)1 : (byte)0, Hash = root.VolumeId + Helper.EncodePath(directory.RelPath), Read = 1, Write = 1, Locked = 0, Name = root.Alias, Size = 0, VolumeId = root.VolumeId }; DateTime lastModified; if (DateTime.TryParse(directory.LastModified, out lastModified)) { response.UnixTimeStamp = (long)(lastModified - _unixOrigin).TotalSeconds; } return(response); }
public AddResponse(DirInfo newDir, DirInfo parent, WebDavRoot root) { _added = new List <DTOBase>() { DTOBase.Create(newDir, parent, root) }; }
public static DTOBase Create(DirInfo directory, DirInfo parent, WebDavRoot root) { if (directory == null) { throw new ArgumentNullException("directory"); } if (parent == null && directory.IsDirectory) { //throw new Exception("Что то пошло не так!"); } if (directory.IsDirectory) { var response = new DirectoryDTO() { Mime = "directory", ContainsChildDirs = directory.HasSubDirectories ? (byte)1 : (byte)0, Hash = root.VolumeId + Helper.EncodePath(directory.RelPath), Read = 1, Write = 1, Locked = 0, Size = 0, Name = directory.DisplayName }; if (parent != null) { response.ParentHash = root.VolumeId + Helper.EncodePath(parent.RelPath); } DateTime lastModified; if (DateTime.TryParse(directory.LastModified, out lastModified)) { response.UnixTimeStamp = (long)(lastModified - _unixOrigin).TotalSeconds; } return(response); } else { var ext = Path.GetExtension(directory.DisplayName); if (ext == ".enc") { var name = directory.DisplayName.Substring(0, directory.DisplayName.LastIndexOf(".", System.StringComparison.Ordinal)); var ext2 = Path.GetExtension(name); if (ext2 == ".sig") { ext = ".sig.enc"; } } FileDTO response = new FileDTO(); response.Read = 1; response.Write = (byte)1; response.Locked = (byte)0; response.Name = directory.DisplayName; response.VisualizationType = FileDTO.GetVisualization(ext); response.Size = directory.ContentLenght; response.Hash = root.VolumeId + Helper.EncodePath(directory.RelPath); response.ParentHash = root.VolumeId + Helper.EncodePath(parent.RelPath); response.Mime = string.IsNullOrEmpty(ext) ? "unknown" : Helper.GetMimeType(ext.ToLower().Substring(1)); DateTime lastModified; if (DateTime.TryParse(directory.LastModified, out lastModified)) { response.UnixTimeStamp = (long)(lastModified - _unixOrigin).TotalSeconds; } return(response); } }