Ejemplo n.º 1
0
        public static EventTypeInfo EventType(IBMWIoTP.ApiClient cli, SchemaInfo sc)
        {
            Console.WriteLine("Event Type sample request");
            Console.WriteLine("Add Draft EventType");
            EventTypeDraft draft = new EventTypeDraft();

            draft.name        = "Temprature";
            draft.description = "eventType for temperature";
            draft.schemaId    = sc.id;
            EventTypeInfo info = cli.AddDraftEventType(draft);

            Console.WriteLine(new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(info));
            Console.WriteLine("===============================================================================");
            Console.WriteLine("Get All Draft EventType");
            EventTypeCollection collection = cli.GetAllDraftEventType();

            Console.WriteLine(new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(collection));
            Console.WriteLine("===============================================================================");
            Console.WriteLine("Delete Draft");
            //creating another one to delete
            EventTypeInfo del = cli.AddDraftEventType(draft);

            cli.DeleteDraftEventType(del.id);
            Console.WriteLine("Get event type draft of id" + info.id);
            EventTypeInfo reccivedInfo = cli.GetDraftEventType(info.id);

            Console.WriteLine(new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(reccivedInfo));
            Console.WriteLine("===============================================================================");
            Console.WriteLine("Update draft");
            reccivedInfo.description = "updated info";
            Console.WriteLine(new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(cli.UpdateDraftEventType(reccivedInfo)));
            Console.WriteLine("===============================================================================");
            Console.WriteLine("Get all active EventType");
            EventTypeCollection coll = cli.GetAllActiveEventType();

            Console.WriteLine(new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(coll));
            Console.WriteLine("===============================================================================");
            if (coll.results.Count > 0)
            {
                Console.WriteLine("Get all active EventType with id");
                Console.WriteLine(new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(cli.GetActiveEventType(coll.results[0].id)));
                Console.WriteLine("===============================================================================");
            }

            return(reccivedInfo);
        }