static void Main(string[] args) { using (var api = new EmsApiService()) { api.CachedEmsSystem = 1; AnalyticGroupContents rootGroup = api.Analytics.GetGroup(); EnumerateRecursive(rootGroup, api); } }
public CredentialsDialog(EmsApiService api) { m_api = api; Icon = System.Drawing.Icon.FromHandle(Properties.Resources.pushpin.GetHicon()); InitializeComponent(); // Note: These will already contain values if the environment // variables are set (EmsApiEndpoint, EmsApiUsername, EmsApiPassword). m_endpointBox.Text = api.ServiceConfig.Endpoint; m_userBox.Text = api.ServiceConfig.UserName; m_passwordBox.Text = api.ServiceConfig.Password; }
public void Invalid_configuration_should_throw_exception() { var service = new EmsApiService(); var badConfig = new EmsApiServiceConfiguration() { UserName = string.Empty, Password = null }; Action setConfig = () => service.ServiceConfig = badConfig; setConfig.Should().ThrowExactly <EmsApiConfigurationException>(); }
private void MainForm_Load(object sender, EventArgs e) { m_api = new EmsApiService(); CredentialsDialog login = new CredentialsDialog(m_api); if (login.ShowDialog() != DialogResult.OK) { Close(); return; } m_emsSystemDropdown.ApiService = m_api; m_trajectoryTypeDropdown.ApiService = m_api; }
static void Main(string[] args) { Console.WriteLine("Hello from .NET core."); var config = new EmsApiServiceConfiguration(); // Allow the user to override the endpoint, but provide a default. Console.Write("Enter Endpoint URL [{0}]: ", config.Endpoint); string endpoint = Console.ReadLine(); if (!string.IsNullOrEmpty(endpoint)) { config.Endpoint = endpoint; } Console.Write("Enter Username [{0}]: ", config.UserName); string user = Console.ReadLine(); if (!string.IsNullOrEmpty(user)) { config.UserName = user; } string defaultPw = !string.IsNullOrEmpty(config.Password) ? "********" : string.Empty; Console.Write("Enter Password [{0}]: ", defaultPw); string password = Console.ReadLine(); if (!string.IsNullOrEmpty(password)) { config.Password = password; } using (var api = new EmsApiService(config)) { // List all the connected EMS systems on the command line. foreach (EmsSystem ems in api.EmsSystems.GetAll()) { // Retrieve server details about the system. EmsSystemInfo server = api.EmsSystems.GetSystemInfo(ems.Id.Value); Console.WriteLine(string.Format("{0} - {1} - {2} - EMS version {3} - {4}", ems.Id, ems.Name, ems.Description, server.ServerVersion, server.UtcTimeStamp)); } } Console.WriteLine("Press any key to close..."); Console.ReadKey(); }
private static void EnumerateRecursive(AnalyticGroupContents group, EmsApiService api, int indent = 0) { // Calculate indent string. string indentStr = string.Empty; for (int i = 0; i < indent; ++i) { indentStr += "\t"; } // For this example we are only showing groups, but individual analytics are easy as well: // foreach( AnalyticInfo analytic in group.Analytics ) // Console.WriteLine( string.Format( "{0} | Analytic: {1}", indentStr, analytic.Name ) ); // Recurse into the groups. foreach (AnalyticGroup innerGroup in group.Groups) { Console.WriteLine(string.Format("{0} | {1}", indentStr, innerGroup.Name)); EnumerateRecursive(api.Analytics.GetGroup(innerGroup.Id), api, indent + 1); } }
/// <summary> /// Returns a new instance of the EMS API service with a valid configuration /// (set by the EmsApiTest* environment variables) and a valid cached ems system /// id. /// </summary> protected static EmsApiService NewService() { var service = new EmsApiService(m_config.Clone()); if (ValidEmsSystemId != 0) { service.CachedEmsSystem = ValidEmsSystemId; return(service); } lock ( m_getEmsSystemLock ) { if (ValidEmsSystemId != 0) { // Return early if someone else was waiting on the lock. service.CachedEmsSystem = ValidEmsSystemId; return(service); } IEnumerable <EmsSystem> servers = service.EmsSystems.GetAll(); if (servers.Count() == 3) { ValidEmsSystemId = servers.First().Id.Value; } else { EmsSystem ems7 = servers.Where(s => s.Name.ToUpper() == "EMS7-APP").FirstOrDefault(); ValidEmsSystemId = ems7 == null ? servers.First().Id.Value : ems7.Id.Value; } } service.CachedEmsSystem = ValidEmsSystemId; return(service); }
public App() { // Initialize logging and other application wide components. s_emsApi = new EmsApiService(); s_emsApi.RegisterAuthFailedCallback(AuthenticationFailed); }
public void GivenAValidApiEndpoint() { m_api = NewService(); m_api.Authenticate().Should().BeTrue(); }
/// <summary> /// Sets the service that this access class is working for. This must /// be called before accessing methods on the class. /// </summary> /// <param name="service"> /// The service through which we call the raw API. /// </param> /// <remarks> /// This is here so we don't have to implement a constructor for each /// dervied access class. /// </remarks> internal void SetService(EmsApiService service) { m_service = service; }