Beispiel #1
0
        public async Task <string> GetCalls(string token)
        {
            Console.WriteLine(".. GetCallsFromPremise .. " + DateTime.Now);


            string result      = string.Empty;
            var    beginPeriod = await GetSyncStartTime();

            var endPeriod = DateTime.UtcNow;

            DynamicQueryRequest requestBody = new DynamicQueryRequest
            {
                Period = new Period
                {
                    BeginPeriod = beginPeriod,
                    EndPeriod   = endPeriod,
                }
            };

            if (string.IsNullOrEmpty(_authentication.Token))
            {
                await _authentication.Authenticate();
            }

            var _apiClient = _httpClientFactory.CreateClient("recorder");

            _apiClient.DefaultRequestHeaders.Add("Impact360AuthToken", _authentication.Token);

            var response = await _apiClient.PostAsJsonAsync <DynamicQueryRequest>("/DASWebAPI/Query/ExecuteDynamicQuery", requestBody);

            if (response.StatusCode == System.Net.HttpStatusCode.Unauthorized)
            {
                AuthToken authToken = await _authentication.Authenticate();

                token = authToken.token;
                return(await GetCalls(token));
            }

            response.EnsureSuccessStatusCode();

            result = await response.Content.ReadAsStringAsync();

            Console.WriteLine(".. RetrivedCallsFromPremise .. " + DateTime.Now);

            await UpdateState(requestBody);

            return(result);
        }
Beispiel #2
0
        public async Task UpdateState(DynamicQueryRequest requestBody)
        {
            SyncState state = new SyncState
            {
                TenantId         = _settings.TenantId,
                LastSyncTimeUtc  = (DateTime)requestBody.Period.BeginPeriod,
                StartSyncTimeUtc = (DateTime)requestBody.Period.EndPeriod,
                SyncFinished     = false
            };


            var filter = Builders <SyncState> .Filter.Eq(c => c.TenantId, _settings.TenantId);

            var updateOptions = new UpdateOptions()
            {
                IsUpsert = true
            };

            await _context.SyncState.ReplaceOneAsync(filter, state, updateOptions);
        }
Beispiel #3
0
 public ActionResult <NGPResponse <dynamic> > QueryDynamicSingleData(DynamicQueryRequest query)
 {
     return(Ok(_dynamicDataService.QueryDynamicSingleData(query)));
 }