Ejemplo n.º 1
0
        static Count()
        {
            API ClarizenAPI = new API();

            if (!ClarizenAPI.Login(ConfigurationManager.AppSettings["username"], ConfigurationManager.AppSettings["password"]))
            {
                return;
            }

            // We will search this term in the DisplayName field of User entities
            string searchTerm = "ekin";

            // Create the search query
            entityQuery query = new entityQuery("User");

            query.where = new compare(new fieldExpression("DisplayName"), Operator.Like, new constantExpression(String.Format("%{0}%", searchTerm)));
            // Here is how to perform the same search using CZQL instead
            //query.where = new cZQLCondition(@"DisplayName LIKE ""%ekin%""");

            // Run the Count method with the query created above
            Clarizen.API.V2_0.Data.countQuery count = ClarizenAPI.Count(query);
            if (count.IsCalledSuccessfully)
            {
                Console.WriteLine("{0} user(s) found with the display name {1}", count.Data.count, searchTerm);
            }
            else
            {
                Console.WriteLine(count.Error);
            }

            if (ClarizenAPI.Logout())
            {
                Console.WriteLine("{0} API calls made in this session", ClarizenAPI.TotalAPICallsMadeInCurrentSession);
            }
        }
        static EntityQuery_ByName()
        {
            API ClarizenAPI = new API();

            if (!ClarizenAPI.Login(ConfigurationManager.AppSettings["username"], ConfigurationManager.AppSettings["password"]))
            {
                return;
            }

            string      entityName  = "Task"; // Could be any entity that has the Name field, e.g. Project
            entityQuery entityQuery = ClarizenAPI.GetAllEntities(entityName, new string[] { "Name" });

            if (entityQuery.IsCalledSuccessfully)
            {
                Console.WriteLine("{0} {1} entities found", entityQuery.Data.entities.Length, entityName);
                foreach (dynamic entity in entityQuery.Data.entities)
                {
                    Console.WriteLine("\t{0}\t{1}", entity.id, entity.Name);
                }
                if (entityQuery.Data.paging.hasMore)
                {
                    Console.WriteLine("There are more records than the ones shown here");
                }
            }
            else
            {
                Console.WriteLine(entityQuery.Error);
            }

            if (ClarizenAPI.Logout())
            {
                Console.WriteLine("{0} API calls made in this session", ClarizenAPI.TotalAPICallsMadeInCurrentSession);
            }
        }
Ejemplo n.º 3
0
        static EntityQuery_Users()
        {
            API ClarizenAPI = new API();

            if (!ClarizenAPI.Login(ConfigurationManager.AppSettings["username"], ConfigurationManager.AppSettings["password"]))
            {
                return;
            }

            entityQuery entityQuery = ClarizenAPI.GetAllEntities("User", new string[] { "FirstName", "LastName", "Email", "UserName" });

            if (entityQuery.IsCalledSuccessfully)
            {
                Console.WriteLine("{0} users found", entityQuery.Data.entities.Length);
                foreach (dynamic user in entityQuery.Data.entities)
                {
                    Console.WriteLine("\t{0}\t{1} {2}, {3} (Username: {4})", user.id, user.FirstName, user.LastName, user.Email, user.UserName);
                }
                if (entityQuery.Data.paging.hasMore)
                {
                    Console.WriteLine("There are more records than the ones shown here");
                }
            }
            else
            {
                Console.WriteLine(entityQuery.Error);
            }

            if (ClarizenAPI.Logout())
            {
                Console.WriteLine("{0} API calls made in this session", ClarizenAPI.TotalAPICallsMadeInCurrentSession);
            }
        }
Ejemplo n.º 4
0
        static dynamic[] EntityQueryForUser(string entityName, string[] fields)
        {
            entityQuery entityQuery = ClarizenAPI.GetAllEntities(entityName, fields);

            if (entityQuery.IsCalledSuccessfully)
            {
                Console.WriteLine("{0} entity found", entityQuery.Data.entities.Length);
                return(entityQuery.Data.entities);
            }
            else
            {
                return(null);
            }
        }