/// <summary> /// Create a volume /// </summary> /// <param name="createVolumeRequest">Parameters for create</param> /// <param name="userId">User id</param> /// <exception cref="VolumeException">If cannot create a volume</exception> /// <returns>gRPC reply with volume id</returns> public async Task <VolumeReply> Create(CreateVolumeRequest createVolumeRequest, string userId) { logger.LogInformation("Requested for creaton of a volume"); // english string volumeId = IdentityFabric.GenVolumeId(); VolumeModel volume = VolumeAdapter.Volume(volumeId, createVolumeRequest); logger.LogInformation($"Created the VolumeModel with Id {volumeId}"); using IConnectionMultiplexer redis = redisService.Connect(); IDatabase db = redis.GetDatabase(); logger.LogInformation($"Connected to the Redis servier"); ITransaction transaction = db.CreateTransaction(); logger.LogInformation($"Bigin transaction"); string redisKey = GetVolumeKey(userId, volumeId); foreach (PropertyInfo propInfo in volume.GetType().GetProperties()) { _ = transaction.HashSetAsync(redisKey, propInfo.Name, propInfo.GetValue(volume).ToString()); } if (await transaction.ExecuteAsync() == false) { logger.LogError("Cannot create a volume. Transaction failed"); throw new VolumeException("Cannot create a volume"); } logger.LogInformation($"Creansaction completed successfully"); return(VolumeAdapter.Volume(volume)); }
/// <summary> /// Gets volume by id /// </summary> /// <param name="volumeId">Volume id (vol-xxxxxxxxx)</param> /// <param name="userId">User id</param> /// <returns></returns> public async Task <VolumeReply> Get(string volumeId, string userId) { logger.LogInformation($"Searching the volume with id {volumeId}"); logger.LogDebug($"Try to connect to the Redis"); using IConnectionMultiplexer redis = redisService.Connect(); var db = redis.GetDatabase(); logger.LogDebug($"Connected to the Redis"); string redisKey = GetVolumeKey(userId, volumeId); if (db.KeyExists(redisKey, CommandFlags.None) == false) { logger.LogError($"Cannot find a volume with id {redisKey}"); throw new VolumeException($"Cannot find a volume with id {redisKey}"); } logger.LogInformation($"The volume with id {redisKey} is exists in the store. " + $"Reqding the values.."); VolumeModel volumeModel = new VolumeModel(); foreach (PropertyInfo property in volumeModel.GetType().GetProperties()) { RedisValue value = await db.HashGetAsync(redisKey, property.Name); property.SetValue(volumeModel, Convert.ChangeType(value, property.PropertyType)); } logger.LogInformation($"The volume successfully read from the store"); return(VolumeAdapter.Volume(volumeModel)); }
/// <summary> /// List of volumes by user Id /// </summary> /// <param name="userId">Use Id</param> /// <returns></returns> public async Task <IEnumerable <VolumeReply> > List(string userId) { using IConnectionMultiplexer redisConnection = redisService.Connect(); var db = redisConnection.GetDatabase(); logger.LogDebug("Connected to Redis"); string redisKey = GetVolumeKey(userId); logger.LogDebug($"Searching by key pattern: {redisKey}"); EndPoint endPoint = redisConnection.GetEndPoints().First() ?? throw new VolumeException($"Cannot find the endpoint"); RedisKey[] keys = redisConnection.GetServer(endPoint).Keys(pattern: redisKey).ToArray(); logger.LogDebug($"Found {keys.Length} keys"); List <VolumeModel> volumes = new List <VolumeModel>(); foreach (RedisKey key in keys) { logger.LogDebug($"Reading the key {key}"); VolumeModel volumeModel = new VolumeModel(); foreach (PropertyInfo property in volumeModel.GetType().GetProperties()) { var value = await db.HashGetAsync(key, property.Name); property.SetValue(volumeModel, Convert.ChangeType(value, property.PropertyType)); } volumes.Add(volumeModel); } logger.LogDebug($"All volumes ejected successfully"); return(volumes.ConvertAll(v => VolumeAdapter.Volume(v))); }
public static Volume Converta(this VolumeModel model) { return(new Volume { Id = model.Id, Titulo = model.Titulo, Resumo = model.Resumo, ImageLink = model.ImageLink }); }
public IActionResult FromUKGallon(double valueInUKGallon) { try { Results = _volumeConvertingOperations.FromUKGallon(valueInUKGallon); return(Ok(Results)); } catch (Exception e) { return(BadRequest(e.Message)); } }
public IActionResult FromMilliliter(double valueInMilliliter) { try { Results = _volumeConvertingOperations.FromMilliliter(valueInMilliliter); return(Ok(Results)); } catch (Exception e) { return(BadRequest(e.Message)); } }
private static VolumeModel ReadFile(string path) { var input = FileSystem.ReadFile(path); var data = new List <LineModel>() { }; var volume = new VolumeModel() { FilePath = path, Name = path, //prendi solo nome file? Data = data }; return(volume); }
public WoplFile(GlobalTimbreLibrary timbreLibrary) { Version = 3; GlobalFlags = GlobalBankFlags.DeepTremolo | GlobalBankFlags.DeepVibrato; VolumeModel = VolumeModel.Auto; Melodic.Add(new WoplBank { Id = 0, Name = "" }); Percussion.Add(new WoplBank { Id = 0, Name = "" }); for (int i = 0; i < timbreLibrary.Data.Count; i++) { var timbre = timbreLibrary.Data[i]; WoplInstrument x = i < 128 ? Melodic[0].Instruments[i] ?? new WoplInstrument() : Percussion[0].Instruments[i - 128 + 35] ?? new WoplInstrument(); x.Name = ""; x.NoteOffset1 = timbre.MidiPatchNumber; x.NoteOffset2 = timbre.MidiBankNumber; x.InstrumentMode = InstrumentMode.TwoOperator; x.FbConn1C0 = timbre.FeedbackConnection; x.Operator0 = timbre.Carrier; x.Operator1 = timbre.Modulation; x.Operator2 = Operator.Blank; x.Operator3 = Operator.Blank; if (i < 128) { Melodic[0].Instruments[i] = x; } else { Percussion[0].Instruments[i - 128 + 35] = x; } } }
/// <summary> /// Create a vertex buffer for our verticies /// </summary> /// <param name="device"></param> /// <returns></returns> private static VertexBuffer CreateVertexBuffer(GraphicsDevice device, VolumeModel.PositionNormalTextureVertex[] Verticies) { VertexPositionNormalTexture[] vertArray = new VertexPositionNormalTexture[Verticies.Length]; for(int i = 0; i < Verticies.Length; i++) { GridVector3 pos = Verticies[i].Position; GridVector3 norm = Verticies[i].Normal; GridVector2 tex = Verticies[i].Texture; vertArray[i] = new VertexPositionNormalTexture( new Vector3((float)pos.X,(float)pos.Y, (float)pos.Z), new Vector3((float)norm.X,(float)norm.Y,(float)norm.Z), new Vector2((float)tex.X, (float)tex.Y)); } VertexBuffer vb = null; try { vb = new VertexBuffer(device, typeof(VertexPositionNormalTexture), vertArray.Length, BufferUsage.None); vb.SetData<VertexPositionNormalTexture>(vertArray); } catch (Exception) { if (vb != null) { vb.Dispose(); vb = null; } throw; } return vb; }
public static extern void adl_setVolumeRangeModel(IntPtr device, VolumeModel volumeModel);
public Task <ActionResult> Post([FromBody] VolumeModel volume) { return(ExecuteAsync(() => _service.AdicioneFavorito(volume))); }