Esempio n. 1
0
        public Task <ContainerLeaseData> RenewLease(Guid leaseId)
        {
            logger.LogInformation($"Renewing lock {leaseId}...");

            try
            {
                lock (locker)
                {
                    // find lease
                    var lease = leases.SelectMany(l => l.Value).FirstOrDefault(l => l?.LeaseId == leaseId);
                    if (lease == null)
                    {
                        throw new KeyNotFoundException($"The lease with ID={leaseId} does not exist!");
                    }

                    // renew
                    lease.ExpirationDateUtc = DateTime.UtcNow + LeaseTimeout;

                    logger.LogInformation($"Lock ID={lease.LeaseId} renewed and valid until {lease.ExpirationDateUtc}.");

                    LogHub.Refresh(hubContext);

                    return(Task.FromResult(lease));
                }
            }
            catch (Exception ex)
            {
                logger.LogError(ex, $"Error renewing lock {leaseId}!");
                throw;
            }
        }
Esempio n. 2
0
        }//Dispose()

        protected virtual void Dispose(bool disposing)
        {
            lock (m_DisposeLock)
            {
                if (!m_IsDisposed)
                {
                    if (disposing)
                    {
                        if (m_Log != null)
                        {
                            m_Log.RequestStop();
                            m_Log = null;
                        }
                        if (m_Dispatcher != null)
                        {
                            m_Dispatcher.BeginInvokeShutdown();
                            m_Dispatcher = null;
                        }
                        if (m_UAPI != null)
                        {
                            m_UAPI.Shutdown();
                            m_UAPI = null;
                        }
                        if (m_XAPI != null)
                        {
                            m_XAPI.Shutdown();
                            m_XAPI = null;
                        }
                    }
                }
                m_IsDisposed = true;
                OnStopping();
            }
        }//Dispose()
Esempio n. 3
0
        public async Task DropLease(Guid leaseId)
        {
            ContainerLeaseData lease = null;

            lock (locker)
            {
                // find lease
                foreach (var browser in leases)
                {
                    var index = browser.Value.FindIndex(l => l?.LeaseId == leaseId);
                    if (index >= 0)
                    {
                        lease = browser.Value[index];

                        // drop lease
                        browser.Value[index] = null;
                        break;
                    }
                }
            }

            if (lease != null)
            {
                // stop container
                await dockerProvisioningService.StopContainer(lease.ContainerId);

                logger.LogInformation($"The lease {leaseId} was dropped and the container was stopped.");
            }
            else
            {
                logger.LogInformation($"The lease {leaseId} has already been dropped, no action was taken.");
            }

            LogHub.Refresh(hubContext);
        }
Esempio n. 4
0
        /// <summary>
        /// ログを残す
        /// </summary>
        /// <param name="logger">ログの種類</param>
        /// <param name="logedText">ログに残されるべきテキスト</param>
        /// <returns></returns>
        public static string LeaveLog(this LogHub logger, string logedText)
        {
            var displayedSentences = $"【{logger.ToString()}】{logedText}";

            Debug.Log(displayedSentences);
            return(displayedSentences);
        }
Esempio n. 5
0
        private List <SocketClient> m_Clients = new List <SocketClient>(); // place to hold clients GUIs.

        #endregion                                                         // members


        #region Constructors
        // *****************************************************************
        // ****                     Constructors                        ****
        // *****************************************************************
        public SocketServer()
        {
            InitializeComponent();
            string dirPath = System.IO.Directory.GetCurrentDirectory();

            m_Log = new LogHub("SocketTest", dirPath, true, LogLevel.ShowAllMessages);
        }
Esempio n. 6
0
        /// <summary>
        /// This is called by an external thread.  It creates a Thread.WorkerThread and
        /// calls StartInitAPI().  Here, a dispatcher for the worker is created and the
        /// first Action (a call to InitAPI()) is queued and run.
        /// </summary>
        public void Start()
        {
            bool isLogViewerVisible = false;

            //#if DEBUG
            //    isLogViewerVisible = true;
            //#endif

            if (m_Log == null)
            {
                m_Log = new LogHub("TT API Services", Misty.Lib.Application.AppInfo.GetInstance().LogPath, isLogViewerVisible, LogLevel.ShowAllMessages);
            }
            if (m_Instance == null)
            {
                if (m_Log != null)
                {
                    m_Log.NewEntry(LogLevel.Error, "Start: No API instantiated.  Cannot Start(). ");
                }
                return;
            }
            if (m_IsDisposed)
            {
                if (m_Log != null)
                {
                    m_Log.NewEntry(LogLevel.Error, "Start: This TTService is already disposed.  Cannot Start(). ");
                }
                return;
            }
            Thread workerThread = new Thread(m_Instance.StartInitAPI);  // Create a thread to run the API.

            workerThread.Name = "TT API Service";
            workerThread.Start();                                       // Start new thread and exit, releases the calling thread!
        }// Start()
Esempio n. 7
0
        //
        //
        #endregion// members


        #region Constructors
        // *****************************************************************
        // ****                     Constructors                        ****
        // *****************************************************************
        //
        public Monitor()
        {
            InitializeComponent();

            //Misty.Lib.Application.AppInfo appInfo = Misty.Lib.Application.AppInfo.GetInstance("Monitor",true);
            string currentPath = System.IO.Directory.GetCurrentDirectory();

            Log = new LogHub("Monitor", string.Format("{0}\\Logs\\", currentPath), true, LogLevel.ShowAllMessages);
            DateTime now = Log.GetTime();

            m_Writer = new DropQueueWriter(string.Format("{0}\\Logs\\", currentPath), string.Format("data_{0}_{1}.txt", now.ToString("yyyyMMdd"), now.ToString("HHmmss")), this.Log);
            m_Writer.Start();

            string s = string.Format("{0}\\user_female.ico", currentPath);

            if (System.IO.File.Exists(s))
            {
                this.Icon = Icon.ExtractAssociatedIcon(s);
            }

            // Instantiate TT API.
            m_TTService = TTServices.TTApiService.GetInstance();
            m_TTService.ServiceStateChanged += new EventHandler(TTService_ServiceStateChanged);
            m_TTService.Start(true);
        }
Esempio n. 8
0
        /// <summary>
        /// This is called by an external thread.  It creates a Thread.WorkerThread and
        /// calls StartInitAPI().  Here, a dispatcher for the worker is created and the
        /// first Action (a call to InitAPI()) is queued and run.
        /// </summary>
        public void Start()
        {
            if (m_Log == null)
            {
                m_Log = new LogHub("TT API Services", UV.Lib.Application.AppInfo.GetInstance().LogPath, m_IsViewLog, LogLevel.ShowAllMessages);
            }
            if (m_Instance == null)
            {
                if (m_Log != null)
                {
                    m_Log.NewEntry(LogLevel.Error, "Start: No API instantiated.  Cannot Start(). ");
                }
                return;
            }
            if (m_IsDisposed)
            {
                if (m_Log != null)
                {
                    m_Log.NewEntry(LogLevel.Error, "Start: This TTService is already disposed.  Cannot Start(). ");
                }
                return;
            }
            Thread workerThread = new Thread(m_Instance.StartInitAPI);  // Create a thread to run the API.

            workerThread.Name = m_ServiceName;
            workerThread.Start();                                       // Start new thread and exit, releases the calling thread!
        }// Start()
Esempio n. 9
0
        //
        #endregion// members


        #region Constructors
        // *****************************************************************
        // ****                     Constructors                        ****
        // *****************************************************************
        /// <summary>
        /// Immediately starts the thread.  A TT Session must already exist when this is created.
        /// </summary>
        /// <param name="listenerName"></param>
        /// <param name="aLog"></param>
        public OrderListener(string listenerName, Hub parentHub)
        {
            m_ParentHub = parentHub;
            this.Log    = m_ParentHub.Log;
            this.m_Name = listenerName;
            m_TTService = TTApiService.GetInstance();
        }
Esempio n. 10
0
 protected override void SetupInitialize(IEngineHub myEngineHub, IEngineContainer engineContainer, int engineID, bool setupGui)
 {
     base.SetupInitialize(myEngineHub, engineContainer, engineID, setupGui);
     m_Hub      = (Hub)myEngineHub;
     this.m_Log = m_Hub.Log;                                              // set up our logging
     this.m_ExecutionContainer = (ExecutionContainer)engineContainer;
 }
Esempio n. 11
0
        // *****************************************************************
        // ****                     Constructors                        ****
        // *****************************************************************
        //
        //
        //
        public HedgeOptionsDatabaseWriterTest()
        {
            m_Log = new LogHub("BRELibLog", string.Format("{0}{1}", UV.Lib.Application.AppInfo.GetInstance().BasePath,
                                                          UV.Lib.Application.AppInfo.GetInstance().LogDirectory), true, LogLevel.ShowAllMessages);
            InitializeComponent();
            m_UIDispatcher = Dispatcher.CurrentDispatcher;

            DatabaseInfo dbInfo = DatabaseInfo.Create(DatabaseInfo.DatabaseLocation.bredev);

            dbInfo.UserName        = "******";
            dbInfo.UserPW          = "test";
            m_DatabaseReaderWriter = new DatabaseReaderWriter(dbInfo);
            m_DatabaseReaderWriter.QueryResponse += new EventHandler(DatabaseReaderWriter_QueryResponse);

            this.textBoxExchangeName.Text = "CME";
            this.textBoxProductName.Text  = "GE";
            this.textBoxProductType.Text  = "Spread";

            m_TTAPIService = TTApiService.GetInstance();
            m_TTAPIService.ServiceStateChanged += new EventHandler(TTApiService_ServiceStateChanged);
            m_TTAPIService.Start(true);

            m_Market = new MarketTTAPI();
            m_Market.MarketStatusChanged += new EventHandler(MarketTTAPI_MarketStatusChanged);
            m_Market.FoundResource       += new EventHandler(MarketTTAPI_MarketFoundServiceResource);
            m_Market.Start();
            m_Market.Connect();                             // initialize connection to API.
        }
Esempio n. 12
0
        //
        // ****         Setup Initialize()          ****
        //
        /// <summary>
        /// This is called by the local execution hub thread.
        /// </summary>
        /// <param name="hub"></param>
        public void SetupInitialize(IEngineHub hub)
        {
            // Keep pointers to my local hub.
            m_LocalEngineHub     = hub;
            m_LocalEngineHubName = hub.ServiceName;
            Log = ((Hub)m_LocalEngineHub).Log;
            // Initialize all my engines.
            int ptr = 0;

            while (ptr < m_IEngineList.Count)
            {
                if (m_IEngineList[ptr] is Engine)
                {
                    Engine engine = (Engine)m_IEngineList[ptr];
                    engine.SetupInitialize(hub, this, engine.EngineID);
                }
                ptr++;
            }

            m_ConfirmSynthOrderEventArg.Status            = EngineEventArgs.EventStatus.Confirm; // create reusable event arg.
            m_ConfirmSynthOrderEventArg.EngineHubName     = this.RemoteEngineHub.ServiceName;
            m_ConfirmSynthOrderEventArg.EngineContainerID = this.EngineContainerID;
            m_ConfirmSynthOrderEventArg.MsgType           = EngineEventArgs.EventType.SyntheticOrder;
            m_ConfirmSynthOrderEventArg.DataObjectList    = new List <object>();
        }// SetupInitialize()
Esempio n. 13
0
        //
        //
        // ******************************************************
        // ****             Setup Initialize()               ****
        // ******************************************************
        /// <summary>
        /// Since we are a specialized gui manager, we override SetupInitialize()
        /// and don't create a default popup gui.
        /// </summary>
        /// <param name="myEngineHub"></param>
        /// <param name="engineContainer"></param>
        /// <param name="engineID"></param>
        /// <param name="isSetupGui"></param>
        protected override void SetupInitialize(IEngineHub myEngineHub, IEngineContainer engineContainer, int engineID, bool isSetupGui)
        {
            base.SetupInitialize(myEngineHub, engineContainer, engineID, false);// call base class first.

            m_Parent = (Strategy)engineContainer;
            m_ParentEngineContainerID = engineContainer.EngineContainerID;
            Log = m_Parent.StrategyHub.Log;

            // Set the plotting hour offset.
            m_StartTime = m_Parent.StrategyHub.GetLocalTime();
            m_StartHour = m_StartTime.Hour + m_StartTime.Minute / 60.0 + m_StartTime.Second / 3600.0;
            if (m_StartHour >= 16.0)
            {
                m_StartHour -= 24.0;                            // after 4pm, shift to negative numbers (new trading day).
            }
            //
            // Add our custom ZGraphControl template
            //
            UV.Lib.FrontEnds.GuiTemplates.EngineGui engineGui = new Lib.FrontEnds.GuiTemplates.EngineGui();
            engineGui.DisplayName           = "Graph";
            engineGui.EngineID              = this.m_EngineID;
            engineGui.EngineFullName        = this.GetType().FullName;
            engineGui.HeaderControlFullName = typeof(UV.Lib.FrontEnds.Graphs.ZGraphControl).FullName;
            engineGui.ParameterList.AddRange(this.m_PInfo);
            m_EngineGuis.Add(engineGui);
        }//SetupInitialize()
Esempio n. 14
0
        public IHttpActionResult PutLogMessage(int id, LogMessage logMessage)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != logMessage.ID)
            {
                return(BadRequest());
            }

            try
            {
                _logger.UpdateLogMessage(id, logMessage);
            }
            catch (ArgumentException)
            {
                return(NotFound());
            }

            LogHub.UpdateMessage(logMessage);

            return(StatusCode(HttpStatusCode.NoContent));
        }
Esempio n. 15
0
        //
        //
        #endregion//Constructors


        #region Properties
        // *****************************************************************
        // ****                     Properties                          ****
        // *****************************************************************
        //
        //
        #endregion//Properties


        #region Public Methods
        // *****************************************************************
        // ****                     Public Methods                      ****
        // *****************************************************************
        //
        //
        //
        //
        //
        //
        #endregion//Public Methods


        #region Private Methods
        // *****************************************************************
        // ****                     Private Methods                     ****
        // *****************************************************************
        //

        //
        private void Shutdown()
        {
            m_IsShuttingDown = true;
            if (m_Writer != null)
            {
                m_Writer.RequestStop();
                m_Writer = null;
            }
            if (m_TTService != null)
            {
                m_TTService.Dispose();
                m_TTService = null;
            }
            if (m_PriceListener != null)
            {
                m_PriceListener.Dispose();
                m_PriceListener = null;
            }
            if (m_FillListener != null)
            {
                m_FillListener.Dispose();
                m_FillListener = null;
            }
            if (m_OrderListener != null)
            {
                m_OrderListener.Dispose();
                m_OrderListener = null;
            }
            if (Log != null)
            {
                Log.RequestStop();
                Log = null;
            }
        }
Esempio n. 16
0
        //
        //
        // ****         SetupBegin()            ****
        //
        public override void SetupBegin(IEngineHub myEngineHub, IEngineContainer engineContainer)
        {
            base.SetupBegin(myEngineHub, engineContainer);
            m_Parent = (Strategy)engineContainer;
            Log      = ((Hub)myEngineHub).Log;

            // Get Engines of interest.
            int modelCounter = 0;

            foreach (IEngine ieng in m_Parent.GetEngines())
            {
                if (ieng is ZGraphEngine)
                {
                    if (m_GraphEngine == null)
                    {
                        m_GraphEngine = (ZGraphEngine)ieng;                 // take first found graph engine to draw to.
                    }
                }
                else if (ieng is ModelEngine)
                {
                    if (ieng == this)
                    {
                        m_ModelEngineID = modelCounter;
                    }                                                           // store the number of models in front of me (use as my id!)
                    modelCounter++;
                }
            }
        }//SetupBegin()
Esempio n. 17
0
 protected override void SetupInitialize(IEngineHub myEngineHub, IEngineContainer engineContainer, int engineID, bool setupGui)
 {
     base.SetupInitialize(myEngineHub, engineContainer, engineID, setupGui);
     m_StrategyHub = (StrategyHub)myEngineHub;
     this.m_Log    = m_StrategyHub.Log;                                           // set up our logging
     this.m_Market = m_StrategyHub.m_Market;                                      // grab the market so we can have some instrument details
 }
        /// <summary>
        /// GUI constructor to have both of the paths as members and log as well as drop file player, audit trail player.
        /// </summary>
        public AmbreRecoveryViewer()
        {
            InitializeComponent();
            typeof(MarketTTAPI).ToString();

            // Create log viewer.
            bool isLogViewerVisible = true;

            Log = new LogHub(ApplicationName, AppInfo.GetInstance().LogPath, isLogViewerVisible, LogLevel.ShowAllMessages);

            // Create app service and get useful paths.
            AppServices appAmbreMaintenanceServices = AppServices.GetInstance(ApplicationName, true);

            m_RepositoryDropFilePath = appAmbreMaintenanceServices.Info.DropPath;
            m_AuditTrailFilePath     = appAmbreMaintenanceServices.Info.DropPath;
            if (m_DebugMode)
            {
                m_ReferenceDropFilePath = m_RepositoryDropFilePath.Replace(ApplicationName, ReferenceApplicationName);
            }
            else
            {
                m_ReferenceDropFilePath = m_RepositoryDropFilePath.Replace(string.Format("\\{0}", ApplicationName), "");
            }

            Log.NewEntry(LogLevel.Minor, "The default paths to operate are {0} and {1}.", m_RepositoryDropFilePath, m_ReferenceDropFilePath);
            if (!System.IO.Directory.Exists(m_ReferenceDropFilePath))
            {
                m_ReferenceDropFilePath = m_RepositoryDropFilePath.Replace(ApplicationName, "Ambre");
                Log.NewEntry(LogLevel.Major, "The default path for reference Ambre system does not exist, and the operating path becomes {0}.", m_ReferenceDropFilePath);
                if (!System.IO.Directory.Exists(m_ReferenceDropFilePath))
                {
                    Log.NewEntry(LogLevel.Major, "The changed path still does not exist. and the program can not proceed.");
                    return;
                }
            }

            // Create market tt api service and tt api service.
            m_MarketTTAPIService = new MarketTTAPI();
            m_MarketTTAPIService.Start();
            m_TTAPIService     = TTApiService.GetInstance();
            m_TTAPIService.Log = this.Log;
            m_TTAPIService.ServiceStateChanged += new EventHandler(TTAPIService_ServiceStateChanged);
            m_TTAPIService.Start();

            // Sample for the user login name and fill hub name.
            textBoxUserName.Text    = "BETSIM";
            textBoxFillHubName.Text = "2014";
            m_UserName = textBoxUserName.Text;
            m_FillHubOrFillManagerName = textBoxFillHubName.Text;

            // Create file players.
            m_DropFilePlayer = new DropFilePlayer(m_ReferenceDropFilePath, Log);

            // Add closing form event trigger.
            this.FormClosing += new FormClosingEventHandler(AmbreRecoveryViewer_Closing);

            // Find all existing audit trail files. Also in this block, toggle the earliest and latest date time to the GUI.
            m_RepoFileList = new List <string>();
            LoadAllAuditTrailFiles();
        }//AmbreRecoveryViewer()
Esempio n. 19
0
 //
 //
 // ****             Setup Begin()               ****
 //
 public override void SetupBegin(IEngineHub myEngineHub, IEngineContainer engineContainer)
 {
     base.SetupBegin(myEngineHub, engineContainer);
     m_Name   = base.EngineName;
     m_Parent = (Strategy)engineContainer;
     this.Log = ((StrategyHub)myEngineHub).Log;
 }//SetupBegin()
Esempio n. 20
0
 // *****************************************************************
 // ****                     Public Methods                      ****
 // *****************************************************************
 //
 //
 //string filePath = string.Format("{0}{1}", this.Info.UserConfigPath, configFileName);
 //
 //
 public static bool TryCreateFromFile(string filePath, LogHub aLog, out List <Strategy> strategyList)
 {
     strategyList = new List <Strategy>();             // place to put new strategies
     try
     {
         List <IStringifiable> iStringObjects;
         using (StringifiableReader reader = new StringifiableReader(filePath))
         {
             iStringObjects = reader.ReadToEnd();
         }
         if (aLog != null)
         {
             aLog.NewEntry(LogLevel.Major, "StrategyMaker: Created {0} iStringifiable objects from {1}", iStringObjects.Count, filePath.Substring(filePath.LastIndexOf("\\") + 1));
         }
         foreach (IStringifiable iStrObj in iStringObjects)
         {
             if (iStrObj is Strategy)
             {
                 strategyList.Add((Strategy)iStrObj);
             }
         }
     }
     catch (Exception e)
     {
         StringBuilder msg = new StringBuilder();
         msg.AppendFormat("Exception: {0}\r\nContinue? \r\n{1}", e.Message, e.StackTrace);
         System.Windows.Forms.DialogResult result = System.Windows.Forms.MessageBox.Show(msg.ToString(), "StrategyMaker.TryCreateFromFile", System.Windows.Forms.MessageBoxButtons.OKCancel);
         if (aLog != null)
         {
             aLog.NewEntry(LogLevel.Major, "StrategyMaker: Exception {0}", e.Message);
         }
         return(result == System.Windows.Forms.DialogResult.OK);
     }
     return(true);
 }// TryCreateFromFile()
Esempio n. 21
0
        protected ConcurrentQueue <EventArgs> m_InQueue = new ConcurrentQueue <EventArgs>(); // threadsafe queue to push events to processed onto.
        #endregion                                                                           //members

        #region Constructors
        // *****************************************************************
        // ****                     Constructors                        ****
        // *****************************************************************
        public ExecutionListener(string name, IEngineHub engineHub)
        {
            m_EngineHub = engineHub;
            if (engineHub is Hub)
            {
                this.Log = ((Hub)engineHub).Log;
            }
            m_Name = name;
        }
Esempio n. 22
0
 // *****************************************************************
 // ****                     Constructors                        ****
 // *****************************************************************
 //
 //
 //
 /// <summary>
 /// Constructor to create audit trail player input user name, fill hub name and audit trail path.
 /// </summary>
 /// <param name="auditTrailPath"></param>
 /// <param name="userName"></param>
 /// <param name="fillHubName"></param>
 /// <param name="log"></param>
 public AuditTrailPlayer(string auditTrailPath, string userName, string fillHubName, LogHub log)
 {
     m_AuditTrailPath           = auditTrailPath;
     m_UserName                 = userName;
     m_FillHubName              = fillHubName;
     m_FillEventArgsList        = new List <FillEventArgs>();
     m_NeededBookInstrumentList = new List <InstrumentKey>();
     Log = log;
 }
Esempio n. 23
0
        private List <string> m_PropertyFormat          = new List <string>(); // column formats
        //
        //
        //
        #endregion// members


        #region Constructors
        // *****************************************************************
        // ****                     Constructors                        ****
        // *****************************************************************
        public FormFillBookViewer(Ambre.TTServices.Markets.MarketTTAPI priceHub, FillHub aFillHub)
        {
            InitializeComponent();
            Log       = aFillHub.Log;
            m_FillHub = aFillHub;
            m_Market  = priceHub;

            UpdateNewFills();
        }// FormFillBookViewer()
Esempio n. 24
0
 //
 // *****************************************
 // ****     Setup Initialize()          ****
 // *****************************************
 protected override void SetupInitialize(IEngineHub myEngineHub, IEngineContainer engineContainer, int engineID, bool setupGui)
 {
     base.SetupInitialize(myEngineHub, engineContainer, engineID, setupGui);
     //
     // Keep pointers to important objects.
     //
     this.ParentStrategy = (Strategy)engineContainer;
     this.Log            = ((Hub)myEngineHub).Log;                   // Pricing engines tend to log a lot, so keep a pointer.
 }
Esempio n. 25
0
        // *****************************************************************
        // ****                     Constructors                        ****
        // *****************************************************************
        //
        //
        //
        private HedgeOptions(InstrumentName instrumentName, string instrumentNameTT, string instrumentNameDatabase, LogHub log)
        {
            m_QuoteInstrument        = instrumentName;
            m_InstrumentNameTT       = instrumentNameTT;
            m_InstrumentNameDatabase = instrumentNameDatabase;
            m_Log = log;

            m_HedgeOptions = new List <HedgeOption>();
        }
        }//HubEventHandler()

        //
        //
        //
        // *************************************************************************
        // ***                      Process Request                             ****
        // *************************************************************************
        /// <summary>
        /// These are request for fill hub resources.  Some can not be completed yet, and these
        /// will be stored in a Queue for retrying later.
        /// </summary>
        private void ProcessAuditTrailEvent(AuditTrailEventArgs eventArg)
        {
            if (eventArg == null)
            {
                return;
            }

            if (eventArg.auditTrailEventType == AuditTrailEventType.LoadAuditTrailFills)
            {
                if (m_Listener != null)
                {
                    // It does not need the TT to start fill listening.
                    m_IsInitializingBooks = false;
                    Log.NewEntry(LogLevel.Minor, "Connected to audit trail file.");
                    m_Listener.Filled += new EventHandler(HubEventEnqueue);
                    AuditTrailPlayer  auditTrailReader  = (AuditTrailPlayer)eventArg.Data[0];
                    AuditTrailFillHub auditTrailFillHub = (AuditTrailFillHub)eventArg.Data[1];
                    DateTime          auditTrailReadingStartDateTime = (DateTime)eventArg.Data[2];
                    DateTime          auditTrailPlayingEndDateTime   = (DateTime)eventArg.Data[3];
                    LogHub            log = (LogHub)eventArg.Data[4];
                    m_Listener.Log = log;

                    // Get the variables from GUI thread to load audit trail fills and update initial state of fill hub.
                    if (auditTrailReader.TryReadAuditTrailFills(auditTrailReadingStartDateTime, auditTrailPlayingEndDateTime, auditTrailFillHub))
                    {
                        m_NeededCheckKeys.Clear();
                        m_NeededCheckKeys.AddRange(auditTrailReader.m_NeededBookInstrumentList);
                        Log.NewEntry(LogLevel.Minor, "Successfully load fills from audit trail file.");
                    }
                    else
                    {
                        Log.NewEntry(LogLevel.Major, "Failed to load fills from audit trail file.");
                        return;
                    }
                }
            }
            else if (eventArg.auditTrailEventType == AuditTrailEventType.PlayAuditTrailFills)
            {
                AuditTrailPlayer  auditTrailReader  = (AuditTrailPlayer)eventArg.Data[0];
                AuditTrailFillHub auditTrailFillHub = (AuditTrailFillHub)eventArg.Data[1];
                DateTime          auditTrailReadingStartDateTime = (DateTime)eventArg.Data[2];
                DateTime          auditTrailPlayingEndDateTime   = (DateTime)eventArg.Data[3];
                LogHub            log = (LogHub)eventArg.Data[4];

                // Get the variables from GUI thread to play the audit trail fills.
                if (auditTrailReader.TryPlayAuditTrailFillsForFillHub(auditTrailFillHub, auditTrailReadingStartDateTime, auditTrailPlayingEndDateTime, out auditTrailFillHub))
                {
                    Log.NewEntry(LogLevel.Minor, "Successful in playing the audit trail file.");
                }
                else
                {
                    Log.NewEntry(LogLevel.Major, "Failed to play the audit trail file.");
                    return;
                }
            }
        }// ProcessRequest()
Esempio n. 27
0
        // *****************************************************************
        // ****                     Constructors                        ****
        // *****************************************************************
        //
        //
        /// <summary>
        /// Caller would like to create a new Instrument matrix for a given list of
        /// instruments.  This class will use the provided DatabaseReaderWriter to submit
        /// queries and create the need matrix of quote and hedge legs as well as there hedge
        /// ratios.
        /// </summary>
        /// <param name="instruments"></param>
        /// <param name="dbReaderWriter"></param>
        public InstrumentMatrix(List <InstrumentName> instruments, DatabaseReaderWriter dbReaderWriter)
        {
            m_Instruments          = instruments;
            m_DatabaseReaderWriter = dbReaderWriter;
            m_Log = dbReaderWriter.Log;

            //m_DatabaseReaderWriter.QueryResponse += new EventHandler();
            // Need to think about threading issues here...who is going to own
            // this object and how the collections will be accessed
        }
        //
        // *********************************************
        // ****         SetUp Initialize()          ****
        // *********************************************
        /// <summary>
        /// </summary>
        protected override void SetupInitialize(IEngineHub myEngineHub, IEngineContainer engineContainer, int engineID, bool setupGui)
        {
            // Save information about local strategy hub.
            m_EngineContainerId = engineContainer.EngineContainerID;
            if (myEngineHub is IService)
            {
                m_LocalEngineHubName = ((IService)myEngineHub).ServiceName;
            }
            StrategyHub strategyHub = ((StrategyHub)myEngineHub);

            this.Log         = strategyHub.Log;
            m_LocalEngineHub = myEngineHub;

            // Locate our target remote hub/service.
            IEngineHub   remoteEngineHub = null;
            EventHandler del             = new EventHandler(ProcessRemoteEngineEvents);

            if (strategyHub.SubscribeToRemoteEngineHub("ExecutionHub", m_EngineContainerId, m_EngineID, del, out remoteEngineHub))
            {
                m_RemoteEngineHub = remoteEngineHub;
            }
            else
            {
                throw new Exception("Failed to locate remote hub.");
            }


            // Create the parameter table.
            Type remoteEngineType;

            if (Stringifiable.TryGetType(m_RemoteEngineClassName, out remoteEngineType))
            {
                this.m_PInfo = CreateParameterInfo(myEngineHub, engineContainer.EngineContainerID, this.EngineID, remoteEngineType);
            }

            //
            // Add sub-engines to the parent Strategy
            //
            //  They will be automatically initialized outside in StrategyHub loop
            //  that called us, since we will add new engine to the end of the list we are looping thru now.
            List <IStringifiable> subElements = m_Node.GetElements();

            if (subElements != null)
            {
                foreach (IStringifiable iObject in subElements)
                {                                       // Engines that are beneath non-engines will not be found here.
                    if (iObject is ExecutionController) // This remote engine will not need to broad its existance,
                    {
                        ExecutionController subEngine = (ExecutionController)iObject;
                        subEngine.m_IsSubEngine = true;                     // since it will be included in another engine (this one).
                        ((Strategy)engineContainer).TryAddEngine(subEngine, myEngineHub);
                    }
                }
            }
        }//SetupInitialize()
Esempio n. 29
0
        // *****************************************************************
        // ****                     Constructors                        ****
        // *****************************************************************
        public Form1(string[] args)
        {
            InitializeComponent();
            AppInfo m_AppInfo = AppInfo.GetInstance("Breconcile", true);



            m_FtpReader = new Ftp.FtpReader(true);
            Log         = m_FtpReader.Log;                                  // I will use his Log.
            m_FtpReader.RequestCompleted += new EventHandler(FtpReader_RequestCompleted);
        }
Esempio n. 30
0
        //
        // This method is invoked when the application has loaded and is ready to run. In this
        // method you should instantiate the window, load the UI into it and then make the window
        // visible.
        //
        // You have 17 seconds to return from this method, or iOS will terminate your application.
        //
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            // Appearance
            UITableView.Appearance.BackgroundColor = Styles.RTDarkerBlue;
            UITableView.Appearance.SeparatorInset  = UIEdgeInsets.Zero;
            UITabBar.Appearance.BarTintColor       = Styles.RTDarkerBlue;

            // create a new window instance based on the screen size
            window = new UIWindow(UIScreen.MainScreen.Bounds);

            var cs = new ConcurrencyService();

            _cs = cs;

            var logSource = new LogHub();

            _loggerFactory = new LoggerFactory(logSource);

#if DEBUG
            UIApplication.CheckForIllegalCrossThreadCalls = true;
            var logViewController = new LogViewController(cs, logSource);
#endif

            _reactiveTrader        = new Adaptive.ReactiveTrader.Client.Domain.ReactiveTrader();
            _startUpViewController = new StartUpView(Initalize);
            Initalize();


            _notificationHandler = new NotificationGenerator(_reactiveTrader, cs);
            _notificationHandler.Initialise();

            var tradesViewController = new TradesViewController(_reactiveTrader, cs);
            var pricesViewController = new PriceTilesViewController(_reactiveTrader, cs);
            var statusViewController = new StatusViewController(_reactiveTrader, cs, _notificationHandler.NotificationsEnabled);

            tabBarController = new UITabBarController();
            tabBarController.ViewControllers = new UIViewController[] {
                pricesViewController,
                tradesViewController,
                statusViewController
                                #if DEBUG
                , logViewController
                                #endif
            };

            tabBarController.ModalTransitionStyle = UIModalTransitionStyle.CrossDissolve;

            window.RootViewController = _startUpViewController;
            window.MakeKeyAndVisible();

            new WormholeSender(_reactiveTrader);

            return(true);
        }