/// <summary> /// <see cref="Sif.Framework.Consumer.IGenericConsumer{T,PK}.Update(System.Collections.Generic.IEnumerable<T>)">Update</see> /// </summary> public virtual void Update(IEnumerable <T> objs) { if (!registrationService.Registered) { throw new InvalidOperationException("Consumer has not registered."); } string url = EnvironmentUtils.ParseServiceUrl(environmentTemplate) + "/" + TypeName + "s"; string body = ListSerialiser.Serialise((List <T>)objs); string xml = HttpUtils.PutRequest(url, registrationService.AuthorisationToken, body); if (log.IsDebugEnabled) { log.Debug("XML from PUT request ..."); } if (log.IsDebugEnabled) { log.Debug(xml); } }
/// <summary> /// /// </summary> /// <param name="url"></param> /// <returns></returns> private ICollection <T> PagingRetrieve(string url) { if (!registrationService.Registered) { throw new InvalidOperationException("Consumer has not registered."); } List <T> result = new List <T>(); int pageIndex = 0; int pageResultCount = 0; do { string xml = HttpUtils.GetRequest(url, registrationService.AuthorisationToken, pageIndex++, SettingsManager.ConsumerSettings.NavigationPageSize); if (log.IsDebugEnabled) { log.Debug("XML from GET request (page " + (pageIndex - 1) + ") ..."); } if (log.IsDebugEnabled) { log.Debug(xml); } if (xml.Length > 0) { ICollection <T> pageResult = ListSerialiser.Deserialise(xml); if (pageResult == null || pageResult.Count == 0) { pageResultCount = 0; } else { pageResultCount = pageResult.Count; result.AddRange(pageResult); } } }while (pageResultCount == SettingsManager.ConsumerSettings.NavigationPageSize); return(result); }
/// <summary> /// <see cref="Sif.Framework.Consumer.IGenericConsumer{T,PK}.Retrieve(System.Int32, System.Int32)">Retrieve</see> /// </summary> public virtual ICollection <T> Retrieve(int navigationPage, int navigationPageSize) { if (!registrationService.Registered) { throw new InvalidOperationException("Consumer has not registered."); } string url = EnvironmentUtils.ParseServiceUrl(environmentTemplate) + "/" + TypeName + "s"; string xml = HttpUtils.GetRequest(url, registrationService.AuthorisationToken, navigationPage, navigationPageSize); if (log.IsDebugEnabled) { log.Debug("XML from GET request ..."); } if (log.IsDebugEnabled) { log.Debug(xml); } return(ListSerialiser.Deserialise(xml)); }
/// <summary> /// <see cref="Sif.Framework.Consumer.IGenericConsumer{T,PK}.Retrieve(T)">Retrieve</see> /// </summary> public virtual ICollection <T> Retrieve(T obj) { if (!registrationService.Registered) { throw new InvalidOperationException("Consumer has not registered."); } string url = EnvironmentUtils.ParseServiceUrl(environmentTemplate) + "/" + TypeName + "s"; string body = ObjectSerialiser.Serialise(obj); string xml = HttpUtils.PostRequest(url, registrationService.AuthorisationToken, body, "GET"); if (log.IsDebugEnabled) { log.Debug("XML from POST request ..."); } if (log.IsDebugEnabled) { log.Debug(xml); } return(ListSerialiser.Deserialise(xml)); }