Beispiel #1
0
        public override void OnFileSaved()
        {
            base.OnFileSaved();

            if (!UserConnection.GetIsFeatureEnabled("LinkPreview"))
            {
                return;
            }

            var fileType = Entity.GetTypedColumnValue <Guid>("TypeId");

            if (fileType == Terrasoft.WebApp.FileConsts.LinkTypeUId)
            {
                var url = Entity.GetTypedColumnValue <string>("Name").Trim();
                if (IsURLValid(url))
                {
                    LinkPreview     linkPreview     = new LinkPreview();
                    LinkPreviewInfo linkPreviewInfo = linkPreview.GetWebPageLinkPreview(url);
                    if (linkPreviewInfo != null)
                    {
                        LinkPreviewProvider linkPreviewProvider = new LinkPreviewProvider(UserConnection);
                        linkPreviewProvider.SaveLinkPreviewInfo(linkPreviewInfo, Entity.PrimaryColumnValue);
                    }
                }
            }
        }
Beispiel #2
0
        public LinkPreviewServiceResponse GetWebPageLinkPreview(string url)
        {
            LinkPreview linkPreview = CreateLinkPreview();

            LinkPreviewServiceResponse response = new LinkPreviewServiceResponse();

            try {
                response.LinkPreviewInfo = linkPreview.GetWebPageLinkPreview(url);
            } catch (Exception e) {
                response.Exception = e;
            }
            return(response);
        }