private void SaveFriendsData(DailyMileFriends dmFriends) { _logger.EnQueueAppTraceMessage("SaveFriendsData() Enter"); tsStatus.Text = "Saving Daily Mile Friend Data"; try { using (FileStream fs = new FileStream(_friendsInfoFile, FileMode.OpenOrCreate, FileAccess.Write, FileShare.None)) { using (BinaryWriter binWriter = new BinaryWriter(fs)) { binWriter.Write(VengSoft.DailyMileAPIWrapper.SerializersJSON.Serialize<DailyMileFriends>(dmFriends)); } } } catch (System.Exception ex) { _logger.EnQueueFatalMessage("SaveFriendsData() Exception: " + ex.Message); } _logger.EnQueueAppTraceMessage("SaveFriendsData() Leave"); }
public DailyMileFriends GetUsersFriends(string userName) { string jsonResults; string reqData = string.Empty; DailyMileFriends friends = new DailyMileFriends(); try { if (LogonDailyMile() == true) { reqData = string.Format("{0}/people/{1}/friends.json?oauth_token={2}", _connectionInfo.DailyMileURL, userName, _connectionInfo.ServerKey); jsonResults = RequestData(reqData); friends = SerializersJSON.Deserialise<DailyMileFriends>(jsonResults); } } catch (VSException ve) { throw ve; } catch (System.Exception ex) { throw new VSException(string.Format("GetUsersFriends User({0}) reqData({1}) Exception {2}", userName, reqData, ex.Message)); } return friends; }
private DailyMileFriends ReadFriendsData() { _logger.EnQueueAppTraceMessage("ReadFriendsData() Enter"); DailyMileFriends friends; friends = new DailyMileFriends(); try { using (FileStream fs = new FileStream(_friendsInfoFile, FileMode.OpenOrCreate, FileAccess.Read, FileShare.None)) { using (BinaryReader binReader = new BinaryReader(fs)) { friends = VengSoft.DailyMileAPIWrapper.SerializersJSON.Deserialise<DailyMileFriends>(binReader.ReadBytes((int)fs.Length)); } } } catch (System.Exception ex) { _logger.EnQueueFatalMessage("ReadFriendsData() Exception: " + ex.Message); } _logger.EnQueueAppTraceMessage("ReadFriendsData() Leave"); return friends; }