Exemplo n.º 1
0
 private Task GenerateQvx(string entityName)
 {
     return(Task.Run(() =>
     {
         IsBusy = true;
         var server = new QvCouchbaseEntityServer(_bucket, EntityModels.ToList());
         server.RunStandalone("", "StandalonePipe", "", string.Format(@"c:\temp\{0}.qvx", entityName), string.Format("select * from {0}", entityName));
         IsBusy = false;
     }));
 }
Exemplo n.º 2
0
        protected virtual IMongoEntityModel GetEntityModel <TEntity>()
        {
            var model = EntityModels.GetOrDefault(typeof(TEntity));

            if (model == null)
            {
                throw new MongoDbException("Could not find a model for given entity type: " +
                                           typeof(TEntity).AssemblyQualifiedName);
            }

            return(model);
        }
Exemplo n.º 3
0
        private async Task MaterializeDataModel()
        {
            IsIndeterminate = false;
            var entityMap = EntityModels.ToLookup(e => e.Name);

            using (var materializedBucket = _cluster.OpenBucket("materialized"))
            {
                var query = _bucket.CreateQuery("entities", "all").Group(false).Reduce(true);
                MaximumProgress = (await _bucket.QueryAsync <long>(query)).Rows.First().Value;
                Progress        = 0;

                var         limit = PageSize;
                var         offset = 0;
                int         rows = 0;
                string      name, type, id;
                EntityModel model;
                List <Task> tasks;

                do
                {
                    tasks = new List <Task>();
                    query = _bucket.CreateQuery("entities", "all").Reduce(false).Limit(limit).Skip(offset);
                    var result = await _bucket.QueryAsync <dynamic>(query);

                    var entities = new List <Dictionary <string, object> >();

                    rows = result.Rows.Count();
                    foreach (var row in result.Rows)
                    {
                        id    = row.Id;
                        name  = row.Key[0];
                        type  = row.Key[1];
                        model = entityMap[type].FirstOrDefault();
                        tasks.Add(MaterializeSingleEntity(id, name, type, model, _bucket, materializedBucket));
                    }

                    await Task.WhenAll(tasks.ToArray());

                    tasks    = new List <Task>();
                    offset  += rows;
                    Progress = offset;
                }while (rows > 0);
            }

            IsIndeterminate = true;
        }