public static IList <CallNote> ReadCallNotes(string filePath, string fileName) { if (Logger.IsDebugEnabled) { Logger.Debug("[CallNoteFileHelper::ReadCallNotes] Starting reading all CallNotes. FilePath: {}, FileName: {}", filePath, fileName); } try { var jObject = JsonFileHelper.ReadJsonFile(filePath, fileName); var callNotes = jObject["CallNotes"].Select(JTokenToCallNote).ToList(); if (Logger.IsDebugEnabled) { Logger.Debug( "[CallNoteFileHelper::ReadCallNotes] Reading all CallNotes Successfully. callNotes: {}", callNotes); } return(callNotes); } catch (FileNotFoundException e) { Logger.Error(e, "[CallNoteFileHelper::ReadCallNotes] Reading all CallNotes Failed. Can not find file. FilePath: {}, FileName: {}", filePath, fileName); throw new FileNotFoundException("[CallNoteFileHelper::ReadCallNotes] Reading all CallNotes Failed. Can not find file.", e); } catch (Exception e) { Logger.Error(e, "[CallNoteFileHelper::ReadCallNotes] Reading all CallNotes Failed. FilePath: {}, FileName: {}", filePath, fileName); throw new DataAccessException("[CallNoteFileHelper::ReadCallNotes] Reading all CallNotes Failed.", e); } }
public static int GetIdSeq() { if (Logger.IsDebugEnabled) { Logger.Debug("[IdSeqGenerator::GetIdSeq] Getting IdSeq."); } try { // if IdSeq file not exist, create a new one if (!File.Exists(Path.Combine(IdSeqFilePath, IdSeqFileName))) { var jObject = new JObject { ["IdSeq"] = Constants.InitIdSeq }; JsonFileHelper.WriteJsonFile(IdSeqFilePath, IdSeqFileName, jObject); } var jObj = JsonFileHelper.ReadJsonFile(IdSeqFilePath, IdSeqFileName); var idSeq = (int)jObj["IdSeq"]; idSeq++; jObj["IdSeq"] = idSeq; JsonFileHelper.WriteJsonFile(IdSeqFilePath, IdSeqFileName, jObj); if (Logger.IsDebugEnabled) { Logger.Debug("[IdSeqGenerator::GetIdSeq] Get IdSeq successfully. IdSeq: {}", idSeq); } return(idSeq); } catch (Exception e) { Logger.Error(e, "[IdSeqGenerator::GetIdSeq] Get IdSeq error."); throw new DataAccessException("IdSeqGenerator::GetIdSeq: Get IdSeq error.", e); } }