Exemple #1
0
 public QueueLogInfo(string queuedBy, SoundBoardItem item)
 {
     QueueTimestamp = DateTime.Now;
     QueuedBy = queuedBy;
     SampleName = item.Title;
     ItemId = item.Id;
 }
        private void Scan(string directory,IEnumerable<string> filter)
        {
            int newMediaItems = 0;
            int mediaItemsFound = 0;
            int mediaItemUpdated = 0;
            int fileItemsSkipped = 0;

            var soundBoardItemSource = SoundBoardItemSource.GetInstance();

            
            Console.ForegroundColor = ConsoleColor.DarkGreen;
            Console.WriteLine("{0} Started media scan with filter: [{1}]", DateTime.Now, GetFormatterFilterString(filter));
            
            
            var beginTime = DateTime.Now;

            foreach(var file in System.IO.Directory.GetFiles(directory,"*.*",SearchOption.AllDirectories))
            {
                if (filter.Any(a => file.EndsWith(a)))
                {
                    SoundBoardItem soundBoardItem = null;
                    if(soundBoardItemSource.Items.TryGetValue(file,out soundBoardItem))
                    {

                    }
                    else
                    {
                        soundBoardItem = new SoundBoardItem
                        {
                            Id = Guid.NewGuid(),
                            SoundboardLogo = SoundBoardLogo.Default,
                            Title = Path.GetFileName(file),
                            Category = new DirectoryInfo(Path.GetDirectoryName(file)).Name,
                            File = file

                        };

                        if (soundBoardItemSource.Items.TryAdd(file,soundBoardItem))
                            Console.WriteLine("{0} Added item {1} to media libary",DateTime.Now,soundBoardItem.Title);
                        else
                        {
                            Console.ForegroundColor = ConsoleColor.Red;
                            Console.WriteLine("{0} Failed to add item {1} to media libary!");
                            Console.ForegroundColor = ConsoleColor.Green;
                        }

                        newMediaItems++;
                    }
                    mediaItemsFound ++;
                }

            }

            foreach(var item in soundBoardItemSource.Items)
            {
                if(!File.Exists(item.Key))
                {
                    SoundBoardItem soundBoardItem = null;
                    Console.ForegroundColor = ConsoleColor.Yellow;
                    Console.WriteLine("{0} Removing item {1} from media libary because it does not longer exsist on disk",DateTime.Now,item);

                    if (!soundBoardItemSource.Items.TryRemove(item.Key, out soundBoardItem))
                    {
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine("{0} Failed to remove item {1} from media libary!");
                        Console.ForegroundColor = ConsoleColor.Green;
                    }

                    Console.ForegroundColor = ConsoleColor.Green;
                }
            }

            var endTime = DateTime.Now;

            Console.WriteLine("{0} Items Found: [{1}] Items updated: [{2}] Items skipped: [{3}]", DateTime.Now,mediaItemsFound,mediaItemUpdated,fileItemsSkipped);
            Console.WriteLine("{0} Finished media scan in [{1}]", DateTime.Now, endTime - beginTime);

            Console.ForegroundColor = ConsoleColor.White;

            
        }
Exemple #3
0
 public static void LogQueue(SoundBoardItem item, string queuedBy)
 {
     if (item == null) return;
     item.PlayCount ++;
     _queueLog.Add(new QueueLogInfo(queuedBy, item));
 }
 public void Enqueue(SoundBoardItem soundBoardItem)
 {
     _mediaQueue.ItemQueue.Enqueue(soundBoardItem);
     TaskExtensions.Signal();
 }