public void NeedRefreshMatrix () { if ((DateTime.UtcNow - _lastQueryTime).Seconds < 3) return; if (string.IsNullOrEmpty (SelectedObjectId)) return; _lastQueryTime = DateTime.UtcNow; int rowCount = 50; switch (SelectedRowCount) { case 1: rowCount = 100; break; case 2: rowCount = 300; break; } int goal = SelectedGoal; var queryString = WebAccessTestDataHelper.GetMatrixParameterString (SelectedObjectId, EndDate, goal, rowCount, IsRedColor, IsGreenColor, IsYellowColor); var shortQueryString = WebAccessTestDataHelper.GetMatrixShortParameterString (SelectedObjectId, EndDate, goal, rowCount, IsRedColor, IsGreenColor, IsYellowColor); var parameters = new MatrixParameters () { QueryString = queryString, ShortQueryString = shortQueryString, Goal = SelectedGoal, RowCount = SelectedRowCount, }; UpdatePresentationProperties (); RefreshMatrix (parameters); }
private async Task RefreshMatrix (MatrixParameters parameters) { if (_matrixControl != null) { _matrixControl.SetFilterProperties (parameters.Goal, parameters.RowCount); if (LastSelectedControl != null) { LastSelectedControl.IsSelected = false; LastSelectedControl = null; } UpdateSelectedItem (null); _view.SetAnimation (true); string jsonString = ""; MatrixCacheItem cacheItem = null; ShowAnimation (); if (CrossConnectivity.Current.IsConnected) { var responce = await WebAccessTestDataHelper.GetMatrixData (parameters.QueryString); jsonString = responce.JsonData; if (!string.IsNullOrEmpty (jsonString)) { cacheItem = new MatrixCacheItem () { Created = DateTime.UtcNow, QueryString = parameters.ShortQueryString, JsonData = jsonString }; await _repository.AddOrUpdateItem (cacheItem); } else { if (responce.Status == HttpStatusCode.Unauthorized) { await _notificator.Notify (ToastNotificationType.Error, "Не удалось загрузить данные", "Неверный логин или пароль", TimeSpan.FromSeconds (2)); GoToLoginCommand.Execute (null); } } } else { cacheItem = await _repository.GetMatrixCacheItemByQueryString (parameters.ShortQueryString); if (cacheItem != null) jsonString = cacheItem.JsonData; } TreeMapRootGroup data = null; if (!string.IsNullOrEmpty (jsonString)) data = JsonConvert.DeserializeObject<TreeMapRootGroup> (jsonString); else data = new TreeMapRootGroup (); _matrixControl.DrawMatrix (data); var tableData = GetTableData (data); _tableView.FillTable (tableData); _view.SetAnimation (false); HideAnimation (); } }