当前位置: 首页>>代码示例>>C#>>正文


C# BindingList.Skip方法代码示例

本文整理汇总了C#中BindingList.Skip方法的典型用法代码示例。如果您正苦于以下问题:C# BindingList.Skip方法的具体用法?C# BindingList.Skip怎么用?C# BindingList.Skip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BindingList的用法示例。


在下文中一共展示了BindingList.Skip方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RefreshChannels


//.........这里部分代码省略.........

            int days = FilterTime.ReturnNumberOfDays(_timefilter);
            channels = (days == -1) ? context.Channels : context.Channels.Where(a => (a.LastModified > (DateTime.UtcNow.Add(-TimeSpan.FromDays(days)))));

            if (!string.IsNullOrEmpty(_searchinname))
            {
                string searchlower = _searchinname.ToLower();
                channels = channels.Where(c => (c.Name.ToLower().Contains(searchlower) || c.Id.ToLower().Contains(searchlower)));
            }

            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 = c.EncodingType != ChannelEncodingType.None ? EncodingImage : null,
                                       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 = c.EncodingType != ChannelEncodingType.None ? EncodingImage : null,
                                       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 = c.EncodingType != ChannelEncodingType.None ? EncodingImage : null,
                                       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 = c.EncodingType != ChannelEncodingType.None ? EncodingImage : null,
                                       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));
        }
开发者ID:shushengli,项目名称:Azure-Media-Services-Explorer,代码行数:101,代码来源:live.cs

示例2: RefreshPrograms


//.........这里部分代码省略.........
                programs = programs.Where(p => (p.Name.ToLower().Contains(searchlower) || p.Id.ToLower().Contains(searchlower) || p.Asset.Id.ToLower().Contains(searchlower)));
            }

            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));
        }
开发者ID:shushengli,项目名称:Azure-Media-Services-Explorer,代码行数:101,代码来源:live.cs

示例3: Refreshjobs


//.........这里部分代码省略.........
            }
            else
            {
                jobsServerQuery = context.Jobs.Where(j =>
                                 (!filterStartDate || j.LastModified > dateTimeStart)
                                 &&
                                 (!filterEndDate || j.LastModified < dateTimeRangeEnd)
                                 &&
                                 (!filterstate || j.State == jobstate)
                                );
            }


            // SHORTCUT (needed for account with large number of jobs)
            if (_orderjobs == OrderJobs.LastModifiedDescending && (_timefilter == FilterTime.First50Items || _timefilter == FilterTime.First1000Items))
            {
                if (_timefilter == FilterTime.First50Items)
                {
                    jobs = jobsServerQuery.Take(50);
                }
                else if (_timefilter == FilterTime.First1000Items)
                {
                    jobs = jobsServerQuery.Take(1000);
                }
            }
            else // general case

            {
                // let's get all the results locally

                IList<IJob> aggregateListJobs = new List<IJob>();
                int skipSize = 0;
                int batchSize = 1000;
                int currentSkipSize = 0;
                while (true)
                {
                    // Enumerate through all jobs (1000 at a time)
                    var jobsq = jobsServerQuery
                        .Skip(skipSize).Take(batchSize).ToList();

                    currentSkipSize += jobsq.Count;

                    foreach (var j in jobsq)
                    {
                        aggregateListJobs.Add(j);
                    }

                    if (currentSkipSize == batchSize)
                    {
                        skipSize += batchSize;
                        currentSkipSize = 0;
                    }
                    else
                    {
                        break;
                    }
                }
                jobs = aggregateListJobs;



                switch (_orderjobs)
                {
                    case OrderJobs.LastModifiedDescending:
                        jobs = from j in jobs orderby j.LastModified descending select j;
                        break;
开发者ID:vaibhavkadian,项目名称:Azure-Media-Services-Explorer,代码行数:67,代码来源:Mainform.cs

示例4: RefreshStreamingEndpoints

        // all assets are refreshed
        public void RefreshStreamingEndpoints(CloudMediaContext context, int pagetodisplay)
        {
            if (!_initialized) return;

            this.BeginInvoke(new Action(() => this.FindForm().Cursor = Cursors.WaitCursor));
            //this.FindForm().Cursor = Cursors.WaitCursor;

            _context = context;

            IEnumerable<StreamingEndpointEntry> endpointquery;

            streamingendpoints = context.StreamingEndpoints;

            _context = context;
            _pagecount = (int)Math.Ceiling(((double)streamingendpoints.Count()) / ((double)_originsperpage));
            if (_pagecount == 0) _pagecount = 1; // no asset but one page

            if (pagetodisplay < 1) pagetodisplay = 1;
            if (pagetodisplay > _pagecount) pagetodisplay = _pagecount;
            _currentpage = pagetodisplay;

            try
            {
                int c = streamingendpoints.Count();
            }
            catch (Exception e)
            {
                MessageBox.Show("There is a problem when connecting to Azure Media Services. Application will close. " + e.Message);
                Environment.Exit(0);
            }

            switch (_orderstreamingendpoints)
            {
                case OrderStreamingEndpoints.LastModified:
                default:
                    streamingendpoints = from c in streamingendpoints
                                         orderby c.LastModified descending
                                         select c;
                    break;

                case OrderStreamingEndpoints.Name:
                    streamingendpoints = from c in streamingendpoints
                                         orderby c.Name
                                         select c;
                    break;

                case OrderStreamingEndpoints.State:
                    streamingendpoints = from c in streamingendpoints
                                         orderby c.State
                                         select c;
                    break;

                case OrderStreamingEndpoints.ScaleUnits:
                    streamingendpoints = from c in streamingendpoints
                                         orderby c.ScaleUnits
                                         select c;
                    break;
            }

            endpointquery = from c in streamingendpoints
                            select new StreamingEndpointEntry
                            {
                                Name = c.Name,
                                Id = c.Id,
                                Description = c.Description,
                                CDN = c.CdnEnabled ? "CDN" : string.Empty,
                                ScaleUnits = c.ScaleUnits,
                                State = c.State,
                                LastModified = c.LastModified.ToLocalTime(),
                            };

            _MyObservStreamingEndpoints = new BindingList<StreamingEndpointEntry>(endpointquery.ToList());
            _MyObservStreamingEndpointthisPage = new BindingList<StreamingEndpointEntry>(_MyObservStreamingEndpoints.Skip(_originsperpage * (_currentpage - 1)).Take(_originsperpage).ToList());
            this.BeginInvoke(new Action(() => this.DataSource = _MyObservStreamingEndpointthisPage));
            _refreshedatleastonetime = true;
            this.BeginInvoke(new Action(() => this.FindForm().Cursor = Cursors.Default));
        }
开发者ID:websider,项目名称:Azure-Media-Services-Explorer,代码行数:78,代码来源:StreamingEndpoint.cs

示例5: Refreshjobs


//.........这里部分代码省略.........
                string searchlower = _searchinname.ToLower();
                jobs = jobs.Where(j => (j.Name.ToLower().Contains(searchlower) || j.Id.ToLower().Contains(searchlower)));
            }

            switch (_orderjobs)
            {
                case OrderJobs.LastModifiedDescending:
                    jobs = from j in jobs orderby j.LastModified descending select j;
                    break;

                case OrderJobs.LastModifiedAscending:
                    jobs = from j in jobs orderby j.LastModified ascending select j;
                    break;

                case OrderJobs.NameDescending:
                    jobs = from j in jobs orderby j.Name descending select j;
                    break;

                case OrderJobs.NameAscending:
                    jobs = from j in jobs orderby j.Name ascending select j;
                    break;

                case OrderJobs.EndTimeDescending:
                    jobs = from j in jobs orderby j.EndTime descending select j;
                    break;

                case OrderJobs.EndTimeAscending:
                    jobs = from j in jobs orderby j.EndTime ascending select j;
                    break;

                case OrderJobs.ProcessTimeDescending:
                    jobs = from j in jobs orderby j.RunningDuration descending select j;
                    break;

                case OrderJobs.ProcessTimeAscending:
                    jobs = from j in jobs orderby j.RunningDuration ascending select j;
                    break;

                case OrderJobs.StartTimeDescending:
                    jobs = from j in jobs orderby j.StartTime descending select j;
                    break;

                case OrderJobs.StartTimeAscending:
                    jobs = from j in jobs orderby j.StartTime ascending select j;
                    break;

                case OrderJobs.StateDescending:
                    jobs = from j in jobs orderby j.State descending select j;
                    break;

                case OrderJobs.StateAscending:
                    jobs = from j in jobs orderby j.State ascending select j;
                    break;

                default:
                    jobs = from j in jobs orderby j.LastModified descending select j;
                    break;
            }

            if ((!string.IsNullOrEmpty(_timefilter)) && _timefilter == FilterTime.First50Items)
            {
                jobs = jobs.Take(50);
            }

            _context = context;
            _pagecount = (int)Math.Ceiling(((double)jobs.Count()) / ((double)_jobsperpage));
            if (_pagecount == 0) _pagecount = 1; // no asset but one page

            if (pagetodisplay < 1) pagetodisplay = 1;
            if (pagetodisplay > _pagecount) pagetodisplay = _pagecount;
            _currentpage = pagetodisplay;

            try
            {
                jobquery = from j in jobs
                           select new JobEntry
                           {
                               Name = j.Name,
                               Id = j.Id,
                               Tasks = j.Tasks.Count,
                               Priority = j.Priority,
                               State = j.State,
                               StartTime = j.StartTime.HasValue ? (Nullable<DateTime>)((DateTime)j.StartTime).ToLocalTime() : null,
                               EndTime = j.EndTime.HasValue ? ((DateTime)j.EndTime).ToLocalTime().ToString() : null,
                               Duration = (j.StartTime.HasValue && j.EndTime.HasValue) ? ((DateTime)j.EndTime).Subtract((DateTime)j.StartTime).ToString(@"d\.hh\:mm\:ss") : string.Empty,
                               Progress = (j.State == JobState.Scheduled || j.State == JobState.Processing || j.State == JobState.Queued) ? j.GetOverallProgress() : 101d
                           };
                _MyObservJob = new BindingList<JobEntry>(jobquery.ToList());
            }
            catch (Exception e)
            {
                MessageBox.Show("There is a problem when connecting to Azure Media Services. Application will close. " + Constants.endline + Program.GetErrorMessage(e));
                Environment.Exit(0);
            }

            _MyObservAssethisPage = new BindingList<JobEntry>(_MyObservJob.Skip(_jobsperpage * (_currentpage - 1)).Take(_jobsperpage).ToList());
            this.BeginInvoke(new Action(() => this.DataSource = _MyObservAssethisPage));
            _refreshedatleastonetime = true;
            this.FindForm().Cursor = Cursors.Default;
        }
开发者ID:mkc-rongk,项目名称:Azure-Media-Services-Explorer,代码行数:101,代码来源:Mainform.cs

示例6: RefreshAssets

        public void RefreshAssets(CloudMediaContext context, int pagetodisplay) // all assets are refreshed
        {
            if (!_initialized) return;
            Debug.WriteLine("RefreshAssets Start");

            if (WorkerAnalyzeAssets.IsBusy)
            {
                // cancel the analyze.
                WorkerAnalyzeAssets.CancelAsync();
            }
            this.FindForm().Cursor = Cursors.WaitCursor;


            // 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;
                }
            }

            IQueryable<IAsset> assetsServerQuery = null;// = context.Assets.AsQueryable(); ;
            bool SwitchedToLocalQuery = false;

            ///////////////////////
            // SEARCH
            ///////////////////////
            if (_searchinname != null && !string.IsNullOrEmpty(_searchinname.Text))
            {
                bool Error = false;
                int skipSize = 0;
                int batchSize = 1000;
                int currentSkipSize = 0;
                string strsearch = _searchinname.Text.ToLower();

                switch (_searchinname.SearchType)
                {
                    // Search on Asset name
                    case SearchIn.AssetName:

                        assetsServerQuery = context.Assets.Where(a =>
                                (a.Name.Contains(_searchinname.Text))
                                &&
                                (!filterStartDate || a.LastModified > dateTimeStart)
                                &&
                                (!filterEndDate || a.LastModified < dateTimeRangeEnd)
                                );
                        /*
                        if (assetsServerQuery.Count() > 1000) // we need to paginate
                        {

                        IList<IAsset> newAssetList = new List<IAsset>();

                        while (true)
                        {
                            // Enumerate through all assets (1000 at a time)
                                var assetsq = assetsServerQuery
                                .Skip(skipSize).Take(batchSize).ToList();

                            currentSkipSize += assetsq.Count;

                            foreach (var a in assetsq)
                            {
                                newAssetList.Add(a);
                            }

                            if (currentSkipSize == batchSize)
                            {
                                skipSize += batchSize;
                                currentSkipSize = 0;
                            }
                            else
                            {
                                break;
                            }
                        }

                        SwitchedToLocalQuery = true;
                        assets = newAssetList;
                        }
                        */
                        break;

                    // Search on Asset aternate id
//.........这里部分代码省略.........
开发者ID:vaibhavkadian,项目名称:Azure-Media-Services-Explorer,代码行数:101,代码来源:Mainform.cs

示例7: RefreshAssets


//.........这里部分代码省略.........
                        assets = assets.Where(a => a.Options == AssetCreationOptions.None);
                        break;
                    case StatusAssets.DynEnc:
                        assets = assets.Where(a => a.DeliveryPolicies.Any());
                        break;
                    case StatusAssets.Streamable:
                        assets = assets.Where(a => a.IsStreamable);
                        break;
                    case StatusAssets.SupportDynEnc:
                        assets = assets.Where(a => a.SupportsDynamicEncryption);
                        break;
                    case StatusAssets.Empty:
                        assets = assets.Where(a => a.AssetFiles.Count() == 0);
                        break;
                    case StatusAssets.DefaultStorage:
                        assets = assets.Where(a => a.StorageAccountName == _context.DefaultStorageAccount.Name);
                        break;
                    case StatusAssets.NotDefaultStorage:
                        assets = assets.Where(a => a.StorageAccountName != _context.DefaultStorageAccount.Name);
                        break;
                    default:
                        break;
                }
            }

            var size = new Func<IAsset, long>(AssetInfo.GetSize);

            switch (_orderassets)
            {
                case OrderAssets.LastModifiedDescending:
                    assets = from a in assets orderby a.LastModified descending select a;
                    break;

                case OrderAssets.LastModifiedAscending:
                    assets = from a in assets orderby a.LastModified ascending select a;
                    break;

                case OrderAssets.NameAscending:
                    assets = from a in assets orderby a.Name ascending select a;
                    break;

                case OrderAssets.NameDescending:
                    assets = from a in assets orderby a.Name descending select a;
                    break;

                case OrderAssets.SizeDescending:
                    assets = from a in assets orderby size(a) descending select a;
                    break;

                case OrderAssets.SizeAscending:
                    assets = from a in assets orderby size(a) ascending select a;
                    break;

                case OrderAssets.LocatorExpirationAscending:
                    assets = from a in assets where a.Locators.Any() orderby a.Locators.Min(l => l.ExpirationDateTime) ascending select a;
                    break;

                case OrderAssets.LocatorExpirationDescending:
                    assets = from a in assets where a.Locators.Any() orderby a.Locators.Min(l => l.ExpirationDateTime) descending select a;
                    break;

                default:
                    assets = from a in assets orderby a.LastModified descending select a;
                    break;
            }


            if ((!string.IsNullOrEmpty(_timefilter)) && _timefilter == FilterTime.First50Items)
            {
                assets = assets.Take(50);
            }

            _context = context;
            _pagecount = (int)Math.Ceiling(((double)assets.Count()) / ((double)_assetsperpage));
            if (_pagecount == 0) _pagecount = 1; // no asset but one page

            if (pagetodisplay < 1) pagetodisplay = 1;
            if (pagetodisplay > _pagecount) pagetodisplay = _pagecount;
            _currentpage = pagetodisplay;

            try
            {
                assetquery = from a in assets
                             select new AssetEntry { Name = a.Name, Id = a.Id, Type = null, LastModified = ((DateTime)a.LastModified).ToLocalTime(), Storage = a.StorageAccountName };
                _MyObservAsset = new BindingList<AssetEntry>(assetquery.ToList());
            }
            catch (Exception e)
            {
                MessageBox.Show("There is a problem when connecting to Azure Media Services. Application will close. " + Constants.endline + Program.GetErrorMessage(e));
                Environment.Exit(0);
            }

            BindingList<AssetEntry> MyObservAssethisPage = new BindingList<AssetEntry>(_MyObservAsset.Skip(_assetsperpage * (_currentpage - 1)).Take(_assetsperpage).ToList());
            this.BeginInvoke(new Action(() => this.DataSource = MyObservAssethisPage));
            _refreshedatleastonetime = true;

            AnalyzeItemsInBackground();

            this.FindForm().Cursor = Cursors.Default;
        }
开发者ID:mkc-rongk,项目名称:Azure-Media-Services-Explorer,代码行数:101,代码来源:Mainform.cs

示例8: Refreshjobs


//.........这里部分代码省略.........
                                 (!filterstate || j.State == jobstate)
                                );
            }

            switch (_orderjobs)
            {
                case OrderJobs.LastModifiedDescending:
                    jobs = from j in jobs orderby j.LastModified descending select j;
                    break;

                case OrderJobs.LastModifiedAscending:
                    jobs = from j in jobs orderby j.LastModified ascending select j;
                    break;

                case OrderJobs.NameDescending:
                    jobs = from j in jobs orderby j.Name descending select j;
                    break;

                case OrderJobs.NameAscending:
                    jobs = from j in jobs orderby j.Name ascending select j;
                    break;

                case OrderJobs.EndTimeDescending:
                    jobs = from j in jobs orderby j.EndTime descending select j;
                    break;

                case OrderJobs.EndTimeAscending:
                    jobs = from j in jobs orderby j.EndTime ascending select j;
                    break;

                case OrderJobs.ProcessTimeDescending:
                    jobs = from j in jobs orderby j.RunningDuration descending select j;
                    break;

                case OrderJobs.ProcessTimeAscending:
                    jobs = from j in jobs orderby j.RunningDuration ascending select j;
                    break;

                case OrderJobs.StartTimeDescending:
                    jobs = from j in jobs orderby j.StartTime descending select j;
                    break;

                case OrderJobs.StartTimeAscending:
                    jobs = from j in jobs orderby j.StartTime ascending select j;
                    break;

                case OrderJobs.StateDescending:
                    jobs = from j in jobs orderby j.State descending select j;
                    break;

                case OrderJobs.StateAscending:
                    jobs = from j in jobs orderby j.State ascending select j;
                    break;

                default:
                    jobs = from j in jobs orderby j.LastModified descending select j;
                    break;
            }

            if ((!string.IsNullOrEmpty(_timefilter)) && _timefilter == FilterTime.First50Items)
            {
                jobs = jobs.Take(50);
            }

            _context = context;
            _pagecount = (int)Math.Ceiling(((double)jobs.Count()) / ((double)_jobsperpage));
            if (_pagecount == 0) _pagecount = 1; // no asset but one page

            if (pagetodisplay < 1) pagetodisplay = 1;
            if (pagetodisplay > _pagecount) pagetodisplay = _pagecount;
            _currentpage = pagetodisplay;

            try
            {
                jobquery = from j in jobs
                           select new JobEntry
                           {
                               Name = j.Name,
                               Id = j.Id,
                               Tasks = j.Tasks.Count,
                               Priority = j.Priority,
                               State = j.State,
                               StartTime = j.StartTime.HasValue ? (Nullable<DateTime>)((DateTime)j.StartTime).ToLocalTime() : null,
                               EndTime = j.EndTime.HasValue ? ((DateTime)j.EndTime).ToLocalTime().ToString() : null,
                               Duration = (j.StartTime.HasValue && j.EndTime.HasValue) ? ((DateTime)j.EndTime).Subtract((DateTime)j.StartTime).ToString(@"d\.hh\:mm\:ss") : string.Empty,
                               Progress = (j.State == JobState.Scheduled || j.State == JobState.Processing || j.State == JobState.Queued) ? j.GetOverallProgress() : 101d
                           };
                _MyObservJob = new BindingList<JobEntry>(jobquery.ToList());
            }
            catch (Exception e)
            {
                MessageBox.Show("There is a problem when connecting to Azure Media Services. Application will close. " + Constants.endline + Program.GetErrorMessage(e));
                Environment.Exit(0);
            }

            _MyObservAssethisPage = new BindingList<JobEntry>(_MyObservJob.Skip(_jobsperpage * (_currentpage - 1)).Take(_jobsperpage).ToList());
            this.BeginInvoke(new Action(() => this.DataSource = _MyObservAssethisPage));
            _refreshedatleastonetime = true;
            this.FindForm().Cursor = Cursors.Default;
        }
开发者ID:sk-bln,项目名称:Azure-Media-Services-Explorer,代码行数:101,代码来源:Mainform.cs

示例9: RefreshAssets


//.........这里部分代码省略.........
                        }
                        catch
                        {
                            Error = true;
                            MessageBox.Show("Error with program Id. Is it a valid GUID or program Id ?", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        if (!Error)
                        {
                            var queryprog = context.Programs.Where(p => p.Id == Constants.ProgramIdPrefix + programguid).FirstOrDefault();
                            if (queryprog != null)
                            {
                                assets = context.Assets.Where(a =>
                                                                   (!filterday || a.LastModified > datefilter)
                                                                   &&
                                                                   queryprog.AssetId == a.Id
                                                                   );
                            }
                            else
                            {
                                MessageBox.Show("No program was found with this Id.", "Not found", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }
                        }
                        break;

                    // Search on Program name
                    case SearchIn.ProgramName:
                        // we take only the first 1000 programs that contains the text. We could improve this by paging the query (to do)
                        var queryprog2 = context.Programs.Where(p => p.Name.ToLower().Contains(_searchinname.Text.ToLower())).AsEnumerable().Select(p => p.AssetId).ToList();

                        IList<IAsset> passets = new List<IAsset>();

                        int skipSizePr = 0;
                        int batchSizePr = 1000;
                        int currentSkipSizePr = 0;

                        while (true)
                        {
                            // Enumerate through all assets (1000 at a time)
                            var assetsq = context.Assets.Where(a =>
                                (!filterday || a.LastModified > datefilter))
                                .Skip(skipSizePr).Take(batchSizePr).ToList();

                            currentSkipSizePr += assetsq.Count;

                            var assetsq2 = assetsq.Where(a => queryprog2.Contains(a.Id)); // assets which are in the program query

                            foreach (var a in assetsq2)
                            {
                                passets.Add(a);
                            }

                            if (currentSkipSizePr == batchSizePr)
                            {
                                skipSizePr += batchSizePr;
                                currentSkipSizePr = 0;
                            }
                            else
                            {
                                break;
                            }
                        }
                        assets = passets;
                        break;


                    default:
开发者ID:sk-bln,项目名称:Azure-Media-Services-Explorer,代码行数:67,代码来源:Mainform.cs

示例10: RefreshPrograms


//.........这里部分代码省略.........
                                              );

                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");
        }
开发者ID:sk-bln,项目名称:Azure-Media-Services-Explorer,代码行数:101,代码来源:live.cs

示例11: RefreshChannels


//.........这里部分代码省略.........
                    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));
        }
开发者ID:sk-bln,项目名称:Azure-Media-Services-Explorer,代码行数:101,代码来源:live.cs


注:本文中的BindingList.Skip方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。