Example #1
0
        static int ProcessImageRow(db2DataSet.MyDataSet.CONTENT_ITEMRow ContentItemRow)
        {
            int    imagecount  = 0;
            string errmsg      = "";
            string article_uid = ContentItemRow.CONTENT_ITEM_UID;

            db2DataSet.MyDataSet.RELATED_CONTENTDataTable RelatedContentItemDataTable = new db2DataSet.MyDataSet.RELATED_CONTENTDataTable();
            RelatedContentTableAdapter.FillBy(RelatedContentItemDataTable, article_uid);  // Get Related Content table for this article
            if (RelatedContentItemDataTable.Rows.Count > 0)
            {
                foreach (db2DataSet.MyDataSet.RELATED_CONTENTRow RelatedContentRow in RelatedContentItemDataTable)
                {
                    try
                    {
                        db2DataSet.MyDataSetTableAdapters.CONTENT_ITEMTableAdapter Local_ContentItemTableAdapter = new db2DataSet.MyDataSetTableAdapters.CONTENT_ITEMTableAdapter();
                        db2DataSet.MyDataSet.CONTENT_ITEMDataTable ContentItemDataTable = new db2DataSet.MyDataSet.CONTENT_ITEMDataTable();
                        Local_ContentItemTableAdapter.FillByUID(ContentItemDataTable, RelatedContentRow.RELATED_CONTENT_ITEM_UID); // Content_item of related content
                        if (ContentItemDataTable.Rows.Count == 1 && ((db2DataSet.MyDataSet.CONTENT_ITEMRow)(ContentItemDataTable.Rows[0])).CONTENT_TYPE_UID == (int)asset.image)
                        {
                            string position  = Convert.IsDBNull(RelatedContentRow["POSITION_UCODE"]) ? "" : RelatedContentRow.POSITION_UCODE;
                            string asset_uid = ((db2DataSet.MyDataSet.CONTENT_ITEMRow)(ContentItemDataTable.Rows[0])).CONTENT_ITEM_UID;
                            db2DataSet.MyDataSet.IMAGEDataTable ImageDataTable = new db2DataSet.MyDataSet.IMAGEDataTable();
                            ImageTableAdapter.FillBy(ImageDataTable, asset_uid);
                            if (ImageDataTable.Count() == 1)
                            {
                                db2DataSet.MyDataSet.IMAGERow ImageRow = (db2DataSet.MyDataSet.IMAGERow)ImageDataTable.Rows[0];
                                string caption    = Convert.IsDBNull(ImageRow["CAPTION"]) ? "" : ImageRow.CAPTION;
                                string media_type = Convert.IsDBNull(ImageRow["MEDIA_SIZE_TYPE_UCODE"]) ? "" : ImageRow.MEDIA_SIZE_TYPE_UCODE;
                                int    filesize   = 0;
                                byte[] data       = getFile(new Uri(ImageRow.IMAGE_URL), ref errmsg);
                                if (errmsg.Length == 0)
                                {
                                    filesize = data.Length;
                                }
                                DataDb.spExecute("LoadImage", ref errmsg, "@article_uid", article_uid, "@asset_uid", asset_uid, "@imagepath", ImageRow.IMAGE_URL, "@position", position, "@width", ImageRow.WIDTH, "@height", ImageRow.HEIGHT, "@caption", caption, "@filesize", filesize, "@media_type", media_type);
                                if (errmsg.Length > 0)
                                {
                                    writetolog(string.Format("Article id: {0} LoadImageTable {1} ", article_uid, errmsg));
                                }
                                else
                                {
                                    imagecount += 1;
                                }
                            } // ImageDataTable == 1
                        }
                    }
                    catch (Exception e)
                    {
                        writeExceptionLog(e.Message, e.StackTrace);
                    }
                } // foreach
            }
            return(imagecount);
        } // ProcessImageRow
Example #2
0
        static string GetOrigSite(string article_uid, string contentitemUid)
        {
            string origSiteUid = "";

            db2DataSet.MyDataSet.CONTENT_ITEMDataTable ContentItemDataTable = new db2DataSet.MyDataSet.CONTENT_ITEMDataTable();
            ContentItemTableAdapter.FillByUID(ContentItemDataTable, contentitemUid);
            if (ContentItemDataTable.Rows.Count == 1)
            {
                db2DataSet.MyDataSet.CONTENT_ITEMRow ContentItemRow = (db2DataSet.MyDataSet.CONTENT_ITEMRow)ContentItemDataTable.Rows[0];
                origSiteUid = ContentItemRow.SITE_UID;
            }
            else
            {
                string msg = string.Format("Error GetOrigSite article: {0} contentid: {1} contentitem table returned {2} rows ", article_uid, contentitemUid, ContentItemDataTable.Rows.Count);
                writetolog(msg);
            }
            return(origSiteUid);
        }
Example #3
0
        } // ProcessImageRow

        static void ProcessArticleRow(db2DataSet.MyDataSet.CONTENT_ITEMRow ContentItemRow, int imagecount, int articleCount)
        {
            string origsite = "", errmsg = "";

            string   article_uid = ContentItemRow.CONTENT_ITEM_UID;
            DateTime StartDate   = Convert.IsDBNull(ContentItemRow["START_DATE"]) ? DateTime.Now : ContentItemRow.START_DATE;

            gStartDate = StartDate;
            DateTime EndDate        = Convert.IsDBNull(ContentItemRow["END_DATE"]) ? DateTime.Now.AddYears(100) : ContentItemRow.END_DATE;
            string   keyword        = Convert.IsDBNull(ContentItemRow["KEYWORD"]) ? "" : ContentItemRow.KEYWORD;
            string   seodescription = scrub(Convert.IsDBNull(ContentItemRow["SEO_DESCRIPTIVE_TEXT"]) ? "" : ContentItemRow.SEO_DESCRIPTIVE_TEXT);
            string   heading        = scrub(Convert.IsDBNull(ContentItemRow["CONTENT_TITLE"]) ? "" : ContentItemRow.CONTENT_TITLE);
            string   category       = GetArticleCategory(article_uid);

            String[] RelatedArticlesUID = GetRelatedArticles(ContentItemRow.CONTENT_ITEM_UID);

            StringBuilder relatedArticles = new StringBuilder();

            if (RelatedArticlesUID.Count() > 0)
            {
                foreach (string relatedArticleUID in RelatedArticlesUID)
                {
                    relatedArticles.Append(string.Format("{0},", relatedArticleUID));
                }
            }
            string sRelatedArticles = relatedArticles.ToString();

            if (sRelatedArticles.EndsWith(","))
            {
                sRelatedArticles = sRelatedArticles.Substring(0, sRelatedArticles.Length - 1);
            }

            string SectionAnchorUID = Convert.IsDBNull(ContentItemRow["SECTION_ANCHOR_UID"]) ? "0" : ContentItemRow.SECTION_ANCHOR_UID;
            // if (SectionAnchorUID.Length > 0)
            //    SectionAnchor = GetSectionItem(article_uid, SectionAnchorUID);
            string origContentItemUid = Convert.IsDBNull(ContentItemRow["ORIG_CONTENT_ITEM_UID"]) ? "" : ContentItemRow.ORIG_CONTENT_ITEM_UID;

            if (origContentItemUid.Length > 0)
            {
                origsite = GetOrigSite(article_uid, origContentItemUid);  // shared content save original Site UID
            }
            db2DataSet.MyDataSet.ARTICLEDataTable ArticleDataTable = new db2DataSet.MyDataSet.ARTICLEDataTable();
            ArticleTableAdapter.FillBy2(ArticleDataTable, article_uid); // article table
            if (ArticleDataTable.Rows.Count != 1)
            {
                writetolog(string.Format("Content id: {0} rows returned: {1}", ContentItemRow.CONTENT_ITEM_UID, ArticleDataTable.Rows.Count));
                return;
            }
            db2DataSet.MyDataSet.ARTICLERow ArticleRow = (db2DataSet.MyDataSet.ARTICLERow)ArticleDataTable.Rows[0];
            string summary = scrub(Convert.IsDBNull(ArticleRow["ABSTRACT"]) ? "" : ArticleRow.ABSTRACT);
            // Note saxotech can not handle abstartion field greater then 100
            string byline   = scrub(Convert.IsDBNull(ArticleRow["BYLINE"]) ? "" : ArticleRow.BYLINE);
            string body     = scrub(Convert.IsDBNull(ArticleRow["BODY"]) ? "" : ArticleRow.BODY);
            string subtitle = scrub(Convert.IsDBNull(ArticleRow["SUBTITLE"]) ? "" : ArticleRow.SUBTITLE);

            // Save the following to the Database ...
            //  @siteid @siteid @article_uid  @category  @anchor @startdate @enddate @heading @body @byline @subtitle @summary @RelatedArticles @seodescription @keyword
            DataDb.spExecute("LoadArticle", ref errmsg, "@siteid", site_uid, "@article_uid", article_uid, "@category", category, "@anchor", SectionAnchorUID, "@startdate", StartDate, "@enddate", EndDate, "@heading", heading, "@body", body, "@byline", byline, "@subtitle", subtitle, "@summary", summary, "@RelatedArticles", sRelatedArticles, "@seodescription", seodescription, "@keyword", keyword, "@imagecount", imagecount, "@origsite", origsite);
            if (errmsg.Length > 0)
            {
                writetolog(string.Format("Failed Article id: {0} LoadArticle {1} ", article_uid, errmsg));
                failedArticles += 1;
            }
            // else
            //    Console.WriteLine(string.Format("Processed: {0} Article {1} Images: {2}", articleCount, article_uid, imagecount));
        }