Exemplo n.º 1
0
        public void ChangeReference(ObjectReal objectReal, ReferenceObject referenceObject, bool bulk = false)
        {
            var filter = Builders <ObjectReal> .Filter.Eq(or => or.EPC, objectReal.EPC);

            var objects = ObjectsReal.Find(filter).ToList();

            if (objects.Count < 1)
            {
                return;
            }
            if (objects[0].objectReference == referenceObject.id.ToString())
            {
                return;
            }
            var update = Builders <ObjectReal> .Update
                         .Set(r => r.objectReference, referenceObject.id.ToString())
                         .Set(r => r.name, referenceObject.name)
                         .Set(r => r.marca, referenceObject.marca)
                         .Set(r => r.price, referenceObject.precio)
                         .Set(r2 => r2.LastmodDate, DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss"));

            if (!bulk)
            {
                var result = ObjectsReal.UpdateOneAsync(filter, update);
                ObjectsReal = _database.GetCollection <ObjectReal>("ObjectReal");
            }
            else
            {
                BulkObjectsReal.Add(new UpdateOneModel <ObjectReal>(filter, update));
            }
        }
Exemplo n.º 2
0
        public void ChangeSerial(ObjectReal objectReal, string serial, bool bulk = false)
        {
            var filter = Builders <ObjectReal> .Filter.Eq(or => or.EPC, objectReal.EPC);

            var test = ObjectsReal.Find(filter).ToList();

            if (test.Count < 1)
            {
                filter = Builders <ObjectReal> .Filter.Eq(or => or.id, objectReal.id);

                test = ObjectsReal.Find(filter).ToList();
                if (test.Count < 1)
                {
                    return;
                }
            }
            if (test[0].serie == serial)
            {
                return;
            }

            var update = Builders <ObjectReal> .Update
                         .Set(r => r.serie, serial)
                         .Set(r2 => r2.LastmodDate, DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss"));

            if (!bulk)
            {
                var result = ObjectsReal.UpdateOneAsync(filter, update);
                ObjectsReal = _database.GetCollection <ObjectReal>("ObjectReal");
            }
            else
            {
                BulkObjectsReal.Add(new UpdateOneModel <ObjectReal>(filter, update));
            }
        }
Exemplo n.º 3
0
        public void Insert(ObjectReal objectReal)
        {
            if (ObjectsNumber == 0)
            {
                var result = ReferenceObjects.Find(_ => true).SortByDescending(x => x.object_id).Limit(1).ToList();
                if (result.Count > 0)
                {
                    ObjectsNumber = Convert.ToInt32(result[0].object_id) + 1;
                }
            }

            objectReal.object_id = ObjectsNumber.ToString();
            ObjectsReal.InsertOne(objectReal);
            ObjectsNumber++;
        }
Exemplo n.º 4
0
        public void ChangeLocation(ObjectReal objectReal, Location location, bool bulk = false)
        {
            var filter = Builders <ObjectReal> .Filter.Eq(or => or.EPC, objectReal.EPC);

            var update = Builders <ObjectReal> .Update
                         .Set(r => r.location, location.id.ToString())
                         .Set(r2 => r2.LastmodDate, DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss"));

            if (!bulk)
            {
                var result = ObjectsReal.UpdateOneAsync(filter, update);
                ObjectsReal = _database.GetCollection <ObjectReal>("ObjectReal");
            }
            else
            {
                BulkObjectsReal.Add(new UpdateOneModel <ObjectReal>(filter, update));
            }
        }
Exemplo n.º 5
0
        public void Remove(ObjectReal objectReal)
        {
            var filter = Builders <ObjectReal> .Filter.Eq(or => or.id, objectReal.id);

            var result = ObjectsReal.DeleteOneAsync(filter);
        }