Beispiel #1
0
        async void BtnNext_Click(object sender, RoutedEventArgs e)
        {
            var supportsPin = true;

            if (supportsPin)
            {
                await _nav.Navigate(new StartupWizardPage2(_nav, _connectionManager, _presentation, _logger));
            }
            else
            {
                Dispatcher.InvokeAsync(() => _presentation.ShowModalLoadingAnimation());

                try
                {
                    var connectionResult = await _connectionManager.Connect(CancellationToken.None);

                    Dispatcher.InvokeAsync(() => _presentation.HideModalLoadingAnimation());

                    if (connectionResult.State == ConnectionState.Unavailable)
                    {
                        await _nav.Navigate(new StartupPageServerEntry(_nav, _connectionManager, _presentation, _logger));
                    }
                    else
                    {
                        App.Instance.NavigateFromConnectionResult(connectionResult);
                    }
                }
                catch (Exception)
                {
                    Dispatcher.InvokeAsync(() => _presentation.HideModalLoadingAnimation());
                }
            }
        }
Beispiel #2
0
        private async Task SyncInternal(ServerInfo server, bool enableCameraUpload, IProgress <double> progress, CancellationToken cancellationToken)
        {
            _logger.Debug("Beginning ServerSync with server {0}, Id {1}", server.Name, server.Id);

            if (string.IsNullOrWhiteSpace(server.AccessToken) && string.IsNullOrWhiteSpace(server.ExchangeToken))
            {
                _logger.Info("Skipping sync process for server " + server.Name + ". No server authentication information available.");
                progress.Report(100);
                return;
            }

            // Don't need these here
            var result = await _connectionManager.Connect(server, new ConnectionOptions
            {
                EnableWebSocket        = false,
                ReportCapabilities     = false,
                UpdateDateLastAccessed = false
            }, cancellationToken).ConfigureAwait(false);

            if (result.State == ConnectionState.SignedIn)
            {
                await SyncInternal(server, result.ApiClient, enableCameraUpload, progress, cancellationToken).ConfigureAwait(false);

                progress.Report(100);
            }
            else
            {
                _logger.Info("Skipping sync process for server " + server.Name + ". ConnectionManager returned a state of {0}", result.State.ToString());
                progress.Report(100);
            }
        }
Beispiel #3
0
        private async void GoNext()
        {
            StopPinTimer();

            _presentation.ShowModalLoadingAnimation();

            try
            {
                var connectionResult = await _connectionManager.Connect(CancellationToken.None);

                _presentation.HideModalLoadingAnimation();

                if (connectionResult.State == ConnectionState.Unavailable)
                {
                    connectionResult.State = ConnectionState.ServerSelection;
                }

                App.Instance.NavigateFromConnectionResult(connectionResult);
                return;
            }
            catch (Exception)
            {
                _presentation.HideModalLoadingAnimation();
            }

            await _nav.Navigate(new StartupPageServerEntry(_nav, _connectionManager, _presentation, _logger));
        }
        public async Task Sync(ServerInfo server, IProgress <double> progress, CancellationToken cancellationToken)
        {
            if (string.IsNullOrWhiteSpace(server.AccessToken) && string.IsNullOrWhiteSpace(server.ExchangeToken))
            {
                LogNoAuthentication(server);
                progress.Report(100);
                return;
            }

            // Don't need these here
            var result = await _connectionManager.Connect(server, new ConnectionOptions
            {
                EnableWebSocket    = false,
                ReportCapabilities = false
            }, cancellationToken).ConfigureAwait(false);

            if (result.State == ConnectionState.SignedIn)
            {
                await SyncInternal(server, result.ApiClient, progress, cancellationToken).ConfigureAwait(false);

                progress.Report(100);
            }
            else
            {
                LogNoAuthentication(server);
                progress.Report(100);
            }
        }
Beispiel #5
0
        async void BtnNext_Click(object sender, RoutedEventArgs e)
        {
            if (ValidateInput())
            {
                var serverAddress = string.Format("http://{0}", TxtHost.Text);
                if (!string.IsNullOrEmpty(TxtPort.Text))
                {
                    serverAddress += ":" + TxtPort.Text;
                }

                try
                {
                    var connectionResult = await _connectionManager.Connect(serverAddress, CancellationToken.None);

                    if (connectionResult.State == ConnectionState.Unavailable)
                    {
                        ShowUnavailableMessage();
                        return;
                    }

                    App.Instance.NavigateFromConnectionResult(connectionResult);
                }
                catch (Exception)
                {
                    ShowUnavailableMessage();
                }
            }
        }
Beispiel #6
0
        /// <summary>
        ///  Get search  list
        /// </summary>
        /// <param name="inputObjects">This is the dictionary of arraylists of
        /// business object transactions specified by the caller. This typically hails
        /// from the web service or page class and simply passed from one object in the
        /// chain to another until it is referenced here.</param>
        /// <param name="globals">This is a dictionary where the keys are intended to hold globally
        /// unique values used to establish relationships between collections of business object
        /// transactions in the inputObjects dictionary. The objects corresponding to each key
        /// are intended to be a instance of the KeyResolver class.</param>
        /// <param name="prototype">search object</param>
        /// <returns>List of search</returns>
        public List <Isearch> Getsearch(IDictionary <object, object> inputObjects, IDictionary <object, object> globals, Isearch prototype)
        {
            IDictionary <object, object> workingObjects = new Dictionary <object, object>();

            try
            {
                _cm.Init(base.Env, base.Server);
                _cm.Connect(DBEntity.PMC, base.PmcID, base.SiteID, base.UserID);
                _dao.CM = _cm;
                RPComponents.IBusinessObjectTransaction         bot  = new RPComponents.BusinessObjectTransaction();
                IList <RPComponents.IBusinessObjectTransaction> bots = new List <RPComponents.IBusinessObjectTransaction>();
                bot.BusinessObject = prototype;
                bot.RequestType    = undefinedDAO.RequestTypes.search;
                bot.Action         = new RPComponents.Action(RPComponents.Action.Select);
                bots.Add(bot);
                _dao.ProcessTransactions(inputObjects, workingObjects, globals, bots);
            }
            finally
            {
                _cm.Disconnect();
            }
            List <Isearch> list = (List <Isearch>)workingObjects[undefinedDAO.WorkingTypes.search];

            return(list);
        }
Beispiel #7
0
        private IConnectionManager GetConnectionMangerWithUnavailableBehavior()
        {
            TargetInfo fakeTargetInfo = ProbeHelper.CreateFakeTarget();
            IList <IConnectionProvider> fakeContext = ProbeHelper.CreateFakeContext();
            string errorMessage = string.Format("Error connecting to {0}", fakeTargetInfo.GetAddress());

            MockRepository     mock = new MockRepository();
            IConnectionManager connectionManagerWithInvalidCredentials = mock.DynamicMock <IConnectionManager>();

            Expect.Call(connectionManagerWithInvalidCredentials.Connect <RegistryConnectionProvider>(fakeContext, fakeTargetInfo))
            .IgnoreArguments().Throw(new CannotConnectToHostException(fakeTargetInfo, errorMessage));

            mock.ReplayAll();
            return(connectionManagerWithInvalidCredentials);
        }
        private IConnection EnsureConnection([NotNull] Session childSession)
        {
            var existsConnection = childSession.TryGetEntry <IConnection>();

            if (existsConnection != null)
            {
                return(existsConnection);
            }

            var connection = _connectionManager.Connect();

            childSession.Include(connection);

            return(connection);
        }
Beispiel #9
0
        public void Execute(IConnectionManager connection, ICommand command)
        {
            INetwork network;

            if (command.Network == null)
            {
                //if the network infomation is not set explicitly
                //parse it out, when calling the command as
                //a client command /server then this will be the
                //case.
                string uri = command.Arguments[0];
                string protocol = "irc://";

                if (!uri.StartsWith(protocol))
                {
                    uri = protocol + uri;
                }

                Uri networkUrl = new Uri(uri);

                if (networkUrl.Port < 0)
                {
                    uri += ":6667";
                }

                network = new Network
                {
                    Url = new Uri(uri),
                    LocalUser = new User(command.User),
                };
            }
            else
            {
                network = command.Network;
            }

            connection.Connect(network, command.User);
        }
Beispiel #10
0
        private async Task Sync(List <ServerInfo> servers, List <string> cameraUploadServers, bool syncOnlyOnLocalNetwork, IProgress <double> progress, CancellationToken cancellationToken = default(CancellationToken))
        {
            var    numComplete      = 0;
            double startingPercent  = 0;
            double percentPerServer = 1;

            if (servers.Count > 0)
            {
                percentPerServer /= servers.Count;
            }

            _logger.Debug("Beginning MultiServerSync with {0} servers", servers.Count);

            foreach (var server in servers)
            {
                cancellationToken.ThrowIfCancellationRequested();

                var currentPercent = startingPercent;
                var serverProgress = new DoubleProgress();
                serverProgress.RegisterAction(pct =>
                {
                    var totalProgress = pct * percentPerServer;
                    totalProgress    += currentPercent;
                    progress.Report(totalProgress);
                });

                // Grab the latest info from the connection manager about that server
                var serverInfo = await _connectionManager.GetServerInfo(server.Id).ConfigureAwait(false);

                if (serverInfo == null)
                {
                    serverInfo = server;
                }

                if (syncOnlyOnLocalNetwork)
                {
                    var result = await _connectionManager.Connect(server, new ConnectionOptions
                    {
                        EnableWebSocket        = false,
                        ReportCapabilities     = false,
                        UpdateDateLastAccessed = false
                    }, cancellationToken).ConfigureAwait(false);

                    var apiClient = result.ApiClient;

                    var endpointInfo = await apiClient.GetEndPointInfo(cancellationToken).ConfigureAwait(false);

                    _logger.Debug("Server: {0}, Id: {1}, IsInNetwork:{2}", server.Name, server.Id, endpointInfo.IsInNetwork);

                    if (!endpointInfo.IsInNetwork)
                    {
                        continue;
                    }
                }

                var enableCameraUpload = cameraUploadServers.Contains(serverInfo.Id, StringComparer.OrdinalIgnoreCase);

                await new ServerSync(_connectionManager, _logger, _localAssetManager, _fileTransferManager, _connectionManager.ClientCapabilities)
                .Sync(serverInfo, enableCameraUpload, serverProgress, cancellationToken).ConfigureAwait(false);

                numComplete++;
                startingPercent  = numComplete;
                startingPercent /= servers.Count;
                startingPercent *= 100;
                progress.Report(startingPercent);
            }

            progress.Report(100);
        }
Beispiel #11
0
        public async Task Run(CancellationToken token)
        {
            var hubConnection = await _connectionManager.Connect();

            var telemetry = new rF2Telemetry();
            var scoring   = new rF2Scoring();

            var playerScoring   = new rF2VehicleScoring();
            var playerTelemetry = new rF2VehicleTelemetry();

            while (true)
            {
                await Task.Delay(200);

                try
                {
                    _scoringBuffer.GetMappedDataPartial(ref scoring);
                    _telemetryBuffer.GetMappedDataPartial(ref telemetry);
                }
                catch (Exception)
                {
                    await _connectionManager.Disconnect(hubConnection);

                    return;
                }

                if (telemetry.mNumVehicles != 0 && scoring.mScoringInfo.mNumVehicles != 0 && (rFactor2Constants.rF2GamePhase)scoring.mScoringInfo.mGamePhase == rFactor2Constants.rF2GamePhase.GreenFlag)
                {
                    var mappedIds = MapmIdToPositionInArray(ref telemetry);

                    foreach (var scoringVehicle in scoring.mVehicles)
                    {
                        switch ((rFactor2Constants.rF2Control)scoringVehicle.mControl)
                        {
                        case rFactor2Constants.rF2Control.AI:
                        case rFactor2Constants.rF2Control.Player:
                        case rFactor2Constants.rF2Control.Remote:
                            if (scoringVehicle.mIsPlayer == 1)
                            {
                                playerScoring = scoringVehicle;
                            }
                            break;

                        default:
                            continue;
                        }
                        if (playerScoring.mIsPlayer == 1)
                        {
                            break;
                        }
                    }

                    var playerTelemetryId = -1;
                    if (mappedIds.TryGetValue(playerScoring.mID, out playerTelemetryId))
                    {
                        playerTelemetry = telemetry.mVehicles[playerTelemetryId];
                    }
                    else
                    {
                        continue;
                    }

                    var telemetryToSend = new Test
                    {
                        Telemetry = new Telemetry(ref playerTelemetry)
                    };
                    await hubConnection.SendAsync("Send", telemetryToSend);
                }
            }
        }
 public override async Task StartAsync(CancellationToken cancellationToken)
 {
     _logger.LogInformation($"Worker started at: {DateTime.Now}");
     _mqManager.Connect();
     await base.StartAsync(cancellationToken);
 }
 private void Join(object sender, RoutedEventArgs e)
 {
     connection.Connect(SessionId, session.CurrentUser);
 }
Beispiel #14
0
 public void Connect(string url)
 {
     m_connectionManager.Connect(url);
 }
Beispiel #15
0
        private void OpenConnection(TargetInfo target)
        {
            IList <IConnectionProvider> connectionContext = new List <IConnectionProvider>();

            this.connectionProvider = connectionManager.Connect <WindowsSystemInformationConnectionProvider>(connectionContext, target);
        }