Example #1
0
        /// <summary>
        /// 获取任务列表,数据有查询缓存
        /// </summary>
        /// <returns></returns>
        public List <TaskInfo> getTaskList()
        {
            tasks.Clear();

            RequestType type = getRequestType();

            string name = "index.php?m=my&f=task&t=json&type=assignedTo&orderBy=id_desc&recTotal=0&recPerPage=1000&pageID=1";

            if (type == RequestType.PATH_INFO)
            {
                name = "my-task-assignedTo-id_desc-0-1000-1.json";
            }
            string taskUrl = getAPIUrl(name);

            string       body   = HttpClient.get(taskUrl);
            ZentaoResult result = JsonConvert.DeserializeObject <ZentaoResult>(body);

            if (result.isSuccess())
            {
                TaskResult taskResult = JsonConvert.DeserializeObject <TaskResult>(result.data);

                foreach (TaskInfo task in taskResult.tasks)
                {
                    if (!task.status.Equals("done") && !task.status.Equals("done"))
                    {
                        tasks.Add(task);
                    }
                }

                return(tasks);
            }

            return(new List <TaskInfo>());
        }
Example #2
0
        /// <summary>
        /// 获取BUG列表: 此处的结果有数据缓存,最新的数据调用searchBugList
        /// </summary>
        /// <returns></returns>
        public List <BugInfo> getBugList()
        {
            bugs.Clear();

            RequestType type = getRequestType();
            string      name = "index.php?m=my&f=bug&t=json&type=assignedTo&orderBy=id_desc&recTotal=0&recPerPage=1000&pageID=1";

            if (type == RequestType.PATH_INFO)
            {
                name = "my-bug-assignedTo-id_desc-0-1000-1.json";
            }

            string bugUrl = this.getAPIUrl(name);

            string body = HttpClient.get(bugUrl);

            ZentaoResult result = JsonConvert.DeserializeObject <ZentaoResult>(body);

            if (result.isSuccess())
            {
                BugResult bugResult = JsonConvert.DeserializeObject <BugResult>(result.data);
                foreach (BugInfo bug in bugResult.bugs)
                {
                    if (bug.status.Equals("active"))
                    {
                        bugs.Add(bug);
                    }
                }

                return(bugs);
            }


            return(new List <BugInfo>());
        }
Example #3
0
        /// <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);
        }