/// <summary>
        /// Argument Constructor
        /// </summary>
        /// <param name="fetchData"></param>
        /// <param name="communicationController"></param>
        public MarketDataControler(FetchData fetchData, ICommunicationController communicationController)
        {
            try
            {
                Logger.SetLoggingLevel();

                // Initialize Lists
                _barSubscriptionList  = new List <string>();
                _tickSubscriptionList = new List <string>();

                _communicationController = communicationController;
                SubscribeRequiredEvents();
                FetchMarketData = fetchData;

                FetchMarketData.BarFired            += FetchMarketDataBarFired;
                FetchMarketData.TickFired           += FetchMarketDataTickFired;
                FetchMarketData.HistoricalDataFired += FetchMarketDataHistoricDataFired;

                EventSystem.Subscribe <string>(OnDataCompleted);
            }
            catch (Exception exception)
            {
                Logger.Error(exception, _type.FullName, "MarketDataControler");
            }
        }
示例#2
0
 public GameFacade(MainForm mainForm)
 {
     _communicationController = new WebSocketAdapter(this);
     _gameController          = new GameController(this);
     _keyController           = new KeyControllerConcreteSubject();
     _gameForm = new GameForm(this);
     _keyController.AttachForm(_gameForm);
     _keyController.Attach(_gameForm);
     _mainForm = mainForm;
     _keyController.Attach(_gameController);
 }
 /// <summary>
 /// Initializes a component.
 /// </summary>
 /// <param name="logMarshal">The <see cref="LogMarshal"/> provided by the <see cref="LogController"/>.</param>
 /// <param name="communicationController">The <see cref="ICommunicationController"/> used by this component to create <see cref="Networking.IClient"/>s.</param>
 /// <param name="logSourceId">The value used as the source id when creating log entries.</param>
 public void Initialize(LogMarshal logMarshal,
                        ICommunicationController communicationController,
                        string logSourceId)
 {
     _LogMarshal = logMarshal ?? throw new ArgumentNullException(nameof(logMarshal));
     _CommunicationController = communicationController ?? throw new ArgumentNullException(nameof(communicationController));
     if (string.IsNullOrWhiteSpace(logSourceId))
     {
         throw new ArgumentNullException(nameof(logSourceId));
     }
     _LogSourceId = logSourceId;
 }
示例#4
0
        void SetupLazyComs()
        {
            if (_explorerItemViewModel.IsFolder)
            {
                _lazyComs = new CommunicationController {
                    ServiceName = "DuplicateFolderService"
                };
                _lazyComs.AddPayloadArgument("FixRefs", FixReferences.ToString());
            }
            _lazyComs.AddPayloadArgument("NewResourceName", Name);

            if (!_explorerItemViewModel.IsFolder)
            {
                _lazyComs.AddPayloadArgument("ResourceID", _explorerItemViewModel.ResourceId.ToString());
            }

            _lazyComs.AddPayloadArgument("sourcePath", _explorerItemViewModel.ResourcePath);
            _lazyComs.AddPayloadArgument("destinationPath", Path);
        }
示例#5
0
        public void StartUp()
        {
            Logger.SetLoggingLevel();

            // Create Mocks
            _moqReadMarketData          = new Mock <IReadMarketData>();
            _moqCommunicationController = new Mock <ICommunicationController>();

            // Initialize dependency objects
            _communicationController = _moqCommunicationController.Object;
            _fetchData = new FetchData(_moqReadMarketData.Object);

            //// Initialize controllers
            //_marketDataControler = new MarketDataControler(_fetchData, _communicationController);
            //_simulatedOrderController = new SimulatedOrderController(_communicationController, _simulateMarketOrder,
            //                                                         _simulateLimitOrder);

            // Create sample bar data
            PopulateBarData();
        }
        /// <summary>
        /// Constructor:
        /// Hooks all the required Events of SimulateMarketOrder class and SimulateLimitOrderClass
        /// </summary>
        /// <param name="communicationController"> </param>
        /// <param name="simulateMarketOrder"></param>
        /// <param name="simulateLimitOrder"> </param>
        public SimulatedOrderController(ICommunicationController communicationController, SimulateMarketOrder simulateMarketOrder, SimulateLimitOrder simulateLimitOrder)
        {
            try
            {
                // Initialize Disruptor
                _tickDisruptor = new Disruptor.Dsl.Disruptor <Tick>(() => new Tick(), _ringSize, TaskScheduler.Default);
                // Add Consumer
                _tickDisruptor.HandleEventsWith(this);
                // Start Disruptor
                _tickRingBuffer = _tickDisruptor.Start();

                _communicationController = communicationController;
                _simulateLimitOrder      = simulateLimitOrder;
                _simulateMarketOrder     = simulateMarketOrder;

                //Initializing  ConcurrentQueue for bar.
                _barsQueue  = new ConcurrentQueue <Bar>();
                _ticksQueue = new ConcurrentQueue <Tick>();
                _blockingCollectionBarData  = new BlockingCollection <Bar>(_barsQueue);
                _blockingCollectionTickData = new BlockingCollection <Tick>(_ticksQueue);

                _simulateLimitOrder.LimitOrderRejection   += RejectionArrived;
                _simulateMarketOrder.MarketOrderRejection += RejectionArrived;
                _simulateLimitOrder.NewArrived            += SimulateLimitOrderNewArrived;
                _simulateLimitOrder.NewExecution          += SimulateLimitOrderNewExecution;
                _simulateMarketOrder.NewArrived           += SimulateMarketOrderNewArrived;
                _simulateMarketOrder.NewExecution         += SimulateMarketOrderNewExecution;

                EventSystem.Subscribe <Bar>(NewBarArrived);
                EventSystem.Subscribe <Tick>(NewTickArrived);
                EventSystem.Subscribe <int>(SetTickDataCount);

                HookAllRequiredEvents();
                //Task.Factory.StartNew(ReadBarFromQueue);
                //Task.Factory.StartNew(ReadTickFromQueue);
            }
            catch (Exception exception)
            {
                Logger.Error(exception, _type.FullName, "SimulatedOrderController");
            }
        }
示例#7
0
        IList <IPluginAction> GetPluginActions(IPluginSource source, INamespaceItem ns, ICommunicationController comsController, Dev2JsonSerializer serializer)
        {
            comsController.AddPayloadArgument(nameof(source), serializer.SerializeToBuilder(source));
            comsController.AddPayloadArgument("namespace", serializer.SerializeToBuilder(ns));
            var workspaceId = Connection.WorkspaceID;
            var result      = comsController.ExecuteCommand <ExecuteMessage>(Connection, workspaceId);

            if (result == null || result.HasError)
            {
                if (!Connection.IsConnected)
                {
                    ShowServerDisconnectedPopup();
                    return(new List <IPluginAction>());
                }
                if (result != null)
                {
                    throw new WarewolfSupportServiceException(result.Message.ToString(), null);
                }
                throw new WarewolfSupportServiceException(ErrorResource.ServiceDoesNotExist, null);
            }

            return(serializer.Deserialize <List <IPluginAction> >(result.Message.ToString()));
        }
示例#8
0
        private void CallDuplicateService()
        {
            ObservableCollection <IExplorerItemViewModel> childItems = null;

            try
            {
                IsDuplicating = true;

                if (_explorerItemViewModel.IsFolder)
                {
                    _lazyComs = new CommunicationController {
                        ServiceName = "DuplicateFolderService"
                    };
                    _lazyComs.AddPayloadArgument("FixRefs", FixReferences.ToString());
                }
                _lazyComs.AddPayloadArgument("NewResourceName", Name);

                if (!_explorerItemViewModel.IsFolder)
                {
                    _lazyComs.AddPayloadArgument("ResourceID", _explorerItemViewModel.ResourceId.ToString());
                }

                _lazyComs.AddPayloadArgument("sourcePath", _explorerItemViewModel.ResourcePath);
                _lazyComs.AddPayloadArgument("destinationPath", Path);

                var executeCommand = _lazyComs.ExecuteCommand <ResourceCatalogDuplicateResult>(_lazyCon ?? ServerRepository.Instance.ActiveServer?.Connection, GlobalConstants.ServerWorkspaceID);
                if (executeCommand == null)
                {
                    var environmentViewModel = SingleEnvironmentExplorerViewModel.Environments.FirstOrDefault();
                    environmentViewModel?.RefreshCommand.Execute(null);
                    CloseView();
                    ViewResult = MessageBoxResult.OK;
                }
                else
                {
                    if (executeCommand.Status == ExecStatus.Success)
                    {
                        var duplicatedItems      = executeCommand.DuplicatedItems;
                        var environmentViewModel = SingleEnvironmentExplorerViewModel.Environments.FirstOrDefault();
                        var parentItem           = SelectedItem ?? _explorerItemViewModel.Parent;
                        childItems = environmentViewModel?.CreateExplorerItemModels(duplicatedItems, _explorerItemViewModel.Server, parentItem, false, false);
                        var explorerItemViewModels = parentItem.Children;
                        explorerItemViewModels.AddRange(childItems);
                        parentItem.Children = explorerItemViewModels;
                        CloseView();
                        ViewResult = MessageBoxResult.OK;
                    }
                    else
                    {
                        ErrorMessage = executeCommand.Message;
                    }
                }
            }
            catch (Exception)
            {
                //
            }
            finally
            {
                ConnectControlSingleton.Instance.ReloadServer();

                if (childItems != null)
                {
                    foreach (var childItem in childItems.Where(model => model.ResourceType == "Dev2Server"))
                    {
                        FireServerSaved(childItem.ResourceId);
                    }
                }

                IsDuplicating = false;
            }
        }