public FaceEncodingInfo GetFromDB(string imageFile)
 {
     try
     {
         string imageFileLower = imageFile.ToLower();
         var    info           = _faceCollection.Include(x => x.FingerAndLocations).FindById(imageFileLower);
         if (info != null)
         {
             var fi = new FileInfo(imageFileLower);
             //Debug.WriteLine(fi.LastWriteTime.Ticks);
             if (fi.LastWriteTime.ToLongTimeString() == info.LastWriteTime.ToLongTimeString() &&
                 fi.LastWriteTime.ToLongDateString() == info.LastWriteTime.ToLongDateString() &&
                 fi.Length == info.Length)
             {
                 return(info);
             }
             else
             {
                 Debug.WriteLine($"Не совпадает LastWriteTime Length {imageFile}");
             }
         }
     }
     catch (InvalidCastException ex)
     {
         bool result = _faceCollection.Delete(imageFile);
         return(null);
     }
     return(null);
 }
Esempio n. 2
0
 public VpdbGame GetGame(string gameId)
 {
     return(_games
            .Include(g => g.Backglass)
            .Include(g => g.Logo)
            .FindById(gameId));
 }
Esempio n. 3
0
        public VpdbRelease GetRelease(string releaseId)
        {
            var release = _releases.Include(x => x.Game).FindById(releaseId);

            if (release == null)
            {
                return(null);
            }

            if (release.Game.Backglass != null)
            {
                release.Game.Backglass = _files.FindById(release.Game.Backglass.Id);
            }
            if (release.Game.Logo != null)
            {
                release.Game.Logo = _files.FindById(release.Game.Logo.Id);
            }
            release.Versions.ToList().ForEach(version => {
                version.Files.ToList().ForEach(file => {
                    file.Reference      = _files.FindById(file.Reference.Id);
                    file.PlayfieldImage = _files.FindById(file.PlayfieldImage.Id);
                    if (file.PlayfieldVideo != null)
                    {
                        file.PlayfieldVideo = _files.FindById(file.PlayfieldVideo.Id);
                    }
                    file.Compatibility = file.Compatibility.Select(build => _builds.FindById(build.Id)).ToList();
                });
            });
            release.Authors.ToList().ForEach(author => {
                author.User = _users.FindById(author.User.Id);
            });
            return(release);
        }
Esempio n. 4
0
        private void LoadData()
        {
            Logger logger = new Logger();

            using (var db = new LiteDatabase("pcclinic.db", null, logger))
            {
                LiteCollection <Customer> customersCollection = db.GetCollection <Customer>("customers");
                LiteCollection <Customer> customerFirstName   = customersCollection.Include(x => x.FirstName);

                var query = customersCollection
                            .Include(x => x.FirstName)
                            .Include(x => x.LastName)
                            .Find(x => x.Id >= 1);

                tblClients.ItemsSource = query;
            }
        }
Esempio n. 5
0
        public List <Job> GetJobs()
        {
            var jobs = _jobs
                       .Include(j => j.File)
                       .FindAll()
                       .ToList();

            jobs.ForEach(job => job.Release = GetRelease(job.Release.Id));
            return(jobs);
        }
Esempio n. 6
0
        public void consultar(ref Usuario usuario)
        {
            Usuario aux = col_usuario
                          .Include(x => x.conexoes)
                          .Include(x => x.pessoa)
                          .FindById(usuario.id);

            if (aux != null)
            {
                usuario = aux;
            }
            else
            {
                throw new Exception("BD não retornou valor");
            }
        }
Esempio n. 7
0
        private Deltaboard getCurrentDeltaboard(LiteCollection <Deltaboard> deltaboardCollection, DeltaboardType type)
        {
            DateTime startUtc;

            switch (type)
            {
            case DeltaboardType.Daily:
                startUtc = DateTime.Today.AddDays(1).ToUniversalTime();
                break;

            case DeltaboardType.Weekly:
                startUtc = DateTime.Now.StartOfWeek(DayOfWeek.Monday).ToUniversalTime();
                break;

            case DeltaboardType.Monthly:
                startUtc = DateTime.Now.StartOfMonth().ToUniversalTime();
                break;

            case DeltaboardType.Yearly:
                startUtc = DateTime.Now.StartOfYear().ToUniversalTime();
                break;

            case DeltaboardType.AllTime:
                startUtc = DateTime.MinValue.ToUniversalTime();
                break;

            default:
                throw new UnhandledEnumException <DeltaboardType>(type);
            }

            // Find deltaboard
            string id         = $"{type}-{startUtc}";
            var    deltaboard = deltaboardCollection
                                .Include(d => d.Entries)
                                .FindById(id);

            // Create if it doesn't exist
            if (deltaboard == null)
            {
                deltaboard = createDeltaboard(id, type, startUtc);
                deltaboardCollection.EnsureIndex(d => d.Id, true);
                deltaboardCollection.Insert(deltaboard);
            }

            return(deltaboard);
        }
Esempio n. 8
0
        //+
        private void OnMainData_SelectionChanged(object sender, EventArgs e)
        {
            if (MainDataGridView.SelectedRows.Count == 0)
            {
                return;
            }

            mainOrder = colMain
                        .Include(x => x.ClientOrders).Include(x => x.ClientOrders[0].Client).Include(x => x.ClientOrders[0].OrderItems[0].Product)
                        .FindById((int)MainDataGridView.SelectedRows[0].Cells[0].Value);

            //Fetch data
            Data_Fetch();

            //TEsT
            //orderItems.Sort((x,y) => {
            //    if (x.Quantity > y.Quantity) return 1;
            //    else if (x.Quantity < y.Quantity) return -1;
            //    else return 0;
            //});
        }
Esempio n. 9
0
        public void SimpleCase()
        {
            var mem = new MemoryStream();

            // Re-use mapper from global instance
            var mapper = BsonMapper.Global;

            // Produts and Customer are other collections (not embedded document)
            // you can use [BsonRef("colname")] attribute
            mapper.Entity <Order>()
            .DbRef(x => x.Products, "products")
            .DbRef(x => x.Customer, "customers");

            using (var db = new LiteDatabase(mem))
            {
                LiteCollection <Customer> customers = db.GetCollection <Customer>("customers");
                LiteCollection <Product>  products  = db.GetCollection <Product>("products");
                LiteCollection <Order>    orders    = db.GetCollection <Order>("orders");

                // create examples
                var john = new Customer {
                    Name = "John Doe"
                };
                var tv = new Product {
                    Description = "TV Sony 44\"", Price = 799
                };
                var iphone = new Product {
                    Description = "iPhone X", Price = 999
                };
                var order1 = new Order {
                    OrderDate = new DateTime(2017, 1, 1), Customer = john, Products = new List <Product> {
                        iphone, tv
                    }
                };
                var order2 = new Order {
                    OrderDate = new DateTime(2017, 10, 1), Customer = john, Products = new List <Product> {
                        iphone
                    }
                };

                // insert into collections
                customers.Insert(john);
                products.Insert(new[] { tv, iphone });
                orders.Insert(new[] { order1, order2 });

                // create index in OrderDate
                orders.EnsureIndex(x => x.OrderDate);

                // When query Order, includes references
                IEnumerable <Order> query = orders
                                            .Include(x => x.Customer)
                                            .Include(x => x.Products)
                                            .Find(x => x.OrderDate == new DateTime(2017, 1, 1));

                // Each instance of Order will load Customer/Products references
                Check.That(query.Count()).IsEqualTo(1);
                foreach (var c in query)
                {
                    Console.WriteLine("#{0} - {1}", c.Id, c.Customer.Name);

                    foreach (var p in c.Products)
                    {
                        Console.WriteLine(" > {0} - {1:c}", p.Description, p.Price);
                    }
                }
            }
        }
 public ICollectionWrapper <T> Include(Action <T> action)
 {
     return(new LiteCollectionWrapper <T>(_collection.Include(action), Database));
 }
Esempio n. 11
0
 public LiteCollection <T> Include <K>(Expression <Func <T, K> > keySelector)
 {
     return(LiteCollection.Include <K>(keySelector));
 }
Esempio n. 12
0
 public MailHeaderEntity FindOne(Expression <Func <MailHeaderEntity, bool> > predicate)
 {
     return(_mailHeaderEntity.Include(x => x.MailFromEntity).FindOne(predicate));
 }