private CachedLog ParseJob(CachedLog log) { var localDataVersion = CacheLog(log.ID).DataVersion; if (!string.IsNullOrEmpty(log.HtmlPath) && localDataVersion >= CachedLog.CurrentDataVersion) { return(log); } if (string.IsNullOrEmpty(log.EvtcPath) || !File.Exists(log.EvtcPath)) { UpdateFilePaths(log); return(log); } var res = EliteInsights.Parse(log.EvtcPath); var html = res.Where(path => path.EndsWith(".html")).FirstOrDefault(); var json = res.Where(path => path.EndsWith(".json")).FirstOrDefault(); //Maybe Add corrupted flag if no output is generated if (res.Count == 0) { var ex = new Exception($"Could not parse the {log.BossName} log! ({log.SizeKb} kb)\n{log.EvtcPath}"); if (log.SizeKb >= 30) { throw ex; } Logger.LogException(ex); return(log); } if (!log.DataCorrected || localDataVersion < CachedLog.CurrentDataVersion) { var jsonStr = GP.ReadJsonFile(json); log.UpdateEi(jsonStr); if (string.IsNullOrWhiteSpace(log.JsonPath)) { var simpleLogJson = new SimpleLogJson(jsonStr); var newjson = json.Substring(0, json.Length - ".json".Length) + "_simple.json"; GP.WriteJsonFile(newjson, simpleLogJson.ToString()); log.JsonPath = newjson; } } log.HtmlPath = html; File.Delete(json); LogDBConnector.Update(log.GetDBLog()); return(log); }
private CachedLog ReParseData(CachedLog log) { if (!log.DataCorrected) { return(ParseJob(log)); } if (!string.IsNullOrWhiteSpace(log.Link)) { var response = DPSReport.GetEncounterDataPermalink(log.Link); var simpleLogJson = new SimpleLogJson(response); if (!string.IsNullOrWhiteSpace(log.JsonPath)) { if (File.Exists(log.JsonPath)) { File.Delete(log.JsonPath); } } string name; if (!string.IsNullOrWhiteSpace(log.EvtcPath)) { name = log.EvtcPath.Substring(0, log.EvtcPath.LastIndexOf('.')).Split('\\').Last(); } else { name = log.Link.Split('/').Last(); } var newjson = EliteInsights.LogsPath + name + "_simple.json"; GP.WriteJsonFile(newjson, simpleLogJson.ToString()); log.JsonPath = newjson; LogDBConnector.Update(log.GetDBLog()); log.ApplySimpleLog(simpleLogJson); return(log); } if (!string.IsNullOrWhiteSpace(log.EvtcPath)) { if (!File.Exists(log.EvtcPath)) { UpdateFilePaths(log); return(log); } var res = EliteInsights.Parse(log.EvtcPath); var html = res.Where(path => path.EndsWith(".html")).FirstOrDefault(); var json = res.Where(path => path.EndsWith(".json")).FirstOrDefault(); if (res.Count == 0) { return(null); } if (!string.IsNullOrWhiteSpace(log.HtmlPath) && File.Exists(log.HtmlPath)) { File.Delete(log.HtmlPath); } if (!string.IsNullOrWhiteSpace(log.JsonPath) && File.Exists(log.JsonPath)) { File.Delete(log.HtmlPath); } if (!log.DataCorrected) { var jsonStr = GP.ReadJsonFile(json); log.UpdateEi(jsonStr); if (string.IsNullOrWhiteSpace(log.JsonPath)) { var simpleLogJson = new SimpleLogJson(jsonStr); var newjson = json.Substring(0, json.Length - ".json".Length) + "_simple.json"; GP.WriteJsonFile(newjson, simpleLogJson.ToString()); log.JsonPath = newjson; } } log.HtmlPath = html; File.Delete(json); LogDBConnector.Update(log.GetDBLog()); } return(null); // cannot upgrade data }