private CIJob InitialiseJob(JToken projectJson, CIServer server) { if (!GetBool(projectJson["active"])) { return(default(CIJob)); } var _job = new CIJob(); _job.ServerType = CIServerType.TravisCI; _job.ServerName = server.Name; _job.Name = GetString(projectJson["slug"]); // is the server open source, pro or enterprise? if (server.Url.Contains("api.travis-ci.org")) { _job.Url = string.Format("https://travis-ci.org/{0}", _job.Name); } else if (server.Url.Contains("api.travis-ci.com")) { _job.Url = string.Format("https://travis-ci.com/{0}", _job.Name); } else { _job.Url = string.Format("{0}/{1}", server.Url.Split(new[] { "/api/" }, StringSplitOptions.RemoveEmptyEntries)[0], _job.Name); } _job.BuildId = GetString(projectJson["last_build_number"]); _job.TimeStamp = GetDateTime(projectJson["last_build_started_at"]); _job.Duration = GetInt(projectJson["last_build_duration"]); _job.BuildStatus = MapBuildStatus(projectJson["last_build_state"].ToString()); return(_job); }
private void UpdateJob(CIJob jobToUpdate, CIJob job) { jobToUpdate.BuildId = job.BuildId; jobToUpdate.BuildStatus = job.BuildStatus; jobToUpdate.Duration = job.Duration; jobToUpdate.TimeStamp = job.TimeStamp; }
private CIJob InitialiseJob(JToken projectJson, CIServer server) { var job = new CIJob(); job.ServerType = CIServerType.AppVeyor; job.ServerName = server.Name; job.Name = string.Format("{0} ({1})", projectJson["name"], projectJson["repositoryBranch"]); job.Url = string.Format("{0}/{1}/{2}", server.Url.TrimEnd('/', '\\'), projectJson["accountName"], projectJson["slug"]); job.Url = job.Url.Replace("api/", string.Empty); job.Url = job.Url.Replace("/projects/", "/project/"); var buildsJson = (JArray)projectJson["builds"]; if (buildsJson == default(JArray) || !buildsJson.Any()) { job.BuildStatus = BuildStatusType.Unknown; return(job); } var buildJson = buildsJson.First; job.BuildId = GetString(buildJson["version"]); job.TimeStamp = GetDateTime(buildJson["started"]); var finished = GetDateTime(buildJson["finished"]); job.Duration = finished != DateTime.MinValue ? (int)(finished - job.TimeStamp).TotalMilliseconds : 0; job.BuildStatus = MapBuildStatus(buildJson["status"].ToString()); return(job); }
private CIJob UpdateJob(CIJob job, string token) { if (job == default(CIJob)) { return(job); } // retrieve job page json var _jobJson = GetJson(job.Url, token); // if no job then return if (_jobJson == default(JObject)) { return(job); } // grab latest build ID job.BuildId = _jobJson["lastBuild"] == default(JArray) || !_jobJson["lastBuild"].Any() ? "0" : GetString(_jobJson["lastBuild"]["number"]); //retrieve build page json if (string.IsNullOrWhiteSpace(job.BuildId) || job.BuildId == "0") { job.Duration = 0; job.TimeStamp = DateTime.MinValue; } else { var _url = string.Format("{0}{1}", job.Url, job.BuildId); var _buildJson = GetJson(_url, token); // if no build then return current job setup if (_buildJson == default(JObject)) { return(job); } // get the duration, or the estimated duration job.Duration = _buildJson["duration"] == default(JToken) || GetInt(_buildJson["duration"]) <= 0 ? GetInt(_buildJson["estimatedDuration"]) : GetInt(_buildJson["duration"]); if (job.Duration > 0) { job.Duration = (int)(job.Duration / 1000.0); } // get the timestamp job.TimeStamp = EpochDate.AddMilliseconds(GetLong(_buildJson["timestamp"])); // update url job.Url = _url; } return(job); }
public void CoreLogic() { if (_notifyQueue != default(ConcurrentQueue <CIJob>) && _notifyQueue.Count > 0) { var job = default(CIJob); if (_notifyQueue.TryDequeue(out job) && !Interrupted && JobHandler != null) { _currentNotifyJob = job; JobHandler(job, SleepTime); } } }
public void Run() { while (!Interrupted) { if (_notifyQueue != default(ConcurrentQueue <CIJob>) && _notifyQueue.Count > 0) { var job = default(CIJob); if (_notifyQueue.TryDequeue(out job) && !Interrupted && JobHandler != null) { _currentNotifyJob = job; JobHandler(job); } } if (!Interrupted) { Thread.Sleep(SleepTime); } } }
private void NotifyJob(CIJob job) { TaskbarNotifier.ShowBalloonTip(2000, job.Name, job.BuildStatus.ToString(), ToolTipIcon.Info); }
private void NotifyJob(CIJob job, int sleep) { TaskbarNotifier.ShowBalloonTip(sleep, job.Name, string.Format("{0} on {1}", job.BuildStatus, job.ServerName), ToolTipIcon.Info); }