Beispiel #1
0
    public static UpdateDocument get_update_from_str(string str)
    {
        BsonDocument   doc        = BsonSerializer.Deserialize <BsonDocument>(str);
        UpdateDocument doc_update = new UpdateDocument();

        doc_update.AddRange(doc.Elements);
        return(doc_update);
    }
        public new void InsertDiscovery(long?discoveryID, string absoluteUri, int discoveryStateID, int discoveryTypeID, bool expectFileOrImage, int numberOfTimesDiscovered)
        {
            try
            {
                BsonDocument bsonDocument = new BsonDocument(false);

                bsonDocument.Add("id", BsonValue.Create(discoveryID, true));
                bsonDocument.Add("absoluteUri", BsonValue.Create(absoluteUri, true));
                bsonDocument.Add("discoveryStateID", BsonValue.Create(discoveryStateID, true));
                bsonDocument.Add("discoveryTypeID", BsonValue.Create(discoveryTypeID, true));
                bsonDocument.Add("expectFileOrImage", BsonValue.Create(expectFileOrImage, true));
                bsonDocument.Add("numberOfTimesDiscovered", BsonValue.Create(numberOfTimesDiscovered, true));

                IMongoQuery mongoQuery = Query.EQ("absoluteUri", absoluteUri);

                BsonDocument mongoResponse = _discoveriesCollection.FindOne(mongoQuery);

                if (mongoResponse != null)
                {
                    mongoResponse["id"] = bsonDocument["id"];
                    mongoResponse["discoveryStateID"]        = bsonDocument["discoveryStateID"];
                    mongoResponse["discoveryTypeID"]         = bsonDocument["discoveryTypeID"];
                    mongoResponse["expectFileOrImage"]       = bsonDocument["expectFileOrImage"];
                    mongoResponse["numberOfTimesDiscovered"] = bsonDocument["numberOfTimesDiscovered"];

                    UpdateDocument updateDocument = new UpdateDocument();

                    updateDocument.AddRange(mongoResponse);

                    _discoveriesCollection.Update(mongoQuery, updateDocument);
                }
                else
                {
                    _discoveriesCollection.Insert(bsonDocument);
                }
            }
            catch (Exception exception)
            {
                InsertException(absoluteUri, null, exception, false);
            }
        }
Beispiel #3
0
 public static UpdateDocument get_update_from_str(string str)
 {
     BsonDocument doc = BsonSerializer.Deserialize<BsonDocument>(str);
     UpdateDocument doc_update = new UpdateDocument();
     doc_update.AddRange(doc.Elements);
     return doc_update;
 }