Exemplo n.º 1
0
        public static void Run(string[] id)
        {
            MongoCRUD db            = new MongoCRUD("SportService_Database");
            channel   catalog1      = default;
            int       number_of_rss = 8;

            for (int i = 0; i < number_of_rss; i++)
            {
                string path = AppDomain.CurrentDomain.BaseDirectory + "\\Updates\\Update__done_" + id[i] + ".xml";

                string xml = File.ReadAllText(path);

                catalog1 = xml.ParseXML <channel>();
                for (int j = 0; j < 50; j++)
                {
                    catalog1.item[j].link = ContentDownloader.DownloadContent(catalog1.item[j].link);
                }
                //     DeserializationTest(catalog1);


                var  a = db.LoadRecord <ChanelMongoDatabesPatern>("channels");
                bool IsRepeatability = false;
                foreach (var item in a)
                {
                    if (item.title == catalog1.title)
                    {
                        IsRepeatability = true;
                    }
                }

                if (IsRepeatability)
                {
                    db.UpsertRecord("channels", catalog1.title, catalog1);
                }
                else
                {
                    db.InsertRecord("channels", catalog1);
                }
            }
        }