public DataSet CreateDataSet(DataSet dataset) { try { _dbase.Insert(dataset); } catch (Exception err) { throw new Exception(Errors.ERR_SIMULATION_BADREQUEST, err); } return(dataset); }
public DeviceManifest Create(DeviceManifest manifest) { try { if (manifest.isValid()) { // Provision the device in IoT Hub var device = AsyncHelper.RunSync <Device>(() => _registryManager.AddDeviceAsync(new Device(manifest.serialnumber))); // Update the manifest and store in DocDb manifest.key = device.Authentication.SymmetricKey.PrimaryKey; _dbase.Insert(manifest); } else { throw new Exception(Errors.ERR_DEVICEM_MODEL_NOT_VALID); } } catch (Exception err) { throw new Exception(Errors.ERR_DEVICEM_BAGREQUEST, err); } return(manifest); }
public Manifest Create(Manifest manifest) { try { if (manifest.IsValid()) { // Provision the device in IoT Hub var device = AsyncHelper.RunSync <Microsoft.Azure.Devices.Device>( () => _registryManager.AddDeviceAsync( new Microsoft.Azure.Devices.Device(manifest.SerialNumber))); var tags = new TwinPropertyRequest { DeviceId = device.Id, Name = "manufacturer", Properties = { ["manufacturer"] = manifest.Manufacturer, ["model"] = manifest.ModelNumber } }; UpdateTwinTags(tags); var desiredProps = new TwinPropertyRequest { DeviceId = device.Id, Name = "cadenceConfig", Properties = { ["heartbeat"] = manifest.Extensions["heartbeat"], ["telemetry"] = manifest.Extensions["telemetry"] } }; UpdateTwinProperties(desiredProps); // Update the manifest and store in DocDb manifest.Modified = DateTime.UtcNow; manifest.Key.PrimaryKey = device.Authentication.SymmetricKey.PrimaryKey; manifest.Key.SecondaryKey = device.Authentication.SymmetricKey.SecondaryKey; manifest.Hub = _iothubhostname; _dbase.Insert(manifest); } else { throw new Exception(Errors.ERR_DEVICE_MODEL_NOT_VALID); } } catch (Exception err) { throw new Exception(Errors.ERR_DEVICE_BAGREQUEST, err); } return(manifest); }
// Insert and then cache public void Insert <T>(T model) { _dbase.Insert <T>(model); //var objType = typeof(T); //var prop1 = objType.GetProperty("id"); //var prop2 = objType.GetProperty("cachettl"); //var id = (string)prop1.GetValue(model); //var cachettl = (int)prop2.GetValue(model); //var objStr = ModelManager.ModelToJson<T>(model); //_cache.Insert(id, objStr, cachettl); }
public Subscription Create(Subscription subscription) { try { if (subscription.IsValid()) { _dbase.Insert(subscription); } else { throw new Exception(Errors.ERR_ACCOUNT_INVALIDMODEL); } } catch (Exception err) { throw new Exception(Errors.ERR_ACCOUNT_BADREQUEST, err); } return(subscription); }
public Profile Create(Profile profile) { try { if (profile.IsValid()) { _dbase.Insert(profile); } else { throw new Exception(Errors.ERR_PROFILE_MODEL_INVALID); } } catch (Exception err) { throw new Exception(Errors.ERR_PROFILE_BADREQUEST, err); } return(profile); }
public Organization Create(Organization organization) { try { if (organization.IsValid()) { _dbase.Insert(organization); } else { throw new Exception(Errors.ERR_Customer_INVALIDMODEL); } } catch (Exception err) { throw new Exception(Errors.ERR_Customer_BADREQUEST, err); } return(organization); }
public Entity Create(Entity entity) { try { if (entity.isValid()) { _dbase.Insert(entity); } else { throw new Exception(Errors.ERR_REF_ENTITY_NOT_VALID); } } catch (Exception err) { throw new Exception(Errors.ERR_REF_BADREQUEST, err); } return(entity); }