public Result <string> saveSVNLog(SVNLog log) { Result <string> result = new Result <string>(); result.status = 1; result.msg = Plugin.lang.getText("OperateSucess"); result.data = ""; RequestType type = getRequestType(); string name = "index.php?m=svn&f=ajaxSaveLog&t=json"; if (type == RequestType.PATH_INFO) { name = "svn-ajaxSaveLog.json"; } string updateUrl = getAPIUrl(name); string data = "repoUrl=" + Uri.EscapeDataString(log.repoUrl) + "&repoRoot=" + Uri.EscapeDataString(log.repoRoot) + "&message=" + Uri.EscapeDataString(log.message) + "&revision=" + log.revision; foreach (string path in log.files) { data += "&files[]=" + Uri.EscapeDataString(path); } string body = HttpClient.post(updateUrl, Encoding.UTF8.GetBytes(data)); //TODO return(result); }
/// <summary> /// 登录禅道系统 /// </summary> /// <param name="url"></param> /// <param name="username"></param> /// <param name="password"></param> /// <returns></returns> public static Result <string> login(string url, string username, string password) { //每次登录清除Cookie HttpClient.container = new CookieContainer(); string data = "account=" + Uri.EscapeDataString(username) + "&password="******"&keepLogin%5B%5D=on"; RequestType type = getRequestType(url); string name = "index.php?m=user&f=login&t=json"; if (type == RequestType.PATH_INFO) { name = "user-login.json"; } string loginUrl = getAPIUrl(url, name); Result <string> result = new Result <string>(); try { string body = HttpClient.post(loginUrl, Encoding.UTF8.GetBytes(data)); ZentaoResult res = JsonConvert.DeserializeObject <ZentaoResult>(body); if (res.isSuccess()) { result.status = 1; result.msg = Plugin.lang.getText("Login Success"); result.data = ""; } else { result.status = 0; result.msg = res.reason; result.data = ""; } } catch (Exception e) { result.status = 0; result.msg = Plugin.lang.getText("ServerResponseError"); result.data = ""; } return(result); }
/// <summary> /// 更新任务 /// </summary> /// <param name="taskId"></param> /// <returns></returns> public Result <string> updateTask(TaskInfo task) { string taskId = task.id; string consumed = task.consumed; string left = task.left; Result <string> result = new Result <string>(); result.status = 1; result.msg = Plugin.lang.getText("OperateSucess"); result.data = ""; string operate = "recordEstimate"; string data = "id[1]=1" + "&dates[1]=" + DateTime.Now.ToString("yyyy-MM-dd") + "&consumed[1]=" + task.currentConsumed + "&left[1]=" + left + $"&work[1]=handle task#{task.id} {task.name}&objectType[1]=task&objectID[1]=" + taskId; if (int.Parse(left) < 1) { operate = "finish"; data = "consumed=" + consumed + "&assignedTo=" + "&finishedDate=" + DateTime.Now.ToString("yyyy-MM-dd") + "&comment="; } RequestType type = getRequestType(); string name = "index.php?t=json&m=task&f=" + operate + "&taskID=" + taskId; if (type == RequestType.PATH_INFO) { if (operate.Equals("finish")) { name = "task-" + operate + "-" + taskId + ".json"; } else { name = "effort-createForObject-task-" + taskId + ".json"; } } string updateUrl = getAPIUrl(name); string body = HttpClient.post(updateUrl, Encoding.UTF8.GetBytes(data)); return(result); }
/// <summary> /// 更新BUG /// </summary> /// <param name="bugId"></param> /// <returns></returns> public Result <string> updateBug(string bugId, string comment) { RequestType type = getRequestType(); string name = "index.php?t=json&m=bug&f=resolve&bugID=" + bugId; if (type == RequestType.PATH_INFO) { name = "bug-resolve-" + bugId + ".json"; } string updateUrl = getAPIUrl(name); string data = "resolution=fixed&resolvedBuild=trunk&resolvedDate=" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "&assignedTo=" + username; string body = HttpClient.post(updateUrl, Encoding.UTF8.GetBytes(data)); Result <string> result = new Result <string>(); result.status = 1; result.msg = Plugin.lang.getText("OperateSucess"); result.data = ""; return(result); }