public MainWindow() { //Deletar(); InitializeComponent(); try { AgentePropertiesContainer agentProperties = LoadAgentProperties(); txt_authenticationhost.Text = agentProperties.HttpAuthenticationHost; txt_authenticationport.Text = agentProperties.HttpAuthenticationPort; txt_authenticationrealm.Text = agentProperties.HttpAuthenticationRealm; txt_jvm.Text = agentProperties.JVM; txt_LibDir.Text = agentProperties.LibDir; txt_Log4j.Text = agentProperties.Log4J; txt_ServiceLog.Text = agentProperties.ServiceLog; txt_password.Text = agentProperties.HttpPassword; txt_serviceurl.Text = agentProperties.HttpServiceurl; txt_username.Text = agentProperties.HttpUserName; } catch { MessageBox.Show("Exception ao tentar carregar agentProperties"); } }
private AgentePropertiesContainer LoadAgentProperties() { AgentePropertiesContainer agentProperties = new AgentePropertiesContainer(); string dirpath = System.IO.Directory.GetParent(AppDomain.CurrentDomain.BaseDirectory).Parent.FullName + "\\ssAgent"; string agentFile = "agent.properties"; string fullname = dirpath + "\\" + agentFile; try { Thread.Sleep(3000); FileInfo file = new FileInfo(fullname); var lineCounter = 0L; using (var reader = new StreamReader(file.FullName)) { while (reader.EndOfStream == false) { var line = reader.ReadLine(); if (line.Contains("jvm=")) { agentProperties.JVM = line.Replace("jvm=", ""); } else if (line.Contains("http.serviceurl=")) { agentProperties.HttpServiceurl = line.Replace("http.serviceurl=", "");; } else if (line.Contains("http.authenticationHost=")) { agentProperties.HttpAuthenticationHost = line.Replace("http.authenticationHost=", ""); } else if (line.Contains("http.authenticationPort=")) { agentProperties.HttpAuthenticationPort = line.Replace("http.authenticationPort=", ""); } else if (line.Contains("http.authenticationRealm=")) { agentProperties.HttpAuthenticationRealm = line.Replace("http.authenticationRealm=", ""); } else if (line.Contains("http.username="******"http.username="******""); } else if (line.Contains("http.password="******"http.password="******""); } else if (line.Contains("libdir=")) { agentProperties.LibDir = line.Replace("libdir=", ""); } else if (line.Contains("log4j=")) { agentProperties.Log4J = line.Replace("log4j=", ""); } else if (line.Contains("serviceLog=")) { agentProperties.ServiceLog = line.Replace("serviceLog=", ""); } lineCounter++; } } } catch (Exception ex) { MessageBox.Show("Exception ao tentar procurar o diretorio do ssAgent"); MessageBox.Show("Msg exception: " + ex.Message); MessageBox.Show("fullname: " + fullname); } return(agentProperties); }