private void LoadTree(AdapterConfiguration a)
        {
            List <Control> tempList = new List <Control>();

            foreach (var p in a.Plugins.Plugins)
            {
                if (p is ISessionable)
                {
                    RadioButton b = new RadioButton()
                    {
                        Text = p.Name,
                        Tag  = p,
                        Dock = DockStyle.Top
                    };
                    b.BringToFront();
                    b.CheckedChanged += OnCheckedChanged;

                    placeHolder.Controls.Add(b);
                    tempList.Add(b);

                    var option = new PluginOptions();
                    option.ModeSelectionEnabled = false;

                    _sessionFiles[p] = option;
                }
            }

            foreach (var c in tempList)
            {
                c.BringToFront();
            }
        }
コード例 #2
0
        static async Task Main(string[] args)
        {
            var builder = new ConfigurationBuilder()
                          .SetBasePath(Directory.GetCurrentDirectory())
                          .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);

            IConfigurationRoot configuration = builder.Build();

            var adapterConfiguration = new AdapterConfiguration();

            configuration.Bind("AdapterConfiguration", adapterConfiguration);

            var applicationConfiguration = new ApplicationConfiguration();

            configuration.Bind("ApplicationConfiguration", applicationConfiguration);

            var serviceProvider = new ServiceCollection()
                                  .AddAdapter(adapterConfiguration)
                                  .AddApplication(applicationConfiguration)
                                  .AddSingleton <ISubscriberService, SubscriberService>()
                                  .AddSingleton <IGooglePubSubAdapter, GooglePubSubAdapter>()
                                  .AddLogging()
                                  .BuildServiceProvider();

            try
            {
                var topicName         = new TopicName(applicationConfiguration.ProjectId, applicationConfiguration.TopicId);
                var subscriberService = (ISubscriberService)serviceProvider.GetService(typeof(ISubscriberService));
                await subscriberService.ShowMessagesForSubscriptionAsync(topicName, applicationConfiguration.ProjectId, applicationConfiguration.SubscriptionId);
            }
            catch (Exception e)
            {
                Console.WriteLine("Something went wrong: {0}", e.Message);
            }
        }
コード例 #3
0
        public ScheduledPropertyPage(AdapterConfiguration adapterConfiguration)
        {
            this.adapterConfiguration = adapterConfiguration;
            InitializeComponent();

            //Schedule tab defaults
            this.checkSuspendMessage.Checked = false;
            this.radioDayofMonth.Checked     = true;
            this.radioDayInterval.Checked    = true;
            //DateTime now = DateTime.Now;
            DateTime now = DateTime.UtcNow;

            this.dateStartDate.Value      = new DateTime(now.Year, now.Month, now.Day, 0, 0, 0);
            this.dateStartTime.Value      = new DateTime(now.Year, now.Month, now.Day, 0, 0, 0);
            this.updownTimeInterval.Value = 1;
            //this.radioEveryDayTSP.Visible = true;
            //this.radioEveryDayTSP.Checked = true;
            this.comboScheduleType.Items.AddRange(new object[] { ScheduleType.TimeSpan, ScheduleType.Daily, ScheduleType.Weekly, ScheduleType.Monthly });
            this.comboScheduleType.SelectedItem = ScheduleType.TimeSpan;
            this.comboTimeUnits.Items.AddRange(new object[] { ScheduleTimeUnit.Seconds, ScheduleTimeUnit.Minutes, ScheduleTimeUnit.Hours });
            this.comboTimeUnits.SelectedItem = ScheduleTimeUnit.Hours;
            this.comboOrdinal.Items.AddRange(new object[] { ScheduleOrdinal.First, ScheduleOrdinal.Second, ScheduleOrdinal.Third, ScheduleOrdinal.Fourth, ScheduleOrdinal.Last });
            this.comboWeekday.Items.AddRange(new object[] { ScheduleDay.Sunday, ScheduleDay.Monday, ScheduleDay.Tuesday, ScheduleDay.Wednesday, ScheduleDay.Thursday, ScheduleDay.Friday, ScheduleDay.Saturday, ScheduleDay.Weekday, ScheduleDay.Day });

            this.Load += ScheduledPropertyPage_OnLoad;
        }
コード例 #4
0
 private static Specifier GetSpecifier(long marketId, string stringValue, AdapterConfiguration adapterConfiguration)
 {
     return(new Specifier(
                adapterConfiguration.Specifiers.Total.Contains(marketId) ? SpecifierKey.Total
                         : adapterConfiguration.Specifiers.Pointnr.Contains(marketId) ? SpecifierKey.PointNumber : SpecifierKey.Handicap,
                stringValue
                ));
 }
コード例 #5
0
        private void LoadTree(AdapterConfiguration a)
        {
            TreeNode node = new TreeNode("adapter");

            node.Tag = a;

            treeView.Nodes.Add(node);

            TreeNode logging = new TreeNode(a.Logging.Name)
            {
                Tag = a.Logging
            };

            node.Nodes.Add(logging);

            TreeNode plugins = new TreeNode(a.Plugins.Name)
            {
                Tag = a.Plugins
            };

            node.Nodes.Add(plugins);

            foreach (var p in a.Plugins.Plugins)
            {
                if (p is ISessionable)
                {
                    var pNode = new TreeNode(p.Name)
                    {
                        Tag = p
                    };

                    var option = new PluginOptions();

                    if (p.Name.StartsWith("goose"))
                    {
                        option.ModeSelectionEnabled = false;
                    }

                    _sessionFiles[p] = option;

                    plugins.Nodes.Add(pNode);
                }
                else
                {
                    var pNode = new TreeNode(p.Name)
                    {
                        Tag       = p,
                        ForeColor = Color.Gray
                    };
                    plugins.Nodes.Add(pNode);
                }
            }

            treeView.ExpandAll();
        }
コード例 #6
0
        static void Main(string[] args)
        {
            var builder = new ConfigurationBuilder()
                          .SetBasePath(Directory.GetCurrentDirectory())
                          .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);

            IConfigurationRoot configuration = builder.Build();

            var adapterConfiguration = new AdapterConfiguration();

            configuration.Bind("AdapterConfiguration", adapterConfiguration);

            var applicationConfiguration = new ApplicationConfiguration();

            configuration.Bind("ApplicationConfiguration", applicationConfiguration);

            var serviceProvider = new ServiceCollection()
                                  .AddAdapter(adapterConfiguration)
                                  .AddApplication(applicationConfiguration)
                                  .AddSingleton <IPublishService, PublishService>()
                                  .AddSingleton <IGooglePubSubAdapter, GooglePubSubAdapter>()
                                  .AddLogging()
                                  .BuildServiceProvider();

            var publishMessage = new PublishMessage
            {
                Message           = "Teste",
                ProjectId         = applicationConfiguration.ProjectId,
                TopicId           = applicationConfiguration.TopicId,
                ServiceCollection = serviceProvider
            };

            timer = new Timer(
                callback: new TimerCallback(TimerTaskAsync),
                state: publishMessage as PublishMessage,
                dueTime: 1000,
                period: 2000);

            while (publishMessage.Counter <= 10)
            {
                Task.Delay(1000).Wait();
            }

            timer.Dispose();
            Console.WriteLine($"{DateTime.Now:HH:mm:ss.fff}: done.");
        }
コード例 #7
0
        protected override void CoreInitialize()
        {
            AdapterConfiguration <DelimitedTextAdapterConfiguration> sourceAdapterConfiguration;
            DelimitedTextSpec effectiveDelimitedTextSpec;

            if (DataTypeFascade.Instance.IsNullOrWhiteSpace(this.AdapterConfiguration.AdapterSpecificConfiguration.DelimitedTextFilePath))
            {
                throw new InvalidOperationException(string.Format("Configuration missing: '{0}'.", "DestinationAdapterConfiguration.DelimitedTextAdapterConfiguration.DelimitedTextFilePath"));
            }

            sourceAdapterConfiguration = new AdapterConfiguration <DelimitedTextAdapterConfiguration>(((ObfuscationConfiguration)this.AdapterConfiguration.Parent).SourceAdapterConfiguration);

            if ((object)this.AdapterConfiguration.AdapterSpecificConfiguration.DelimitedTextSpec == null &&
                ((object)sourceAdapterConfiguration == null ||
                 (object)sourceAdapterConfiguration.AdapterSpecificConfiguration.DelimitedTextSpec == null))
            {
                throw new InvalidOperationException(string.Format("Configuration missing: '{0}'.", "[Source/Destination]...DelimitedTextSpec"));
            }

            if ((object)this.AdapterConfiguration.AdapterSpecificConfiguration.DelimitedTextSpec != null)
            {
                effectiveDelimitedTextSpec = this.AdapterConfiguration.AdapterSpecificConfiguration.DelimitedTextSpec;

                if (effectiveDelimitedTextSpec.HeaderSpecs.Count <= 0 &&
                    (object)sourceAdapterConfiguration != null &&
                    (object)sourceAdapterConfiguration.AdapterSpecificConfiguration.DelimitedTextSpec.HeaderSpecs != null)
                {
                    effectiveDelimitedTextSpec.HeaderSpecs.AddRange(sourceAdapterConfiguration.AdapterSpecificConfiguration.DelimitedTextSpec.HeaderSpecs);
                }
            }
            else
            {
                effectiveDelimitedTextSpec = this.AdapterConfiguration.AdapterSpecificConfiguration.DelimitedTextSpec;
            }

            if ((object)effectiveDelimitedTextSpec == null ||
                effectiveDelimitedTextSpec.HeaderSpecs.Count <= 0)
            {
                throw new InvalidOperationException(string.Format("Configuration missing: '{0}'.", "[Source/Destination]...DelimitedTextSpec.HeaderSpecs"));
            }

            this.DelimitedTextWriter = new DelimitedTextWriter(new StreamWriter(File.Open(this.AdapterConfiguration.AdapterSpecificConfiguration.DelimitedTextFilePath, FileMode.Create, FileAccess.Write, FileShare.None)), effectiveDelimitedTextSpec);
        }
コード例 #8
0
        public TransmitterCommandsFactory(
            AdapterConfiguration adapterConfiguration,

            IDataEventAdapter dataEventAdapter,
            IMarketEventAdapter marketEventAdapter,
            ITranslationAdapter translationAdapter,
            IBetStartEventAdapter betStartEventAdapter,
            IBetStopEventAdapter betStopEventAdapter,
            IPingMessageAdapter pingMessageAdapter
            )
        {
            this.adapterConfiguration = adapterConfiguration;
            this.dataEventAdapter     = dataEventAdapter;
            this.marketEventAdapter   = marketEventAdapter;
            this.translationAdapter   = translationAdapter;
            this.betStartEventAdapter = betStartEventAdapter;
            this.betStopEventAdapter  = betStopEventAdapter;
            this.pingMessageAdapter   = pingMessageAdapter;
        }
コード例 #9
0
        public MarketEventAdapter(
            AdapterConfiguration adapterConfiguration,
            ILogger <MarketEventAdapter> logger
            )
        {
            this.adapterConfiguration = adapterConfiguration;
            this.logger = logger;

            var arr = adapterConfiguration.OutcomeMapping
                      .SelectMany(t => t.Values.Select(y => new { key = y, value = t.GroupId })).ToArray();

            // Checking
            var badItem = arr.GroupBy(t => t.key).FirstOrDefault(t => t.Count() > 1)?.ToArray();

            if (badItem != null)
            {
                throw new Exception($"Invalid configuration is detected. OutcomeMapping parameter has dublicated id {badItem[0].key} in groups {badItem[0].value} and {badItem[1].value}.");
            }

            marketGroups = arr.ToDictionary(k => k.key, v => v.value);
        }
コード例 #10
0
        public IEnumerable <Message> ValidateAdapterSpecificConfiguration(AdapterConfiguration adapterConfiguration, string adapterContext)
        {
            AdapterConfiguration <TAdapterSpecificConfiguration> _adapterConfiguration;

            if ((object)adapterConfiguration == null)
            {
                throw new ArgumentNullException("adapterConfiguration");
            }

            if ((object)adapterConfiguration.AdapterSpecificConfiguration == null)
            {
                throw new InvalidOperationException(string.Format("Configuration missing: '{0}'.", "AdapterSpecificConfiguration"));
            }

            _adapterConfiguration = new AdapterConfiguration <TAdapterSpecificConfiguration>(adapterConfiguration);

            if ((object)_adapterConfiguration.AdapterSpecificConfiguration == null)
            {
                throw new InvalidOperationException(string.Format("Configuration missing: '{0}'.", "AdapterSpecificConfiguration"));
            }

            return(_adapterConfiguration.AdapterSpecificConfiguration.Validate(adapterContext));
        }
コード例 #11
0
        public void Initialize(AdapterConfiguration adapterConfiguration)
        {
            AdapterConfiguration <TAdapterSpecificConfiguration> _adapterConfiguration;

            if ((object)adapterConfiguration == null)
            {
                throw new ArgumentNullException("adapterConfiguration");
            }

            if ((object)adapterConfiguration.AdapterSpecificConfiguration == null)
            {
                throw new InvalidOperationException(string.Format("Configuration missing: '{0}'.", "AdapterSpecificConfiguration"));
            }

            _adapterConfiguration = new AdapterConfiguration <TAdapterSpecificConfiguration>(adapterConfiguration);

            if ((object)_adapterConfiguration.AdapterSpecificConfiguration == null)
            {
                throw new InvalidOperationException(string.Format("Configuration missing: '{0}'.", "AdapterSpecificConfiguration"));
            }

            this.AdapterConfiguration = _adapterConfiguration;
            this.CoreInitialize();
        }
        public void LoadConfiguration(string filePath, ConfigFileType?type = null)
        {
            if (type == null)
            {
                type = GetFileType(filePath);
            }

            if (type == ConfigFileType.MainAdapter)
            {
                AdapterConfiguration config = new AdapterConfiguration();
                config.Load(filePath);

                foreach (var p in config.Plugins.Plugins)
                {
                    ISessionable s = p as ISessionable;
                    if (s != null)
                    {
                        foreach (var session in s.Sessions)
                        {
                            var path = session.LocalFilePath;
                            var temp = Path.Combine(WorkingDirectory, path.TrimStart(new char[] { '\\', '/' }));
                            session.SessionConfiguration.Load(temp);
                        }
                    }
                }
                ActiveConfiguration = config;
            }
            else if (type == ConfigFileType.Template)
            {
                var relative = FileHelper.MakeRelativePath(WorkingDirectory, filePath);
                var session  = Session.FromFile(WorkingDirectory, relative);
                session.Name = relative;

                ActiveConfiguration = session;
            }
        }
コード例 #13
0
        public static IServiceCollection AddAdapter(this IServiceCollection services, AdapterConfiguration adapterConfiguration)
        {
            if (services == null)
            {
                throw new ArgumentNullException(nameof(services));
            }

            if (adapterConfiguration == null)
            {
                throw new ArgumentNullException(nameof(adapterConfiguration));
            }

            // Registra a instancia do objeto de configuracoes desta camanda.
            services.AddSingleton(adapterConfiguration);


            // Registra a implementacao do IGooglePubSubAdapter para ser utilizado na camada de aplicacao.
            services.AddScoped <IGooglePubSubAdapter, GooglePubSubAdapter>();

            return(services);
        }
コード例 #14
0
        public AdapterDataFlow(
            ILogger <AdapterDataFlow> logger,
            IMessageDumper messageDumper,
            ITransmitterAdapterHost transmitterHost,
            TranslationSubscriptionCollection subscriptions,
            ITransmitterCommandsFactory transmitterCommandsFactory,
            AdapterConfiguration adapterConfiguration
            )
        {
            this.logger                     = logger;
            this.messageDumper              = messageDumper;
            this.transmitterHost            = transmitterHost;
            this.subscriptions              = subscriptions;
            this.transmitterCommandsFactory = transmitterCommandsFactory;
            this.adapterConfiguration       = adapterConfiguration;

            // Flow 1-1
            translationCheckBlock
                = new TransformManyBlock <MessageContext <Translation>,
                                          MessageContext <Translation> >(
                      TranslationCheckHandler,
                      new ExecutionDataflowBlockOptions()
            {
                MaxDegreeOfParallelism = maxDegreeOfParallelism
            }
                      );

            // Flow 1-2
            eventMessageTransformBlock
                = new TransformManyBlock <MessageContext <EventsMessage>,
                                          MessageContext <EventData, TranslationSubscription> >(
                      EventMessageTransformHandler,
                      new ExecutionDataflowBlockOptions()
            {
                MaxDegreeOfParallelism = maxDegreeOfParallelism
            }
                      );

            // Flow 2-1
            translationCreateCommandBlock
                = new TransformManyBlock <MessageContext <Translation>,
                                          MessageContext <ITransmitterCommand, string> >(
                      TranslationCreateCommandHandler,
                      new ExecutionDataflowBlockOptions()
            {
                MaxDegreeOfParallelism = maxDegreeOfParallelism
            }
                      );

            // Flow 2-2
            eventDataCreateCommandBlock
                = new TransformManyBlock <MessageContext <EventData, TranslationSubscription>,
                                          MessageContext <ITransmitterCommand, string> >(
                      EventDataCreateCommandHandler,
                      new ExecutionDataflowBlockOptions()
            {
                MaxDegreeOfParallelism = maxDegreeOfParallelism
            }
                      );

            // Flow 2-3
            pingMessageCreateCommandBlock
                = new TransformManyBlock <MessageContext <PingMessage>,
                                          MessageContext <ITransmitterCommand, string> >(
                      PingMessageCreateCommandHandler,
                      new ExecutionDataflowBlockOptions()
            {
                MaxDegreeOfParallelism = maxDegreeOfParallelism
            }
                      );

            // Flow 3
            sendCommandBlock
                = new TransformManyBlock <MessageContext <ITransmitterCommand, string>,
                                          MessageContext <ITransmitterCommand, string> > (
                      SendCommandHandler,
                      new ExecutionDataflowBlockOptions()
            {
                MaxDegreeOfParallelism = maxDegreeOfParallelism
            }
                      );

            // Flow 3
            writeDumpBlock
                = new ActionBlock <MessageContext <ITransmitterCommand, string> >(
                      WriteDumpHandler,
                      new ExecutionDataflowBlockOptions()
            {
                MaxDegreeOfParallelism = maxDegreeOfParallelism
            }
                      );

            translationCheckBlock.LinkTo(translationCreateCommandBlock);
            eventMessageTransformBlock.LinkTo(eventDataCreateCommandBlock);

            translationCreateCommandBlock.LinkTo(sendCommandBlock);
            eventDataCreateCommandBlock.LinkTo(sendCommandBlock);
            pingMessageCreateCommandBlock.LinkTo(sendCommandBlock);

            sendCommandBlock.LinkTo(writeDumpBlock);
        }
コード例 #15
0
        public AdapterDataFlow(
            ILogger <AdapterDataFlow> logger,
            IMessageDumper messageDumper,
            ITransmitterAdapterHost transmitterHost,
            TranslationSubscriptionCollection subscriptions,
            ITransmitterCommandsFactory transmitterCommandsFactory,
            AdapterConfiguration adapterConfiguration
            )
        {
            this.logger                     = logger;
            this.messageDumper              = messageDumper;
            this.transmitterHost            = transmitterHost;
            this.subscriptions              = subscriptions;
            this.transmitterCommandsFactory = transmitterCommandsFactory;
            this.adapterConfiguration       = adapterConfiguration;

            // Flow 1-1
            adaptApiMessageBlock
                = new TransformManyBlock <MessageContext <ApiResponseParsed>, MessageContext <AdaptMessage> >(
                      AdaptApiMessageHandler,
                      new ExecutionDataflowBlockOptions()
            {
                MaxDegreeOfParallelism = maxDegreeOfParallelism
            }
                      );

            // Flow 1-2
            adaptFeedMessageBlock
                = new TransformManyBlock <MessageContext <FeedMessageReady>, MessageContext <AdaptMessage> >(
                      AdaptFeedMessageHandler,
                      new ExecutionDataflowBlockOptions()
            {
                MaxDegreeOfParallelism = maxDegreeOfParallelism
            }
                      );

            // Flow 2
            createTransmitterCommandsBlock = new TransformManyBlock <MessageContext <AdaptMessage>, MessageContext <ITransmitterCommand> >(
                CreateTransmitterCommandsHandler,
                new ExecutionDataflowBlockOptions()
            {
                MaxDegreeOfParallelism = maxDegreeOfParallelism
            }
                );


            // Flow 3
            broadcastTransmitterCommandBlock = new BroadcastBlock <MessageContext <ITransmitterCommand> >(t => t);

            // Flow 4-1
            sendCommandBlock
                = new ActionBlock <MessageContext <ITransmitterCommand> > (
                      SendCommandHandler,
                      new ExecutionDataflowBlockOptions()
            {
                MaxDegreeOfParallelism = maxDegreeOfParallelism
            }
                      );

            // Flow 4-2
            writeDumpBlock
                = new ActionBlock <MessageContext <ITransmitterCommand> >(
                      WriteDumpHandler,
                      new ExecutionDataflowBlockOptions()
            {
                MaxDegreeOfParallelism = maxDegreeOfParallelism
            }
                      );

            adaptApiMessageBlock.LinkTo(createTransmitterCommandsBlock);
            adaptFeedMessageBlock.LinkTo(createTransmitterCommandsBlock);

            createTransmitterCommandsBlock.LinkTo(broadcastTransmitterCommandBlock);

            broadcastTransmitterCommandBlock.LinkTo(sendCommandBlock);
            broadcastTransmitterCommandBlock.LinkTo(writeDumpBlock);
        }
コード例 #16
0
        public static IProviderBuilder AddTransmitterAdapter(this IProviderBuilder providerBuilder, AdapterConfiguration adapterConfiguration)
        {
            providerBuilder.ServiceCollection
            // Adapter
            .AddBetRadarTransmitterAdapter()
            .AddSingleton(adapterConfiguration)                                     // Перепилить на Options
            ;

            return(providerBuilder);
        }
コード例 #17
0
 public AzureStorageAdapter(SyncRelationship relationship, AdapterConfiguration configuration)
     : base(relationship, configuration)
 {
 }
コード例 #18
0
 public RestoreOnlyWindowsFileSystemAdapter(
     SyncRelationship relationship,
     AdapterConfiguration configuration)
     : base(relationship, configuration)
 {
 }
コード例 #19
0
        public static void Init(string version = null)
        {
            _logger.Log(Level.Info, "Initialize schema manager...");
            var appDataDir = FileHelper.GetAppDataFolder();

            Directory.CreateDirectory(Path.Combine(appDataDir, SchemaDirectory));

            DefaultSchemaDirectory = Path.Combine(appDataDir, SchemaDirectory);

            if (!string.IsNullOrWhiteSpace(version))
            {
                DefaultVersion = version;
            }

            Directory.CreateDirectory(Path.Combine(DefaultSchemaDirectory, DefaultVersion));

            var versions = Directory.GetDirectories(DefaultSchemaDirectory);

            var assembly      = Assembly.GetAssembly(typeof(SchemaManager));
            var adapterConfig = new AdapterConfiguration();

            foreach (var v in versions)
            {
                Schema sm = new Schema(v);

                _schema[sm.Version] = sm;

                foreach (var p in adapterConfig.Plugins.Plugins)
                {
                    var resourceName = $"{typeof(SchemaManager).Namespace}.{p.Name}.json";

                    var local = Path.Combine(v, $"{p.Name}.json");

                    try
                    {
                        if (!File.Exists(local))
                        {
                            if (sm.Version.Equals(DefaultVersion, StringComparison.InvariantCultureIgnoreCase))
                            {
                                using (Stream stream = assembly.GetManifestResourceStream(resourceName))
                                {
                                    if (stream != null)
                                    {
                                        using (StreamReader reader = new StreamReader(stream))
                                        {
                                            var template = reader.ReadToEnd();
                                            File.WriteAllText(local, template);
                                        }
                                    }
                                }
                            }
                        }

                        if (File.Exists(local))
                        {
                            _logger.Log(Level.Info, $"Loading schema for {p.Name}");

                            using (StreamReader reader = new StreamReader(local))
                            {
                                var template = reader.ReadToEnd();

                                var schema = JSchema.Parse(template);

                                sm.AddSchema(p.Name, schema);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        _logger.Log(Level.Error, ex.Message, ex);
                    }
                }
            }

            ParseOpenFMBDocument("OpenFMB.Models.xml");
        }