public User Login() { if (_redmineManager != null) { _redmineManager.GetCurrentUser(); } var host = Settings.Default.RedMineHost; var account = Settings.Default.Account; var passWord = Settings.Default.Password; var apiKey = Settings.Default.ApiKey; if (!apiKey.IsNullOrEmpty()) { _redmineManager = new RedmineManager(host, apiKey, timeout: new TimeSpan(0, 0, 5)); } else if (!account.IsNullOrEmpty()) { _redmineManager = new RedmineManager(host, account, passWord, timeout: new TimeSpan(0, 0, 5)); } if (_redmineManager is null) { throw new NotLoginException(); } try { return(_redmineManager.GetCurrentUser()); } catch { throw new NotLoginException(); } }
private static bool GetCredentialsIfNeeded(Configuration configuration) { if (configuration.OpenTickets) { // Get use name and password Console.Write("Redmine Username: "******"Redmine password: "); _password = Console.ReadLine(); _redmineManager = new RedmineManager(configuration.RedmineUrl, _user, _password); try { _redmineManager.GetCurrentUser(); return true; } catch (RedmineException) { return false; } } return true; }
public void Should_Connect_With_Username_And_Password() { var a = new RedmineManager(Helper.Uri, Helper.Username, Helper.Password); var currentUser = a.GetCurrentUser(); Assert.NotNull(currentUser); Assert.True(currentUser.Login.Equals(Helper.Username), "usernames not equals."); }
public void Should_Get_Current_User() { User currentUser = redmineManager.GetCurrentUser(); Assert.IsNotNull(currentUser, "Current user is null."); Assert.AreEqual(currentUser.ApiKey, Helper.ApiKey, "Current user api key is invalid."); }
public void Should_Connect_With_Api_Key() { var a = new RedmineManager(Helper.Uri, Helper.ApiKey); var currentUser = a.GetCurrentUser(); Assert.NotNull(currentUser); Assert.True(currentUser.ApiKey.Equals(Helper.ApiKey),"api keys not equals."); }
private static bool GetCredentialsIfNeeded(Configuration configuration) { if (configuration.OpenTickets) { // Get use name and password Console.Write("Redmine Username: "******"Redmine password: "); _password = Console.ReadLine(); _redmineManager = new RedmineManager(configuration.RedmineUrl, _user, _password); try { _redmineManager.GetCurrentUser(); return(true); } catch (RedmineException) { return(false); } } return(true); }
public static RedmineService ConnectAndCreate(string url, string apiKey) { var manager = new RedmineManager(url, apiKey); manager.GetCurrentUser(); return(new RedmineService(manager)); }
public void Should_Connect_With_Api_Key() { var a = new RedmineManager(Credentials.Uri, Credentials.ApiKey); var currentUser = a.GetCurrentUser(); Assert.NotNull(currentUser); Assert.True(currentUser.ApiKey.Equals(Credentials.ApiKey), "api keys not equals."); }
public void Should_Connect_With_Username_And_Password() { var a = new RedmineManager(Credentials.Uri, Credentials.Username, Credentials.Password); var currentUser = a.GetCurrentUser(); Assert.NotNull(currentUser); Assert.True(currentUser.Login.Equals(Credentials.Username), "usernames not equals."); }
private static void OpenTicket(string dump, DumpData res, Configuration configuration) { OwnershipData ownershipData = configuration.Owners.FirstOrDefault(o => o.Filter == res.FilterOfInterest); Owner assignee = configuration.DefaultOwner; if (ownershipData != null) { assignee = ownershipData.Owner; } var author = new IdentifiableName { Id = _redmineManager.GetCurrentUser().Id }; IdentifiableName assignedTo = _projectMembers.SingleOrDefault(pm => pm != null && pm.Name == assignee.Name) ?? _projectMembers.SingleOrDefault(pm => pm != null && pm.Name == configuration.DefaultOwner.Name); if (assignedTo == null) { // TODO: do something about this? } string subject = "Unexpected exception occurred"; string description = string.Format("Please investigate a dump located at {0}.{1}{2}Here's the beginning of the call stack for the last event:{3}{4}", dump, Environment.NewLine, Environment.NewLine, Environment.NewLine, string.Join(Environment.NewLine, res.CallStack.Take(Math.Min(res.CallStack.Count, 30)))); if (res.FrameOfInterest != null) { subject = string.Format("A problem occurred in {0}.{1}: {2}", res.FrameOfInterest.ModuleName, res.FrameOfInterest.MethodName, res.LastEvent.Description); description = string.Format("There was a problem in {0}: {1}.{2}Please investigate a dump located at {3}.{4}{5}Here's the call stack for the last event:{6}{7}", res.FrameOfInterest.ModuleName, res.LastEvent, Environment.NewLine, dump, Environment.NewLine, Environment.NewLine, Environment.NewLine, string.Join(Environment.NewLine, res.CallStack.Take(Math.Min(res.CallStack.Count, 30)))); } var issue = new Issue { Subject = subject.Substring(0, Math.Min(subject.Length, 255)), Description = description, AssignedTo = assignedTo, Author = author, Project = new IdentifiableName { Id = _project.Id }, }; _redmineManager.CreateObject(issue); }
public static bool Authentificate() { Console.WriteLine(DateTime.Now + ": ServerClass.Authentificate"); try { if (Properties.Settings.Default.LoginType) { redmine = new RedmineManager(Properties.Settings.Default.RedmineAddress, Properties.Settings.Default.UserName, Properties.Settings.Default.Password, MimeFormat.Json); } else { redmine = new RedmineManager(Properties.Settings.Default.RedmineAddress, Properties.Settings.Default.ApiKey, MimeFormat.Json); } CurrentUser = redmine.GetCurrentUser(); Connected_to_server = true; return(true); } catch (Exception) { Connected_to_server = false; return(false); } }
public void RedmineUser_ShouldReturnCurrentUser() { User currentUser = redmineManager.GetCurrentUser(); Assert.AreEqual(currentUser.ApiKey, ConfigurationManager.AppSettings["apiKey"]); }
/// <summary> /// Gets the current user asynchronous. /// </summary> /// <param name="redmineManager">The redmine manager.</param> /// <param name="parameters">The parameters.</param> /// <returns></returns> public static Task <User> GetCurrentUserAsync(this RedmineManager redmineManager, NameValueCollection parameters = null) { return(Task.Factory.StartNew(() => redmineManager.GetCurrentUser(parameters), CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default)); }
/// <summary> /// Gets the current user asynchronous. /// </summary> /// <param name="redmineManager">The redmine manager.</param> /// <param name="parameters">The parameters.</param> /// <returns></returns> public static Task <User> GetCurrentUserAsync(this RedmineManager redmineManager, NameValueCollection parameters = null) { return(delegate { return redmineManager.GetCurrentUser(parameters); }); }
/// <summary> /// Gets the current user asynchronous. /// </summary> /// <param name="redmineManager">The redmine manager.</param> /// <param name="parameters">The parameters.</param> /// <returns></returns> public static Task <User> GetCurrentUserAsync(this RedmineManager redmineManager, NameValueCollection parameters = null) { return(Task.Factory.StartNew(() => redmineManager.GetCurrentUser(parameters), TaskCreationOptions.LongRunning)); }
public User getCurrentUser() { return(_manager.GetCurrentUser()); }
public CommonRemineEntities.User GetCurrentUser() { var currentUser = RedmineManager.GetCurrentUser(); return(EntityMapper.Map <CommonRemineEntities.User>(currentUser)); }