From b419cfc72d39d731c4c83ee7c67492045b71af5e Mon Sep 17 00:00:00 2001 From: ruslan Date: Tue, 14 Aug 2012 16:29:26 +0300 Subject: [PATCH] reading wpi logs fixed --- .../WebsitePanel.Server/WindowsServer.asmx.cs | 10 ++-- .../ServersEditWebPlatformInstaller.ascx.cs | 47 +++++++++++++------ 2 files changed, 38 insertions(+), 19 deletions(-) diff --git a/WebsitePanel/Sources/WebsitePanel.Server/WindowsServer.asmx.cs b/WebsitePanel/Sources/WebsitePanel.Server/WindowsServer.asmx.cs index 7c990684..0f7e240d 100644 --- a/WebsitePanel/Sources/WebsitePanel.Server/WindowsServer.asmx.cs +++ b/WebsitePanel/Sources/WebsitePanel.Server/WindowsServer.asmx.cs @@ -740,12 +740,13 @@ namespace WebsitePanel.Server Log.WriteError("WpiGetLogFileDirectory", ex); - throw; + //throw; + return string.Empty; } } [WebMethod] - public SettingPair[] WpiGetLogsInDirectory(string Path) + public SettingPair[] WpiGetLogsInDirectory(string path) { try { @@ -753,7 +754,7 @@ namespace WebsitePanel.Server ArrayList result = new ArrayList(); - string[] filePaths = Directory.GetFiles(Path); + string[] filePaths = Directory.GetFiles(path); foreach (string filePath in filePaths) { using (StreamReader streamReader = new StreamReader(filePath)) @@ -773,7 +774,8 @@ namespace WebsitePanel.Server Log.WriteError("WpiGetLogFileDirectory", ex); - throw; + //throw; + return null; } } diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ServersEditWebPlatformInstaller.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ServersEditWebPlatformInstaller.ascx.cs index 1b2c1156..f51dfa41 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ServersEditWebPlatformInstaller.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ServersEditWebPlatformInstaller.ascx.cs @@ -327,7 +327,10 @@ namespace WebsitePanel.Portal if (string.IsNullOrEmpty(wpiLogsDir)) { wpiLogsDir = ES.Services.Servers.WpiGetLogFileDirectory(PanelRequest.ServerId); - ViewState[_wpiLogsDirViewStateKey] = wpiLogsDir; + if (!string.IsNullOrEmpty(wpiLogsDir)) + { + ViewState[_wpiLogsDirViewStateKey] = wpiLogsDir; + } } } catch @@ -532,37 +535,51 @@ namespace WebsitePanel.Portal protected void ShowLogsButton_OnClick(object sender, EventArgs e) { //show logs + + string wpiLogsDir = null; + object[] logsEntrys = null; try { - string wpiLogsDir = ViewState[_wpiLogsDirViewStateKey] as string; + wpiLogsDir = ViewState[_wpiLogsDirViewStateKey] as string; if (!string.IsNullOrEmpty(wpiLogsDir)) { //Get logs !!! - object[] logsEntrys = ES.Services.Servers.WpiGetLogsInDirectory(PanelRequest.ServerId, wpiLogsDir); + logsEntrys = ES.Services.Servers.WpiGetLogsInDirectory(PanelRequest.ServerId, wpiLogsDir); - WpiLogsPanel.Visible = true; - - StringBuilder sb = new StringBuilder(); - - foreach (SettingPair entry in logsEntrys) + if (null == logsEntrys) { - string fileName = (string)entry.Name; - string fileContent = (string)entry.Value; - sb.AppendLine().AppendFormat("

{0}

", fileName).AppendLine().Append(fileContent).AppendLine(); + WpiLogsPanel.Visible = true; + string msg = string.Format("Could not get logs files. Log files folder:\n{0}", wpiLogsDir); + WpiLogsPre.InnerText = msg; } + else + { + WpiLogsPanel.Visible = true; - WpiLogsPre.InnerHtml = sb.ToString(); + StringBuilder sb = new StringBuilder(); - ShowLogsButton.Visible = false; - ProgressTimer.Enabled = false; + foreach (SettingPair entry in logsEntrys) + { + string fileName = (string) entry.Name; + string fileContent = (string) entry.Value; + sb.AppendLine().AppendFormat("

{0}

", fileName).AppendLine().Append(fileContent). + AppendLine(); + } + + WpiLogsPre.InnerHtml = sb.ToString(); + + ShowLogsButton.Visible = false; + ProgressTimer.Enabled = false; + } } } catch (Exception ex) { WpiLogsPanel.Visible = true; - WpiLogsPre.InnerText = ex.ToString(); + string msg = string.Format("wpiLogsDir: {0}\nlogsEntrys is null: {1}\n{2}", wpiLogsDir, logsEntrys == null, ex); + WpiLogsPre.InnerText = msg; } } }