public void Execute(Client client, Imagination.Model.Object lwm2mObject, List<Model.Property> properties) { foreach (Model.Property item in properties) { DataAccessFactory.Servers.Execute(client, lwm2mObject.ObjectDefinitionID, lwm2mObject.InstanceID, item); } }
public void CancelObserveResource(Client client, Guid objectDefinitionID, string instanceID, Guid propertyDefinitionID, bool useReset) { Service.ILWM2MServerService service = GetService(client.Server); lock (service) { service.CancelObserveObjectProperty(client.ClientID, objectDefinitionID, instanceID, propertyDefinitionID, useReset); } }
public void CancelObserveObjects(Client client, Guid objectDefinitionID, bool useReset) { Service.ILWM2MServerService service = GetService(client.Server); lock (service) { service.CancelObserveObjects(client.ClientID, objectDefinitionID, useReset); } }
public static Client Deserialise(Stream stream) { Client result = new Client(); result.ClientID = IPCHelper.ReadGuid(stream); result.Name = IPCHelper.ReadString(stream); DateTime? dateTime = IPCHelper.ReadDateTime(stream); if (dateTime.HasValue) result.Lifetime = dateTime.Value; string version = IPCHelper.ReadString(stream); result.Version = Version.Parse(version); string bindingModeText = IPCHelper.ReadString(stream); TBindingMode bindingMode; if (Enum.TryParse<TBindingMode>(bindingModeText,true, out bindingMode)) result.BindingMode = bindingMode; result.SMSNumber = IPCHelper.ReadString(stream); result.SupportedTypes = ObjectTypes.Deserialise(stream); return result; }
//public List<Client> GetClients() //{ // List<Client> result = null; // Service.ILWM2MServerService service = GetService("tcp://localhost:14080"); // TODO: replace this with call to DB // lock (service) // { // result = service.GetClients(); // } // return result; //} public void DeleteClient(Client client) { Service.ILWM2MServerService service = GetService(client.Server); lock (service) { service.DeleteClient(client.ClientID); } }
public void SaveClient(Client client, TObjectState state) { IMongoDatabase database = GetDatabase(DATABASE_NAME, true); IMongoCollection<BsonDocument> collection = database.GetCollection<BsonDocument>("Client"); EnsureIndexExists<BsonDocument>(collection, "OrganisationID"); FilterDefinition<BsonDocument> query = Builders<BsonDocument>.Filter.Eq("_id", client.ClientID.ToByteArray()); if ((state == TObjectState.Add) || (state == TObjectState.Update)) { BsonDocument doc = new BsonDocument(); BsonHelper.SetValue(doc, "_id", client.ClientID); BsonHelper.SetValue(doc, "Name", client.Name); BsonHelper.SetValue(doc, "OrganisationID", client.OrganisationID); BsonHelper.SetValue(doc, "Lifetime", client.Lifetime); BsonHelper.SetValue(doc, "Version", client.Version.ToString()); BsonHelper.SetValue(doc, "BindingMode", (int)client.BindingMode); BsonHelper.SetValue(doc, "SMSNumber", client.SMSNumber); BsonHelper.SetValue(doc, "Server", client.Server); BsonHelper.SetValue(doc, "LastActivityTime", client.LastActivityTime); if (client.SupportedTypes.Count > 0) { BsonArray array = new BsonArray(); foreach (ObjectType supportedType in client.SupportedTypes) { BsonDocument supportedTypeDoc = new BsonDocument(); BsonHelper.SetValue(supportedTypeDoc, "_id", supportedType.ObjectTypeID); BsonHelper.SetValue(supportedTypeDoc, "Path", supportedType.Path); if (supportedType.Instances.Count > 0) { BsonArray instances = new BsonArray(); foreach (int instance in supportedType.Instances) { instances.Add(instance); } supportedTypeDoc.Add("Instances", instances); } array.Add(supportedTypeDoc); } doc.Add("SupportedTypes", array); } UpdateOptions options = new UpdateOptions(); options.IsUpsert = true; collection.ReplaceOne(query, doc, options); } else if (state == TObjectState.Delete) { collection.DeleteOne(query); } }
public void SaveObject(Client client, Imagination.Model.Object lwm2mObject, Model.TObjectState state) { DataAccessFactory.Servers.SaveObject(client, lwm2mObject, state); }
public Imagination.Model.Object GetObject(Client client, Guid objectDefinitionID, string instanceID) { return DataAccessFactory.Servers.GetObject(client, objectDefinitionID, instanceID); }
public void ObserveObjects(Client client, Guid objectDefinitionID) { Service.ILWM2MServerService service = GetService(client.Server); lock (service) { service.ObserveObjects(client.ClientID, objectDefinitionID); } }
public List<Imagination.Model.Object> GetObjects(Client client, Guid objectDefinitionID) { List<Imagination.Model.Object> result = null; Service.ILWM2MServerService service = GetService(client.Server); lock (service) { result = service.GetObjects(client.ClientID, objectDefinitionID); } return result; }
public Imagination.Model.Object GetObject(Client client, Guid objectDefinitionID, string instanceID) { Imagination.Model.Object result = null; Service.ILWM2MServerService service = GetService(client.Server); lock (service) { result = service.GetObject(client.ClientID, objectDefinitionID, instanceID); } return result; }
public DeviceConnectedStatus GetDeviceConnectedStatus(Client client) { DeviceConnectedStatus result = null; Service.ILWM2MServerService service = GetService(client.Server); lock (service) { result = service.GetDeviceConnectedStatus(client.ClientID); } return result; }
public bool Execute(Client client, Guid objectDefinitionID, string instanceID, Model.Property property) { bool result = false; Service.ILWM2MServerService service = GetService(client.Server); lock (service) { result = service.ExecuteResource(client.ClientID, objectDefinitionID, instanceID, property.PropertyDefinitionID); } return result; }
private Client LoadClientFromDoc(BsonDocument doc) { Client result = null; if (doc != null) { result = new Client(); result.ClientID = BsonHelper.GetGuid(doc, "_id"); result.Name = BsonHelper.GetString(doc, "Name"); result.OrganisationID = BsonHelper.GetInt32(doc, "OrganisationID"); result.Lifetime = BsonHelper.GetDateTime(doc, "Lifetime"); string versionText = BsonHelper.GetString(doc, "Version"); Version version; if (Version.TryParse(versionText, out version)) result.Version = version; result.BindingMode = (TBindingMode)BsonHelper.GetInt32(doc, "BindingMode"); result.SMSNumber = BsonHelper.GetString(doc, "SMSNumber"); result.Server = BsonHelper.GetString(doc, "Server"); result.LastActivityTime = BsonHelper.GetDateTime(doc, "LastActivityTime"); result.LastUpdateActivityTime = result.LastActivityTime; if (doc.Contains("SupportedTypes")) { BsonArray array = doc["SupportedTypes"].AsBsonArray; foreach (BsonValue arrayItem in array) { BsonDocument supportedTypeDoc = arrayItem.AsBsonDocument; if (supportedTypeDoc != null) { ObjectType supportedType = new ObjectType(); supportedType.ObjectTypeID = BsonHelper.GetInt32(supportedTypeDoc, "_id"); supportedType.Path = BsonHelper.GetString(supportedTypeDoc, "Path"); if (supportedTypeDoc.Contains("Instances")) { BsonArray instances = supportedTypeDoc["Instances"].AsBsonArray; foreach (BsonValue instance in instances) { supportedType.Instances.Add(instance.AsInt32); } } if (result.SupportedTypes == null) result.SupportedTypes = new ObjectTypes(); result.SupportedTypes.AddObjectType(supportedType); } } } } return result; }
public void DeleteClient(Client client) { DataAccessFactory.Clients.SaveBlacklistedClient(client, TObjectState.Add); //DataAccessFactory.Metrics.DeleteMetrics(client); DataAccessFactory.Servers.DeleteClient(client); }
public void SaveObject(Client client, Imagination.Model.Object lwm2mObject, Model.TObjectState state) { Service.ILWM2MServerService service = GetService(client.Server); lock (service) { string instanceID = service.SaveObject(client.ClientID, lwm2mObject, state); if (!string.IsNullOrEmpty(instanceID)) { lwm2mObject.InstanceID = instanceID; } } }
public void SaveObjectProperty(Client client, Guid objectDefinitionID, string instanceID, Property property, Model.TObjectState state) { Service.ILWM2MServerService service = GetService(client.Server); lock (service) { service.SaveObjectProperty(client.ClientID, objectDefinitionID, instanceID, property, state); } }
public List<Imagination.Model.Object> GetObjects(Client client, Guid objectDefinitionID) { return DataAccessFactory.Servers.GetObjects(client, objectDefinitionID); }
public bool SetNotificationParameters(Client client, Guid objectDefinitionID, string instanceID, Guid propertyDefinitionID, NotificationParameters notificationParameters) { bool setNotificationParameters = false; Service.ILWM2MServerService service = GetService(client.Server); lock (service) { setNotificationParameters = service.SetNotificationParameters(client.ClientID, objectDefinitionID, instanceID, propertyDefinitionID, notificationParameters); } return setNotificationParameters; }
public void SaveObjectProperty(Client client, Guid objectDefinitionID, string instanceID, Property property, Model.TObjectState state) { DataAccessFactory.Servers.SaveObjectProperty(client, objectDefinitionID, instanceID, property, state); }
public void SaveBlacklistedClient(Client client, TObjectState state) { IMongoDatabase database = GetDatabase(DATABASE_NAME, true); IMongoCollection<BsonDocument> collection = database.GetCollection<BsonDocument>("BlacklistedClient"); EnsureIndexExists<BsonDocument>(collection, "OrganisationID"); FilterDefinition<BsonDocument> query = Builders<BsonDocument>.Filter.Eq("_id", client.ClientID.ToByteArray()); if ((state == TObjectState.Add) || (state == TObjectState.Update)) { BsonDocument doc = new BsonDocument(); BsonHelper.SetValue(doc, "_id", client.ClientID); BsonHelper.SetValue(doc, "OrganisationID", client.OrganisationID); UpdateOptions options = new UpdateOptions(); options.IsUpsert = true; collection.ReplaceOne(query, doc, options); } else if (state == TObjectState.Delete) { collection.DeleteOne(query); } BroadcastTableChange("BlacklistedClient", StringUtils.GuidEncode(client.ClientID)); }