private void AddNewValueToExistingItem(AnalyticStatisticsItem item,
                                               AnalyticStatisticsValue value)
        {
            AnalyticStatisticsValueEntity entityToAdd =
                AnalyticStatisticsValueAssembler.FromDomainObjectToEntity(value);

            using (VTSDatabase database = new VTSDatabase())
            {
                AnalyticStatisticsItemEntity existingItem = database.AnalyticStatisticsItem.First(
                    i => i.Type == (int)item.Type &&
                    i.TargetEngineFamilyType == (int)item.TargetEngineFamilyType &&
                    i.TargetEngineType == (int)item.TargetEngineType);
                existingItem.AnalyticStatisticsValue.Add(entityToAdd);
                database.SaveChanges();
                RememberUpdatedItem(existingItem);
            }
        }
示例#2
0
 private static List <AnalyticStatisticsValue> GetFromService(
     AnalyticRuleType type, string vin)
 {
     try
     {
         List <AnalyticStatisticsValue> result  = new List <AnalyticStatisticsValue>();
         VtsWebServiceClient            service = new VtsWebServiceClient();
         foreach (AnalyticStatisticsValueDto dto in
                  service.GetAnalyticStatisticsPerVehicle(vin, (int)type))
         {
             result.Add(AnalyticStatisticsValueAssembler.FromDtoToDomainObject(dto));
         }
         return(result);
     }
     catch (Exception e)
     {
         Log.Error(e, "Could not fill Analytic statistics cache");
         return(new List <AnalyticStatisticsValue>());
     }
 }