private void SaveConfiguration() { if (!m_IsModified) return; Configuration m_c = new Configuration(); m_c.ServerAddress = this.textBoxServerAddress.Text; m_c.ServerPort = (int)this.numericUpDownPort.Value; m_c.ADSLEntryName = this.textBoxADSLEntryName.Text; m_c.ADSLUserName = this.textBoxADSLUserName.Text; m_c.ADSLPassword = this.textBoxADSLPassword.Text; m_c.CurrentMode = ClientControlManager.Mode; m_c.Configurations = new Dictionary<ClientMode, ConfigurationDetailInMode>(); ConfigurationDetailInMode low = new ConfigurationDetailInMode(); low.QueryInterval = (int)this.numericUpDownQueryIntervalLow.Value; low.SingleTransportation = (int)this.numericUpDownSingleTranspotationLow.Value; low.MaxRunningTask = (int)this.numericUpDownMaxRunningTaskLow.Value; low.MaxRetryTime = (int)this.numericUpDownMaxRetryTimeLow.Value; low.MaxCPUUsage = (int)this.numericUpDownCPUUsageLow.Value; m_c.Configurations.Add(ClientMode.LowspeedMode, low); ConfigurationDetailInMode standard = new ConfigurationDetailInMode(); standard.QueryInterval = (int)this.numericUpDownQueryIntervalStandard.Value; standard.SingleTransportation = (int)this.numericUpDownSingleTranspotationStandard.Value; standard.MaxRunningTask = (int)this.numericUpDownMaxRunningTaskStandard.Value; standard.MaxRetryTime = (int)this.numericUpDownMaxRetryTimeStandard.Value; standard.MaxCPUUsage = (int)this.numericUpDownCPUUsageStandard.Value; m_c.Configurations.Add(ClientMode.StandardspeedMode, standard); ConfigurationDetailInMode high = new ConfigurationDetailInMode(); high.QueryInterval = (int)this.numericUpDownQueryIntervalHigh.Value; high.SingleTransportation = (int)this.numericUpDownSingleTranspotationHigh.Value; high.MaxRunningTask = (int)this.numericUpDownMaxRunningTaskHigh.Value; high.MaxRetryTime = (int)this.numericUpDownMaxRetryTimeHigh.Value; high.MaxCPUUsage = (int)this.numericUpDownCPUUsageHigh.Value; m_c.Configurations.Add(ClientMode.HighspeedMode, high); ClientControlManager.Configuration = m_c; m_IsModified = false; }
private static void LoadManagerFromFile(FrmMain uiform) { IFormatter formatter = new BinaryFormatter(); try { Stream stream = new FileStream("SlowAndSteadyParser.store", FileMode.Open, FileAccess.Read, FileShare.Read); try { LocalStorage store = (LocalStorage)formatter.Deserialize(stream); ms_tmc = store.CurrentTaskManager; DomainManager.DomainList = store.DomainList; ms_c = store.Configuration; } catch (SerializationException e) { log.Warn("本地数据文件格式错误", e); } finally { stream.Close(); } } catch (System.IO.FileNotFoundException e) { log.Warn("未找到本地数据文件", e); } finally { if (ms_tmc == null) ms_tmc = new TaskManagerClient(); RecheckConfiguration(); SetConfigurationToServerInfo(); SetConfigurationToManager(); SetConfigurationToPerformanceBalancer(); SetConfigurationToADSL(); } }