Skip to main content

<a id=“SuperOffice_WebApi_Agents_ViewStateAgent”></a> Class ViewStateAgent

Namespace: SuperOffice.WebApi.Agents
Assembly: SuperOffice.WebApi.dll
User interface view state, history, currentXXX values

Inheritance

objectAgentBaseViewStateAgent

Implements

IViewStateAgent, IAgentBase, IDisposable

Inherited Members

AgentBase._json, AgentBase._binary, AgentBase._config, AgentBase._client, AgentBase._disposeClient, AgentBase.Merge(RequestOptions), AgentBase.BuildRequestFromObject(HttpMethod, string, object, WebApiOptions, string), AgentBase.BuildRequestFromStream(HttpMethod, string, Stream, WebApiOptions, string), AgentBase.BuildRequestFromObjectWithStream(HttpMethod, string, object, Stream, WebApiOptions, string), AgentBase.ParseAuthorization(IAuthorization), AgentBase.CancelRequest(), AgentBase.SendRequestObject(HttpMethod, string, object, WebApiOptions, string), AgentBase.SendRequestObjectWithStream(HttpMethod, string, object, Stream, WebApiOptions, string), AgentBase.SendRequest(HttpRequestMessage, RequestOptions), AgentBase.ThrowOnResponseErrorAsync(HttpRequestMessage, HttpResponseMessage), AgentBase.ParseResponse<T&gt;(HttpResponseMessage), AgentBase.Finally(RequestOptions), AgentBase.Dispose(), AgentBase.Configuration, AgentBase.Client, AgentBase.HasRunningRequest, AgentBase.ClientCancellationTokenSource, AgentBase.ProgressListener, AgentBase.UploadProgressListener, object.ToString(), object.Equals(object), object.Equals(object, object), object.ReferenceEquals(object, object), object.GetHashCode(), object.GetType(), object.MemberwiseClone()

Examples

<pre><code class=“lang-csharp”>using SuperOffice.WebApi; using SuperOffice.WebApi.Agents; var mySession = new WebApiOptions(“http://example.com/super/api”); mySession.Authorization = new AuthorizationUsernamePassword(“user”, “pass”); using (ViewStateAgent agent = new ViewStateAgent(mySession)) { // call methods on agent here… }</code></pre>

Constructors

<a id=“SuperOffice_WebApi_Agents_ViewStateAgent__ctor_System_Net_Http_HttpClient_”></a> ViewStateAgent(HttpClient)

Constructor: User interface view state, history, currentXXX values

Parameters

httpClient HttpClient Use this HTTP client instead of making own HttpClient instance.

<a id=“SuperOffice_WebApi_Agents_ViewStateAgent__ctor_SuperOffice_WebApi_WebApiOptions_System_Net_Http_HttpClient_”></a> ViewStateAgent(WebApiOptions, HttpClient)

Constructor: User interface view state, history, currentXXX values

Parameters

options WebApiOptions Base URL and authentication values. httpClient HttpClient Optional: Use this HTTP client instead of making a new one.

Methods

<a id=“SuperOffice_WebApi_Agents_ViewStateAgent_DeleteHistoryAsync_System_String_System_Int32_SuperOffice_WebApi_RequestOptions_”></a> DeleteHistoryAsync(string, int, RequestOptions)

Deletes the history element

Parameters

historyName string Name of the history list, e.g. contact, project id int Id of the history element, e.g. Contact id requestOptions RequestOptions Override language/culture codes on this request.

Returns

Task

<a id=“SuperOffice_WebApi_Agents_ViewStateAgent_GetCurrentAsync_System_String_SuperOffice_WebApi_RequestOptions_”></a> GetCurrentAsync(string, RequestOptions)

Get the current (most recent) value of the history list. This is the item with rank = 1. If no item exists a default value is returned. This is usually the first item in the table representing the history list.

Parameters

historyName string Name of the history list, e.g. contact, project requestOptions RequestOptions Override language/culture codes on this request.

Returns

Task<History&gt; The current (most recent) history item

<a id=“SuperOffice_WebApi_Agents_ViewStateAgent_GetHistoriesAsync_SuperOffice_WebApi_RequestOptions_”></a> GetHistoriesAsync(RequestOptions)

Returns all history items that belong to the currently logged in user

Parameters

requestOptions RequestOptions Override language/culture codes on this request.

Returns

Task<History[]&gt; Array of History items

<a id=“SuperOffice_WebApi_Agents_ViewStateAgent_GetHistoriesByNameAsync_System_String_SuperOffice_WebApi_RequestOptions_”></a> GetHistoriesByNameAsync(string, RequestOptions)

Returns the named history list that belong to the currently logged in user

Parameters

historyName string Name of the history list requestOptions RequestOptions Override language/culture codes on this request.

Returns

Task<History[]&gt; Array of History items

<a id=“SuperOffice_WebApi_Agents_ViewStateAgent_GetHistoriesByNamesAndIdsAsync_SuperOffice_WebApi_Data_HistoryRequest___SuperOffice_WebApi_RequestOptions_”></a> GetHistoriesByNamesAndIdsAsync(HistoryRequest[], RequestOptions)

Returns history data for the named entities and the given ids - which may not directly correspond to the current history records in the database.<para/>Use this method if you know exactly which items you need, regardless of whether they are in the current history or not.<para/>The history in the database is not changed or even looked at by this method.

Parameters

requests HistoryRequest[] Array of request objects that define what entities we are requesting history information for requestOptions RequestOptions Override language/culture codes on this request.

Returns

Task<History[]&gt; On history item for each history name/id pair specified, in exactly the same order as specified.<para/>If a specified item cannot be found in the database, its Id will be 0 and its name will be blank in the return array.

<a id=“SuperOffice_WebApi_Agents_ViewStateAgent_GetHistoriesByNamesAsync_System_String___SuperOffice_WebApi_RequestOptions_”></a> GetHistoriesByNamesAsync(string[], RequestOptions)

Returns the named history lists that belong to the currently logged in user

Parameters

historyNames string[] String array of list names requestOptions RequestOptions Override language/culture codes on this request.

Returns

Task<History[]&gt; Array of History items

<a id=“SuperOffice_WebApi_Agents_ViewStateAgent_GetHistoryAsync_System_Int32_SuperOffice_WebApi_RequestOptions_”></a> GetHistoryAsync(int, RequestOptions)

Gets a specific History object.

Parameters

historyId int The identifier of the History object requestOptions RequestOptions Override language/culture codes on this request.

Returns

Task<History&gt; History

<a id=“SuperOffice_WebApi_Agents_ViewStateAgent_GetHistoryLengthPrefValueAsync_SuperOffice_WebApi_RequestOptions_”></a> GetHistoryLengthPrefValueAsync(RequestOptions)

Get the logged on user’s preferred history list length. Will return the system preference if no user preferences are available.

Parameters

requestOptions RequestOptions Override language/culture codes on this request.

Returns

Task<int&gt; The history list lenght

<a id=“SuperOffice_WebApi_Agents_ViewStateAgent_GetLiveUiConfigAsync_SuperOffice_WebApi_RequestOptions_”></a> GetLiveUiConfigAsync(RequestOptions)

Gets live UI configuration

Parameters

requestOptions RequestOptions Override language/culture codes on this request.

Returns

Task<LiveUiConfig&gt; Live UI configuration containing the parameters needed for live UI functionality

<a id=“SuperOffice_WebApi_Agents_ViewStateAgent_GetNextCurrentAsync_System_String_System_Int32_SuperOffice_WebApi_RequestOptions_”></a> GetNextCurrentAsync(string, int, RequestOptions)

Returns the next current item. If no item exists a default value is returned. This is usually the first item in the table representing the history list.

Parameters

historyName string Name of the history list, e.g. contact, project id int Id of the history element, e.g. Contact id requestOptions RequestOptions Override language/culture codes on this request.

Returns

Task<History&gt; The current value.

<a id=“SuperOffice_WebApi_Agents_ViewStateAgent_GetPreviousCurrentAsync_System_String_System_Int32_SuperOffice_WebApi_RequestOptions_”></a> GetPreviousCurrentAsync(string, int, RequestOptions)

Returns the previous current item. If no item exists a default value is returned. This is usually the first item in the table representing the history list.

Parameters

historyName string Name of the history list, e.g. contact, project id int Id of the history element, e.g. Contact id requestOptions RequestOptions Override language/culture codes on this request.

Returns

Task<History&gt; The current value.

<a id=“SuperOffice_WebApi_Agents_ViewStateAgent_PublishAndRetrieveUiEventsAsync_System_Int32_SuperOffice_WebApi_Data_UiEvent___SuperOffice_WebApi_Data_MetricPair___SuperOffice_WebApi_RequestOptions_”></a> PublishAndRetrieveUiEventsAsync(int, UiEvent[], MetricPair[], RequestOptions)

Publish zero or more events, and return any new events since the given event id. The initial implementation is in-memory only; applies solely to the front-end web server; and anything older than 20 minutes is discarded

Parameters

latestKnownEventId int The last event ID that this client knows about. The return value will be any events occurring /after/ that point, numbered by the server. Clients need to keep track themselves of this number between calls publishEvents UiEvent[] Array of events to publish. This can be empty if the client only wants to retrieve information metrics MetricPair[] Optional statistical and performance metrics collected by the frontend. Can be null or empty. Metrics are sum-accumulated and reported once a minute; please do not report the same logical event twice requestOptions RequestOptions Override language/culture codes on this request.

Returns

Task<UiEvent[]&gt; Array of events since the given event ID; within the time span kept by the event mechanism. Event/primarykey combinations are not guaranteed to be unique, and events in the PublishEvents parameter are echoed back to the client

<a id=“SuperOffice_WebApi_Agents_ViewStateAgent_SaveCurrentAsync_SuperOffice_WebApi_Data_History_SuperOffice_WebApi_RequestOptions_”></a> SaveCurrentAsync(History, RequestOptions)

Saving the current history item. This history item is saved with Rank = 1, and all the remaining elements rank values are shifted one down. The list is maintained with the max lenght of the History list length preference.

Parameters

current History The new current history element. requestOptions RequestOptions Override language/culture codes on this request.

Returns

Task<History&gt; The current (most recent) history item

<a id=“SuperOffice_WebApi_Agents_ViewStateAgent_SaveCurrentsAsync_SuperOffice_WebApi_Data_History___SuperOffice_WebApi_RequestOptions_”></a> SaveCurrentsAsync(History[], RequestOptions)

Saves the history elements as the current value for their respective lists. If more than one item is submitted for the same list, they are added sequently, meaning that the last one is the most current.

Parameters

currents History[] Array of new history items to save. requestOptions RequestOptions Override language/culture codes on this request.

Returns

Task<History[]&gt; Array of the saved History items

<a id=“SuperOffice_WebApi_Agents_ViewStateAgent_SaveHistoriesAsync_System_String_SuperOffice_WebApi_Data_History___SuperOffice_WebApi_RequestOptions_”></a> SaveHistoriesAsync(string, History[], RequestOptions)

Replaces the existing history-list for the currently logged in user. All elements must belong to the same history list. If not they are ignored.

Parameters

historyName string history History[] Array of new history items to save. requestOptions RequestOptions Override language/culture codes on this request.

Returns

Task<History[]&gt; Array of the saved History items

<a id=“SuperOffice_WebApi_Agents_ViewStateAgent_SetHistoryLengthPrefValueAsync_System_Int32_SuperOffice_WebApi_RequestOptions_”></a> SetHistoryLengthPrefValueAsync(int, RequestOptions)

Set the logged on user’s preferred history list length.

Parameters

length int The new history list lenght requestOptions RequestOptions Override language/culture codes on this request.

Returns

Task