private Dictionary <string, UpdatedInfo> LoadData() { // if we have the data available then return it if (_data != null) { return(_data); } // if we are processing the feed then the client needs to wait. while (_inProgress) { Thread.Sleep(50); } try { var fileNameExtention = _definition.HashValueFileName; if (string.IsNullOrEmpty(fileNameExtention)) { fileNameExtention = _definition.HashValueTable; } var dataLocation = ConfigurationReader.Configuration.HashValueStorageLocation + Path.DirectorySeparatorChar + _provider.Name + "-" + fileNameExtention + ".slu"; var fileInfo = new FileInfo(dataLocation); // if the file doesnt exist then if (!fileInfo.Exists) { return(new Dictionary <string, UpdatedInfo>()); } var data = new Dictionary <string, UpdatedInfo>(); using (var fs = new FileStream(dataLocation, FileMode.Open)) { using (var br = new BinaryReader(fs)) { var count = br.ReadInt32(); for (int i = 0; i < count; i++) { var info = new UpdatedInfo(); info.Id = br.ReadString(); info.EntityId = br.ReadString(); info.HashValue = br.ReadInt32(); info.LastUpdated = DateTime.Parse(br.ReadString()); data.Add(info.Id, info); } } } _data = data; return(_data); } catch (Exception ex) { Logging.LogError(1, "Error Loading Data {0} {1}", ex.Message, ex.StackTrace); } _data = new Dictionary <string, UpdatedInfo>(); return(_data); }
protected Dictionary<string, UpdatedInfo> LoadData() { // if we have the data available then return it if (_data != null) { return _data; } // if we are processing the feed then the client needs to wait. while (_inProgress) { Thread.Sleep(50); } UpdatedInfo info = null; var data = new Dictionary<string, UpdatedInfo>(); try { //var fileNameExtention = _definition.HashValueFileName; //if (string.IsNullOrEmpty(fileNameExtention)) // fileNameExtention = _definition.HashValueTable; var dataLocation = ConfigurationReader.Configuration.HashValueStorageLocation + Path.DirectorySeparatorChar + _hashValueFileName + ".slu"; var fileInfo = new FileInfo(dataLocation); // if the file doesnt exist then if (!fileInfo.Exists) return new Dictionary<string, UpdatedInfo>(); using (var fs = new FileStream(dataLocation, FileMode.Open)) { using (var br = new BinaryReader(fs)) { var count = br.ReadInt32(); for (int i = 0; i < count; i++) { info = new UpdatedInfo(); info.Id = br.ReadString(); info.EntityId = br.ReadString(); info.HashValue = br.ReadInt32(); info.LastUpdated = DateTime.Parse(br.ReadString()); data.Add(info.EntityId, info); } } fs.Close(); } _data = data; return _data; } catch (Exception ex) { Logging.LogError(1, "Error Loading Data {0} {1}", ex.Message, ex.StackTrace); } _data = new Dictionary<string, UpdatedInfo>(); return _data; }