Esempio n. 1
0
        public static List<string> GetNewsToday()
        {
            List<string> tmp = new List<string>();
            TextExtraction t = new TextExtraction();

            ZetaCrawlerEntities db = new ZetaCrawlerEntities();

            string[] strSplit = { "/" };

            var pBIDV = from q in db.BIDVObjects
                    where ((q.IsToEmail == false) && (q.LastModified.Value.Day == DateTime.Now.Day))
                    select q;

            foreach (var item in pBIDV)
            {
                tmp.Add("<br />" + "[" + item.LastModified.ToString() + "] " + "<b>" + t.GetBetween2Words("Trích yếu: ", "Độ khẩn", item.Summary) + "</b><br />Xem chi tiết : " + item.OriginalUrl + "<br />");
                item.IsToEmail = true;
            }

            var pASPNET = from q in db.ASPNETObjects
                    where ((q.IsToEmail == false) &&(q.LastModified.Value.Day == DateTime.Now.Day) )
                    select q;

            foreach (var item in pASPNET)
            {
                tmp.Add("<br />" + "[" + item.LastModified.ToString() + "] " + "<b>" + item.Summary + "</b><br />Xem chi tiết : " + item.OriginalUrl + "<br />");
                item.IsToEmail = true;
            }

            db.SaveChanges();
            return tmp;
        }
        public ActionResult FileUploaderAjax(PDFFile membervalues)
        {
            //string FileName = Path.GetFileNameWithoutExtension(membervalues.PDFFileName.FileName);

            ////To Get File Extension
            //string FileExtension = Path.GetExtension(membervalues.PDFFileName.FileName);

            ////Add Current Date To Attached File Name
            //FileName = DateTime.Now.ToString("yyyyMMdd") + "-" + FileName.Trim() + FileExtension;
            string errorLogPathStr = ConfigurationManager.AppSettings["ErrorLogPath"];
            string errorLogPath    = Server.MapPath(errorLogPathStr);
            bool   deleteUploadedFile;

            try
            {
                if (Request.Files.Count > 0)
                {
                    var file = Request.Files[0];

                    if (file != null && file.ContentLength > 0)
                    {
                        var fileName = Path.GetFileName(file.FileName);

                        string UploadPathConfig = ConfigurationManager.AppSettings["UploadPath"].ToString();
                        deleteUploadedFile = Convert.ToBoolean(ConfigurationManager.AppSettings["DeleteUploadedFile"].ToString());
                        string UploadPath = Server.MapPath(UploadPathConfig);
                        var    path       = Path.Combine(UploadPath, fileName);//+"_"+Guid.NewGuid().ToString()

                        if (!System.IO.File.Exists(path))
                        {
                            file.SaveAs(path);
                        }
                        TextExtraction             textExtraction = new TextExtraction();
                        Dictionary <string, Int64> keyValuePairs  = textExtraction.CalculatePages(path, errorLogPath);
                        ViewBag.PDFInfo  = keyValuePairs;
                        ViewBag.FilePath = path;
                        if (deleteUploadedFile && System.IO.File.Exists(path))
                        {
                            System.IO.File.Delete(path);
                        }
                        return(Json(new { Total = keyValuePairs["TotalPages"], Colored = keyValuePairs["ColorPages"], BlackAndWhite = keyValuePairs["BWPages"] }, JsonRequestBehavior.AllowGet));
                    }
                }
            }
            catch (Exception ex)
            {
                CreateLog(ex, errorLogPath);
            }

            //Get Upload path from Web.Config file AppSettings.


            //Its Create complete path to store in server.
            //membervalues.ImagePath = UploadPath + FileName;

            //To copy and save file into server.
            //membervalues.PDFFileName.SaveAs(membervalues.ImagePath);

            return(View());
        }
        public void MergeFrom(AnnotationPayload other)
        {
            if (other == null)
            {
                return;
            }
            if (other.AnnotationSpecId.Length != 0)
            {
                AnnotationSpecId = other.AnnotationSpecId;
            }
            if (other.DisplayName.Length != 0)
            {
                DisplayName = other.DisplayName;
            }
            switch (other.DetailCase)
            {
            case DetailOneofCase.Translation:
                if (Translation == null)
                {
                    Translation = new global::Google.Cloud.AutoML.V1.TranslationAnnotation();
                }
                Translation.MergeFrom(other.Translation);
                break;

            case DetailOneofCase.Classification:
                if (Classification == null)
                {
                    Classification = new global::Google.Cloud.AutoML.V1.ClassificationAnnotation();
                }
                Classification.MergeFrom(other.Classification);
                break;

            case DetailOneofCase.ImageObjectDetection:
                if (ImageObjectDetection == null)
                {
                    ImageObjectDetection = new global::Google.Cloud.AutoML.V1.ImageObjectDetectionAnnotation();
                }
                ImageObjectDetection.MergeFrom(other.ImageObjectDetection);
                break;

            case DetailOneofCase.TextExtraction:
                if (TextExtraction == null)
                {
                    TextExtraction = new global::Google.Cloud.AutoML.V1.TextExtractionAnnotation();
                }
                TextExtraction.MergeFrom(other.TextExtraction);
                break;

            case DetailOneofCase.TextSentiment:
                if (TextSentiment == null)
                {
                    TextSentiment = new global::Google.Cloud.AutoML.V1.TextSentimentAnnotation();
                }
                TextSentiment.MergeFrom(other.TextSentiment);
                break;
            }

            _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
        }
Esempio n. 4
0
        /// <summary>
        /// </summary>
        /// <param name="crawler">
        /// The crawler.
        /// </param>
        /// <param name="propertyBag">
        /// The property bag.
        /// </param>
        public void Process(Crawler crawler, PropertyBag propertyBag)
        {
            CultureInfo contentCulture = (CultureInfo)propertyBag["LanguageCulture"].Value;
            string cultureDisplayValue = "N/A";
            if (!contentCulture.IsNull())
            {
                cultureDisplayValue = contentCulture.DisplayName;
            }

            TextExtraction t = new TextExtraction();

            lock (this)
            {
                BIDVObject item = new BIDVObject();
                item.OriginalUrl = propertyBag.Step.Uri.ToString();

                if (!IsDuplicate(item.OriginalUrl))
                {
                    item.Title = propertyBag.Title;
                    item.StatusDescription = propertyBag.StatusDescription;
                    item.ResponseUri = propertyBag.ResponseUri.ToString();
                    item.Text = propertyBag.Text;
                    item.Depth = propertyBag.Step.Depth;
                    item.LastModified = propertyBag.LastModified;
                    item.OriginalReferrerUrl = propertyBag.OriginalReferrerUrl.ToString();
                    item.Server = propertyBag.Server;
                    string description = t.GetBetween2Words("Chi tiết văn bản", "Xem toàn màn hình", item.Text.Replace("\r","  ").Replace("\n","  "));
                    item.Summary = t.RemoveWhiteSpace(description);

                    string strNgayPhatHanh = t.GetBetween2Words("Ngày phát hành", "Số đi", item.Summary);
                    strNgayPhatHanh = strNgayPhatHanh.Replace(' ', '/').Remove(0, ("Ngày phát hành").Length);
                    string[] strSplit = { "/" };
                    int day = int.Parse(strNgayPhatHanh.Split(strSplit, StringSplitOptions.None)[1]);
                    int month = int.Parse(strNgayPhatHanh.Split(strSplit, StringSplitOptions.None)[2]);
                    int year = int.Parse(strNgayPhatHanh.Split(strSplit, StringSplitOptions.None)[3]);

                    //Clean the text field is null
                    item.Text = null;
                    item.IsToEmail = false;

                    db.AddToBIDVObjects(item);

                    item.ContentEncoding = propertyBag.ContentEncoding;
                    item.ContentType = propertyBag.ContentType;
                    //item.Length = propertyBag.Text.IsNull() ? 0 : propertyBag.Text.Length;
                    //item.CultureDisplayValue = cultureDisplayValue;
                }
            }

            try
            {
                db.SaveChanges();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Esempio n. 5
0
        /// <summary>
        /// </summary>
        /// <param name="crawler">
        /// The crawler.
        /// </param>
        /// <param name="propertyBag">
        /// The property bag.
        /// </param>
        public void Process(Crawler crawler, PropertyBag propertyBag)
        {
            CultureInfo contentCulture = (CultureInfo)propertyBag["LanguageCulture"].Value;
            string cultureDisplayValue = "N/A";
            if (!contentCulture.IsNull())
            {
                cultureDisplayValue = contentCulture.DisplayName;
            }

            TextExtraction t = new TextExtraction();

            lock (this)
            {
                BIDVObject item = new BIDVObject();
                //item.Id = Guid.NewGuid();
                //item.Url = propertyBag.Step.Uri.ToString();

                //if (item.Url.StartsWith("http://bidvportal.vn/eDocman"))
                //{
                //    item.Title = propertyBag.Title;

                //    string strTarget = t.GetMinimumString(propertyBag.Text, "Chi tiết văn bản", "Nội dung văn bản");
                //    item.Text = strTarget;

                //    string strNgayPhatHanh = t.GetMinimumString(strTarget, "Ngày phát hành", "Số đi");
                //    item.NgayPhatHanh = strNgayPhatHanh.Replace(' ','/');

                //    string strSubject = t.GetMinimumString(strTarget, "Trích yếu", "Độ khẩn");
                //    //item.Subject = strSubject;

                //    //item.ContentEncoding = propertyBag.ContentEncoding;
                //    //item.ContentType = propertyBag.ContentType;
                //    //item.Length = propertyBag.Text.IsNull() ? 0 : propertyBag.Text.Length;
                //    item.Depth = propertyBag.Step.Depth;
                //    //item.CultureDisplayValue = cultureDisplayValue;

                //    string[] strSplit = { "/" };
                //    int day = int.Parse(item.NgayPhatHanh.Split(strSplit, StringSplitOptions.None)[0]);
                //    int month = int.Parse(item.NgayPhatHanh.Split(strSplit, StringSplitOptions.None)[1]);
                //    int year = int.Parse(item.NgayPhatHanh.Split(strSplit, StringSplitOptions.None)[2]);

                //    if ((DateTime.Now.Year == year) && (DateTime.Now.Month == month) && (DateTime.Now.Day == day))
                //    {
                //        //db.AddToItems(item);
                //    }
                //}
            }

            try
            {
                db.SaveChanges();
            }
            catch (Exception ex)
            {
                Console.WriteLine("=====================================================");
                Console.WriteLine(ex.Message);
            }
        }
Esempio n. 6
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (detailCase_ == DetailOneofCase.Translation)
            {
                hash ^= Translation.GetHashCode();
            }
            if (detailCase_ == DetailOneofCase.Classification)
            {
                hash ^= Classification.GetHashCode();
            }
            if (detailCase_ == DetailOneofCase.ImageObjectDetection)
            {
                hash ^= ImageObjectDetection.GetHashCode();
            }
            if (detailCase_ == DetailOneofCase.VideoClassification)
            {
                hash ^= VideoClassification.GetHashCode();
            }
            if (detailCase_ == DetailOneofCase.VideoObjectTracking)
            {
                hash ^= VideoObjectTracking.GetHashCode();
            }
            if (detailCase_ == DetailOneofCase.TextExtraction)
            {
                hash ^= TextExtraction.GetHashCode();
            }
            if (detailCase_ == DetailOneofCase.TextSentiment)
            {
                hash ^= TextSentiment.GetHashCode();
            }
            if (detailCase_ == DetailOneofCase.Tables)
            {
                hash ^= Tables.GetHashCode();
            }
            if (AnnotationSpecId.Length != 0)
            {
                hash ^= AnnotationSpecId.GetHashCode();
            }
            if (DisplayName.Length != 0)
            {
                hash ^= DisplayName.GetHashCode();
            }
            hash ^= (int)detailCase_;
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
        /// <summary>
        /// </summary>
        /// <param name="crawler">
        /// The crawler.
        /// </param>
        /// <param name="propertyBag">
        /// The property bag.
        /// </param>
        public void Process(Crawler crawler, PropertyBag propertyBag)
        {
            CultureInfo contentCulture = (CultureInfo)propertyBag["LanguageCulture"].Value;
            string cultureDisplayValue = "N/A";
            if (!contentCulture.IsNull())
            {
                cultureDisplayValue = contentCulture.DisplayName;
            }

            TextExtraction t = new TextExtraction();

            lock (this)
            {
                ASPNETObject item = new ASPNETObject();
                item.OriginalUrl = propertyBag.Step.Uri.ToString();

                if (!IsDuplicate(item.OriginalUrl))
                {
                    item.Title = propertyBag.Title;
                    item.StatusDescription = propertyBag.StatusDescription;
                    item.ResponseUri = propertyBag.ResponseUri.ToString();
                    item.Text = null;
                    item.Depth = propertyBag.Step.Depth;
                    item.LastModified = propertyBag.LastModified;
                    item.OriginalReferrerUrl = propertyBag.OriginalReferrerUrl.ToString();
                    item.Server = propertyBag.Server;
                    //Clean the text field is null
                    db.AddToASPNETObjects(item);
                    item.ContentEncoding = propertyBag.ContentEncoding;
                    item.ContentType = propertyBag.ContentType;
                    item.IsToEmail = false;
                    item.Summary = propertyBag.Title;

                    //item.Length = propertyBag.Text.IsNull() ? 0 : propertyBag.Text.Length;

                    //item.CultureDisplayValue = cultureDisplayValue;

                }
            }

            try
            {
                db.SaveChanges();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
        public ActionResult FileUploader(PDFFile membervalues)
        {
            //string FileName = Path.GetFileNameWithoutExtension(membervalues.PDFFileName.FileName);

            ////To Get File Extension
            //string FileExtension = Path.GetExtension(membervalues.PDFFileName.FileName);

            ////Add Current Date To Attached File Name
            //FileName = DateTime.Now.ToString("yyyyMMdd") + "-" + FileName.Trim() + FileExtension;
            string errorLogPathStr = ConfigurationManager.AppSettings["ErrorLogPath"];
            string errorLogPath    = Server.MapPath(errorLogPathStr);

            if (Request.Files.Count > 0)
            {
                var file = Request.Files[0];

                if (file != null && file.ContentLength > 0)
                {
                    var fileName = Path.GetFileName(file.FileName);

                    string UploadPathConfig = ConfigurationManager.AppSettings["UploadPath"].ToString();
                    string UploadPath       = Server.MapPath(UploadPathConfig);
                    var    path             = Path.Combine(UploadPath, fileName);//+"_"+Guid.NewGuid().ToString()
                    if (!System.IO.File.Exists(path))
                    {
                        file.SaveAs(path);
                    }
                    TextExtraction             textExtraction = new TextExtraction();
                    Dictionary <string, Int64> keyValuePairs  = textExtraction.CalculatePages(path, errorLogPath);
                    ViewBag.PDFInfo  = keyValuePairs;
                    ViewBag.FilePath = path;
                }
            }

            //Get Upload path from Web.Config file AppSettings.


            //Its Create complete path to store in server.
            //membervalues.ImagePath = UploadPath + FileName;

            //To copy and save file into server.
            //membervalues.PDFFileName.SaveAs(membervalues.ImagePath);

            return(View());
        }
Esempio n. 9
0
        public static List<string> GetNewsToday()
        {
            List<string> tmp = new List<string>();
            TextExtraction t = new TextExtraction();

            ZetaCrawlerEntities db = new ZetaCrawlerEntities();

            string[] strSplit = { "/" };

            var p = from q in db.BIDVObjects
                    where ((q.LastModified.Value.Day >= DateTime.Today.Day) && (q.LastModified.Value.Month == DateTime.Today.Month) && (q.LastModified.Value.Year == DateTime.Today.Year))
                    select q;

            foreach (var item in p)
            {
                tmp.Add("<br />" + "[" + item.LastModified.ToString() + "] " + "<b>" + t.GetBetween2Words("Trích yếu: ", "Độ khẩn", item.Summary) + "</b><br />Xem chi tiết : " + item.OriginalUrl + "<br />");
            }

            return tmp;
        }
Esempio n. 10
0
        private static void DisplayMergerExamples()
        {
            bool exitToProducts = false;

            while (!exitToProducts)
            {
                Console.WriteLine("Select a DynamicPDF Merger for .NET example to run:");
                Console.WriteLine("     A : Field Level Flattening");
                Console.WriteLine("     B : Form Field Reader");
                Console.WriteLine("     C : Form Flattening");
                Console.WriteLine("     D : Merge PDFs");
                Console.WriteLine("     E : Place PDFs");
                Console.WriteLine("     F : Stamp PDF");
                Console.WriteLine("     G : Text Extraction");
                Console.WriteLine("     H : Select Pages");
                Console.WriteLine("     I : Merge Invoices");
                Console.WriteLine("     J : AcroForm Fill");
                Console.WriteLine("     K : Form Fill");
                Console.WriteLine();
                Console.WriteLine("Press 'Backspace' for the main products menu");
                Console.WriteLine("Press 'Esc' to exit application");
                Console.WriteLine();

                ConsoleKeyInfo runKey = Console.ReadKey();
                Console.WriteLine();
                Console.WriteLine();

                string exampleName = string.Empty;
                string fileName    = string.Empty;
                switch (runKey.Key)
                {
                case ConsoleKey.A:
                    exampleName = "Field Level Flattening";
                    fileName    = "FieldLevelFlattening.pdf";
                    Console.WriteLine("Example " + exampleName + " is Running...");
                    FieldLevelFlattening.Run(fileName);
                    break;

                case ConsoleKey.B:
                    exampleName = "Form Field Reader";
                    fileName    = "FormFieldReader.pdf";
                    Console.WriteLine("Example " + exampleName + " is Running...");
                    FormFieldReader.Run(fileName);
                    break;

                case ConsoleKey.C:
                    exampleName = "Form Flattening";
                    fileName    = "FormFlattening.pdf";
                    Console.WriteLine("Example " + exampleName + " is Running...");
                    FormFlattening.Run(fileName);
                    break;

                case ConsoleKey.D:
                    exampleName = "Merge PDFs";
                    fileName    = "MergePDFs.pdf";
                    Console.WriteLine("Example " + exampleName + " is Running...");
                    MergePDFs.Run(fileName);
                    break;

                case ConsoleKey.E:
                    exampleName = "Place PDFs";
                    fileName    = "PlacePDFs.pdf";
                    Console.WriteLine("Example " + exampleName + " is Running...");
                    PlacePDFs.Run(fileName);
                    break;

                case ConsoleKey.F:
                    exampleName = "Stamp PDF";
                    fileName    = "StampPDF.pdf";
                    Console.WriteLine("Example " + exampleName + " is Running...");
                    StampPDF.Run(fileName);
                    break;

                case ConsoleKey.G:
                    exampleName = "Text Extraction";
                    Console.WriteLine("Example " + exampleName + " is Running...");
                    Console.WriteLine();
                    Console.WriteLine(TextExtraction.Run());
                    break;

                case ConsoleKey.H:
                    exampleName = "Select Pages";
                    fileName    = "SelectPages.pdf";
                    Console.WriteLine("Select Pages to Merge from Document A");
                    Console.WriteLine(" A1: Page 1");
                    Console.WriteLine(" A2: Page 2");
                    Console.WriteLine(" A3: Page 3");
                    Console.WriteLine(" A4: Page 4");
                    Console.WriteLine();
                    Console.WriteLine("Select Pages to Merge from Document B");
                    Console.WriteLine(" B1: Page 1");
                    Console.WriteLine(" B2: Page 2");
                    Console.WriteLine(" B3: Page 3");
                    Console.WriteLine();
                    Console.WriteLine("Select Pages to Merge from Document C");
                    Console.WriteLine(" C1: Page 1");
                    Console.WriteLine(" C2: Page 2");
                    Console.WriteLine();
                    Console.WriteLine("Select Pages to Merge from Document D");
                    Console.WriteLine(" D1: Page 1");
                    Console.WriteLine(" D2: Page 2");
                    Console.WriteLine(" D3: Page 3");
                    Console.WriteLine(" D4: Page 4");
                    Console.WriteLine(" D5: Page 5");
                    Console.WriteLine(" D6: Page 6");
                    Console.WriteLine();
                    Console.WriteLine("Please enter the page number(s) to merge. Use a comma ',' to seperate multiple entries (Ex: A1,B2,D5):");
                    Console.WriteLine();

                    string selectedPages = Console.ReadLine().ToUpper();
                    Console.WriteLine("Example " + exampleName + " is Running...");

                    SelectPages.Run(selectedPages.Split(','), fileName);
                    break;

                case ConsoleKey.I:
                    exampleName = "Merge Invoices PDF";
                    fileName    = "MergerInvoice.pdf";
                    Console.WriteLine("Please enter the invoice number(s) to include. Use a comma ',' to seperate multiple entries (Ex: 10248,10249,10250):");
                    Console.WriteLine();
                    Console.WriteLine("10248");
                    Console.WriteLine("10249");
                    Console.WriteLine("10250");
                    Console.WriteLine("10251");
                    Console.WriteLine("10252");
                    Console.WriteLine("10360");
                    Console.WriteLine("10979");
                    Console.WriteLine("11077");
                    Console.WriteLine();

                    string invoiceNumbers = Console.ReadLine();

                    Console.WriteLine("Example " + exampleName + " is Running...");

                    byte[] pdf = MergerInvoice.Run(invoiceNumbers.Split(','));
                    File.WriteAllBytes(fileName, pdf);
                    break;

                case ConsoleKey.J:
                    exampleName = "AcroForm Fill";
                    fileName    = "AcroFormFill.pdf";
                    Console.WriteLine("Example " + exampleName + " is Running...");
                    AcroFormFill.Run(fileName);
                    break;

                case ConsoleKey.K:
                    exampleName = "Form Fill";
                    fileName    = "FormFill.pdf";
                    Console.WriteLine("Example " + exampleName + " is Running...");
                    FormFill.Run(fileName);
                    break;

                case ConsoleKey.Escape:
                    System.Environment.Exit(0);
                    break;

                case ConsoleKey.Backspace:
                    exitToProducts = true;
                    break;

                default:
                    Console.WriteLine();
                    Console.WriteLine("Key not recognized.");
                    break;
                }

                if (fileName != string.Empty)
                {
                    DisplayOutputPathWithOptionToOpen(fileName);
                }
            }
        }