static GetAllEntities() { API ClarizenAPI = new API(); if (!ClarizenAPI.Login(ConfigurationManager.AppSettings["username"], ConfigurationManager.AppSettings["password"])) { return; } listEntities metadata = ClarizenAPI.ListEntities(); if (metadata.IsCalledSuccessfully) { metadata.Data.SortTypeNames(); Console.WriteLine("{0} entities found", metadata.Data.typeNames.Length); // Note that the following query will be truncated at 2000 characters (RestClient.GET limitation) describeEntities entities = ClarizenAPI.DescribeEntities(metadata.Data.typeNames); if (entities.IsCalledSuccessfully) { foreach (entityDescription description in entities.Data.entityDescriptions) { description.SortFields(); Console.WriteLine("Fields for the {0} object:", description.typeName); foreach (fieldDescription field in description.fields) { Console.WriteLine("\t{0} ({1}) {2}", field.name, field.label, field._type); } Console.WriteLine(""); } } else { Console.WriteLine(entities.Error); } } else { Console.WriteLine(metadata.Error); } if (ClarizenAPI.Logout()) { Console.WriteLine("{0} API calls made in this session", ClarizenAPI.TotalAPICallsMadeInCurrentSession); } }
private void list_Click(object sender, RoutedEventArgs e) { listEntities window = new listEntities(); Close(); window.Show(); SqlConnection connect = new SqlConnection(@"Data Source=.\SQLEXPRESS;Initial Catalog=myDb; Integrated Security=True"); try { connect.Open(); SqlCommand command = new SqlCommand(); command.CommandText = "SELECT * FROM student"; command.Connection = connect; SqlDataReader reader = command.ExecuteReader(); if (reader.HasRows) { List <Pers> myList = new List <Pers>(); while (reader.Read()) { int id = Convert.ToInt32(reader.GetValue(0)); string name = Convert.ToString(reader.GetValue(1)); string lastName = Convert.ToString(reader.GetValue(2)); int age = Convert.ToInt32(reader.GetValue(3)); string phone = Convert.ToString(reader.GetValue(4)); string language = Convert.ToString(reader.GetValue(5)); myList.Add(new Pers(id, name, lastName, phone, age, language)); } ; window.list.ItemsSource = myList; } } catch (SqlException ex) { MessageBox.Show(ex.Message); } finally { connect.Close(); } }
static GetAllEntityRelations() { API ClarizenAPI = new API(); if (!ClarizenAPI.Login(ConfigurationManager.AppSettings["username"], ConfigurationManager.AppSettings["password"])) { return; } listEntities metadata = ClarizenAPI.ListEntities(); if (metadata.IsCalledSuccessfully) { metadata.Data.SortTypeNames(); Console.WriteLine("{0} entities found", metadata.Data.typeNames.Length); // Note that the following query will be truncated at 2000 characters (RestClient.GET limitation) describeEntityRelations entities = ClarizenAPI.DescribeEntityRelations(metadata.Data.typeNames); if (entities.IsCalledSuccessfully) { WriteEntityRelationsDescription(entities.Data.entityRelations); } else { Console.WriteLine(entities.Error); } } else { Console.WriteLine(metadata.Error); } if (ClarizenAPI.Logout()) { Console.WriteLine("{0} API calls made in this session", ClarizenAPI.TotalAPICallsMadeInCurrentSession); } }