/// <summary> /// TryPutJson /// </summary> /// <param name="url"></param> /// <param name="headerName"></param> /// <param name="headerValue"></param> /// <param name="postData"></param> /// <param name="timeOut"></param> /// <typeparam name="TResult"></typeparam> /// <returns></returns> public static TResult TryPutJson <TResult>(string url, string headerName, string headerValue, string postData, int timeOut = 60000) { TResult result = default(TResult); string responseJson = string.Empty; HttpWebResponse response = null; Stream requestStream = null; HttpWebRequest request = null; try { request = (HttpWebRequest)WebRequest.Create(url); request.Method = "PUT"; request.ContentType = "application/json; charset=utf-8"; request.Timeout = timeOut; request.Headers[headerName] = headerValue; byte[] data = Encoding.UTF8.GetBytes(postData); request.ContentLength = data.Length; requestStream = request.GetRequestStream(); requestStream.Write(data, 0, data.Length); requestStream.Close(); response = (HttpWebResponse)request.GetResponse(); requestStream = response.GetResponseStream(); if (requestStream != null) { using (var reader = new StreamReader(requestStream)) { responseJson = reader.ReadToEnd(); } } result = Serializer.Deserialize <TResult>(responseJson); } catch (Exception exception) { LogObject logException = new LogObject(); logException.Description = exception.Message; logException.StatusTag = Constants.ERROR; logException.Exception = exception; logger.Print(logException); } finally { if (request != null) { request.Abort(); } if (response != null) { response.Close(); } if (requestStream != null) { requestStream.Close(); requestStream.Dispose(); } } return(result); }
internal FacebookTestUserListResultModel FacebookTestUserListRequest(string appId, string appSecret, int count) { FacebookTestUserListResultModel result = new FacebookTestUserListResultModel(); try { string url = string.Format("https://graph.facebook.com/{0}/accounts", appId); string postData = string.Format("type=test-users&access_token={0}|{1}&limit={2}", appId, appSecret, count); result = HttpRequestExtensions.TryGetJson <FacebookTestUserListResultModel>(url + "?" + postData, 300000); if (result == null) { result = HttpRequestExtensions.TryGetJson <FacebookTestUserListResultModel>(url + "?" + postData, 300000); } } catch (Exception exception) { LogObject logException = new LogObject(); logException.Description = exception.Message + "Failed to get Facebook users list "; logException.StatusTag = Constants.ERROR; logException.Exception = exception; logger.Print(logException); result = null; } return(result); }
/// <summary> /// Facebook API Request /// </summary> /// <param name="appId"></param> /// <param name="appSecret"></param> /// <param name="installed"></param> /// <returns></returns> /// internal FacebookTestUserResultModel FacebookTestUserRequest(string appId, string appSecret, bool installed) { FacebookTestUserResultModel result = new FacebookTestUserResultModel(); try { string url = string.Format("https://graph.facebook.com/{0}/accounts/test-users", appId); var data = new FacebookTestUser { AppId = appId, AppSecret = appSecret, Installed = installed }; string postData = string.Format("installed={0}&access_token={1}|{2}", data.Installed, data.AppId, data.AppSecret); result = HttpRequestExtensions.TryPostJson <FacebookTestUserResultModel>(url, postData, 300000); if (result == null) { result = HttpRequestExtensions.TryPostJson <FacebookTestUserResultModel>(url, postData, 300000); } } catch (Exception exception) { LogObject logException = new LogObject(); logException.Description = exception.Message + "Failed to create Facebook user"; logException.StatusTag = Constants.ERROR; logException.Exception = exception; logger.Print(logException); result = null; } return(result); }
internal bool FacebookTestUserFriendRequest(string testUser1Id, string testUser2Id, string testUser1AccessToken, string testUser2AccessToken) { bool result; try { string url = string.Format("https://graph.facebook.com/{0}/friends/{1}", testUser1Id, testUser2Id); string postData = string.Format("access_token={0}", testUser1AccessToken); result = HttpRequestExtensions.TryPostJson <bool>(url, postData, 300000); if (result) { url = string.Format("https://graph.facebook.com/{1}/friends/{0}", testUser1Id, testUser2Id); postData = string.Format("access_token={0}", testUser2AccessToken); result = HttpRequestExtensions.TryPostJson <bool>(url, postData); if (!result) { //retry result = HttpRequestExtensions.TryPostJson <bool>(url, postData); } } else { //retry url = string.Format("https://graph.facebook.com/{1}/friends/{0}", testUser1Id, testUser2Id); postData = string.Format("access_token={0}", testUser2AccessToken); result = HttpRequestExtensions.TryPostJson <bool>(url, postData); if (!result) { //retry result = HttpRequestExtensions.TryPostJson <bool>(url, postData); } } } catch (Exception exception) { LogObject logException = new LogObject(); logException.Description = exception.Message + "Failed to create Facebook friends connection "; logException.StatusTag = Constants.ERROR; logException.Exception = exception; logger.Print(logException); result = false; } return(result); }
public static string GetJsonValue(string url, string key, int timeOut = 5000) { try { string parameterValue = string.Empty; var request = (HttpWebRequest)WebRequest.Create(url); request.Timeout = timeOut; using (var response = (HttpWebResponse)request.GetResponse()) { using (Stream reader = response.GetResponseStream()) { if (reader == null) { return(null); } using (var sr = new StreamReader(reader, Encoding.UTF8)) { string queryResult = sr.ReadToEnd(); JObject json = JObject.Parse(queryResult); foreach (var variable in json) { if (variable.Key == key) { return(variable.Value.ToString()); } } } } } } catch (Exception exception) { LogObject logException = new LogObject(); logException.Description = exception.Message; logException.StatusTag = Constants.ERROR; logException.Exception = exception; logger.Print(logException); return(null); } return(null); }
public static TResult TryGetJson <TResult>(string url, string headersName, string headersValue, int timeOut = 5000) { TResult result = default(TResult); try { //Log4NetLogger.Log(eLogLevel.Debug, string.Format("GetJson from url: {0}", url)); var request = (HttpWebRequest)WebRequest.Create(url); request.Timeout = timeOut; request.Headers[headersName] = headersValue; using (var response = (HttpWebResponse)request.GetResponse()) { using (Stream reader = response.GetResponseStream()) { if (reader == null) { return(result); } using (var sr = new StreamReader(reader, Encoding.UTF8)) { string queryResult = sr.ReadToEnd(); result = Serializer.Deserialize <TResult>(queryResult); } } } } catch (Exception exception) { LogObject logException = new LogObject(); logException.Description = exception.Message; logException.StatusTag = Constants.ERROR; logException.Exception = exception; logger.Print(logException); } return(result); }
/// <summary> /// Unitest will cal this one /// </summary> /// <param name="batchId"></param> /// <returns></returns> public bool ExecuteOneBatch(string batchId) { try { var jp = new JsonParser(); //VSH: clean global configuration before ExecuteOneBatch Boolean res = jp.AddConfigToMemory(""); string remote = Constants.MemoryConf["RemoteNode"]; int timeoutAllScenarios = Convert.ToInt32(Constants.MemoryConf["TimeoutAllScenarios"]) * 1000; var sel = new Selenium(); if (batchId == string.Empty) { MessageBox.Show("Select Batch first", "Applenium"); return(false); } var sql = new Sql(); _batchId = Convert.ToInt32(batchId); DataTable dtScenario = sql.GetDataTable(Constants.StrBatchScenariosToSelenium, _batchId.ToString(CultureInfo.InvariantCulture)); //SetAllScenariusStatusToRunorNot(dtScenario, Constants.Pending); var adapterBatches = new BatchesTableAdapter(); var adapterBatchLogic = new BatchLogicTableAdapter(); var adapterBrowser = new BrowsersTableAdapter(); _batchname = adapterBatches.GetBatchName(_batchId); var adapterScenario = new ScenarioTableAdapter(); _projectId = Convert.ToInt32(adapterBatches.GetProjectID(Convert.ToInt32(_batchId))); LogObject logObject = new LogObject(); logObject.ExecutionID = _runExecutionId; logObject.BatchID = _batchId; logObject.Description = Constants.LogBatchStatus + "=" + Constants.PROGRESS_STARTED; logObject.BatchName = _batchname; logObject.BatchProgress = Constants.PROGRESS_STARTED; logObject.StatusTag = Constants.DONE; logObject.ProjectID = _projectId; logger.Print(logObject); Singleton myInstance = Singleton.Instance; myInstance.BatchResult = true; var threadFinishEvents = new List <EventWaitHandle>(); foreach (DataRow row in dtScenario.Rows) { if (myInstance.StopExecution) { myInstance.BatchResult = false; break; } var threadFinish = new EventWaitHandle(false, EventResetMode.ManualReset); string BrowserID = row["BrowserID"].ToString(); string batchLogicId = row["BatchLogicID"].ToString(); int executionStatus = Convert.ToInt32(row["ExecutionStatusID"].ToString()); if (executionStatus == 1) //run only selected scenarios { threadFinishEvents.Add(threadFinish); _browserName = adapterBrowser.GetBrowserName(Convert.ToInt32(BrowserID)); ThreadStart ts = delegate { //wait till hub return available browser RemoteWebDriver driver = null; driver = sel.SetWebDriverBrowser(null, BrowserID, false); driver.Manage().Window.Maximize(); string scenarioId = row["ScenarioID"].ToString(); // adapterBatchLogic.Update(_batchId, Convert.ToInt32(scenarioId), Convert.ToInt32(browserId),Constants.Running, Convert.ToInt32(batchLogicId)); string scenarioname = adapterScenario.GetScenarioName(Convert.ToInt32(scenarioId)); if (guiInstance != null && isBatchRun == true) { guiInstance.UpdateProgressLabel("", "", Constants.UpdateProgress_REGULAR); } LogObject logObject2 = new LogObject(); logObject2.ExecutionID = _runExecutionId; logObject2.BatchID = _batchId; logObject2.ScenarioID = Convert.ToInt32(scenarioId); logObject2.ScnearioName = scenarioname; logObject2.Browser = _browserName; logObject2.ProjectID = _projectId; logObject2.ProjectName = _projectName; logObject2.BatchName = _batchname; logObject2.ProjectPageID = _projectPageId; logObject2.StatusTag = Constants.DONE; logObject2.Browser = _browserName; logger.Print(logObject2); // Do long work here bool scanearioresult = ExecuteOneScenario(scenarioId, driver); Dispatcher.CurrentDispatcher.Invoke(DispatcherPriority.Normal, (EventHandler) delegate { if (scanearioresult == false) { myInstance.BatchResult = false; //adapterBatchLogic.Update(_batchId,Convert.ToInt32(scenarioId),Convert.ToInt32(browserId),Constants.Failed,Convert.ToInt32(batchLogicId)); } driver.Quit(); threadFinish.Set(); }, null, null); }; try { ts.BeginInvoke(delegate(IAsyncResult aysncResult) { ts.EndInvoke(aysncResult); }, null); } catch (Exception exc) { MessageBox.Show("An exception has occoured when trying to execute a scenario - " + exc.TargetSite); } if (remote == "no") { WaitHandle.WaitAll(threadFinishEvents.ToArray(), Convert.ToInt32(timeoutAllScenarios)); } } } WaitHandle.WaitAll(threadFinishEvents.ToArray(), Convert.ToInt32(timeoutAllScenarios)); string description; int status; string bStatus = Constants.PROGRESS_FAILED; if (myInstance.BatchResult) { description = string.Format("{0}={1}", Constants.LogBatchName, "Passed"); status = Constants.PASSED; bStatus = Constants.PROGRESS_PASSED; //LogResult(_runExecutionId, Convert.ToInt32(_batchId), 0, 0, 0, batchname + " Batch Passed",Constants.Passed, "0", _projectId, 0); } else { //LogResult(_runExecutionId, Convert.ToInt32(_batchId), 0, 0, 0, batchname + " Batch Failed",Constants.Failed, "0", _projectId, 0); description = string.Format("{0}={1}", Constants.LogBatchStatus, "Failed"); status = Constants.FAILED; bStatus = Constants.PROGRESS_FAILED; } LogObject logObject3 = new LogObject(); logObject3.ExecutionID = _runExecutionId; logObject3.BatchID = Convert.ToInt32(_batchId); logObject3.Description = description; logObject3.StatusTag = status; logObject3.BatchStatus = bStatus; logObject3.ProjectID = _projectId; logger.Print(logObject3); //SetAllScenariusStatusToRunorNot(dtScenario, Constants.NotRunnig); return(myInstance.BatchResult); } catch (Exception exception) { LogObject exceptionLog = new LogObject(); exceptionLog.Description = exception.Message; exceptionLog.StatusTag = Constants.ERROR; logger.Print(exceptionLog); return(false); } }
internal bool ExecuteOneScenario(string scenarioId, RemoteWebDriver driver) { //clean global configuration before ExecuteOneScenario var jp = new JsonParser(); Boolean res = jp.AddConfigToMemory(""); //init test status count var testStatus = new Dictionary <string, int>(); if (testStatus.ContainsKey("PassedTests")) { testStatus["PassedTests"] = 0; } else { testStatus.Add("PassedTests", 0); } if (testStatus.ContainsKey("FailedTests")) { testStatus["FailedTests"] = 0; } else { testStatus.Add("FailedTests", 0); } if (testStatus.ContainsKey("TotalTests")) { testStatus["TotalTests"] = 0; } else { testStatus.Add("TotalTests", 0); } try { if (scenarioId == string.Empty) { MessageBox.Show("Select Scenario first", "Applenium"); return(false); } _flowId = Convert.ToInt32(scenarioId); var sql = new Sql(); DataTable dtScenario = sql.GetDataTable(Constants.StrScenarioTestsToSelenium, scenarioId); var adapterScenario = new ScenarioTableAdapter(); _projectId = Convert.ToInt32(adapterScenario.GetProjectID(_flowId)); _scenarioname = adapterScenario.GetScenarioName(_flowId); string scenariodescription = adapterScenario.GetScenarioDescription(_flowId); if (guiInstance != null && isBatchRun == false) { guiInstance.UpdateProgressLabel(_scenarioname, _testname, Constants.UpdateProgress_REGULAR); } LogObject logObject = new LogObject(); logObject.Description = "-------------------------------------------------------------------------------------------------------------\n" + "\t\t\t\t\t\t\t\t\t\t" + _scenarioname + " Scenario Started\n-------------------------------------------------------------------------------------------------------------\n"; logObject.StatusTag = Constants.INFO; logger.Print(logObject); // AppleniumLogger.LogResult(string.Empty, //"-------------------------------------------------------------------------------------------------------------\n" + "\t\t\t\t\t\t\t\t\t\t" + scenarioname + " Scenario Started\n-------------------------------------------------------------------------------------------------------------\n", Constants.Info, null); LogObject logObject2 = new LogObject(); logObject2.ExecutionID = _runExecutionId; logObject2.BatchID = _batchId; logObject2.BatchName = _batchname; logObject2.ProjectName = _projectName; logObject2.ScenarioID = _flowId; logObject2.ScenarioStatus = Constants.PROGRESS_STARTED; logObject2.StatusTag = Constants.DONE; logObject2.Description = Constants.LogScenarioStatus + "=" + Constants.PROGRESS_STARTED; logger.Print(logObject2); Singleton myInstance = Singleton.Instance; // Will always be the same instance... bool scenarioresult = true; LogObject result = new LogObject(); foreach (DataRow row in dtScenario.Rows) { // Check if we got a warning message, if we did skip all tests in the scenario if (Applenium._4____Infrustructure.Utilities.skipSCN == true) { break; } if (myInstance.StopExecution) { scenarioresult = false; break; } string testId = row["GuiTestID"].ToString(); bool testresult = ExecuteOneTest(testId, row["InputDataRow"].ToString(), driver, ref testStatus); if (testresult == false) { scenarioresult = false; } } string description; if (scenarioresult == true && Applenium._4____Infrustructure.Utilities.skipSCN == false) { description = String.Format("{0}={1}", Constants.LogScenarioStatus, "Passed"); result.ScenarioStatus = Constants.PROGRESS_PASSED; result.StatusTag = Constants.PASSED; } else if (scenarioresult == false && Applenium._4____Infrustructure.Utilities.skipSCN == false) { result.ScenarioStatus = Constants.PROGRESS_FAILED; result.StatusTag = Constants.FAILED; } else if (scenarioresult == true && Applenium._4____Infrustructure.Utilities.skipSCN == true) { scenarioresult = true; result.StatusTag = Constants.DEBUG; } result.ExecutionID = _runExecutionId; result.BatchID = _batchId; result.BatchName = _batchname; result.ScenarioID = _flowId; result.ScnearioName = _scenarioname; result.ProjectName = _projectName; result.ProjectID = _projectId; result.ProjectPageID = _projectPageId; result.BatchName = _batchname; result.Description = scenariodescription + " | PassedTest=" + testStatus["PassedTests"] + " | FailedTest=" + testStatus["FailedTests"] + " | TotalTest=" + testStatus["TotalTests"]; result.ProjectID = _projectId; result.Browser = _browserName; logger.Print(result); Applenium._4____Infrustructure.Utilities.skipSCN = false; return(scenarioresult); } catch (Exception exception) { LogObject logObject3 = new LogObject(); logObject3.Exception = exception; logObject3.StatusTag = Constants.ERROR; logObject3.Description = exception.Message; logger.Print(logObject3); return(false); } }
internal bool ExecuteOneTest(string testId, string inputDataRow, RemoteWebDriver driver, ref Dictionary <string, int> testStatus) { try { if (testId == string.Empty) { MessageBox.Show("Select test first", "Applenium"); return(false); } if (testStatus.ContainsKey("TotalTests")) { testStatus["TotalTests"] = testStatus["TotalTests"] + 1; } else { testStatus.Add("TotalTests", 1); } var sql = new Sql(); DataTable dt = sql.GetDataTable(Constants.StrTestStepsToSelenium, testId); bool testresult = true; bool recursivetestresult = true; var adapterGuiproject = new GuiProjectPageTableAdapter(); var adapterTest = new TestTableAdapter(); var adapteGuiPageSection = new GuiPageSectionTableAdapter(); _testname = adapterTest.GetTestName(Convert.ToInt32(testId)); if (guiInstance != null) { guiInstance.UpdateProgressLabel(_scenarioname, _testname, Constants.UpdateProgress_REGULAR); } LogObject logObject = new LogObject(); logObject.Description = "*-------------------------------------------------------------------------------------------------------------\n" + "\t\t\t\t\t\t\t\t\t\t" + _testname + " Test Started\n-------------------------------------------------------------------------------------------------------------\n"; logObject.StatusTag = Constants.INFO; logger.Print(logObject); LogObject loggg = new LogObject(); loggg.StepName = _stepname; loggg.ExecutionID = _runExecutionId; loggg.TestStatus = Constants.PROGRESS_STARTED; loggg.TestName = _testname; loggg.Description = Constants.LogTestName + "=" + Constants.PROGRESS_STARTED; loggg.ScnearioName = _scenarioname; loggg.ProjectName = _projectName; loggg.BatchName = _batchname; loggg.Parameter1 = inputDataRow; loggg.StatusTag = Constants.DONE; loggg.Exception = null; logger.Print(loggg); var jp = new JsonParser(); string skipTestOnStepFail = Constants.MemoryConf["SkipTestOnStepFail"]; Singleton myInstance = Singleton.Instance; // Will always be the same instance... if (inputDataRow != null) { if (inputDataRow.IndexOf("rand", 0, StringComparison.Ordinal) >= 0) { if (inputDataRow.IndexOf("-", 0, StringComparison.Ordinal) >= 0) { string[] rows = inputDataRow.Split('-', '(', ')'); //get rundom number Random random = new Random(); int rownumber = random.Next(Convert.ToInt32(rows[1]), Convert.ToInt32(rows[2])); testresult = ExecuteOneTest(testId, rownumber.ToString(), driver, ref testStatus); if (testresult == false) { recursivetestresult = false; } return(recursivetestresult); } } if (inputDataRow.IndexOf("-", 0, StringComparison.Ordinal) >= 0) { string[] rows = inputDataRow.Split('-'); for (int i = Convert.ToInt32(rows[0].ToString(CultureInfo.InvariantCulture)); i <= Convert.ToInt32(rows[1].ToString(CultureInfo.InvariantCulture)); i++) { testresult = ExecuteOneTest(testId, i.ToString(CultureInfo.InvariantCulture), driver, ref testStatus); if (testresult == false) { recursivetestresult = false; } } return(recursivetestresult); } if (inputDataRow.IndexOf(",", 0, StringComparison.Ordinal) >= 0) { string[] rows = inputDataRow.Split(','); foreach (string key in rows) { testresult = ExecuteOneTest(testId, key, driver, ref testStatus); if (testresult == false) { recursivetestresult = false; } } return(recursivetestresult); } foreach (DataRow testrow in dt.Rows) { testrow["InputDataRow"] = inputDataRow; } } foreach (DataRow row in dt.Rows) { if (myInstance.StopExecution) { testresult = false; break; } bool stepresult = ExecuteStep(row, driver); if (stepresult == false) { testresult = false; if (skipTestOnStepFail == "yes") { LogObject logObject2 = new LogObject(); logObject2.Description = "Previous Step is Failed => TestStatus=Skiped moving to next test"; logObject2.StatusTag = Constants.ERROR; logObject2.ExecutionID = _runExecutionId; logObject2.Exception = null; logger.Print(logObject2); break; } } } adapterTest.GetTestName(Convert.ToInt32(testId)); int projectPageSectionId = Convert.ToInt32(adapterTest.GetPageSectionID(Convert.ToInt32(Convert.ToInt32(testId)))); _projectPageId = Convert.ToInt32(adapteGuiPageSection.GetGuiPageID(projectPageSectionId)); _projectId = Convert.ToInt32(adapterGuiproject.GetProjectID(_projectPageId)); LogObject logObject3 = new LogObject(); if (testresult) { //description = string.Format("{0}={1}", Constants.LogTestStatus, "Passed"); //status = Constants.Passed; logObject3.TestStatus = Constants.PROGRESS_PASSED; logObject3.StatusTag = Constants.PASSED; if (testStatus.ContainsKey("PassedTests")) { testStatus["PassedTests"] = testStatus["PassedTests"] + 1; } else { testStatus.Add("PassedTests", 1); } } else { logObject3.TestStatus = Constants.PROGRESS_FAILED; logObject3.Description = _testname + " has failed"; logObject3.StatusTag = Constants.FAILED; if (testStatus.ContainsKey("FailedTests")) { testStatus["FailedTests"] = testStatus["FailedTests"] + 1; } else { testStatus.Add("FailedTests", 1); } } logObject3.Parameter1 = ""; logObject3.Parameter2 = ""; logObject3.Snapshot = ss; logObject3.BatchID = _batchId; logObject3.ScenarioID = _flowId; logObject3.TestID = Convert.ToInt32(testId); logObject3.TestName = _testname; logObject3.ScnearioName = _scenarioname; logObject3.BatchName = _batchname; logObject3.StepID = -1; logObject3.ExecutionID = _runExecutionId; logObject3.ProjectPageID = _projectPageId; logObject3.ProjectName = _projectName; logObject3.ProjectID = _projectId; logger.Print(logObject3); //AppleniumLogger.LogResult(_runExecutionId, _batchId, _flowId, Convert.ToInt32(testId), 0, description + " with DataRow=" + inputDataRow, status, "0", _projectId, _projectPageId); return(testresult); } catch (Exception exception) { LogObject logObject4 = new LogObject(); logObject4.Description = exception.Message; logObject4.CommandName = string.Empty; logObject4.StatusTag = Constants.EXECPTION; logObject4.Exception = exception; logger.Print(logObject4); //AppleniumLogger.LogResult(string.Empty,exception.Message, Constants.Error, exception); return(false); } }
public static TResult TryPostJson <TResult>(string url, string headers, string postData, int timeOut = 60000) { TResult result = default(TResult); string responseJson = string.Empty; HttpWebResponse response = null; Stream requestStream = null; HttpWebRequest request = null; try { request = (HttpWebRequest)WebRequest.Create(url); request.Method = "POST"; request.Timeout = timeOut; request.ContentType = "application/x-www-form-urlencoded"; request.Headers["Authorization"] = headers; //request.Accept = "application/json, text/javascript, */*; q=0.01"; byte[] data = Encoding.UTF8.GetBytes(postData); request.ContentLength = data.Length; requestStream = request.GetRequestStream(); requestStream.Write(data, 0, data.Length); requestStream.Close(); response = (HttpWebResponse)request.GetResponse(); requestStream = response.GetResponseStream(); if (requestStream != null) { using (var reader = new StreamReader(requestStream)) { responseJson = reader.ReadToEnd(); } } result = Serializer.Deserialize <TResult>(responseJson); } catch (Exception exception) { LogObject logException = new LogObject(); logException.Description = string.Format("Failed to PostJson from url: {0}, exeption: {1}", url, exception); logException.StatusTag = Constants.ERROR; logException.Exception = exception; logger.Print(logException); } finally { if (request != null) { request.Abort(); } if (response != null) { response.Close(); } if (requestStream != null) { requestStream.Close(); requestStream.Dispose(); } } return(result); }