Exemplo n.º 1
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Mp3ZingItem EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToMp3ZingItem(Mp3ZingItem mp3ZingItem)
 {
     base.AddObject("Mp3ZingItem", mp3ZingItem);
 }
Exemplo n.º 2
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)
            {
                Mp3ZingItem item = new Mp3ZingItem();
                item.Url = propertyBag.Step.Uri.ToString();

                if (item.Url.StartsWith("http://mp3.zing.vn/mp3/nghe-bai-hat"))
                {
                    item.Text = propertyBag.Text.IsNull() ? "" : propertyBag.Text;
                    item.Title = propertyBag.Title;
                    item.Length = propertyBag.Text.IsNull() ? 0 : propertyBag.Text.Length;
                    item.ContentType = propertyBag.ContentType;
                    item.ContentEncoding = propertyBag.ContentEncoding;
                    item.Depth = propertyBag.Step.Depth;
                    //item.CultureDisplayValue = cultureDisplayValue;
                    string[] strSplit = {"|"};
                    item.Subject = propertyBag.Title.Split(strSplit, StringSplitOptions.None)[0];

                    db.AddToMp3ZingItem(item);
                }

                //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);
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Create a new Mp3ZingItem object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 public static Mp3ZingItem CreateMp3ZingItem(global::System.Int32 id)
 {
     Mp3ZingItem mp3ZingItem = new Mp3ZingItem();
     mp3ZingItem.Id = id;
     return mp3ZingItem;
 }