Exemplo n.º 1
0
        static void Main(string[] args)
        {
            #region MySQL Service Check
            ServiceController[] allServices;
            allServices = ServiceController.GetServices();
            foreach (ServiceController service in allServices)
            {
                if (service.DisplayName.Contains("MySQL") || service.DisplayName.Contains("MYSQL"))
                {
                    Console.WriteLine("[Main] Found MySql Service.\n[Main] Status: {0}", service.Status);
                    if (service.Status != ServiceControllerStatus.Running)
                    {
                        Console.Write("[Main] Starting MySql service (6 seconds)...");
                        service.Start();
                        System.Threading.Thread.Sleep(6000);
                    }
                }
            }
            #endregion

            #region Database Population
            Repository.Instance.createDatabaseIfNeeded();
            PopulateDatabase populateDB = new PopulateDatabase();
            populateDB.GetMusicFiles(Environment.GetFolderPath(Environment.SpecialFolder.MyMusic).ToString());
            #endregion

            #region Directory Monitor
            DirectoryMonitor monitor = new DirectoryMonitor(Environment.GetFolderPath(Environment.SpecialFolder.MyMusic).ToString());
            Thread directoryMonitorThread = new Thread(new ThreadStart(monitor.Run));
            directoryMonitorThread.Start();
            #endregion

            #region Server Location Service
            Thread serverLocationService = new Thread(new ThreadStart(ServerLocationService.Instance.Run));
            serverLocationService.Start();
            #endregion

            #region API Server
            Thread serverAPIThread = new Thread(new ThreadStart(APIServer.Instance.Run));
            serverAPIThread.Start();
            #endregion

            #region Web Server
            IISExpress iis = IISExpress.Start(
                @"webServer\Web.config",
                @"clientWebHosting",
                @"Clr4IntegratedAppPool");
            #endregion

            while (true)
            {
                Console.WriteLine("Enter command");
                string command = Console.ReadLine();
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// New file added to folder. 
 /// </summary>
 /// <param name="source">Watcher that sent the event</param>
 /// <param name="args">Provides the file path</param>
 private static void OnCreated(object source, FileSystemEventArgs args)
 {
     if (source == _fileWatcher)
     {
         Console.WriteLine("[Directory Monitor] File Watcher: File " + args.FullPath + " " + args.ChangeType);
         Repository.Instance.addSongToDatabase(args.FullPath);
     }
     else
     {
         Console.WriteLine("[Directory Monitor] Directory Watcher: Directory " + args.FullPath + " " + args.ChangeType);
         PopulateDatabase populateNewFolder = new PopulateDatabase();
         populateNewFolder.GetMusicFiles(args.FullPath);
     }
     
 }
Exemplo n.º 3
0
 /// <summary>
 /// File renamed in the folder.
 /// </summary>
 /// <param name="source">Watcher that sent the event</param>
 /// <param name="args">Provides the  old  and new file paths</param>
 private static void OnRenamed(object source, RenamedEventArgs args)
 {
     if (source == _fileWatcher)
     {
         Console.WriteLine("[Directory Monitor] File Watcher: File " + args.FullPath + " " + args.ChangeType);
         Repository.Instance.updateFilename(args.OldFullPath, args.FullPath);
     }
     else
     {
         Console.WriteLine("[Directory Monitor] Directory Watcher: Directory " + args.FullPath + " " + args.ChangeType);
         // Need to update all files in directory to reflect change to file path
         Repository.Instance.removeSongsInDirectory(args.OldFullPath);
         PopulateDatabase updateFilePaths = new PopulateDatabase();
         updateFilePaths.GetMusicFiles(args.FullPath);
     }
 }