예제 #1
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()
예제 #2
0
        } // TryPeriodicBookDrop()

        //
        //
        // *************************************************************
        // ****             StartNewDropArchive()                   ****
        // *************************************************************
        /// <summary>
        /// Create a new complete snapshot and drop in into file.
        /// Called by the FillHub thread, so we know no fills will be being added while we are here.
        /// </summary>
        public void StartNewDropArchive()
        {
            m_FillHub.Log.NewEntry(LogLevel.Major, "Running drop files for account/instrument {0} for {1}!", m_FillHub.Name, AppServices.GetInstance().m_AmbreUserName);

            if (m_FillHub.ListenerTradeSubscriptionFilter == null)
            {
                m_FillHub.Log.NewEntry(LogLevel.Warning, "*****Notice***** The account or instrument filter becomes corrupted because fill listener filter is null now");
                if (!string.IsNullOrEmpty(m_FillHub.m_LastListenAccountFilter))
                {
                    m_FillHub.ResetFillListener();
                }
            }
            else
            {
                if (m_FillHub.ListenerTradeSubscriptionFilter.GetType() != typeof(TradeSubscriptionAccountFilter) && m_FillHub.ListenerTradeSubscriptionFilter.GetType() != typeof(TradeSubscriptionInstrumentFilter))
                {
                    m_FillHub.Log.NewEntry(LogLevel.Warning, "*****Notice***** The account or instrument filter becomes corrupted because fill listener filter has different types from account or instrument filter");
                    if (!string.IsNullOrEmpty(m_FillHub.m_LastListenAccountFilter))
                    {
                        m_FillHub.ResetFillListener();
                    }
                }
            }
            m_FillHub.CheckMakeUpFilterArgs(m_FillHub.m_LastListenAccountFilter);
            string fillHubSnapshot = Stringifiable.Stringify(m_FillHub, m_StringifyOverrideTable);

            if (m_ArcBookWriter != null)
            {
                // Wrap up the current working file, and archive it.
                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 droppath = string.Format("\\\\fileserver\\Users\\DV_Ambre\\AmbreUsers\\{0}\\Drops\\", AppServices.GetInstance().m_AmbreUserName);
                    string repoPath = DropSimple.GetArchivePath(DropFileStartDateTime, droppath);
                    m_FillHub.Log.NewEntry(LogLevel.Minor, "Sending request to copy to new drop directory:{0}.", repoPath);
                    m_ArcBookWriter.RequestCopyTo(repoPath, string.Empty);  // push current file to new repository now, keep same filename.
                    //m_ArcBookWriter.RequestCopyAllFiles(repoPath, "*FillBooks*");// try to sync all

                    // Also copy the files to old path that is \\\\fileserver\\Users\\dv_bre\\Ambre\\Drops\\ told by Mike.
                    // Temp fix to allow a smooth transition from the old approach to the new approach.
                    droppath = "\\\\fileserver\\Users\\dv_bre\\Ambre\\Drops\\";
                    repoPath = DropSimple.GetArchivePath(DropFileStartDateTime, droppath);
                    m_FillHub.Log.NewEntry(LogLevel.Minor, "Sending request to copy to old drop directory:{0}.", repoPath);
                    m_ArcBookWriter.RequestCopyTo(repoPath, string.Empty);
                }
                // Set new starting time stamp for the new archival file.
                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.
                m_ArcBookWriter.RequestChangeFileName(archivalPath, GetArchiveFileName(DropFileStartDateTime, DropType_FillBook));            // Change current output filename to a new name (thereby ending our writes to the last one).
                m_ArcBookWriter.RequestEnqueue(fillHubSnapshot);                                                                              // initialize the new file with new snapshot
                m_ArcBookWriter.RequestFlushNow();                                                                                            // flush it just in case, so at least some entry is present in file if we crash.
            }
            LastBookDrop = m_FillHub.Log.GetTime();                                                                                           // store the time we last did a snapshot.
        } // DropFillBooks()
예제 #3
0
 //
 //
 // *****************************************************
 // ****                 Stop()                      ****
 // *****************************************************
 public void Stop()
 {
     if (m_ArcBookWriter != null)
     {
         m_ArcBookWriter.SetLog(null);                       // Disconnect my fillHub's log, since we are shutting down (and the writer may persist for a long time).
         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 droppath = string.Format("{0}{1}{2}", "\\\\fileserver\\Users\\DV_Ambre\\AmbreUsers\\", AppServices.GetInstance().m_AmbreUserName, "\\Drops\\");
             string repoPath = DropSimple.GetArchivePath(DropFileStartDateTime, droppath);                                    //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))); // just a precaution.
         }
         m_ArcBookWriter.RequestStop();
     }
 }//Dispose()
예제 #4
0
 private string GetArchiveFileNameBase(string bookType)
 {
     return(DropSimple.GetArchiveFileBaseName(bookType, this.UniqueUserName, FileSuffix));
     //return string.Format("{0}_{1}.{2}",bookType,this.UniqueUserName,FileSuffix);
 }
예제 #5
0
 //private string GetRepositoryPath(DateTime date)
 //{
 //    return DropSimple.GetArchivePath(date, DropRules.BreRepositoryPath);
 //    //return string.Format("{0}{1:yyyyMMdd}\\", DropRules.BreRepositoryPath, date);
 //}
 //
 // File name elements
 //
 private string GetArchiveFileName(DateTime date, string bookType)
 {
     //return string.Format("{0:HHmmss}_{1}",date,GetArchiveFileNameBase(bookType));
     return(DropSimple.GetArchiveFileName(date, bookType, this.UniqueUserName, FileSuffix));
 }