4 Replies Latest reply on Oct 18, 2013 6:17 AM by ashley.cotter

    Need an ASP guru to fix resource

    sotherls

      I need some assitance from a ASP guru out there..... I had a working resource in 9.5x that showed me current down devices and time it went down and duration. It worked very well but in version 10.x when I click on the edit button I get an error and need to see what needs to be tweaked.

      The working resource looks like this:

       

      But when I hit the Edit button I see this error:

      I also see the error on a custom page which lists nodes by their name suffices. It seems that the code for the edit function changed and I am not sure how to get around it.

      The code for the resource I am using is:

      <%@ Control Language="C#" ClassName="Outages" Inherits="SolarWinds.Orion.Web.UI.BaseResourceControl" %>
      <%@ Import Namespace="System.Data.SqlClient"%>
      <%@ Import Namespace="SolarWinds.Orion.Common"%>
      <%@ Import Namespace="SolarWinds.Orion.Web.DAL"%>
      <%@ Import Namespace="System.Data"%>
      <%@ Register TagPrefix="orion" Namespace="SolarWinds.Orion.Web.Controls" %>

      <script runat="server">
          protected void Page_Load(object sender, EventArgs e)
          {
              string filter = this.Resource.Properties["Filter"];

              DataTable table;

              try
              {
                  string sql = @"
      SELECT Nodes.NodeID, Nodes.Caption, Nodes.StatusDescription, Nodes.GroupStatus, Nodes.StatusLED,
      Nodes.IP_Address, Nodes.DNS, Nodes.SysName, Nodes.status_info, WebCommunityStrings.GUID,
      MAX(E.EventTime) AS DownTime,
      Cast(DateDiff(day,MAX(E.EventTime),getdate()) as varchar) + ' Day(s) ' + convert(char(8),dateadd(second,DateDiff(second,MAX(E.EventTime),getdate()),0),14) as Duration, Nodes.Department
      FROM Nodes
      INNER JOIN Events E ON E.NetworkNode = Nodes.NodeID
      LEFT OUTER JOIN WebCommunityStrings ON WebCommunityStrings.CommunityString = Nodes.Community
      WHERE Nodes.status = 2 {0}
      GROUP BY Nodes.StatusLED, Nodes.Caption, Nodes.Department, Nodes.NodeID, Nodes.StatusDescription, Nodes.GroupStatus, Nodes.IP_Address, Nodes.DNS, Nodes.SysName, Nodes.status_info, WebCommunityStrings.GUID
      ORDER BY Nodes.Caption
      ";
                  if (!String.IsNullOrEmpty(filter))
                      sql = string.Format(sql, "AND " + filter.Replace('*', '%').Replace('?', '_'));
                  else
                      sql = string.Format(sql, "");
         
                  using (SqlCommand cmd = SqlHelper.GetTextCommand(Limitation.LimitSQL(sql)))
                  {
                      table = SqlHelper.ExecuteDataTable(cmd);
                  }
              }
              catch (SqlException)
              {
                  this.SQLErrorPanel.Visible = true;
                  return;
              }

              this.downNodesTable.DataSource = table;
              this.downNodesTable.DataBind();
          }

          protected override string DefaultTitle
          {
              get { return "Current Down Devices and Status"; }
          }

          public override string HelpLinkFragment
          {
              get { return "OrionPHResourceDownNodes"; }
          }

          public override string EditURL
          {
              get
              {
                  string url = String.Format("/Orion/NetPerfMon/Resources/FilterEdit.aspx?ResourceID={0}&ViewID={1}&HideInterfaceFilter=True",
                      this.Resource.ID, this.Resource.View.ViewID);
                  if (!String.IsNullOrEmpty(this.Request.QueryString["NetObject"]))
                  {
                      url += "&NetObject=" + this.Request.QueryString["NetObject"];
                  }

                  return url;
              }
          }

          public override string SubTitle
          {
              get
              {
                  string subTitle = base.SubTitle;
                  if (String.IsNullOrEmpty(subTitle))
                  {
                      return "The Following Nodes are not Responding";
                  }
                  return subTitle;
              }
          }
      </script>

      <orion:resourceWrapper runat="server" ID="wrapper">
          <Content>
              <asp:Panel ID="SQLErrorPanel" runat="server" Visible="false">
                  <table cellpadding="10px">
                      <tr>
                          <td style="font-weight: bold; font-size: small; color: Red">
                              Custom SQL filter is incorrectly formated.
                          </td>
                      </tr>
                  </table>
              </asp:Panel>
              <asp:Repeater runat="server" ID="downNodesTable">
                  <HeaderTemplate>
                      <table border="0" cellpadding="2" cellspacing="0" width="100%">
                          <tr>
                              <th class="ReportHeader" colspan="2">DEVICE</th>
                              <th class="ReportHeader">LAST CHANGE</th>
                              <th class="ReportHeader">DURATION</th>
                              <th class="ReportHeader">DEPARTMENT</th>
                              <th class="ReportHeader">COMMENTS</th>
                          </tr>
                  </HeaderTemplate>
                  <ItemTemplate>
                      <tr>
                    <td class="Property" valign="middle" width="20">
                        <img alt="Status" src='/Orion/images/StatusIcons/Small-<%# Eval("StatusLED").ToString().Trim() %>' /> 
                    </td>
                    <td class="Property">
                        <orion:ToolsetLink ID="ToolsetLink1" runat="server" IPAddress='<%# Eval("IP_Address") %>' DNS='<%# Eval("DNS") %>' SysName='<%# Eval("SysName") %>' CommunityGUID='<%# Eval("GUID") %>' NodeID='<%# Eval("NodeID") %>' ToolTip='<%# Eval("StatusDescription") %>'>
                            <%# Eval("Caption") %>
                        </orion:ToolsetLink>
                    </td>
                    <td class="Property"><%# Eval("Downtime") %></td>
                    <td class="Property"><%# Eval("Duration") %></td>
                    <td class="Property"><%# Eval("Department") %></td>
                    <td class="Property"><%# Eval("Status_Info") %></td>
                </tr>
                  </ItemTemplate>
                  <FooterTemplate>
                      </table>
                  </FooterTemplate>
              </asp:Repeater>
          </Content>
      </orion:resourceWrapper>