Пример #1
0
        protected override void Process(object obj)
        {
            if (obj != null)
            {
                Log.Debug("Processing message...");
                NewThing t = (NewThing)obj;

                var att = t.Attributes.AdditionalProperties.Where(a => a.Key == "name").FirstOrDefault();
                try
                {
                    Log.Debug("Trying to update thing with thingId: " + att.Value.ToString() + "...");
                    Task <Thing> tt = dc.Things3Async(att.Value.ToString(), null, null, t);
                    tt.Wait();
                    Log.Debug("Thing with thingId: " + att.Value.ToString() + " updated.");
                }
                catch (Exception ex)
                {
                    Log.Error("Couldn't modify thing with thingId " + att.Value.ToString());
                    Log.Fatal(ex.ToString());
                }
            }
            else
            {
                throw new ArgumentNullException(nameof(obj));
            }
        }
Пример #2
0
        public IEnumerable <NewThing> GetNew()
        {
            var result = new List <NewThing>();

            foreach (var thing in _things)
            {
                result.AddRange(NewThing.FromOldThing(thing));
            }
            return(result);
        }
Пример #3
0
        public NewThing ConvertThing(Thing t)
        {
            NewThing nt = new NewThing();

            nt.AdditionalProperties = t.AdditionalProperties;
            nt.Attributes           = t.Attributes;
            nt.Definition           = t.Definition;
            nt.Features             = t.Features;
            nt.PolicyId             = t.PolicyId;
            return(nt);
        }
Пример #4
0
        internal static async Task <Thing> CreateThing(IWimdioApiClient client, Place place)
        {
            var random = Guid.NewGuid().ToString().Split('-').First();

            var thing = new NewThing
            {
                Name        = "Name " + random,
                Description = "Description " + random
            };

            return(await client.CreateThing(place.Id, thing));
        }