Esempio n. 1
0
        /// <summary>
        /// Gets audit logs asynchronously
        /// </summary>
        /// <returns>A page of audit logs</returns>
        /// <example>This example shows how to get the first page of audit logs:
        /// <code>
        /// using ProKnow;
        /// using System.Threading.Tasks;
        ///
        /// var pk = new ProKnowApi("https://example.proknow.com", "./credentials.json");
        /// FilterParameters filterParams = new FilterParameters();
        /// var page = await _proKnow.Audit.Query(filterParams);
        /// var nextPage = await page.Next();
        /// </code>
        /// </example>
        public async Task <AuditPage> Query(FilterParameters filter)
        {
            FilterParametersExtended filterParameters = new FilterParametersExtended();

            filterParameters.Copy(filter);

            filterParameters.PageNumber = null;
            if (filter == null)
            {
                filterParameters.PageSize = 25;
            }

            var bodyJson       = JsonSerializer.Serialize(filterParameters, _serializerOptions);
            var requestContent = new StringContent(bodyJson, Encoding.UTF8, "application/json");

            var json = await _proKnow.Requestor.PostAsync("/audit/events/search", null, requestContent);

            var page = JsonSerializer.Deserialize <AuditPage>(json);

            if (page.Items.Count > 0)
            {
                filterParameters.FirstId    = page.Items[0].Id;
                filterParameters.PageNumber = 0;
            }

            page.PostProcessDeserialization(_proKnow, filterParameters);
            return(page);
        }
Esempio n. 2
0
        /// <summary>
        /// Finishes initialization of object after deserialization from JSON
        /// </summary>
        /// <param name="proKnow">Root object for interfacing with the ProKnow API</param>
        /// <param name="parameters">The filter paramters used in API call</param>
        internal void PostProcessDeserialization(ProKnowApi proKnow, FilterParametersExtended parameters)
        {
            _proKnow          = proKnow;
            _filterParameters = new FilterParametersExtended(parameters);

            //Increment page number for next page call.
            ++this._filterParameters.PageNumber;
        }
 public FilterParametersExtended(FilterParametersExtended data)
 {
     this.PageSize       = data.PageSize;
     this.StartTime      = data.StartTime;
     this.EndTime        = data.EndTime;
     this.Types          = data.Types;
     this.UserName       = data.UserName;
     this.PatientName    = data.PatientName;
     this.Classification = data.Classification;
     this.Methods        = data.Methods;
     this.URI            = data.URI;
     this.UserAgent      = data.UserAgent;
     this.IpAddress      = data.IpAddress;
     this.StatusCodes    = data.StatusCodes;
     this.WorkspaceId    = data.WorkspaceId;
     this.ResourceId     = data.ResourceId;
     this.FirstId        = data.FirstId;
     this.PageNumber     = data.PageNumber;
 }