Пример #1
0
        /// <summary> Connect this <see cref="NodePort"/> to another </summary>
        /// <param name="port">The <see cref="NodePort"/> to connect to</param>
        public void Connect(INodePort port)
        {
            if (connections == null)
            {
                connections = new List <PortConnection>();
            }

            if (!ConnectionValidator.Validate(this, port))
            {
                GameLog.LogError($"{node?.GraphData.ItemName}:{Node?.ItemName}:{ItemName} Connection Error. Validation Failed");
                return;
            }

            if (port.ConnectionType == ConnectionType.Override && port.ConnectionCount != 0)
            {
                port.ClearConnections();
            }

            if (ConnectionType == ConnectionType.Override && ConnectionCount != 0)
            {
                ClearConnections();
            }

            var portNode = port.Node;

            connections.Add(new PortConnection(port, portNode.Id));

            if (!port.IsConnectedTo(this))
            {
                port.CreateConnection(nodeId, ItemName);
            }
        }
Пример #2
0
        /// <summary>
        /// Initializes the feed (unity)
        /// </summary>
        protected virtual void InitFeed()
        {
            if (FeedInitialized)
            {
                return;
            }

            lock (_lockInitialized)
            {
                if (FeedInitialized)
                {
                    return;
                }

                InternalConfig.Load(); // loads bookmaker_details
                if (InternalConfig.BookmakerDetails == null)
                {
                    _log.LogError("Token not accepted.");
                    return;
                }
                UnityContainer.RegisterTypes(this, InternalConfig);
                UnityContainer.RegisterAdditionalTypes();

                _feedRecoveryManager = UnityContainer.Resolve <IFeedRecoveryManager>();
                _connectionValidator = UnityContainer.Resolve <ConnectionValidator>();

                FeedInitialized = true;
            }
        }
Пример #3
0
        /// <summary>
        /// <see cref="IRemoteConnection.IsValid(ConnectionValidator)" />
        /// </summary>
        public bool IsValid(ConnectionValidator validator)
        {
            if (validator == null)
            {
                return(true);
            }

            return(validator(this));
        }
Пример #4
0
        /// <summary>
        /// Constructs a new instance of the <see cref="MtsSdk"/> class
        /// </summary>
        /// <param name="config">A <see cref="ISdkConfiguration"/> instance representing feed configuration</param>
        /// <param name="loggerFactory">A <see cref="ILoggerFactory"/> used to create <see cref="ILogger"/> used within sdk</param>
        /// <param name="metricsRoot">A <see cref="IMetricsRoot"/> used to provide metrics within sdk</param>
        public MtsSdk(ISdkConfiguration config, ILoggerFactory loggerFactory = null, IMetricsRoot metricsRoot = null)
        {
            Guard.Argument(config, nameof(config)).NotNull();

            LogInit();

            _isDisposed = false;
            _isOpened   = 0;

            _unityContainer = new UnityContainer();
            _unityContainer.RegisterTypes(config, loggerFactory, metricsRoot);
            _config = _unityContainer.Resolve <ISdkConfigurationInternal>();

            _executionLog   = SdkLoggerFactory.GetLoggerForExecution(typeof(MtsSdk));
            _interactionLog = SdkLoggerFactory.GetLoggerForExecution(typeof(MtsSdk));

            LogInit();

            _metricsRoot          = _unityContainer.Resolve <IMetricsRoot>();
            _metricsLogger        = SdkLoggerFactory.GetLoggerForStats(typeof(MtsSdk));
            _metricsTaskScheduler = new AppMetricsTaskScheduler(
                TimeSpan.FromSeconds(_config.StatisticsTimeout),
                async() => { await LogMetricsAsync(); });


            _connectionValidator = _unityContainer.Resolve <ConnectionValidator>();

            BuilderFactory          = _unityContainer.Resolve <IBuilderFactory>();
            _ticketPublisherFactory = _unityContainer.Resolve <ITicketSenderFactory>();

            _entitiesMapper = _unityContainer.Resolve <EntitiesMapper>();

            _rabbitMqMessageReceiverForTickets           = _unityContainer.Resolve <IRabbitMqMessageReceiver>("TicketResponseMessageReceiver");
            _rabbitMqMessageReceiverForTicketCancels     = _unityContainer.Resolve <IRabbitMqMessageReceiver>("TicketCancelResponseMessageReceiver");
            _rabbitMqMessageReceiverForTicketCashouts    = _unityContainer.Resolve <IRabbitMqMessageReceiver>("TicketCashoutResponseMessageReceiver");
            _rabbitMqMessageReceiverForTicketNonSrSettle = _unityContainer.Resolve <IRabbitMqMessageReceiver>("TicketNonSrSettleResponseMessageReceiver");

            ClientApi        = _unityContainer.Resolve <IMtsClientApi>();
            CustomBetManager = _unityContainer.Resolve <ICustomBetManager>();
            ConnectionStatus = _unityContainer.Resolve <IConnectionStatus>();
            ReportManager    = _unityContainer.Resolve <IReportManager>();

            _autoResetEventsForBlockingRequests        = new ConcurrentDictionary <string, AutoResetEvent>();
            _responsesFromBlockingRequests             = new ConcurrentDictionary <string, ISdkTicket>();
            _ticketsForNonBlockingRequests             = new MemoryCache("TicketsForNonBlockingRequests");
            _lockForTicketsForNonBlockingRequestsCache = new object();

            foreach (var t in Enum.GetValues(typeof(SdkTicketType)))
            {
                var publisher = _ticketPublisherFactory.GetTicketSender((SdkTicketType)t);
                if (publisher != null)
                {
                    publisher.TicketSendFailed += PublisherOnTicketSendFailed;
                }
            }
        }
        public bugzilla_properties CheckConnection(BugzillaProfile profile)
        {
            var errors = new PluginProfileErrorCollection();

            try
            {
                var validators = new Queue <Validator>();

                var connectionValidator = new ConnectionValidator(profile);
                validators.Enqueue(connectionValidator);

                var scriptValidator = new ScriptValidator(profile);
                validators.Enqueue(scriptValidator);

                var responseValidator = new ResponseValidator(profile, scriptValidator);
                validators.Enqueue(responseValidator);

                var deserializeValidator = new DeserializeValidator(profile, responseValidator);
                validators.Enqueue(deserializeValidator);

                var settingsValidator = new SettingsValidator(profile, deserializeValidator);
                validators.Enqueue(settingsValidator);

                var savedQueryValidator = new SavedQueryValidator(profile);
                validators.Enqueue(savedQueryValidator);

                while (validators.Count > 0)
                {
                    var validator = validators.Dequeue();
                    validator.Execute(errors);
                }

                if (errors.Any())
                {
                    throw new BugzillaPluginProfileException(profile, errors);
                }

                return(deserializeValidator.Data);
            }
            catch (BugzillaPluginProfileException)
            {
                throw;
            }
            catch (Exception ex)
            {
                errors.Add(new PluginProfileError
                {
                    FieldName = BugzillaProfile.ProfileField,
                    Message   = string.Format("The connection with {0} is failed. {1}", profile, ex.Message)
                });
                throw new BugzillaPluginProfileException(profile, errors);
            }
        }
Пример #6
0
        public static ConnectionCredentials GetConnectionCredentials(string serverUrl, string username, SecureString password)
        {
            var credentials = new ConnectionCredentials
            {
                ServerUrl           = new Uri(serverUrl),
                PortSpecifiedByUser = ConnectionValidator.Port80Specified(serverUrl),
                ProxyRequired       = false,
                Username            = username,
                Password            = password,
            };

            return(credentials);
        }
Пример #7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Feed"/> class
        /// </summary>
        /// <param name="config">A <see cref="IOddsFeedConfiguration"/> instance representing feed configuration</param>
        /// <param name="isReplay">Value indicating whether the constructed instance will be used to connect to replay server</param>
        protected Feed(IOddsFeedConfiguration config, bool isReplay)
        {
            Contract.Requires(config != null);

            LogInit();

            var container = new UnityContainer();

            container.EnableDebugDiagnostic();
            container.RegisterBaseTypes(config);
            var internalConfig = container.Resolve <IOddsFeedConfigurationInternal>();

            if (isReplay || internalConfig.Environment == SdkEnvironment.Replay)
            {
                internalConfig.EnableReplayServer();
            }
            internalConfig.Load(); // loads bookmaker_details
            container.RegisterTypes(this);
            container.RegisterAdditionalTypes();
            CurrentUnityContainer = container;

            EventRecoveryRequestIssuer   = CurrentUnityContainer.Resolve <IEventRecoveryRequestIssuer>();
            SportDataProvider            = CurrentUnityContainer.Resolve <ISportDataProvider>();
            CashOutProbabilitiesProvider = CurrentUnityContainer.Resolve <ICashOutProbabilitiesProvider>();
            _feedRecoveryManager         = CurrentUnityContainer.Resolve <IFeedRecoveryManager>();
            _connectionValidator         = CurrentUnityContainer.Resolve <ConnectionValidator>();
            InternalConfig           = CurrentUnityContainer.Resolve <IOddsFeedConfigurationInternal>();
            BookingManager           = CurrentUnityContainer.Resolve <IBookingManager>();
            MarketDescriptionManager = CurrentUnityContainer.Resolve <IMarketDescriptionManager>();
            BookmakerDetails         = InternalConfig.BookmakerDetails;
            CustomBetManager         = CurrentUnityContainer.Resolve <ICustomBetManager>();
            try
            {
                ProducerManager = CurrentUnityContainer.Resolve <IProducerManager>();
                if (isReplay || internalConfig.Environment == SdkEnvironment.Replay)
                {
                    ((ProducerManager)ProducerManager).SetIgnoreRecovery(0);
                }
            }
            catch (Exception e)
            {
                Log.Error("Error getting available producers.", e);
                throw;
            }
        }
Пример #8
0
        /// <summary>
        /// Constructs a new instance of the <see cref="MtsSdk"/> class
        /// </summary>
        /// <param name="config">A <see cref="ISdkConfiguration"/> instance representing feed configuration</param>
        public MtsSdk(ISdkConfiguration config)
        {
            Guard.Argument(config, nameof(config)).NotNull();

            LogInit();

            _isDisposed = false;
            _isOpened   = 0;

            _unityContainer = new UnityContainer();
            SdkUnityBootstrapper.RegisterTypes(_unityContainer, config);

            _config = _unityContainer.Resolve <ISdkConfigurationInternal>();
            _connectionValidator = _unityContainer.Resolve <ConnectionValidator>();

            BuilderFactory          = _unityContainer.Resolve <IBuilderFactory>();
            _ticketPublisherFactory = _unityContainer.Resolve <ITicketSenderFactory>();

            _entitiesMapper = _unityContainer.Resolve <EntitiesMapper>();

            _rabbitMqMessageReceiverForTickets           = _unityContainer.Resolve <IRabbitMqMessageReceiver>("TicketResponseMessageReceiver");
            _rabbitMqMessageReceiverForTicketCancels     = _unityContainer.Resolve <IRabbitMqMessageReceiver>("TicketCancelResponseMessageReceiver");
            _rabbitMqMessageReceiverForTicketCashouts    = _unityContainer.Resolve <IRabbitMqMessageReceiver>("TicketCashoutResponseMessageReceiver");
            _rabbitMqMessageReceiverForTicketNonSrSettle = _unityContainer.Resolve <IRabbitMqMessageReceiver>("TicketNonSrSettleResponseMessageReceiver");

            ClientApi        = _unityContainer.Resolve <IMtsClientApi>();
            CustomBetManager = _unityContainer.Resolve <ICustomBetManager>();
            ConnectionStatus = _unityContainer.Resolve <IConnectionStatus>();
            ReportManager    = _unityContainer.Resolve <IReportManager>();

            _autoResetEventsForBlockingRequests        = new ConcurrentDictionary <string, AutoResetEvent>();
            _responsesFromBlockingRequests             = new ConcurrentDictionary <string, ISdkTicket>();
            _ticketsForNonBlockingRequests             = new MemoryCache("TicketsForNonBlockingRequests");
            _lockForTicketsForNonBlockingRequestsCache = new object();

            foreach (var t in Enum.GetValues(typeof(SdkTicketType)))
            {
                var publisher = _ticketPublisherFactory.GetTicketSender((SdkTicketType)t);
                if (publisher != null)
                {
                    publisher.TicketSendFailed += PublisherOnTicketSendFailed;
                }
            }
        }
Пример #9
0
        /*public string ProxyUrl { get; private set; }
         * public int ProxyPort { get; private set; }
         * public bool ProxyAuthRequired { get; private set; }
         * public string ProxyUserName { get; private set; }
         * public SecureString ProxyPassword { get; private set; }   */

        public static ConnectionCredentials GetConnectionCredentials(ConnectionParams connectionParams)
        {
            var credentials = new ConnectionCredentials
            {
                Password            = connectionParams.Password,
                ServerUrl           = connectionParams.Url(),
                PortSpecifiedByUser = ConnectionValidator.Port80Specified(connectionParams.Server),
                Username            = connectionParams.UserName,

                /*ProxyAuthRequired = connectionParams.Proxy.IsAuthRequired,
                 * ProxyPassword = connectionParams.Proxy.Password,
                 * ProxyPort = connectionParams.Proxy.Port,
                 * ProxyRequired = connectionParams.Proxy.IsRequired,
                 * ProxyUrl = connectionParams.Proxy.Url,
                 * ProxyUserName = connectionParams.Proxy.UserName*/
            };

            return(credentials);
        }
        public void RunCase(Func <FlowBuilder, IFlowNode> createNode, int errorsCount)
        {
            // Arrange
            var b = new FlowBuilder();

            var f = b.FaultHandler <MyFaultHandler>();
            var c = b.Activity <MyCancellationHandler>();

            b.WithDefaultFaultHandler(f);
            b.WithDefaultCancellationHandler(c);

            var node = createNode(b);

            b.WithInitialNode(node);

            var validator = new ConnectionValidator();

            // Act
            validator.Validate(b.CreateFlow());

            // Assert
            Assert.That(validator.Result.GetErrorsOf(node).Count(), Is.EqualTo(errorsCount));
        }
Пример #11
0
        /// <summary>
        /// Initializes the feed (unity)
        /// </summary>
        protected virtual void InitFeed()
        {
            if (FeedInitialized)
            {
                return;
            }

            lock (_lockInitialized)
            {
                if (FeedInitialized)
                {
                    return;
                }

                InternalConfig.Load(); // loads bookmaker_details
                UnityContainer.RegisterTypes(this, InternalConfig);
                UnityContainer.RegisterAdditionalTypes();

                _feedRecoveryManager = UnityContainer.Resolve <IFeedRecoveryManager>();
                _connectionValidator = UnityContainer.Resolve <ConnectionValidator>();

                FeedInitialized = true;
            }
        }
Пример #12
0
        /// <summary>
        /// Initializes the feed (unity)
        /// </summary>
        protected virtual void InitFeed()
        {
            if (FeedInitialized)
            {
                return;
            }

            lock (_lockInitialized)
            {
                if (FeedInitialized)
                {
                    return;
                }

                InternalConfig.Load(); // loads bookmaker_details
                if (InternalConfig.BookmakerDetails == null)
                {
                    _log.Error("Token not accepted.");
                    return;
                }

                UnityContainer.RegisterInstance(InternalConfig.ExceptionHandlingStrategy, new ContainerControlledLifetimeManager());
                UnityContainer.RegisterInstance <IOddsFeedConfiguration>(InternalConfig, new ContainerControlledLifetimeManager());
                UnityContainer.RegisterInstance(InternalConfig, new ContainerControlledLifetimeManager());

                UnityContainer.RegisterTypes(this);

                UpdateDependency();
                UnityContainer.RegisterAdditionalTypes();

                _feedRecoveryManager = UnityContainer.Resolve <IFeedRecoveryManager>();
                _connectionValidator = UnityContainer.Resolve <ConnectionValidator>();

                FeedInitialized = true;
            }
        }
        public static void Init(TestContext context)
        {
            var config = TestConfigurationInternal.GetConfig();

            _validator = new ConnectionValidator(config, new HttpDataFetcher(new HttpClient(), TestData.AccessToken, new Deserializer <response>()));
        }
Пример #14
0
        private async void BtnSubmit_Clicked(object sender, EventArgs e)
        {
            // Pencil test
            if (TxtHowDeep.Text != null)
            {
                survey.pencilDepth = Double.Parse(TxtHowDeep.Text);
            }

            // How soft is the deadwood
            survey.deadwoodSoftness = (string)PickHowSoft.SelectedItem;

            // Adds comma separated string of animals inside the deadwood
            List <string> AnimalsInDeadWoodList = new List <string>()
            {
                (string)PickInside.SelectedItem
            };

            foreach (Picker item in StackInside.Children)
            {
                AnimalsInDeadWoodList.Add((string)item.SelectedItem);
            }
            string AnimalsInDeadWood = string.Join(", ", AnimalsInDeadWoodList);

            Console.WriteLine("ANIMALS ON DEADWOOD: " + AnimalsInDeadWood);
            survey.faunaOnDeadwood = AnimalsInDeadWood;

            // Deadwood colour
            survey.deadwoodColour = (string)PickColour.SelectedItem;

            // Decay
            if (PickDecay.SelectedIndex >= 0)
            {
                survey.deadwoodDecay = int.Parse((string)PickDecay.SelectedItem);
            }


            // Will submit final survey
            bool result = await DisplayAlert("Are you sure?", "Would you like to submit your survey? You cannot go back and change it once you do", "Submit", "Cancel");

            if (result)
            {
                LblSendingMessage.Text = "Sending, please wait...";
                //test for net connection
                while (true)
                {
                    ConnectionValidator connectionValidator = new ConnectionValidator();

                    if (connectionValidator.CheckForInternetConnection())
                    {
                        Sender surveySender = new Sender();
                        await surveySender.RunAsync(survey);

                        break;
                    }

                    System.Threading.Thread.Sleep(5000);
                }

                bool thanks = await DisplayAlert("Thank you", "Thank you for completing the dead good deadwood survey! Feel free to complete more surveys", "OK", "Cancel");

                if (thanks || !thanks)
                {
                    await Navigation.PopToRootAsync();
                }
            }
        }
Пример #15
0
 bool IRemoteConnection.IsValid(ConnectionValidator validator)
 {
     return(this.Connection.IsValid(validator));
 }