Example #1
0
        public void GlobalInitialize()
        {
            client = new XmlObixClient(obixLobby);

            Assert.IsNotNull(client, "Initializing the oBIX client failed.");
            client.ErrorStack.ErrorAdded += ObixError_ErrorAdded;
        }
        public ObixClientInit()
        {
            oBixClient = new XmlObixClient(new Uri("http://173.165.100.105/obix"));
            oBixClient.WebClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(Encoding.ASCII.GetBytes("obix:obix")));

            oBixResult = oBixClient.Connect();
            if (oBixResult != ObixResult.kObixClientSuccess)
            {
                throw new InvalidOperationException();
            }
        }
Example #3
0
        public void GlobalCleanup()
        {
            if (client.ErrorStack.HasErrors)
            {
                Console.Out.WriteLine("\r\n\r\n\r\n");
                Console.Out.WriteLine("--- Error Stack ---");
                foreach (ObixError err in client.ErrorStack.PopArray())
                {
                    Console.Out.WriteLine(err.ToString());
                    if (string.IsNullOrEmpty(err.AuxErrorMessage) == false)
                    {
                        Console.Out.WriteLine(" - " + err.AuxErrorMessage);
                    }
                }
            }

            client.Dispose();
            client = null;
        }
Example #4
0
        static void Main(string[] args)
        {
            string Server   = "<server>";
            string Username = "******";
            string Password = "******";

            using (var obixClient = new XmlObixClient(new Uri(Server)))
            {
                obixClient.WebClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue
                                                                           (
                    "Basic",
                    Convert.ToBase64String(
                        Encoding.ASCII.GetBytes(
                            string.Format("{0}:{1}", Username, Password))));

                var connectResult = obixClient.Connect();
                if (connectResult != ObixResult.kObixClientSuccess)
                {
                    throw new Exception("Connection to server failed: " +
                                        ObixResult.Message(connectResult));
                }

                var readResult = obixClient.ReadUriXml(new Uri(Server + "histories/"));
                if (readResult.ResultSucceeded)
                {
                    var element = readResult.Result;
                    System.Console.WriteLine(element.ToString());
                }
                else
                {
                    throw new Exception("Error reading from server: " + ObixResult.Message(readResult));
                }

                System.Console.ReadKey();
            }
        }