示例#1
0
            public QueryField(QuerySection section, PropertyInfo pi, GetCountsResult counts)
            {
                ParentSection = section;
                Title         = pi.GetCustomAttribute <DisplayNameAttribute>()?.DisplayName ?? pi.Name;
                var pt = pi.PropertyType;

                if (pt.IsNumber())
                {
                    QueryFieldType = QueryFieldTypes.Numeric;
                }
                else if (pt == typeof(bool))
                {
                    QueryFieldType = QueryFieldTypes.Boolean;
                }
                else if (pt == typeof(DateTime))
                {
                    QueryFieldType = QueryFieldTypes.Date;
                }
                else
                {
                    QueryFieldType = QueryFieldTypes.Text;
                }
                PropertyPath = (ParentSection.PropertyPath.AppendIfHasData(".") ?? "") + pi.Name;
                JPath        = (ParentSection.JPath.AppendIfHasData(".") ?? "") + pi.GetSerializedPropertyName();
                if (counts != null)
                {
                    var cntByVal = counts.CntByValByField.FindOrDefault(JPath);
                    if (cntByVal != null && cntByVal.Count > 0)
                    {
                        ValuesList = cntByVal.ConvertAll(kvp => new SelectListItem {
                            Value = kvp.Key, Text = $"{kvp.Key} ({kvp.Value})"
                        });
                    }
                }
            }
示例#2
0
        public async Task Populate(TraffkRdbContext rdb, CrmDdbContext crm, bool includePhi, params CollectionNames[] supportedCollections)
        {
            foreach (var collection in supportedCollections)
            {
                Type            baseType;
                GetCountsResult counts = null;
                switch (collection)
                {
                case CollectionNames.Contacts:
                    counts = await rdb.GetContrainedFieldCountsAsync <Contact>(true);

                    baseType = typeof(Contact);
                    break;

                case CollectionNames.Eligibility:
                    counts = await rdb.GetContrainedFieldCountsAsync <Eligibility>(true);

                    baseType = typeof(Eligibility);
                    break;

                case CollectionNames.Scores:
                    counts = await rdb.GetContrainedFieldCountsAsync <Score>(true);

                    baseType = typeof(Score);
                    break;

                case CollectionNames.Demographics:
                    counts = await rdb.GetContrainedFieldCountsAsync <Demographic>(true);

                    baseType = typeof(Demographic);
                    break;

                case CollectionNames.Pcp:
                    counts = await rdb.GetContrainedFieldCountsAsync <MemberPCP>(true);

                    baseType = typeof(MemberPCP);
                    break;

                case CollectionNames.HighCostDiagnosis:
                    counts = await rdb.GetContrainedFieldCountsAsync <HighCostDiagnosi>(true);

                    baseType = typeof(HighCostDiagnosi);
                    break;

                default:
                    throw new UnexpectedSwitchValueException(collection);
                }
                var section = new QuerySection(collection, baseType, null, includePhi, counts);
                Sections.Add(section);
            }
        }
示例#3
0
        public ListingFilters(GetCountsResult counts, string path, string queryString)
        {
            var q          = WebHelpers.ParseQueryParams(queryString);
            var sections   = new List <Section>();
            var totalCount = 0;

            foreach (var fieldName in counts.CntByValByField.Keys)
            {
                var filters  = new List <Filter>();
                var cntByVal = counts.CntByValByField[fieldName];
                foreach (var val in cntByVal.Keys)
                {
                    totalCount += cntByVal[val];
                    var f = new Filter
                    {
                        Title     = $"{val} ({cntByVal[val]})",
                        Value     = val,
                        FieldName = fieldName,
                        Count     = cntByVal[val]
                    };
                    if (q.Contains(fieldName, val))
                    {
                        f.IsChecked = true;
                        q.Remove(fieldName, val);
                        if (q.Count == 0)
                        {
                            f.OnSubmittedUrl = path;
                        }
                        else
                        {
                            f.OnSubmittedUrl = WebHelpers.AppendParameters("", q.AtomEnumerable);
                        }
                        q.Add(fieldName, val);
                    }
                    else
                    {
                        f.IsChecked = false;
                        q.Add(fieldName, val);
                        f.OnSubmittedUrl = WebHelpers.AppendParameters("", q.AtomEnumerable);
                        q.Remove(fieldName, val);
                    }
                    filters.Add(f);
                }
                var section = new Section {
                    SectionName = fieldName, Filters = filters.ToArray(), TotalCount = totalCount
                };
                sections.Add(section);
            }
            Sections = sections;
        }
示例#4
0
 public QuerySection(CollectionNames collection, Type baseType, MemberInfo baseMember, bool includePhi, GetCountsResult counts, QuerySection parentSection = null)
 {
     Collection    = collection;
     ParentSection = parentSection;
     Title         = baseType.GetCustomAttribute <DisplayNameAttribute>()?.DisplayName ?? baseType.Name;
     if (baseMember != null)
     {
         PropertyPath = parentSection.PropertyPath + "." + baseMember.Name;
         JPath        = parentSection.JPath + "." + baseMember.GetSerializedPropertyName();
     }
     baseType.MemberWalk <QuerySection>(
         BindingFlags.GetProperty | BindingFlags.Public | BindingFlags.Instance,
         (parent, t, mi) => this,
         (ctx, t, mi) =>
     {
         var pi = (PropertyInfo)mi;
         if (ShouldIgnore(pi))
         {
             return;
         }
         if (t.GetTypeInfo().IsClass&& t.Namespace.StartsWith("Traffk."))
         {
             var s = new QuerySection(collection, t, mi, includePhi, counts, this);
             if (s.Children.Count > 0)
             {
                 Children.Add(s);
             }
         }
         else
         {
             var qf = new QueryField(this, pi, counts);
             Children.Add(qf);
         }
     },
         (ctx, t, mi) =>
     {
         if (t.IsA(typeof(IEnumerable)))
         {
             return(false);
         }
         if (!t.Namespace.StartsWith("Traffk."))
         {
             return(false);
         }
         if (ShouldIgnore((PropertyInfo)mi))
         {
             return(false);
         }
         return(true);
     }
         );
 }