/* Dependency injection, decoupled from database */
 public ApplicationController(IApplication application,
                              IConfiguration configuration,
                              IApplicationFiles applicationFiles,
                              IProgramme programme,
                              IUser user, IEmail email)
 {
     _config           = configuration;
     _application      = application;
     _applicationFiles = applicationFiles;
     _user             = user;
     _programme        = programme;
     _email            = email;
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets the name of the parts for programme.
        /// </summary>
        /// <param name="programme">The programme.</param>
        /// <returns></returns>
        private string[] GetPartsForProgrammeName(IProgramme programme)
        {
            // If the TVSchedule plugin already did this then use there results.
            if (programme.ProgrammeNameParts != null)
            {
                return(programme.ProgrammeNameParts);
            }

            // Remove the ' because regex isnt picking it up..
            programme.ProgramName = programme.ProgramName.Replace("'", "");

            // Split titles into parts.
            string[] programmeParts = RemoveBadCharacters(programme.ProgramName).ToLower().Split(' ', ',', '.', '-').ToArray();

            // Strip bad words out of the arrays
            programmeParts = programmeParts.Where(m => !MovieControlModel.GetInstance.FileCacheManager.WordsToIgnore.Contains(m.ToLower().SafeTrim())).ToArray();

            // Distinct the words.
            return(programmeParts.Distinct().ToArray());
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Gets the matches.
        /// </summary>
        /// <param name="programme">The programme.</param>
        /// <returns></returns>
        public List <MenuItemModel> GetMatchesForProgramme(IProgramme Programme)
        {
            // Prepare result.
            List <MenuItemModel> matches = new List <MenuItemModel>();

            // Ignore one word titles such as "news".
            if (Programme.ProgramName == null ||
                MovieControlModel.GetInstance.FileCacheManager.ProgrammesToIgnore.Contains(Programme.ProgramName.ToLower().SafeTrim()))
            {
                return(matches);
            }

            if (Programme.ProgramName.ToLower().Contains("james may"))
            {
                int breakpoint = 1;
            }

            string[] programmeParts = GetPartsForProgrammeName(Programme);

            // Loop local files.
            Parallel.ForEach <FileCacheEntity>(MovieControlModel.GetInstance.FileCacheManager.FileCacheEntities, fileEntity =>
            {
                int matchCount = 0;

                foreach (string f in fileEntity.FileParts)
                {
                    foreach (string p in programmeParts)
                    {
                        if (f.ToLower().SafeTrim() == p.ToLower().SafeTrim())
                        {
                            matchCount++;
                        }
                    }
                }

                // Accept the file?
                if (matchCount >= programmeParts.Count() || matchCount >= fileEntity.FileParts.Count())
                {
                    lock (obj)
                    {
                        matches.Add(new MenuItemModel()
                        {
                            DisplayText    = Path.GetFileNameWithoutExtension(fileEntity.FullPathAndName),
                            FilePath       = fileEntity.FullPathAndName,
                            IsVisible      = true,
                            ParentSelected = true,
                            IsSelected     = false,
                            RelayCommand   = new RelayCommand(() =>
                            {
                                // move focus to the mini playpanel
                                MovieControlModel.GetInstance.PlayOptionsVisible = true;
                                PageModel.GetInstance.UnSelectPageModel();
                            })
                        });
                    }
                }
            });

            // Return result.
            return(matches);
        }