Ejemplo n.º 1
0
 private static AnalyticRuleSettingsDto GetDefaultSettingsBySignature(
     int ruleType, int engineFamilyType, int engineType)
 {
     using (VTSDatabase database = new VTSDatabase())
     {
         AnalyticRuleSettingsEntity exactMatch =
             database.AnalyticRuleSettings.FirstOrDefault(
                 s => s.RuleType == ruleType &&
                 s.EngineFamilyType == engineFamilyType &&
                 s.EngineType == engineType);
         if (exactMatch != null)
         {
             return(AnalyticRuleSettingsAssembler.
                    FromEntityToDto(exactMatch));
         }
         AnalyticRuleSettingsEntity engineFamilyMatch =
             database.AnalyticRuleSettings.FirstOrDefault(
                 s => s.RuleType == ruleType &&
                 s.EngineFamilyType == engineFamilyType &&
                 s.EngineType == null);
         if (engineFamilyMatch != null)
         {
             return(AnalyticRuleSettingsAssembler.
                    FromEntityToDto(engineFamilyMatch));
         }
         AnalyticRuleSettingsEntity typeFallbackMatch =
             database.AnalyticRuleSettings.First(
                 s => s.RuleType == ruleType &&
                 s.EngineFamilyType == null &&
                 s.EngineType == null);
         return(AnalyticRuleSettingsAssembler.
                FromEntityToDto(typeFallbackMatch));
     }
 }
Ejemplo n.º 2
0
 private static AnalyticRuleSettingsEntity Get(int ruleType, int engineFamilyType, int engineType)
 {
     using (VTSDatabase database = new VTSDatabase())
     {
         AnalyticRuleSettingsEntity exactMatch =
             database.AnalyticRuleSettings.FirstOrDefault(
                 s => s.RuleType == ruleType &&
                 s.EngineFamilyType == engineFamilyType &&
                 s.EngineType == engineType);
         if (exactMatch != null)
         {
             return(exactMatch);
         }
         AnalyticRuleSettingsEntity engineFamilyMatch =
             database.AnalyticRuleSettings.FirstOrDefault(
                 s => s.RuleType == ruleType &&
                 s.EngineFamilyType == engineFamilyType &&
                 s.EngineType == null);
         if (engineFamilyMatch != null)
         {
             return(engineFamilyMatch);
         }
         AnalyticRuleSettingsEntity typeFallbackMatch =
             database.AnalyticRuleSettings.First(
                 s => s.RuleType == ruleType &&
                 s.EngineFamilyType == null &&
                 s.EngineType == null);
         return(typeFallbackMatch);
     }
 }
        private void AggregateAnalyticStatisticsItemEntity(
            AnalyticStatisticsItemEntity item,
            VTSDatabase database)
        {
            VTS.Shared.DomainObjects.AnalyticStatisticsItem asi =
                AnalyticStatisticsItemAssembler.FromEntityToDomainObject(item);
            VTS.AnalysisCore.Common.AnalyticRuleSettings settings = AggregatorFactory.Create(asi).Aggregate();
            AnalyticRuleSettingsEntity entityToUpdate             = database.AnalyticRuleSettings.
                                                                    FirstOrDefault(s => s.RuleType == (int)settings.RuleType && s.EngineType == (int)settings.EngineType);

            if (entityToUpdate == null)
            {
                database.AnalyticRuleSettings.Add(
                    AnalyticRuleSettingsAssembler.FromDomainObjectToEntity(settings));
            }
            else
            {
                AnalyticRuleSettingsEntity sourceEntity =
                    AnalyticRuleSettingsAssembler.FromDomainObjectToEntity(settings);
                UpdateAnalyticRuleStatisticalAtomEntity(sourceEntity, entityToUpdate);
                ReliabilitySummarizer summarizer = new ReliabilitySummarizer();
                summarizer.SummarizeFor(entityToUpdate);
            }
        }