Exemplo n.º 1
0
        public override void AnnotationRenderWebPage(Guid renderTaskId, string renderUrl, AnnotationRenderWebPageComplete annotationRenderWebPageComplete)
        {
            ThreadPool.QueueUserWorkItem(delegate(object s)
            {
                string imageMimeType = "";
                int imageWidth       = 0;
                int imageHeight      = 0;
                _renderWebPage       = null;

                try
                {
                    if (renderUrl.ToLower().EndsWith(".jpg") || renderUrl.ToLower().EndsWith(".jpeg"))
                    {
                        Obany.Communications.CommunicationsResult communicationResult = Obany.Communications.CommunicationsManager.Get(new Uri(renderUrl), null);

                        if (communicationResult.Status == OperationStatus.Success)
                        {
                            using (System.IO.MemoryStream ms = new System.IO.MemoryStream(communicationResult.BinaryResponse))
                            {
                                using (System.Drawing.Image image = System.Drawing.Bitmap.FromStream(ms))
                                {
                                    imageMimeType  = "image/jpeg";
                                    imageWidth     = image.Width;
                                    imageHeight    = image.Height;
                                    _renderWebPage = communicationResult.BinaryResponse;
                                }
                            }
                        }
                    }
                }
                catch
                {
                }

                if (_renderWebPage == null)
                {
                    Obany.Render.Web.HtmlToImage h2i = new Obany.Render.Web.HtmlToImage();
                    _renderWebPage = h2i.RenderToBitmap(renderUrl, out imageWidth, out imageHeight, out imageMimeType);
                }

                if (annotationRenderWebPageComplete != null)
                {
                    annotationRenderWebPageComplete(_renderWebPage != null, renderTaskId, _renderWebPage, imageWidth, imageHeight, imageMimeType, null);
                }
            });
        }
 public abstract void AnnotationRenderWebPage(Guid renderTaskId, string renderUrl, AnnotationRenderWebPageComplete annotationRenderWebPageComplete);
Exemplo n.º 3
0
        public override void AnnotationRenderWebPage(Guid renderTaskId, string renderUrl, AnnotationRenderWebPageComplete annotationRenderWebPageComplete)
        {
            ThreadPool.QueueUserWorkItem(delegate(object s)
            {
                string imageMimeType = "";
                int imageWidth = 0;
                int imageHeight = 0;
                _renderWebPage = null;

                try
                {
                    if (renderUrl.ToLower().EndsWith(".jpg") || renderUrl.ToLower().EndsWith(".jpeg"))
                    {
                        Obany.Communications.CommunicationsResult communicationResult = Obany.Communications.CommunicationsManager.Get(new Uri(renderUrl), null);

                        if (communicationResult.Status == OperationStatus.Success)
                        {
                            using (System.IO.MemoryStream ms = new System.IO.MemoryStream(communicationResult.BinaryResponse))
                            {
                                using (System.Drawing.Image image = System.Drawing.Bitmap.FromStream(ms))
                                {
                                    imageMimeType = "image/jpeg";
                                    imageWidth = image.Width;
                                    imageHeight = image.Height;
                                    _renderWebPage = communicationResult.BinaryResponse;
                                }
                            }
                        }
                    }
                }
                catch
                {
                }

                if (_renderWebPage == null)
                {
                    Obany.Render.Web.HtmlToImage h2i = new Obany.Render.Web.HtmlToImage();
                    _renderWebPage = h2i.RenderToBitmap(renderUrl, out imageWidth, out imageHeight, out imageMimeType);
                }

                if (annotationRenderWebPageComplete != null)
                {
                    annotationRenderWebPageComplete(_renderWebPage != null, renderTaskId, _renderWebPage, imageWidth, imageHeight, imageMimeType, null);
                }
            });
        }