public void GetUserOpenIssue() { listUserRedmine.Clear(); try { NameValueCollection param = new NameValueCollection { { "Id", "*" } }; foreach (var user in redmineManager.GetObjects <User>(param)) { UserRedmine userRedmine = new UserRedmine(); userRedmine.Value = user; listUserRedmine.Add(userRedmine); if (userRedmine.Value.LastName.Equals("Чамин")) { userRedmine.EmailAddress = "*****@*****.**"; } } param = new NameValueCollection { { "status_id", "open" } }; foreach (var issue in redmineManager.GetObjects <Issue>(param)) { UserRedmine userRedmine = null; if (issue.AssignedTo == null) { userRedmine = listUserRedmine.Find(x => x.Value.Id == issue.Author.Id); } else { userRedmine = listUserRedmine.Find(x => x.Value.Id == issue.AssignedTo.Id); } UserIssue userIssue = new UserIssue(); userIssue.issue = issue; userRedmine.ListUserIssue.Add(userIssue); } this.Sort(); } catch (Exception ex) { Console.WriteLine(DateTime.Now.ToString() + " Error in GetUserOpenIssue: {0}", ex); SaveError.SaveMessage(ex.ToString()); } }
public void Should_Get_All_Issues() { var issues = redmineManager.GetObjects <Issue>(null); Assert.IsNotNull(issues, "Issues is null."); CollectionAssert.AllItemsAreInstancesOfType(issues, typeof(Issue), "Not all items are of type issue."); CollectionAssert.AllItemsAreNotNull(issues, "Issues list contains null items."); CollectionAssert.AllItemsAreUnique(issues, "Issues are not unique."); }
public GetStatuses(string key, string value) { Parameters.Add(key, value); foreach (var status in Connection.GetObjects <IssueStatus>(Parameters)) { statuses.Add(new Ticket(status.Name, status.Id)); } statuses.ToObservableCollection(); }
public void Should_Get_All_Roles() { var roles = redmineManager.GetObjects <Role>(null); Assert.IsNotNull(roles, "Get all roles returned null"); Assert.IsTrue(roles.Count == NUMBER_OF_ROLES, "Roles count != " + NUMBER_OF_ROLES); CollectionAssert.AllItemsAreNotNull(roles, "Roles list contains null items."); CollectionAssert.AllItemsAreUnique(roles, "Roles items are not unique."); CollectionAssert.AllItemsAreInstancesOfType(roles, typeof(Role), "Not all items are of type role."); }
public void RedmineTrackers_ShouldGetAllTrackers() { var trackers = redmineManager.GetObjects <Tracker>(null); Assert.IsNotNull(trackers, "Get all trackers returned null"); Assert.IsTrue(trackers.Count == NUMBER_OF_TRACKERS, "Trackers count != " + NUMBER_OF_TRACKERS); CollectionAssert.AllItemsAreNotNull(trackers, "Trackers list contains null items."); CollectionAssert.AllItemsAreUnique(trackers, "Trackers items are not unique."); CollectionAssert.AllItemsAreInstancesOfType(trackers, typeof(Tracker), "Not all items are of type Tracker."); }
public void Should_Get_IssueRelations_By_Issue_Id() { var relations = redmineManager.GetObjects <IssueRelation>(new NameValueCollection { { RedmineKeys.ISSUE_ID, ISSUE_ID } }); Assert.IsNotNull(relations, "Get issue relations by issue id returned null."); CollectionAssert.AllItemsAreNotNull(relations, "Relations contains null items."); CollectionAssert.AllItemsAreUnique(relations, "Relations items are not unique."); Assert.IsTrue(relations.Count == NUMBER_OF_RELATIONS, "Number of issue relations != " + NUMBER_OF_RELATIONS); }
public void RedmineCustomFields_ShouldGetAllCustomFields() { var customFields = redmineManager.GetObjects <CustomField>(null); Assert.IsNotNull(customFields, "Get custom fields returned null."); Assert.IsTrue(customFields.Count == NUMBER_OF_CUSTOM_FIELDS, "Custom fields count != " + NUMBER_OF_CUSTOM_FIELDS); CollectionAssert.AllItemsAreNotNull(customFields, "Custom fields list contains null items."); CollectionAssert.AllItemsAreUnique(customFields, "Custom fields items are not unique."); CollectionAssert.AllItemsAreInstancesOfType(customFields, typeof(CustomField), "Not all items are of type custom fields."); Assert.IsTrue(customFields.Exists(cf => cf.CustomizedType == RedmineKeys.ISSUE) == ISSUE_CUSTOM_FIELD_EXISTS, "Customized type check not valid."); }
public void Should_Get_Memberships_By_Project_Identifier() { var projectMemberships = redmineManager.GetObjects <ProjectMembership>(new NameValueCollection { { RedmineKeys.PROJECT_ID, PROJECT_IDENTIFIER } }); Assert.IsNotNull(projectMemberships, "Get project memberships by project id returned null."); Assert.AreEqual(projectMemberships.Count, NUMBER_OF_PROJECT_MEMBERSHIPS, "Project memberships count != " + NUMBER_OF_PROJECT_MEMBERSHIPS); CollectionAssert.AllItemsAreNotNull(projectMemberships, "Project memberships list contains null items."); CollectionAssert.AllItemsAreUnique(projectMemberships, "Project memberships items are not unique."); CollectionAssert.AllItemsAreInstancesOfType(projectMemberships, typeof(ProjectMembership), "Not all items are of type ProjectMembership."); }
public IEnumerable <CommonRemineEntities.User> GetUsers(int projectId) { var filter = new NameValueCollection { { RedmineKeys.PROJECT_ID, projectId.ToString() } }; return(RedmineManager.GetObjects <ProjectMembership>(filter) .Select(pm => pm.User) .Select(u => EntityMapper.Map <CommonRemineEntities.User>(u)) .ToArray()); }
public void Should_Get_All_Queries() { var queries = redmineManager.GetObjects <Query>(null); Assert.IsNotNull(queries, "Get all queries returned null"); Assert.IsTrue(queries.Count == NUMBER_OF_QUERIES, "Queries count != " + NUMBER_OF_QUERIES); CollectionAssert.AllItemsAreNotNull(queries, "Queries list contains null items."); CollectionAssert.AllItemsAreUnique(queries, "Queries items are not unique."); CollectionAssert.AllItemsAreInstancesOfType(queries, typeof(Query), "Not all items are of type query."); Assert.IsTrue(queries.Exists(q => q.IsPublic) == EXISTS_PUBLIC_QUERY, EXISTS_PUBLIC_QUERY ? "Public query should exist." : "Public query should not exist."); }
public void Should_Get_All_IssueCategories_By_ProjectId() { var issueCategories = redmineManager.GetObjects <IssueCategory>(new NameValueCollection { { RedmineKeys.PROJECT_ID, PROJECT_ID } }); Assert.IsNotNull(issueCategories, "Get issue categories returned null."); CollectionAssert.AllItemsAreInstancesOfType(issueCategories, typeof(IssueCategory), "Not all items are of type IssueCategory."); CollectionAssert.AllItemsAreNotNull(issueCategories, "Issue categories contains null items."); CollectionAssert.AllItemsAreUnique(issueCategories, "Issue categories items are not unique."); Assert.IsTrue(issueCategories.Count == NUMBER_OF_ISSUE_CATEGORIES, "Number of issue categories != " + NUMBER_OF_ISSUE_CATEGORIES); }
public void Should_Get_All_Issue_Statuses() { var issueStatuses = redmineManager.GetObjects<IssueStatus>(null); Assert.IsNotNull(issueStatuses, "Get issue statuses returned null."); Assert.IsTrue(issueStatuses.Count == NUMBER_OF_ISSUE_STATUSES, "Issue statuses count != " + NUMBER_OF_ISSUE_STATUSES); CollectionAssert.AllItemsAreNotNull(issueStatuses, "Issue statuses list contains null items."); CollectionAssert.AllItemsAreUnique(issueStatuses, "Issue statuses items are not unique."); CollectionAssert.AllItemsAreInstancesOfType(issueStatuses, typeof(IssueStatus), "Not all items are of type IssueStatus."); Assert.IsTrue(issueStatuses.Exists(i => i.IsClosed) == EXISTS_CLOSED_ISSUE_STATUSES, EXISTS_CLOSED_ISSUE_STATUSES ? "Closed issue statuses were expected to exist." : "Closed issue statuses were not expected to exist."); Assert.IsTrue(issueStatuses.Exists(i => i.IsDefault) == EXISTS_DEFAULT_ISSUE_STATUSES, EXISTS_DEFAULT_ISSUE_STATUSES ? "Default issue statuses were expected to exist." : "Default issue statuses were not expected to exist."); }
public ActionResult <QueryResult> Get(string issues_type, int from_id) { QueryResult queryResult = new QueryResult(); NameValueCollection nameValueCollection = null; RedmineManager manager = new RedmineManager(Globals.RedmineURL, Globals.APIKey); switch (issues_type) { case "author_id": // 按作者 nameValueCollection = new NameValueCollection() { { RedmineKeys.INCLUDE, RedmineKeys.RELATIONS }, { "author_id", from_id.ToString() } }; break; case "cf_22": // 按医院 nameValueCollection = new NameValueCollection() { { RedmineKeys.INCLUDE, RedmineKeys.RELATIONS }, { "cf_22", from_id.ToString() } }; break; case "assigned_to_id": // 按指派给 nameValueCollection = new NameValueCollection() { { RedmineKeys.INCLUDE, RedmineKeys.RELATIONS }, { "assigned_to_id", from_id.ToString() } }; break; } if (nameValueCollection != null) { var issues = manager.GetObjects <Redmine.Net.Api.Types.Issue>(nameValueCollection); queryResult.total_count = issues.Count; foreach (Redmine.Net.Api.Types.Issue issue in issues) { issue.Description = ""; queryResult.issues.Add(issue); } } return(queryResult); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } var proj_collection = new NameValueCollection { { RedmineKeys.INCLUDE, RedmineKeys.RELATIONS } }; RedmineManager manager = new RedmineManager(Globals.RedmineURL, Account, Password, MimeFormat.Json); try { var getProjectes = manager.GetObjects <Redmine.Net.Api.Types.Project>(proj_collection); //User user = new User(); //user.User_account = Account; //user.User_password = Password; //user.Theme_url = "/images/4.jpg"; if (Account.Equals("redmine") == false) { manager = new RedmineManager(Globals.RedmineURL, "redmine", "aa123456", MimeFormat.Json); } var getAllUser = manager.GetObjects <Redmine.Net.Api.Types.User>(new NameValueCollection() { { RedmineKeys.STATUS, ((int)Redmine.Net.Api.Types.UserStatus.StatusActive).ToString(CultureInfo.InvariantCulture) }, { RedmineKeys.INCLUDE, RedmineKeys.RELATIONS } }); GorillaUtil.Resort(getAllUser); User user = Globals.AllUser.FirstOrDefault(t => t.User_account.Equals(Account)); user.User_password = Password; SessionExtensions.Set <User>(HttpContext.Session, SessionExtensions.SessionKey_CUA, user); return(RedirectToPage("Index")); } catch (RedmineException exc) { return(RedirectToPage("Login", new { errcode = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })); } }
/// <summary> /// разработка метода с применением технологии LINQ /// </summary> public void GetDataFromRedmine() { NameValueCollection parametr; ClearLists(); progressBar.InvokeIfNeeded(delegate { progressBar.DisplayStyle = ProgressBarDisplayText.CustomText; }); progressBar.InvokeIfNeeded(delegate { progressBar.CustomText = "Загрузка записей, подождите пожалуйста."; }); progressBar.InvokeIfNeeded(delegate { progressBar.Minimum = 0; }); SetInitProgBar(progressBar, 0, 5, 1); try { // получение списка пользователей redmine parametr = new NameValueCollection { { "user_id", "*" } }; List <User> listUserRedm = redmineManager.GetObjects <User>(parametr); progressBar.InvokeIfNeeded(delegate { progressBar.PerformStep(); }); // получение списка групп пользователей redmine parametr = new NameValueCollection { { "group_id", "*" } }; List <Group> listGroupRedm = redmineManager.GetObjects <Group>(parametr); progressBar.InvokeIfNeeded(delegate { progressBar.PerformStep(); }); // получение списка задач из redmine parametr = new NameValueCollection { { "created_on", ">=2019-01-01" } }; //{ "status_id", "*" } List <Issue> listIssueRedm = redmineManager.GetObjects <Issue>(parametr); progressBar.InvokeIfNeeded(delegate { progressBar.PerformStep(); }); // получение списка проектов из redmine parametr = new NameValueCollection { { "project_id", "*" } }; List <Project> listProjectRedm = redmineManager.GetObjects <Project>(parametr); progressBar.InvokeIfNeeded(delegate { progressBar.PerformStep(); }); // получение списка трудозатра из redmine parametr = new NameValueCollection { { "spent_on", ">=2019-01-01" } }; //{ "user_id", "*" } List <TimeEntry> listTimeEntryRedm = redmineManager.GetObjects <TimeEntry>(parametr); progressBar.InvokeIfNeeded(delegate { progressBar.PerformStep(); }); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public static void UpdateVariables() { Console.WriteLine(DateTime.Now + ": ServerClass.UpdateVariables"); /*try * {*/ IList <Project> allProjects = redmine.GetObjects <Project>(); List <Tracker> allTrackers = redmine.GetObjects <Tracker>(); List <IssueStatus> allStatuses = redmine.GetObjects <IssueStatus>(); List <IssuePriority> allPrioritys = redmine.GetObjects <IssuePriority>(); List <TimeEntryActivity> allActivities = redmine.GetObjects <TimeEntryActivity>(); File.Delete(VariablesPath); FileInfo fl = new FileInfo(VariablesPath); StreamWriter sw = fl.AppendText(); int count = allProjects.Count; string[,] projects = new string[count, 2]; for (int r = 0; r < count; r++) { projects[count - 1 - r, 0] = allProjects[r].Name; projects[count - 1 - r, 1] = Convert.ToString(allProjects[r].Id); } sw.WriteLine(JsonConvert.SerializeObject(projects)); count = allTrackers.Count; string[,] Trackers = new string[count, 2]; for (int r = 0; r < count; r++) { Trackers[count - 1 - r, 0] = allTrackers[r].Name; Trackers[count - 1 - r, 1] = Convert.ToString(allTrackers[r].Id); } sw.WriteLine(JsonConvert.SerializeObject(Trackers)); count = allStatuses.Count; string[,] Statuses = new string[count, 2]; for (int r = 0; r < count; r++) { Statuses[r, 0] = allStatuses[r].Name; Statuses[r, 1] = Convert.ToString(allStatuses[r].Id); } sw.WriteLine(JsonConvert.SerializeObject(Statuses)); count = allPrioritys.Count; string[,] Prioritys = new string[count, 2]; for (int r = 0; r < count; r++) { Prioritys[r, 0] = allPrioritys[r].Name; Prioritys[r, 1] = Convert.ToString(allPrioritys[r].Id); } sw.WriteLine(JsonConvert.SerializeObject(Prioritys)); count = allActivities.Count; string[,] Activities = new string[count, 2]; for (int r = 0; r < count; r++) { Activities[r, 0] = Convert.ToString(allActivities[r].Name); Activities[r, 1] = Convert.ToString(allActivities[r].Id); } sw.WriteLine(JsonConvert.SerializeObject(Activities)); string[,] user = new string[1, 2] { { CurrentUser.Login, Convert.ToString(CurrentUser.Id) } }; try { List <User> allUsers = redmine.GetObjects <User>(); count = allUsers.Count; string[,] Users = new string[count, 2]; for (int r = 0; r < count; r++) { Users[r, 0] = Convert.ToString(allUsers[r].Id); Users[r, 1] = Convert.ToString(allUsers[r].Id); } sw.WriteLine(JsonConvert.SerializeObject(Users)); } catch { sw.WriteLine(JsonConvert.SerializeObject(user)); } sw.Close(); /*} * catch { }*/ }