Exemple #1
0
        public void TestConnect()
        {
            ObixResult result;

            result = client.Connect();
            Console.Out.WriteLine("Connect result: {0}", result);

            Assert.AreEqual <int>(result, ObixResult.kObixClientSuccess,
                                  string.Format("Connect failed with error: {0}: {1}", result, ObixResult.Message((int)result)));
        }
        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();
            }
        }
Exemple #3
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();
            }
        }