public static void WriteToFile() { DateTime now = DateTime.Now; string fileName = now.Year + "-" + now.Month + "-" + now.Day + "_" + now.Hour + "-" + string.Format("{0:00}", now.Minute) + "-" + string.Format("{0:00}", now.Second) + "-" + string.Format("{0:000}", now.Millisecond) + ".txt"; LogFile = fileName; using (Stream fileStream = new FileStream(fileName, FileMode.Create, FileAccess.Write, FileShare.None)) { using (StreamWriter writer = new StreamWriter(fileStream)) { writer.WriteLine("Instant Gameworks (c) 2018"); writer.WriteLine("Exit Time: " + now.ToShortDateString() + " " + FormatSmallDate(now)); writer.WriteLine("Event Count: " + LogCount); writer.WriteLine(); writer.WriteLine("Start of log"); for (int logLength = 0; logLength < LogCount; logLength++) { if (FullEventLog.Count > logLength && FullEventLog[logLength] != null) { Event?current = FullEventLog[logLength]; writer.WriteLine("[" + current?.LogMessageNumber + "] " + FormatSmallDate(current?.DateTime) + ": " + current?.Message); } if (FullErrorLog.Count > logLength && FullErrorLog[logLength] != null) { Error?current = FullErrorLog[logLength]; writer.WriteLine("[" + current?.LogMessageNumber + "] " + FormatSmallDate(current?.DateTime) + ": " + current?.Exception + " at " + current?.TraceSource + " - " + current?.StackTrace); } } writer.WriteLine("End of log"); } } }
private ApplicationResult(bool isSuccess, object model = null, Error?errorCode = null, string message = null) { Data = model; IsSuccess = isSuccess; ErrorCode = errorCode; Message = message; }
private bool isUserMoveInPLayerTurnPossibleMoves( string i_FromSlotKey, string i_ToSlotKey, out int?o_PossibleMovesIndex, out Error?o_Error) { o_Error = null; o_PossibleMovesIndex = 0; bool isExists = false; foreach (PlayerMove playerMove in m_PlayerTurn.PossibleMoves) { isExists = i_FromSlotKey == playerMove.FromSlotKey && i_ToSlotKey == playerMove.ToSlotKey; if (isExists) { break; } o_PossibleMovesIndex++; } if (!isExists) { o_PossibleMovesIndex = null; o_Error = getErrorUserMoveDidNotFoundInPossibleMoves(i_FromSlotKey, i_ToSlotKey); } return(isExists); }
private bool isUserMoveKeysLegal(string i_FromSlotKey, string i_ToSlotKey, out Error?o_Error) { o_Error = null; bool fromSlotKeyLegal = m_Board.IsKeyInRange(i_FromSlotKey); bool toSlotKeyLegal = m_Board.IsKeyInRange(i_ToSlotKey); bool keysLegal = fromSlotKeyLegal && toSlotKeyLegal; if (!fromSlotKeyLegal && !toSlotKeyLegal) { o_Error = new Error(i_FromSlotKey, i_ToSlotKey, Error.eType.SlotKeysAreNotInRange); } else { if (!fromSlotKeyLegal) { o_Error = new Error(i_FromSlotKey, i_ToSlotKey, Error.eType.FromSlotKeyIsNotInRange); } if (!toSlotKeyLegal) { o_Error = new Error(i_FromSlotKey, i_ToSlotKey, Error.eType.ToSlotKeyIsNotInRange); } } return(keysLegal); }
public HttpResponse(HttpStatusCode statusCode, string?requestId, NameValueCollection headers, Error?error) { StatusCode = statusCode; RequestId = requestId; Headers = headers; Error = error; }
private ApplicationResult(bool isSuccess, TModel model = null, Error?errorCode = null, string errorMessage = null) { Data = model; IsSuccess = true; ErrorCode = errorCode; ErrorMessage = ErrorMessage; }
private void decrypterButton_Click(object sender, EventArgs e) { if (!IsReady()) { return; } if (_inputDir != null && _outputDir != null) { Metadata met = new Metadata(_inputDir, _outputDir, State.Decode, _keepInvalidChar, _codeAndTranslate, _type, _cesarKey); ICrypt crypt = (_algorithm == TypeC.Aero) ? new Aero(met, _aeroUseInt) : (_algorithm == TypeC.Cesar) ? new Cesar(met, _cesarLeftToRight) : (_algorithm == TypeC.Morse) ? new Morse(met) : (_algorithm == TypeC.Navajo) ? new Navajo(met) : (_algorithm == TypeC.Vigenere) ? new Vigenere(met, _vigenereKey) : new Binaire(met); crypt.Translate(); crypt.WriteResult(); } else { string message = "Erreur: paramètre inexistant, veuillez entrer une valeur."; string source = (_inputDir is null) ? nameof(_inputDir) : nameof(_outputDir); string details = $"Error in Decrypt method: {source} should not be null"; Error err = new Error(message, source, details); Error = err; } CryptoStatusCheck(State.Decode); }
/// <summary> /// Merges two error instances into one. /// </summary> public static Error?Merge(Error?left, Error?right, string separator) { if (left is null && right is null) { return(null); } if (left is null) { return(right); } if (right is null) { return(left); } var message = ResultBase.Merge(left.ErrorMessage, right.ErrorMessage, separator); if (left.Exception != null && right.Exception != null) { var exception = new AggregateException(left.Exception, right.Exception); return(new Error(message, exception, diagnostics: null)); } var diagnostics = ResultBase.Merge(left.Diagnostics, right.Diagnostics, separator); // Keeping an exception instance for the error (this is important for tracking critical errors for instance). return(new Error(message, exception: left.Exception ?? right.Exception, diagnostics)); }
public Tuple <string, string, TEntity> ApplyResponse <TEntity>(Error?err, TEntity data = null, string errCode = null, string errDesc = null) where TEntity : class { errCode = err.HasValue ? Utils.GetErrorCode(err.Value) : errCode; errDesc = err.HasValue ? Utils.GetErrorDesc(err.Value) : errDesc; return(Tuple.Create(errCode, errDesc, data)); }
/// <summary> /// Initializes a new instance of the <see cref="KafkaOffsetsCommittedEvent" /> class. /// </summary> /// <param name="offsets"> /// The per-partition offsets and success or error information. /// </param> /// <param name="error"> /// The overall operation success or error information. /// </param> public KafkaOffsetsCommittedEvent( IReadOnlyCollection <TopicPartitionOffsetError>?offsets, Error?error = null) { Offsets = offsets ?? Array.Empty <TopicPartitionOffsetError>(); Error = error ?? new Error(ErrorCode.NoError); }
private Error(ErrorType type, string message, StackTrace trace, Error?inner = null) { this.Type = type; this.Message = message; this.Trace = trace; this.Inner = inner; }
internal Result(ref Source Source) { this.Error = null; this.Source = Source; this.Start = Source.Position; this.Length = 0; }
public static async Task ExecuteCommandAsync(IConsole console, string?registry, Func <Task> execute) { try { await execute(); } catch (Exception e) { ConsoleColor savedColor = Console.ForegroundColor; Console.ForegroundColor = ConsoleColor.Red; string message = e.Message; if (e is DockerRegistryClient.DockerRegistryException dockerRegistryException) { Error?error = dockerRegistryException.Errors.FirstOrDefault(); if (error?.Code == "UNAUTHORIZED") { string loginCommand = "docker login"; if (registry is not null) { loginCommand += $" {registry}"; } message = $"Authentication required. Ensure that your credentials are stored for the registry by running '{loginCommand}'."; } else { message = error?.Message ?? message; } } console.Error.WriteLine(message); Console.ForegroundColor = savedColor; } }
public ActionCompletedEventArgs(Error?error, ActionProfileOptions action, MacroEvaluatorTransientValues transients, ActionRunResult runResult = null) { Error = error; Action = action; Transients = transients; RunResult = runResult; }
public ProactiveCopyResult(PushFileResult ringCopyResult, PushFileResult outsideRingCopyResult, int retries, ContentLocationEntry?entry = null) { RingCopyResult = ringCopyResult; OutsideRingCopyResult = outsideRingCopyResult; Retries = retries; Entry = entry ?? ContentLocationEntry.Missing; var results = new[] { ringCopyResult, outsideRingCopyResult }; if (results.Any(r => r.Succeeded)) { Status = ProactiveCopyStatus.Success; } else if (results.Any(r => r.Status.IsRejection())) { Status = ProactiveCopyStatus.Rejected; } else if (results.All(r => r.Status == CopyResultCode.Disabled)) { Status = ProactiveCopyStatus.Skipped; } else { Status = ProactiveCopyStatus.Error; } if (!IsSuccessfulStatus(Status)) { var error = GetErrorMessage(ringCopyResult, outsideRingCopyResult); var diagnostics = GetDiagnostics(ringCopyResult, outsideRingCopyResult); _error = Error.FromErrorMessage(error !, diagnostics); } }
public DataRecordBuilder( long?index = null, double?monitorTime = null, BusChannel?channel = null, Error?error = null, ControlWord?cw1 = null, ControlWord?cw2 = null, ResponseWord?rw1 = null, ResponseWord?rw2 = null, ushort[] data = null ) { record = new DataRecord(); if (index != null) { record.Index = index.Value; } if (monitorTime != null) { record.MonitorTime = monitorTime.Value; } if (channel != null) { record.Channel = channel.Value; } if (error != null) { record.Error = error.Value; } if (cw1 != null) { record.Cw1 = cw1.Value; } if (cw2 != null) { record.Cw2 = cw2.Value; } if (rw1 != null) { record.Rw1 = rw1.Value; } if (rw2 != null) { record.Rw2 = rw2.Value; } if (data != null) { Data(data); } }
public void SetError(Error error) { Error = error; IsInErrorState = true; Console.Error.WriteLine(error.ErrorMessage); Console.Error.WriteLine(error.ErrorDetails); Console.Error.WriteLine(error.ErrorStackTrace); }
public static bool TryGetError(this Exception exception, out Error?error) { if (exception is ErrorException errorException) { error = errorException.Error; return(true); } error = null; return(false); }
public TlsConnectionResult(TlsVersion? version, CipherSuite? cipherSuite, CurveGroup? curveGroup, SignatureHashAlgorithm? signatureHashAlgorithm, Error? error, string errorDescription, List<string> smtpResponses ) : this(version, cipherSuite, curveGroup, signatureHashAlgorithm, error, errorDescription, smtpResponses, null) { }
public ResultCommon(Maybe <Error> error) { if (error.IsSomething()) { _error = error.Value; } else { _error = null; } }
public OperationResult(bool result, Error?error) { Result = result; if (error != null) { Errors = new List <Error>() { error }; } }
public bool Equals(Error?other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return(Code == other.Code); }
/// <inheritdoc /> public bool Equals(Error?other) { if (other is null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return((ErrorMessage, Exception, _diagnostics).Equals((other.ErrorMessage, other.Exception, other._diagnostics))); }
public bool IsMatch(Error?error) { if (error == null) { return(false); } var isValid = error.Code == _errorCode1 || error.Code == _errorCode2 || error.Code == _errorCode3 || (_errorCodes?.Contains(error.Code) ?? false); return(isValid && (_condition?.Invoke(error) ?? true)); }
/// <inheritdoc /> public bool Equals(Error?other) { if (other is null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return(Details.Equals(other.Details) && State == other.State); }
private void InitMeta() { _codeAndTranslate = false; _type = WritingType.Normal; _keepInvalidChar = true; _cesarKey = 0; _algorithm = TypeC.Cesar; _aeroUseInt = true; _cesarLeftToRight = true; _inputDir = null; _outputDir = null; Error = null; _vigenereKey = null; _isInteractive = true; }
public DoctestWithoutNamespaceOrError(DoctestWithoutNamespace?doctestWithoutNamespace, Error?error) { if (doctestWithoutNamespace == null && error == null) { throw new ArgumentException("Both doctest and error are null."); } if (doctestWithoutNamespace != null && error != null) { throw new ArgumentException("Both doctest and error are given."); } DoctestWithoutNamespace = doctestWithoutNamespace; Error = error; }
private void CryptoStatusCheck(State state) { if (Error is not null) { MessageBox.Show(Error.ToString(), "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error); Error = null; } else { string message = (state == State.Code) ? "Cryptage" : "Decryptage"; message += " terminé !"; MessageBox.Show(message, "Fin de l'opération", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
public TlsTestResult(TlsVersion?version, CipherSuite?cipherSuite, CurveGroup?curveGroup, SignatureHashAlgorithm?signatureHashAlgorithm, Error?error, string errorDescription, List <string> smtpResponses) { Version = version; CipherSuite = cipherSuite; CurveGroup = curveGroup; SignatureHashAlgorithm = signatureHashAlgorithm; Error = error; ErrorDescription = errorDescription; SmtpResponses = smtpResponses; }
public override void WriteJson(JsonWriter writer, Error?value, JsonSerializer serializer) { if (value == null) { writer.WriteNull(); return; } var errorObj = JObject.FromObject(value, new JsonSerializer { ContractResolver = serializer.ContractResolver }); var fieldProp = errorObj.Property(nameof(Error.Fields), StringComparison.OrdinalIgnoreCase); if (fieldProp is { Value : JObject fields })
private void OnCurrentChanged(object sender, EventArgs e) { var wasPlaying = IsPlaying; IsPlaying = false; if (Playlist.Current != null) { var track = Playlist.Current.Track as Track; if (track != null && track.InternalTrack.IsValid()) { _session.PlayerUnload(); _player.ClearBuffers(); _logger.Log("Changing track to " + track.Name, Category.Info, Priority.Low); _lastLoadStatus = track.InternalTrack.Load(); if (wasPlaying && _lastLoadStatus.GetValueOrDefault() == Error.OK) { track.InternalTrack.Play(); }else { _eventAggregator.GetEvent<NotificationEvent>().Publish(new NotificationMessage(_lastLoadStatus.Value.GetMessage())); _logger.Log(_lastLoadStatus.Value.GetMessage(), Category.Warn, Priority.Medium); } _playLocation = TimeSpan.Zero; } } else { _logger.Log("No more tracks to play.", Category.Info, Priority.Low); Stop(); } }
public void Play() { if (!_lastLoadStatus.HasValue) { if (_playlist.Current == null) { _playlist.Next(); } if (_playlist.Current != null) { var track = (Track)Playlist.Current.Track; _lastLoadStatus = track.InternalTrack.Load(); } } if (_lastLoadStatus.HasValue && _lastLoadStatus == Error.OK) { _session.PlayerPlay(); _player.Play(); _logger.Log("Playing", Category.Info, Priority.Low); } }