Exemplo n.º 1
0
        public async Task <bool> DeleteFile(string path, string filename)
        {
            var deletedResult = await _client.Files.ListFolderAsync(path, includeDeleted : true);

            var file = deletedResult.Entries.FirstOrDefault(file => file.Name.Equals(filename)).AsDeleted;

            _client.Dispose();
            if (file != null)
            {
                return(true);
            }
            return(false);
        }
Exemplo n.º 2
0
 public void Close()
 {
     if (DBClient != null)
     {
         DBClient.Dispose();
     }
 }
Exemplo n.º 3
0
        public override void Dispose()
        {
            _requestHandler.Dispose();
            _httpClient.Dispose();
            _client.Dispose();

            base.Dispose();
        }
Exemplo n.º 4
0
 /// <summary>
 /// Disposed the object
 /// </summary>
 void IDisposable.Dispose()
 {
     if (_Dropbox != null)
     {
         _Dropbox.Dispose();
         _Dropbox = null;
     }
 }
 /// <summary>
 /// Disposes the Dropbox library.
 /// </summary>
 public void Dispose()
 {
     if (dropboxClient != null)
     {
         dropboxClient.Dispose();
         dropboxClient = null;
     }
 }
Exemplo n.º 6
0
        /// <inheritdoc/>
        public Task SignOutAsync()
        {
            _client?.Dispose();

            TokenProvider.SetToken("AccessToken", string.Empty);
            IsAuthenticated = false;

            Logger.Instance.Information($"User signed out from {CloudServiceName}.");
            return(Task.CompletedTask);
        }
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (client != null)
         {
             client.Dispose();
         }
     }
     // free native resources
 }
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         // dispose managed resources
         if (_client != null)
         {
             _client.Dispose();
         }
     }
 }
Exemplo n.º 9
0
 private void InitDriveService()
 {
     dropboxClient?.Dispose();
     if (!string.IsNullOrEmpty(LastRefreshToken))
     {
         dropboxClient = new DropboxClient(LastRefreshToken, ApiKey);  // offline 類型的 token
     }
     else
     {
         dropboxClient = new DropboxClient(LastAccessToken);  // legacy 類型的 token
     }
 }
Exemplo n.º 10
0
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (cts != null)
         {
             // dispose managed resources
             cts.Dispose();
         }
         if (client != null)
         {
             client.Dispose();
         }
     }
     // free native resources
 }
Exemplo n.º 11
0
        private bool disposedValue = false; // To detect redundant calls

        void Dispose(bool disposing)
        {
            if (!disposedValue)
            {
                if (disposing)
                {
                    // TODO: dispose managed state (managed objects).
                    _dropboxClient.Dispose();
                }

                // TODO: free unmanaged resources (unmanaged objects) and override a finalizer below.
                // TODO: set large fields to null.

                disposedValue = true;
            }
        }
Exemplo n.º 12
0
        async Task Upload(string folder, HttpPostedFileBase file)
        {
            //Create object of DropboxClient Class by passing AccessToken
            var dbx = new DropboxClient("As1AQyu_qJAAAAAAAAAAHJmONLCS5kU_FlJQcJhdWmcwpkixJrEyt_60I3qWLpNP");

            try
            {
                //Get Select File Name
                string fileName = file.FileName;

                //Get Stream of Selected File
                Stream fs = file.InputStream;

                //Convert Stream to Binary
                BinaryReader br = new BinaryReader(fs);

                //Convert Binary to bytes
                byte[] bytes = br.ReadBytes((Int32)fs.Length);

                //Conert bytes to MemoryStream
                System.IO.MemoryStream dataStream = new System.IO.MemoryStream(bytes);

                //Upload file to Dropbox
                var updated = await dbx.Files.UploadAsync("/" + folder + "/" + fileName, WriteMode.Overwrite.Instance, body : dataStream);

                if (updated != null)
                {
                    TempData["flag"] = 1;
                }
                else
                {
                    TempData["flag"] = 0;
                }
            }
            catch (Exception ex)
            {
            }
            finally
            {
                //Destroy object if not null
                if (dbx != null)
                {
                    dbx.Dispose();
                }
            }
        }
Exemplo n.º 13
0
        private void InsertTaskAfterActivityResult(string identifier, string title)
        {
            var content = GetTasksContent(_accessToken);
            var index   = content.IndexOf("Tasks\r\n");

            content = content.Insert(index + 7, "\t" + identifier + "::" + title + "\r\n");
            var task = Task.Run(() => {
                var dbx = new DropboxClient(_accessToken);
                var mem = new MemoryStream(Encoding.UTF8.GetBytes(content));
                dbx.Files.UploadAsync("/Development/Tasks.txt", Dropbox.Api.Files.WriteMode.Overwrite.Instance, false, null, false, mem).ContinueWith(m => {
                    if (m.IsCompleted && m.Status == TaskStatus.RanToCompletion)
                    {
                        var genericTask = new GenericTask()
                        {
                            Category    = "B",
                            Identifier  = identifier,
                            IsCompleted = false,
                            IsOutside   = false,
                            Title       = title
                        };
                        //_data.Add(genericTask);
                        _dbHandler.InsertGenericTask(genericTask);

                        RunOnUiThread(() => Toast.MakeText(this, "Tasks updated", ToastLength.Short).Show());

                        _adapterList.Add(new JavaDictionary <string, object> {
                            { "identifier", genericTask.Identifier },
                            { "title", genericTask.Title }
                        });
                        RunOnUiThread(() => {
                            RepopulateTasksFromContent(content);
                            _listView.DeferNotifyDataSetChanged();
                        });
                    }
                    else
                    {
                        RunOnUiThread(() => Toast.MakeText(this, "Error: Unable to insert task", ToastLength.Short).Show());
                    }
                    dbx.Dispose();
                }
                                                                                                                                                      );
            });
        }
Exemplo n.º 14
0
        /// <summary>
        /// The user clicked the exit button.
        /// </summary>
        private void BtnExit_Click(object sender, RoutedEventArgs e)
        {
            m_InstallationTaskController.Cancel();
            m_PDDownloadEndTaskController.Cancel();

            m_InstallationTaskController.Dispose();
            m_PDDownloadEndTaskController.Dispose();

            if (m_Downloader != null)
            {
                m_Downloader.Dispose();
            }

            if (m_DBClient != null)
            {
                m_DBClient.Dispose();
            }

            DeleteTempFiles();

            System.Windows.Application.Current.Shutdown();
        }
Exemplo n.º 15
0
 public override void Dispose()
 {
     client.Dispose();
 }
Exemplo n.º 16
0
 public void Dispose()
 {
     _client.Dispose();
 }
Exemplo n.º 17
0
 //-------------------------------------------------------------------------------------------------------------------------------
 public static void Disconnect()
 {
     dbx.Dispose();
 }
 public void Dispose() => _dropboxClient?.Dispose();
        public void Close()
        {
            _dropboxClient.Dispose();

            IsOpened = false;
        }
Exemplo n.º 20
0
 public void Dispose()
 {
     _semaphore.Dispose();
     _dropboxClient?.Dispose();
 }