OnLogicalLogClose(LogicalLog ToClose, CancellationToken cancellationToken) { await _Lock.WaitUntilSetAsync(cancellationToken).ConfigureAwait(false); try { PhysicalLog handleOwner = null; ReleaseAssert.AssertIfNot(_Logs.TryGetValue(ToClose.OwnerId, out handleOwner), "_Logs index is inconsistent"); if (await handleOwner.OnCloseLogicalLog(ToClose, cancellationToken).ConfigureAwait(false)) { // last handle or logical log closed on the PhysicalLog, removed from this index _Logs.Remove(ToClose.OwnerId); if ((_Handles.Count == 0) && (_Logs.Count == 0)) { var m = _AppDomainPhysLogManager; _AppDomainPhysLogManager = null; await m.CloseAsync(cancellationToken).ConfigureAwait(false); } } } finally { _Lock.Set(); } }
public async Task <IActionResult> Edit(int id, [Bind("Id,DateTime,PersonId,BodyWeight,Waist,BodyFat")] PhysicalLog physicalLog) { if (id != physicalLog.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(physicalLog); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PhysicalLogExists(physicalLog.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(ListPhysicalLogs))); } ViewData["PersonId"] = new SelectList(_context.Set <Person>(), "Id", "FullName", physicalLog.PersonId); return(View(physicalLog)); }
Handle(PhysicalLog owner, long handleId) { this._Owner = owner; this._OwnerId = owner.Id; this._HandleId = handleId; this.IsOpen = false; }
public async Task <IActionResult> Create([Bind("Id,DateTime,PersonId,BodyWeight,Waist,BodyFat")] PhysicalLog physicalLog) { if (ModelState.IsValid) { _context.Add(physicalLog); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(ListPhysicalLogs))); } ViewData["PersonId"] = new SelectList(_context.Set <Person>(), "Id", "FullName", physicalLog.PersonId); return(View(physicalLog)); }
OnPhysicalLogHandleClose(PhysicalLog.Handle ToClose, CancellationToken cancellationToken) { await _Lock.WaitUntilSetAsync(cancellationToken).ConfigureAwait(false); try { PhysicalLog handleOwner = null; ReleaseAssert.AssertIfNot(_Logs.TryGetValue(ToClose.OwnerId, out handleOwner), "_Logs index is inconsistent"); if (await handleOwner.OnCloseHandle(ToClose, cancellationToken).ConfigureAwait(false)) { // last reference on the PhysicalLog removed - it is closed, remove from this _Logs index _Logs.Remove(ToClose.OwnerId); if ((_Handles.Count == 0) && (_Logs.Count == 0)) { var m = _AppDomainPhysLogManager; _AppDomainPhysLogManager = null; try { await m.CloseAsync(cancellationToken).ConfigureAwait(false); } catch (Exception ex) { // // Close can throw STATUS_OBJECT_NO_LONGER_EXISTS if the log has been deleted while // the opened. This is benign and so just ignore it. // // TODO asnegi: RDBug #10278280 Adding 0xc0190021 as it is expected HResult for exception. However, it seems that it is not being // translated to 0x80071A97 or generated properly in dotnet_coreclr_linux. if ((ex.InnerException == null) || ((ex.InnerException.HResult != unchecked ((int)0x80071A97)) && (ex.InnerException.HResult != unchecked ((int)0xc0190021))) || (ex.InnerException.InnerException != null && ex.InnerException.InnerException.HResult != unchecked ((int)0xc0190021))) { // Only ERROR_OBJECT_NO_LONGER_EXISTS is an expected result code. Any other error should be passed back up throw; } } } } } finally { _Lock.Set(); } }
OnOpenPhysicalLogAsync( string pathToCommonContainer, Guid physicalLogId, bool isStagingLog, CancellationToken cancellationToken) { Requires.Argument("pathToCommonContainer", pathToCommonContainer).NotNull(); IPhysicalLog result = null; await _Lock.WaitUntilSetAsync(cancellationToken).ConfigureAwait(false); try { PhysicalLog subjectLog; if (_Logs.TryGetValue(physicalLogId, out subjectLog) == false) { // P.Log has not been opened yet- attempt to open its underpinnings var underlyingContainer = await _AppDomainPhysLogManager.OpenLogContainerAsync( pathToCommonContainer, isStagingLog?Guid.Empty : physicalLogId, cancellationToken).ConfigureAwait(false); Exception caughtException = null; try { subjectLog = new PhysicalLog(physicalLogId, underlyingContainer); _Logs.Add(physicalLogId, subjectLog); subjectLog.IsOpen = true; result = await subjectLog.OnCreateHandle(cancellationToken).ConfigureAwait(false); } catch (Exception ex) { // Cause clean up failed create caughtException = ex; } if (caughtException != null) { // clean up failed create and forward the causing exception if (subjectLog != null) { subjectLog.IsOpen = false; _Logs.Remove(physicalLogId); } try { await underlyingContainer.CloseAsync(cancellationToken).ConfigureAwait(false); } catch (Exception ex) { AppTrace.TraceSource.WriteInfo(TraceType, "OnOpenPhysicalLogAsync - CloseAsync: Exception {0}", ex); } throw caughtException; } } else { // Already open - just alias with another handle result = await subjectLog.OnCreateHandle(cancellationToken).ConfigureAwait(false); } } finally { _Lock.Set(); } return(result); }
OnCreatePhysicalLogAsync( string pathToCommonContainer, Guid physicalLogId, long containerSize, uint maximumNumberStreams, uint maximumLogicalLogBlockSize, LogManager.LogCreationFlags CreationFlags, CancellationToken cancellationToken) { Requires.Argument("pathToCommonContainer", pathToCommonContainer).NotNull(); IPhysicalLog result = null; await _Lock.WaitUntilSetAsync(cancellationToken).ConfigureAwait(false); try { PhysicalLog subjectLog; if (_Logs.TryGetValue(physicalLogId, out subjectLog) == false) { // P.Log has not been opened or created - attempt to create it var underlyingContainer = await _AppDomainPhysLogManager.CreateContainerAsync( pathToCommonContainer, physicalLogId, containerSize, maximumNumberStreams, maximumLogicalLogBlockSize, CreationFlags, cancellationToken).ConfigureAwait(false); Exception caughtException = null; try { // Make and "open" PhysicalLog representing the underlying IPhysicalLogContainer subjectLog = new PhysicalLog(physicalLogId, underlyingContainer); _Logs.Add(physicalLogId, subjectLog); subjectLog.IsOpen = true; result = await subjectLog.OnCreateHandle(cancellationToken).ConfigureAwait(false); } catch (Exception ex) { // Cause clean up failed create caughtException = ex; } if (caughtException != null) { // clean up failed - create and forward the causing exception if (subjectLog != null) { subjectLog.IsOpen = false; _Logs.Remove(physicalLogId); } try { await underlyingContainer.CloseAsync(cancellationToken).ConfigureAwait(false); } catch (Exception ex) { AppTrace.TraceSource.WriteInfo(TraceType, "OnCreatePhysicalLogAsync - CloseAsync: Exception {0}", ex); } try { await underlyingContainer.DeletePhysicalLogStreamAsync(physicalLogId, cancellationToken).ConfigureAwait(false); } catch (Exception ex) { AppTrace.TraceSource.WriteInfo(TraceType, "OnCreatePhysicalLogAsync - DeletePhysicalLogStreamAsync: Exception {0}", ex); } throw caughtException; } } else { // Have an existing physical log with this id already - fault throw new UnauthorizedAccessException(SR.Error_PhysicalLog_Exists); } } finally { _Lock.Set(); } return(result); }
public string Info() { int i; StringBuilder sb = new StringBuilder(); sb.AppendLine(); sb.Append("QualityPreference: "); for (i = 0; i < QualityPreference.Length; i++) { sb.AppendFormat("{0} ", QualityPreference[i]); } sb.AppendLine(); sb.AppendFormat("{0}: {1}\n", "TrailerDownloadFolder", TrailerDownloadFolder.ToString()); sb.AppendFormat("{0}: {1}\n", "MetadataDownloadFolder", MetadataDownloadFolder.ToString()); sb.AppendFormat("{0}: {1}\n", "3DTrailerDownloadFolder", Trailer3DDownloadFolder.ToString()); sb.AppendFormat("{0}: {1}\n", "3DMetadataDownloadFolder", Metadata3DDownloadFolder.ToString()); sb.AppendFormat("{0}: {1}\n", "GrabPoster", GrabPoster.ToString()); sb.AppendFormat("{0}: {1}\n", "CreateFolder", CreateFolder.ToString()); sb.AppendFormat("{0}: {1}\n", "VerboseLogging", VerboseLogging.ToString()); sb.AppendFormat("{0}: {1}\n", "PhysicalLog", PhysicalLog.ToString()); sb.AppendFormat("{0}: {1}\n", "PauseWhenDone", PauseWhenDone.ToString()); sb.AppendFormat("{0}: {1}\n", "KeepFor", KeepFor.ToString()); sb.AppendFormat("{0}: {1}\n", "DeleteToRecycleBin", DeleteToRecycleBin.ToString()); sb.AppendFormat("{0}: {1}\n", "UseExclusions", UseExclusions.ToString()); sb.AppendFormat("{0}: {1}\n", "TrailersOnly", TrailersOnly.ToString()); sb.AppendFormat("{0}: {1}\n", "TrailersIdenticaltoTheatricalTrailers", TrailersIdenticaltoTheatricalTrailers.ToString()); sb.AppendFormat("{0}: {1}\n", "SkipTheatricalTrailers", SkipTheatricalTrailers.ToString()); sb.AppendFormat("{0}: {1}\n", "SkipTeaserTrailers", SkipTeaserTrailers.ToString()); sb.AppendFormat("{0}: {1}\n", "ConsiderTheatricalandNumberedTrailersasIdentical", ConsiderTheatricalandNumberedTrailersasIdentical.ToString()); sb.AppendFormat("{0}: {1}\n", "DownloadSpecifiedGenresOnly", IncludeGenres.ToString()); sb.AppendFormat("{0}: {1}\n", "DownloadSpecifiedGenresOnly", ExcludeGenres.ToString()); sb.AppendFormat("{0}: {1}\n", "DownloadSpecifiedLanguagesOnly", IncludeLanguages.ToString()); sb.AppendFormat("{0}: {1}\n", "MinTrailerSize", MinTrailerSize.ToString()); sb.AppendFormat("{0}: {1}\n", "AddDates", AddDates.ToString()); if ((UserAgentId == null) || (UserAgentId.Length == 0)) { sb.AppendLine("No UserAgentId defined"); } else { for (i = 0; i < UserAgentId.Length; i++) { sb.AppendFormat("UserAgendId({0}): {1}\n", i + 1, UserAgentId[i]); } } if ((UserAgentString == null) || (UserAgentString.Length == 0)) { sb.AppendLine("No UserAgentString defined"); } else { for (i = 0; i < UserAgentString.Length; i++) { sb.AppendFormat("UserAgentString({0}): {1}\n", i + 1, UserAgentString[i]); } } sb.AppendFormat("{0}: {1}\n", "FeedAddress", FeedAddress.ToString()); sb.AppendFormat("{0}: {1}\n", "YouTubePlayList", YouTubePlayList.ToString()); sb.AppendFormat("{0}: {1}\n", "EmailAddress", EmailAddress.ToString()); sb.AppendFormat("{0}: {1}\n", "EmailSummary", EmailSummary.ToString()); sb.AppendFormat("{0}: {1}\n", "SMTPServer", SMTPServer.ToString()); sb.AppendFormat("{0}: {1}\n", "SMTPPort", SMTPPort.ToString()); sb.AppendFormat("{0}: {1}\n", "UseDefaultCredentials", UseDefaultCredentials.ToString()); if (!UseDefaultCredentials) { sb.AppendFormat("{0}: {1}\n", "SMTPUsername", "*********"); sb.AppendFormat("{0}: {1}\n", "SMTPPassword", "*********"); } sb.AppendFormat("{0}: {1}\n", "SMTPEnableSsl", SMTPEnableSsl.ToString()); sb.AppendFormat("{0}: {1}\n", "EmailReturnAddress", EmailReturnAddress.ToString()); sb.AppendFormat("{0}: {1}\n", "EmailReturnDisplayName", EmailReturnDisplayName.ToString()); return(sb.ToString()); }