11/*
2- * Copyright 2016 Systemic Pty Ltd
2+ * Copyright 2017 Systemic Pty Ltd
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
1515 */
1616
1717using log4net ;
18+ using Sif . Framework . Extensions ;
1819using Sif . Framework . Model . DataModels ;
1920using Sif . Framework . Model . Query ;
2021using Sif . Framework . Model . Responses ;
@@ -181,6 +182,23 @@ public void Unregister(bool? deleteOnUnregister = null)
181182 registrationService . Unregister ( deleteOnUnregister ) ;
182183 }
183184
185+ /// <summary>
186+ /// <see cref="IConsumer{TSingle,TMultiple,TPrimaryKey}.GetChangesSinceMarker(string, string)">GetChangesSinceMarker</see>
187+ /// </summary>
188+ public string GetChangesSinceMarker ( string zone = null , string context = null )
189+ {
190+
191+ if ( ! RegistrationService . Registered )
192+ {
193+ throw new InvalidOperationException ( "Consumer has not registered." ) ;
194+ }
195+
196+ string url = EnvironmentUtils . ParseServiceUrl ( EnvironmentTemplate ) + "/" + TypeName + "s" + HttpUtils . MatrixParameters ( zone , context ) ;
197+ WebHeaderCollection responseHeaders = HttpUtils . HeadRequest ( url , RegistrationService . AuthorisationToken ) ;
198+
199+ return responseHeaders [ HttpUtils . RequestHeader . changesSinceMarker . ToDescription ( ) ] ;
200+ }
201+
184202 /// <summary>
185203 /// <see cref="IConsumer{TSingle,TMultiple,TPrimaryKey}.Create(TSingle, string, string)">Create</see>
186204 /// </summary>
@@ -298,7 +316,7 @@ public virtual TMultiple Query(uint? navigationPage = null, uint? navigationPage
298316 }
299317
300318 /// <summary>
301- /// <see cref="IConsumer{TSingle,TMultiple,TPrimaryKey}.QueryByExample(TSingle, uint?, uint?, string, string)">Query </see>
319+ /// <see cref="IConsumer{TSingle,TMultiple,TPrimaryKey}.QueryByExample(TSingle, uint?, uint?, string, string)">QueryByExample </see>
302320 /// </summary>
303321 public virtual TMultiple QueryByExample ( TSingle obj , uint ? navigationPage = null , uint ? navigationPageSize = null , string zone = null , string context = null )
304322 {
@@ -319,7 +337,7 @@ public virtual TMultiple QueryByExample(TSingle obj, uint? navigationPage = null
319337 }
320338
321339 /// <summary>
322- /// <see cref="IConsumer{TSingle,TMultiple,TPrimaryKey}.QueryByServicePath(IEnumerable{EqualCondition}, uint?, uint?, string, string)">Query </see>
340+ /// <see cref="IConsumer{TSingle,TMultiple,TPrimaryKey}.QueryByServicePath(IEnumerable{EqualCondition}, uint?, uint?, string, string)">QueryByServicePath </see>
323341 /// </summary>
324342 public virtual TMultiple QueryByServicePath ( IEnumerable < EqualCondition > conditions , uint ? navigationPage = null , uint ? navigationPageSize = null , string zone = null , string context = null )
325343 {
@@ -357,6 +375,36 @@ public virtual TMultiple QueryByServicePath(IEnumerable<EqualCondition> conditio
357375 return DeserialiseMultiple ( xml ) ;
358376 }
359377
378+ /// <summary>
379+ /// <see cref="IConsumer{TSingle,TMultiple,TPrimaryKey}.QueryChangesSince(string, out string, uint?, uint?, string, string)">QueryChangesSince</see>
380+ /// </summary>
381+ public TMultiple QueryChangesSince ( string changesSinceMarker , out string nextChangesSinceMarker , uint ? navigationPage = null , uint ? navigationPageSize = null , string zone = null , string context = null )
382+ {
383+
384+ if ( ! RegistrationService . Registered )
385+ {
386+ throw new InvalidOperationException ( "Consumer has not registered." ) ;
387+ }
388+
389+ string changesSinceParameter = ( changesSinceMarker == null ? string . Empty : "?changesSinceMarker=" + changesSinceMarker ) ;
390+ string url = EnvironmentUtils . ParseServiceUrl ( EnvironmentTemplate ) + "/" + TypeName + "s" + HttpUtils . MatrixParameters ( zone , context ) + changesSinceParameter ;
391+ WebHeaderCollection responseHeaders ;
392+ string xml ;
393+
394+ if ( navigationPage . HasValue && navigationPageSize . HasValue )
395+ {
396+ xml = HttpUtils . GetRequestAndHeaders ( url , RegistrationService . AuthorisationToken , out responseHeaders , ( int ) navigationPage , ( int ) navigationPageSize ) ;
397+ }
398+ else
399+ {
400+ xml = HttpUtils . GetRequestAndHeaders ( url , RegistrationService . AuthorisationToken , out responseHeaders ) ;
401+ }
402+
403+ nextChangesSinceMarker = responseHeaders [ HttpUtils . RequestHeader . changesSinceMarker . ToDescription ( ) ] ;
404+
405+ return DeserialiseMultiple ( xml ) ;
406+ }
407+
360408 /// <summary>
361409 /// <see cref="IConsumer{TSingle,TMultiple,TPrimaryKey}.Update(TSingle, string, string)">Update</see>
362410 /// </summary>
0 commit comments