static DBConnectionManager() { string registerPath = System.Environment.CurrentDirectory + DB_CONFIG_FILE; try { if (!File.Exists(registerPath)) { throw new CoreException(CoreException.ERROR_FILE_NOT_EXIST_1, registerPath); } PropertyFileOperator file = new PropertyFileOperator(registerPath); connection_path = file.GetPropertiesText(KEY_DB_FILE_PATH); if (!File.Exists(connection_path)) { throw new CoreException(CoreException.ERROR_FILE_NOT_EXIST_1, connection_path); } } catch (CoreException e) { throw e; } }
private void InitData() { try { string configPath1 = Path.Combine(path, @"webapps\ginkgo\WEB-INF\classes", "db.properties"); string configPath2 = Path.Combine(path, @"webapps\ginkgo\WEB-INF", "web.xml"); string configPath3 = Path.Combine(path, @"conf", "server.xml"); if (System.Configuration.ConfigurationManager.AppSettings["LogConfigPathFlag"] != "0") { MixLogHelper.Info(GetType().Name, configPath1); MixLogHelper.Info(GetType().Name, configPath2); MixLogHelper.Info(GetType().Name, configPath3); } hasConfigFile = File.Exists(configPath1) && File.Exists(configPath2); if (!File.Exists(configPath1) || !File.Exists(configPath2)) { MessageBox.Show(this, "配置文件不存在"); return; } propertyFileOperator = new PropertyFileOperator(configPath1); textJDBCUrl.Text = propertyFileOperator.GetPropertiesText("jdbcUrl"); textBrokerUrl.Text = propertyFileOperator.GetPropertiesText("brokerURL"); textAdminUserOrgCode.Text = propertyFileOperator.GetPropertiesText("adminUserOrgCode"); textUpdateSrvTime.Text = propertyFileOperator.GetPropertiesText("updateSrvTime"); textUpdateSrvStatus.Text = propertyFileOperator.GetPropertiesText("updateSrvStatus"); txt_hlsUrl.Text = propertyFileOperator.GetPropertiesText("hlsUrl"); txt_hlsMappedUrl.Text = propertyFileOperator.GetPropertiesText("hlsMappedUrl"); txt_updateUrl.Text = propertyFileOperator.GetPropertiesText("updateUrl"); txt_updateMappedUrl.Text = propertyFileOperator.GetPropertiesText("updateMappedUrl"); txtaudioInnerNet.Text = propertyFileOperator.GetPropertiesText("audioInnerNet"); txtaudioInnerPort.Text = propertyFileOperator.GetPropertiesText("audioInnerPort"); txtaudioOuterNet.Text = propertyFileOperator.GetPropertiesText("audioOuterNet"); txtaudioOuterPort.Text = propertyFileOperator.GetPropertiesText("audioOuterPort"); txtinnerNet.Text = propertyFileOperator.GetPropertiesText("innerNet"); txtinnerPort.Text = propertyFileOperator.GetPropertiesText("innerPort"); txtouterNet.Text = propertyFileOperator.GetPropertiesText("outerNet"); txtouterPort.Text = propertyFileOperator.GetPropertiesText("outerPort"); XElement xeWeb = XElement.Load(configPath2); var elements = xeWeb.XPathSelectElements("//*"); var media = elements.FirstOrDefault(ele => ele.Name.LocalName == "param-name" && ele.Value == "mediaUrl"); var value = (media.NextNode as XElement).Value; textMediaUrl.Text = value; //XElement xeServer = XElement.Load(configPath3); //var contextElements = xeServer.XPathSelectElements("//Context"); //textDocBase.Text = contextElements.FirstOrDefault(q => q.Attributes("docBase").Count() > 0).Attribute("docBase").Value; } catch (Exception e) { MixLogHelper.Error(GetType().Name, "初始化CMDServer配置文件异常", e.StackTrace); } }