Esempio n. 1
0
 internal bool ShouldExtract(O8cEntry o8centry)
 {
     try
     {
         Log.InfoFormat("Checking if should extract {0}", o8centry.cardImage);
         bool ret = false;
         Log.InfoFormat("Grabbing game {0},{1}", o8centry.gameGuid, o8centry.cardImage);
         var game = GetById(Guid.Parse(o8centry.gameGuid));
         if (game != null)
         {
             Log.InfoFormat("Game exists {0},{1}", o8centry.gameGuid, o8centry.cardImage);
             Guid cardGuid = Guid.Parse(o8centry.cardImage.Split('.')[0]);
             Log.InfoFormat("Checking Paths {0},{1},{2}", o8centry.setsDir, o8centry.cardsDir, o8centry.cardImage);
             if (o8centry.setsDir == "Sets" && o8centry.cardsDir == "Cards")
             {
                 Log.InfoFormat("Paths good {0},{1},{2}", o8centry.setsDir, o8centry.cardsDir, o8centry.cardImage);
                 ret = true;
             }
         }
         else
         {
             Log.InfoFormat("Couldn't find game {0},{1}", o8centry.gameGuid, o8centry.cardImage);
         }
         Log.InfoFormat("Finishing {0}", o8centry.cardImage);
         return(ret);
     }
     finally
     {
         Log.InfoFormat("Finished {0}", o8centry.cardImage);
     }
 }
Esempio n. 2
0
 internal bool extract(ZipEntry entry, out Guid gameGuid, Guid testGuid)
 {
     try
     {
         Log.InfoFormat("Extracting {0},{1}", entry.FileName, testGuid);
         bool ret = false;
         gameGuid = testGuid;
         string[] split = entry.FileName.Split('/');
         Log.InfoFormat("Split file name {0},{1}", entry.FileName, testGuid);
         if (split.Length == 5)
         {
             Log.InfoFormat("File name right count {0},{1}", entry.FileName, testGuid);
             O8cEntry o8cEntry = new O8cEntry()
             {
                 gameGuid  = split[0],
                 setsDir   = split[1],
                 setGuid   = split[2],
                 cardsDir  = split[3],
                 cardImage = split[4]
             };
             Log.InfoFormat("Checking if testGuid is empty {0},{1}", entry.FileName, testGuid);
             if (testGuid.Equals(Guid.Empty))
             {
                 Log.InfoFormat("testGuid is empty {0},{1}", entry.FileName, testGuid);
                 testGuid = Guid.Parse(o8cEntry.gameGuid);
                 gameGuid = Guid.Parse(o8cEntry.gameGuid);
                 Log.InfoFormat("Setting gameguid and testguid {0},{1},{2}", entry.FileName, testGuid, gameGuid);
             }
             Log.InfoFormat("Checking if {0}=={1} {2}", testGuid, o8cEntry.gameGuid, entry.FileName);
             if (!testGuid.Equals(Guid.Parse(o8cEntry.gameGuid)))
             {
                 Log.InfoFormat("{0}!={1} {2}", testGuid, o8cEntry.gameGuid, entry.FileName);
                 return(ret);
             }
             Log.InfoFormat("Checking if should extract part {0},{1}", entry.FileName, testGuid);
             if (ShouldExtract(o8cEntry))
             {
                 Log.InfoFormat(
                     "Should extract, so extracting {0},{1},{2}",
                     Paths.Get().ImageDatabasePath,
                     entry.FileName,
                     testGuid);
                 entry.Extract(Paths.Get().ImageDatabasePath, ExtractExistingFileAction.OverwriteSilently);
                 Log.InfoFormat("Extracted {0},{1},{2}", Paths.Get().ImageDatabasePath, entry.FileName, testGuid);
                 ret = true;
             }
         }
         Log.InfoFormat("Finishing {0},{1},{2}", ret, entry.FileName, testGuid);
         return(ret);
     }
     catch (IOException e)
     {
         throw new UserMessageException("Error extracting {0} to {1}\n{2}", entry.FileName, Paths.Get().DatabasePath, e.Message);
     }
     finally
     {
         Log.InfoFormat("Finished {0},{1}", entry.FileName, testGuid);
     }
 }
Esempio n. 3
0
        internal bool ShouldExtract(O8cEntry o8centry)
        {
            try
            {
                Log.InfoFormat("Checking if should extract {0}", o8centry.cardImage);
                bool ret = false;
                Log.InfoFormat("Grabbing game {0},{1}", o8centry.gameGuid, o8centry.cardImage);
                var game = GetById(Guid.Parse(o8centry.gameGuid));
                if (game != null)
                {
                    Log.InfoFormat("Game exists {0},{1}", o8centry.gameGuid, o8centry.cardImage);
                    Guid cardGuid = Guid.Parse(o8centry.cardImage.Split('.')[0]);
                    Log.InfoFormat("Checking Paths {0},{1},{2}", o8centry.setsDir, o8centry.cardsDir, o8centry.cardImage);
                    if (o8centry.setsDir == "Sets" && o8centry.cardsDir == "Cards")
                    {
                        Log.InfoFormat("Paths good {0},{1},{2}", o8centry.setsDir, o8centry.cardsDir, o8centry.cardImage);
                        ret = true;
                    }
                }
                else
                {
                    Log.InfoFormat("Couldn't find game {0},{1}", o8centry.gameGuid, o8centry.cardImage);
                }
                Log.InfoFormat("Finishing {0}", o8centry.cardImage);
                return (ret);

            }
            finally
            {
                Log.InfoFormat("Finished {0}", o8centry.cardImage);
            }
        }
Esempio n. 4
0
        internal bool extract(ZipEntry entry, out Guid gameGuid, Guid testGuid)
        {
            try
            {
                Log.InfoFormat("Extracting {0},{1}", entry.FileName, testGuid);
                bool ret = false;
                gameGuid = testGuid;
                string[] split = entry.FileName.Split('/');
                Log.InfoFormat("Split file name {0},{1}", entry.FileName, testGuid);
                if (split.Length == 5)
                {
                    Log.InfoFormat("File name right count {0},{1}", entry.FileName, testGuid);
                    O8cEntry o8cEntry = new O8cEntry()
                                            {
                                                gameGuid = split[0],
                                                setsDir = split[1],
                                                setGuid = split[2],
                                                cardsDir = split[3],
                                                cardImage = split[4]
                                            };
                    Log.InfoFormat("Checking if testGuid is empty {0},{1}", entry.FileName, testGuid);
                    if (testGuid.Equals(Guid.Empty))
                    {
                        Log.InfoFormat("testGuid is empty {0},{1}", entry.FileName, testGuid);
                        testGuid = Guid.Parse(o8cEntry.gameGuid);
                        gameGuid = Guid.Parse(o8cEntry.gameGuid);
                        Log.InfoFormat("Setting gameguid and testguid {0},{1},{2}", entry.FileName, testGuid, gameGuid);
                    }
                    Log.InfoFormat("Checking if {0}=={1} {2}", testGuid, o8cEntry.gameGuid, entry.FileName);
                    if (!testGuid.Equals(Guid.Parse(o8cEntry.gameGuid)))
                    {
                        Log.InfoFormat("{0}!={1} {2}", testGuid, o8cEntry.gameGuid, entry.FileName);
                        return (ret);
                    }
                    Log.InfoFormat("Checking if should extract part {0},{1}", entry.FileName, testGuid);
                    if (ShouldExtract(o8cEntry))
                    {
                        Log.InfoFormat(
                            "Should extract, so extracting {0},{1},{2}",
                            Paths.Get().ImageDatabasePath,
                            entry.FileName,
                            testGuid);
                        entry.Extract(Paths.Get().ImageDatabasePath, ExtractExistingFileAction.OverwriteSilently);
                        Log.InfoFormat("Extracted {0},{1},{2}", Paths.Get().ImageDatabasePath, entry.FileName, testGuid);
                        ret = true;
                    }
                }
                Log.InfoFormat("Finishing {0},{1},{2}", ret, entry.FileName, testGuid);
                return (ret);

            }
            catch (IOException e)
            {
                throw new UserMessageException("Error extracting {0} to {1}\n{2}", entry.FileName, Paths.Get().DatabasePath, e.Message);
            }
            finally
            {
                Log.InfoFormat("Finished {0},{1}", entry.FileName, testGuid);
            }
        }