static void retrieveByQuery()
        {
            Console.WriteLine("\n\nRetrieving active, unresolved incidents");
            var query = @"active=true^u_resolved=false";
            TableAPIClient <incident> client = new TableAPIClient <incident>("incident", myInstance, instanceUserName, instancePassword);

            IRestQueryResponse <incident> response = client.GetByQuery(query);

            Console.WriteLine(response.ResultCount + " records found. \n\nPress return to list results.");
            Console.ReadLine();
            foreach (incident r in response.Result)
            {
                DateTime     openedOn  = DateTime.Parse(r.opened_at);
                ResourceLink openedFor = r.caller_id;

                Console.WriteLine(r.number + " :  " + r.short_description + " (Opened " + openedOn.ToShortDateString() + " for " + r.caller_first_name + ")");
            }
        }
        // You would of course have these cached somewhere most likely.
        static string findLocationId(string locationName)
        {
            TableAPIClient <location> locationClient = new TableAPIClient <location>("cmn_location", myInstance, instanceUserName, instancePassword);
            var query = @"name=" + locationName;

            IRestQueryResponse <location> locationResult = locationClient.GetByQuery(query);

            if (locationResult.ResultCount == 0)
            {
                throw new Exception(String.Format("No location by the name {0} was found.", locationName));
            }
            if (locationResult.ResultCount > 1)
            {
                throw new Exception(String.Format("Multiple locations found by the name {0}.", locationName));
            }

            // We found our location lets return it
            return(locationResult.Result.First().sys_id);
        }
Exemple #3
0
        public void GetByQuery()
        {
            TableAPIClient <sys_user> client = new TableAPIClient <sys_user>("sys_user", "yourInstance", "user", "pass");

            string query = "u_agency.sys_id=e2353kf15n11239870249577c9tas67d^active=true";

            var retrievedUsers = client.GetByQuery(query);

            if (retrievedUsers.IsError)
            {
                Assert.Fail(retrievedUsers.ErrorMsg);
            }
            if (retrievedUsers.Result.Count == 0)
            {
                Assert.Fail("Expected users to be returned but none were.");
            }
            var testUser = retrievedUsers.Result.Where(x => x.last_name == "McArthur" & x.first_name == "Ryan").FirstOrDefault();

            Assert.AreEqual("012345", testUser.employee_number);
        }
        public IRestQueryResponse <Problem> GetRecordByQuery(string query)
        {
            IRestQueryResponse <Problem> result = _problemAPIRepository.GetByQuery(query);

            return(result);
        }
Exemple #5
0
        public IRestQueryResponse <Incident> GetRecordByQuery(string query)
        {
            IRestQueryResponse <Incident> result = _tableAPIRepository.GetByQuery(query);

            return(result);
        }
Exemple #6
0
        public IRestQueryResponse <ServiceNowTask> GetRecordByQuery(string query)
        {
            IRestQueryResponse <ServiceNowTask> result = _taskAPIRepository.GetByQuery(query);

            return(result);
        }