private void CInitialize() { APIKeyInfo = new SOLMain.APIKeySetDoc(); APIKeyInfo.APIKeySets = new List <SOLMain.APIKeySet>(); APIKeyInfo.PrimaryKey = new SOLMain.APIKey(); SOLMain.WriteLoglineEvent += new SOLMain.WriteLoglineDelegate(WriteLog); SOLMain.UpdateSecretKeyEvent += new SOLMain.UpdateSecretKeyDelegate(UpdateSecretKey); SOLMain.GetPrimaryAPIKeyEvent += new SOLMain.GetPrimaryAPIKeyDelegate(GetPrimaryAPIKey); SOLMain.GetFullAPIKeySetEvent += new SOLMain.GetFullAPIKeySetDelegate(GetFullAPIKeySet); SOLMain.GetConfigPathEvent += new SOLMain.GetConfigPathDelegate(GetConfigPath); SOLMain.CreateNewMonitorEvent += new SOLMain.CreateNewMonitorDelegate(CreateNewMonitor); }
private void AppConfigRead() { while (true) { if (Directory.Exists(Path.GetDirectoryName(APIKeyPath))) { if (File.Exists(APIKeyPath)) { StreamReader reader; try { reader = new StreamReader(APIKeyPath); XmlSerializer xmlSerializer = new XmlSerializer(APIKeyInfo.GetType()); try { APIKeyInfo = (SOLMain.APIKeySetDoc)xmlSerializer.Deserialize(reader); reader.Close(); break; } catch (InvalidOperationException e) { reader.Close(); SOLMain.WriteLogline(e.Message, SOLMain.LogLevel.Error); SOLMain.WriteLogline("密钥配置文件错误,重新生成密钥配置文件", SOLMain.LogLevel.Error); MessageBox.Show("请先填写用于访问腾讯云API的密钥", "未找到密钥配置文件", MessageBoxButtons.OK, MessageBoxIcon.Information); OpenConnectionForm(); } } catch (Exception e) { SOLMain.WriteLogline("读取密钥XML时抛出异常:" + e.Message, SOLMain.LogLevel.Error); throw e; } } else { SOLMain.WriteLogline("未找到密钥配置文件"); MessageBox.Show("请先填写用于访问腾讯云API的密钥,并设置主密钥", "未找到密钥配置文件", MessageBoxButtons.OK, MessageBoxIcon.Information); OpenConnectionForm(); } } else { SOLMain.WriteLogline("配置文件目录未建立,开始建立目录"); Directory.CreateDirectory(Path.GetDirectoryName(APIKeyPath)); } } }
private void CInitialize() { APIKeys = SOLMain.GetFullAPIKeySet(); PrimaryKey = SOLMain.GetPrimaryAPIKey(); RegionDataPath = SOLMain.GetConfigPath(SOLMain.ConfigType.Region); }
private void CInitialize() { FullAPIKeySet = SOLMain.GetFullAPIKeySet(); APIKeyPath = SOLMain.GetConfigPath(SOLMain.ConfigType.APIKey); SelectionChanged(); }