public void DeleteEmbeddedDocument(Images parentDocument, EmbeddedImageData deleteData) { FilterDefinitionBuilder <Images> filterBuilder = Builders <Images> .Filter; FilterDefinition <Images> filter = filterBuilder.And(filterBuilder.Eq("_id", parentDocument.ID), filterBuilder.Eq("image._id", deleteData.ID)); UpdateDefinition <Images> update = Builders <Images> .Update.PullFilter("Image", Builders <EmbeddedImageData> .Filter.Eq("_id", deleteData.ID)); connectionManager.RetrieveCollection <Images>().FindOneAndUpdate(filter, update); }
public void AppendNewDataItem(Images parentDocument, EmbeddedImageData newData) { FilterDefinition <Images> filter = Builders <Images> .Filter.Eq("_id", parentDocument.ID); UpdateDefinition <Images> update = Builders <Images> .Update.Push("image", newData); connectionManager.RetrieveCollection <Images>().UpdateOne(filter, update); }
public void UpdateOneEmbeddedData(Images parentDocument, EmbeddedImageData updatedData) { FilterDefinitionBuilder <Images> filterBuilder = Builders <Images> .Filter; FilterDefinition <Images> filter = filterBuilder.And(filterBuilder.Eq("_id", parentDocument.ID), filterBuilder.Eq("image._id", updatedData.ID)); UpdateDefinition <Images> update = Builders <Images> .Update.Set(document => document.ImageData[-1], updatedData); connectionManager.RetrieveCollection <Images>().FindOneAndUpdate(filter, update); }
private void ConvertFromWDV(LayerData[] layers, Size[] pageSizes) { if (pageSizes.Length >= layers.Length) { // all pages are bestfit to the first page Size destSize = pageSizes[0]; for (int i = 0; i < pageSizes.Length && i < layers.Length; i++) { float zoom = ScaleBestFit(pageSizes[i], destSize); SizeF zoomSize = new SizeF(pageSizes[i].Width * zoom, pageSizes[i].Height * zoom); PointF offset = new PointF((destSize.Width - zoomSize.Width) / 2, (destSize.Height - zoomSize.Height) / 2); EmbeddedImageData embeddedImage; AnnotationData data; for (int j = 0; j < layers[i].Items.Count; j++) { data = layers[i].Items[j]; if (layers[i].Items[j] is ReferencedImageData) { embeddedImage = new EmbeddedImageData(); embeddedImage.Location = layers[i].Items[j].Location; embeddedImage.Size = layers[i].Items[j].Size; try { Uri referencedImage = new Uri(((ReferencedImageData)layers[i].Items[j]).FileName); if (!referencedImage.IsAbsoluteUri) { if (System.Web.HttpContext.Current != null) { embeddedImage.Image = new AnnotationImage(new global::Atalasoft.Imaging.AtalaImage(System.Web.HttpContext.Current.Request.MapPath(((ReferencedImageData)layers[i].Items[j]).FileName))); } else { embeddedImage.Image = new AnnotationImage(new global::Atalasoft.Imaging.AtalaImage(((ReferencedImageData)layers[i].Items[j]).FileName)); } } layers[i].Items[j] = embeddedImage; } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); } } // can't use data.Transform because it stays with the annotation, need to modify data directly data.Location = new PointF((data.Location.X - offset.X) / zoom, (data.Location.Y - offset.Y) / zoom); data.Size = new SizeF(data.Size.Width / zoom, data.Size.Height / zoom); } } } }