public static string GetOpenedPortsForProcessString(string processName) { StringBuilder output = new StringBuilder(); try { Process[] processes = Process.GetProcessesByName(processName.Replace(".exe", "")); if (processes.Length > 0) { foreach (Process p in processes) { var path = ""; try { path = "Path " + Html.I(p.Modules[0].FileName); } catch (Exception) { } var processOwner = ""; try { processOwner = Helper.GetProcessOwner(p.Id); } catch (Exception) { } output.Append(Html.U(Html.br + "PID: " + p.Id + " " + processName + " " + processOwner) + path + Helper.GetOpenedPortsForProcessId(p.Id)); } } return(output.ToString()); } catch (Exception ex) { Logger.Error(ex.ToString()); return(ex.Message); } }
string GetOpenedPortsInfo() { try { StringBuilder info = new StringBuilder(); if (numberOfRunningAgents == 1) { info.Append(Html.U("PID: " + agentProcessId + " " + agentProcessOwnder) + Html.br + "Path: " + agentProcessPath + Helper.GetOpenedPortsForProcessId(agentProcessId)); } if (numberOfRunningAgents > 1) { for (int i = 0; i < numberOfRunningAgents; i++) { info.Append(Html.U("PID: " + agentProcessIds[i] + " " + agentProcessOwnders[i]) + "Path " + Html.I(agentProcessPaths[i]) + Helper.GetOpenedPortsForProcessId(agentProcessIds[i])); } } // add the raw output to the DOM in case for debug purposes //if (numberOfRunningAgents > 0) //{ // info.Append(Html.Div(openedPortDetailsFromCMD.ToString(), "ports", "dontShow")); //} return(info.ToString()); } catch (Exception ex) { Logger.Error(ex.ToString()); return(null); } }
public static string GetRegistraionFailuresContent() { try { var regFailureFiles = ProductInfo.RegistrationFailureLogs; //if no files are found get out of here if (regFailureFiles.Count == 0) { return("None, no RegistrationFailure log files found"); } StringBuilder output = new StringBuilder(); foreach (var file in regFailureFiles) { string lastLines = GetLastLinesFromFile(1024, file.fullPath, 5); output.Append(String.Format("Last 5 lines in: {0} {1} {2}" , Html.I(Path.GetFileName(file.fullPath)) , Html.br, lastLines)); } return(output.Length > 0 ? output.ToString() : "Not found!"); } catch (Exception ex) { Logger.Error(ex.ToString()); return(ex.Message); } }