public List <Issue> getAllIssueList() { List <Issue> issueList = new List <Issue>(); User user = SecurityModel.getInstance().AuthenticatedUser; var req = WebRequest.Create(Server.ApiUrl + "/issues/" + user.UserId); req.Method = "GET"; req.ContentType = "application/json"; var resp = (HttpWebResponse)req.GetResponse(); using (var reader = new StreamReader(resp.GetResponseStream())) { var issueData = reader.ReadToEnd(); dynamic issueApiModel = JsonConvert.DeserializeObject <dynamic>(issueData); if ((int)issueApiModel.state == 0) { foreach (dynamic o in issueApiModel.list) { Issue issue = new Issue(); issue.IssueId = o.issueId; issue.IssueGroupId = o.issueGroupId; issue.State = o.state; issue.IssueName = o.title; issue.Description = o.description; issue.Serverity = o.serverity; issue.Priority = o.priority; issue.ReporterId = o.reporterId; issue.ReportDate = formatDateToDateTime((long)o.reportTime); issue.PersonInChargeId = o.personInChargeId; if (issue.State == "已完成") { issue.FinishDate = issue.ReportDate; } else { issue.FinishDate = (o.finishTime == null) ? DateTime.MaxValue : formatDateToDateTime((long)o.finishTime); } issue.ProjectId = o.projectId; issueList.Add(issue); } } } return(issueList); }
public Issue getIssueInfo(int issueId) { Issue issue = new Issue(); User user = SecurityModel.getInstance().AuthenticatedUser; var req = WebRequest.Create(Server.ApiUrl + "/issues/" + user.UserId + "/" + issueId); req.Method = "GET"; var resp = (HttpWebResponse)req.GetResponse(); using (var reader = new StreamReader(resp.GetResponseStream())) { var issueData = reader.ReadToEnd(); dynamic issueApiModel = JsonConvert.DeserializeObject <dynamic>(issueData); if (int.Parse((String)issueApiModel.state) == 0) { issue.IssueId = int.Parse((String)issueApiModel.issue.issueId); issue.IssueGroupId = issueApiModel.issue.issueGroupId; issue.ProjectId = issueApiModel.issue.projectId; issue.State = issueApiModel.issue.state; issue.IssueName = issueApiModel.issue.title; issue.Description = issueApiModel.issue.description; issue.Priority = issueApiModel.issue.priority; issue.Serverity = issueApiModel.issue.serverity; issue.ReporterId = issueApiModel.issue.reporterId; issue.ReportDate = formatDateToDateTime((long)issueApiModel.issue.reportTime); issue.PersonInChargeId = issueApiModel.issue.personInChargeId; if (issue.State == "已完成") { issue.FinishDate = issue.ReportDate; } else { issue.FinishDate = (issueApiModel.issue.finishTime == null) ? DateTime.MaxValue : formatDateToDateTime((long)issueApiModel.issue.finishTime); } } else { issue.IssueId = -int.Parse((String)issueApiModel.state); } } return(issue); }
public int deleteUser(int userId) { User user = SecurityModel.getInstance().AuthenticatedUser; var req = WebRequest.Create(Server.ApiUrl + "/users/delete/" + user.UserId + "/" + userId); req.Method = "GET"; String state; var resp = (HttpWebResponse)req.GetResponse(); using (var reader = new StreamReader(resp.GetResponseStream())) { var userData = reader.ReadToEnd(); state = userData; if (int.Parse(state) == 0) { Notify(); } } Notify(); return(int.Parse(state)); }
public List <User> getUserList() { List <User> userList = new List <User>(); var req = WebRequest.Create(Server.ApiUrl + "/users/list/" + SecurityModel.getInstance().AuthenticatedUser.UserId); req.Method = "GET"; var resp = (HttpWebResponse)req.GetResponse(); using (var reader = new StreamReader(resp.GetResponseStream())) { var userData = reader.ReadToEnd(); dynamic userApiModel = new JDynamic(userData); if (userApiModel.state == 0) { foreach (dynamic o in userApiModel.list) { User user = new User(); user.Authority = formatUserRoleToAuthority(o.userRole); user.UserId = o.userId; user.UserName = o.name; user.EmailAddress = o.emailAddress; user.JoinedProjects = getJoinedProjectsByUser(user.UserId); user.InvitedProjects = getInvitedProjectsByUser(user.UserId); user.Issues = getIssuesByUser(user.UserId); userList.Add(user); } } else { userList = null; } } return(userList); }
public void updateAuthenticatedUser(int userId) { User user = getUserInfo(userId); SecurityModel.getInstance().AuthenticatedUser = user; }