private static UPMInboxFile ModelInboxFileFromInboxFile(UPInboxFile inboxFile) { UPMInboxFile upmInboxFile = new UPMInboxFile(StringIdentifier.IdentifierWithStringId(inboxFile.Path)) { Path = inboxFile.Path, URL = inboxFile.URL }; #if PORTING upmInboxFile.Name = inboxFile.Path.LastPathComponent(); Exception attributesErr; NSDictionary fileAttributes = NSFileManager.DefaultManager().AttributesOfItemAtPathError(inboxFile.Path, attributesErr); if (attributesErr) { DDLogError("UPInBoxPageModelController error no fileAttributes: %@", fileAttributes); } NSNumber fileSizeNumber = fileAttributes.ObjectForKey(NSFileSize); upmInboxFile.Size = fileSizeNumber.LongLongValue(); upmInboxFile.FormattedSize = NSByteCountFormatter.StringFromByteCountCountStyle(upmInboxFile.Size, NSByteCountFormatterCountStyleFile); upmInboxFile.Date = fileAttributes.ObjectForKey(NSFileCreationDate); // Cant use TimeZone here. Called before Login and server independent. upmInboxFile.FormattedDate = UPInBoxPageModelController.UpDateFormatter().StringFromDate(upmInboxFile.Date); UIDocumentInteractionController interactionController = UIDocumentInteractionController.InteractionControllerWithURL(inboxFile.URL); ArrayList icons = interactionController.Icons; //upmInboxFile.Icon = icons.LastObject(); // Adding largest Icon available #endif upmInboxFile.MimeTye = UPInboxFileManager.MimeTypeForPath(upmInboxFile.Path); upmInboxFile.Color = UPInBoxPageModelController.ColorForMimeType(upmInboxFile.MimeTye); return(upmInboxFile); }
/// <summary> /// Updateds the element. /// </summary> /// <param name="element">The element.</param> /// <returns></returns> public override UPMElement UpdatedElement(UPMElement element) { UPMInBoxPage oldPage = (UPMInBoxPage)this.TopLevelElement; UPMInBoxPage page = new UPMInBoxPage(StringIdentifier.IdentifierWithStringId("Inbox")) { UploadFieldGroup = oldPage.UploadFieldGroup, FileNameEditField = oldPage.FileNameEditField, SkipUploadIfPossible = oldPage.SkipUploadIfPossible }; UPInboxFileManager manager = UPInboxFileManager.CurrentInboxFileManager(); List <UPInboxFile> files = manager.AllInboxFiles(); foreach (UPInboxFile inboxFile in files) { UPMInboxFile upmInboxFile = ModelInboxFileFromInboxFile(inboxFile); page.AddChild(upmInboxFile); } this.TopLevelElement = page; this.SortFilesByDate(); page.Invalid = false; this.InformAboutDidChangeTopLevelElement(page, page, null, null); return(element); }
/// <summary> /// Deletes the files. /// </summary> /// <param name="deleteFiles">The delete files.</param> public void DeleteFiles(List <UPMInboxFile> deleteFiles) { foreach (UPMInboxFile file in deleteFiles) { UPInboxFileManager.DeleteFileWithURL(file.URL); } this.UpdatedElement(this.Page); }
/// <summary> /// Currents the inbox file manager. /// </summary> /// <returns></returns> public static UPInboxFileManager CurrentInboxFileManager() { if (defaultManager == null) { defaultManager = new UPInboxFileManager(); #if PORTING defaultManager.InboxPath = UPPathService.DocumentPath().StringByAppendingPathComponent("writeableInbox"); defaultManager.RealInboxPath = UPPathService.DocumentPath().StringByAppendingPathComponent("Inbox"); if (!NSFileManager.DefaultManager().FileExistsAtPath(defaultManager.InboxPath)) { NSError error = null; NSFileManager.DefaultManager().CreateDirectoryAtPathWithIntermediateDirectoriesAttributesError(defaultManager.InboxPath, false, null, error); } #endif } return(defaultManager); }
/// <summary> /// Inboxes the file from URL. /// </summary> /// <param name="url">The URL.</param> /// <returns></returns> public static UPMInboxFile InboxFileFromURL(Uri url) { UPInboxFile inboxFile = UPInboxFileManager.InboxFileFromURL(url); return(ModelInboxFileFromInboxFile(inboxFile)); }