public static bool ParseMessageUsingMAPIInspector(string fileName) { bool result = true; List <FiddlerExe.Fiddler.Session> allSessions = new List <FiddlerExe.Fiddler.Session>(); FiddlerExe.Fiddler.Session sessionExe; List <FiddlerCore.Fiddler.Session> oAllSessionsNew = FiddlerCore.Fiddler.Utilities.ReadSessionArchive(fileName, false, "MAPIAutomationTest").ToList(); int sessionCount = oAllSessionsNew.Count; for (int i = 0; i < sessionCount; i++) { FiddlerExe.Fiddler.HTTPRequestHeaders requestHeader = new FiddlerExe.Fiddler.HTTPRequestHeaders(); if (oAllSessionsNew[i].RequestHeaders.Exists("X-RequestType")) { requestHeader["X-RequestType"] = oAllSessionsNew[i].RequestHeaders["X-RequestType"]; } if (oAllSessionsNew[i].RequestHeaders.ExistsAndContains("Content-Type", "application/mapi-http")) { requestHeader["Content-Type"] = oAllSessionsNew[i].RequestHeaders["Content-Type"]; } sessionExe = new FiddlerExe.Fiddler.Session(requestHeader, oAllSessionsNew[i].requestBodyBytes); sessionExe.responseBodyBytes = oAllSessionsNew[i].responseBodyBytes; if (oAllSessionsNew[i].ResponseHeaders.Exists("Transfer-Encoding")) { sessionExe["Transfer-Encoding"] = oAllSessionsNew[i].ResponseHeaders["Transfer-Encoding"]; } if (oAllSessionsNew[i].ResponseHeaders.Exists("X-ResponseCode")) { sessionExe["X-ResponseCode"] = oAllSessionsNew[i].ResponseHeaders["X-ResponseCode"]; } if (oAllSessionsNew[i].ResponseHeaders.Exists("Content-Type")) { sessionExe["Content-Type"] = oAllSessionsNew[i].ResponseHeaders["Content-Type"]; } sessionExe.fullUrl = oAllSessionsNew[i].fullUrl; sessionExe["VirtualID"] = (i + 1).ToString(); allSessions.Add(sessionExe); } MapiInspector.MAPIInspector ma = new MapiInspector.MAPIInspector(); string errorPath = TestBase.testingfolderPath + Path.DirectorySeparatorChar + TestBase.testName; result = ma.ParseCaptureFile(allSessions.ToArray(), errorPath); return(result); }
/// <summary> /// Parse the capture file using the MAPI Inspector /// </summary> /// <param name="fileName">The file name to parse</param> /// <param name="allRops">All ROPs contained in list</param> /// <returns>Parse result, true means success</returns> public static bool ParseMessageUsingMAPIInspector(string fileName, out List <string> allRops) { bool result = true; List <FiddlerExe.Fiddler.Session> allSessions = new List <FiddlerExe.Fiddler.Session>(); FiddlerExe.Fiddler.Session sessionExe; List <FiddlerCore.Fiddler.Session> allSessionsNew = FiddlerCore.Fiddler.Utilities.ReadSessionArchive(fileName, false, "MAPIAutomationTest").ToList(); int sessionCount = allSessionsNew.Count; for (int i = 0; i < sessionCount; i++) { FiddlerExe.Fiddler.HTTPRequestHeaders requestHeader = new FiddlerExe.Fiddler.HTTPRequestHeaders(); if (allSessionsNew[i].RequestHeaders.Exists("X-RequestType")) { requestHeader["X-RequestType"] = allSessionsNew[i].RequestHeaders["X-RequestType"]; } if (allSessionsNew[i].RequestHeaders.ExistsAndContains("Content-Type", "application/mapi-http")) { requestHeader["Content-Type"] = allSessionsNew[i].RequestHeaders["Content-Type"]; } if (allSessionsNew[i].RequestHeaders.Exists("X-ClientInfo")) { requestHeader["X-ClientInfo"] = allSessionsNew[i].RequestHeaders["X-ClientInfo"]; } sessionExe = new FiddlerExe.Fiddler.Session(requestHeader, allSessionsNew[i].requestBodyBytes); sessionExe.responseBodyBytes = allSessionsNew[i].responseBodyBytes; if (allSessionsNew[i].ResponseHeaders.Exists("Transfer-Encoding")) { sessionExe["Transfer-Encoding"] = allSessionsNew[i].ResponseHeaders["Transfer-Encoding"]; } if (allSessionsNew[i].ResponseHeaders.Exists("X-ResponseCode")) { sessionExe["X-ResponseCode"] = allSessionsNew[i].ResponseHeaders["X-ResponseCode"]; } if (allSessionsNew[i].ResponseHeaders.Exists("Content-Type")) { sessionExe["Content-Type"] = allSessionsNew[i].ResponseHeaders["Content-Type"]; } if (allSessionsNew[i].LocalProcess != string.Empty) { sessionExe["LocalProcess"] = allSessionsNew[i].LocalProcess; } sessionExe.fullUrl = allSessionsNew[i].fullUrl; sessionExe["VirtualID"] = (i + 1).ToString(); allSessions.Add(sessionExe); } MapiInspector.MAPIInspector ma = new MapiInspector.MAPIInspector(); // string errorPath = TestBase.TestingfolderPath + Path.DirectorySeparatorChar + TestBase.TestName; string errorPath = TestBase.filePath; result = ma.ParseCaptureFile(allSessions.ToArray(), errorPath, TestBase.TestName, out allRops); if (!result) { string filenameNew = fileName.Split('\\').Last().Split('.').First(); File.Move(errorPath + "\\" + "error.txt", errorPath + "\\" + filenameNew + ".txt"); } return(result); }