Esempio n. 1
0
        private void btnDirAC_Click(object sender, EventArgs e)
        {
            string path = "";

            if (txtACEXE.Text.Equals(""))
            {
                path = ACHelper.getACSFolder();
            }
            else
            {
                path = Path.GetFullPath(txtACEXE.Text);
            }

            OpenFileDialog openfile = new OpenFileDialog();

            openfile.CheckFileExists  = true;
            openfile.FileName         = "AssettoCorsa.exe";
            openfile.InitialDirectory = path;
            DialogResult dlgRes = openfile.ShowDialog();

            if (dlgRes == DialogResult.OK)
            {
                if (File.Exists(openfile.FileName) && openfile.FileName.Contains("AssettoCorsa.exe"))
                {
                    this.txtACEXE.Text = openfile.FileName;
                    SaveSettings();
                }
            }
        }
Esempio n. 2
0
 private void StartAC()
 {
     if (ACHelper.CheckLocalExeAndContentFolder(txtACEXE.Text) == true)
     {
         System.Diagnostics.Process.Start(txtACEXE.Text);
     }
 }
Esempio n. 3
0
 private Boolean CheckForContentFolders()
 {
     try
     {
         mainDirectories = ACHelper.checkFolderForMainFolders(rootDir);
         return(mainDirectories.Count > 0);
     }
     catch
     {
         return(false);
     }
 }
Esempio n. 4
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!"));
        }
Esempio n. 5
0
        public string InfoString()
        {
            string toReturn = ftpDir.GetSeriesName() + " (";

            foreach (string subdir in ACHelper.getContentTypes())
            {
                var dirs = rootFolder.lstFiles.Where(x => x.getSerie() == ftpDir.PathOnServer && x.getSubFolder(1) == subdir).Select(y => y.getSubFolder(2)).Distinct().ToList();

                toReturn += subdir + ": " + dirs.Count + " ";
                //FTPDirectoryDirect dir = ftpDir.Descendants().Where(x => x._name.Equals(subdir)).FirstOrDefault();
                //if (dir != null)
                //{
                //    toReturn += dir._name + ": " + dir.subDirectories.Count + " " ;
                //}
            }
            toReturn += ")";

            if (ftpDirsToSync != null && ftpDirsToSync.Count > 0)
            {
                if (ftpDirsToSync.Where(x => x.toAdd).Count() > 0)
                {
                    toReturn += " toAdd: " + ftpDirsToSync.Where(x => x.toAdd).Count();
                }

                if (ftpDirsToSync.Where(x => !x.toAdd).Count() > 0)
                {
                    toReturn += " toSync: " + ftpDirsToSync.Where(x => !x.toAdd).Count();
                }
            }
            if (ftpFilesToSync != null && ftpFilesToSync.Count > 0)
            {
                toReturn += " toSync: " + ftpFilesToSync.Count + " Files ";
                foreach (string subdir in ACHelper.getContentTypes())
                {
                    var lstSubFolders = ftpFilesToSync.Where(x => x.getSubFolder(1).Equals(subdir)).Select(y => y.getSubFolder(2)).Distinct().ToList();
                    if (lstSubFolders.Count() > 0)
                    {
                        toReturn += ", " + lstSubFolders.Count() + " " + subdir;
                    }
                }
                long size = ftpFilesToSync.Select(x => x.SizeByte).Sum();
                toReturn += " with Total Size of " + ACHelper.FormatBytes(size);
            }
            return(toReturn);
        }
Esempio n. 6
0
        /// <summary>
        /// Lädt die Einstelungen aus den Usersettings
        /// </summary>
        private void LoadSettings()
        {
            txtFTP.Text   = AC_SRU_Sync.Properties.Settings.Default.ftpPath;
            txtACEXE.Text = AC_SRU_Sync.Properties.Settings.Default.localPath;
            if (txtACEXE.Text.Equals(""))
            {
                txtACEXE.Text = ACHelper.getACSFolder() + @"\AssettoCorsa.exe";
            }
            txtFtpUser.Text      = AC_SRU_Sync.Properties.Settings.Default.ftpUser;
            pnlSettings.Visible  = AC_SRU_Sync.Properties.Settings.Default.SettingsVisible;
            btnShowSettings.Text = pnlSettings.Visible ? "-" : "+";

            if (!AC_SRU_Sync.Properties.Settings.Default.ftpPassword.Equals(""))
            {
                txtFtpPassword.Text = simpleAES.DecryptString(AC_SRU_Sync.Properties.Settings.Default.ftpPassword);
            }
            else
            {
                txtFtpPassword.Text = "";
            }
            if (AC_SRU_Sync.Properties.Settings.Default.deep > 3)
            {
                deepToCheck = AC_SRU_Sync.Properties.Settings.Default.deep;
            }
            cmbDeep.Value    = deepToCheck;
            btnSync.Enabled  = false;
            btnStart.Enabled = false;

            checkBoxes = new Dictionary <int, CheckBox>();
            checkBoxes.Add(0, checkBox1);
            checkBoxes.Add(1, checkBox2);
            checkBoxes.Add(2, checkBox3);
            checkBoxes.Add(3, checkBox4);
            checkBoxes.Add(4, checkBox5);
            checkBoxes.Add(5, checkBox6);
            checkBoxes.Add(6, checkBox7);
            checkBoxes.Add(7, checkBox8);
            LoadMainDirsFromSettings();
            isLoading = false;
        }
Esempio n. 7
0
        private void SyncAllSelectedMainDirs()
        {
            DateTime start = DateTime.Now;

            WriteLog(Environment.NewLine + "Sync started at " + start.ToLongTimeString() + Environment.NewLine);
            List <MainDirectory> toSync = mainDirectories.Where(x => AC_SRU_Sync.Properties.Settings.Default.ToSync.Contains(x.ftpDir.GetSeriesName())).ToList();
            long totalSizeLong          = toSync.Select(x => x.ftpFilesToSync.Select(y => y.SizeByte).Sum()).Sum();

            double factor    = totalSizeLong > Int32.MaxValue ? totalSizeLong / (double)Int32.MaxValue : 1;
            int    totalSize = Convert.ToInt32(totalSizeLong / factor);
            int    actSize   = 0;

            SetProgress(actSize, totalSize);
            foreach (MainDirectory mainDir in toSync)
            {
                WriteLog("Sync Folder " + mainDir.ftpDir.GetSeriesName());
                string curObject     = "";
                string curObjectType = "";

                foreach (FTPFile ftpFile in mainDir.ftpFilesToSync)
                {
                    if (!curObject.Equals(ftpFile.getSubFolder(2)))
                    {
                        if (!curObject.Equals(""))
                        {
                            WriteLog("Sync ObjectType " + curObjectType + " Name: " + curObject);
                        }
                        //start = DateTime.Now;
                        curObjectType = ftpFile.getSubFolder(1);
                        curObject     = ftpFile.getSubFolder(2);
                    }
                    double seconds = actSize == 0 ? 0 : (totalSize / actSize * (DateTime.Now - start).TotalSeconds);

                    string time = actSize == 0?" ?" : string.Format("{0:00}:{1:00}:{2:00}", seconds / 3600, (seconds / 60) % 60, seconds % 60);
                    SetProgress(actSize, totalSize, ftpFile.FullPath + " Size " + ACHelper.FormatBytes(ftpFile.SizeByte) + "        (" + ACHelper.FormatBytes(Convert.ToInt64(actSize * factor)) + " / " + ACHelper.FormatBytes(totalSizeLong) + ")", " " + time);
                    GetFTPHelper().DownloadFile(ftpFile);
                    actSize += Convert.ToInt32(ftpFile.SizeByte / factor);

                    //Entfernen fürs weitermachen
                    mainDir.ftpFilesAlreadyDone.Add(ftpFile);
                    if (isAborting)
                    {
                        foreach (FTPFile file in mainDir.ftpFilesAlreadyDone)
                        {
                            mainDir.ftpFilesToSync.Remove(file);
                        }
                        WriteLog(Environment.NewLine + "Sync abborted!");
                        //this.Cursor = Cursors.Default;
                        btnStart.Enabled = false;
                        btnSync.Enabled  = true;
                        isSyncing        = false;

                        StopProgress();
                        return;
                    }
                }
                mainDir.ftpFilesToSync.Clear();
            }
            WriteLog(Environment.NewLine + "Sync finished!");

            StopProgress();
            CheckSyncState();
        }