コード例 #1
0
        public override bool Populate()
        {
            string filename = PathAndName;
            this.Title = System.IO.Path.GetFileNameWithoutExtension(PathAndName);

            try
            {
                EPocalipse.IFilter.FilterReader ifil = new EPocalipse.IFilter.FilterReader(filename);
                this.All = ifil.ReadToEnd();
                ifil.Close();
            }
            catch (Exception ex)
            {
                throw new Exception("IFilter population failed. Exception : " + ex.Message, ex);
            }
            if (this.All != string.Empty)
            {
                this.Description = base.GetDescriptionFromWordsOnly(WordsOnly);
                return true;
            }
            else
            {
                return false;
            }
        }
コード例 #2
0
        public override bool GetResponse(System.Net.HttpWebResponse webresponse)
        {
            string filename = System.IO.Path.Combine(Preferences.DownloadedTempFilePath, (System.IO.Path.GetFileName(this.Uri.LocalPath)));

            this.Title = System.IO.Path.GetFileNameWithoutExtension(filename);

            //System.IO.Stream filestream = webresponse.GetResponseStream();
            //this.Uri = webresponse.ResponseUri;

            //using (System.IO.BinaryReader reader = new System.IO.BinaryReader(filestream))
            //{
            //    using (System.IO.FileStream iofilestream = new System.IO.FileStream(filename, System.IO.FileMode.Create))
            //    {
            //        int BUFFER_SIZE = 1024;
            //        byte[] buf = new byte[BUFFER_SIZE];
            //        int n = reader.Read(buf, 0, BUFFER_SIZE);
            //        while (n > 0)
            //        {
            //            iofilestream.Write(buf, 0, n);
            //            n = reader.Read(buf, 0, BUFFER_SIZE);
            //        }

            //        this.Uri = webresponse.ResponseUri;
            //        this.Length = iofilestream.Length;
            //        iofilestream.Close();
            //        iofilestream.Dispose();
            //    }
            //    reader.Close();
            //}
            SaveDownloadedFile(webresponse, filename);
            try
            {
                EPocalipse.IFilter.FilterReader ifil = new EPocalipse.IFilter.FilterReader(filename);
                this.All = ifil.ReadToEnd();
                ifil.Close();
                System.IO.File.Delete(filename);    // clean up
            }
            catch (Exception)
            {
//                ProgressEvent(this, new ProgressEventArgs(2, "IFilter failed on " + this.Uri + " " + e.Message + ""));
            }
            if (this.All != string.Empty)
            {
                this.Description = base.GetDescriptionFromWordsOnly(WordsOnly);
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #3
0
 /// <summary>
 /// [v7] Move the primary IFilter code into a protected method,
 /// to make extension (ie. subclassing) easier
 /// </summary>
 protected void GetResponseCore(System.Net.HttpWebResponse webresponse, string filename)
 {
     this.Title = System.IO.Path.GetFileNameWithoutExtension(filename);
     SaveDownloadedFile(webresponse, filename);
     try
     {
         EPocalipse.IFilter.FilterReader ifil = new EPocalipse.IFilter.FilterReader(filename);
         this.All = ifil.ReadToEnd();
         ifil.Close();
     }
     catch (Exception argex)
     {
         System.Diagnostics.Debug.WriteLine(argex);
     }
 }
コード例 #4
0
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            string[]         files = e.Argument as string[];
            BackgroundWorker wrk   = sender as BackgroundWorker;
            int i = 0;

            foreach (string fn in files)
            {
                if (wrk.CancellationPending)
                {
                    e.Cancel = true;
                    break;
                }
                backgroundWorker1.ReportProgress(1, fn);
                try
                {
                    if (hoot.IsIndexed(fn) == false)
                    {
                        using (TextReader tf = new EPocalipse.IFilter.FilterReader(fn))
                        {
                            string s = "";
                            if (tf != null)
                            {
                                s = tf.ReadToEnd();
                            }
                            if (s != "")
                            {
                                hoot.Index(new myDoc(new FileInfo(fn), s), true);
                            }
                        }
                    }
                }
                catch {
                }
                i++;
                if (i > 1000)
                {
                    i = 0;
                    hoot.Save();
                }
            }
            hoot.Save();
            //hoot.OptimizeIndex();
        }
コード例 #5
0
ファイル: Form1.cs プロジェクト: modulexcite/hOOt
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            string[] files = e.Argument as string[];
            BackgroundWorker wrk = sender as BackgroundWorker;
            int i = 0;
            foreach (string fn in files)
            {
                if (wrk.CancellationPending)
                {
                    e.Cancel = true;
                    break;
                }
                backgroundWorker1.ReportProgress(1, fn);
                try
                {
                    if (hoot.IsIndexed(fn) == false)
                    {
                        TextReader tf = new EPocalipse.IFilter.FilterReader(fn);
                        string s = "";
                        if (tf != null)
                            s = tf.ReadToEnd();

                        hoot.Index(new Document(new FileInfo(fn), s), true);
                    }
                }
                catch { }
                i++;
                if (i > 1000)
                {
                    i = 0;
                    hoot.Save();
                }
            }
            hoot.Save();
            hoot.OptimizeIndex();
        }
コード例 #6
0
 /// <summary>
 /// [v7] Move the primary IFilter code into a protected method, 
 /// to make extension (ie. subclassing) easier
 /// </summary>
 protected void GetResponseCore(System.Net.HttpWebResponse webresponse, string filename)
 {
     this.Title = System.IO.Path.GetFileNameWithoutExtension(filename);
     SaveDownloadedFile(webresponse, filename);
     try
     {
         EPocalipse.IFilter.FilterReader ifil = new EPocalipse.IFilter.FilterReader(filename);
         this.All = ifil.ReadToEnd();
         ifil.Close();
     }
     catch (Exception argex)
     {
         System.Diagnostics.Debug.WriteLine(argex);
     }
 }