Ejemplo n.º 1
0
        private void CheckFTPANDLocalFolders()
        {
            DateTime start = DateTime.Now;

            pgbar.Maximum = 5;
            pgbar.Step    = 1;
            pgbar.Value   = 1;
            WriteLog("Check started at " + start.ToLongTimeString() + Environment.NewLine, false);
            if (checkFTPServer(txtFTP.Text) == false)
            {
                WriteLog("Sorry, could not conect to FTP Server!");
                WriteLog("Please check network connection and FTP-Settings");
                return;
            }
            pgbar.Value = 2;
            long size = rootDir.lstFiles.Select(x => x.SizeByte).Sum();

            WriteLog("Successfull FTP Connection! Content.txt loaded with " + rootDir.lstFiles.Count() + " Files with Total Size of " + ACHelper.FormatBytes(size));
            //WriteLog("Elapsed: " + (DateTime.Now - start).TotalSeconds.ToString("0.00") + " s" + Environment.NewLine);
            start = DateTime.Now;
            if (CheckForContentFolders() == false)
            {
                WriteLog("Sorry, no content Folder found on Server!");
                return;
            }

            pgbar.Value = 3;

            WriteLog("Found Contentfolders: " + mainDirectories.Count + " ");
            //WriteLog("Elapsed:" + (DateTime.Now - start).TotalSeconds.ToString("0.00") + "s" + Environment.NewLine);
            start = DateTime.Now;
            //Check AC Exe
            if (ACHelper.CheckLocalExeAndContentFolder(txtACEXE.Text) == false)
            {
                txtStatus.Text += "AC.exe or content folder not found! Check Path to Exe.";
                return;
            }
            pgbar.Value = 4;
            WriteLog("Compare folders in FileSystem");
            if (mainDirectories.Count > 0)
            {
                LoadMainDirsFromFoundDirs(mainDirectories);
            }
            foreach (MainDirectory mainDir in mainDirectories)
            {
                mainDir.ftpFilesToSync = ACHelper.CheckLocalFolder(txtACEXE.Text, rootDir, mainDir);
                WriteLog("Subfolder " + mainDir.InfoString());
            }
            CheckSyncState();
            pgbar.Value = 5;
            WriteLog(Environment.NewLine + "Check Finished!!! " + (btnStart.Enabled ? "You are ready to Start Assetto Corsa!" : "Please Sync your Folders!"));
        }