Example #1
0
        public void Iniciar()
        {
            SessionSettings  settings = new SessionSettings(this.ArquivoConfiguracao);
            FileStoreFactory store    = new FileStoreFactory(settings);
            FileLogFactory   logs     = new FileLogFactory(settings);
            MessageFactory   msgs     = new DefaultMessageFactory();

            // Cria o socket
            if (this.EhInitiator)
            {
                _socketInitiator =
                    new SocketInitiator(
                        this.AplicacaoFix, store, settings, logs, msgs);
                _socketInitiator.start();
            }
            else
            {
                _socketAcceptor =
                    new SocketAcceptor(
                        this.AplicacaoFix, store, settings, logs, msgs);
                _socketAcceptor.start();
            }

            // Envia mensagem para aplicação
            this.AplicacaoFix.Iniciar();
        }
Example #2
0
  static void Main( string[] args )
  {
    if ( args.Length != 1 )
    {
      Console.WriteLine( "usage: executor_csharp FILE." );
      return ;
    }

    try
    {
      SessionSettings settings = new SessionSettings( args[ 0 ] );
      Application application = new Application();
      FileStoreFactory storeFactory = new FileStoreFactory( settings );
      ScreenLogFactory logFactory = new ScreenLogFactory( settings );
      MessageFactory messageFactory = new DefaultMessageFactory();
      SocketAcceptor acceptor
        = new SocketAcceptor( application, storeFactory, settings, logFactory, messageFactory );

      acceptor.start();
      Console.WriteLine("press <enter> to quit");
      Console.Read();
      acceptor.stop();
    }
    catch ( Exception e )
    {
      Console.WriteLine( e );
    }
  }
        public static void InitializeServer(string settingsPath)
        {
            try
            {
                _targetCompID_SessionCode   = new Dictionary <string, string>();
                _sessionCode_sessionDetails = new Dictionary <string, SessionInfo>();
                _sessionID_sessionCode      = new Dictionary <string, string>();
                _sessionsCodesToRep         = new List <string>();

                using (DataLayer.DatabaseMethods db = new DataLayer.DatabaseMethods())
                {
                    foreach (DataRow row in db.GetTable("FixSessionCode").Rows)
                    {
                        string targetCompID = row["TargetCompID"].ToString();
                        string code         = row["Code"].ToString();
                        bool   isRep        = Convert.ToBoolean(row["IsRep"]);
                        _targetCompID_SessionCode.Add(targetCompID, code);
                        if (isRep)
                        {
                            _sessionsCodesToRep.Add(code);
                        }
                    }
                }
                SessionSettings settings = new SessionSettings(settingsPath);
                _acceptor = new SocketAcceptor(new SvcFixServer(), new FileStoreFactory(settings), settings, new FileLogFactory(settings), new DefaultMessageFactory());
                _acceptor.start();
                SystemLogger.WriteOnConsoleAsync(true, string.Format("Fix Server Started Up !"), ConsoleColor.Green, ConsoleColor.Black, false);
            }
            catch (Exception e)
            {
                SystemLogger.WriteOnConsoleAsync(true, string.Format("InitializeServer Error, Error {0}", e.ToString()), ConsoleColor.Red, ConsoleColor.Black, true);
            }
        }
Example #4
0
        static void Main(string[] args)
        {
            if (args.Length != 1)
            {
                Console.WriteLine("usage: executor_csharp FILE.");
                return;
            }

            try
            {
                SessionSettings  settings       = new SessionSettings(args[0]);
                Application      application    = new Application();
                FileStoreFactory storeFactory   = new FileStoreFactory(settings);
                ScreenLogFactory logFactory     = new ScreenLogFactory(settings);
                MessageFactory   messageFactory = new DefaultMessageFactory();
                SocketAcceptor   acceptor
                    = new SocketAcceptor(application, storeFactory, settings, logFactory, messageFactory);

                acceptor.start();
                Console.WriteLine("press <enter> to quit");
                Console.Read();
                acceptor.stop();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Example #5
0
    static void Main(string[] args)
    {
        string file = "";

        if (args.Length >= 2 && args[0].Equals("-f") && args[1] != null)
        {
            file = args[1];
        }
        else
        {
            Console.WriteLine("usage: at" + " -f FILE [-t]");
            return;
        }

        SessionSettings  settings    = new SessionSettings(file);
        at_application   application = new at_application();
        FileStoreFactory factory     = new FileStoreFactory(settings);
        Acceptor         acceptor    = new SocketAcceptor
                                           (application, factory, settings, new DefaultMessageFactory());

        acceptor.start();
        while (true)
        {
            Thread.Sleep(1000);
        }
    }
Example #6
0
        static void Main(string[] args)
        {
            try
            {
                SessionSettings      settings       = new SessionSettings(@"C:\Users\anhtv\Desktop\QuickFix\QuickFix\acceptor1.cfg");
                FixServerApplication application    = new FixServerApplication();
                FileStoreFactory     storeFactory   = new FileStoreFactory(settings);
                ScreenLogFactory     logFactory     = new ScreenLogFactory(settings);
                MessageFactory       messageFactory = new DefaultMessageFactory();
                SocketAcceptor       acceptor       = new SocketAcceptor(application, storeFactory, settings, logFactory, messageFactory);

                acceptor.start();
                Console.WriteLine("press enter to quit");
                Console.Read();
                acceptor.stop();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }
        }
Example #7
0
 public bool Start(string user, string pw)
 {
     try
     {
         SessionSettings  settings       = new SessionSettings(_setpath);
         Application      application    = this;
         FileStoreFactory storeFactory   = new FileStoreFactory(settings);
         FileLogFactory   logFactory     = new FileLogFactory(settings);
         MessageFactory   messageFactory = new DefaultMessageFactory();
         acceptor = new SocketAcceptor
                        (application, storeFactory, settings, logFactory /*optional*/, messageFactory);
         acceptor.start();
         _val = true;
         return(true);
     }
     catch (Exception ex)
     {
         debug("exception starting server: " + ex.Message + ex.StackTrace);
         _val = false;
     }
     return(false);
 }
Example #8
0
  static void Main(string[] args)
  {
    string file = "";

    if( args.Length >= 2 && args[0].Equals("-f") && args[1] != null ) 
    {
      file = args[1];
	  }
    else 
    {
      Console.WriteLine( "usage: at" + " -f FILE [-t]" );
      return;
	  }

    SessionSettings settings = new SessionSettings(file);
    at_application application = new at_application();
    FileStoreFactory factory = new FileStoreFactory(settings);
    Acceptor acceptor = new SocketAcceptor
        ( application, factory, settings, new DefaultMessageFactory() );
    acceptor.start();
    while( true ) Thread.Sleep( 1000 );
  }
Example #9
0
        static void Main(string[] args)
        {
            AppLogger = new PerDayFileLogSource(Directory.GetCurrentDirectory() + "\\Log", Directory.GetCurrentDirectory() + "\\Log\\Backup")
            {
                FilePattern = "Log.{0:yyyy-MM-dd}.log",
                DeleteDays  = 20
            };

            string path = ConfigurationManager.AppSettings["AcceptorPath"];

            SessionSettings  = new SessionSettings(path);
            FileStoreFactory = new FileStoreFactory(SessionSettings);
            ScreenLogFactory = new ScreenLogFactory(SessionSettings);
            MessageFactory   = new DefaultMessageFactory();

            Program myProgram = new Program();

            Acceptor = new SocketAcceptor(myProgram, FileStoreFactory, SessionSettings, ScreenLogFactory, MessageFactory);

            Acceptor.start();

            Console.WriteLine("Acceptor successfully started...");
            Console.ReadKey();
        }
Example #10
0
 public bool Start(string user, string pw)
 {
     try
     {
         SessionSettings settings = new SessionSettings(_setpath);
         Application application = this;
         FileStoreFactory storeFactory = new FileStoreFactory(settings);
         FileLogFactory logFactory = new FileLogFactory(settings);
         MessageFactory messageFactory = new DefaultMessageFactory();
         acceptor = new SocketAcceptor
           (application, storeFactory, settings, logFactory /*optional*/, messageFactory);
         acceptor.start();
         _val = true;
         return true;
     }
     catch (Exception ex)
     {
         debug("exception starting server: " + ex.Message + ex.StackTrace);
         _val = false;
     }
     return false;
 }
Example #11
0
        public virtual void IniciarServico()
        {
            logger.Info("IniciarServico(): iniciando canal Bovespa ....");

            // Carrega configurações
            _config = GerenciadorConfig.ReceberConfig <CanalNegociacaoConfig>();

            // Cria sessao que será usada para mandar as mensagens
            _session =
                new SessionID(
                    new BeginString(_config.BeginString),
                    new SenderCompID(_config.SenderCompID),
                    new TargetCompID(_config.TargetCompID));


            // Cria dicionario da configuracao
            Dictionary mainDic = new Dictionary();

            if (_config.SocketAcceptPort > 0)
            {
                mainDic.setLong("SocketAcceptPort", _config.SocketAcceptPort);
            }
            mainDic.setLong("SocketConnectPort", _config.SocketConnectPort);
            mainDic.setLong("HeartBtInt", _config.HeartBtInt);
            mainDic.setLong("ReconnectInterval", _config.ReconnectInterval);

            mainDic.setBool("ResetOnLogon", _config.ResetSeqNum);
            mainDic.setBool("PersistMessages", _config.PersistMessages);

            // Ver
            // ret.setString("ConnectionType", ConnectionType.ToLower());
            mainDic.setString("SocketConnectHost", _config.Host);
            mainDic.setString("FileStorePath", _config.FileStorePath);

            logger.Debug("FileLogPath: " + _config.FileLogPath);
            mainDic.setString("FileLogPath", _config.FileLogPath);
            mainDic.setString("StartTime", _config.StartTime);
            mainDic.setString("EndTime", _config.EndTime);
            if (_config.Initiator)
            {
                mainDic.setString("ConnectionType", "initiator");
            }
            else
            {
                mainDic.setString("ConnectionType", "acceptor");
            }

            Dictionary sessDic = new Dictionary();

            sessDic.setString("BeginString", _config.BeginString);
            sessDic.setString("SenderCompID", _config.SenderCompID);
            sessDic.setString("TargetCompID", _config.TargetCompID);
            sessDic.setString("DataDictionary", _config.DataDictionary);
            sessDic.setBool("UseDataDictionary", true);


            // Configure the session settings
            SessionSettings settings = new SessionSettings();

            settings.set(mainDic);
            settings.set(_session, sessDic);

            FileStoreFactory store = new FileStoreFactory(settings);
            FileLogFactory   logs  = new FileLogFactory(settings);

            QuickFix.MessageFactory msgs = new DefaultMessageFactory();

            // Cria o socket
            if (_config.Initiator)
            {
                _socketInitiator = new SocketInitiator(this, store, settings, logs, msgs);
                _socketInitiator.start();
            }
            else
            {
                _socketAcceptor = new SocketAcceptor(this, store, settings, logs, msgs);
                _socketAcceptor.start();
            }

            _status = ServicoStatus.EmExecucao;

            logger.Info("IniciarServico(): canal Bovespa em execucao....");
        }