Exemple #1
0
        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);
        }
Exemple #2
0
        public TripSummary()
        {
            PicturesThumb = new List <String>();
            Countries     = new List <string>();
            Distance      = 0;

            SyncGooglePlus = new SynchroHandle(SynchroManager.ServerName.GooglePlus);
            SyncFacebook   = new SynchroHandle(SynchroManager.ServerName.Facebook);
            SyncDropbox    = new SynchroHandle(SynchroManager.ServerName.Dropbox);
            SyncUsb        = new SynchroHandle(SynchroManager.ServerName.Usb);
        }
Exemple #3
0
 internal async Task <Boolean> DeleteContent(SynchroHandle _syncHandle)
 {
     if (_syncHandle.Requested)
     {
         StorageServer _manager = CloudServerFromName(_syncHandle.Server);
         return(await _manager.DeleteContent(_syncHandle.TripSummary));
     }
     else
     {
         return(true);
     }
 }
Exemple #4
0
 private async void pic_sync_Tapped(SynchroHandle _obj, TappedRoutedEventArgs e)
 {
     e.Handled = true;
     if (_parent is ViewHome)
     {
         await(_parent as ViewHome).SwitchSynchro(_obj, this);
     }
     else if (_parent is ViewMapTrip)
     {
         await(_parent as ViewMapTrip).SwitchSynchro(_obj, this);
     }
 }
Exemple #5
0
        private void UpdateCheckSync(SynchroHandle _handle, ComboBox _comboBox, CheckBox _checkBox)
        {
            if (_handle.Compression == SynchroManager.ComprLevel.Undefined)
            {
                _handle.Compression = SynchroManager.ComprLevel.Original;
            }

            _comboBox.SelectedIndex = SynchroManager.ComprToInt(TripSummaryRef.SyncUsb.Compression);
            _comboBox.Visibility    = (Boolean)_checkBox.IsChecked ? Visibility.Visible : Visibility.Collapsed;

            if ((TripRef.Sample) || !(PageRef is ViewHome))
            {
                _comboBox.IsEnabled = false;
                _checkBox.IsEnabled = false;
            }
        }
Exemple #6
0
        private void removeFromQueue(SynchroHandle _syncObj)
        {
            for (int _idx = 0; _idx < _listSyncHandle.Count; _idx++)
            {
                if ((_listSyncHandle[_idx].Server == _syncObj.Server) &&
                    (_listSyncHandle[_idx].TripSummary.Id == _syncObj.TripSummary.Id))
                {
                    _listSyncHandle.RemoveAt(_idx);
                    break;
                }
            }

            if (_syncObj.InProgress)
            {
                Cancel(_syncObj);
            }
        }
Exemple #7
0
 public void Update(SynchroHandle _syncHandle)
 {
     if ((_syncHandle.Requested && _syncHandle.Finished))
     {
         _syncHandle.SetSynchroStatus(Status.Synchronized);
     }
     else if ((_syncHandle.Requested && !_syncHandle.Finished))
     {
         _syncHandle.SetSynchroStatus(Status.InProgress);
         addToQueue(_syncHandle);
     }
     else
     {
         _syncHandle.SetSynchroStatus(Status.NoRequest);
         removeFromQueue(_syncHandle);
     }
 }
Exemple #8
0
        internal async Task Synchronize()
        {
            if (_syncInProgress)
            {
                return;
            }

            _syncInProgress = true;

            while (_listSyncHandle.Count > 0)
            {
                SynchroHandle _syncHandle = _listSyncHandle.First <SynchroHandle>();
                Status        _status     = SynchroManager.Status.ErrorOrNotConnected;

                StorageServer _server = CloudServerFromName(_syncHandle.Server);
                _server.SyncMngr    = this;
                _server.Compression = _syncHandle.Compression;
                if (Parent != null)
                {
                    _server.Parent = Parent;
                }

                // start synchronization, reset Cts before
                _syncHandle.InProgress = true;
                _server.ResetCts();
                _status = await _server.Synchronize(_syncHandle);

                _syncHandle.InProgress = false;

                if (_status == Status.Synchronized)
                {
                    _syncHandle.Finished = true;
                }

                _syncHandle.SetSynchroStatus(_status);

                removeFromQueue(_syncHandle);

                if ((_listSyncHandle.Count == 0) && (Parent != null) && (Parent is ViewHome))
                {
                    await(Parent as ViewHome).SaveSummary();
                }
            }

            _syncInProgress = false;
        }
Exemple #9
0
        public void SetSynchroStatus(SynchroHandle _syncObj, SynchroManager.Status _status)
        {
            // not synchronized => rect not visible
            // synchronized but not connected => rect visible red
            // synchronized connected but not finished => rect visible orange
            // synchronized connected but finished => rect visible green

            Visibility      _visibility = Visibility.Collapsed;
            SolidColorBrush _color      = null;

            switch (_status)
            {
            case SynchroManager.Status.NoRequest:
                loadRing.IsActive = false;
                _color            = new SolidColorBrush(Colors.White);
                _timer.Stop();
                break;

            case SynchroManager.Status.ErrorOrNotConnected:
                loadRing.IsActive = false;
                _visibility       = Visibility.Visible;
                _color            = new SolidColorBrush(Colors.Red);
                _timer.Stop();
                break;

            case SynchroManager.Status.InProgress:
                loadRing.IsActive = true;
                _visibility       = Visibility.Visible;
                _color            = new SolidColorBrush(Colors.Orange);
                _handleProgress   = _syncObj;
                _timer.Start();
                break;

            case SynchroManager.Status.Synchronized:
                loadRing.IsActive = false;
                _visibility       = Visibility.Visible;
                _color            = new SolidColorBrush(Colors.Green);
                _timer.Stop();
                break;
            }

            _syncObj.UpdateRectangle(_visibility, _color);
        }
        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);
        }
Exemple #11
0
        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);
        }
        public async Task SwitchSynchro(SynchroHandle _syncObj, TripDescUserControl _tripDesc)
        {
            _syncObj.Requested = !_syncObj.Requested;
            _syncObj.Finished  = false;

            if (_syncObj.Compression == SynchroManager.ComprLevel.Undefined)
            {
                MessageDialog messageDialog;
                messageDialog = new MessageDialog(_res.GetString("CompressionChooseLevel"),
                                                  _res.GetString("SynchroWith") + " " + _app.SynchroManager.CloudServerFromName(_syncObj.Server).DisplayName);
                messageDialog.Commands.Add(new UICommand(_res.GetString("CompressionHigh"), (command) => { _syncObj.Compression = SynchroManager.ComprLevel.High; }));
                messageDialog.Commands.Add(new UICommand(_res.GetString("CompressionMedium"), (command) => { _syncObj.Compression = SynchroManager.ComprLevel.Medium; }));
                messageDialog.Commands.Add(new UICommand(_res.GetString("CompressionNo"), (command) => { _syncObj.Compression = SynchroManager.ComprLevel.Original; }));
                messageDialog.CancelCommandIndex  = 0;
                messageDialog.DefaultCommandIndex = 2;
                await messageDialog.ShowAsync();
            }

            await SaveSummary();

            _app.SynchroManager.Update(_syncObj);
        }
Exemple #13
0
        public void Cancel(SynchroHandle _syncHandle)
        {
            StorageServer _manager = CloudServerFromName(_syncHandle.Server);

            _manager.Cancel();
        }
Exemple #14
0
 private async void addToQueue(SynchroHandle _syncObj)
 {
     _listSyncHandle.Add(_syncObj);
     await Synchronize();
 }
 public abstract Task <SynchroManager.Status> Synchronize(SynchroHandle _syncHandle);
        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);
            }
        }