public void WriteDictCachedData(long regionEntityKey) { ApexConsumer.ErrorLevel errorLevel = ApexConsumer.ErrorLevel.None; string errorMessage = string.Empty; _Logger.InfoFormat("Writing Dictionary Cache file to {0}", dicFilePath); try { long[] regEntityKey = new long[] { _Region.EntityKey }; this.depotsForRegionDict = _ApexConsumer.RetrieveDepotsForRegion(out errorLevel, out errorMessage, regionEntityKey); this.orderClassesDict = _ApexConsumer.RetrieveOrderClassesDict(out errorLevel, out errorMessage); this.regionEntityKeyDict = _ApexConsumer.RetrieveRegionEntityKey(out errorLevel, out errorMessage); this.serviceTimeEntityKeyDict = _ApexConsumer.RetrieveServiceTimeEntityKey(out errorLevel, out errorMessage); this.timeWindowEntityKeyDict = _ApexConsumer.RetrieveTimeWindowEntityKey(out errorLevel, out errorMessage); List <ServiceLocation> locations = _ApexConsumer.RetrieveServiceLocationsByRegion(out errorLevel, out errorMessage, regEntityKey).ToList(); this.serviceLocationDict = locations.ToDictionary(x => x.Identifier, y => y); Newtonsoft.Json.JsonSerializerSettings settings = new Newtonsoft.Json.JsonSerializerSettings { PreserveReferencesHandling = Newtonsoft.Json.PreserveReferencesHandling.Objects, ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore }; string jsonData = Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.None, settings); // StreamWriter writer = new StreamWriter(dictCacheFile, append: false); System.IO.File.WriteAllText(dicFilePath, jsonData); // writer.Write(jsonData); } catch (Exception ex) { _Logger.ErrorFormat("Error writing cache file: {0}", ex.Message); } }
public void refreshServiceLocation() { ApexConsumer.ErrorLevel errorLevel = ApexConsumer.ErrorLevel.None; string errorMessage = string.Empty; _Logger.InfoFormat("Refresh Service Location Cache file to {0}", dicFilePath); try { long[] regEntityKey = new long[] { _Region.EntityKey }; List <ServiceLocation> locations = _ApexConsumer.RetrieveServiceLocationsByRegion(out errorLevel, out errorMessage, regEntityKey).ToList(); this.serviceLocationDict = locations.ToDictionary(x => x.Identifier, y => y); } catch (Exception ex) { _Logger.ErrorFormat("Error refreshing service location cache file: {0}", ex.Message); } }