public void RefreshPrograms(CloudMediaContext context, int pagetodisplay) // all assets are refreshed { if (!_initialized) { return; } this.BeginInvoke(new Action(() => this.FindForm().Cursor = Cursors.WaitCursor)); _context = context; IEnumerable <ProgramEntry> programquery; int days = FilterTime.ReturnNumberOfDays(_timefilter); programs = (days == -1) ? context.Programs : context.Programs.Where(a => (a.LastModified > (DateTime.UtcNow.Add(-TimeSpan.FromDays(days))))); // search if (_searchinname != null && !string.IsNullOrEmpty(_searchinname.Text)) { switch (_searchinname.SearchType) { case SearchIn.ProgramName: programs = programs.Where(a => (a.Name.IndexOf(_searchinname.Text, StringComparison.OrdinalIgnoreCase) != -1) // for no case sensitive ); break; case SearchIn.ProgramId: programs = programs.Where(a => (a.Id.IndexOf(_searchinname.Text, StringComparison.OrdinalIgnoreCase) != -1) ); break; default: break; } } if (FilterState != "All") { programs = programs.Where(p => p.State == (ProgramState)Enum.Parse(typeof(ProgramState), _statefilter)); } switch (_orderitems) { case OrderPrograms.LastModified: programquery = programs.AsEnumerable().Where(p => idsList.Contains(p.ChannelId)).OrderByDescending(p => p.LastModified) .Join(_context.Channels.AsEnumerable(), p => p.ChannelId, c => c.Id, (p, c) => new ProgramEntry { Name = p.Name, Id = p.Id, Description = p.Description, ArchiveWindowLength = p.ArchiveWindowLength, State = p.State, LastModified = p.LastModified.ToLocalTime(), ChannelName = c.Name, ChannelId = c.Id, Published = p.Asset.Locators.Where(l => l.Type == LocatorType.OnDemandOrigin).Count() > 0 ? Streaminglocatorimage : null, }).ToArray(); break; case OrderPrograms.Name: programquery = programs.AsEnumerable().Where(p => idsList.Contains(p.ChannelId)).OrderBy(p => p.Name) .Join(_context.Channels.AsEnumerable(), p => p.ChannelId, c => c.Id, (p, c) => new ProgramEntry { Name = p.Name, Id = p.Id, Description = p.Description, ArchiveWindowLength = p.ArchiveWindowLength, State = p.State, LastModified = p.LastModified.ToLocalTime(), ChannelName = c.Name, ChannelId = c.Id, Published = p.Asset.Locators.Where(l => l.Type == LocatorType.OnDemandOrigin).Count() > 0 ? Streaminglocatorimage : null, }).ToArray(); break; case OrderPrograms.State: programquery = programs.AsEnumerable().Where(p => idsList.Contains(p.ChannelId)).OrderBy(p => p.State) .Join(_context.Channels.AsEnumerable(), p => p.ChannelId, c => c.Id, (p, c) => new ProgramEntry { Name = p.Name, Id = p.Id, Description = p.Description, ArchiveWindowLength = p.ArchiveWindowLength, State = p.State, LastModified = p.LastModified.ToLocalTime(), ChannelName = c.Name, ChannelId = c.Id, Published = p.Asset.Locators.Where(l => l.Type == LocatorType.OnDemandOrigin).Count() > 0 ? Streaminglocatorimage : null, }).ToArray(); break; default: programquery = programs.AsEnumerable().Where(p => idsList.Contains(p.ChannelId)) .Join(_context.Channels.AsEnumerable(), p => p.ChannelId, c => c.Id, (p, c) => new ProgramEntry { Name = p.Name, Id = p.Id, Description = p.Description, ArchiveWindowLength = p.ArchiveWindowLength, State = p.State, LastModified = p.LastModified.ToLocalTime(), ChannelName = c.Name, ChannelId = c.Id, Published = p.Asset.Locators.Where(l => l.Type == LocatorType.OnDemandOrigin).Count() > 0 ? Streaminglocatorimage : null, }).ToArray(); break; } if ((!string.IsNullOrEmpty(_timefilter)) && _timefilter == FilterTime.First50Items) { programquery = programquery.Take(50); } _MyObservPrograms = new BindingList <ProgramEntry>(programquery.ToList()); _MyObservProgramsthisPage = new BindingList <ProgramEntry>(_MyObservPrograms.Skip(_itemssperpage * (_currentpage - 1)).Take(_itemssperpage).ToList()); this.BeginInvoke(new Action(() => this.DataSource = _MyObservProgramsthisPage)); _refreshedatleastonetime = true; this.BeginInvoke(new Action(() => this.FindForm().Cursor = Cursors.Default)); }
public void RefreshChannels(CloudMediaContext context, int pagetodisplay) // all assets are refreshed { if (!_initialized) { return; } this.BeginInvoke(new Action(() => this.FindForm().Cursor = Cursors.WaitCursor)); _context = context; IEnumerable <ChannelEntry> channelquery; int days = FilterTime.ReturnNumberOfDays(_timefilter); channels = (days == -1) ? context.Channels : context.Channels.Where(a => (a.LastModified > (DateTime.UtcNow.Add(-TimeSpan.FromDays(days))))); // search if (_searchinname != null && !string.IsNullOrEmpty(_searchinname.Text)) { switch (_searchinname.SearchType) { case SearchIn.ChannelName: channels = channels.Where(a => (a.Name.IndexOf(_searchinname.Text, StringComparison.OrdinalIgnoreCase) != -1) // for no case sensitive ); break; case SearchIn.ChannelId: channels = channels.Where(a => (a.Id.IndexOf(_searchinname.Text, StringComparison.OrdinalIgnoreCase) != -1) ); break; default: break; } } if (FilterState != "All") { channels = channels.Where(c => c.State == (ChannelState)Enum.Parse(typeof(ChannelState), _statefilter)); } switch (_orderitems) { case OrderChannels.LastModified: channelquery = from c in channels orderby c.LastModified descending select new ChannelEntry { Name = c.Name, Id = c.Id, Description = c.Description, InputProtocol = string.Format("{0} ({1})", Program.ReturnNameForProtocol(c.Input.StreamingProtocol), c.Input.Endpoints.Count), Encoding = ReturnChannelBitmap(c), InputUrl = c.Input.Endpoints.FirstOrDefault().Url, PreviewUrl = c.Preview.Endpoints.FirstOrDefault().Url, State = c.State, LastModified = c.LastModified.ToLocalTime() }; break; case OrderChannels.Name: channelquery = from c in channels orderby c.Name select new ChannelEntry { Name = c.Name, Id = c.Id, Description = c.Description, InputProtocol = string.Format("{0} ({1})", Program.ReturnNameForProtocol(c.Input.StreamingProtocol), c.Input.Endpoints.Count), Encoding = ReturnChannelBitmap(c), InputUrl = c.Input.Endpoints.FirstOrDefault().Url, PreviewUrl = c.Preview.Endpoints.FirstOrDefault().Url, State = c.State, LastModified = c.LastModified.ToLocalTime() }; break; case OrderChannels.State: channelquery = from c in channels orderby c.State select new ChannelEntry { Name = c.Name, Id = c.Id, Description = c.Description, InputProtocol = string.Format("{0} ({1})", Program.ReturnNameForProtocol(c.Input.StreamingProtocol), c.Input.Endpoints.Count), Encoding = ReturnChannelBitmap(c), InputUrl = c.Input.Endpoints.FirstOrDefault().Url, PreviewUrl = c.Preview.Endpoints.FirstOrDefault().Url, State = c.State, LastModified = c.LastModified.ToLocalTime() }; break; default: channelquery = from c in channels select new ChannelEntry { Name = c.Name, Id = c.Id, Description = c.Description, InputProtocol = string.Format("{0} ({1})", Program.ReturnNameForProtocol(c.Input.StreamingProtocol), c.Input.Endpoints.Count), Encoding = ReturnChannelBitmap(c), InputUrl = c.Input.Endpoints.FirstOrDefault().Url, PreviewUrl = c.Preview.Endpoints.FirstOrDefault().Url, State = c.State, LastModified = c.LastModified.ToLocalTime() }; break; } if ((!string.IsNullOrEmpty(_timefilter)) && _timefilter == FilterTime.First50Items) { channelquery = channelquery.Take(50); } _MyObservChannels = new BindingList <ChannelEntry>(channelquery.ToList()); _MyObservChannelthisPage = new BindingList <ChannelEntry>(_MyObservChannels.Skip(_channelsperpage * (_currentpage - 1)).Take(_channelsperpage).ToList()); this.BeginInvoke(new Action(() => this.DataSource = _MyObservChannelthisPage)); _refreshedatleastonetime = true; this.BeginInvoke(new Action(() => this.FindForm().Cursor = Cursors.Default)); }
public async Task RefreshAssetsAsync(int pagetodisplay) // all assets are refreshed { if (!_initialized) { return; } if (pagetodisplay == 1) { _currentPageNumberIsMax = false; } Debug.WriteLine("RefreshAssets Start"); if (WorkerAnalyzeAssets.IsBusy) { // cancel the analyze. WorkerAnalyzeAssets.CancelAsync(); } this.BeginInvoke(new Action(() => this.FindForm().Cursor = Cursors.WaitCursor)); /* * * * Property * Name Filtering Ordering * Equals Greater than Less Than Ascending Descending * Name ✓ ✓ ✓ ✓ ✓ * Properties/AssetId ✓ * Properties/Created ✓ ✓ ✓ ✓ ✓ * Properties/LastModified * Properties/AlternateId ✓ * Properties/Description * Properties/Container * Properties/StorageId * * */ /////////////////////// // SORTING /////////////////////// var odataQuery = new ODataQuery <Asset>(); switch (_orderassets) { case OrderAssets.CreatedDescending: odataQuery.OrderBy = "Properties/Created desc"; break; case OrderAssets.CreatedAscending: odataQuery.OrderBy = "Properties/Created"; break; case OrderAssets.NameAscending: odataQuery.OrderBy = "Name"; break; case OrderAssets.NameDescending: odataQuery.OrderBy = "Name desc"; break; default: odataQuery.OrderBy = "Properties/Created desc"; break; } /////////////////////// // SEARCH /////////////////////// if (_searchinname != null && !string.IsNullOrEmpty(_searchinname.Text)) { string search = _searchinname.Text; switch (_searchinname.SearchType) { // Search on Asset name Equals case SearchIn.AssetNameEquals: search = "'" + search + "'"; odataQuery.Filter = "name eq " + search; break; // Search on Asset name starts with case SearchIn.AssetNameStartsWith: search = "'" + search + "'"; odataQuery.Filter = "name gt " + search.Substring(0, search.Length - 2) + char.ConvertFromUtf32(char.ConvertToUtf32(search, search.Length - 2) - 1) + new String('z', 262 - search.Length) + "'" + " and name lt " + search.Substring(0, search.Length - 2) + char.ConvertFromUtf32(char.ConvertToUtf32(search, search.Length - 2) + 1) + "'"; break; // Search on Asset name Greater than case SearchIn.AssetNameGreaterThan: search = "'" + search + "'"; odataQuery.Filter = "name gt " + search; break; // Search on Asset name Less than case SearchIn.AssetNameLessThan: search = "'" + search + "'"; odataQuery.Filter = "name lt " + search; break; // Search on Asset aternate id case SearchIn.AssetAltId: search = "'" + search + "'"; odataQuery.Filter = "properties/alternateid eq " + search; break; case SearchIn.AssetId: odataQuery.Filter = "properties/assetid eq " + search; break; default: break; } } // DAYS bool filterStartDate = false; bool filterEndDate = false; DateTime dateTimeStart = DateTime.UtcNow; DateTime dateTimeRangeEnd = DateTime.UtcNow.AddDays(1); int days = FilterTime.ReturnNumberOfDays(_timefilter); if (days > 0) { filterStartDate = true; dateTimeStart = (DateTime.UtcNow.Add(-TimeSpan.FromDays(days))); } else if (days == -1) // TimeRange { filterStartDate = true; filterEndDate = true; dateTimeStart = _timefilterTimeRange.StartDate; if (_timefilterTimeRange.EndDate != null) // there is an end time { dateTimeRangeEnd = (DateTime)_timefilterTimeRange.EndDate; } } if (filterStartDate) { if (odataQuery.Filter != null) { odataQuery.Filter = odataQuery.Filter + " and "; } odataQuery.Filter = odataQuery.Filter + $"properties/created gt {dateTimeStart.ToString("o")}"; } if (filterEndDate) { if (odataQuery.Filter != null) { odataQuery.Filter = odataQuery.Filter + " and "; } odataQuery.Filter = odataQuery.Filter + $"properties/created lt {dateTimeRangeEnd.ToString("o")}"; } IPage <Asset> currentPage = null; await _client.RefreshTokenIfNeededAsync(); if (pagetodisplay == 1) { firstpage = await _client.AMSclient.Assets.ListAsync(_client.credentialsEntry.ResourceGroup, _client.credentialsEntry.AccountName, odataQuery); currentPage = firstpage; } else { currentPage = firstpage; _currentPageNumber = 1; while (currentPage.NextPageLink != null && pagetodisplay > _currentPageNumber) { _currentPageNumber++; currentPage = await _client.AMSclient.Assets.ListNextAsync(currentPage.NextPageLink); } if (currentPage.NextPageLink == null) { _currentPageNumberIsMax = true; // we reached max } } /* * var assets = currentPage.Select(a => new AssetEntryV3 * { * Name = a.Name, * Description = a.Description, * AssetId = a.AssetId, * AlternateId = a.AlternateId, * Created = ((DateTime)a.Created).ToLocalTime().ToString("G"), * StorageAccountName = a.StorageAccountName * } * ); */ var assets = currentPage.Select(a => (cacheAssetentriesV3.ContainsKey(a.Name) && cacheAssetentriesV3[a.Name].LastModified != null && (cacheAssetentriesV3[a.Name].LastModified == a.LastModified.ToLocalTime().ToString("G")) ? cacheAssetentriesV3[a.Name] : new AssetEntryV3 { Name = a.Name, Description = a.Description, AssetId = a.AssetId, AlternateId = a.AlternateId, Created = ((DateTime)a.Created).ToLocalTime().ToString("G"), LastModified = ((DateTime)a.LastModified).ToLocalTime().ToString("G"), StorageAccountName = a.StorageAccountName } )); _MyObservAssetV3 = new BindingList <AssetEntryV3>(assets.ToList()); this.BeginInvoke(new Action(() => this.DataSource = _MyObservAssetV3)); Debug.WriteLine("RefreshAssets End"); AnalyzeItemsInBackground(); this.BeginInvoke(new Action(() => this.FindForm().Cursor = Cursors.Default)); }
public void RefreshPrograms(CloudMediaContext context, int pagetodisplay) // all assets are refreshed { if (!_initialized) { return; } if (idsList.Count == 0) { return; } Debug.WriteLine("RefreshPrograms : start"); this.BeginInvoke(new Action(() => this.FindForm().Cursor = Cursors.WaitCursor)); _context = context; IEnumerable <ProgramEntry> programquery; IQueryable <IProgram> programssrv = context.Programs; // DAYS int days = FilterTime.ReturnNumberOfDays(_timefilter); bool filterday = days != -1; DateTime datefilter = DateTime.UtcNow; if (filterday) { datefilter = (DateTime.UtcNow.Add(-TimeSpan.FromDays(days))); } // STATE bool pFilterOnState = FilterState != "All"; ProgramState myStateFilter = ProgramState.Running; if (pFilterOnState) { myStateFilter = (ProgramState)Enum.Parse(typeof(ProgramState), _statefilter); //programs = programs.Where(p => p.State == (ProgramState)Enum.Parse(typeof(ProgramState), _statefilter)); } bool bListEmpty = (idsList.Count == 0); // search if (_searchinname != null && !string.IsNullOrEmpty(_searchinname.Text)) { bool Error = false; switch (_searchinname.SearchType) { case SearchIn.ProgramName: programssrv = context.Programs.Where(p => (p.Name.ToLower().Contains(_searchinname.Text.ToLower())) && (!filterday || p.LastModified > datefilter) ); break; case SearchIn.ProgramId: string programguid = _searchinname.Text; if (programguid.StartsWith(Constants.ProgramIdPrefix)) { programguid = programguid.Substring(Constants.ProgramIdPrefix.Length); } try { var g = new Guid(programguid); } catch { Error = true; MessageBox.Show("Error with program Id. Is it a valid GUID or program Id ?", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } if (!Error) { programssrv = context.Programs.Where(p => (p.Id == Constants.ProgramIdPrefix + programguid) // no need to filter the date or ID as user request a specific ID ); } break; default: break; } } else { programssrv = context.Programs.Where(p => (!filterday || p.LastModified > datefilter) ); if (idsList.Count == 1 && !_anyChannel) { programssrv = programssrv.Where(p => p.ChannelId == idsList[0]); } else if (idsList.Count > 1 && !_anyChannel) { // let's build the query for all the IDs // The IQueryable data to query. IQueryable <IProgram> queryableData = programssrv.AsQueryable <IProgram>(); // Compose the expression tree that represents the parameter to the predicate. ParameterExpression pe = Expression.Parameter(typeof(IProgram), "p"); List <Expression> exp = new List <Expression>(); foreach (var s in idsList) { // ***** Where(p => p.ChannelId == "nb:chid:UUID:29aae99e-66d9-4a54-8cf0-8f652fd0f0ff" || p.ChannelId == "nb:chid:UUID:....)) ***** // Create an expression tree that represents the expression 'p.ChannelId == "nb:chid:UUID:2.... Expression left = Expression.Property(pe, typeof(IProgram).GetProperty("ChannelId")); Expression right = Expression.Constant(s); exp.Add(Expression.Equal(left, right)); } // Combine the expression trees to create an expression tree that represents the Expression predicateBody = Expression.OrElse(exp[0], exp[1]); for (int i = 2; i < idsList.Count; i++) { predicateBody = Expression.OrElse(predicateBody, exp[i]); } // Create an expression tree that represents the expression MethodCallExpression whereCallExpression = Expression.Call( typeof(Queryable), "Where", new Type[] { queryableData.ElementType }, queryableData.Expression, Expression.Lambda <Func <IProgram, bool> >(predicateBody, new ParameterExpression[] { pe })); // ***** End Where ***** // Create an executable query from the expression tree. programssrv = queryableData.Provider.CreateQuery <IProgram>(whereCallExpression); } } // Sorting switch (_orderitems) { case OrderPrograms.LastModified: programssrv = programssrv.OrderByDescending(p => p.LastModified); break; case OrderPrograms.Name: programssrv = programssrv.OrderBy(p => p.Name); break; case OrderPrograms.State: programssrv = programssrv.OrderBy(p => p.State); break; default: break; } IEnumerable <IProgram> programs = programssrv.AsEnumerable(); // local query now if (pFilterOnState) { programs = programs.Where(p => p.State.Equals(myStateFilter)); // this query has to be locally. Not supported on the server } if ((!string.IsNullOrEmpty(_timefilter)) && _timefilter == FilterTime.First50Items) { programs = programs.Take(50); } programquery = programs.Select(p => new ProgramEntry { Name = p.Name, Id = p.Id, Description = p.Description, ArchiveWindowLength = p.ArchiveWindowLength, State = p.State, LastModified = p.LastModified.ToLocalTime(), ChannelName = p.Channel.Name, ChannelId = p.Channel.Id, Published = p.Asset.Locators.Where(l => l.Type == LocatorType.OnDemandOrigin).Count() > 0 ? Streaminglocatorimage : null, }); _MyObservPrograms = new BindingList <ProgramEntry>(programquery.ToList()); _MyObservProgramsthisPage = new BindingList <ProgramEntry>(_MyObservPrograms.Skip(_itemssperpage * (_currentpage - 1)).Take(_itemssperpage).ToList()); this.BeginInvoke(new Action(() => this.DataSource = _MyObservProgramsthisPage)); _refreshedatleastonetime = true; this.BeginInvoke(new Action(() => this.FindForm().Cursor = Cursors.Default)); Debug.WriteLine("RefreshPrograms : end"); }
public void RefreshChannels(CloudMediaContext context, int pagetodisplay) // all assets are refreshed { if (!_initialized) { return; } this.BeginInvoke(new Action(() => this.FindForm().Cursor = Cursors.WaitCursor)); _context = context; IEnumerable <ChannelEntry> channelquery; // DAYS int days = FilterTime.ReturnNumberOfDays(_timefilter); bool filterday = days != -1; DateTime datefilter = DateTime.UtcNow; if (filterday) { datefilter = (DateTime.UtcNow.Add(-TimeSpan.FromDays(days))); } // STATE bool filterstate = FilterState != "All"; ChannelState channelstate = ChannelState.Running; if (filterstate) { channelstate = (ChannelState)Enum.Parse(typeof(ChannelState), FilterState); } IQueryable <IChannel> channelssrv = context.Channels; // search if (_searchinname != null && !string.IsNullOrEmpty(_searchinname.Text)) { bool Error = false; switch (_searchinname.SearchType) { case SearchIn.ChannelName: channelssrv = context.Channels.Where(c => (c.Name.ToLower().Contains(_searchinname.Text.ToLower())) && (!filterday || c.LastModified > datefilter) ); break; case SearchIn.ChannelId: string channelguid = _searchinname.Text; if (channelguid.StartsWith(Constants.ChannelIdPrefix)) { channelguid = channelguid.Substring(Constants.ChannelIdPrefix.Length); } try { var g = new Guid(channelguid); } catch { Error = true; MessageBox.Show("Error with channel Id. Is it a valid GUID or channel Id ?", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } if (!Error) { channelssrv = context.Channels.Where(c => (c.Id == Constants.ChannelIdPrefix + channelguid) && (!filterday || c.LastModified > datefilter) ); } break; default: break; } } else { channelssrv = context.Channels.Where(c => (!filterday || c.LastModified > datefilter) ); } switch (_orderitems) { case OrderChannels.LastModified: channelssrv = channelssrv.OrderByDescending(p => p.LastModified); break; case OrderChannels.Name: channelssrv = channelssrv.OrderBy(p => p.LastModified); break; case OrderChannels.State: channelssrv = channelssrv.OrderBy(p => p.State); break; default: break; } IEnumerable <IChannel> channels = channelssrv.AsEnumerable(); // local query now if (filterstate) { channels = channels.Where(c => c.State == channelstate); // this query has to be locally. Not supported on the server } if ((!string.IsNullOrEmpty(_timefilter)) && _timefilter == FilterTime.First50Items) { channels = channels.Take(50); } channelquery = channels.Select(c => new ChannelEntry { Name = c.Name, Id = c.Id, Description = c.Description, InputProtocol = string.Format("{0} ({1})", Program.ReturnNameForProtocol(c.Input.StreamingProtocol), c.Input.Endpoints.Count), Encoding = ReturnChannelBitmap(c), InputUrl = c.Input.Endpoints.FirstOrDefault().Url, PreviewUrl = c.Preview.Endpoints.FirstOrDefault().Url, State = c.State, LastModified = c.LastModified.ToLocalTime() }); _MyObservChannels = new BindingList <ChannelEntry>(channelquery.ToList()); _MyObservChannelthisPage = new BindingList <ChannelEntry>(_MyObservChannels.Skip(_channelsperpage * (_currentpage - 1)).Take(_channelsperpage).ToList()); this.BeginInvoke(new Action(() => this.DataSource = _MyObservChannelthisPage)); _refreshedatleastonetime = true; this.BeginInvoke(new Action(() => this.FindForm().Cursor = Cursors.Default)); }
public async Task RefreshjobsAsync(int pagetodisplay) // all jobs are refreshed { if ((!_initialized) || _transformName.Count == 0) { return; } Debug.WriteLine("Refresh Jobs Start"); this.BeginInvoke(new Action(() => this.FindForm().Cursor = Cursors.WaitCursor)); /////////////////////// // SORTING /////////////////////// var odataQuery = new ODataQuery <Job>(); switch (_orderjobs) { case OrderJobs.CreatedDescending: odataQuery.OrderBy = "Properties/Created desc"; break; case OrderJobs.CreatedAscending: odataQuery.OrderBy = "Properties/Created"; break; case OrderJobs.NameAscending: odataQuery.OrderBy = "Name"; break; case OrderJobs.NameDescending: odataQuery.OrderBy = "Name desc"; break; default: odataQuery.OrderBy = "Properties/Created desc"; break; } /////////////////////// // Filter /////////////////////// switch (_filterjobsstate) { case "All": break; default: odataQuery.Filter = string.Format("Properties/state eq Microsoft.Media.JobState'{0}'", _filterjobsstate); break; } // DAYS bool filterStartDate = false; bool filterEndDate = false; DateTime dateTimeStart = DateTime.UtcNow; DateTime dateTimeRangeEnd = DateTime.UtcNow.AddDays(1); int days = FilterTime.ReturnNumberOfDays(_timefilter); if (days > 0) { filterStartDate = true; dateTimeStart = (DateTime.UtcNow.Add(-TimeSpan.FromDays(days))); } else if (days == -1) // TimeRange { filterStartDate = true; filterEndDate = true; dateTimeStart = _timefilterTimeRange.StartDate; if (_timefilterTimeRange.EndDate != null) // there is an end time { dateTimeRangeEnd = (DateTime)_timefilterTimeRange.EndDate; } } if (filterStartDate) { if (odataQuery.Filter != null) { odataQuery.Filter = odataQuery.Filter + " and "; } odataQuery.Filter = odataQuery.Filter + $"Properties/Created gt {dateTimeStart.ToString("o")}"; } if (filterEndDate) { if (odataQuery.Filter != null) { odataQuery.Filter = odataQuery.Filter + " and "; } odataQuery.Filter = odataQuery.Filter + $"Properties/Created lt {dateTimeRangeEnd.ToString("o")}"; } // Paging await _client.RefreshTokenIfNeededAsync(); IPage <Job> currentPage = null; var transform = _transformName.First(); if (pagetodisplay == 1) { firstpage = await _client.AMSclient.Jobs.ListAsync(_client.credentialsEntry.ResourceGroup, _client.credentialsEntry.AccountName, transform, odataQuery); currentPage = firstpage; } else { currentPage = firstpage; _currentPageNumber = 1; while (currentPage.NextPageLink != null && pagetodisplay > _currentPageNumber) { _currentPageNumber++; currentPage = await _client.AMSclient.Jobs.ListNextAsync(currentPage.NextPageLink); } if (currentPage.NextPageLink == null) { _currentPageNumberIsMax = true; // we reached max } } var jobs = currentPage.Select(a => new JobEntryV3 { Name = a.Name, Description = a.Description, LastModified = ((DateTime)a.LastModified).ToLocalTime().ToString("G"), TransformName = transform, Outputs = a.Outputs.Count, Priority = a.Priority, State = a.State, Progress = ReturnProgressJob(a).progress // progress; we don't want the progress bar to be displayed } ); _MyObservJobV3 = new BindingList <JobEntryV3>(jobs.ToList()); this.BeginInvoke(new Action(() => this.DataSource = _MyObservJobV3)); Debug.WriteLine("RefreshJobs End"); RestoreJobProgress(new List <string> { transform }); this.BeginInvoke(new Action(() => this.FindForm().Cursor = Cursors.Default)); }