public WebDAVFileOrFolderModel(ResourceInfoModel item) { Name = item.Name; Path = item.Path; Size = item.Size; ETag = item.ETag; IsDirectory = item.IsDirectory; ContentType = item.ContentType; LastModified = item.LastModified; Created = item.Created; QuotaUsed = item.QuotaUsed; QuotaAvailable = item.QuotaAvailable; Id = item.Id; FileId = item.FileId; IsFavorite = item.IsFavorite; CommentsHref = item.CommentsHref; CommentsCount = item.CommentsCount; CommentsUnread = item.CommentsUnread; OwnderId = item.OwnderId; OwnerDisplayName = item.OwnerDisplayName; ShareTypes = item.ShareTypes; Checksums = item.Checksums; HasPreview = item.HasPreview; Glyph = SetTypeGlyph(); }
private bool LoadSavePath(ResourceInfoModel model, string WebSit) { string SavePath = string.Empty; SavePath = model.DownFilePath; SavePath = LoadPath + SavePath; bool result = DownLoad(WebSit, SavePath); return(result); }
public static ResourceInfoModel GetBackwardDirectoryInfo() { ResourceInfoModel fileInfo = null; fileInfo = new ResourceInfoModel(); fileInfo.Name = ".."; fileInfo.Type = Settings.Constants.ResourceType.Directory; return(fileInfo); }
// // GET: /SystemMaint/Resource/ public ActionResult Index() { var model = new ResourceInfoModel(); BL.ResourceInfo BL = new BL.ResourceInfo(); model.List = BL.GetList(); //if (Request.IsAjaxRequest()) //{ // return PartialView("_List", model.List); //} return(View(model)); }
private List <ResourceInfoModel> GetResourceInfoModel(DataTable table) { List <ResourceInfoModel> list = new List <ResourceInfoModel>(); if (table != null) { foreach (DataRow dr in table.Rows) { ResourceInfoModel rm = new ResourceInfoModel(); rm.ID = Convert.ToInt32(dr["Id"].ToString()); rm.FileURL = dr["URL"].ToString(); rm.DownFilePath = dr["Path"].ToString(); list.Add(rm); } } return(list); }
public static List <ResourceInfoModel> GetLocalResourceList(string path) { var localResourceList = new List <ResourceInfoModel>(); try { if (path.IndexOf("\\") + 1 != path.Length) { localResourceList.Add(Common.GetBackwardDirectoryInfo()); } foreach (string dicPath in Directory.GetDirectories(path, "*", SearchOption.TopDirectoryOnly)) { ResourceInfoModel resourceInfo = Common.GetLocalResourceInfo(dicPath, Constants.ResourceType.Directory); if (resourceInfo != null) { localResourceList.Add(resourceInfo); } } foreach (string filePath in Directory.GetFiles(path, "*.*", SearchOption.TopDirectoryOnly)) { ResourceInfoModel resourceInfo = Common.GetLocalResourceInfo(filePath, Constants.ResourceType.File); if (resourceInfo != null) { localResourceList.Add(resourceInfo); } } } catch (Exception) { } return(localResourceList); }
public static ResourceInfoModel GetLocalResourceInfo(string path, Settings.Constants.ResourceType type) { ResourceInfoModel ResourceInfo = null; FileSystemInfo fileInfo = null; switch (type) { case Settings.Constants.ResourceType.Directory: fileInfo = new DirectoryInfo(path); break; case Settings.Constants.ResourceType.File: fileInfo = new FileInfo(path); break; } if (fileInfo.Exists) { if ((fileInfo.Attributes & FileAttributes.Hidden) != FileAttributes.Hidden && (fileInfo.Attributes & FileAttributes.System) != FileAttributes.System && (fileInfo.Attributes & FileAttributes.Encrypted) != FileAttributes.Encrypted) { ResourceInfo = new ResourceInfoModel(); ResourceInfo.Name = fileInfo.Name; ResourceInfo.LastWrittenTime = fileInfo.LastAccessTime; ResourceInfo.FullPath = fileInfo.FullName; ResourceInfo.Extension = fileInfo.Extension; ResourceInfo.Length = type == Settings.Constants.ResourceType.File ? ((FileInfo)fileInfo).Length : 0; ResourceInfo.Type = type; } } return(ResourceInfo); }
public Task <Resource> ResourceInformationAsync(ResourceInfoModel model) { return(GetAsync <ResourceInfoModel, Resource>(model)); }
public static ResourceInfoModel ToResourceInfo(this WebDavSessionItem item, Uri baseUri) { var res = new ResourceInfoModel { ContentType = item.ContentType, IsDirectory = item.IsFolder.HasValue ? true: false, Created = item.CreationDate ?? DateTime.MinValue, ETag = item.ETag, LastModified = item.LastModified ?? DateTime.MinValue, Name = item.Name, QuotaAvailable = item.QuotaAvailableBytes ?? 0, QuotaUsed = item.QuotaUsedBytes ?? 0, Size = item.ContentLength.HasValue && item.ContentLength.Value != 0 ? item.ContentLength.Value : item.QuotaUsedBytes ?? 0, Path = Uri.UnescapeDataString(item.Uri.AbsoluteUri.Replace(baseUri.AbsoluteUri, "")) }; // NC specific properties. var ncProps = item.AdditionalProperties; if (ncProps != null) { var key = XName.Get(WebDAVPropNameConstants.Checksums, NsOc); if (ncProps.ContainsKey(key)) { res.Checksums = ncProps[key]; } key = XName.Get(WebDAVPropNameConstants.CommentsCount, NsOc); if (ncProps.ContainsKey(key)) { var commentsCount = ncProps[key]; res.CommentsCount = string.IsNullOrEmpty(commentsCount) ? 0 : long.Parse(commentsCount); } key = XName.Get(WebDAVPropNameConstants.CommentsHref, NsOc); if (ncProps.ContainsKey(key)) { var commentsHref = ncProps[key]; res.CommentsHref = string.IsNullOrEmpty(commentsHref) ? null : UriHelper.CombineUri(baseUri, new Uri(commentsHref, UriKind.Relative)); } key = XName.Get(WebDAVPropNameConstants.CommentsUnread, NsOc); if (ncProps.ContainsKey(key)) { var commentsUnread = ncProps[key]; res.CommentsUnread = string.IsNullOrEmpty(commentsUnread) ? 0 : long.Parse(commentsUnread); } key = XName.Get(WebDAVPropNameConstants.Favorite, NsOc); if (ncProps.ContainsKey(key)) { var favorite = ncProps[key]; res.IsFavorite = string.IsNullOrEmpty(favorite) ? false : string.CompareOrdinal(favorite, "1") == 0 ? true : false; } key = XName.Get(WebDAVPropNameConstants.FileId, NsOc); if (ncProps.ContainsKey(key)) { res.FileId = ncProps[key]; } key = XName.Get(WebDAVPropNameConstants.HasPreview, NsOc); if (ncProps.ContainsKey(key)) { var hasPreview = ncProps[key]; res.HasPreview = string.IsNullOrEmpty(hasPreview) ? false : string.CompareOrdinal(hasPreview, "1") == 0 ? true : false; } key = XName.Get(WebDAVPropNameConstants.Id, NsOc); if (ncProps.ContainsKey(key)) { res.Id = ncProps[key]; } key = XName.Get(WebDAVPropNameConstants.OwnerDisplayName, NsOc); if (ncProps.ContainsKey(key)) { res.OwnerDisplayName = ncProps[key]; } key = XName.Get(WebDAVPropNameConstants.OwnerId, NsOc); if (ncProps.ContainsKey(key)) { res.OwnderId = ncProps[key]; } key = XName.Get(WebDAVPropNameConstants.ShareTypes, NsOc); if (ncProps.ContainsKey(key)) { var shareType = ncProps[key]; if (!string.IsNullOrEmpty(shareType)) { res.ShareTypes = (OcsShareType)int.Parse(ncProps[key]); } } key = XName.Get(WebDAVPropNameConstants.Size, NsOc); if (ncProps.ContainsKey(key)) { var size = ncProps[key]; res.Size = string.IsNullOrEmpty(size) ? 0 : long.Parse(size); } } return(res); }
public ActionResult ResourceInfo(Guid id) { var model = new ResourceInfoModel(); var userId = User.Identity.GetUserId(); var currentUser = _usersRepository.Find(f => f.Id.ToString() == userId); if (_annotationItemsRepository.Select().Any(a => a.Id == id)) { var foundAi = _annotationItemsRepository.Select().Where(w => w.Id == id).First(); var firstDescription = foundAi.Object.References.Descriptions.First(); model.Title = firstDescription.Title; model.Abstract = firstDescription.Abstract; model.OwnerName = foundAi.OwnerName; model.OwnerId = foundAi.OwnerId; if (null != userId) { model.HasAccess = _searchService.CheckThatAnnotationItemsIsAccessible(id, Guid.Parse(userId)); } model.Id = id; model.ResourceType = SearchResultItemType.AnnotationItem; model.Hosters = foundAi.Object.References.Hosters.Select(s => s.HosterName.Value).ToList(); model.Link = "/AnnotationItem?id=" + id; foreach (var person in foundAi.Object.References.Persons) { string email = ""; string phone = ""; string givenName = ""; string position = ""; string salutation = ""; string surname = ""; if (person.EmailAddress.Any()) { email = person.EmailAddress.First(); } if (person.PhoneNumber.Any()) { phone = person.PhoneNumber.First(); } if (person.GivenName.Any()) { givenName = person.GivenName.First(); } if (person.Position.Any()) { position = person.Position.First().Value; } if (person.Salutation.Any()) { salutation = person.Salutation.First(); } if (person.SurName.Any()) { surname = person.SurName.First(); } model.Persons.Add(new PersonModel() { Email = email, GivenName = givenName, Phone = phone, Position = position, Salutation = salutation, Surname = surname }); } } else if (_usersFilesRepository.Select().Any(a => a.Id == id)) { var appConfig = _configurationProvider.Get <ApplicationConfiguration>(); var basePath = appConfig.ApploadsRoot; var userFilesPath = Path.Combine(basePath, "UserFiles"); var foundFile = _usersFilesRepository.Select().Where(w => w.Id == id).First(); var fileExtension = Path.GetExtension(foundFile.Name); model.Title = foundFile.Name; model.Abstract = foundFile.Description; model.OwnerName = foundFile.Owner.Name; model.OwnerId = foundFile.Owner.Id.ToString(); model.HasAccess = _searchService.CheckThatFileIsAccessible(id, Guid.Parse(userId)); model.Id = id; model.ResourceType = SearchResultItemType.File; model.Link = userFilesPath + '/' + foundFile.Id + fileExtension; } else { throw new ApplicationException("Unknown file or annotation item"); } return(View(model)); }
public static List <ResourceInfoModel> GetRemoteResourceList(string path, HostDetailModel hostDetail, bool needBackward) { var remoteList = new List <ResourceInfoModel>(); var ftpReq = GetFtpWebRequest(path, hostDetail); ftpReq.Method = WebRequestMethods.Ftp.ListDirectoryDetails; var ftpRes = (FtpWebResponse)ftpReq.GetResponse(); var sr = new StreamReader(ftpRes.GetResponseStream()); string res = sr.ReadToEnd(); FileStruct[] list = GetRemoteList(res); var dicList = new List <ResourceInfoModel>(); var fileList = new List <ResourceInfoModel>(); if (needBackward && path.IndexOf("/") > -1) { remoteList.Add(Common.GetBackwardDirectoryInfo()); } foreach (FileStruct file in list) { var fileInfo = new ResourceInfoModel(); fileInfo.Name = file.Name; fileInfo.FullPath = path + "/" + file.Name; fileInfo.LastWrittenTime = file.CreateTime; if (file.IsDirectory) { fileInfo.Type = Settings.Constants.ResourceType.Directory; dicList.Add(fileInfo); } else { fileInfo.Type = Settings.Constants.ResourceType.File; fileInfo.Length = file.length; if (file.Name.IndexOf(".") > -1) { fileInfo.Extension = file.Name.Substring(file.Name.LastIndexOf("."), file.Name.Length - file.Name.LastIndexOf(".")); } else { fileInfo.Extension = file.Name; } fileList.Add(fileInfo); } } foreach (ResourceInfoModel dic in dicList) { remoteList.Add(dic); } foreach (ResourceInfoModel file in fileList) { remoteList.Add(file); } sr.Close(); return(remoteList); }