Esempio n. 1
0
        public AddInHost(ICadExtensionApplication app, IInitiator initiator)
        {
            m_App = app;

            m_Initiator = initiator;

            try
            {
                m_Initiator.Init(this);

                Extension = m_App.Extension;

                m_RegisteredCommands = new List <Tuple <EnumCommandGroupSpec, Delegate> >();
                m_Handlers           = new Dictionary <CommandSpec, Tuple <Delegate, Enum> >();

                Extension.StartupCompleted += OnStartupCompleted;
                Extension.Connect          += OnExtensionConnect;
                Extension.Disconnect       += OnExtensionDisconnect;
                if (Extension is IXServiceConsumer)
                {
                    (Extension as IXServiceConsumer).ConfigureServices += OnConfigureExtensionServices;
                }

                m_ModulesLoader = new ModulesLoader();
                m_Modules       = m_ModulesLoader.Load(this, app.GetType());
            }
            catch (Exception ex)
            {
                new GenericMessageService("CAD+").ShowError(ex, "Failed to init add-in");
                new AppLogger().Log(ex);
                throw;
            }
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            Directory.SetCurrentDirectory(Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName));
            var mode = args.FirstOrDefault();

            Serilog.Log.Logger = new LoggerConfiguration()
                                 .Enrich.FromLogContext()
                                 .WriteTo.Console()
                                 .WriteTo.File($"logs/{mode}-.log", rollingInterval: RollingInterval.Day)
                                 .CreateLogger();

            IInitiator initiator = null;
            IAcceptor  acceptor  = null;

            if (mode == "client")
            {
                var clientSettings = new SessionSettings("client.cfg");
                initiator = new SocketInitiator(new ClientApp(100_000), new MemoryStoreFactory(), clientSettings, new FileLogFactory(clientSettings), new MessageFactory());
                initiator.Start();
            }
            else
            {
                var serverSettings = new SessionSettings("server.cfg");
                acceptor = new ThreadedSocketAcceptor(new ServerApp(), new MemoryStoreFactory(), serverSettings, new FileLogFactory(serverSettings), new MessageFactory());
                acceptor.Start();
            }

            Console.ReadLine();
            Console.WriteLine("Bye");

            initiator?.Stop(true);
            acceptor?.Stop(true);
        }
Esempio n. 3
0
        public virtual void Connect()
        {
            if (this.isConnected)
            {
                return;
            }
            if (!this.isInitiated)
            {
                this.Init();
                switch (this.InitiatorMode)
                {
                case InitiatorMode.Single:
                    this.initiator = !this.loggingEnabled ? new SocketInitiator(this.application, this.storeFactory, this.sessionSettings, this.messageFactory) : new SocketInitiator(this.application, this.storeFactory, this.sessionSettings, this.logFactory, this.messageFactory);
                    break;

                case InitiatorMode.Threaded:
                    this.initiator = !this.loggingEnabled ? new ThreadedSocketInitiator(this.application, this.storeFactory, this.sessionSettings, this.messageFactory) : new ThreadedSocketInitiator(this.application, this.storeFactory, this.sessionSettings, this.logFactory, this.messageFactory);
                    break;
                }
                this.initiator.start();
                this.isInitiated                     = true;
                this.application.Logon              += new FIXLogonEventHandler(this.H3T4F4ZJZW);
                this.application.Logout             += new FIXLogoutEventHandler(this.L0C4OEBGEG);
                this.application.SecurityDefinition += new FIXSecurityDefinitionEventHandler(this.lB74tX1KNj);
                this.application.MarketDataSnapshot += new FIXMarketDataSnapshotEventHandler(this.ST74ZxO7ZP);
                this.application.ExecutionReport    += new ExecutionReportEventHandler(this.LpP4CCeYG5);
                this.application.OrderCancelReject  += new OrderCancelRejectEventHandler(this.aNk4mHq3DK);
            }
            this.application.Connect();
        }
Esempio n. 4
0
        public virtual void Connect()
        {
            if (this.isConnected)
            {
                return;
            }
            if (!this.isInitiated)
            {
                this.Init();
                switch (this.InitiatorMode)
                {
                case InitiatorMode.Single:
                    this.iTjfR0QTM = !this.loggingEnabled ? (Initiator) new SocketInitiator((Application)this.application, this.storeFactory, this.sessionSettings, this.messageFactory) : (Initiator) new SocketInitiator((Application)this.application, this.storeFactory, this.sessionSettings, this.logFactory, this.messageFactory);
                    break;

                case InitiatorMode.Threaded:
                    this.iTjfR0QTM = !this.loggingEnabled ? (Initiator) new ThreadedSocketInitiator((Application)this.application, this.storeFactory, this.sessionSettings, this.messageFactory) : (Initiator) new ThreadedSocketInitiator((Application)this.application, this.storeFactory, this.sessionSettings, this.logFactory, this.messageFactory);
                    break;
                }
                this.iTjfR0QTM.start();
                this.isInitiated                     = true;
                this.application.Logon              += new FIXLogonEventHandler(this.CPQrwXYoJ);
                this.application.Logout             += new FIXLogoutEventHandler(this.qKXl1YwC8);
                this.application.SecurityDefinition += new FIXSecurityDefinitionEventHandler(this.BbGIo0Hmp);
                this.application.MarketDataSnapshot += new FIXMarketDataSnapshotEventHandler(this.hvUXgZCyf);
                this.application.ExecutionReport    += new ExecutionReportEventHandler(this.pQ0g8arCK);
                this.application.OrderCancelReject  += new OrderCancelRejectEventHandler(this.Q4TGKECr3);
            }
            this.application.Connect();
        }
Esempio n. 5
0
        /// <summary>
        /// InitializSession
        /// </summary>
        public Task Initialize(Action <string> progress, CancellationToken cancellationToken)
        {
            return(Task.Run(() =>

            {
                var settings = new SessionSettings("cts.cfg");

                IMessageStoreFactory messageFactory = new FileStoreFactory(settings);

                ILogFactory logFactory = new FileLogFactory(settings);

                initiator = new SocketInitiator(this, messageFactory, settings, logFactory);

                progress("Initialization done");
            }, cancellationToken));
        }
        public bool Start()
        {
            try
            {
                if (this._initiator == null)
                {
                    SessionSettings      settings       = new SessionSettings(this._fixSettingsFile);
                    IApplication         application    = this;
                    FileStoreFactory     storeFactory   = new FileStoreFactory(settings);
                    FileLogFactory       logFactory     = new FileLogFactory(settings);
                    IMessageStoreFactory messageFactory = new FileStoreFactory(settings);

                    this._initiator = new QuickFix.Transport.SocketInitiator(application, storeFactory, settings, logFactory);
                    this._initiator.Start();

                    if (Logger.IsInfoEnabled)
                    {
                        Logger.Info("Fix Order Client Started.", _type.FullName, "Start");
                    }
                }
                else
                {
                    if (!this._initiator.IsStopped)
                    {
                        if (Logger.IsInfoEnabled)
                        {
                            Logger.Info("Fix Order Client Already Started.", _type.FullName, "Start");
                        }
                    }
                    else
                    {
                        this._initiator.Start();
                        if (Logger.IsInfoEnabled)
                        {
                            Logger.Info("Fix Order Client Started.", _type.FullName, "Start");
                        }
                    }
                }

                return(true);
            }
            catch (Exception exception)
            {
                Logger.Error(exception.ToString(), _type.FullName, "Start");
            }
            return(false);
        }
Esempio n. 7
0
        public Boolean Load(string sectionName = "ModConfigSection")
        {
            bool result = false;

            //!TODO cleaning of private variables, making it ready for loading, removing old loaded instances
            typeFactory.DeepSearch = true;
            typeFactory.LoadPreloadedAssemblies();

            System.Configuration.Configuration configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
            ModConfigSection section = configuration.GetSection(sectionName) as ModConfigSection;

            configuration.SaveAs(".\\somewhere\\external.xml", ConfigurationSaveMode.Full, true);

            if (section != null)
            {
                pluginsLoaded = LoadPlugins(section.PluginCollection);
                if (pluginsLoaded)
                {
                    modulesLoaded = LoadModules(section.ModuleConfigCollection, 0);
                    if (modulesLoaded)
                    {
                        for (int i = 0; i < modules.Count; i++)
                        {
                            IInitiator initiator = modules[i].Instance as IInitiator;
                            if (initiator != null)
                            {
                                if ((initiator.Initialize() == false) && !initiator.IsInitialized)
                                {
                                    throw new ConfigurationErrorsException("Couldn't load " + modules[i].Type);
                                }
                            }
                        }
                        result = true;
                    }
                }
            }
            return(result);
        }
Esempio n. 8
0
 public static bool IsLoggedOn(this IInitiator init)
 {
     return(init.IsLoggedOn);
 }
Esempio n. 9
0
		public virtual void Connect()
		{
			if (this.isConnected)
				return;
			if (!this.isInitiated)
			{
				this.Init();
				switch (this.InitiatorMode)
				{
					case InitiatorMode.Single:
						this.initiator = !this.loggingEnabled ? new SocketInitiator(this.application, this.storeFactory, this.sessionSettings, this.messageFactory) : new SocketInitiator(this.application, this.storeFactory, this.sessionSettings, this.logFactory, this.messageFactory);
						break;
					case InitiatorMode.Threaded:
						this.initiator = !this.loggingEnabled ? new ThreadedSocketInitiator(this.application, this.storeFactory, this.sessionSettings, this.messageFactory) : new ThreadedSocketInitiator(this.application, this.storeFactory, this.sessionSettings, this.logFactory, this.messageFactory);
						break;
				}
				this.initiator.start();
				this.isInitiated = true;
				this.application.Logon += new FIXLogonEventHandler(this.H3T4F4ZJZW);
				this.application.Logout += new FIXLogoutEventHandler(this.L0C4OEBGEG);
				this.application.SecurityDefinition += new FIXSecurityDefinitionEventHandler(this.lB74tX1KNj);
				this.application.MarketDataSnapshot += new FIXMarketDataSnapshotEventHandler(this.ST74ZxO7ZP);
				this.application.ExecutionReport += new ExecutionReportEventHandler(this.LpP4CCeYG5);
				this.application.OrderCancelReject += new OrderCancelRejectEventHandler(this.aNk4mHq3DK);
			}
			this.application.Connect();
		}
Esempio n. 10
0
 public InitiatorControl(QuickFix.IInitiator initiator)
 {
     _initiator = initiator;
 }
Esempio n. 11
0
		public virtual void Connect()
		{
			if (this.isConnected)
				return;
			if (!this.isInitiated)
			{
				this.Init();
				switch (this.InitiatorMode)
				{
					case InitiatorMode.Single:
						this.iTjfR0QTM = !this.loggingEnabled ? (Initiator)new SocketInitiator((Application)this.application, this.storeFactory, this.sessionSettings, this.messageFactory) : (Initiator)new SocketInitiator((Application)this.application, this.storeFactory, this.sessionSettings, this.logFactory, this.messageFactory);
						break;
					case InitiatorMode.Threaded:
						this.iTjfR0QTM = !this.loggingEnabled ? (Initiator)new ThreadedSocketInitiator((Application)this.application, this.storeFactory, this.sessionSettings, this.messageFactory) : (Initiator)new ThreadedSocketInitiator((Application)this.application, this.storeFactory, this.sessionSettings, this.logFactory, this.messageFactory);
						break;
				}
				this.iTjfR0QTM.start();
				this.isInitiated = true;
				this.application.Logon += new FIXLogonEventHandler(this.CPQrwXYoJ);
				this.application.Logout += new FIXLogoutEventHandler(this.qKXl1YwC8);
				this.application.SecurityDefinition += new FIXSecurityDefinitionEventHandler(this.BbGIo0Hmp);
				this.application.MarketDataSnapshot += new FIXMarketDataSnapshotEventHandler(this.hvUXgZCyf);
				this.application.ExecutionReport += new ExecutionReportEventHandler(this.pQ0g8arCK);
				this.application.OrderCancelReject += new OrderCancelRejectEventHandler(this.Q4TGKECr3);
			}
			this.application.Connect();
		}
 public FixEngineConnection(ISessionWrapper session, IInitiator socketInitiator)
 {
     _session        = session;
     SocketInitiator = socketInitiator;
 }