Created
March 13, 2015 14:50
-
-
Save mgonzales3/a8813345cb557aea1885 to your computer and use it in GitHub Desktop.
Trace EWS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Currently EWS returns strings with the declaration in the wrong place. This file fixes that. | |
*/ | |
public class TraceListener : ITraceListener | |
{ | |
public void Trace(string traceType, string traceMessage) | |
{ | |
CreateXMLTextFile(traceType, traceMessage.ToString()); | |
} | |
private void CreateXMLTextFile(string fileName, string traceContent) | |
{ | |
string updatedContent = ""; | |
try | |
{ | |
updatedContent = traceContent; | |
if (traceContent.IndexOf("?xml") > -1) | |
updatedContent = traceContent.Remove(traceContent.IndexOf("?xml"), 42); | |
XDocument xd = XDocument.Parse(updatedContent); | |
xd.Save(AppDomain.CurrentDomain.BaseDirectory + @"Trace\Exchange\" + fileName + ".xml", SaveOptions.None); | |
} | |
catch | |
{ | |
// If the trace data is not valid XML, save it as a text document. | |
System.IO.File.WriteAllText(AppDomain.CurrentDomain.BaseDirectory + @"Trace\Exchange\" + fileName + ".txt", traceContent); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment