Esempio n. 1
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);
        }
Esempio n. 2
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);
            }
        }
Esempio n. 3
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);
            }
        }