Ejemplo n.º 1
0
        public void DbImport(out List <GameDevEssence> gameDevEsList, GameDevEntities db)
        {
            gameDevEsList = new List <GameDevEssence>();
            int k = 0;

            foreach (var obj in db.GameIndustry)
            {
                GameDevEssence gameDevEssence = new GameDevEssence();
                gameDevEssence.GameIndustry = obj;
                gameDevEsList.Add(gameDevEssence);
                k++;
            }

            for (int i = 0; i < k; i++)
            {
                foreach (var obj in db.Games)
                {
                    if (obj.Id == gameDevEsList[i].GameIndustry.GameId)
                    {
                        gameDevEsList[i].Games = obj;
                        break;
                    }
                }

                foreach (var obj in db.Companies)
                {
                    if (obj.Id == gameDevEsList[i].GameIndustry.CompanyId)
                    {
                        gameDevEsList[i].Companies = obj;
                        break;
                    }
                }

                foreach (var obj in db.Publishers)
                {
                    if (obj.Id == gameDevEsList[i].GameIndustry.PublisherId)
                    {
                        gameDevEsList[i].Publishers = obj;
                        break;
                    }
                }

                foreach (var obj in db.Developers)
                {
                    if (obj.Id == gameDevEsList[i].GameIndustry.DeveloperId)
                    {
                        gameDevEsList[i].Developers = obj;
                        break;
                    }
                }
            }
        }
Ejemplo n.º 2
0
 protected override void OnStart(string[] args)
 {
     try
     {
         using (GameDevEntities db = new GameDevEntities())
         {
             List <GameDevEssence> gameDevEsList = new List <GameDevEssence>();
             DatabaseOperations    dataAccess    = new DatabaseOperations();
             dataAccess.DbImport(out gameDevEsList, db);
             List <string>   data            = dataAccess.DbConvert(gameDevEsList);
             XmlDbSerializer xmlDbSerializer = new XmlDbSerializer();
             xmlDbSerializer.XmlSerialize <List <string> >($"G:/Work/GameIndustryInfo.xml", data);
         }
     }
     catch (Exception ex)
     {
         using (StreamWriter sw = new StreamWriter("errors.txt"))
         {
             sw.WriteLine(ex.Message);
         }
     }
 }