Ejemplo n.º 1
0
        private void LoadConfig()
        {
            // Init Test
            // Create Required Files
            txbStatusOutput.AppendText("[INFO]\tSearching for Config-Files...\r\n");

            if (!File.Exists(@"C:\RBCPlus\config\rbcplus.ini"))
            {
                btnStartSystem.Enabled    = false;
                btnStopSystem.Enabled     = false;
                btnSystemMonitor.Enabled  = false;
                btnSystemSettings.Enabled = false;

                RBCP_Log.AddMessage(LogType.Error, "No System Configurations Found!");
                RBCP_Log.AddMessage(LogType.Blank, "Configure the System by clicking on");
                RBCP_Log.AddMessage(LogType.Setup, "");

                Thread.Sleep(500);
            }
            else
            {
                RBCP_Log.AddMessage(LogType.Info, "Config-File found!");
                RBCP_Log.AddMessage(LogType.Blank, "Loading config...");

                Thread.Sleep(500);

                StreamReader sr = new StreamReader(@"C:\RBCPlus\config\rbcplus.ini");
                string       line;
                string[]     dataParts = new string[2];

                while ((line = sr.ReadLine()) != null)
                {
                    if (line.StartsWith("["))
                    {
                        continue;
                    }

                    dataParts = line.Split('=');

                    RBCP_Config.Set((Config)Enum.Parse(typeof(Config), dataParts[0]), dataParts[1]);

                    RBCP_Log.AddMessage(LogType.Load, "Loading: " + dataParts[0]);

                    Thread.Sleep(5);
                }

                sr.Close();

                RBCP_Log.AddMessage(LogType.Info, "Load Completed!");
            }
        }
        private void LoadValues()
        {
            txbNasName.Text        = (string)RBCP_Config.Get(Config.NAS_NAME);
            txbNasDescription.Text = (string)RBCP_Config.Get(Config.NAS_DESCRIPTION);

            numNasSize.Value               = decimal.Parse((string)RBCP_Config.Get(Config.NAS_SIZE));
            cbxRaidType.SelectedValue      = (string)RBCP_Config.Get(Config.RAID_TYPE);
            cbxSyncFrequency.SelectedValue = (string)RBCP_Config.Get(Config.SYNC_FREQUENCY);
            cbxSyncStrategy.SelectedValue  = (string)RBCP_Config.Get(Config.SYNC_STRATEGY);

            trbLogAccuracy.Value     = int.Parse((string)RBCP_Config.Get(Config.LOG_ACCURACY));
            cbxSendLog.SelectedValue = (string)RBCP_Config.Get(Config.LOG_MAIL_NOTIFY);
            txbLogEmail.Text         = (string)RBCP_Config.Get(Config.LOG_EMAIL_ADDRESS);

            fbdMainStorageDriveBrowser.SelectedPath = (string)RBCP_Config.Get(Config.MAIN_DRIVE);
            chbAllowDirectAccess.Checked            = bool.Parse((string)RBCP_Config.Get(Config.ALLOW_DIRECT_ACCESS));

            chbDirectAccesByAdmin.Checked        = bool.Parse((string)RBCP_Config.Get(Config.ADMIN_ACCESS_ONLY));
            chbEnableBackup.Checked              = bool.Parse((string)RBCP_Config.Get(Config.ENABLE_BACKUP));
            cbxBackupFrequency.SelectedValue     = (string)RBCP_Config.Get(Config.BACKUP_FREQUENCY);
            cbxBackupFormat.SelectedValue        = (string)RBCP_Config.Get(Config.BACKUP_FORMAT);
            rbnBackupLocal.Checked               = bool.Parse((string)RBCP_Config.Get(Config.ENABLE_LOCAL_BACKUP));
            rbnBackupFTP.Checked                 = bool.Parse((string)RBCP_Config.Get(Config.ENABLE_FTP_BACKUP));
            fbdBackupStorageBrowser.SelectedPath = (string)RBCP_Config.Get(Config.BACKUP_DRIVE);

            chbEnableCaching.Checked          = bool.Parse((string)RBCP_Config.Get(Config.ENABLE_CACHING));
            fbdCacheDriveBrowser.SelectedPath = (string)RBCP_Config.Get(Config.CACHING_DRIVE);

            numCacheSize.Value             = decimal.Parse((string)RBCP_Config.Get(Config.MAX_CACHABLE_SIZE));
            cbxCacheSizeUnit.SelectedValue = (string)RBCP_Config.Get(Config.MAX_CACHABLE_SIZE_UNIT);

            lbxPermaCacheFolders.Text = (string)RBCP_Config.Get(Config.PERMA_CACHE);

            chbEnableFileRequesting.Checked      = bool.Parse((string)RBCP_Config.Get(Config.ENABLE_REQUESTING));
            cbxFileRequestDuration.SelectedValue = (string)RBCP_Config.Get(Config.REQUEST_CACHE_DURATION);
            chbAllowRequestCanceling.Checked     = bool.Parse((string)RBCP_Config.Get(Config.ALLOW_REQUEST_CANCELING));
            chbAllowRequestExtension.Checked     = bool.Parse((string)RBCP_Config.Get(Config.ALLOW_REQUEST_EXTENSION));
            numRequestSize.Value             = decimal.Parse((string)RBCP_Config.Get(Config.MAX_REQUEST_SIZE));
            cbxRequestSizeUnit.SelectedValue = (string)RBCP_Config.Get(Config.MAX_REQUEST_SIZE_UNIT);

            chbEnableWebInterface.Checked  = bool.Parse((string)RBCP_Config.Get(Config.ENABLE_WEB_INTERFACE));
            chbEnableWebManagement.Checked = bool.Parse((string)RBCP_Config.Get(Config.ENABLE_WEB_MANAGEMENT));

            txbWebAddress.Text = (string)RBCP_Config.Get(Config.WEB_ADDRESS);
        }