本文整理汇总了C#中System.Net.Connection.Authenticate方法的典型用法代码示例。如果您正苦于以下问题:C# Connection.Authenticate方法的具体用法?C# Connection.Authenticate怎么用?C# Connection.Authenticate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Net.Connection
的用法示例。
在下文中一共展示了Connection.Authenticate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
//todo use mono.options https://www.nuget.org/packages/Mono.Options/
if (args.Length < 5)
{
Console.WriteLine("YouTrack Release helper, marks a version as released and creates version numbers for follow up releases. Works with version numbers up to 3 digits");
Console.WriteLine("");
Console.WriteLine("Usage:");
Console.WriteLine(" YouTrackRelease --server=<server> --username=<username> --password=<password> --project=<project> --version=<version>");
Console.WriteLine("");
Console.WriteLine("Options:");
Console.WriteLine(" --server=<server> Server address, ie http://youtrack.domain.com/youtrack");
Console.WriteLine(" --username=<username> User with admin role");
Console.WriteLine(" --password=<password> ");
Console.WriteLine(" --project=<project> ID of project being released");
Console.WriteLine(" --version=<version> The version number to be released (i.e 1.2.3)");
return;
}
var server = GetArgNotNull(args, "--server");
var username = GetArgNotNull(args, "--username");
var password = GetArgNotNull(args, "--password");
var projectId = GetArgNotNull(args, "--project");
var version = GetArgNotNull(args, "--version");
var uri = new Uri(server);
Console.WriteLine("Connecting to server: {0}, {1}, {2}", uri, uri.Port, uri.AbsolutePath);
var conn = new Connection(uri.Host, uri.Port, uri.Scheme == "https", uri.AbsolutePath);
conn.Authenticate(username, password);
var projectManagement = new ProjectManagement(conn);
var project = projectManagement.GetProject(projectId);
if (project == null)
throw new Exception("Project does not exist");
var existingVersions = projectManagement.GetVersions(project).Select((v) => v.Name);
if (!existingVersions.Contains(version))
throw new Exception("Version does not exist");
Console.Out.WriteLine("Releasing version: {0}", version);
projectManagement.UpdateVersion(project, new ProjectVersion { IsReleased = true, Name = version, ReleaseDate = JavaTimeNow() });
var currentVersion = new VersionNumber(version);
var nextVersions = currentVersion.GetNextReleaseVersions().Select((v) => v.ToString());
var missingVersions = nextVersions.Where((v) => !existingVersions.Contains(v));
foreach (var newVersion in missingVersions)
{
Console.Out.WriteLine("Adding version: {0}", newVersion);
projectManagement.AddVersion(project, new ProjectVersion {IsReleased = false, Name = newVersion});
}
if (Debugger.IsAttached)
Console.ReadLine();
}