/// <summary>
        /// 
        /// </summary>
        /// <param name="snapshot"></param>
        /// <param name="rulesViolationType"></param>
        /// <param name="businessCriteriaId"></param>
        /// <param name="onlyFailedChecks"></param>
        /// <returns></returns>
        private static IQueryable<ApplicationResult> GetQueryRuleViolations(Snapshot snapshot,
                                                                            Constants.RulesViolation rulesViolationType,
                                                                            Constants.BusinessCriteria businessCriteriaId,
                                                                            bool onlyFailedChecks)
        {
            if (snapshot == null || snapshot.BusinessCriteriaResults == null) return null;

            var query = snapshot.BusinessCriteriaResults.AsQueryable();

            if (businessCriteriaId != 0) {
                query = query.Where(_ => _.Reference.Key == businessCriteriaId.GetHashCode());
            }

            switch (rulesViolationType)
            {
                case Constants.RulesViolation.CriticalRulesViolation:
                    query = query.SelectMany(_ => _.CriticalRulesViolation);
                    break;
                case Constants.RulesViolation.NonCriticalRulesViolation:
                    query = query.SelectMany(_ => _.NonCriticalRulesViolation);
                    break;
                default:
                    query = query.SelectMany(_ => _.CriticalRulesViolation.Union(_.NonCriticalRulesViolation));
                    break;
            }

            query = (from bc in query
                     where bc.DetailResult != null
                     && bc.DetailResult.ViolationRatio != null
                     && (!onlyFailedChecks || bc.DetailResult.ViolationRatio.FailedChecks > 0)
                     select bc);

            return query;
        }
Example #2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="CurrentSnapshot"></param>
        /// <param name="PreviousSnapshot"></param>
        /// <param name="application"></param>
        /// <param name="indicatorId"></param>
        /// <returns></returns>
        public static Double? SumDeltaIndicator(Snapshot CurrentSnapshot, Snapshot PreviousSnapshot, Application application, Constants.SizingInformations measureId)
        {
            double? result = null;
            if(application != null && CurrentSnapshot != null && CurrentSnapshot.SizingMeasuresResults != null)
            {
                result = GetSizingMeasure(CurrentSnapshot, measureId);

                if (PreviousSnapshot != null && PreviousSnapshot.Annotation.Date.DateSnapShot.HasValue && PreviousSnapshot.SizingMeasuresResults != null )
                {
                    DateTime dtPrevoiusSnapshot = PreviousSnapshot.Annotation.Date.DateSnapShot.Value;
                    DateTime dtCurrentSnapshot = CurrentSnapshot.Annotation.Date.DateSnapShot.Value;

                    var quryPreviusIndicators = from s in application.Snapshots
                                                where s.Annotation.Date.DateSnapShot > dtPrevoiusSnapshot
                                                &&    s.Annotation.Date.DateSnapShot < dtCurrentSnapshot
                                                from i in s.SizingMeasuresResults
                                                where i.Reference.Key == measureId.GetHashCode()
                                                select i;

                    result += quryPreviusIndicators.Sum(s => s.DetailResult.Value);
                }
            }
            return result;
        }
Example #3
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="snapshot"></param>
        /// <param name="nbResult"></param>
        /// <returns></returns>
        public static List<ModuleResultDTO> GetModulesMeasure(Snapshot snapshot, int nbResult, Constants.SizingInformations measureId)
        {
            if(snapshot !=null && snapshot.SizingMeasuresResults != null)
            {
                return snapshot.SizingMeasuresResults
                               .Where(_ => _.Reference.Key == measureId.GetHashCode())
                               .SelectMany(_ => _.ModulesResult)
                               .Where(m => m.DetailResult != null)
                               .Select( _ => new ModuleResultDTO { Name = _.Module.Name, Value= _.DetailResult.Value})
                               .OrderByDescending(_ => _.Value)
                               .Take(nbResult)
                               .ToList();
            }

            return null;
        }
Example #4
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="snapshot"></param>
        /// <returns></returns>
        public static Double? GetSizingMeasure(Snapshot snapshot, Constants.SizingInformations measureId)
        {
            if (null != snapshot && snapshot.SizingMeasuresResults != null)
            {
                var measure = snapshot.SizingMeasuresResults.Where(_ => _.Reference.Key == measureId.GetHashCode())
                                                              .FirstOrDefault();

                if (null != measure && measure.DetailResult != null)
                    return MathUtility.GetRound(measure.DetailResult.Value);
            }

            return null;
        }
 /// <summary>
 /// Get TQI for snapshot
 /// </summary>
 /// <param name="snapshot"></param>
 /// <returns></returns>
 public static Double? GetSnapshotBusinessCriteriaGrade(Snapshot snapshot, Constants.BusinessCriteria bcId, bool Round)
 {
     double? res = null;
     if (null != snapshot && null != snapshot.BusinessCriteriaResults)
     {
         var resultBC = snapshot.BusinessCriteriaResults.SingleOrDefault(_ => _.Reference.Key == bcId.GetHashCode());
         if (resultBC != null)
         {
             res = Round ? MathUtility.GetRound(resultBC.DetailResult.Grade) : resultBC.DetailResult.Grade;
         }
     }
     return res;
 }