static void DoDemo(AtTaskRestClient client)
        {
            //Get user object of the user that is signed in
            Console.WriteLine("** Retrieving user...");
            JToken user        = client.Get(ObjCode.USER, client.UserID, "homeGroupID");
            string userGroupID = user["data"].Value <string>("homeGroupID");

            Console.WriteLine(user);
            Console.WriteLine("** Done");
            Console.WriteLine();

            //Search all projects
            Console.WriteLine("** Searching projects...");
            JToken projects = client.Search(ObjCode.PROJECT, new { groupID = userGroupID });

            foreach (var j in projects["data"].Children())
            {
                Console.WriteLine("Name: {0}", j.Value <string>("name"));
            }
            Console.WriteLine("** Done");
            Console.WriteLine();

            //Create a new project
            Console.WriteLine("** Creating project...");
            JToken project = client.Create(ObjCode.PROJECT, new { name = "OldProjectName", groupID = userGroupID });

            Console.WriteLine(project);
            Console.WriteLine("Done");
            Console.WriteLine();

            //Edit an existing project
            Console.WriteLine("** Editing project...");
            string projectID = project["data"].Value <string>("ID");

            project = client.Update(ObjCode.PROJECT, new { id = projectID, name = "NewProjectName" });
            Console.WriteLine(project);
            Console.WriteLine("Done");
            Console.WriteLine();

            //Add new issues to an existing project
            Console.WriteLine("** Adding issues to project...");
            for (int i = 1; i <= 3; i++)
            {
                string issueName = "issue " + i.ToString();
                client.Create(ObjCode.ISSUE, new { name = issueName, projectID = projectID });
            }
            project = client.Search(ObjCode.ISSUE, new { projectID = projectID, fields = "projectID" });
            Console.WriteLine(project);
            Console.WriteLine("Done");
            Console.WriteLine("");

            //Delete an existing project
            Console.WriteLine("Deleting project...");
            JToken deleted = client.Delete(ObjCode.PROJECT, new { id = projectID });

            Console.WriteLine(deleted);
            Console.WriteLine("Done");
            Console.WriteLine();
        }
Beispiel #2
0
 static void Main(string[] args)
 {
     string url = "<AtTask URL>";
     using (AtTaskRestClient client = new AtTaskRestClient(url)) {
         client.Login("<AtTask Username>", "<AtTask Password>");
         //				client.DebugUrls = true; //If true, then every URL requested will be printed
         DoDemo(client);
     }
 }
        static void Main(string[] args)
        {
            string url = "http://localhost:8080/attask/api/";

            using (AtTaskRestClient client = new AtTaskRestClient(url)) {
                client.Login("admin", "user");
//				client.DebugUrls = true; //If true, then every URL requested will be printed
                DoDemo(client);
            }
        }
Beispiel #4
0
 static void DoDemo(AtTaskRestClient client)
 {
     //Get user object of the user that is signed in
     Console.WriteLine("** Retrieving user...");
     JToken user = client.Get(ObjCode.USER, client.UserID, "homeGroupID");
     string userGroupID = user["data"].Value<string>("homeGroupID");
     Console.WriteLine(user);
     Console.WriteLine("** Done");
     Console.WriteLine();
     //Search all projects
     Console.WriteLine("** Searching projects...");
     JToken projects = client.Search(ObjCode.PROJECT, new { groupID = userGroupID });
     foreach (var j in projects["data"].Children()) {
         Console.WriteLine("Name: {0}", j.Value<string>("name"));
     }
     Console.WriteLine("** Done");
     Console.WriteLine();
     //Create a new project
     Console.WriteLine("** Creating project...");
     JToken project = client.Create(ObjCode.PROJECT, new { name = "OldProjectName", groupID = userGroupID });
     Console.WriteLine(project);
     Console.WriteLine("Done");
     Console.WriteLine();
     //Edit an existing project
     Console.WriteLine("** Editing project...");
     string projectID = project["data"].Value<string>("ID");
     project = client.Update(ObjCode.PROJECT, new { id = projectID, name = "NewProjectName" });
     Console.WriteLine(project);
     Console.WriteLine("Done");
     Console.WriteLine();
     //Add new issues to an existing project
     Console.WriteLine("** Adding issues to project...");
     for (int i = 1; i <= 3; i++) {
         string issueName = "issue " + i.ToString();
         client.Create(ObjCode.ISSUE, new { name = issueName, projectID = projectID });
     }
     project = client.Search(ObjCode.ISSUE, new { projectID = projectID, fields = "projectID" });
     Console.WriteLine(project);
     Console.WriteLine("Done");
     Console.WriteLine("");
     //Delete an existing project
     Console.WriteLine("Deleting project...");
     JToken deleted = client.Delete(ObjCode.PROJECT, new { id = projectID });
     Console.WriteLine(deleted);
     Console.WriteLine("Done");
     Console.WriteLine();
 }