コード例 #1
0
 public IEnumerable <Ruleset> GetRuleSets()
 {
     return(_rulesRepository.GetAll <Ruleset>()
            .OrderBy(r => r.Name)
            .ThenBy(r => r.MajorVersion)
            .ThenBy(r => r.MinorVersion)
            .ToList());
 }
コード例 #2
0
 public ActionResult <List <ManagementRule> > Get() => _rulesRepository.GetAll();
コード例 #3
0
 public List <Rules> GetRules(int CountryId)
 {
     return(_rulesRepository.GetAll(CountryId).ToList());
 }
コード例 #4
0
        private void Process()
        {
            var subscriptionResult = ytService.GetSubscriptions();

            if (subscriptionResult.Status != ActionStatus.Success)
            {
                return;
            }

            var rules = rulesRepository.GetAll().Data;

            foreach (var subscription in subscriptionResult.Data)
            {
                var uploads = ytService.GetUploads(subscription.Id);
                if (uploads.Status != ActionStatus.Success)
                {
                    continue;
                }
                var unprocessedVideos = uploads.Data.Where(o => !ytService.IsProcessed(o.Id)).ToList();
                foreach (var video in unprocessedVideos) // should only process new videos
                {
                    Console.WriteLine("Checking video {0}", video.Title);
                    ManagementRule matchedRule = null;
                    foreach (var rule in rules.OrderByDescending(o => o.Priority))
                    {
                        var success = false;
                        switch (rule.SearchPosition)
                        {
                        case SearchPosition.VideoTitle:
                            success = CheckRuleOnString(video.Title, rule, out matchedRule);
                            break;

                        case SearchPosition.ChannelTitle:
                            success = CheckRuleOnString(subscription.Title, rule, out matchedRule);
                            break;

                        case SearchPosition.All:
                            if (success = CheckRuleOnString(video.Title, rule, out matchedRule))
                            {
                                break;
                            }
                            success |= CheckRuleOnString(subscription.Title, rule, out matchedRule);
                            break;

                        default:
                            Console.WriteLine("SearchPosition {0} not supported", rule.SearchPosition);
                            continue;
                        }
                        if (success)
                        {
                            break;
                        }
                    }
                    if (matchedRule == null)
                    {
                        Console.WriteLine("No rules found for '{0}'", video.Title);
                        continue;
                    }

                    matchedRule.LastMatch = DateTime.Now;
                    if (!matchedRule.IgnoreVideo)
                    {
                        Console.WriteLine("Moving video '{0}' to '{1}'", video.Title, matchedRule.Target);
                        var addResult = ytService.AddToPlaylist(video.Id, matchedRule.Target);
                        if (addResult.Status != ActionStatus.Success)
                        {
                            Console.WriteLine("{0} {1}", addResult.Status, addResult.Message);
                            continue;
                        }
                    }
                    ytService.SetProcessed(video.Id, matchedRule.Id);
                }
            }
        }
コード例 #5
0
ファイル: ApiRules.cs プロジェクト: wlkodlak/FreediveComp
 public List <RulesDto> GetRules()
 {
     return(rulesRepository.GetAll().Select(BuildRules).ToList());
 }