public static bool?TestParsing( string sampleLog, IAlertPopup alerts, ITempFilesManager tempFilesManager, IObjectFactory objectsFactory, XmlNode formatRoot, string formatSpecificNodeName ) { if (sampleLog == "") { alerts.ShowPopup("", "Provide sample log first", AlertFlags.Ok | AlertFlags.WarningIcon); return(null); } string tmpLog = tempFilesManager.GenerateNewName(); try { XDocument clonedFormatXmlDocument = XDocument.Parse(formatRoot.OuterXml); UserDefinedFactoryParams createParams; createParams.Entry = null; createParams.RootNode = clonedFormatXmlDocument.Element("format"); createParams.FormatSpecificNode = createParams.RootNode.Element(formatSpecificNodeName); createParams.FactoryRegistry = null; createParams.TempFilesManager = tempFilesManager; // Temporary sample file is always written in Unicode wo BOM: we don't test encoding detection, // we test regexps correctness. using (var w = new StreamWriter(tmpLog, false, new UnicodeEncoding(false, false))) w.Write(sampleLog); ChangeEncodingToUnicode(createParams); var cp = ConnectionParamsUtils.CreateFileBasedConnectionParamsFromFileName(tmpLog); ILogProviderFactory f; if (formatSpecificNodeName == "regular-grammar") { f = new RegularGrammar.UserDefinedFormatFactory(createParams); } else if (formatSpecificNodeName == "xml") { f = new XmlFormat.UserDefinedFormatFactory(createParams); } else { return(null); } using (f as IDisposable) using (var interaction = objectsFactory.CreateTestDialog()) { return(interaction.ShowDialog(f, cp)); } } finally { File.Delete(tmpLog); } }
public override string GetTaskbarLogName() { if (eventLogIdentity.FileName != null) { return(ConnectionParamsUtils.GuessFileNameFromConnectionIdentity(eventLogIdentity.FileName)); } return(eventLogIdentity.LogName); }
IConnectionParams ILogProviderFactory.GetConnectionParamsToBeStoredInMRUList(IConnectionParams originalConnectionParams) { var cp = originalConnectionParams.Clone(true); cp[ConnectionParamsKeys.PathConnectionParam] = null; ConnectionParamsUtils.RemoveInitialTimeOffset(cp); return(cp); }
public LogProvider(ILogProviderHost host, string fileName) : base(host, PlainText.Factory.Instance, ConnectionParamsUtils.CreateConnectionParamsWithIdentity(ConnectionParamsUtils.CreateFileBasedConnectionIdentityFromFileName(fileName))) { this.fileName = fileName; StartLiveLogThread(string.Format("'{0}' listening thread", fileName)); }
public RecentLogEntry(ILogProviderFactory factory, IConnectionParams connectionParams, string annotation, DateTime?useTimestampUtc) { if (factory == null) { throw new ArgumentNullException("factory"); } if (connectionParams == null) { throw new ArgumentNullException("connectionParams"); } this.Factory = factory; this.ConnectionParams = connectionParams; this.Annotation = annotation; this.UseTimestampUtc = useTimestampUtc; ConnectionParamsUtils.ValidateConnectionParams(ConnectionParams, Factory); }
public RecentLogEntry(ILogProviderFactoryRegistry registry, string recentLogEntryString, string annotation, DateTime?useTimestampUtc) { var m = MatchRecentLogEntryString(recentLogEntryString); string company = m.Groups["company"].Value; string name = m.Groups["name"].Value; this.Factory = registry.Find(company, name); if (Factory == null) { throw new FormatNotRegistedException(company, name); } this.ConnectionParams = new ConnectionParams(m.Groups["connectStr"].Value); ConnectionParamsUtils.ValidateConnectionParams(ConnectionParams, Factory); this.Annotation = annotation; this.UseTimestampUtc = useTimestampUtc; }
public LogProvider(ILogProviderHost host, Factory factory) : base(host, factory, ConnectionParamsUtils.CreateConnectionParamsWithIdentity(DebugOutput.Factory.connectionIdentity)) { using (trace.NewFrame) { try { dataReadyEvt = new EventWaitHandle(false, EventResetMode.AutoReset, "DBWIN_DATA_READY"); bufferReadyEvt = new EventWaitHandle(false, EventResetMode.AutoReset, "DBWIN_BUFFER_READY"); trace.Info("Events opened OK. DBWIN_DATA_READY={0}, DBWIN_BUFFER_READY={1}", dataReadyEvt.SafeWaitHandle.DangerousGetHandle(), bufferReadyEvt.SafeWaitHandle.DangerousGetHandle()); bufferFile = new SafeFileHandle( Unmanaged.CreateFileMapping(new IntPtr(-1), IntPtr.Zero, Unmanaged.PAGE_READWRITE, 0, 1024, "DBWIN_BUFFER"), true); if (bufferFile.IsInvalid) { throw new Win32Exception(Marshal.GetLastWin32Error()); } trace.Info("DBWIN_BUFFER shared file opened OK. Handle={0}", bufferFile.DangerousGetHandle()); bufferAddress = new SafeViewOfFileHandle( Unmanaged.MapViewOfFile(bufferFile, Unmanaged.FILE_MAP_READ, 0, 0, 512), true); if (bufferAddress.IsInvalid) { throw new Win32Exception(Marshal.GetLastWin32Error()); } trace.Info("View of file mapped OK. Ptr={0}", bufferAddress.DangerousGetHandle()); StartLiveLogThread("DebugOutput listening thread"); } catch (Exception e) { trace.Error(e, "Failed to inistalize DebugOutput reader. Disposing what has been created so far."); Cleanup(); throw; } } }
string ILogProviderFactory.GetUserFriendlyConnectionName(IConnectionParams connectParams) { return(ConnectionParamsUtils.GetFileOrFolderBasedUserFriendlyConnectionName(connectParams)); }
public string GetConnectionId(IConnectionParams connectParams) { return(ConnectionParamsUtils.GetConnectionIdentity(connectParams)); }
IConnectionParams IFileBasedLogProviderFactory.CreateParams(string fileName) { return(ConnectionParamsUtils.CreateFileBasedConnectionParamsFromFileName(fileName)); }
public override IConnectionParams GetConnectionParamsToBeStoredInMRUList(IConnectionParams originalConnectionParams) { return(ConnectionParamsUtils.RemoveNonPersistentParams(originalConnectionParams.Clone(true), tempFilesManager)); }
public IConnectionParams GetConnectionParamsToBeStoredInMRUList(IConnectionParams originalConnectionParams) { return(ConnectionParamsUtils.RemoveNonPersistentParams(originalConnectionParams.Clone(true), TempFilesManager.GetInstance())); }
public IConnectionParams CreateRotatedLogParams(string folder) { return(ConnectionParamsUtils.CreateRotatedLogConnectionParamsFromFolderPath(folder)); }
public IConnectionParams CreateParams(string fileName) { return(ConnectionParamsUtils.CreateFileBasedConnectionParamsFromFileName(fileName)); }
string ILogProviderFactory.GetConnectionId(IConnectionParams connectParams) { return(ConnectionParamsUtils.GetConnectionIdentity(connectParams)); }
IConnectionParams ILogProviderFactory.GetConnectionParamsToBeStoredInMRUList(IConnectionParams originalConnectionParams) { return(ConnectionParamsUtils.RemoveNonPersistentParams(originalConnectionParams.Clone(true), tempFiles)); }
public static IConnectionParams CreateConnectionParamsFromBaseFileName(string baseFileName) { return(ConnectionParamsUtils.CreateFileBasedConnectionParamsFromFileName(baseFileName)); }
public override string GetUserFriendlyConnectionName(IConnectionParams connectParams) { return(ConnectionParamsUtils.GetFileOrFolderBasedUserFriendlyConnectionName(connectParams)); }
public override string GetTaskbarLogName() { return(ConnectionParamsUtils.GuessFileNameFromConnectionIdentity(fileName)); }
IConnectionParams IFileBasedLogProviderFactory.CreateRotatedLogParams(string folder) { return(ConnectionParamsUtils.CreateRotatedLogConnectionParamsFromFolderPath(folder)); }
IConnectionParams IFileBasedLogProviderFactory.CreateRotatedLogParams(string folder, IEnumerable <string> patterns) { return(ConnectionParamsUtils.CreateRotatedLogConnectionParamsFromFolderPath(folder, this, patterns)); }