private static string DownloadPdfFromUrl(string pdfUrl) { BusyWndSingleton.Show("Processing PDF-link..."); WebClient webClient = new WebClient(); try { using (Stream stream = webClient.OpenRead(pdfUrl)) { string PathName = Utils.RandomFilePath(".pdf"); using (var fs = new FileStream(PathName, FileMode.Create)) { stream.CopyTo(fs); stream.Flush(); return(PathName); } } } catch (Exception) { return(null); } finally { BusyWndSingleton.Hide(); } }
//if Url!=null, uses it. otherwice asks for URL private static Attachment AttachFromYoutube(ArgPoint Point, string Url) { string URLToUse = Url; if (URLToUse == null) { InpDialog dlg = new InpDialog(); dlg.ShowDialog(); URLToUse = dlg.Answer; if (URLToUse == null || !URLToUse.StartsWith("http://")) { return(null); } } BusyWndSingleton.Show("Processing Youtube attachment..."); Attachment res = new Attachment(); try { YouTubeInfo videoInfo = YouTubeProvider.LoadVideo(URLToUse); if (videoInfo == null) { return(null); } res.Format = (int)AttachmentFormat.Youtube; res.VideoEmbedURL = videoInfo.EmbedUrl; res.VideoThumbURL = videoInfo.ThumbNailUrl; res.VideoLinkURL = videoInfo.LinkUrl; res.Link = videoInfo.LinkUrl; res.Title = videoInfo.VideoTitle; res.Name = URLToUse; res.Thumb = ImageToBytes(GetYoutubeThumb(videoInfo.ThumbNailUrl), new JpegBitmapEncoder()); if (Point != null) { Point.Attachment.Add(res); } ///PublicBoardCtx.Get().SaveChanges(); } finally { BusyWndSingleton.Hide(); } return(res); }
public static void startResultViewer() { if (SessionInfo.Get().discussion == null) { MessageDlg.Show("No default discussion"); } else { if (SessionInfo.Get().person.Session == null) { MessageDlg.Show( string.Format( "The function requires experimental mode (session)!", SessionInfo.Get().person.Name)); return; } var tsd = new TopicSelectionDlg(SessionInfo.Get().discussion); tsd.ShowDialog(); if (tsd.topic == null) { return; } if (tsd.Html) { var reportUrl = string.Format( "http://{0}/discsvc/report?discussionId={1}&topicId={2}&sessionId={3}", ConfigManager.ServiceServer, SessionInfo.Get().discussion.Id, tsd.topic.Id, SessionInfo.Get().person.Session.Id); try { System.Diagnostics.Process.Start("chrome", reportUrl); } catch { System.Diagnostics.Process.Start(reportUrl); } //var browser = WebkitBrowserWindow.Instance(reportUrl, tsd.topic.Id); //browser.Show(); //browser.Activate(); } else { BusyWndSingleton.Show("Exporting, please wait..."); try { (new PdfReportDriver()).Run(SessionInfo.Get().person.Session, tsd.topic, SessionInfo.Get().discussion, SessionInfo.Get().person); } finally { BusyWndSingleton.Hide(); } } } }