gpt4 book ai didi

c# - 尝试从 Team City Sharp 服务器获取开始日期

转载 作者:太空宇宙 更新时间:2023-11-03 16:31:54 25 4
gpt4 key购买 nike

这是我获取到 TeamCitySharp 服务器的 Json 连接的代码。本地主机是我的 Json 连接。现在,我正试图让开始日期在我转到本地主机时显示,但它显示为空。有想法该怎么解决这个吗?

 HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://localhost:81/Status/AllStatuses");
var response = request.GetResponse();
var reader = new StreamReader(response.GetResponseStream());
var responseString = reader.ReadToEnd();

var serializer = new JavaScriptSerializer();
serializer.RegisterConverters((new[] { new DynamicJsonConverter() }));
dynamic obj = serializer.Deserialize(responseString, typeof(object));

foreach (var objects in obj)
{

foreach (var project in client.Projects)
{


foreach (var build in project.Builds)
{
bs.date = project.ProjectStartDate.ToString();

这是在单独项目中的另一个 Controller 上调用 Jsonresult。

public JsonResult AllStatuses() //from the json called in the _client view
{
var buildStatuses = new List<BuildStatus>();

var projects = Client.AllProjects();

//var projects = storeDB.Projects.Include("Builds").ToList();
//var buildStatuses = new List<BuildStatus>();


foreach (var project in projects)
{
try
{
var buildConfigs = Client.BuildConfigsByProjectId(project.Id);

foreach (var buildConfig in buildConfigs)
{
var build = Client.LastBuildByBuildConfigId(buildConfig.Id);

var b = new BuildStatus();
b.id = buildConfig.Id.ToString();
if (b.date != null)
b.date = b.date.ToString();
if (b.status != null)
b.status = build.Status.ToString();
buildStatuses.Add(b);
}
} catch { }
}
//var query = buildStatuses.OrderBy(x => x.status); // Create a sorted list from Error - Unknown

return Json(buildStatuses, JsonRequestBehavior.AllowGet);
}

最佳答案

我不确定这个问题对提出它的人是否仍然有意义。我会为可能遇到相同问题的其他人回答。

有一个 FluentTc 库,可通过其 REST API 轻松访问 TeamCity。有一种方法可以检索带有开始和/或结束日期的构建:


IList 构建 =
new RemoteTc().Connect(h => h.ToHost("teamcity.codebetter.com").AsGuest())
.GetBuilds(b =>
b.BuildConfiguration(c =>
c.Id("FluentTc_FluentTcDevelop"))
.Branch(r => r.Branched()),
i => i.IncludeStatusText().IncludeStartDate().IncludeFinishDate());



该库作为 nuget 包提供:https://www.nuget.org/packages/fluenttc

关于c# - 尝试从 Team City Sharp 服务器获取开始日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10541726/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com