示例#1
0
        static void Main(string[] args)
        {
            string        directoryPath  = "X:\\";
            List <string> directories    = new List <string>();
            var           channelsNumber = 0;

            VideoLibraryConsoleDataContext VideoConsoleDB = new VideoLibraryConsoleDataContext();

            directories = Common.GetDirectories(directoryPath);


            foreach (var directory in directories)
            {
                //Console.WriteLine(directory);
                files.AddRange(Common.GetFiles(directory));
            }

            Console.WriteLine("Directories count: " + directoryCounter);
            Console.WriteLine("Files count: " + filesCounter);


            files.Sort();

            videoFiles = Common.GetVideoFiles(files, videoFileExtensions);

            /*
             * foreach (var videoFile in videoFiles)
             * {
             *      Console.WriteLine(videoFile);
             * }
             */

            Console.WriteLine("Video files:");
            foreach (var videoFile in videoFiles)
            {
                var mi = new MediaInfo();
                mi.Open(videoFile);

                var videoInfo = new VideoInfo(mi);
                var audioInfo = new AudioInfo(mi);

                //Console.WriteLine(audioInfo.ChannelPositions);
                //Console.WriteLine(audioInfo.ChannelsOriginal);
                //Console.WriteLine(videoFile);
                //Console.WriteLine(audioInfo.Channels);


                channelsNumber = audioInfo.ChannelsOriginal > audioInfo.Channels ? audioInfo.ChannelsOriginal : audioInfo.Channels;

                Console.WriteLine(videoFile);


                var existingVideos = from c in VideoConsoleDB.Videos
                                     where c.FullFileName == videoFile
                                     select c;

                if (existingVideos.Count() == 0)
                {
                    Videos newVideo = new Videos()
                    {
                        FullFileName  = videoFile,
                        AudioChannels = channelsNumber,
                        FileName      = Path.GetFileName(videoFile),
                        FilePath      = Path.GetDirectoryName(videoFile)
                    };

                    VideoConsoleDB.Videos.InsertOnSubmit(newVideo);
                    // executes the commands to implement the changes to the database
                    VideoConsoleDB.SubmitChanges();
                }


                mi.Close();
            }


            Console.WriteLine("\nPress any key to exit...");
            Console.ReadKey();
        }
示例#2
0
 partial void UpdateVideos(Videos instance);
示例#3
0
 partial void DeleteVideos(Videos instance);
示例#4
0
 partial void InsertVideos(Videos instance);