public static IMAGE GetIMAGEFromDocument(Document doc) { IMAGE theVal = new IMAGE(); theVal._id = new Oid(doc["_id"].ToString()); theVal.ImageId = int.Parse(doc["IMAGEID"].ToString()); theVal.ContentType = doc["CONTENTTYPE"].ToString(); theVal.ImageData = ((Binary)doc["IMAGEDATA"]).ToArray <byte>(); theVal.ImageName = doc["IMAGENAME"].ToString(); theVal.TimesServed = int.Parse(doc["TIMESSERVED"].ToString()) + 1; return(theVal); }
public static IMAGE[] GetIMAGEsFromQueryDocument(IMongoCollection <Document> coll, Document query) { IMAGE[] arr = null; var cursor = coll.Find(query); if (cursor.Documents.Count() > 0) { arr = new IMAGE[cursor.Documents.Count()]; int ind = 0; foreach (Document doc in cursor.Documents) { arr[ind++] = GetIMAGEFromDocument(doc); } } return(arr); }
public static bool UpdateDocumentFromMEMBER(IMongoCollection <Document> coll, IMAGE val) { bool ret = true; Document doc = new Document(); var q = new Document(); q["_id"] = val._id; doc = coll.FindOne(q); if (doc.Count == 0) { return(false); } doc["IMAGEID"] = val.ImageId; doc["CONTENTTYPE"] = val.ContentType; doc["IMAGEDATA"] = new Binary(val.ImageData); doc["IMAGENAME"] = val.ImageName; doc["TIMESSERVED"] = val.TimesServed; coll.Save(doc); return(ret); }
public static bool InsertDocumentFromMEMBER(IMongoCollection <Document> coll, IMAGE val) { bool ret = true; Document doc = new Document(); doc["IMAGEID"] = val.ImageId; doc["CONTENTTYPE"] = val.ContentType; doc["IMAGEDATA"] = new Binary(val.ImageData);; doc["IMAGENAME"] = val.ImageName; doc["TIMESSERVED"] = val.TimesServed; coll.Insert(doc); return(ret); }