public Boolean Process() { Boolean retVal = false; try { //!!!This may cause issues with UWP String stringContents = File.ReadAllText((String)_fullPath.Value); _stringContents.SetValue(stringContents); retVal = true; } finally { if (retVal) { Processed?.Invoke(this, EventArgs.Empty); } } if (retVal) { return(_next[0].Process()); } else { return(false); } }
public override int GetHashCode() { int hash = 1; if (MsgCmd != 0) { hash ^= MsgCmd.GetHashCode(); } if (Uuid.Length != 0) { hash ^= Uuid.GetHashCode(); } if (TimeStart.Length != 0) { hash ^= TimeStart.GetHashCode(); } if (TimeEnd.Length != 0) { hash ^= TimeEnd.GetHashCode(); } if (ImageBase64.Length != 0) { hash ^= ImageBase64.GetHashCode(); } if (Processed != 0) { hash ^= Processed.GetHashCode(); } hash ^= targetFeatureList_.GetHashCode(); hash ^= targetResultList_.GetHashCode(); return(hash); }
public IActionResult Process(int id) { var actionItem = actionItemRepository.Get(id); if (actionItem.CalculateUnallocatedPayment() != 0) { ModelState.AddModelError("Error", "Cannot process"); return(RedirectToAction("Details", new { id = id })); } var processed = new Processed { Id = actionItem.Id, Status = StatusType.PendingApproval }; processed.Fees = actionItem.Fees; processed.PaymentGroup = actionItem.PaymentGroup; processed.Remissions = actionItem.Remissions; actionItemRepository.Remove(actionItem); actionItemRepository.Add(processed); return(RedirectToAction("Index")); }
/// <summary> /// Processes the queued filenames, reading them as GR2 data, /// renaming them to an appropriate name, and returning data about /// the rename. /// </summary> public IEnumerable <Processed> Process(string outputDirectory) { while (this.filepaths.Count > 0) { string filePath = this.filepaths.Dequeue(); Processed processed = new Processed { CurrentName = filePath, }; try { string generatedName = GranReader.GetGR2Name(filePath); if (generatedName.Length > 0) { string originalFilename = Path.GetFileNameWithoutExtension(filePath); string from = filePath; processed.NewName = Path.Combine(outputDirectory, $"{generatedName}_{originalFilename}.gr2"); if (processed.CurrentName != processed.NewName) { File.Move(processed.CurrentName, processed.NewName); } } } catch (Exception e) { processed.Err = new Exception($"Failed to process {filePath}: {e.Message}"); } yield return(processed); } }
public override Expression Visit(Expression node) { History.Push(node); if (node is BinaryExpression) { var binary = node as BinaryExpression; Visit(binary.Right); VisitBinary(binary); Visit(binary.Left); } else if (node is MemberExpression) { var member = node as MemberExpression; if (!Processed.Contains(member)) { if (!(member.Expression is ParameterExpression)) { Visit(member.Expression); Concatenate("of"); } VisitMember(member); } } else { node = base.Visit(node); } History.Pop(); return(node); }
// 4 - Raise the notification event // by convention event publisher methods must be // protected virtual void and start with 'On' protected virtual void OnProcessed(string message) { //Check if there are subscribers to the event and raise the subscriber's event handlers Processed?.Invoke(this, new MessageEventArgs() { Msg = message }); }
private void SaveDateWave() { WavFile new_file = new WavFile(FileName.Remove(FileName.Length - 4) + "-Modify.wav"); //выходной файл Line.Points.ForEach(p => Processed.WriteSample((float)p.Y)); new_file.WriteData(Processed); }
/* We begin from start point and spread waves to all sides * -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 * -2 -2 -1 -2 -> -2 -2 -1 -2 -> -2 -2 -1 -2 -> -2 -2 -1 -2 -> -2 -2 4 -2 * -2 -1 -1 -2 -2 -1 -1 -2 -2 2 -1 -2 -2 2 3 -2 -2 2 3 -2 * 0 -1 -2 -2 0 1 -2 -2 0 1 -2 -2 0 1 -2 -2 0 1 -2 -2 * * During executing we mark all found squares as related * to main square (what was used as start point) * If there are another water squares that are not related * to 'lake' then they won't be marked as related and * would be handled during the next calling of this method */ private void FindRelated(Square startPoint) { const int isNotVisited = -1, doNotVisit = -2; bool add = true; int mapHeight = Processed.GetLength(0); int mapWidth = Processed.GetLength(1); int x, y, step = 0; // Making "virtual" map for searching int[,] map = GenerateMap(mapHeight, mapWidth, isNotVisited, doNotVisit); // We will begin searching from this point map[startPoint.Y, startPoint.X] = 0; startPoint.IsMain = true; // While we have anything to mark while (add == true) { add = false; for (y = 0; y < mapHeight; y++) { for (x = 0; x < mapWidth; x++) { if (map[y, x] == step) { // If square is not main then add it as related to main var item = WaterSquares.First(s => s.Y == y && s.X == x); if (!item.IsMain) { startPoint.AddRelatedSquare(item); item.IsRelated = true; } // Mark surround squares if (y - 1 >= 0 && map[y - 1, x] != doNotVisit && map[y - 1, x] == isNotVisited) { map[y - 1, x] = step + 1; } if (x - 1 >= 0 && map[y, x - 1] != doNotVisit && map[y, x - 1] == isNotVisited) { map[y, x - 1] = step + 1; } if (y + 1 < mapHeight && map[y + 1, x] != doNotVisit && map[y + 1, x] == isNotVisited) { map[y + 1, x] = step + 1; } if (x + 1 < mapWidth && map[y, x + 1] != doNotVisit && map[y, x + 1] == isNotVisited) { map[y, x + 1] = step + 1; } } } } step++; add = step <= mapHeight * mapWidth; } }
public void Process(TableRequests table) { var foods = table.Get <Food>(); foreach (Food food in foods) { food.Prepare(); } Processed?.Invoke(table); }
/// <inheritdoc /> public void Removed(string file) { var item = Processing.First(entry => entry.File == file); Processing.Remove(item); item.FileStatus = FileStatus.Aborted; Processed.Add(item); }
private void Concatenate(string value, Expression expression) { if (Processed.Contains(expression)) { return; } Result.Push(new { value, expression, expression.NodeType }); Processed.Add(expression); }
/// <inheritdoc /> public void DoesNotExists(string file) { var item = Processing.First(entry => entry.File == file); Processing.Remove(item); item.FileStatus = FileStatus.DoesNotExist; Processed.Add(item); }
public void DeleteProcessed(List <DadTupleId> outputIds) { Deleted.UnionWith(outputIds); foreach (var outputId in outputIds) { Processed.Remove(outputId); } // TODO: remove from shared? }
public override int GetHashCode() { var hashCode = -1374379752; hashCode = hashCode * -1521134295 + Processed.GetHashCode(); hashCode = hashCode * -1521134295 + ToProcess.GetHashCode(); hashCode = hashCode * -1521134295 + Errors.GetHashCode(); hashCode = hashCode * -1521134295 + Processing.GetHashCode(); return(hashCode); }
public override ValueTask <EventHandlingStatus> HandleEvent(IMessageConsumeContext ctx) { Count++; if (ctx == null) { throw new InvalidOperationException(); } Processed.Add(ctx); return(default);
public IActionResult CreateProcessed() { var actionItem = new Processed { Id = idGenerator.GetId(), Status = StatusType.InProgress }; actionItemRepository.Add(actionItem); return(View("ActionItem", actionItem)); }
public void SaveProcessedTuples(DadTupleId upstreamId, List <DadTuple> processedTuples) { Debug.Assert(!Processed.ContainsKey(upstreamId)); Debug.Assert(!Delivered.Contains(upstreamId)); foreach (var processedTuple in processedTuples) { Debug.Assert(!Deleted.Contains(processedTuple.Id)); } Processed.Add(upstreamId, processedTuples); // TODO: remove from shared? }
public void AddSample(float sample) { SampleProcessed++; if (Samples.Count < FFTLength) { Enqueue(sample); } else { Enqueue(sample); CurrentGap++; if (CurrentGap < SampleGap && SampleProcessed != SampleCount) { return; } CurrentGap = 0; if (Samples.Count == FFTLength) { Complex[] fft = new Complex[FFTLength]; int i = 0; foreach (var s in Samples) { fft[i].X = (float)(s * FastFourierTransform.HammingWindow(i, FFTLength)); fft[i].Y = 0; i++; } FastFourierTransform.FFT(true, m, fft); SampleAnalysis[] result = new SampleAnalysis[FFTLength]; for (int n = 0; n < fft.Length; n++) { result[n].Frequency = Physics.GetFrequency(n, AudioReader.WaveFormat.SampleRate, FFTLength); result[n].Amplitude = Physics.GetAmplitude(fft[n]); } Processed?.Invoke(result); } } }
private void OnProcessed(Processed evt) { if (this._map.Remove(evt.Id, out var node) && this.IsRecovering) { // In recovery mode, the message is expected to have already been sent. // However, due to processing outside a state change (Persist), the queue will be reconstructed without the proper "Dequeue" this._queue.Remove(node); } else { // In the normal flow, we tell send back the message to the actor. evt.ActorRef.Tell(evt.Message, this.Self); } }
public virtual ActionResult Process(StripePaymentModel model) { try { var provider = GatewayContext.Payment.GetProviderByKey(Constants.Stripe.GatewayProviderSettingsKey); //var paymentMethod = CheckoutManager.Payment.GetPaymentMethod(); var paymentMethod = this.CheckoutManager.Payment.GetPaymentGatewayMethods().FirstOrDefault(x => x.PaymentMethod.ProviderKey == provider.Key).PaymentMethod; if (paymentMethod == null) { var ex = new NullReferenceException("PaymentMethod was null"); return(HandlePaymentException(model, ex)); } var args = new ProcessorArgumentCollection(); args.SetTokenId(model.Token); args.SetCustomerName(model.Name); args.SetCustomerEmail(model.Email); // We can now capture the payment // This will actually make a few more API calls back to Stripe to get required transaction // data so that we can refund the payment later through the back office if needed. var attempt = CheckoutManager.Payment.AuthorizeCapturePayment(paymentMethod.Key, args); // Raise the event to process the email Processed.RaiseEvent(new PaymentAttemptEventArgs <IPaymentResult>(attempt), this); var resultModel = CheckoutPaymentModelFactory.Create(CurrentCustomer, paymentMethod, attempt); resultModel.SuccessRedirectUrl = model.SuccessRedirectUrl; string invoiceId = attempt.Invoice.Key.ToString().EncryptWithMachineKey(); if (attempt.Payment.Success) { CustomerContext.SetValue("invoiceKey", attempt.Invoice.Key.ToString()); } if (!resultModel.ViewData.Success) { var invoiceKey = attempt.Invoice.Key; var paymentKey = attempt.Payment.Result != null ? attempt.Payment.Result.Key : Guid.Empty; EnsureDeleteInvoiceOnCancel(invoiceKey, paymentKey); } return(HandlePaymentSuccess(resultModel, invoiceId)); } catch (Exception ex) { return(HandlePaymentException(model, ex)); } }
private async Task ProcessQueue(CancellationToken cancellationToken) { while (!cancellationToken.IsCancellationRequested) { cancellationToken.ThrowIfCancellationRequested(); { T item = default(T); bool dequeued = false; lock (queueLock) { if (processingQueue.Count > 0) { item = processingQueue.Dequeue(); queueSet.Remove(item); currentlyProcessing.Add(item); dequeued = true; } } if (dequeued) { try { await Process(item, cancellationToken); } finally { lock (queueLock) { currentlyProcessing.Remove(item); } } Interlocked.Increment(ref processedItemCount); Processed?.Invoke(this, BuildEventArgs()); } else { await Task.Delay(PauseWhenQueueEmpty, cancellationToken); } } } cancellationToken.ThrowIfCancellationRequested(); }
private void InvokeEventAndCleanup(ReplayStatus status, string replayPath = "", string gifPath = "", string outputPath = "", string errorMessage = "") { if (!String.IsNullOrEmpty(replayPath) && File.Exists(replayPath)) { File.Delete(replayPath); } if (!String.IsNullOrEmpty(gifPath) && File.Exists(gifPath)) { if (status != ReplayStatus.GameError) { File.Move(gifPath, outputPath, true); } File.Delete(gifPath); } Processed?.Invoke(this, new ReplayEventArgs(status, outputPath, errorMessage)); }
public override int GetHashCode() { int hash = 1; if (Blockchain.Length != 0) { hash ^= Blockchain.GetHashCode(); } if (SrcAddress.Length != 0) { hash ^= SrcAddress.GetHashCode(); } if (DstAddress.Length != 0) { hash ^= DstAddress.GetHashCode(); } if (Order.Length != 0) { hash ^= Order.GetHashCode(); } if (Amount.Length != 0) { hash ^= Amount.GetHashCode(); } if (Tx.Length != 0) { hash ^= Tx.GetHashCode(); } if (Block.Length != 0) { hash ^= Block.GetHashCode(); } if (Processed != false) { hash ^= Processed.GetHashCode(); } if (Sighash.Length != 0) { hash ^= Sighash.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
private string FillWaterSquares() { var processed = Processed.Cast <Square>() .Where(x => x.SquareType == SquareType.Water) .Order(); WaterSquares = new List <Square>(); var added = new List <Square>(); foreach (var item in processed) { WaterSquares.Add(item); } return(null); }
private void Timer_Tick(object sender, EventArgs e) { //Data has 7 parts: Measure;AreaId;Id;AreaName;Name;Value;Units //var id = rnd.Next(0, 6); //Processed.ReceiveData($"Temperature;0;{id};Window 0;Left;{rnd.Next(25, 30)};C"); //Compound data example //Real Package Processed.ReceiveData($"Battery;0;0;Main;Battery;{rnd.Next(25, 30)};C", new byte[] { 0, 10, 64, 88, 0, 0, 88, 8, 0, 88, 0, 0, 2, 143, 1, 2, 146, 4, 1, 41, 4, 1, 44, 3, 3, 4, 2, 143, 1, 44, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 8, 253, 175, 2, 28, 2, 228, 2, 168, 31 }); Processed.ReceiveDataSerialPort(); }
public void Iterate(DateTime?forced) { Progress = 0d; Results.Clear(); Left.Clear(); for (int i = 0; i < Data.Count; i++) { Record subject = Data[i]; string date = forced?.ToString("dd.MM.yy"); if (subject.Temp == string.Empty) { subject.Temp = date; } var result = Process(subject, false); if (result == null) { result = Process(subject, true); } Application.Current.Dispatcher.Invoke(() => { if (result != null) { Results.Add(result); } else { var left = new Processed() { Number = i + 1, Fullname = $"{Data[i].Surname} {Data[i].Name}", Result = $"{Data[i].Result}, {Data[i].Temp}", CheckDates = null, }; Left.Add(left); } }); Progress = 100d * ((double)(i + 1) / (double)Data.Count); } }
private void BuildPatterns(string pattern) { if (Processed.Contains(pattern)) { return; } Processed.Add(pattern); string[] groups = pattern.Split('~'); for (int i = 0; i < groups.Length; i++) { string v = groups[i]; if (v == "0" || v == "1" || v == "2") { List <string> target = v == "0" ? S1 : (v == "1" ? S2 : S3); BuildSeries(pattern, i, target); } } }
string FindLowestCostNode() { var lowestCost = double.PositiveInfinity; string lowestCostNode = null; var nodes = Costs.Where(n => !Processed.Contains(n.Key)); foreach (var node in nodes) { var cost = node.Value; if (cost < lowestCost) { lowestCost = cost; lowestCostNode = node.Key; } } return(lowestCostNode); }
void textBox_LostFocused(IFocusable sender, FocusEventArgs args) { string text = textBox.Text; IsValid = roomInfo.PasswordHash == WebManager.GetPasswordHash(text); textBox.Parent.RemoveChild(textBox); if (Processed != null) { Processed.Invoke(this, EventArgs.Empty); } if (!IsValid) { this.InsertChild(new TextureString(device, Utility.Language["NotCorrectPassword"], 20, true, PPDColors.White) { Position = new Vector2(400, 250) }, 0); } }
private void OnSample(object sender, SampleEventArgs e) { FFTBuffer[FFTPosition].X = (float)(e.Right * FastFourierTransform.HammingWindow(FFTPosition, FFTLength)); // e.Right ? seems equal to e.Left in this case (mono?) FFTBuffer[FFTPosition].Y = 0; FFTPosition++; if (FFTPosition >= FFTBuffer.Length) { FastFourierTransform.FFT(true, (int)Math.Log(FFTLength, 2.0), FFTBuffer); FFTPosition = 0; SampleAnalysis[] result = new SampleAnalysis[FFTLength]; for (int n = 0; n < FFTBuffer.Length; n++) { result[n].Frequency = Physics.GetFrequency(n, AudioReader.WaveFormat.SampleRate, FFTLength); result[n].Amplitude = Physics.GetAmplitude(FFTBuffer[n]); } Processed?.Invoke(result); } }