/// <summary> /// 初始化同步对象 /// </summary> internal void InitSynchObject() { if (asyncTaskResult == null) { asyncTaskResult = new AsyncTaskResult(null, null); } }
void RestoreSessionCallback(AsyncTaskResult result) { CloseProgressDialog(); try { result.CheckException(); if (viewModel.BoxSessionEnabled && viewModel.HasValidFolderTree) { // 復元できたならば、その BoxSession を用いて Upload を開始します。 ShowConfirmUploadDialog(); } else { // 設定が存在しない、あるいは、設定にあるフォルダ情報が無効な場合は、 // それらを設定するために BoxSetupWizardDialog を表示します。 ShowBoxSetupWizardDialog(); } } catch (Exception e) { ShowErrorDialog(Strings.BoxConnectionFailedMessage); Console.WriteLine(e.Message); } }
public static string GetErrorMessage(this AsyncTaskResult <CommandResult> result) { if (result.Status != AsyncTaskStatus.Success || result.Data.Status == CommandStatus.Failed) { return(result.ErrorMessage); } return(null); }
public static string GetErrorMessage(this AsyncTaskResult result) { if (result.Status != AsyncTaskStatus.Success) { return(result.ErrorMessage); } return(null); }
public static bool IsSuccess(this AsyncTaskResult result) { if (result.Status != AsyncTaskStatus.Success) { return(false); } return(true); }
public static bool IsSuccess(this AsyncTaskResult <CommandResult> result) { if (result.Status != AsyncTaskStatus.Success || result.Data.Status == CommandStatus.Failed) { return(false); } return(true); }
private async Task <AsyncTaskResult> SendRequestAppUpdateToHpssServer() { var result = new AsyncTaskResult(null, MessageAsyncTaskResult.Non); try { ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; var endPoint = new Uri(HPSS_REQUEST_APP_UPDATE_ENDPOINT); HPSSBodyRequest request = new HPSSBodyRequest(); var data = JsonConvert.SerializeObject(new { ProductID = AppInfoVO.ProductID, Company = AppInfoVO.Company, Description = AppInfoVO.Description, ProductName = AppInfoVO.ProductName, ProductVersion = AppInfoVO.ProductVersion, ReleaseDate = AppInfoVO.ReleaseDate, }); var httpContent = new StringContent(data); //need this to authorize customer httpContent.Headers.Add("x-functions-key", HPSS_REQUEST_APP_UPDATE_FUNCTION_KEY); httpContent.Headers.Add("hpss-request-id", HPSSCustomerServiceDefinitions.HPSS_PHARMACY_CHECK_APP_UPDATE); HttpClient client = new HttpClient(); client.Timeout = TimeSpan.FromSeconds(10); Logger.I($"Start a http connection: Endpoint = {endPoint}, Content = {data}"); var response = await client.PostAsync(endPoint, httpContent); response.EnsureSuccessStatusCode(); string responseBody = await response.Content.ReadAsStringAsync(); result.Result = responseBody; result.MesResult = MessageAsyncTaskResult.Done; response.Dispose(); } catch (Exception e) { Logger.E(e.Message); result.Messsage = e.Message; result.MesResult = MessageAsyncTaskResult.Aborted; } finally { } return(result); }
public async Task <string> BindUserProfile(UserProfileInput input) { ValidationResult validationResult = _userProfileInputValidator.Validate(input); if (!validationResult.IsValid) { throw new LotteryDataException(validationResult.Errors.Select(p => p.ErrorMessage).ToList().ToString(";")); } var validIdentifyCodeOutput = _identifyCodeAppService.ValidIdentifyCode(input.Profile, input.Identifycode); if (validIdentifyCodeOutput.IsOvertime) { await SendCommandAsync(new InvalidIdentifyCodeCommand(validIdentifyCodeOutput.IdentifyCodeId, input.Profile, _lotterySession.UserId)); throw new LotteryDataException("验证码超时,请重新获取验证码"); } if (!validIdentifyCodeOutput.IsValid) { // await SendCommandAsync(new InvalidIdentifyCodeCommand(validIdentifyCodeOutput.IdentifyCodeId, user.Account, _lotterySession.UserId)); throw new LotteryDataException("您输入的验证码错误,请重新输入"); } await SendCommandAsync(new InvalidIdentifyCodeCommand(validIdentifyCodeOutput.IdentifyCodeId, input.Profile, _lotterySession.UserId)); var isReg = await _userManager.IsExistAccount(input.Profile); if (isReg) { throw new LotteryDataException("已经存在该账号,不允许被绑定"); } var validPwdResult = await _userManager.VerifyPassword(input.Password, input.Password); if (!validPwdResult) { throw new LotteryDataException("密码错误"); } AsyncTaskResult result = null; if (input.ProfileType == AccountRegistType.Email) { var bindUserEmailCommand = new BindUserEmailCommand(_lotterySession.UserId, input.Profile); result = await SendCommandAsync(bindUserEmailCommand); } else if (input.ProfileType == AccountRegistType.Phone) { var bindUserPhoneCommand = new BindUserPhoneCommand(_lotterySession.UserId, input.Profile); result = await SendCommandAsync(bindUserPhoneCommand); } Debug.Assert(result != null, "result != null"); if (result.Status == AsyncTaskStatus.Success) { return("用户信息绑定成功"); } throw new LotteryDataException("绑定失败"); }
public async Task ShouldRunTask() { //arrange var taskRunner = TaskRunner.Instance; const string expectedResult = "Test string"; var task = new AsyncTaskResult <string>(() => expectedResult); //action taskRunner.AddTask(task); var actualResult = await task.GetResultAsync(); //assert Assert.That(actualResult, Is.EqualTo(expectedResult)); }
void SaveSettingsCallback(AsyncTaskResult result) { CloseProgressDialog(); try { result.CheckException(); ShowFinishTabItem(); } catch (Exception e) { HandleWebException(e); } }
void PrepareFolderTreeCallback(AsyncTaskResult result) { CloseProgressDialog(); try { result.CheckException(); ShowSaveSettingsTabItem(); } catch (Exception e) { HandleWebException(e); } }
void AccessAccountCallback(AsyncTaskResult result) { CloseProgressDialog(); try { result.CheckException(); ShowCreateFolderTabItem(); } catch (Exception e) { HandleWebException(e); } }
void GetTicketCallback(AsyncTaskResult result) { CloseProgressDialog(); try { result.CheckException(); ShowAuthorizationTabItem(); } catch (Exception e) { HandleWebException(e); } }
void UploadDemoContentsCallback(AsyncTaskResult result) { CloseProgressDialog(); try { result.CheckException(); ShowUploadedDialog(); } catch (Exception e) { ShowErrorDialog(Strings.UploadDemoBlocksToBoxFailedMessage); Console.WriteLine(e.Message); } }
public async Task ShouldReturnTaskResult() { //arrange const string expectedResult = "task result"; var funcMock = new Mock <Func <string> >(); var task = new AsyncTaskResult <string>(funcMock.Object); funcMock.Setup(f => f()).Returns(expectedResult); //action task.Run(); var actualResult = await task.GetResultAsync(); //assert Assert.That(actualResult, Is.EqualTo(expectedResult)); }
public async Task WhenPreviousTaskThrowExceptionNextTaskShouldBeExcuted() { //arrange var taskRunner = TaskRunner.Instance; var task = new AsyncTaskResult <string>(() => throw new NullReferenceException()); const string expectedResult = "Test string"; var secondTask = new AsyncTaskResult <string>(() => expectedResult); taskRunner.AddTask(task); taskRunner.AddTask(secondTask); //action var actualResult = await secondTask.GetResultAsync(); //assert Assert.That(actualResult, Is.EqualTo(expectedResult)); }
public async Task <ActionResult> Create(CreateReplyModel model) { AsyncTaskResult <CommandResult> asyncTaskResult = await _commandService.ExecuteAsync( new CreateReplyCommand( model.PostId, model.ParentId, model.Body, _contextService.CurrentAccount.AccountId), CommandReturnType.EventHandled); var result = asyncTaskResult.Data; if (result.Status == CommandStatus.Failed) { return(Json(new { success = false, errorMsg = result.ErrorMessage })); } return(Json(new { success = true })); }
public async Task <ActionResult> Update(EditPostModel model) { if (model.AuthorId != _contextService.CurrentAccount.AccountId) { return(Json(new { success = false, errorMsg = "您不是帖子的作者,不能编辑该帖子。" })); } AsyncTaskResult <CommandResult> asyncTaskResult = await _commandService.ExecuteAsync(new UpdatePostCommand(model.Id, model.Subject, model.Body), CommandReturnType.EventHandled); var result = asyncTaskResult.Data; if (result.Status == CommandStatus.Failed) { return(Json(new { success = false, errorMsg = result.ErrorMessage })); } return(Json(new { success = true })); }
public async Task <ActionResult> Update(EditSectionModel model) { if (_contextService.CurrentAccount.AccountName != "admin") { return(Json(new { success = false, errorMsg = "只有系统管理员才能修改版块。" })); } AsyncTaskResult <CommandResult> asyncTaskResult = await _commandService.ExecuteAsync(new ChangeSectionNameCommand(model.Id, model.Name), CommandReturnType.EventHandled); var result = asyncTaskResult.Data; if (result.Status == CommandStatus.Failed) { return(Json(new { success = false, errorMsg = result.ErrorMessage })); } return(Json(new { success = true })); }
/// <summary> /// 设置异步调用的回调函数和传递的对象。 /// </summary> /// <param name="asyncCallback">异步回调对象</param> /// <param name="state">传递的对象</param> /// <param name="timeout">执行任务的时限毫秒(值为-1表示无限时),若超时将调用asyncCallback的回调函数。</param> internal void AsyncInvokeSetup(AsyncCallback asyncCallback, object state, int timeout) { // 添加后面这个判断是怕应用程序开发员将一个已经执行了的异步任务再此执行异步任务,并更改了回调函数。 if (asyncTaskResult == null || !asyncTaskResult.AsyncCallbackObjEquals(asyncCallback)) { asyncTaskResult = new AsyncTaskResult(asyncCallback, state); } asyncTaskTimeouts = timeout; //Hungry mode if (NetworkConstants.WAIT_FOR_COMPLETE != asyncTaskTimeouts) { asyncTaskStopwatch = Stopwatch.StartNew(); } else { asyncTaskStopwatch = null; } }
public void GetResultAsyncShouldThrowExceptionWhenFuncThrowsToo() { //arrange var exception = new NullReferenceException(); var funcMock = new Mock <Func <string> >(); var task = new AsyncTaskResult <string>(funcMock.Object); funcMock.Setup(f => f()).Throws(exception); //action task.Run(); async Task GetResult() { await task.GetResultAsync(); } //assert Assert.ThrowsAsync <NullReferenceException>(GetResult); }
private static ITask CreateTask() { var rnd = new Random(); var typeIndex = rnd.Next(0, 10) % 2; ITask task; if (typeIndex == 0) { task = new ActionTask(DoSomething); } else { task = new AsyncTaskResult <string>(DoSomethingWithResult); } var index = Interlocked.Increment(ref _taskCounter); task.Name = "Task " + index; task.Success += TaskSuccess; return(task); }
private async Task <AsyncTaskResult> OpenBrowserToHPSSContactEndpoint() { var result = new AsyncTaskResult(null, MessageAsyncTaskResult.Non); try { await Task.Delay(1000); Process.Start(HPSS_CONTACT_MESSENGER_ENDPOINT); } catch (Exception e) { Logger.E(e.Message); App.Current.ShowApplicationMessageBox("Trình duyệt hiện tại không được hỗ trợ!", HPSolutionCCDevPackage.netFramework.AnubisMessageBoxType.Default, HPSolutionCCDevPackage.netFramework.AnubisMessageImage.Error, OwnerWindow.MainScreen, "Lỗi!"); } return(result); }
private void RequestSaveBugReportCallback(AsyncTaskResult result) { SetCompleteFlagAfterExecuteCommand(); BRPViewModel.ButtonCommandOV.IsSendReportButtonRunning = false; BRPViewModel.UploadVOCAlertTextVisibility = System.Windows.Visibility.Hidden; if (result.MesResult == MessageAsyncTaskResult.Done) { App.Current.ShowApplicationMessageBox(result.Messsage, HPSolutionCCDevPackage.netFramework.AnubisMessageBoxType.Default, HPSolutionCCDevPackage.netFramework.AnubisMessageImage.Success, OwnerWindow.Default, "Thông báo!"); } else { App.Current.ShowApplicationMessageBox(result.Messsage, HPSolutionCCDevPackage.netFramework.AnubisMessageBoxType.Default, HPSolutionCCDevPackage.netFramework.AnubisMessageImage.Error, OwnerWindow.Default, "Lỗi!"); } }
public async Task ShouldExecutesAllTasks() { //arrange var taskRunner = TaskRunner.Instance; const int expectedTaskCount = 100; var actualCompletedTaskCount = 0; var tasks = new Task[expectedTaskCount]; //action for (var i = 0; i < expectedTaskCount; i++) { var task = new AsyncTaskResult <string>(() => { actualCompletedTaskCount++; return("test string"); }); taskRunner.AddTask(task); tasks[i] = task.GetResultAsync(); } await Task.WhenAll(tasks); //assert Assert.That(actualCompletedTaskCount, Is.EqualTo(expectedTaskCount)); }
private async Task <AsyncTaskResult> SendRequestSaveBugReportToHpssServer() { var result = new AsyncTaskResult(null, MessageAsyncTaskResult.Non); try { ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; var endPoint = new Uri(HPSS_REQUEST_UPLOAD_VOC_ENDPOINT); var data = JsonConvert.SerializeObject(new { UserName = BRPViewModel.UserInfoOV.FullNameText, Email = BRPViewModel.UserInfoOV.EmailText, Address = BRPViewModel.UserInfoOV.AddressText, Phone = BRPViewModel.UserInfoOV.PhoneText, ProductID = BRPViewModel.ProductInfoOV.ProdIDText, ProductVersion = BRPViewModel.ProductInfoOV.ProdVersionText, IncidentTime = BRPViewModel.IssueInfoOV.IncidentTimeText, IssueDetail = BRPViewModel.IssueInfoOV.IssueDetailText, IssueTitle = BRPViewModel.IssueInfoOV.IssueTitleText, }); MultipartFormDataContent form = new MultipartFormDataContent(); form.Add(new StringContent(data), "other-data"); var logFileStream = new FileStream(BRPViewModel.IssueInfoOV.LogPathText, FileMode.Open); form.Add(new StreamContent(logFileStream), "log_file.txt", logFileStream.Name); if (!String.IsNullOrEmpty(BRPViewModel.IssueInfoOV.VideoPathText)) { var attachedFileStream = new FileStream(BRPViewModel.IssueInfoOV.VideoPathText, FileMode.Open); var fileNameParts = BRPViewModel.IssueInfoOV.VideoPathText.Split('.'); form.Add(new StreamContent(attachedFileStream), "attached_file." + fileNameParts[fileNameParts.Length - 1], logFileStream.Name); } //need this to authorize customer form.Headers.Add("x-functions-key", HPSS_REQUEST_UPLOAD_VOC_FUNCTION_KEY); form.Headers.Add("hpss-request-id", HPSSCustomerServiceDefinitions.HPSS_PHARMACY_UPLOAD_VOC_FILE); HttpClient client = new HttpClient(); Logger.I($"Start a http connection: Endpoint = {endPoint}, Content = {data}"); BRPViewModel.UploadVOCAlertTextVisibility = System.Windows.Visibility.Visible; var response = await client.PostAsync(endPoint, form); response.EnsureSuccessStatusCode(); string responseBody = await response.Content.ReadAsStringAsync(); var message = JObject.Parse(responseBody)["message"].ToString(); Logger.I($"Response from server: status code = {response.StatusCode}"); result.Result = responseBody; result.Messsage = message; result.MesResult = MessageAsyncTaskResult.Done; response.Dispose(); } catch (Exception e) { Logger.E(e.Message); result.Messsage = e.Message; result.MesResult = MessageAsyncTaskResult.Aborted; } finally { } return(result); }
/// <summary> /// Create a new result arguments object from the provided information /// </summary> /// <param name="result">The final status of the task</param> /// <param name="message">Optional. A display message to complement the result.</param> public AsyncTaskResultEventArgs(AsyncTaskResult result, string message) { Result = result; Message = message; }
/// <summary> /// Create a new result arguments object from the provided information /// </summary> /// <param name="result">The final status of the task</param> /// <param name="message">Optional. A display message to complement the result.</param> /// <param name="exception">Optional. An exception object to allow the caller to do its own interpretation of an exception.</param> public AsyncTaskResultEventArgs(AsyncTaskResult result, string message, Exception exception) { Result = result; Message = message; Exception = exception; }
/// <summary> /// Create a new result arguments object from the provided information /// </summary> /// <param name="fileSize">The number of bytes in the package, if sent succesfully.</param> /// <param name="result">The final status of the task</param> /// <param name="message">Optional. A display message to complement the result.</param> /// <param name="exception">Optional. An exception object to allow the caller to do its own interpretation of an exception.</param> public PackageSendEventArgs(int fileSize, AsyncTaskResult result, string message, Exception exception) : base(result, message, exception) { FileSize = fileSize; }
/// <summary> /// The Get Task Status returns the status of the specified task id. /// After calling an asynchronous task, you can call Get Task Status /// to determine whether the task has succeeded, failed, or is still /// in progress. /// </summary> /// <param name='taskId'> /// Required. The task Id for the request you wish to track. /// </param> /// <param name='cancellationToken'> /// Cancellation token. /// </param> /// <returns> /// Info about the async task /// </returns> public async Task <TaskStatusInfo> GetOperationStatusAsync(string taskId, CancellationToken cancellationToken) { // Validate if (taskId == null) { throw new ArgumentNullException("taskId"); } // Tracing bool shouldTrace = TracingAdapter.IsEnabled; string invocationId = null; if (shouldTrace) { invocationId = TracingAdapter.NextInvocationId.ToString(); Dictionary <string, object> tracingParameters = new Dictionary <string, object>(); tracingParameters.Add("taskId", taskId); TracingAdapter.Enter(invocationId, this, "GetOperationStatusAsync", tracingParameters); } // Construct URL string url = ""; url = url + "/"; if (this.Credentials.SubscriptionId != null) { url = url + Uri.EscapeDataString(this.Credentials.SubscriptionId); } url = url + "/cloudservices/"; url = url + Uri.EscapeDataString(this.CloudServiceName); url = url + "/resources/"; url = url + Uri.EscapeDataString(this.ResourceNamespace); url = url + "/~/"; url = url + "CisVault"; url = url + "/"; url = url + Uri.EscapeDataString(this.ResourceName); url = url + "/api/jobs/"; url = url + Uri.EscapeDataString(taskId); List <string> queryParameters = new List <string>(); queryParameters.Add("api-version=2014-01-01.1.0"); if (queryParameters.Count > 0) { url = url + "?" + string.Join("&", queryParameters); } string baseUrl = this.BaseUri.AbsoluteUri; // Trim '/' character from the end of baseUrl and beginning of url. if (baseUrl[baseUrl.Length - 1] == '/') { baseUrl = baseUrl.Substring(0, baseUrl.Length - 1); } if (url[0] == '/') { url = url.Substring(1); } url = baseUrl + "/" + url; url = url.Replace(" ", "%20"); // Create HTTP transport objects HttpRequestMessage httpRequest = null; try { httpRequest = new HttpRequestMessage(); httpRequest.Method = HttpMethod.Get; httpRequest.RequestUri = new Uri(url); // Set Headers httpRequest.Headers.Add("Accept", "application/xml"); httpRequest.Headers.Add("x-ms-version", "2014-01-01"); // Set Credentials cancellationToken.ThrowIfCancellationRequested(); await this.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); // Send Request HttpResponseMessage httpResponse = null; try { if (shouldTrace) { TracingAdapter.SendRequest(invocationId, httpRequest); } cancellationToken.ThrowIfCancellationRequested(); httpResponse = await this.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false); if (shouldTrace) { TracingAdapter.ReceiveResponse(invocationId, httpResponse); } HttpStatusCode statusCode = httpResponse.StatusCode; if (statusCode != HttpStatusCode.OK) { cancellationToken.ThrowIfCancellationRequested(); CloudException ex = CloudException.Create(httpRequest, null, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false)); if (shouldTrace) { TracingAdapter.Error(invocationId, ex); } throw ex; } // Create Result TaskStatusInfo result = null; // Deserialize Response if (statusCode == HttpStatusCode.OK) { cancellationToken.ThrowIfCancellationRequested(); string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); result = new TaskStatusInfo(); XDocument responseDoc = XDocument.Parse(responseContent); XElement jobStatusInfoElement = responseDoc.Element(XName.Get("JobStatusInfo", "http://windowscloudbackup.com/CiS/V2013_03")); if (jobStatusInfoElement != null) { XElement jobIdElement = jobStatusInfoElement.Element(XName.Get("JobId", "http://windowscloudbackup.com/CiS/V2013_03")); if (jobIdElement != null) { string jobIdInstance = jobIdElement.Value; result.TaskId = jobIdInstance; } XElement statusElement = jobStatusInfoElement.Element(XName.Get("Status", "http://windowscloudbackup.com/CiS/V2013_03")); if (statusElement != null) { AsyncTaskStatus statusInstance = ((AsyncTaskStatus)Enum.Parse(typeof(AsyncTaskStatus), statusElement.Value, true)); result.Status = statusInstance; } XElement resultElement = jobStatusInfoElement.Element(XName.Get("Result", "http://windowscloudbackup.com/CiS/V2013_03")); if (resultElement != null) { AsyncTaskResult resultInstance = ((AsyncTaskResult)Enum.Parse(typeof(AsyncTaskResult), resultElement.Value, true)); result.Result = resultInstance; } XElement errorElement = jobStatusInfoElement.Element(XName.Get("Error", "http://windowscloudbackup.com/CiS/V2013_03")); if (errorElement != null) { ErrorDetails errorInstance = new ErrorDetails(); result.Error = errorInstance; XElement codeElement = errorElement.Element(XName.Get("Code", "http://schemas.microsoft.com/wars")); if (codeElement != null) { string codeInstance = codeElement.Value; errorInstance.Code = codeInstance; } XElement messageElement = errorElement.Element(XName.Get("Message", "http://schemas.microsoft.com/wars")); if (messageElement != null) { string messageInstance = messageElement.Value; errorInstance.Message = messageInstance; } } XElement taskResultElement = jobStatusInfoElement.Element(XName.Get("TaskResult", "http://windowscloudbackup.com/CiS/V2013_03")); if (taskResultElement != null) { AsyncTaskAggregatedResult taskResultInstance = ((AsyncTaskAggregatedResult)Enum.Parse(typeof(AsyncTaskAggregatedResult), taskResultElement.Value, true)); result.AsyncTaskAggregatedResult = taskResultInstance; } XElement jobStepsSequenceElement = jobStatusInfoElement.Element(XName.Get("JobSteps", "http://windowscloudbackup.com/CiS/V2013_03")); if (jobStepsSequenceElement != null) { foreach (XElement jobStepsElement in jobStepsSequenceElement.Elements(XName.Get("JobStep", "http://windowscloudbackup.com/CiS/V2013_03"))) { TaskStep jobStepInstance = new TaskStep(); result.TaskSteps.Add(jobStepInstance); XElement messageElement2 = jobStepsElement.Element(XName.Get("Message", "http://windowscloudbackup.com/CiS/V2013_03")); if (messageElement2 != null) { string messageInstance2 = messageElement2.Value; jobStepInstance.Message = messageInstance2; } XElement statusElement2 = jobStepsElement.Element(XName.Get("Status", "http://windowscloudbackup.com/CiS/V2013_03")); if (statusElement2 != null) { AsyncTaskStatus statusInstance2 = ((AsyncTaskStatus)Enum.Parse(typeof(AsyncTaskStatus), statusElement2.Value, true)); jobStepInstance.Status = statusInstance2; } XElement resultElement2 = jobStepsElement.Element(XName.Get("Result", "http://windowscloudbackup.com/CiS/V2013_03")); if (resultElement2 != null) { AsyncTaskResult resultInstance2 = ((AsyncTaskResult)Enum.Parse(typeof(AsyncTaskResult), resultElement2.Value, true)); jobStepInstance.Result = resultInstance2; } XElement detailElement = jobStepsElement.Element(XName.Get("Detail", "http://windowscloudbackup.com/CiS/V2013_03")); if (detailElement != null) { string detailInstance = detailElement.Value; jobStepInstance.Detail = detailInstance; } XElement errorCodeElement = jobStepsElement.Element(XName.Get("ErrorCode", "http://windowscloudbackup.com/CiS/V2013_03")); if (errorCodeElement != null) { string errorCodeInstance = errorCodeElement.Value; jobStepInstance.ErrorCode = errorCodeInstance; } } } } } result.StatusCode = statusCode; if (httpResponse.Headers.Contains("x-ms-request-id")) { result.RequestId = httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); } if (shouldTrace) { TracingAdapter.Exit(invocationId, result); } return(result); } finally { if (httpResponse != null) { httpResponse.Dispose(); } } } finally { if (httpRequest != null) { httpRequest.Dispose(); } } }