public OrbColor GetCurrentColor() { DequeExpiredProgressColors(); if (_builders.OrdersCount == 0 && _curColor.Color == _progressColor) { _curColor = _lastNotProgressColor; } return(_curColor.Color); }
public ProgressColorCounter(OrbColor progressColor, OrbColor successColor, TimeSpan buildTimeout) { _lastNotProgressColor = new ColorInfo(OrbColor.Red, DateTime.Now.AddSeconds(-5)); _progressColor = progressColor; _successColor = successColor; _curColor = new ColorInfo(progressColor, DateTime.Now); _builders = new BuilderInfos(this); _buildTimeout = buildTimeout; }
public void ProcessColor(OrbColor color, string sender) { BuilderInfo builderInfo = _builders.GetInfo(sender); if (color == _progressColor) { DateTime buildStartTime = DateTime.Now; builderInfo.ProgressQueue.Enqueue(buildStartTime); _curColor = new ColorInfo(color, buildStartTime); } else { DateTime expectedBuildStartedTime = builderInfo.GetFirstBuildTimeStarted(); if (_builders.OrdersCount > 0) { DateTime buidStarted = builderInfo.ProgressQueue.Dequeue(); if (color == _successColor) { _buildTimeout = CalcBuildTimeout(buidStarted); } DequeExpiredProgressColors(); } if (_builders.OrdersCount == 0) { if (expectedBuildStartedTime.Ticks >= _lastNotProgressColor.BuildStartTime.Ticks) { _curColor = new ColorInfo(color, expectedBuildStartedTime); } else { _curColor = _lastNotProgressColor; } } _lastNotProgressColor = new ColorInfo(color, expectedBuildStartedTime); } }