public async static Task<List<Folder>> GetFakesFolders()
        {
            var folders = new List<Folder>();

            Folder folder1 = new Folder();
            folder1.CreationDate = DateTime.Now;
            folder1.UpdateDate = DateTime.Now;
            folder1.Name = "Documents";
            folder1.Permission = PermissionRight.read_write;
            //folder1.Size = 2546978230;
            List<File> files = new List<File>();
            File file1 = new File();
            File file2 = new File();
            files.Add(file1);
            files.Add(file2);
            folder1.Files = files;

            Folder folder2 = new Folder();
            folder2.CreationDate = DateTime.Now;
            folder2.UpdateDate = DateTime.Now;
            folder2.Name = "Shared";
            folder2.Permission = PermissionRight.read_write;
            //folder2.Size = 45789362145;
            List<File> files2 = new List<File>();
            File file12 = new File();
            File file22 = new File();
            files.Add(file12);
            files.Add(file22);
            folder2.Files = files;

            folders.Add(folder1);
            folders.Add(folder2);
            return folders;
        }
        public async static Task<List<File>> GetFakesFiles()
        {
            List<File> files = new List<File>();

            File file1 = new File();
            file1.CreationDate = DateTime.Now;
            file1.UpdateDate = DateTime.Now;
            file1.Name = "file 1";
            file1.Permission = PermissionRight.read_write;
            file1.Size = 5030;
            files.Add(file1);

            File file2 = new File();
            file2.CreationDate = DateTime.Now;
            file2.UpdateDate = DateTime.Now;
            file2.Name = "file 2";
            file2.Permission = PermissionRight.read_write;
            file2.Size = 7302;
            files.Add(file2);


            File file3 = new File();
            file3.CreationDate = DateTime.Now;
            file3.UpdateDate = DateTime.Now;
            file3.Name = "file 3";
            file3.Permission = PermissionRight.read_write;
            file3.Size = 7302;
            files.Add(file3);

            return files;
        }
Example #3
0
 public File(File file) : base(file)
 {
     this.ContentType = file.ContentType;
     this.FolderId = file.FolderId;
     this.Md5 = file.Md5;
     this.Path = file.Path;
     this.Size = file.Size;
 }
 public async void GetLocalEntities()
 {
     LocalEntities.Clear();
     var localFiles = await ApplicationData.Current.LocalFolder.GetFilesAsync();
     foreach (var localFile in localFiles)
     {
         if (!localFile.Name.Equals("__ApplicationSettings"))
         {
             var file = new File();
             file.CreationDate = localFile.DateCreated.DateTime;
             var nameAndContentType = localFile.Name.Split('~');
             file.ContentType = nameAndContentType[1];
             file.Name = nameAndContentType[2];
             //file.Path = localFile.Attributes;
             var test = localFile.Attributes;
             file.Path = localFile.Path.Split('\\').Last();
             var fileWithIcon = DetermineIcon(file);
             LocalEntities.Add(fileWithIcon);
         }
     }
 }
        public void DownloadFile(File file)
        {
            if (BackgroundTransferService.Requests.Count() >= 5)
            {
                _informerManagerLocator.InformerManager.AddMessage("Error", "The maximum number of background file transfer requests for this application has been exceeded");
            }
            //var toto = await _fileApi.DownloadFile(file, _user.Token);


            Uri transferUri = _fileApi.GetDownloadUrl(file);
            BackgroundTransferRequest transferRequest = new BackgroundTransferRequest(transferUri);

            // Set the transfer method. GET and POST are supported.
            transferRequest.Method = "GET";
            transferRequest.Headers["Authorization"] = _user.Token;
            Uri downloadUri = new Uri("shared/transfers/" + file.Name, UriKind.RelativeOrAbsolute);
            transferRequest.DownloadLocation = downloadUri;
            transferRequest.Tag = file.Size + "~" + file.ContentType.Split('/').First() + "~" + file.Name;
            transferRequest.TransferPreferences = TransferPreferences.AllowCellularAndBattery;
            try
            {
                BackgroundTransferService.Add(transferRequest);
            }
            catch (InvalidOperationException ex)
            {
                _informerManagerLocator.InformerManager.AddMessage("Unable to add background transfer request", ex.Message);
            }
            catch (Exception)
            {
                _informerManagerLocator.InformerManager.AddMessage("Error", "Unable to add background transfer request.");
            }
            if (transferRequest != null)
            {
                transferRequest.TransferProgressChanged += transfer_TransferProgressChanged;
                transferRequest.TransferStatusChanged += transfer_TransferStatusChanged;
                //this.transferRequests.ToList().Add(transferRequest);
                UpdateRequestsList();
            }
        }