// Methods #region Get(IRobID activityRID) public ActivityModel Get(IRobID activityRID) { var request = BuildRequest("api/activities/{0}".AsFormat(activityRID)); HttpResponseMessage response = Client.SendAsync(request).Result; if (response.IsSuccessStatusCode) { var jobject = response.Content.ReadAsAsync <JObject>().Result; // read past the "activity" wrapper var jProperty = (JProperty)jobject.Children().Single(); return(jProperty.Value.ToObject <ActivityModel>()); } Logger.Error("Request {0} returned {1} ({2})", request.RequestUri, (int)response.StatusCode, response.ReasonPhrase); // ReSharper disable EmptyGeneralCatchClause try { Logger.Error("Response Body: {0}", response.Content.ReadAsAsync <string>().Result); } catch (Exception) { } // ReSharper restore EmptyGeneralCatchClause Console.WriteLine("{0} ({1})", (int)response.StatusCode, response.ReasonPhrase); return(null); }
// Methods public virtual List <IDeviceModel> Get(IRobID principalRID) { var request = BuildRequest("api/people/{0}/devices".AsFormat(principalRID)); HttpResponseMessage response = Client.SendAsync(request).Result; var result = new List <IDeviceModel>(); if (response.IsSuccessStatusCode) { var jobject = response.Content.ReadAsAsync <JObject>().Result; Logger.Debug("Request {0} returned {1}", request.RequestUri, jobject.ToString()); var jdevices = jobject["devices"] as JArray; foreach (JObject jdevice in jdevices) { result.Add(jdevice.ToObject <DeviceModel>()); } } else { Logger.Error("Request {0} returned {1} ({2})", request.RequestUri, (int)response.StatusCode, response.ReasonPhrase); // ReSharper disable EmptyGeneralCatchClause try { Logger.Error("Response Body: {0}", response.Content.ReadAsAsync <string>().Result); } catch (Exception) { } // ReSharper restore EmptyGeneralCatchClause } return(result); }
public AuthenticationHeaderValue GetAuthenticationHeaderValue(IRobID principalRID) { return(new AuthenticationHeaderValue( "Basic", Convert.ToBase64String( System.Text.Encoding.ASCII.GetBytes( string.Format("{0}:{1}", "*****@*****.**", "test"))))); //, "unforgiven+notting!7649458436+6955865")))); }
public override IPersonModel Get(IRobID rid) { var key = _ToKey(rid); var result = Context.Cache.Get <IPersonModel>(key); if (result != null) { return(result); } result = base.Get(rid); Context.Cache.Add(result, key); return(result); }
public override List <IDeviceModel> Get(IRobID principalRID) { var key = _ToKey(principalRID); var result = Context.Cache.Get <List <IDeviceModel> >(key); if (result != null) { return(result); } result = base.Get(principalRID); Context.Cache.Add(result, key); return(result); }
// Methods #region Get(IRobID rid) public virtual IPersonModel Get(IRobID rid) { var request = BuildRequest("api/people/{0}".AsFormat(rid)); HttpResponseMessage response = Client.SendAsync(request).Result; if (response.IsSuccessStatusCode) { var jobject = response.Content.ReadAsAsync <JObject>().Result; // read past the "person" wrapper var jProperty = (JProperty)jobject.Children().Single(); return(jProperty.Value.ToObject <PersonModel>()); } Console.WriteLine("{0} ({1})", (int)response.StatusCode, response.ReasonPhrase); return(null); }
private string _ToKey(IRobID rid) { return("PeopleService_Get_{0}".AsFormat(rid)); }
private string _ToKey(IRobID principalRID) { return("DevicesService_Get_{0}".AsFormat(principalRID)); }