Exemplo n.º 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
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            // Guid g1 = Guid.NewGuid();
            // string key = g1.ToString("N");
            bool show_help = false;

            List <string> extra;
            List <string> siteCodes  = new List <string>();
            List <string> Logfiles   = new List <string>();
            List <string> startDates = new List <string>();
            List <string> endDates   = new List <string>();
            var           p          = new OptionSet()
            {
                { "c|sitecode=", " (required) the source Site Code.", v => siteCodes.Add(v) },
                { "s|start=", " (required) the start Date.", v => startDates.Add(v) },
                { "e|end=", " (required) the End Date.", v => endDates.Add(v) },
                { "l|log=", " (required) log filename.", v => Logfiles.Add(v) },
                { "h|help", " Show this message and exit", v => show_help = v != null },
            };

            try
            {
                extra = p.Parse(args);
            }
            catch (OptionException e)
            {
                Console.Write("migration: ");
                Console.WriteLine(e.Message);
                Console.WriteLine("Try migration --help for more information.");
                return;
            }

            if (show_help)
            {
                ShowHelp(p);
                Console.ReadLine();
                return;
            }

            bool valid = true;

            if (!CheckArgument(siteCodes, "sitecode"))
            {
                valid = false;
            }
            if (!CheckArgument(Logfiles, "Log"))
            {
                valid = false;
            }
            if (!CheckArgument(startDates, "start"))
            {
                valid = false;
            }
            if (!CheckArgument(endDates, "end"))
            {
                valid = false;
            }
            if (!valid)
            {
                wait();
                return;
            }



            site_uid = siteCodes[0];
            DateTime startdate = DateTime.ParseExact(startDates[0], "MM/dd/yyyy", System.Globalization.CultureInfo.InvariantCulture);
            DateTime stopDate  = DateTime.ParseExact(endDates[0], "MM/dd/yyyy", System.Globalization.CultureInfo.InvariantCulture);

            LogFileName = Logfiles[0];
            db2DataSet.MyDataSetTableAdapters.CONTENT_ITEMTableAdapter ContentItemTableAdapter = new db2DataSet.MyDataSetTableAdapters.CONTENT_ITEMTableAdapter();
            db2DataSet.MyDataSet.CONTENT_ITEMDataTable ContentItemDataTable = new db2DataSet.MyDataSet.CONTENT_ITEMDataTable();
            Console.WriteLine("site_uid: {0} startdate: {1} stopdate: {2}", site_uid, startdate, stopDate);
            ContentItemTableAdapter.FillBy(ContentItemDataTable, site_uid, (int)asset.article, startdate, stopDate); // Get Articles
            Console.WriteLine("Total Articles: {0} ", ContentItemDataTable.Rows.Count);
            LoadArticles(ContentItemDataTable);
            Console.WriteLine(string.Format("Finished Failed: {0} ", failedArticles));
            Console.Read();
        }