public static void TickRate(this ProgressBarBase pb, string message = null) { var rc = pb.GetOrSetAttached(() => new RateCalc()).Value; rc.Tick(); pb.Tick($"{rc} - {message}"); }
private static async Task <(bool Success, string[] Messages)> CreateEntities(ProgressBarBase progressBar, IApiClient apiClient, string tenantCode, string environmentCode, string definition, string dataSource, ICollection <(int RowNumber, IDictionary <string, object> Values)> data)
public static IObserver <Unit> ThrottleTicks(this ProgressBarBase bar, TimeSpan?interval = null) { var observer = ThrottleProgress(bar, interval); var ticks = new Subject <Unit>(); ticks.Scan(bar.CurrentTick, (count, _) => count + 1).Subscribe(observer); return(ticks.AsObserver()); }
public static IObserver <int> ThrottleProgress(this ProgressBarBase bar, TimeSpan?interval = null) { var s = new Subject <int>(); var tillMax = s.TakeWhile(x => x < bar.MaxTicks); tillMax.Sample(interval ?? TimeSpan.FromMilliseconds(100)).Subscribe(val => bar.Tick(val)); //sample values based on interval tillMax.Subscribe(_ => { }, //synchronous completion e => bar.Message = "Error: " + e.Message, () => bar.Tick(bar.MaxTicks)); return(s.AsObserver()); }
/// <summary> /// Makes the progress bar vertical and whether it starts from bottom or not. /// </summary> /// <param name="progressBarBase">The progress bar instance that this method extends.</param> /// <param name="bottom">Sets whether progress bar should start from bottom or not.</param> /// <returns>Current component.</returns> public static ProgressBarBase Vertical(this ProgressBarBase progressBarBase, bool bottom = true) { progressBarBase.Core.Properties.Add("IsVertival", true); progressBarBase.AddCssClass(string.Format("{0}-vertical", progressBarBase.GetBaseClass())); if (bottom) { progressBarBase.AddCssClass(string.Format("{0}-bottom", progressBarBase.GetBaseClass())); } return(progressBarBase); }
private Exception PushFiles(CancellationToken token, ProgressBarBase parentBar, ProgressBarBase parseBar, ProgressBarBase pushBar) { try { var repo = new MssqlRepository(); var name = Transistor.ToTableName( new Transistor(VtnVoltage, VtnSigma, VtnDeviation), new Transistor(VtpVoltage, VtpSigma, VtpDeviation) ); repo.Use(name); using (var pipeline = new PipeLine.PipeLine(token)) { var first = pipeline.AddSelectMany(Parallel, QueueBuffer, InputFiles, RecordFactory.BuildFromCsv); first.OnInterval += s => parseBar?.Tick($"parsed: {s}"); first.OnFinish += () => parentBar?.Tick($"Finished parse csv files. {first.TotalResultsCount} records were parsed"); pipeline.Invoke(() => { var list = new List <Record>(); var sum = 0; foreach (var r in first.Results.GetConsumingEnumerable()) { list.Add(r); pushBar.MaxTicks++; if (list.Count != QueueBuffer) { continue; } sum += list.Count; repo.BulkUpsert(list); foreach (var record in list) { pushBar.Tick($"{record}"); } pushBar.Message = $"{sum} records pushed"; list = new List <Record>(); } if (!list.Any()) { return; } sum += list.Count; repo.BulkUpsert(list); foreach (var record in list) { pushBar.Tick($"{record}"); } pushBar.Message = $"{sum} records pushed"; }); parentBar.Tick("Finished push"); } } catch (OperationCanceledException e) { return(e); } catch (Exception e) { return(e); } return(null); }
private void SpawnProgressBar() { delayTimer.Stop(); progressBar = CreateProgressBar(); progressBar.Tick((int)(currentValue * Scaling)); }
/// <summary> /// Makes the progress bar to start from right side. /// </summary> /// <param name="progressBarBase">The progress bar instance that this method extends.</param> /// <returns>Current component.</returns> public static ProgressBarBase Right(this ProgressBarBase progressBarBase) { progressBarBase.AddCssClass(string.Format("{0}-right", progressBarBase.GetBaseClass())); return(progressBarBase); }
/// <summary> /// Adds border to the progress bar. /// </summary> /// <param name="progressBarBase">The progress bar instance that this method extends.</param> /// <returns>Current component.</returns> public static ProgressBarBase Border(this ProgressBarBase progressBarBase) { progressBarBase.AddCssClass(string.Format("{0}-bordered", progressBarBase.GetBaseClass())); return(progressBarBase); }
/// <summary> /// Sets the size of the progress bar. /// </summary> /// <param name="progressBarBase">The progress bar instance that this method extends.</param> /// <param name="size">The value of the size.</param> /// <returns>Current component.</returns> public static ProgressBarBase Size(this ProgressBarBase progressBarBase, BootstrapSizeBase size) { SizeHelper.Size(progressBarBase, size); return(progressBarBase); }