Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
0
        }//TryLoadBooks()

        //
        //
        //
        // *****************************************************
        // ****                 Dispose()                   ****
        // *****************************************************
        public void Dispose()
        {
            if (m_FillWriter != null)
            {
                m_FillWriter.RequestStop();            // this will purge any drop lines in buffer.
                m_FillWriter = null;
            }
            if (m_LocalBookWriter != null)
            {
                m_LocalBookWriter.RequestStop();
                m_LocalBookWriter = null;
            }
            if (m_ArcBookWriter != null)
            {
                m_ArcBookWriter.RequestFlushNow();                  // Following procedure as above, make current file up to date...
                if (PushToRepository)                               // Now its up-to-date, push it to the repository group-shared drive.
                {
                    string repoPath = GetRepositoryPath(DropFileStartDateTime);
                    m_ArcBookWriter.RequestCopyTo(repoPath, string.Empty);// push current file to repository now, keep same filename.
                    m_ArcBookWriter.RequestCopyAllFiles(repoPath, string.Format("*{0}", GetArchiveFileNameBase(DropType_FillBook)));
                }

                m_ArcBookWriter.RequestStop();
                m_ArcBookWriter = null;
            }
        }
Ejemplo n.º 3
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;
            }
        }
Ejemplo n.º 4
0
        //
        //
        //
        //
        #endregion//Constructors


        #region Public Methods
        // *****************************************************************
        // ****                     Public Methods                      ****
        // *****************************************************************
        //
        //
        // *****************************************************
        // ****                 Start()                     ****
        // *****************************************************
        /// <summary>
        /// The user might want to load the old drop file for positions before starting
        /// to write and update a new one.  No drop file will be created until Start() is called.
        /// </summary>
        public void Start()
        {
            // Create drop writers
            // Local writer
            string path     = this.GetLocalPath();
            string fileName = this.GetLocalFileName();

            this.m_FillHub.Log.BeginEntry(LogLevel.Major, "DropRules: Dropping to {0}{1}", path, fileName);
            m_LocalBookWriter = new DropQueueWriter(path, fileName, m_FillHub.Log);
            m_LocalBookWriter.Start();

            // Acrhival writer
            DateTime now = DateTime.Now;

            path     = this.GetArchivePath(now);
            fileName = this.GetArchiveFileName(now, DropType_FillBook);
            this.m_FillHub.Log.AppendEntry(", archived to {0}{1}", path, fileName);
            m_ArcBookWriter = new DropQueueWriter(path, fileName, m_FillHub.Log);
            m_ArcBookWriter.Start();


            // Raw Fill drops
            fileName = this.GetArchiveFileName(now, DropType_Fills);
            this.m_FillHub.Log.AppendEntry(", and fills archived {1}.", path, fileName);
            m_FillWriter = new DropQueueWriter(path, fileName, m_FillHub.Log);
            m_FillWriter.Start();

            this.m_FillHub.Log.EndEntry();
        }// Start()
Ejemplo n.º 5
0
        //
        //
        #endregion// members


        #region Constructors
        // *****************************************************************
        // ****                     Constructors                        ****
        // *****************************************************************
        public DropRules2(FillHub fillHub)
        {
            this.UniqueUserName        = fillHub.Name;
            this.m_FillHub             = fillHub;
            this.DropFileStartDateTime = fillHub.Log.GetTime();               // time stamp "label" used for archiving current drop file.


#if (DEBUG)
            BookDropPeriod = new TimeSpan(0, 5, 0);
#endif

            this.LastBookDrop      = fillHub.Log.GetTime().Subtract(this.BookDropPeriod).AddMinutes(5.0);
            this.m_LocalTimeLast   = this.LastBookDrop;
            this.NextResetDateTime = this.NextResetDateTime.Subtract(this.NextResetDateTime.TimeOfDay).Add(ResetTimeOfDay);

            string path     = this.GetLocalPath();
            string fileName = this.GetLocalFileName();
            this.m_FillHub.Log.NewEntry(LogLevel.Major, "DropRules: Dropping to {0}{1}", path, fileName);
            m_DropWriter = new DropQueueWriter(path, fileName);

            // Raw Fill drops
            string dropDirPath  = this.GetArchivePath(DateTime.Now);
            string dropFileName = this.GetArchiveFileName(DateTime.Now, "Fills");
            m_DropFills = new DropQueueWriter(dropDirPath, dropFileName);
        }
Ejemplo n.º 6
0
        //
        //
        //
        //
        #endregion//Constructors


        #region Public Methods
        // *****************************************************************
        // ****                     Public Methods                      ****
        // *****************************************************************
        //
        //
        // *****************************************************
        // ****                 Start()                     ****
        // *****************************************************
        /// <summary>
        /// Starts the drop service that will periodically write whatever is in its queue.
        /// The user might want to load the old drop file for positions before starting
        /// to write and update a new one.  No new drop files are created until Start() is called.
        /// </summary>
        public void Start()
        {
            // Acrhival writer
            //DropFileStartDateTime = m_FillHub.Log.GetTime();            // This is time stamp of the next archive file to start.
            //string archivalPath = DropSimple.GetArchivePath(DropFileStartDateTime, Misty.Lib.Application.AppInfo.GetInstance().DropPath);// Creates starting time stamp (now's date) in arcPath name.
            //string fileName = this.GetArchiveFileName(DropFileStartDateTime, DropType_FillBook);
            //this.m_FillHub.Log.NewEntry(LogLevel.Major, "DropRules.Start(): Starting drop to dir: {0}  filename: {1}", archivalPath, fileName);

            if (DropFileStartDateTime.CompareTo(new DateTime(2000, 1, 1)) < 0)
            {                                                    // If DropFilStartTime has been changed from MinDateTime, then it points to the drop file
                // We have loaded already.  If its still MinDateTime, then set it to NOW.
                DropFileStartDateTime = m_FillHub.Log.GetTime(); // This is time stamp of the next archive file to start.
            }

            string archivalPath = DropSimple.GetArchivePath(DropFileStartDateTime, Misty.Lib.Application.AppInfo.GetInstance().DropPath);// Creates starting time stamp (now's date) in arcPath name.
            string fileName     = this.GetArchiveFileName(DropFileStartDateTime, DropType_FillBook);

            this.m_FillHub.Log.NewEntry(LogLevel.Major, "DropRules.Start(): Starting drop to dir: {0}  filename: {1}", archivalPath, fileName);
            m_ArcBookWriter           = new DropQueueWriter(archivalPath, fileName, m_FillHub.Log);
            m_ArcBookWriter.Stopping += new EventHandler(ArcBookWriter_Stopping);
            m_ArcBookWriter.Start();
            IsBookWriterRunning = true;

            //this.m_FillHub.Log.EndEntry();
        }// Start()
Ejemplo n.º 7
0
        }//TryLoadBooks()

        //
        //
        //
        // *****************************************************
        // ****                 Dispose()                   ****
        // *****************************************************
        public void Dispose()
        {
            if (m_ArcBookWriter != null)
            {
                m_ArcBookWriter.RequestStop();
                m_ArcBookWriter = null;
            }
        }
Ejemplo n.º 8
0
        }// TryLoadBooks()

        //
        //
        //
        public void Dispose()
        {
            if (m_DropWriter != null)
            {
                m_DropWriter.Stop();            // this will purge any drop lines in buffer.
                m_DropWriter = null;
            }
            if (m_DropFills != null)
            {
                m_DropFills.Stop();
                m_DropFills = null;
            }
        }
Ejemplo n.º 9
0
        //
        //
        //
        //
        #endregion//Constructors


        #region Public Methods
        // *****************************************************************
        // ****                     Public Methods                      ****
        // *****************************************************************
        //
        //
        // *****************************************************
        // ****                 Start()                     ****
        // *****************************************************
        /// <summary>
        /// Starts the drop service that will periodically write whatever is in its queue.
        /// The user might want to load the old drop file for positions before starting
        /// to write and update a new one.  No new drop files are created until Start() is called.
        /// </summary>
        public void Start()
        {
            // Acrhival writer
            DropFileStartDateTime = m_FillHub.Log.GetTime();                                                                           // This is time stamp of the next archive file to start.
            string archivalPath = DropSimple.GetArchivePath(DropFileStartDateTime, UV.Lib.Application.AppInfo.GetInstance().DropPath); // Creates starting time stamp (now's date) in arcPath name.
            string fileName     = this.GetArchiveFileName(DropFileStartDateTime, DropType_FillBook);

            this.m_FillHub.Log.NewEntry(LogLevel.Major, "DropRules.Start(): Starting drop to dir: {0}  filename: {1}", archivalPath, fileName);
            m_ArcBookWriter           = new DropQueueWriter(archivalPath, fileName, m_FillHub.Log);
            m_ArcBookWriter.Stopping += new EventHandler(ArcBookWriter_Stopping);
            m_ArcBookWriter.Start();
            IsBookWriterRunning = true;

            //this.m_FillHub.Log.EndEntry();
        }// Start()
Ejemplo n.º 10
0
        }//Dispose()

        //
        //
        // ****                 ArcWriterStopping()                 ****
        //
        private void ArcBookWriter_Stopping(object sender, EventArgs eventArgs)
        {
            m_ArcBookWriter.Stopping -= new EventHandler(ArcBookWriter_Stopping);
            m_ArcBookWriter           = null;
            IsBookWriterRunning       = false;
        }