public static FileObject ConvertToFileObject(MSFileObject msfo) { FileObject fo = new FileObject(); fo.Id = msfo.id; fo.Name = msfo.name; fo.Type = (FileObjectType)Enum.Parse(typeof(FileObjectType), msfo.file_type); fo.Size = msfo.size; fo.Extension = msfo.extension; fo.UpdateAt = msfo.update_at; fo.DownloadUrl = msfo.download_url; fo.MimeType = msfo.mime_type; fo.SpotId = msfo.spot_id; fo.Owner = new ProfileObject(msfo.owner_account_id, msfo.owner_account_name); return(fo); }
public static void PrintFile(FileObject file) { Debug.WriteLine("id : " + file.Id); Debug.WriteLine("Name : " + file.Name); Debug.WriteLine("Size : " + file.Size); Debug.WriteLine("Type : " + file.Type); Debug.WriteLine("Extension : " + file.Extension); Debug.WriteLine("UpdateAt : " + file.UpdateAt); Debug.WriteLine("Thumbnail : " + file.Thumbnail); Debug.WriteLine("DownloadUrl : " + file.DownloadUrl); Debug.WriteLine("MimeType : " + file.MimeType); Debug.WriteLine("----child START-----"); PrintFileList(file.FileList); Debug.WriteLine("----child END-----"); }
//public static int count = 0; public static FileObject ConvertToFileObject(object db, FileObjectSQL fos) { //count++; //if (count == 100) System.Diagnostics.Debugger.Break(); FileObject fo = new FileObject(fos.Id, fos.Name, fos.Size, fos.Type, fos.Extension, fos.UpdateAt, fos.Thumbnail, fos.DownloadUrl, fos.MimeType); fo.SpotId = fos.SpotId; if (fos.ProfileName != null && fos.ProfileId != null && fos.ProfileEmail != null && fos.ProfilePhoneNumber != null) { fo.Owner = new ProfileObject(); fo.Owner.Id = fos.ProfileId; fo.Owner.Email = fos.ProfileEmail; fo.Owner.Name = fos.ProfileName; fo.Owner.PhoneNumber = fos.ProfilePhoneNumber; } fo.FileList = GetChildList(db, fos.Id); return(fo); }
public async Task <bool> DownloadToCloud(IStorageManager storageManager = null) { try { if (storageManager == null) { storageManager = Switcher.GetMainStorage(); } Stream instream = await App.BlobStorageManager.DownloadFileStreamAsync(this.Id); FileObject root = await storageManager.GetRootFolderAsync(); await storageManager.UploadFileStreamAsync(root.Id, this.Name, instream); } catch { return(false); } return(true); }
public async Task <string> AddFileObjectAsync(FileObject fo) { ///////////////////////////////////////// // TODO : Need to add Storage Capacity ///////////////////////////////////////// if (fo == null) { throw new Exception(); } IStorageManager StorageManager = Switcher.GetCurrentStorage(); string sourceId = fo.Id; if (StorageManager.GetStorageName().Equals(AppResources.GoogleDrive)) { sourceId = fo.DownloadUrl; } return(await App.BlobStorageManager.UploadFileStreamAsync (this.PtcAccountId, this.Id, fo.Name, await StorageManager.DownloadFileStreamAsync(sourceId))); ///////////////////////////////////////////////////////////////////////////////////////////////// /// In the future, Maybe there will be codes for the mobile service table insertion. BUT Not NOW /// ///////////////////////////////////////////////////////////////////////////////////////////// }
public static MSFileObject ConvertToMSFileObject(FileObject fo) { return new MSFileObject(fo.Name, fo.Type.ToString(), fo.Size, fo.Extension, fo.UpdateAt, fo.DownloadUrl, fo.MimeType, fo.Owner.Id, fo.Owner.Name, fo.SpotId); }
public static FileObject ConvertToFileObject(MSFileObject msfo) { FileObject fo = new FileObject(); fo.Id = msfo.id; fo.Name = msfo.name; fo.Type = (FileObjectType)Enum.Parse(typeof(FileObjectType), msfo.file_type); fo.Size = msfo.size; fo.Extension = msfo.extension; fo.UpdateAt = msfo.update_at; fo.DownloadUrl = msfo.download_url; fo.MimeType = msfo.mime_type; fo.SpotId = msfo.spot_id; fo.Owner = new ProfileObject(msfo.owner_account_id, msfo.owner_account_name); return fo; }
public async Task <bool> DownloadFileObjectAsync(IStorageManager StorageManager, FileObject fo) { Stream instream = await App.BlobStorageManager.DownloadFileStreamAsync(fo.Id); FileObject root = await StorageManager.GetRootFolderAsync(); return(await StorageManager.UploadFileStreamAsync(root.Id, fo.Name, instream)); }
// Summary: // Gets the children of the FileObject recursively. // // Returns: // Children list of given FileObject. private async Task<List<FileObject>> _GetChildAsync(FileObject fileObject) { if (FileObjectViewModel.FOLDER.Equals(fileObject.Type.ToString())) { List<FileObject> list = await this.GetFilesFromFolderAsync(fileObject.Id); foreach (FileObject file in list) file.FileList = await _GetChildAsync(file); return list; } else { return null; } }
//public static int count = 0; public static FileObject ConvertToFileObject(object db, FileObjectSQL fos) { //count++; //if (count == 100) System.Diagnostics.Debugger.Break(); FileObject fo = new FileObject(fos.Id, fos.Name, fos.Size, fos.Type, fos.Extension, fos.UpdateAt, fos.Thumbnail, fos.DownloadUrl, fos.MimeType); fo.SpotId = fos.SpotId; if (fos.ProfileName != null && fos.ProfileId != null && fos.ProfileEmail != null && fos.ProfilePhoneNumber != null) { fo.Owner = new ProfileObject(); fo.Owner.Id = fos.ProfileId; fo.Owner.Email = fos.ProfileEmail; fo.Owner.Name = fos.ProfileName; fo.Owner.PhoneNumber = fos.ProfilePhoneNumber; } fo.FileList = GetChildList(db, fos.Id); return fo; }
public async Task<bool> DownloadFileObjectAsync(IStorageManager StorageManager, FileObject fo) { Stream instream = await App.BlobStorageManager.DownloadFileStreamAsync(fo.Id); FileObject root = await StorageManager.GetRootFolderAsync(); return await StorageManager.UploadFileStreamAsync(root.Id, fo.Name, instream); }
public async Task<bool> DeleteFileObjectAsync(FileObject fo) { ////////////////////////////////////////////// // TODO : Need to substract Storage Capacity ////////////////////////////////////////////// return await App.BlobStorageManager.DeleteFileAsync(fo.Id); ///////////////////////////////////////////////////////////////////////////////////////////////// /// In the future, Maybe there will be codes for the mobile service table insertion. BUT Not NOW /// ///////////////////////////////////////////////////////////////////////////////////////////// }
public async Task<FileObject> GetRootFolderAsync() { FileObject rootFile = new FileObject(); AboutResource aboutResource = this.Service.About; About about = await aboutResource.Get().ExecuteAsync(); rootFile.Id = about.RootFolderId; this.RootFodlerId = about.RootFolderId; rootFile.Name = ""; return rootFile; }
public static MSFileObject ConvertToMSFileObject(FileObject fo) { return(new MSFileObject(fo.Name, fo.Type.ToString(), fo.Size, fo.Extension, fo.UpdateAt, fo.DownloadUrl, fo.MimeType, fo.Owner.Id, fo.Owner.Name, fo.SpotId)); }
public static void ConvertToFileObjectSQL(List<FileObjectSQL> list, FileObject fo, string parentId) { if (list == null) System.Diagnostics.Debugger.Break(); FileObjectSQL fos = new FileObjectSQL(); fos.Id = fo.Id; fos.Name = fo.Name; fos.Size = fo.Size; fos.Type = fo.Type; fos.Extension = fo.Extension; fos.UpdateAt = fo.UpdateAt; fos.Thumbnail = fo.Thumbnail; fos.DownloadUrl = fo.DownloadUrl; fos.MimeType = fo.MimeType; fos.ParentId = parentId; if (fo.Owner != null) { fos.ProfileId = fo.Owner.Id; fos.ProfileEmail = fo.Owner.Email; fos.ProfilePhoneNumber = fo.Owner.PhoneNumber; fos.ProfileName = fo.Owner.Name; } fos.SpotId = fo.SpotId; list.Add(fos); if (fo.FileList != null) { for (var i = 0; i < fo.FileList.Count; i++) { ConvertToFileObjectSQL(list, fo.FileList[i], fo.Id); } } }
public async Task<bool> PreviewFileObjectAsync(FileObject fo) { StorageFolder folder = await ApplicationData.Current.LocalFolder.CreateFolderAsync(SpotObject.PREVIEW_FILE_LOCATION, CreationCollisionOption.OpenIfExists); StorageFile file = await folder.CreateFileAsync(fo.Name, CreationCollisionOption.ReplaceExisting); file = await App.BlobStorageManager.DownloadFileAsync(fo.Id, file); return await Launcher.LaunchFileAsync(file); }
public static List<FileObject> GetTreeForFolder(FileObject folder) { if (folder == null) return null; if (folder.FileList == null) return null; if (!GetCurrentTree().Contains(folder)) GetCurrentTree().Push(folder); return folder.FileList; }
public async Task<string> AddFileObjectAsync(FileObject fo) { ///////////////////////////////////////// // TODO : Need to add Storage Capacity ///////////////////////////////////////// if (fo == null) throw new Exception(); IStorageManager StorageManager = Switcher.GetCurrentStorage(); string sourceId = fo.Id; if (StorageManager.GetStorageName().Equals(AppResources.GoogleDrive)) sourceId = fo.DownloadUrl; return await App.BlobStorageManager.UploadFileStreamAsync (this.PtcAccountId, this.Id, fo.Name, await StorageManager.DownloadFileStreamAsync(sourceId)); ///////////////////////////////////////////////////////////////////////////////////////////////// /// In the future, Maybe there will be codes for the mobile service table insertion. BUT Not NOW /// ///////////////////////////////////////////////////////////////////////////////////////////// }