Beispiel #1
0
    /// <summary>
    /// Start dropbox sync
    /// </summary>
    public void Start()
    {
      Debug.Assert(_ws.HasDropBoxToken);

      _client = new DropNetClient(
                  AppSetting.DROPBOX_API_KEY,
                  AppSetting.DROPBOX_API_SECRET,
                  _ws.DropBoxToken,
                  _ws.DropBoxSecret);

      //
      // is first time sync?
      //
      bool isfirstsync = (_ws.HasLastSyncHashCode == false);
      if (isfirstsync)
      {
        Log("First sync:{0}...", _ws.Name);
        _client.GetMetaDataAsync(_ws.DropBoxPath,
                                 OnFirstSyncMetaDataReceived,
                                 OnFirstSyncMetaDataError);
        return;
      }

      Log("Sync was done once before");
      SyncFiles();
    }
Beispiel #2
0
        private void downloadVerseDatabase(DropNetClient client)
        {
            const string VerseDbFileName = "verses.sqlite3";

            client.GetMetaDataAsync("/",
                metadata =>
                {
                    var versesDb = metadata.Contents
                        .Where(x => !x.Is_Dir && x.Name == VerseDbFileName)
                        .FirstOrDefault();

                    if (versesDb == null)
                    {
                        notifyError("Could not find '" + VerseDbFileName + "' in your Dropbox root folder.");
                        return;
                    }

                    client.GetFileAsync(versesDb.Path,
                        file =>
                        {
                            var fileBytes = file.RawBytes;
                            var fileStream = new MemoryStream(fileBytes);
                            writeDatabaseToIsolatedStorage(fileStream);
                        },
                        ex => notifyError(ex));
                },
                ex => notifyError(ex));
        }
Beispiel #3
0
 private static void Synchronize(DropNetClient client,
     SyncInfo info, Action<SyncCompleteInfo> report)
 {
     client.GetMetaDataAsync(info.Path, meta =>
         OnFileMetaReady(client, info, meta, report),
         ex => report(new SyncCompleteInfo
         {
             Path = info.Path,
             Result = SyncResults.Failed,
         }));
 }
Beispiel #4
0
        private void RefreshList()
        {
            progBusy.IsBusy = true;
            _cmdRefresh.IsEnabled = false;

            var client = new DropNetClient(
                DropBoxInfo.KEY, DropBoxInfo.SECRET,
                _token, _secret);

            client.GetMetaDataAsync(_path,
                OnListComplete, OnListFailed);
        }