示例#1
0
        public static void Convert(List <AdvertisingOldV2> adsOldV2, ITVTDatabase database, TVTDataRoot dataRoot)
        {
            foreach (var adSrc in adsOldV2)
            {
                var ad = new TVTAdvertising();
                ad.DataRoot = dataRoot;

                ConvertCommonMinimal(adSrc, ad, database);
                ad.DescriptionDE = adSrc.description;
                ad.DescriptionEN = adSrc.descriptionEnglish;

                ad.CreatorId    = adSrc.creatorID;
                ad.EditorId     = adSrc.editorID;
                ad.LastModified = new DateTime(2004, 1, 1);

                ad.FixPrice    = (adSrc.fixedProfit > 0);
                ad.MinAudience = ConvertOldToNewValueFloat(adSrc.minAudience);
                ad.MinImage    = ConvertOldToNewValue(adSrc.minImage);
                ad.Repetitions = adSrc.repetitions;
                ad.Duration    = adSrc.duration;
                ad.Profit      = ConvertProfitPenalty(adSrc.profit, adSrc.fixedProfit > 0, adSrc.fixedProfit);
                ad.Penalty     = ConvertProfitPenalty(adSrc.penalty, adSrc.fixedPenalty > 0, adSrc.fixedPenalty);

                ad.TargetGroup = ConvertTargetGroup(adSrc.targetgroup);

                ad.Approved = adSrc.approved;

                database.AddAdvertising(ad);
            }
        }
示例#2
0
        public void AssertAdvertisings(TVTAdvertising ad1, TVTAdvertising ad2, TestMode testMode)
        {
            AssertEntity(ad1, ad2, testMode);

            Assert.AreEqual(ad1.TitleDE, ad2.TitleDE);
            Assert.AreEqual(ad1.TitleEN, ad2.TitleEN);
            Assert.AreEqual(ad1.DescriptionDE, ad2.DescriptionDE);
            Assert.AreEqual(ad1.DescriptionEN, ad2.DescriptionEN);
            Assert.AreEqual(ad1.Quality, ad2.Quality);
            Assert.AreEqual(ad1.FixPrice, ad2.FixPrice);
            Assert.AreEqual(ad1.MinAudience, ad2.MinAudience);
            Assert.AreEqual(ad1.MinImage, ad2.MinImage);
            Assert.AreEqual(ad1.Repetitions, ad2.Repetitions);
            Assert.AreEqual(ad1.Duration, ad2.Duration);
            Assert.AreEqual(ad1.Profit, ad2.Profit);
            Assert.AreEqual(ad1.Penalty, ad2.Penalty);
            Assert.AreEqual(ad1.ValidFrom, ad2.ValidFrom);
            Assert.AreEqual(ad1.ValidTill, ad2.ValidTill);
            Assert.AreEqual(ad1.TargetGroup, ad2.TargetGroup);
            AssertExt.AreCollectionEqual(ad1.AllowedGenres, ad2.AllowedGenres);
            AssertExt.AreCollectionEqual(ad1.ProhibitedGenres, ad2.ProhibitedGenres);
            AssertExt.AreCollectionEqual(ad1.AllowedProgrammeTypes, ad2.AllowedProgrammeTypes);
            AssertExt.AreCollectionEqual(ad1.ProhibitedProgrammeTypes, ad2.ProhibitedProgrammeTypes);
            AssertExt.AreCollectionEqual(ad1.ProPressureGroups, ad2.ProPressureGroups);
            AssertExt.AreCollectionEqual(ad1.ContraPressureGroups, ad2.ContraPressureGroups);
        }
示例#3
0
        public static TVTAdvertising GetIconicAdvertising()
        {
            var advertising = new TVTAdvertising();

            advertising.GenerateGuid();
            advertising.OldId        = "110";
            advertising.DataType     = TVTDataType.Undefined;
            advertising.DataStatus   = TVTDataStatus.Approved;
            advertising.DataRoot     = TVTDataRoot.MadTV;
            advertising.DataUsage    = TVTDataUsage.MadTVOriginal;
            advertising.Approved     = true;
            advertising.CreatorId    = "creatorX";
            advertising.EditorId     = "editorY";
            advertising.LastModified = DateTime.Now.AddDays(-1);
            advertising.IsNew        = true;
            advertising.IsChanged    = true;

            advertising.TitleDE       = "ValueA";
            advertising.TitleEN       = "ValueB";
            advertising.DescriptionDE = "ValueC";
            advertising.DescriptionEN = "ValueD";
            advertising.Quality       = 50;
            advertising.FixPrice      = true;
            advertising.MinAudience   = (float)0.55;
            advertising.MinImage      = 51;
            advertising.Repetitions   = 2;
            advertising.Duration      = 3;
            advertising.Profit        = 110;
            advertising.Penalty       = 120;
            advertising.ValidFrom     = 1990;
            advertising.ValidTill     = 1995;
            advertising.TargetGroup   = TVTTargetGroup.Manager;
            advertising.AllowedGenres = new List <TVTProgrammeGenre>();
            advertising.AllowedGenres.Add(TVTProgrammeGenre.Comedy);
            advertising.AllowedGenres.Add(TVTProgrammeGenre.Drama);
            advertising.ProhibitedGenres = new List <TVTProgrammeGenre>();
            advertising.ProhibitedGenres.Add(TVTProgrammeGenre.Erotic);
            advertising.ProhibitedGenres.Add(TVTProgrammeGenre.Family);
            advertising.AllowedProgrammeTypes = new List <TVTProgrammeType>();
            advertising.AllowedProgrammeTypes.Add(TVTProgrammeType.Event);
            advertising.AllowedProgrammeTypes.Add(TVTProgrammeType.Commercial);
            advertising.ProhibitedProgrammeTypes = new List <TVTProgrammeType>();
            advertising.ProhibitedProgrammeTypes.Add(TVTProgrammeType.Movie);
            advertising.ProhibitedProgrammeTypes.Add(TVTProgrammeType.Reportage);

            advertising.ProPressureGroups = new List <TVTPressureGroup>();
            advertising.ProPressureGroups.Add(TVTPressureGroup.AntiSmoker);
            advertising.ProPressureGroups.Add(TVTPressureGroup.ArmsLobby);
            advertising.ContraPressureGroups = new List <TVTPressureGroup>();
            advertising.ContraPressureGroups.Add(TVTPressureGroup.Capitalists);
            advertising.ContraPressureGroups.Add(TVTPressureGroup.Communists);

            return(advertising);
        }
        public TVTAdvertising FindAdMatchWithV2(TVTAdvertising other)
        {
            var allAds = LeadingDatabase.GetAllAdvertisings();

            var results1 = allAds.Where(x => x.TitleDE == other.TitleDE);

            if (results1.Count() == 1)
            {
                return(results1.First());
            }
            else
            {
                var results2 = allAds.Where(new Func <TVTAdvertising, bool>(x =>
                {
                    //if ( x.Genre == other.Genre && x.Topicality == other.Topicality && x.NewsType == other.NewsType && x.Price == other.Price )
                    //{
                    //    if ( x.NewsType == TVTNewsType.FollowingNews && !string.IsNullOrEmpty( x.NewsThreadId ) && !string.IsNullOrEmpty( other.NewsThreadId ) )
                    //    {
                    //        if ( x.NewsThreadInitial != null && other.NewsThreadInitial != null )
                    //        {
                    //            if ( x.NewsThreadInitial.TitleDE == other.NewsThreadInitial.TitleDE )
                    //                return true;
                    //        }
                    //        else
                    //            return true;
                    //    }
                    //    else
                    //        return true;
                    //}

                    return(false);
                }));

                if (results2.Count() == 0)
                {
                    System.Diagnostics.Trace.WriteLine("Not found: " + other.TitleDE);
                }
                else if (results2.Count() == 1)
                {
                    return(results2.First());
                }
                else
                {
                    System.Diagnostics.Trace.WriteLine("Found more then one: " + other.TitleDE);
                }
            }

            return(null);
        }
示例#5
0
        public void SaveAdvertising(TVTAdvertising advertising)
        {
            using (var connection = GetConnection())
            {
                if (advertising.IsNew)
                {
                    TVTCommandsV3.Insert <TVTAdvertising>(connection, TVTCommandsV3.GetAdvertisingSQLDefinition(), new List <TVTAdvertising>()
                    {
                        advertising
                    });
                }
                else if (advertising.IsChanged)
                {
                    TVTCommandsV3.Update <TVTAdvertising>(connection, TVTCommandsV3.GetAdvertisingSQLDefinition(), new List <TVTAdvertising>()
                    {
                        advertising
                    });
                }

                advertising.IsNew     = false;
                advertising.IsChanged = false;
            }
        }
 public void AddAdvertising(TVTAdvertising advertising)
 {
     AdvertisingData.Add(advertising);
 }
示例#7
0
        public void B_ReadXMLV2AndMerge()
        {
            System.Diagnostics.Trace.WriteLine(Directory.GetCurrentDirectory());
            Assert.IsTrue(File.Exists("database.xml"));

            var databaseV2 = new TVTDatabase();

            databaseV2.Initialize();

            var persister = new XmlPersisterV2();

            persister.LoadXML("database.xml", databaseV2, TVTDataRoot.V2InUse);

            var sqlDB = new TVTDatabase();

            sqlDB.Initialize();
            sqlDB.Clear();
            using (var connection = TVTSQLSession.GetSessionNewDB())
            {
                string myConnectionString = "SERVER=localhost;" +
                                            "DATABASE=tvtower_new;" +
                                            "UID=TVTowerUser;" +
                                            "PASSWORD=123;";

                var mvSQLDatabase = new TVTSQLDatabase(myConnectionString);
                mvSQLDatabase.FillTVTDatabase(sqlDB);
            }

            var merging = new DatabaseMerging(sqlDB);

            {
                foreach (var currMovie in databaseV2.GetAllProgrammes(true, true))
                {
                    var found = merging.FindProgrammeMatch(currMovie);
                    if (found != null)
                    {
                        merging.MergeProgrammeData(found, currMovie, true);
                        found.DataRoot  = TVTDataRoot.V2InUse;
                        found.IsChanged = true;
                        foreach (var member in found.Staff)
                        {
                            if (member.Person != null)
                            {
                                member.Person.DataRoot  = TVTDataRoot.V2InUse;
                                member.Person.IsChanged = true;
                            }
                        }
                    }
                    else
                    {
                        var newProgramme = new TVTProgramme();
                        newProgramme.GenerateGuid();
                        merging.MergeProgrammeData(newProgramme, currMovie);
                        newProgramme.DataRoot  = TVTDataRoot.V2InUse;
                        newProgramme.IsNew     = true;
                        newProgramme.IsChanged = true;
                        foreach (var member in newProgramme.Staff)
                        {
                            member.Person.DataRoot  = TVTDataRoot.V2InUse;
                            member.Person.IsChanged = true;
                        }
                        sqlDB.AddProgramme(newProgramme);
                    }
                }
            }

            {
                foreach (var currNews in databaseV2.GetAllNews())
                {
                    var found = merging.FindNewsMatchWithV2(currNews);
                    if (found != null)
                    {
                        merging.MergeNewsData(found, currNews, true);
                        found.DataRoot  = TVTDataRoot.V2InUse;
                        found.IsChanged = true;
                    }
                    else
                    {
                        var newNews = new TVTNews();
                        newNews.GenerateGuid();
                        merging.CopyPropertyValues <TVTNews>(newNews, currNews);
                        newNews.DataRoot  = TVTDataRoot.V2InUse;
                        newNews.IsNew     = true;
                        newNews.IsChanged = true;
                        sqlDB.AddNews(newNews);
                    }
                }
            }

            {
                foreach (var currAd in databaseV2.GetAllAdvertisings())
                {
                    var found = merging.FindAdMatchWithV2(currAd);
                    if (found != null)
                    {
                        merging.CopyPropertyValues <TVTAdvertising>(found, currAd);
                        found.DataRoot  = TVTDataRoot.V2InUse;
                        found.IsChanged = true;
                    }
                    else
                    {
                        var newAd = new TVTAdvertising();
                        newAd.GenerateGuid();
                        merging.CopyPropertyValues <TVTAdvertising>(newAd, currAd);
                        newAd.DataRoot  = TVTDataRoot.V2InUse;
                        newAd.IsNew     = true;
                        newAd.IsChanged = true;
                        sqlDB.AddAdvertising(newAd);
                    }
                }
            }

            using (var connection = TVTSQLSession.GetSessionNewDB())
            {
                string myConnectionString = "SERVER=localhost;" +
                                            "DATABASE=tvtower_new;" +
                                            "UID=TVTowerUser;" +
                                            "PASSWORD=123;";

                var mvSQLDatabase = new TVTSQLDatabase(myConnectionString);
                mvSQLDatabase.WriteChangesToDatabase(sqlDB);
            }
        }
示例#8
0
        public void C_ReadXMLV2AndMergeAdChanges()
        {
            System.Diagnostics.Trace.WriteLine(Directory.GetCurrentDirectory());
            Assert.IsTrue(File.Exists("ads-changes.xml"));

            var databaseV3 = new TVTDatabase();

            databaseV3.Initialize();

            var persister = new XmlPersisterV3();

            persister.LoadXMLV3Beta("ads-changes.xml", databaseV3);

            var sqlDB = new TVTDatabase();

            sqlDB.Initialize();
            sqlDB.Clear();
            using (var connection = TVTSQLSession.GetSessionNewDB())
            {
                string myConnectionString = "SERVER=localhost;" +
                                            "DATABASE=tvtower_new;" +
                                            "UID=TVTowerUser;" +
                                            "PASSWORD=123;";

                var mvSQLDatabase = new TVTSQLDatabase(myConnectionString);
                mvSQLDatabase.FillTVTDatabase(sqlDB);
            }

            var merging = new DatabaseMerging(sqlDB);

            {
                foreach (var currAd in databaseV3.GetAllAdvertisings())
                {
                    var found = merging.FindAdMatchWithV2(currAd);
                    if (found != null)
                    {
                        merging.CopyPropertyValues <TVTAdvertising>(found, currAd);
                        found.DataRoot  = TVTDataRoot.V2InUse;
                        found.IsChanged = true;
                    }
                    else
                    {
                        var newAd = new TVTAdvertising();
                        newAd.GenerateGuid();
                        merging.CopyPropertyValues <TVTAdvertising>(newAd, currAd);
                        newAd.DataRoot  = TVTDataRoot.V2InUse;
                        newAd.IsNew     = true;
                        newAd.IsChanged = true;
                        sqlDB.AddAdvertising(newAd);
                    }
                }
            }

            using (var connection = TVTSQLSession.GetSessionNewDB())
            {
                string myConnectionString = "SERVER=localhost;" +
                                            "DATABASE=tvtower_new;" +
                                            "UID=TVTowerUser;" +
                                            "PASSWORD=123;";

                var mvSQLDatabase = new TVTSQLDatabase(myConnectionString);
                mvSQLDatabase.WriteChangesToDatabase(sqlDB);
            }
        }