コード例 #1
0
ファイル: DropRules.cs プロジェクト: nagyist/mkbiltek.trading
        } // 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()
        {
            string fillHubSnapshot = Stringifiable.Stringify(m_FillHub, m_StringifyOverrideTable);

            // Copy and reinitialize the local file
            if (m_LocalBookWriter != null)
            {
                m_LocalBookWriter.RequestFlushNow();                // Flush queue into the current file, making it up-to-date.
                string fileName = GetLocalFileName();               // Local drop-file name
                string path     = string.Format("{0}Previous\\", GetLocalPath());
                m_LocalBookWriter.RequestMoveTo(path, fileName);    // Move the current drop file to a safe, backup area.
                m_LocalBookWriter.RequestEnqueue(fillHubSnapshot);  // Create a new local drop file, and initialize it w/ snapshot
                m_LocalBookWriter.RequestFlushNow();                // I like to push out the first snapshot immediately...
            }

            // Archive and restart new archival files.
            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))); // try to sync all
                }
                // 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 = GetArchivePath(DropFileStartDateTime);                                              // Creates starting time stamp (now's date) in arcPath name.
                m_ArcBookWriter.RequestChangeFileName(archivalPath, GetArchiveFileName(DateTime.Now, 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.
            }

            // Archive
            if (m_FillWriter != null)
            {
                m_FillWriter.RequestFlushNow();
                string archivalPath = GetArchivePath(DropFileStartDateTime);// Creates starting time stamp (now's date) in arcPath name.
                m_FillWriter.RequestChangeFileName(archivalPath, GetArchiveFileName(DropFileStartDateTime, DropType_Fills));
            }

            // Store the time we did this snapshot.
            LastBookDrop = m_FillHub.Log.GetTime();                 // store the time we last did a snapshot.
        } // DropFillBooks()
コード例 #2
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 repoPath = DropSimple.GetArchivePath(DropFileStartDateTime, DropRules.BreRepositoryPath);                 //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()