public virtual void OnCompleted(ResultType type, string message) { if (System.Threading.Interlocked.CompareExchange(ref mCompletedStatus, 1, 0) == 0) { Result.Status = ResultStatus.Completed; Client.TcpClient.DataReceive = null; Client.TcpClient.ClientError = null; Result.ResultType = type; Result.Messge = message; Completed?.Invoke(this); mReceiveTrack?.Dispose(); mReceiveTrack = null; // TaskCompletion(); if (Command.GetType() == typeof(SELECT) || Command.GetType() == typeof(AUTH)) { Task.Run(() => TaskCompletion()); } else { if (ResultDispatch.UseDispatch) { ResultDispatch.DispatchCenter.Enqueue(this, 3); } else { TaskCompletion(); } } } }
public async Task <Response> Execute() { #if NETCOREAPP2_1 using (mRequestTrack = CodeTrackFactory.TrackReport(this, CodeTrackLevel.Module, null)) { if (Activity.Current != null) { Header[CODE_TREAK_PARENTID] = Activity.Current.Id; } if (mRequestTrack.Enabled) { mRequestTrack.Activity?.AddTag("tag", "BeetleX HttpClient"); } #endif Executing?.Invoke(this); mTaskCompletionSource = CompletionSourceFactory.Create <Response>(TimeOut != null ? TimeOut.Value : HttpHost.Pool.TimeOut); // new AnyCompletionSource<Response>(); mTaskCompletionSource.TimeOut = OnRequestTimeout; OnExecute(); return(await(Task <Response>) mTaskCompletionSource.GetTask()); #if NETCOREAPP2_1 } #endif }
public UserWorkflow(CodeTrack codeTrack) { _codeTrack = codeTrack; _projectWorkflow = new ProjectWorkflow(_codeTrack); }
public ProjectWorkflow(CodeTrack codeTrack) { _codeTrack = codeTrack; }
private void OnReceive(IClient c, ClientReceiveArgs reader) { mReceiveTrack = CodeTrackFactory.Track("Read", CodeTrackLevel.Function, Activity?.Id, "Redis", "Protocol"); if (Command.NetworkReceive != null) { var result = Command.NetworkReceive(this, reader.Stream.ToPipeStream()); if (result != null) { Result = result; OnCompleted(ResultType.Object, null); } } else { ResultType resultType; string msg; PipeStream pipeStream = reader.Stream.ToPipeStream(); if (mFreeLength > 0) { pipeStream.ReadFree(mFreeLength); mFreeLength = 0; } if (Result.Status == ResultStatus.None) { if (pipeStream.TryReadLine(out string line)) { char type = line[0]; switch (type) { case '+': resultType = ResultType.Simple; msg = line.Substring(1, line.Length - 1); OnCompleted(resultType, msg); return; case '-': resultType = ResultType.Error; msg = line.Substring(1, line.Length - 1); OnCompleted(resultType, msg); return; case ':': Result.Data.Add(new ResultItem { Type = ResultType.Integers, Data = long.Parse(line.Substring(1, line.Length - 1)) }); Result.Status = ResultStatus.Completed; OnCompleted(ResultType.Integers, null); return; case '$': Result.ResultType = ResultType.Bulck; Result.ArrayCount = 1; Result.BodyLength = int.Parse(line.Substring(1, line.Length - 1)); Result.Status = ResultStatus.Loading; break; case '*': Result.ResultType = ResultType.Arrays; Result.ArrayCount = int.Parse(line.Substring(1, line.Length - 1)); Result.Status = ResultStatus.Loading; break; } } } if (Result.Status == ResultStatus.Loading) { if (Result.ResultType == ResultType.Arrays) { LoadArray(pipeStream); } else if (Result.ResultType == ResultType.Bulck) { LoadBulck(pipeStream); } } } }