/// <summary> /// Compile all rows from the table storage into the format used in the blob storage for /// ASA job reference data. /// </summary> /// <returns></returns> private async Task <List <DeviceRuleBlobEntity> > BuildBlobEntityListFromTableRows() { IEnumerable <DeviceRuleTableEntity> queryResults = await GetAllRulesFromTable(); Dictionary <string, DeviceRuleBlobEntity> blobEntityDictionary = new Dictionary <string, DeviceRuleBlobEntity>(); foreach (DeviceRuleTableEntity rule in queryResults) { if (rule.Enabled) { DeviceRuleBlobEntity entity = null; if (!blobEntityDictionary.ContainsKey(rule.PartitionKey)) { entity = new DeviceRuleBlobEntity(rule.PartitionKey); blobEntityDictionary.Add(rule.PartitionKey, entity); } else { entity = blobEntityDictionary[rule.PartitionKey]; } if (rule.DataField == DeviceRuleDataFields.TEMP) { entity.TEMP = rule.Threshold; entity.TEMPRuleOutput = rule.RuleOutput; } //else if (rule.DataField == DeviceRuleDataFields.UpperTEMP) //{ // entity.UpperTEMP = rule.Threshold; // entity.TEMPRuleOutput = rule.RuleOutput; //} else if (rule.DataField == DeviceRuleDataFields.REAR_TPM) { entity.REAR_TPM = rule.Threshold; entity.REAR_TPMRuleOutput = rule.RuleOutput; } //insert DATA FIELD else if (rule.DataField == DeviceRuleDataFields.FRONT_TPM) { entity.FRONT_TPM = rule.Threshold; entity.FRONT_TPMRuleOutput = rule.RuleOutput; } else if (rule.DataField == DeviceRuleDataFields.BETTERY_VOLT) { entity.BETTERY_VOLT = rule.Threshold; entity.BETTERY_VOLTRuleOutput = rule.RuleOutput; } } } return(blobEntityDictionary.Values.ToList()); }
/// <summary> /// Compile all rows from the table storage into the format used in the blob storage for /// ASA job reference data. /// </summary> /// <returns></returns> private async Task <List <DeviceRuleBlobEntity> > BuildBlobEntityListFromTableRows() { IEnumerable <DeviceRuleTableEntity> queryResults = await GetAllRulesFromTable(); Dictionary <string, DeviceRuleBlobEntity> blobEntityDictionary = new Dictionary <string, DeviceRuleBlobEntity>(); foreach (DeviceRuleTableEntity rule in queryResults) { if (rule.Enabled) { DeviceRuleBlobEntity entity = null; if (!blobEntityDictionary.ContainsKey(rule.PartitionKey)) { entity = new DeviceRuleBlobEntity(rule.PartitionKey); blobEntityDictionary.Add(rule.PartitionKey, entity); } else { entity = blobEntityDictionary[rule.PartitionKey]; } if (rule.DataField == DeviceRuleDataFields.Temperature) { entity.Temperature = rule.Threshold; entity.TemperatureRuleOutput = rule.RuleOutput; } else if (rule.DataField == DeviceRuleDataFields.Speed) { entity.Speed = rule.Threshold; entity.SpeedRuleOutput = rule.RuleOutput; } else if (rule.DataField == DeviceRuleDataFields.IsObstacleDetected) { entity.IsObstacleDetected = System.Convert.ToBoolean(rule.Threshold); entity.ObstacleRuleOutput = rule.RuleOutput; } } } return(blobEntityDictionary.Values.ToList()); }