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)); } }
public IEnumerable <NewThing> GetNew() { var result = new List <NewThing>(); foreach (var thing in _things) { result.AddRange(NewThing.FromOldThing(thing)); } return(result); }
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); }
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)); }