public RegressionResult(TerminationReason terminationReason, double[] constants, double errorValue, int evaluationCount) { _terminationReason = terminationReason; _constants = constants; _errorValue = errorValue; _evaluationCount = evaluationCount; }
private void ProcessAnyCommands(ref bool shouldTerminateGraphConversionLoop, ref TerminationReason whyDidYouTerminate) { if (PendingCommands.Count < 1) { return; } StreamCommand CurrentCommand = PendingCommands.Dequeue(); switch (CurrentCommand.CommandName) { case StreamCommand.CommandNames.Cancel: shouldTerminateGraphConversionLoop = true; whyDidYouTerminate = TerminationReason.UserCancelled; break; case StreamCommand.CommandNames.Seek: // NON-FUNCTIONAL TimeSpan seekTime = (TimeSpan)CurrentCommand.ParamObject; DoSeekToTime(seekTime); break; case StreamCommand.CommandNames.SetRate: double newRate = (double)CurrentCommand.ParamObject; DoSetRate(newRate); break; default: break; } // Continue and run the graph for another iteration before performing any further pending commands. }
public void StopExecution(string virtualUser, TerminationReason terminationSource, string explanation = null) { _listenerEventsClient = null; _testListenersComplete = true; finalizeTestExecution(); // Kill off user execution threads, than main thread. if (_virtualUserThreads.Count > 0) { // Kill is virtual user thread. foreach (Thread virtualUserThread in _virtualUserThreads) { if (virtualUserThread != null && virtualUserThread.IsAlive) { virtualUserThread.Abort(); } } // Now kill main thread _mainExecutionThread.Abort(); _stopWatch.Stop(); fireExecutionCompleteEvent(this, new TestExecutionCompleteArgs(null, _initialTestScriptObject, terminationSource, _stopWatch.Elapsed, explanation)); } }
public TestExecutionCompleteArgs(string virtualUser, TestScriptObject testScriptObject, TerminationReason terminationSource, TimeSpan elapsedTime, string explanation = null) { _virtualUser = virtualUser; _testScriptObject = testScriptObject; _terminationSource = terminationSource; _explanation = explanation; _elapsedTime = elapsedTime; }
public ICPTerminatedMessage(TerminationReason reason, float currentError, int terminationIteration, string message, string modelFragmentName, string errors) { this.Reason = reason; this.message = (message == "" ? ReasonToString() : message); this.errorAtTermination = currentError; this.terminationIteration = terminationIteration; this.modelFragmentName = modelFragmentName; this.errors = errors; }
public TerminationReasonDTO(TerminationReason source) { TerminationReasonID = source.TerminationReasonID; OrganizationID = source.OrganizationID; Code = source.Code; DisplayName = source.DisplayName; Description = source.Description; IsActive = source.IsActive; StatusType = source.StatusType; }
/// <summary> /// Converts the value of the specified <see cref="TerminationReason"/> to its equivalent <see cref="String"/> representation. /// </summary> /// <param name="reason">A termination reason code.</param> /// <returns>The <see cref="String"/> equivalent of the value of <paramref name="reason"/>.</returns> public static string ToString(TerminationReason reason) { switch (reason) { case TerminationReason.ByBoard: return("Terminated by the Board"); case TerminationReason.CeasedCampaign: return("Ceased Campaign"); case TerminationReason.OffBallot: return("Off the Ballot"); default: return(string.Empty); } }
private static bool Handler(TerminationReason reason) { switch (reason) { case TerminationReason.ControlBreak: case TerminationReason.CloseConsoleHost: UrgentTerminationRequested(reason); WaitOnTermination(); return(true); default: // We're only looking to handle 'console closed' or Ctrl-Break events here. // Anything else should be handed off to .NET or the OS, eg. Ctrl-C is handled // using standard .NET techniques. return(false); } }
/// <summary> /// 型'<see cref="ExapisSOP.TerminationException"/>'の新しいインスタンスを生成します。 /// </summary> /// <param name="message">この例外を説明する翻訳済みのエラーメッセージです。</param> /// <param name="reason">この例外の発生理由です。</param> /// <param name="token">処理を終了させた操作に関連付けられているトークンです。</param> public TerminationException(string message, TerminationReason reason, CancellationToken token) : base(message, token) { this.Reason = reason; switch (reason) { case TerminationReason.ProcessLocked: this.HResult = 5; // アクセスが拒否されました。 break; case TerminationReason.NoCompatible: this.HResult = 13; // データが無効です。 break; case TerminationReason.InvalidCommandLine: this.HResult = 1; // ファンクションが間違っています。 break; } }
public void Disconnect(NetConnection conn, TerminationReason reason, string reasonString) { if (conn.ConnectionState == NetConnectionState.AwaitingChallengeResponse || conn.ConnectionState == NetConnectionState.AwaitingConnectResponse) { conn.OnConnectTerminated(reason, reasonString); RemovePendingConnection(conn); } else if (conn.ConnectionState == NetConnectionState.Connected) { conn.ConnectionState = NetConnectionState.Disconnected; conn.OnConnectionTerminated(reason, reasonString); if (conn.IsNetworkConnection()) { var stream = new PacketStream(); stream.Write((byte)PacketType.Disconnect); var cParams = conn.GetConnectionParameters(); cParams.Nonce.Write(stream); cParams.ServerNonce.Write(stream); var encryptPos = stream.GetBytePosition(); stream.SetBytePosition(encryptPos); stream.WriteString(reasonString); if (cParams.UsingCrypto) { var theCipher = new SymmetricCipher(cParams.SharedSecret); stream.HashAndEncrypt(NetConnection.MessageSignatureBytes, encryptPos, theCipher); } stream.SendTo(Socket, conn.GetNetAddress()); } RemoveConnection(conn); } }
public void DeleteRecord(string index) { try { //Step 1 Code to delete the object from the database TerminationReason s = new TerminationReason(); s.recordId = index; s.name = ""; //s.intName = ""; PostRequest <TerminationReason> req = new PostRequest <TerminationReason>(); req.entity = s; PostResponse <TerminationReason> r = _employeeService.ChildDelete <TerminationReason>(req); if (!r.Success) { X.MessageBox.ButtonText.Ok = Resources.Common.Ok; Common.errorMessage(r); return; } else { //Step 2 : remove the object from the store Store1.Remove(index); //Step 3 : Showing a notification for the user Notification.Show(new NotificationConfig { Title = Resources.Common.Notification, Icon = Icon.Information, Html = Resources.Common.RecordDeletedSucc }); } } catch (Exception ex) { //In case of error, showing a message box to the user X.MessageBox.ButtonText.Ok = Resources.Common.Ok; X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorDeletingRecord).Show(); } }
public void ExecuteCalculation() { // TODO CPUFieldLineModel public do-calculation command Vector3[] positions = new Vector3[MaxSegments]; int positionIndex = 0; positions[positionIndex] = transform.position; positionIndex++; // if (integrationDirection = IntegrationDirection.DownField) // { // upFieldTermination = TerminationReason.MaximumLength; // } // else // { // downFieldTermination = TerminationReason.MaximumLength; // } int i = 1; for (; i < MaxSegments; i++) { Vector3 pos = positions[i - 1]; // TODO what is this supposed to catch? //try //{ Vector3 step = calculate(pos); //} //catch { } if (i > 2) { // Shorten step if the field line is curving significantly Vector3 lastStepDirection = (positions[i - 1] - positions[i - 2]).normalized; float stepModifier = 1; // Don't do anything if this would get caught by the BackTolerance check if (!(Vector3.Dot(lastStepDirection, step) < BackTolerance)) { //stepModifier = Mathf.Sin(Vector3.Dot(lastStepDirection, step) * Mathf.PI / 2); stepModifier = DetermineStepLengthModifier(pos, step); } step *= stepModifier; // step *= (Vector3.Dot(step.normalized, lastStepDirection)+0.25f)/1.25f; } // else // { // step *= 0.1f; // } if (integrationDirection == IntegrationDirection.FromPositive) { pos -= SegmentLength * step; } else { pos += SegmentLength * step; } terminationReason = ShouldTerminateFieldLine(positions, pos, i); if (terminationReason != TerminationReason.None) { break; } positions[i] = pos; } Vector3[] truncatedPositions = new Vector3[i]; truncatedPositions = positions.Take(i).ToArray(); _positions = truncatedPositions; // Report where this field line has landed to the CPU field line manager CPUFieldLineManager.Instance.ReportFieldLineTermination(this, terminationReason); }
private static readonly double JITTER = 1e-10d; // a small value used to protect against floating point noise public static RegressionResult Regress(SimplexConstant[] simplexConstants, double convergenceTolerance, int maxEvaluations, ObjectiveFunctionDelegate objectiveFunction) { // confirm that we are in a position to commence if (objectiveFunction == null) { throw new InvalidOperationException("ObjectiveFunction must be set to a valid ObjectiveFunctionDelegate"); } if (simplexConstants == null) { throw new InvalidOperationException("SimplexConstants must be initialized"); } // create the initial simplex int numDimensions = simplexConstants.Length; int numVertices = numDimensions + 1; Vector[] vertices = _initializeVertices(simplexConstants); double[] errorValues = new double[numVertices]; int evaluationCount = 0; TerminationReason terminationReason = TerminationReason.Unspecified; ErrorProfile errorProfile; errorValues = _initializeErrorValues(vertices, objectiveFunction); // iterate until we converge, or complete our permitted number of iterations while (true) { errorProfile = _evaluateSimplex(errorValues); // see if the range in point heights is small enough to exit if (_hasConverged(convergenceTolerance, errorProfile, errorValues)) { terminationReason = TerminationReason.Converged; break; } // attempt a reflection of the simplex double reflectionPointValue = _tryToScaleSimplex(-1.0, ref errorProfile, vertices, errorValues, objectiveFunction); ++evaluationCount; if (reflectionPointValue <= errorValues[errorProfile.LowestIndex]) { // it's better than the best point, so attempt an expansion of the simplex double expansionPointValue = _tryToScaleSimplex(2.0, ref errorProfile, vertices, errorValues, objectiveFunction); ++evaluationCount; } else if (reflectionPointValue >= errorValues[errorProfile.NextHighestIndex]) { // it would be worse than the second best point, so attempt a contraction to look // for an intermediate point double currentWorst = errorValues[errorProfile.HighestIndex]; double contractionPointValue = _tryToScaleSimplex(0.5, ref errorProfile, vertices, errorValues, objectiveFunction); ++evaluationCount; if (contractionPointValue >= currentWorst) { // that would be even worse, so let's try to contract uniformly towards the low point; // don't bother to update the error profile, we'll do it at the start of the // next iteration _shrinkSimplex(errorProfile, vertices, errorValues, objectiveFunction); evaluationCount += numVertices; // that required one function evaluation for each vertex; keep track } } // check to see if we have exceeded our alloted number of evaluations if (evaluationCount >= maxEvaluations) { terminationReason = TerminationReason.MaxFunctionEvaluations; break; } } RegressionResult regressionResult = new RegressionResult(terminationReason, vertices[errorProfile.LowestIndex].Components, errorValues[errorProfile.LowestIndex], evaluationCount); return(regressionResult); }
private IterationTermination(TerminationReason reason, IExecutionContext context, object returnValue) { this.Reason = reason; this.Context = context; this.ReturnValue = returnValue; }
public SettingRegRespObj AddTerminationReason(RegTerminationReasonObj regObj) { var response = new SettingRegRespObj { Status = new APIResponseStatus { IsSuccessful = false, Message = new APIResponseMessage() } }; try { if (regObj.Equals(null)) { response.Status.Message.FriendlyMessage = "Error Occurred! Unable to proceed with your request"; response.Status.Message.TechnicalMessage = "Registration Object is empty / invalid"; return(response); } if (!EntityValidatorHelper.Validate(regObj, out var valResults)) { var errorDetail = new StringBuilder(); if (!valResults.IsNullOrEmpty()) { errorDetail.AppendLine("Following error occurred:"); valResults.ForEachx(m => errorDetail.AppendLine(m.ErrorMessage)); } else { errorDetail.AppendLine( "Validation error occurred! Please check all supplied parameters and try again"); } response.Status.Message.FriendlyMessage = errorDetail.ToString(); response.Status.Message.TechnicalMessage = errorDetail.ToString(); response.Status.IsSuccessful = false; return(response); } if (!HelperMethods.IsUserValid(regObj.AdminUserId, regObj.SysPathCode, HelperMethods.getSeniorAccountant(), ref response.Status.Message)) { return(response); } if (IsTerminationReasonDuplicate(regObj.Name, 1, ref response)) { return(response); } var terminationReason = new TerminationReason { Name = regObj.Name, Status = (ItemStatus)regObj.Status }; var added = _repository.Add(terminationReason); _uoWork.SaveChanges(); if (added.TerminationReasonId < 1) { response.Status.Message.FriendlyMessage = "Error Occurred! Unable to complete your request. Please try again later"; response.Status.Message.TechnicalMessage = "Unable to save to database"; return(response); } resetCache(); response.Status.IsSuccessful = true; response.SettingId = added.TerminationReasonId; } catch (DbEntityValidationException ex) { ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message); response.Status.Message.FriendlyMessage = "Error Occurred! Please try again later"; response.Status.Message.TechnicalMessage = "Error: " + ex.GetBaseException().Message; response.Status.IsSuccessful = false; return(response); } catch (Exception ex) { ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message); response.Status.Message.FriendlyMessage = "Error Occurred! Please try again later"; response.Status.Message.TechnicalMessage = "Error: " + ex.GetBaseException().Message; response.Status.IsSuccessful = false; return(response); } return(response); }
public virtual void OnConnectionTerminated(TerminationReason reason, string reasonString) { }
/// <summary> /// 型'<see cref="ExapisSOP.TerminationException"/>'の新しいインスタンスを生成します。 /// </summary> /// <param name="innerException">内部例外です。</param> public TerminationException(Exception innerException) : base(Resources.TerminationException_withInnerError, innerException) { this.Reason = TerminationReason.ThrewException; this.HResult = innerException.HResult; }
private void ProcessAnyCommands(ref bool shouldTerminateGraphConversionLoop, ref TerminationReason whyDidYouTerminate) { if (PendingCommands.Count < 1) return; StreamCommand CurrentCommand = PendingCommands.Dequeue(); switch (CurrentCommand.CommandName) { case StreamCommand.CommandNames.Cancel: shouldTerminateGraphConversionLoop = true; whyDidYouTerminate = TerminationReason.UserCancelled; break; case StreamCommand.CommandNames.Seek: // NON-FUNCTIONAL TimeSpan seekTime = (TimeSpan)CurrentCommand.ParamObject; DoSeekToTime(seekTime); break; case StreamCommand.CommandNames.SetRate: double newRate = (double)CurrentCommand.ParamObject; DoSetRate(newRate); break; default: break; } // Continue and run the graph for another iteration before performing any further pending commands. }
/// <summary> /// 型'<see cref="ExapisSOP.TerminationException"/>'の新しいインスタンスを生成します。 /// </summary> public TerminationException() : base(Resources.TerminationException) { this.Reason = TerminationReason.WorkCompleted; this.HResult = 0; // この操作を正しく終了しました。 }
private record TransitionAggregation <T>( ImmutableList <CheckIteration <T> > Checks, CheckStateContext <T> FinalContext, TerminationReason TerminationReason);
/// <summary> /// 型'<see cref="ExapisSOP.TerminationException"/>'を逆直列化します。 /// </summary> /// <param name="info">直列化されたデータを含むオブジェクトです。</param> /// <param name="context">ストリームの転送先または転送元に関する文脈情報です。</param> protected TerminationException(SerializationInfo info, StreamingContext context) : base(info, context) { this.Reason = ((TerminationReason)(info.GetInt32($"{PREFIX}_{nameof(this.Reason)}"))); }
[HandleProcessCorruptedStateExceptions] // Some filters cause AccessViolations; NET 4 doesn't catch these without this flag see http://msdn.microsoft.com/en-us/magazine/dd419661.aspx#id0070035 protected void RunGraph(IGraphBuilder graphBuilder, IBaseFilter seekableFilter) { bool shouldTerminateGraphLoop = false; // Get the media seeking interface to use for computing status and progress updates IMediaSeeking mediaSeeking = (IMediaSeeking)currentOutputFilter; if (!CanGetPositionAndDuration(mediaSeeking)) { // Try to seek using the main graph mediaSeeking = (IMediaSeeking)currentFilterGraph; if (!CanGetPositionAndDuration(mediaSeeking)) { mediaSeeking = null; } } // Run the graph int hr = 0; IMediaControl mediaControl = (IMediaControl)graphBuilder; IMediaEvent mediaEvent = (IMediaEvent)graphBuilder; EventCode statusCode; DateTime startingTime = DateTime.Now; TerminationReason whyDidITerminate = TerminationReason.None; try { hr = mediaControl.Pause(); hr = mediaControl.Run(); DsError.ThrowExceptionForHR(hr); // Signal (if first time) that graph is running OK SignalGraphStartedEvent(true); bool anyClientsYet = false; bool conversionComplete = false; while (!shouldTerminateGraphLoop) // continue until we're done/cancelled { // Any commands? (e.g. seek / cancel) ProcessAnyCommands(ref shouldTerminateGraphLoop, ref whyDidITerminate); // Check graph conversion progress if (conversionComplete) { // stall to avoid 100% loop hr = mediaEvent.WaitForCompletion(250, out statusCode); } else { conversionComplete = CheckGraphConversion(ref mediaSeeking); if (conversionComplete) { if (ConversionProgressChanged != null) { ConversionProgressChanged(new object(), new ProgressChangedEventArgs(100)); // final progress update stating 100% done } if (ConversionCompleted != null) { ConversionCompleted(new object(), new EventArgs()); } } } // Check number of clients int numClients = NumberOfConnectedClients(); if ((numClients > 0) && (!anyClientsYet)) { anyClientsYet = true; // A client connected } else if ((numClients == 0)) { if (anyClientsYet) { // There were clients, but All clients have disconnected shouldTerminateGraphLoop = true; whyDidITerminate = TerminationReason.AllClientsDisconnected; } else { // There aren't any clients and never have been - timeout? TimeSpan timeElapsed = DateTime.Now - startingTime; if (timeElapsed.TotalSeconds > TIMEOUT_SECONDS) { shouldTerminateGraphLoop = true; whyDidITerminate = TerminationReason.NoClientsTimeout; } } } } } catch (Exception ex) { SendDebugMessageWithException("Error running graph: ", ex); whyDidITerminate = TerminationReason.Error; SignalGraphStartedEvent(false); } finally { try { // Raise 'done' event first, before any possible AccessExceptions switch (whyDidITerminate) { case TerminationReason.AllClientsDisconnected: if (Finished != null) { Finished(this, new ConversionEndedEventArgs(false, "All clients disconnected.")); } break; case TerminationReason.NoClientsTimeout: if (Finished != null) { Finished(this, new ConversionEndedEventArgs(false, "No clients ever connected.")); } break; case TerminationReason.UserCancelled: if (Finished != null) { Finished(this, new ConversionEndedEventArgs(false, "User cancelled.")); } break; case TerminationReason.Error: if (Finished != null) { Finished(this, new ConversionEndedEventArgs(true, "Unspecified error.")); } break; default: if (Finished != null) { Finished(this, new ConversionEndedEventArgs(false, "Finished but no additional info.")); } break; } // Stop graph FilterState graphState; IMediaControl mediaControl2 = (IMediaControl)graphBuilder; mediaControl2.GetState(50, out graphState); if (graphState == FilterState.Running) { mediaControl2.Pause(); mediaControl2.Stop(); // Throwing AccessViolationException: attempted to read or write protected memory (probably a badly written filter somewhere) } } catch (AccessViolationException) { SendDebugMessage("Ignoring expected AViolationException", 0); } catch (Exception ex) { SendDebugMessageWithException("Ignoring exception when closing graph: ", ex); } // Close sink - can take a loooong time CloseNetworkSink(); /*//so do in a separate thread... * Thread t = new Thread(CloseNetworkSink); * t.Start();*/ } }
public static void TerminateWithError(string message, TerminationReason reason = 0) { ColoredOutput.WriteError(message); Environment.Exit((int)reason); }
// TerminateEmployee public Employee TerminateEmployee(Employee employee, DateTime terminationDate, TerminationReason terminationReason, bool deactivateAccounts = false) { employee.TerminationDate = terminationDate; employee.TerminationReasonId = terminationReason.Id; employee.DeactivateAccounts = deactivateAccounts; _connector.SendEncryptedRequest <Employee>(employee.TerminateEmployeeRequest); var results = GetEmployees(employee.ClientCode) .WithEmployeeId(employee.EmployeeId) .Find(); return(results.FirstOrDefault()); }
private static void ListenerEvents_OnTestListenersComplete(TerminationReason terminationReason, string message) { LogEvent.Info(message: $"TestListener processing complete. {message} ({terminationReason})"); manualReset.Set(); }
public void TerminateExecution(string message, TerminationReason reason, Steps.Step terminatorStep) { this.TerminationMessage = message; this.TerminationReason = reason; this.TerminatorStepId = terminatorStep.StepId; }
private ExecutionResult(long ticks, DyObject?value, ExecutionContext ctx, TerminationReason reason) => (Ticks, Value, Context, Reason) = (ticks, value, ctx, reason);
protected void SaveNewRecord(object sender, DirectEventArgs e) { //Getting the id to check if it is an Add or an edit as they are managed within the same form. string obj = e.ExtraParams["values"]; TerminationReason b = JsonConvert.DeserializeObject <TerminationReason>(obj); string id = e.ExtraParams["id"]; // Define the object to add or edit as null if (string.IsNullOrEmpty(id)) { try { //New Mode //Step 1 : Fill The object and insert in the store PostRequest <TerminationReason> request = new PostRequest <TerminationReason>(); request.entity = b; PostResponse <TerminationReason> r = _employeeService.ChildAddOrUpdate <TerminationReason>(request); //check if the insert failed if (!r.Success)//it maybe be another condition { //Show an error saving... X.MessageBox.ButtonText.Ok = Resources.Common.Ok; Common.errorMessage(r); return; } else { b.recordId = r.recordId; //Add this record to the store this.Store1.Insert(0, b); //Display successful notification Notification.Show(new NotificationConfig { Title = Resources.Common.Notification, Icon = Icon.Information, Html = Resources.Common.RecordSavingSucc }); this.EditRecordWindow.Close(); RowSelectionModel sm = this.GridPanel1.GetSelectionModel() as RowSelectionModel; sm.DeselectAll(); sm.Select(b.recordId.ToString()); } } catch (Exception ex) { //Error exception displaying a messsage box X.MessageBox.ButtonText.Ok = Resources.Common.Ok; X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorSavingRecord).Show(); } } else { //Update Mode try { //getting the id of the record PostRequest <TerminationReason> request = new PostRequest <TerminationReason>(); request.entity = b; PostResponse <TerminationReason> r = _employeeService.ChildAddOrUpdate <TerminationReason>(request); //Step 1 Selecting the object or building up the object for update purpose //Step 2 : saving to store //Step 3 : Check if request fails if (!r.Success)//it maybe another check { X.MessageBox.ButtonText.Ok = Resources.Common.Ok; Common.errorMessage(r); return; } else { ModelProxy record = this.Store1.GetById(id); BasicInfoTab.UpdateRecord(record); record.Commit(); Notification.Show(new NotificationConfig { Title = Resources.Common.Notification, Icon = Icon.Information, Html = Resources.Common.RecordUpdatedSucc }); this.EditRecordWindow.Close(); } } catch (Exception ex) { X.MessageBox.ButtonText.Ok = Resources.Common.Ok; X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorUpdatingRecord).Show(); } } }
private void TestClassBase_OnStopExecutionRequest(TerminationReason terminationSource, string explanation) { StopExecution(null, terminationSource, explanation); }