Example #1
0
        /// <summary>
        /// Upload the sharing-info file to the server
        /// </summary>
        /// <param pathFullName="newSharingInfo">From.To.Filename.URL.ReKey</param>
        /// <returns></returns>
        public Boolean Upload(SharingInfo newSharingInfo)
        {
            String sharingInfoFileDir  = String.Format("/{0}", newSharingInfo.ID_TO);
            String sharingInfoFileName = String.Format("{0}.txt", newSharingInfo.Reference);
            String sharingInfoFilePath = String.Format("{0}/{1}", sharingInfoFileDir, sharingInfoFileName);

            try
            {
                //this.Client.Delete( sharingInfoFilePath );
                Client.Delete(sharingInfoFilePath);
            }
            catch (System.Exception) { }
            try
            {
                MemoryStream    ms   = new MemoryStream();
                BinaryFormatter bfer = new BinaryFormatter();
                bfer.Serialize(ms, newSharingInfo);
                Client.UploadFileAsync(sharingInfoFileDir, sharingInfoFileName, ms.ToArray(),
                                       (response) => {},
                                       (error) =>
                {
                    //SecuruStikException.ThrowSecuruStik(
                    //                  SecuruStikExceptionType.DropBoxControl_Upload , "UpLoadError" , error );
                });
                return(true);
            }
            catch (System.Exception) { return(false); }
        }
Example #2
0
        private static void OnFileMetaReady(
            DropNetClient client,
            SyncInfo info, MetaData meta,
            Action<SyncCompleteInfo> report)
        {
            // No change from server side
            if (meta.Modified == info.Modified)
            {
                if (!info.HasLocalChanges)
                {
                    report(new SyncCompleteInfo
                    {
                        Path = info.Path,
                        Result = SyncResults.NoChange,
                    });

                    return;
                }

                // Has local change, upload to server
                client.UploadFileAsync(info.Path,
                    info.Database,
                    x => report(new SyncCompleteInfo
                    {
                        Path = info.Path,
                        Modified = x.Modified,
                        Result = SyncResults.Uploaded,
                    }),
                    x => report(new SyncCompleteInfo
                    {
                        Path = info.Path,
                        Result = SyncResults.Failed,
                    }));

                return;
            }

            // Has changes from server
            if (!info.HasLocalChanges)
            {
                // Database should be updated
                client.GetFileAsync(info.Path,
                    x => report(new SyncCompleteInfo
                    {
                        Path = info.Path,
                        Database = x.RawBytes,
                        Modified = meta.Modified,
                        Result = SyncResults.Downloaded,
                    }),
                    ex => report(new SyncCompleteInfo
                    {
                        Path = info.Path,
                        Result = SyncResults.Failed,
                    }));

                return;
            }

            // Conflict
            var path = GetNonConflictPath(info.Path);

            client.UploadFileAsync(path, info.Database,
                x => report(new SyncCompleteInfo
                {
                    Modified = x.Modified,
                    Path = client.GetUrl(path),
                    Result = SyncResults.Conflict,
                }),
                x => report(new SyncCompleteInfo
                {
                    Path = info.Path,
                    Result = SyncResults.Failed,
                }));
        }
Example #3
0
        private void uploadAsync(DropNetClient client)
        {
            const string VerseDbFileName = "verses.sqlite3";

            var store = IsolatedStorageFile.GetUserStoreForApplication();
            var fileStream = store.OpenFile(DbInfo.FileName, System.IO.FileMode.Open, System.IO.FileAccess.Read);

            client.UploadFileAsync("/", VerseDbFileName, fileStream,
                metadata =>
                {
                    fileStream.Close();
                    fileStream.Dispose();
                    reportFinished();
                },
                ex =>
                {
                    fileStream.Close();
                    fileStream.Dispose();
                    reportError(ex);
                });
        }