// // // ***************************************************** // **** 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()
// // // // #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()
} // 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); 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 repoPath = DropSimple.GetArchivePath(DropFileStartDateTime, DropRules.BreRepositoryPath); m_ArcBookWriter.RequestCopyTo(repoPath, string.Empty); // push current file to repository now, keep same filename. //m_ArcBookWriter.RequestCopyAllFiles(repoPath, "*FillBooks*");// 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 = DropSimple.GetArchivePath(DropFileStartDateTime, UV.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()
private string GetArchiveFileNameBase(string bookType) { return(DropSimple.GetArchiveFileBaseName(bookType, this.UniqueUserName, FileSuffix)); //return string.Format("{0}_{1}.{2}",bookType,this.UniqueUserName,FileSuffix); }
//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)); }