//Main Parse method------------------------------------------------------------------------------------------------------------------------------------------------
 /// <summary>
 /// Parses the given log. On parsing failure, parsingFailureReason will be filled with the reason of the failure and the method will return null
 /// <see cref="ParsingFailureReason"/>
 /// </summary>
 /// <param name="operation">Operation object bound to the UI</param>
 /// <param name="evtc">The path to the log to parse</param>
 /// <param name="parsingFailureReason">The reason why the parsing failed, if applicable</param>
 /// <param name="multiThreadAccelerationForBuffs">Will preprocess buff simulation using multi threading </param>
 /// <returns>the ParsedEvtcLog</returns>
 public ParsedEvtcLog ParseLog(ParserController operation, FileInfo evtc, out ParsingFailureReason parsingFailureReason, bool multiThreadAccelerationForBuffs = false)
 {
     parsingFailureReason = null;
     try
     {
         if (!evtc.Exists)
         {
             throw new EvtcFileException("File " + evtc.FullName + " does not exist");
         }
         if (!ParserHelper.IsSupportedFormat(evtc.Name))
         {
             throw new EvtcFileException("Not EVTC");
         }
         ParsedEvtcLog evtcLog;
         using (var fs = new FileStream(evtc.FullName, FileMode.Open, FileAccess.Read, FileShare.Read))
         {
             if (ParserHelper.IsCompressedFormat(evtc.Name))
             {
                 using (var arch = new ZipArchive(fs, ZipArchiveMode.Read))
                 {
                     if (arch.Entries.Count != 1)
                     {
                         throw new EvtcFileException("Invalid Archive");
                     }
                     using (Stream data = arch.Entries[0].Open())
                     {
                         using (var ms = new MemoryStream())
                         {
                             data.CopyTo(ms);
                             ms.Position = 0;
                             evtcLog     = ParseLog(operation, ms, out parsingFailureReason, multiThreadAccelerationForBuffs);
                         };
                     }
                 }
             }
             else
             {
                 evtcLog = ParseLog(operation, fs, out parsingFailureReason, multiThreadAccelerationForBuffs);
             }
         }
         return(evtcLog);
     }
     catch (Exception ex)
     {
         parsingFailureReason = new ParsingFailureReason(ex);
         return(null);
     }
 }
Пример #2
0
 //Main Parse method------------------------------------------------------------------------------------------------------------------------------------------------
 /// <summary>
 /// Parses the given log
 /// </summary>
 /// <param name="operation">Operation object bound to the UI</param>
 /// <param name="evtc">The path to the log to parse</param>
 /// <returns>the ParsedEvtcLog</returns>
 public ParsedEvtcLog ParseLog(ParserController operation, FileInfo evtc)
 {
     operation.UpdateProgressWithCancellationCheck("Reading Binary");
     if (!evtc.Exists)
     {
         throw new FileNotFoundException("File " + evtc.FullName + " does not exist");
     }
     if (!ParserHelper.IsSupportedFormat(evtc.Name))
     {
         throw new InvalidDataException("Not EVTC");
     }
     using (var fs = new FileStream(evtc.FullName, FileMode.Open, FileAccess.Read, FileShare.Read))
     {
         if (ParserHelper.IsCompressedFormat(evtc.Name))
         {
             using (var arch = new ZipArchive(fs, ZipArchiveMode.Read))
             {
                 if (arch.Entries.Count != 1)
                 {
                     throw new InvalidDataException("Invalid Archive");
                 }
                 using (Stream data = arch.Entries[0].Open())
                 {
                     using (var ms = new MemoryStream())
                     {
                         data.CopyTo(ms);
                         ms.Position = 0;
                         ParseLog(operation, ms);
                     };
                 }
             }
         }
         else
         {
             ParseLog(operation, fs);
         }
     }
     operation.UpdateProgressWithCancellationCheck("Data parsed");
     return(new ParsedEvtcLog(_buildVersion, _fightData, _agentData, _skillData, _combatItems, _playerList, _logEndTime - _logStartTime, _parserSettings, operation));
 }