public async override Task <SynchroManager.Status> Synchronize(SynchroHandle _syncHandle) { SynchroManager.Status _syncStatus = SynchroManager.Status.ErrorOrNotConnected; if (LoggedIn != WebAccountState.Connected) { await SyncMngr.Login(SynchroManager.ServerName.GooglePlus); } if (!Connection.InternetAccess()) { return(_syncStatus); } ProgressUpdate(Res.GetString("SynchroStart"), 0); HttpResponseMessage _response = await(new HttpClient()).GetAsync(new Uri(MAIN + "?access_token=" + Token)); if ((_response != null) && (_response.StatusCode == HttpStatusCode.OK)) { ResponseFeed _feed = await Serialization.DeserializeHttpToXml <ResponseFeed>(_response.Content, "feed", "http://www.w3.org/2005/Atom") as ResponseFeed; } Trip _trip = await Trip.LoadFromSummary(_syncHandle.TripSummary); return(SynchroManager.Status.Synchronized); }
public async override Task <SynchroManager.Status> Synchronize(SynchroHandle _syncHandle) { SynchroManager.Status _syncStatus = SynchroManager.Status.ErrorOrNotConnected; if (!Connection.InternetAccess()) { return(_syncStatus); } if (LoggedIn != WebAccountState.Connected) { await SyncMngr.Login(SynchroManager.ServerName.Facebook); } ProgressUpdate(Res.GetString("SynchroStart"), 0); Trip _trip = await Trip.LoadFromSummary(_syncHandle.TripSummary); return(SynchroManager.Status.Synchronized); }
public async override Task <SynchroManager.Status> Synchronize(SynchroHandle _syncHandle) { Boolean _status = true; SynchroManager.Status _syncStatus = SynchroManager.Status.NoRequest; if (LoggedIn != WebAccountState.Connected) { _syncHandleSav = _syncHandle; _status = await SyncMngr.Login(SynchroManager.ServerName.Usb); } if (_status) { Trip _trip = await Trip.LoadFromSummary(_syncHandle.TripSummary); _status &= await SynchronizeTrip(_trip); ProgressFinished(""); // check error status if (CancelInProgress()) { _syncStatus = SynchroManager.Status.NoRequest; } else if (!_status) { _syncStatus = SynchroManager.Status.ErrorOrNotConnected; } else { _syncStatus = SynchroManager.Status.Synchronized; } } else { _syncStatus = SynchroManager.Status.ErrorOrNotConnected; } _syncHandle.SetSynchroStatus(_syncStatus); return(_syncStatus); }
protected async override void OnNavigatedTo(NavigationEventArgs e) { _initFinished = false; _listLoaded = false; if (e.Parameter is ConfObj) { TripSummaryRef = (e.Parameter as ConfObj).TripSummary; AlbumSummaryRef = (e.Parameter as ConfObj).AlbumSummary; PageRef = (e.Parameter as ConfObj).Page; } else { throw new Exception(); } TripRef = await Trip.LoadFromSummary(TripSummaryRef); if ((TripRef.Sample) || !(PageRef is ViewHome)) { TextBoxReadOnly(TripName, true); TextBoxReadOnly(TripLocation, true); } // config from summary TripLocation.Text = TripSummaryRef.LocationFromTo; if (TripRef.Sample) { TripName.Text = TripSummaryRef.LocationMain; TripPath.Text = "Sample"; btnUpdate.IsEnabled = false; } else { TripName.Text = TripSummaryRef.FolderTopName; TripPath.Text = TripRef.PathRoot; } // config from trip AlbumNum.Text = TripRef.Albums.Count().ToString(); ChkRename.IsChecked = TripRef.Reorganize; ChkDropbox.IsChecked = TripSummaryRef.SyncDropbox.Requested; UpdateCheckSync(TripSummaryRef.SyncDropbox, ComboDropbox, ChkDropbox); ChkUsb.IsChecked = TripSummaryRef.SyncUsb.Requested; UpdateCheckSync(TripSummaryRef.SyncUsb, ComboUsb, ChkUsb); UpdateLayout(); // used for selection AlbumConfUserControl _itemRef = null; int _count = 0; foreach (Album _album in TripRef.Albums) { _count += _album.Pictures.Count; AlbumConfUserControl _userControl = new AlbumConfUserControl(_album, NotifyChange); listAlbums.Add(_userControl); if ((AlbumSummaryRef != null) && (_album.Id == AlbumSummaryRef.Id)) { _itemRef = _userControl; } } PicNum.Text = _count.ToString(); tableAlbums.ItemsSource = listAlbums; if (_itemRef != null) { tableAlbums.SelectedItem = _itemRef; tableAlbums.ScrollIntoView(_itemRef, ScrollIntoViewAlignment.Leading); } _initFinished = true; ProgressFinished(""); navigationHelper.OnNavigatedTo(e); }
public async override Task <SynchroManager.Status> Synchronize(SynchroHandle _syncHandle) { _handle = _syncHandle; SynchroManager.Status _syncStatus = SynchroManager.Status.ErrorOrNotConnected; if (!Connection.InternetAccess()) { return(_syncStatus); } ProgressUpdate(Res.GetString("SynchroStart"), 0); //list top-folder, login if not logged (reentrant) ResponseContainer _folderDesc = await MetadataTopFolder(SyncMngr, true); if ((_folderDesc != null) && (_folderDesc.contents != null)) { Boolean _status = true; List <String> _listTripNames = new List <string>(); foreach (ResponseElement _element in _folderDesc.contents) { if (_element.is_dir) { _listTripNames.Add(_element.path); } } // check if trip folder name match, rename if necessary foreach (String _tripName in _listTripNames) { // no error check since the folder may not exist if ((_syncHandle.TripSummary.SyncDropbox.PreviousName != null) && (_syncHandle.TripSummary.SyncDropbox.PreviousName != "")) { if (_syncHandle.TripSummary.SyncDropbox.PreviousName == _tripName) { await RenameFolder(_tripName, _syncHandle.TripSummary.FolderTopName); } } // check cancellation if (CancelInProgress()) { return(SynchroManager.Status.NoRequest); } } Trip _trip = await Trip.LoadFromSummary(_syncHandle.TripSummary); UploadList = new List <UploadOperation>(); _status &= await SynchronizeTrip(_trip); // check error status if (CancelInProgress()) { return(SynchroManager.Status.NoRequest); } else if (!_status) { return(SynchroManager.Status.ErrorOrNotConnected); } _status &= await UploadAll(UploadList); // check error status if (CancelInProgress()) { _syncStatus = SynchroManager.Status.NoRequest; } else if (!_status) { _syncStatus = SynchroManager.Status.ErrorOrNotConnected; } else { _syncStatus = SynchroManager.Status.Synchronized; } return(_syncStatus); } else { ProgressFinished(""); return(SynchroManager.Status.ErrorOrNotConnected); } }