示例#1
0
func (g *GoautSession) GetAllTasks() string {
	var response []byte
	var err error
	var list TaskBriefList
	files, _ := ioutil.ReadDir(g.Conf.TaskDir)
	for _, f := range files {
		if utils.ExtFromFile(f.Name()) == ".json" {
			brief := task.GetTaskBrief(filepath.Join(g.Conf.TaskDir, f.Name()))
			list.Tasks = append(list.Tasks, brief)
		}
	}
	if err == nil {
		list.Success = true
		response, err = json.MarshalIndent(list, "", "  ")
		if err == nil {
			return string(response)
		}
	}
	return fmt.Sprintf("{ \"Success\": false, \"Message\": \"%q\" }", err)
}
示例#2
0
func (g *GoautSession) GetProjects(active bool) string {
	var response []byte
	var err error
	list := NewValueList()
	if active == false {
		files, _ := ioutil.ReadDir(g.Conf.ProjectDir)
		for _, f := range files {
			if utils.ExtFromFile(f.Name()) == ".json" {
				list.Value = append(list.Value, utils.NameFromFile(f.Name()))
			}
		}
		response, err = json.MarshalIndent(list, "", "  ")
		if err == nil {
			return string(response)
		} else {
			return fmt.Sprintf("{ \"Success\": false, \"Message\": \"%s\" }", err)
		}
	}
	return string(response)
}