Beispiel #1
0
        public async Task <SyncCommandResult> Sync(string syncKey, string folderId, ExchangeChangeSet changeset)
        {
            if (string.IsNullOrEmpty(syncKey))
            {
                throw new ArgumentNullException(nameof(syncKey));
            }
            if (string.IsNullOrEmpty(folderId))
            {
                throw new ArgumentNullException(nameof(folderId));
            }
            if (changeset == null)
            {
                throw new ArgumentNullException(nameof(changeset));
            }

            LogService.Log("ActiveSyncServer", string.Format("Syncing key: {0} folder id: {1}", syncKey.TakeLast(5), folderId != null ? folderId.TakeLast(5) : "<none>"));

            SyncCommand command = new SyncCommand(new SyncCommandParameter(syncKey, folderId, changeset), this.settings);

            ResponseResult <SyncCommandResult> result = await command.Execute();

            if (ActiveSyncErrorHelper.IsStatusProvisioningError(result.Data?.Status, result?.Error))
            {
                await this.TryDoProvisioning();

                result = await command.Execute();
            }

            if (result.Error != null)
            {
                throw result.Error;
            }

            return(result.Data);
        }
Beispiel #2
0
        /// <summary>
        /// Complete the authentication process if we're redirected by the oauth callback.
        /// </summary>
        /// <param name="uri"></param>
        public async void CompleteAuth(Uri uri)
        {
            // Only run this function if we don't have an access token.
            IsolatedStorageSettings isss = IsolatedStorageSettings.ApplicationSettings;

            if (!isss.Contains("access_token"))
            {
                SyncCommand.IsEnabled = false;

                /*
                 * Set the auth method to null (neither manual nor automatic if we are on a callback.
                 * The reason is that i don't want the page to flash the non-auth when you're redirected from the login page.
                 * This makes sure that neither enter verifier nor start auth process is shown when you just started.
                 * This also means that if getting an access token fails, the user won't have any recourse. I need to fix that.
                 * Potentially by having the auth method return true/false? I can do that now that I can await Executes.
                 */
                if (uri.OriginalString.Contains("oauth_callback"))
                {
                    IsManualAuth = null;
                    var user = await ReadabilityClient.UserEndpoint.CompleteAuth(uri);

                    if (user != null)
                    {
                        User = user;
                        DataStorage.SaveUser(user);
                        await LoadData();

                        SyncCommand.IsEnabled = true;
                        if (SyncCommand.CanExecute(null))
                        {
                            SyncCommand.Execute(null);
                        }
                    }
                }
                else
                {
                    // If we are not in the callback, then either we're just starting auth or we're doing a manual auth.
                    IsManualAuth = isss.Contains("oauth_token");
                }
                NotifyPropertyChanged("IsManualAuth");
            }
        }
Beispiel #3
0
        public AppViewModel()
        {
            Title = "Syncurr";

            InitTabs();
            SelectedTab = Tabs[0];

            Timer          = new DispatcherTimer();
            Timer.Interval = new TimeSpan(0, Properties.Settings.Default.SyncInterval, 0);
            Timer.Tick    += (s, e) =>
            {
                if (SyncCommand.CanExecute(null))
                {
                    SyncCommand.Execute(null);
                }
            };
            Timer.Start();

            if (Properties.Settings.Default.StartMinimized)
            {
                HasWindow = false;
            }
        }
        public void ManagerRequirementCheckTest()
        {
            var start = new StartElectionCommand(NewPeer.Address);
            var end   = new EndElectionCommand(NewPeer.Address);

            Assert.That(!((TestUi)Station.UI).OngoingElection);
            start.Execute(Station);
            Assert.That(!((TestUi)Station.UI).OngoingElection);
            Station.StartElection();
            Assert.That(Station.ElectionInProgress);
            end.Execute(Station);
            Assert.That(Station.ElectionInProgress);

            var vn            = new VoterNumber(5);
            var cpr           = new CPR(5);
            var req           = new RequestBallotCommand(NewPeer.Address, vn, cpr);
            var reqCPROnly    = new RequestBallotCPROnlyCommand(NewPeer.Address, cpr, "sup homey");
            var revoke        = new RevokeBallotCommand(NewPeer.Address, vn, cpr);
            var revokeCPROnly = new RevokeBallotCPROnlyCommand(NewPeer.Address, cpr, "sup homey");

            req.Execute(Station);
            reqCPROnly.Execute(Station);
            revoke.Execute(Station);
            revokeCPROnly.Execute(Station);
            Assert.That(Station.Database[vn, cpr] == BallotStatus.Unavailable);

            NewPeer.Crypto.VoterDataEncryptionKey = Manager.Crypto.VoterDataEncryptionKey;
            var sync = new SyncCommand(NewPeer);

            sync.Execute(Station);

            var promoteManager = new PromoteNewManagerCommand(NewPeer.Address, NewPeer.Address);

            promoteManager.Execute(Station);
            Assert.That(!Station.Manager.Equals(NewPeer.Address));
        }
Beispiel #5
0
        SyncResponse IEasConnection.Sync(SyncRequest syncRequest)
        {
            SyncCommand syncCommand = new SyncCommand(this.EasConnectionSettings);

            return(syncCommand.Execute(syncRequest));
        }
        private void HandleButtonCommand(GameControllerButtonCommand command, GameControllerUpdateNotification notification)
        {
            int index;

            switch (command)
            {
            case GameControllerButtonCommand.UnPark:
                if (notification == GameControllerUpdateNotification.CommandUp)
                {
                    if (ParkCommand.CanExecute(null))
                    {
                        if (IsParked)
                        {
                            ParkCommand.Execute(null);
                        }
                    }
                }
                break;

            case GameControllerButtonCommand.ParkToHome:
                if (notification == GameControllerUpdateNotification.CommandUp)
                {
                    if (ParkCommand.CanExecute(null))
                    {
                        if (!IsParked)
                        {
                            ParkCommand.Execute(null);
                        }
                    }
                }
                break;

            case GameControllerButtonCommand.Sync:
                if (notification == GameControllerUpdateNotification.CommandUp)
                {
                    if (SyncCommand.CanExecute(null))
                    {
                        SyncCommand.Execute(null);
                    }
                }
                break;

            case GameControllerButtonCommand.IncrementPreset:
                index = Settings.SlewRatePresets.IndexOf(Settings.SlewRatePreset);
                if (index < Settings.SlewRatePresets.Count - 1)
                {
                    Settings.SlewRatePreset = Settings.SlewRatePresets[index + 1];
                }
                break;

            case GameControllerButtonCommand.DecrementPreset:
                index = Settings.SlewRatePresets.IndexOf(Settings.SlewRatePreset);
                if (index > 0)
                {
                    Settings.SlewRatePreset = Settings.SlewRatePresets[index - 1];
                }
                break;

            case GameControllerButtonCommand.EmergencyStop:
                if (notification == GameControllerUpdateNotification.CommandUp)
                {
                    if (StopSlewCommand.CanExecute(SlewButton.Stop))
                    {
                        StopSlewCommand.Execute(SlewButton.Stop);
                    }
                }
                break;

            case GameControllerButtonCommand.North:
                HandleSlewButton(SlewButton.North, notification);
                break;

            case GameControllerButtonCommand.South:
                HandleSlewButton(SlewButton.South, notification);
                break;

            case GameControllerButtonCommand.East:
                HandleSlewButton(SlewButton.East, notification);
                break;

            case GameControllerButtonCommand.West:
                HandleSlewButton(SlewButton.West, notification);
                break;

            case GameControllerButtonCommand.ReverseRA:
                if (notification == GameControllerUpdateNotification.CommandUp)
                {
                    Settings.ReverseRA = !Settings.ReverseRA;
                }
                break;

            case GameControllerButtonCommand.ReverseDec:
                if (notification == GameControllerUpdateNotification.CommandUp)
                {
                    Settings.ReverseDec = !Settings.ReverseDec;
                }
                break;

            case GameControllerButtonCommand.SiderealRate:
                HandleStartStopTrackingButton(TrackingMode.Sidereal, notification);
                break;

            case GameControllerButtonCommand.LunarRate:
                HandleStartStopTrackingButton(TrackingMode.Lunar, notification);
                break;

            case GameControllerButtonCommand.SolarRate:
                HandleStartStopTrackingButton(TrackingMode.Solar, notification);
                break;

            case GameControllerButtonCommand.CustomRate:
                HandleStartStopTrackingButton(TrackingMode.Custom, notification);
                break;

            case GameControllerButtonCommand.StopTracking:
                HandleStartStopTrackingButton(TrackingMode.Stop, notification);
                break;
            }
        }
        public void ExecuteThrowsNotImplemented()
        {
            var cmd = new SyncCommand();

            cmd.Execute(null);
        }
Beispiel #8
0
        public SettingsViewModel(ISettingsService settings, SyncService sync, IIAPService iapService)
        {
            if (settings == null)
            {
                throw new ArgumentNullException("settings");
            }
            _settings = settings;
            if (sync == null)
            {
                throw new ArgumentNullException("sync");
            }
            _syncService = sync;
            if (iapService == null)
            {
                throw new ArgumentNullException("iapService");
            }
            _iapService = iapService;

#pragma warning disable 1998
            ConnectCommand = new AsyncRelayCommand(async(o) =>
            {
                if (!_syncService.IsConnected)
                {
                    await _syncService.Authenticate();
                }
                else
                {
                    _syncService.Disconnect();
                }
            }, null,
                                                   async() =>
            {
                if (SyncEnabled && _syncService.IsConnected)
                {
                    SyncCommand.Execute(null);
                }
                RaisePropertyChanged(() => SyncEnabled);
                RaisePropertyChanged(() => IsConnected);
                RaisePropertyChanged(() => ConnectLabel);
                RaisePropertyChanged(() => OnOffText);
            },
                                                   (ex) =>
            {
                //TODO: Handle Error
            });

            SyncCommand = new AsyncRelayCommand(async(o) =>
            {
                SyncRunning = true;
                await _syncService.Sync();
            }, null,
                                                async() =>
            {
                SyncRunning = false;
            },
                                                (ex) =>
            {
                //TODO: Handle Error
                SyncRunning = false;
                throw ex;
            });
#pragma warning restore 1998
        }