protected override void OnClosed(EventArgs e) { base.OnClosed(e); SystemTray.HideSystemTrayIcon(); _autoRefresh.CallDispose(); _tabIcons.CallDispose(); }
public void Reload() { this.connectionError.Visible = Network.NetworkStatus != Util.ConnectionOKStatus; this.errorMessage.Text = Network.NetworkMessage; if (Network.NetworkStatus != Util.ConnectionOKStatus) { return; } var reload = DnsServiceManager.GetRequestList("filtered requests lookup", Network, Page * _pageSize, _pageSize, Network.Filter, _sortColumn, _isSortAscending) .TakeLast(1) .ObserveOn(this) .Select(list => { PageCount = list.TotalCount / _pageSize + (list.TotalCount == 0 || list.TotalCount % _pageSize > 0 ? 1 : 0); lblTotalPages.Text = PageCount.ToString(); if (Page > PageCount) { Page = PageCount; txtPageNumber.Text = (Page + 1).ToString(); } var selected = SelectedRequest; //update request statuses that have cached results that are awaiting upload - Pending Upload is a local status and is not known by the API foreach (var seg in list.Segment.Where(s => s.Status == DTO.DataMartClient.Enums.DMCRoutingStatus.Submitted || s.Status == DTO.DataMartClient.Enums.DMCRoutingStatus.Resubmitted)) { var cache = new Lib.Caching.DocumentCacheManager(Network.NetworkId, seg.DataMartID, seg.ID, seg.ResponseID); if (cache.HasResponseDocuments) { seg.Status = DTO.DataMartClient.Enums.DMCRoutingStatus.PendingUpload; } } dgvRequestList.DataSource = list.Segment; SelectedRequest = selected == null ? null : list.Segment.FirstOrDefault(rq => rq.ID == selected.ID && rq.DataMartID == selected.DataMartID); DisplaySortGlyph(); EnableDisablePageButtons(); return(Unit.Default); }); var now = DateTime.Now; var newReqsLookup = DnsServiceManager.GetRequestList("new requests lookup", Network, 0, 1, new RequestFilter { DateRange = DateRangeKind.Exact, FromDate = _lastNewRequestsLookup }, null, null) .Take(1) .ObserveOn(this) .Select(n => { if (n.TotalCount > 0) { NewRequestsAvailable = true; } _lastNewRequestsLookup = now.AddMilliseconds(1); return(Unit.Default); }); var invFilter = InvertFilter(_lastInvisibleRequestsLookup); var invisibleReqsLookup = invFilter == null?Observable.Return(Unit.Default) : DnsServiceManager.GetRequestList("hidden requests lookup", Network, 0, 1, invFilter.Value, null, null) .Take(1) .ObserveOn(this) .Select(n => { if (n.TotalCount > 0) { InvisibleRequestsAvailable = true; } _lastInvisibleRequestsLookup = now.AddMilliseconds(1); return(Unit.Default); }); _currentReload.CallDispose(); _currentReload = Observable .Merge(reload, newReqsLookup, invisibleReqsLookup) .TakeLast(1) .Do(_ => { _currentReload = null; Reloaded.Raise(this); }) .Finally(() => _currentReload = null) .Catch((Exception ex) => { _log.Error(ex); Network.NetworkStatus = Util.ConnectionFailedStatus; errorMessage.Text = Network.NetworkMessage = ex.Message; connectionError.Show(); _currentReload = null; ReloadFailed.Raise(this); return(Observable.Empty <Unit>()); }) .Subscribe(); ReloadStarted.Raise(this); }
protected override void OnHandleDestroyed(EventArgs e) { _pageSizeReset.CallDispose(); base.OnHandleDestroyed(e); }
public void Reload() { this.connectionError.Visible = Network.NetworkStatus != Util.ConnectionOKStatus; this.errorMessage.Text = Network.NetworkMessage; if (Network.NetworkStatus != Util.ConnectionOKStatus) { return; } var reload = DnsServiceManager.GetRequestList(Network, Page * _pageSize, _pageSize, Network.Filter, _sortColumn, _isSortAscending) .TakeLast(1) .ObserveOn(this) .Select(list => { PageCount = list.TotalCount / _pageSize + (list.TotalCount == 0 || list.TotalCount % _pageSize > 0 ? 1 : 0); lblTotalPages.Text = PageCount.ToString(); if (Page > PageCount) { Page = PageCount; txtPageNumber.Text = (Page + 1).ToString(); } var selected = SelectedRequest; dgvRequestList.DataSource = list.Segment; SelectedRequest = selected == null ? null : list.Segment.FirstOrDefault(rq => rq.ID == selected.ID && rq.DataMartID == selected.DataMartID); DisplaySortGlyph(); EnableDisablePageButtons(); return(Unit.Default); }); var now = DateTime.Now; var newReqsLookup = DnsServiceManager.GetRequestList(Network, 0, 1, new RequestFilter { DateRange = DateRangeKind.Exact, FromDate = _lastNewRequestsLookup }, null, null) .Take(1) .ObserveOn(this) .Select(n => { if (n.TotalCount > 0) { NewRequestsAvailable = true; } _lastNewRequestsLookup = now.AddMilliseconds(1); return(Unit.Default); }); var invFilter = InvertFilter(_lastInvisibleRequestsLookup); var invisibleReqsLookup = invFilter == null?Observable.Return(Unit.Default) : DnsServiceManager.GetRequestList(Network, 0, 1, invFilter.Value, null, null) .Take(1) .ObserveOn(this) .Select(n => { if (n.TotalCount > 0) { InvisibleRequestsAvailable = true; } _lastInvisibleRequestsLookup = now.AddMilliseconds(1); return(Unit.Default); }); _currentReload.CallDispose(); _currentReload = Observable .Merge(reload, newReqsLookup, invisibleReqsLookup) .TakeLast(1) .Do(_ => { _currentReload = null; Reloaded.Raise(this); }) .Finally(() => _currentReload = null) .Catch((Exception ex) => { _log.Error(ex); Network.NetworkStatus = Util.ConnectionFailedStatus; errorMessage.Text = Network.NetworkMessage = ex.Message; connectionError.Show(); _currentReload = null; ReloadFailed.Raise(this); return(Observable.Empty <Unit>()); }) .Subscribe(); ReloadStarted.Raise(this); }