示例#1
0
        public DataSet TableNavigate(string aSchema, string aName)
        {
            DataTable dtType = new dsNewsReader().Tables["ListType"];
            DataRow   drType = dtType.NewRow();

            drType["schema"] = aSchema;
            drType["table"]  = aName;
            drType["type"]   = "List";

            DataSet dstables = catalog.TableNavigate(aSchema, aName);

            if (dstables.Tables[0].Rows.Count != 0)
            {
                DataSet dstableData = null;
                if (dstables.Tables[0].Rows[0]["NAVIGATE"].ToString() != "")
                {
                    dtType.Rows.Add(drType);
                    dstables.Tables.Add(dtType.Copy());
                }
                else
                {
                    drType["type"] = "Data";
                    drType["pk"]   = dstables.Tables[0].Rows[0]["pk"].ToString();
                    dtType.Rows.Add(drType);
                    dstableData = catalog.TableSelectData(aSchema, aName, "", "");
                    dstableData.Tables.Add(dtType.Copy());
                    return(dstableData);
                }
            }


            return(dstables);
        }
示例#2
0
    public void saveLog(string msj)
    {
        DataRow drLog = new dsNewsReader().Tables["NewsLog"].NewRow();

        drLog["IdNewsPaper"] = IdNewsPaper;
        drLog["IdChannel"]   = IdChannel;
        drLog["Description"] = msj;
        pNew.newsLog_Insert(drLog);
    }
示例#3
0
    public override int getRss(HttpResponse res)
    {
        XmlNodeList authorsList     = RSSXml.GetElementsByTagName(nodeName);
        XDocument   xmlDoc          = RSSXml.ToXDocument();
        DateTime?   maxdate         = pNew.getMaxPublishedDate(IdNewsPaper, IdChannel);
        int         lanacionCounter = 0;

        foreach (XmlNode RSSNode in authorsList)
        {
            /*
             * string title = RSSNode["title"].InnerText.ToString();
             * string link = RSSNode["link"].InnerText.ToString();
             *
             * string content = RSSNode["content"].InnerText;
             */
            DateTime updated   = Convert.ToDateTime(RSSNode["updated"].InnerText.ToString());
            XmlNode  nAuthor   = RSSNode["author"];
            string   strAuthor = nAuthor["name"].InnerText.ToString() + ";" +
                                 nAuthor["uri"].InnerText.ToString() + ";" +
                                 nAuthor["email"].InnerText.ToString();

            DataRow drNew = new dsNewsReader().Tables["News"].NewRow();
            drNew["IdNewsPaper"] = IdNewsPaper;
            drNew["IdChannel"]   = IdChannel;
            drNew["Title"]       = RSSNode["title"].InnerText.ToString();
            drNew["Description"] = RSSNode["content"].InnerText;
            drNew["PublishDate"] = updated;
            drNew["Link"]        = RSSNode["link"].Attributes["href"].Value;
            drNew["Author"]      = strAuthor;

            if (maxdate == null || updated > maxdate)
            {
                lanacionCounter++;
                pNew.newsInsert(drNew);
            }
        }
        return(lanacionCounter);
    }
示例#4
0
    public override int getRss(HttpResponse res)
    {
        var      items   = xEle.Descendants(nodeName);
        string   error   = "";
        int      counter = 0;
        DateTime?maxdate;
        int      cantTitle = 0;

        maxdate = null;
        foreach (var item in items)
        {
            DateTime pData = DateTime.Now;

            try
            {
                pData = Convert.ToDateTime(item.Element("pubDate").Value);
            }
            catch (Exception ex) {
                pData = new ParseDateTime(item.Element("pubDate").Value).getDateTime();
            }


            DataRow drNew = new dsNewsReader().Tables["News"].NewRow();

            Uri    myUri      = new Uri(item.Element("guid").Value);
            string host       = myUri.Host;
            string strChannel = myUri.Segments[1].Replace("/", "");

            if (strChannel == "economia")
            {
                var c = "econo";
            }
            if (strChannel == "deportes-2")
            {
                var c = "DEPOR";
                strChannel = "Deportes";
            }



            if ((strChannel == "Política" || strChannel == "politica" || strChannel == "Economía" || strChannel == "economia" ||
                 strChannel == "Deportes" || strChannel == "El Mundo" || strChannel == "Sociedad" || strChannel == "Policiales" ||
                 strChannel == "noticias"))
            {
                int vChannel = 0;
                // int cantTitle=0;
                DataTable dtChannel = pNew.News_GetChannelIdPorDescripcion(strChannel).Tables[0];



                try{
                    vChannel = (int)dtChannel.Rows[0]["IdChannel"];
                    var vTitle = replaceCDATA(item.Element("title").Value);
                    maxdate   = pNew.getMaxPublishedDate(IdNewsPaper, vChannel);
                    cantTitle = pNew.countByTitle(IdNewsPaper, vChannel, vTitle);

                    drNew["IdNewsPaper"] = IdNewsPaper;
                    drNew["IdChannel"]   = vChannel;
                    drNew["Title"]       = vTitle;
                    drNew["Link"]        = item.Element("guid").Value;
                    drNew["Description"] = RemoveHTML(replaceCDATA(item.Element("description").ToString()));
                    drNew["PublishDate"] = pData;
                    drNew["Author"]      = "";
                }
                catch (Exception ex)
                {
                    // throw ex;
                    error = error + strChannel + ex.Message.ToString();
                }

                if (maxdate == null || pData > maxdate || cantTitle == 0)
                {
                    counter++;
                    pNew.newsInsert(drNew);
                }
            }
        }

        if (error != "")
        {
            throw new Exception(error);
        }
        return(counter);
    }
示例#5
0
    public override int getRss(HttpResponse res)
    {
        IEnumerable <XElement> items;
        DateTime?maxdate;
        int      clarinCounter = 0;

        try
        {
            items = xEle.Descendants(nodeName);
        }
        catch (Exception ex)
        {
            throw new Exception("<h4> xEle.Descendants(nodeName)" + ex.ToString() + " - " + this.url + "</h4>");
        }


        try
        {
            maxdate = pNew.getMaxPublishedDate(IdNewsPaper, IdChannel);
        }
        catch (Exception ex)
        {
            throw new Exception("<h3> getMaxPublishedDate(IdNewsPaper=" + IdNewsPaper.ToString() + ", IdChannel=" + IdChannel.ToString() + " --- " + ex.ToString() + "</h3>");
        }


        foreach (var item in items)
        {
            string itemDescription = HttpUtility.HtmlDecode(item.Element("description").ToString());
            var    iDescription    = new HtmlDocument();
            iDescription.LoadHtml(itemDescription);
            DateTime pData = DateTime.Now;

            try{
                pData = Convert.ToDateTime(item.Element("pubDate").Value);
            }catch (Exception ex) {
                pData = new ParseDateTime(item.Element("pubDate").Value).getDateTime();
            }

            iDescription.DocumentNode.Descendants()
            .Where(n => n.Name == "img" || n.Name == "br" || n.Name == "a")
            .ToList()
            .ForEach(n => n.Remove());

            DataRow drNew = new dsNewsReader().Tables["News"].NewRow();

            try{
                // res.Write("<p style=margin:0;padding:0;>" + item.Element("guid").Value + "</p>");
                drNew["IdNewsPaper"] = IdNewsPaper;
                drNew["IdChannel"]   = IdChannel;
                drNew["Title"]       = item.Element("title").Value;
                drNew["Description"] = iDescription.DocumentNode.InnerText.Replace("<![CDATA[", "").Replace("]]>", "");
                drNew["PublishDate"] = pData;
                drNew["Link"]        = item.Element("guid").Value;
                drNew["Author"]      = "";
            }catch (Exception ex) {
                throw new Exception("<h4> drNew: " + " --- " + ex.ToString() + "</h3>");
            }


            //if (item.Element("enclosure") != null && item.Element("enclosure").HasAttributes){
            //    item.Element("enclosure").Attribute("url").Value;
            //}


            try
            {
                if (maxdate == null || pData > maxdate)
                {
                    clarinCounter++;
                    pNew.newsInsert(drNew);
                }
            }
            catch (Exception ex)
            {
                throw new Exception("<h3> pNew.newsInsert(drNew);" + ex.ToString() + "</h3>");
            }
        }
        return(clarinCounter);
    }