static private void SendPackages(DestinationInfo[] destinations) { foreach (DestinationInfo dInfo in destinations) { try { ReflectInsightPackage[] messages = dInfo.GetInterimMessages(); if (messages.Length > 0) { try { InvokeListeners.Receive(dInfo, dInfo.GetInterimMessages()); } finally { dInfo.ClearInterimMessageQueue(); DebugManager.Sleep(0); } } } catch (ThreadAbortException) { } catch (Exception ex) { if (RIExceptionManager.CanEvent(ex)) { RIExceptionManager.Publish(new ReflectInsightException(String.Format("MessageManager.InvokeListeners: unhandled exception was detected in destination message loop for destination: {0}", dInfo.Name), ex)); } RIEventManager.DoOnQueueException(ex); } } }
//-------------------------------------------------------------------- //private void ExampleHowToExtendTheHeader() //{ // // The code below shows how to extend the header. // // In this example, the MyExtraData must implement the IFastSerializer. // // Extending the header in the context of a text, has very little usage // // but nonetheless, is supported for those odd rare cases if needed. // // FFileHeader.FExtraData["MyExtraData"] = new FastSerializerObjectData(new MyExtraData()); //} /// ------------------------------------------------------------------- private void ProcessMessages(ReflectInsightPackage[] messages) { OpenFileStream(); try { Stream baseStream = (FFileStream as StreamWriter).BaseStream; DateTime dt = DateTime.Now.ToUniversalTime(); foreach (ReflectInsightPackage message in messages) { if (message.FMessageType == MessageType.PurgeLogFile) { PurgeLogFile(); continue; } if (message.FMessageType == MessageType.Clear || RIUtils.IsViewerSpecificMessageType(message.FMessageType)) { continue; } message.FDateTime = dt; message.FSequenceID = FFileHeader.GetNextSequenceId(); String txtMessage = MessageText.Convert(message, FDetails, FMessagePattern, FTimePatterns); if (FileHelper.ShouldAutoSave(FFileHeader, FAutoSave, baseStream, FOnSize, message.FDateTime, txtMessage.Length)) { ForceAutoSave(); message.FSequenceID = FFileHeader.GetNextSequenceId(); txtMessage = MessageText.Convert(message, FDetails, FMessagePattern, FTimePatterns); } if (FFileHeader.FInitDateTime == DateTime.MinValue) { FFileHeader.FInitDateTime = message.FDateTime; FFileHeader.FFirstDateTime = message.FDateTime; FFileHeader.FLastDateTime = message.FDateTime; } FFileHeader.FMessageCount++; FFileHeader.FLastDateTime = message.FDateTime; FFileStream.Write(txtMessage); DebugManager.Sleep(0); } } finally { CloseFileStream(true); } }
public virtual void Receive(ReflectInsightPackage[] messages) { DateTime dt = DateTime.Now.ToUniversalTime(); foreach (ReflectInsightPackage message in messages) { if (message.FMessageType == MessageType.Clear || message.FMessageType == MessageType.PurgeLogFile || RIUtils.IsViewerSpecificMessageType(message.FMessageType)) { continue; } message.FDateTime = dt; if (FColored) { switch (message.FMessageType) { case MessageType.SendDebug: Console.ForegroundColor = ConsoleColor.Green; break; case MessageType.SendInformation: Console.ForegroundColor = ConsoleColor.White; break; case MessageType.SendWarning: Console.ForegroundColor = ConsoleColor.Yellow; break; case MessageType.SendError: Console.ForegroundColor = ConsoleColor.Magenta; break; case MessageType.SendFatal: Console.ForegroundColor = ConsoleColor.Red; break; case MessageType.SendMiniDumpFile: Console.ForegroundColor = ConsoleColor.Red; break; case MessageType.SendException: Console.ForegroundColor = ConsoleColor.Red; break; } } Console.Write(MessageText.Convert(message, FDetails, FMessagePattern, FTimePatterns)); if (FColored) { Console.ForegroundColor = ConsoleColor.Gray; } DebugManager.Sleep(0); } }
//-------------------------------------------------------------------- //private void ExampleHowToExtendTheHeader() //{ // // The code below shows how to extend the header. // // Keep in mind that when you extend the header, you must rewrite // // the file. Try to avoid extending the header frequently as this will // // impact performance. // // // // In this example, the MyExtraData must implement the IFastSerializer. // //RIFileHeader newHeader = (RIFileHeader)FFileHeader.Clone(); // //newHeader.FExtraData["MyExtraData"] = new FastSerializerObjectData(new MyExtraData()); //} ///-------------------------------------------------------------------- private void ProcessMessages(ReflectInsightPackage[] messages) { if (FCreateDirectory) { Directory.CreateDirectory(Path.GetDirectoryName(FFilePath)); FCreateDirectory = false; } OpenFileStream(); try { using (var pool = FastFormatterPool.Pool.Container()) { DateTime dt = DateTime.Now.ToUniversalTime(); foreach (ReflectInsightPackage message in messages) { if (message.FMessageType == MessageType.PurgeLogFile) { PurgeLogFile(); continue; } if (message.FMessageType != MessageType.Clear) { if (RIUtils.IsViewerSpecificMessageType(message.FMessageType)) { continue; } // serialize the message message.FDateTime = dt; message.FSequenceID = FFileHeader.GetNextSequenceId(); Byte[] bMessage = pool.Instance.Serialize(message); if (FileHelper.ShouldAutoSave(FFileHeader, FAutoSave, FFileStream, FOnSize, message.FDateTime, bMessage.Length)) { ForceAutoSave(); // because the previous message was serialized with the previous last sequence id // we need to re-serialize the message with the new sequence id message.FSequenceID = FFileHeader.GetNextSequenceId(); bMessage = pool.Instance.Serialize(message); } if (FFileHeader.FInitDateTime == DateTime.MinValue) { FFileHeader.FInitDateTime = message.FDateTime; FFileHeader.FFirstDateTime = message.FDateTime; FFileHeader.FLastDateTime = message.FDateTime; } FFileHeader.FMessageCount++; FFileHeader.FLastDateTime = message.FDateTime; FFileStream.Write(bMessage, 0, bMessage.Length); } else // clear { RewriteFileIgnoreRequestor((RIFileHeader)FFileHeader.Clone(), pool.Instance, message.FSessionID, message.FRequestID); } DebugManager.Sleep(0); } } } finally { CloseFileStream(true); } }