Ejemplo n.º 1
0
        public DashboardFeatureByCount(DbFeatureContextRow context, DbFeatureRow feature, int count)
        {
            if (context == null) throw new ArgumentNullException(nameof(context));
            if (feature == null) throw new ArgumentNullException(nameof(feature));

            this.Context = context;
            this.Feature = feature;
            this.Count = count;
        }
Ejemplo n.º 2
0
        public static Task<DashboardCommonData> GetCommonDataAsync(FeatureContext featureContext)
        {
            if (featureContext == null) throw new ArgumentNullException(nameof(featureContext));

            {
                var contexts = new Dictionary<long, DbFeatureContextRow>();
                var features = new Dictionary<long, DbFeatureRow>();

                var dbContext = featureContext.DbContext;
                dbContext.Fill(contexts, (r, map) =>
                {
                    var row = new DbFeatureContextRow(r.GetInt32(0), r.GetString(1));
                    map.Add(row.Id, row);
                }, new Query(@"SELECT ID, NAME FROM FEATURE_CONTEXTS"));

                dbContext.Fill(features, (r, map) =>
                {
                    var row = new DbFeatureRow(r.GetInt32(0), r.GetString(1), r.GetInt32(2));
                    map.Add(row.Id, row);
                }, new Query(@"SELECT ID, NAME, CONTEXT_ID FROM FEATURES"));

                return Task.FromResult(new DashboardCommonData(contexts, features));
            }
        }
Ejemplo n.º 3
0
        private DbFeatureRow SaveFeature(IDbContext dbContext, DbFeatureContextRow featureContextRow, string name)
        {
            var contextId = featureContextRow.Id;
            List<DbFeatureRow> features;
            if (this.Features.TryGetValue(contextId, out features))
            {
                foreach (var featureRow in features)
                {
                    if (featureRow.Name.Equals(name, StringComparison.OrdinalIgnoreCase))
                    {
                        return featureRow;
                    }
                }
            }
            else
            {
                // Create feature collection for this context
                features = new List<DbFeatureRow>();
                this.Features.Add(contextId, features);
            }

            // Insert into database
            var newFeatureId = FeatureAdapter.InsertFeature(dbContext, name, contextId);

            var feature = new DbFeatureRow(newFeatureId, name, contextId);

            //Insert the new feature into the collection
            features.Add(feature);

            return feature;
        }
Ejemplo n.º 4
0
        private DbFeatureContextRow SaveContext(IDbContext dbContext, string name)
        {
            DbFeatureContextRow featureContextRow;

            if (!this.Contexts.TryGetValue(name, out featureContextRow))
            {
                // Insert into database
                var newContextId = FeatureAdapter.InsertContext(dbContext, name);

                featureContextRow = new DbFeatureContextRow(newContextId, name);

                // Insert the new context into the collection
                this.Contexts.Add(name, featureContextRow);
            }

            return featureContextRow;
        }