Esempio n. 1
0
        void streamListener_Completed(object sender, EventArgs e)
        {
            try
            {
                StreamListenerTee stream_listener_tee = (StreamListenerTee)sender;

                byte[] captured_data = stream_listener_tee.GetCapturedData();
                if (0 == captured_data.Length)
                {
                    if (!have_notified_about_installing_acrobat)
                    {
                        have_notified_about_installing_acrobat = true;

                        NotificationManager.Instance.AddPendingNotification(
                            new NotificationManager.Notification(
                                "We notice that your PDF files are not loading in your browser.  Please install Acrobat Reader for Qiqqa to be able to automatically add PDFs to your libraries.",
                                "We notice that your PDF files are not loading in your browser.  Please install Acrobat Reader for Qiqqa to be able to automatically add PDFs to your libraries.",
                                NotificationManager.NotificationType.Info,
                                Icons.DocumentTypePdf,
                                "Download",
                                DownloadAndInstallAcrobatReader
                                ));
                    }

                    Logging.Error("We seem to have been notified about a zero-length PDF");
                    return;
                }

                string temp_pdf_filename = TempFile.GenerateTempFilename("pdf");
                File.WriteAllBytes(temp_pdf_filename, captured_data);

                string      pdf_source_url = null; // Can we find this?!!
                PDFDocument pdf_document   = Library.GuestInstance.AddNewDocumentToLibrary_SYNCHRONOUS(temp_pdf_filename, pdf_source_url, null, null, null, true, true);
                File.Delete(temp_pdf_filename);

                Application.Current.Dispatcher.Invoke
                (
                    new Action(() =>
                {
                    PDFReadingControl pdf_reading_control = MainWindowServiceDispatcher.Instance.OpenDocument(pdf_document);
                    pdf_reading_control.EnableGuestMoveNotification(potential_attachment_pdf_document);
                }),
                    DispatcherPriority.Background
                );
            }

            catch (Exception ex)
            {
                Logging.Error(ex, "There was a problem while intercepting the download of a PDF.");
            }
        }
Esempio n. 2
0
        private void Stream_Completed(object sender, string url)
        {
            if (sender is StreamListenerTee)
            {
                StreamListenerTee oStream = sender as StreamListenerTee;
                byte[]            aData   = oStream.GetCapturedData();
                string            sData1  = Encoding.UTF8.GetString(aData);
                string            sData2  = Encoding.UTF7.GetString(aData);
                string            sData3  = Encoding.ASCII.GetString(aData);


                // Custom Event that returns the data
                OnTicketLoaded(new TicketLoadedEventArgs(url, sData1));
            }
        }
Esempio n. 3
0
        private void Stream_Completed(object sender, System.EventArgs e)
        {
            if (sender is StreamListenerTee)
            {
                StreamListenerTee oStream = sender as StreamListenerTee;
                byte[]            aData   = oStream.GetCapturedData();
                string            sData   = Encoding.UTF8.GetString(aData);

                if (url.Contains(Utils.Constants.SEARCH_RESPONSE_ENDPOINT))
                {
                    OnSearchResponse(new ResponseEventArgs(aData, sData));
                }
                else if (url.Contains(Utils.Constants.AUTH_RESPONSE_ENDPOINT))
                {
                    OnAuthResponse(new ResponseEventArgs(aData, sData));
                }
            }
        }