Exemplo n.º 1
0
        public void LoadHubs()
        {
            Hubs.Clear();
            Projects.Clear();
            // Set the base url for the API.
            var client = new RestClient("https://api.bimtrackapp.co/v2/");

            var request = new RestRequest("hubs", Method.GET);

            // easily add HTTP Headers
            request.AddHeader("Accept", "application/json");
            request.AddHeader("Authorization", "Bearer " + ApiKey);

            // or automatically deserialize result
            // return content type is sniffed but can be explicitly set via RestClient.AddHandler();
            var response = client.Execute <List <Hub> >(request);

            if (!response.IsSuccessful)
            {
                MessageBox.Show(response.ErrorMessage ?? response.ErrorException?.Message ?? response.StatusCode.ToString());
                throw new WebException(response.StatusCode.ToString());
            }


            Hubs = response.Data;
        }
Exemplo n.º 2
0
        protected virtual void Dispose(bool disposingManagedResources)
        {
            if (!IsDisposed)
            {
                if (disposingManagedResources)
                {
                    // Dispose managed resources here...
                    for (int i = 0; i < Hubs.Count; i++)
                    {
                        (Hubs[i].Instance as Hub).Dispose();
                    }
                }

                // Set large fields to null here...
                Hubs.Clear();

                // Mark as disposed.
                IsDisposed = true;
            }
        }
Exemplo n.º 3
0
        public int Refresh()
        {
            int rv;
            int n;

            rv = WWUsbDeviceTreeDLL_Refresh();
            if (rv < 0)
            {
                Console.WriteLine("Error: WWUsbDeviceTreeCs::Refresh() failed {0}", rv);
                return(rv);
            }

            HCs.Clear();
            n = WWUsbDeviceTreeDLL_GetNumOfHostControllers();
            for (int i = 0; i < n; ++i)
            {
                WWUsbHostControllerCs hc;
                rv = WWUsbDeviceTreeDLL_GetHostControllerInf(i, out hc);
                if (rv < 0)
                {
                    Console.WriteLine("Error: WWUsbDeviceTreeCs::Update HC failed {0}", rv);
                    return(rv);
                }

                HCs.Add(hc);
            }

            Hubs.Clear();
            n = WWUsbDeviceTreeDLL_GetNumOfHubs();
            for (int i = 0; i < n; ++i)
            {
                WWUsbHubCs hub;
                rv = WWUsbDeviceTreeDLL_GetHubInf(i, out hub);
                if (rv < 0)
                {
                    Console.WriteLine("Error: WWUsbDeviceTreeCs::Update HUB failed {0}", rv);
                    return(rv);
                }
                Hubs.Add(hub);
            }

            HPs.Clear();
            n = WWUsbDeviceTreeDLL_GetNumOfHubPorts();
            for (int i = 0; i < n; ++i)
            {
                WWUsbHubPortNative hpn;
                rv = WWUsbDeviceTreeDLL_GetHubPortInf(i, out hpn);
                if (rv < 0)
                {
                    Console.WriteLine("Error: WWUsbDeviceTreeCs::Update HubPort failed {0}", rv);
                    return(rv);
                }

                WWUsbHubPortCs hp = new WWUsbHubPortCs(hpn);
                for (int j = 0; j < hpn.numStringDesc; ++j)
                {
                    WWUsbStringDescCs sdc;
                    WWUsbDeviceTreeDLL_GetStringDesc(i, j, out sdc);
                    hp.stringDescList.Add(sdc);
                }

                HPs.Add(hp);
            }

            return(0);
        }