Configuration branch

This commit is contained in:
2025-10-11 09:44:08 -04:00
parent 0e59b296a3
commit b9a2709fd5
31 changed files with 1367 additions and 1057 deletions
+16 -42
View File
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="Current" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup> <PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -14,23 +14,9 @@
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<FileUpgradeFlags> <FileUpgradeFlags>
</FileUpgradeFlags> </FileUpgradeFlags>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<OldToolsVersion>3.5</OldToolsVersion> <OldToolsVersion>3.5</OldToolsVersion>
<UpgradeBackupLocation />
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
@@ -40,7 +26,6 @@
<DefineConstants>DEBUG;TRACE</DefineConstants> <DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
@@ -49,51 +34,40 @@
<DefineConstants>TRACE</DefineConstants> <DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="HtmlAgilityPack, Version=1.3.0.0, Culture=neutral, PublicKeyToken=bd319b19eaf3b43a, processorArchitecture=MSIL"> <Reference Include="HtmlAgilityPack, Version=1.3.0.0, Culture=neutral, PublicKeyToken=bd319b19eaf3b43a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>References\HtmlAgilityPack.dll</HintPath> <HintPath>References\HtmlAgilityPack.dll</HintPath>
</Reference> </Reference>
<Reference Include="Oracle.DataAccess, Version=2.102.2.20, Culture=neutral, PublicKeyToken=89b483f429c47342, processorArchitecture=x86">
<SpecificVersion>False</SpecificVersion>
<HintPath>References\Oracle.DataAccess.dll</HintPath>
</Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.configuration" /> <Reference Include="System.configuration" />
<Reference Include="System.Data" /> <Reference Include="System.Data" />
<Reference Include="System.Management" />
<Reference Include="System.ServiceProcess" />
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="HtmlEndpoint.cs" /> <Compile Include="HtmlEndpoint.cs" />
<Compile Include="IEndpoint.cs" /> <Compile Include="HtmlEndpointConfiguration.cs" />
<Compile Include="HttpEndpointConfiguration.cs" />
<Compile Include="IHttpEndpointConfiguration.cs" />
<Compile Include="OracleEndpoint.cs" />
<Compile Include="OracleEndpointConfiguration.cs" />
<Compile Include="IServiceEndpointConfiguration.cs" />
<Compile Include="HttpEndpoint.cs" /> <Compile Include="HttpEndpoint.cs" />
<Compile Include="IServiceEndpoint.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ServiceEndpointFactory.cs" />
<Compile Include="SoapEndpointConfiguration.cs" />
<Compile Include="SoapEndpoint.cs" /> <Compile Include="SoapEndpoint.cs" />
<Compile Include="Status.cs" /> <Compile Include="Status.cs" />
<Compile Include="StatusComparer.cs" />
<Compile Include="WindowsServiceEndpoint.cs" />
<Compile Include="WmiEndpoint.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="App.config" /> <None Include="App.config" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
<Visible>False</Visible>
<ProductName>Windows Installer 3.1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets. Other similar extension points exist, see Microsoft.Common.targets.
+34 -36
View File
@@ -6,36 +6,15 @@ using HtmlAgilityPack;
namespace Endpoint namespace Endpoint
{ {
/// <summary>
/// A website endpoint
/// </summary>
public class HtmlEndpoint : HttpEndpoint public class HtmlEndpoint : HttpEndpoint
{ {
/// <summary> /// <summary>
/// Gets or sets the xpath query for the html document /// Returns the HTML parsed into a standard XmlDocument.
/// </summary> /// Uses the HtmlAgilityPack library for "out of the web" (poorly formatted) html file support.
/// <value>The xpath query.</value>
public string XpathQuery { get; set; }
/// <summary>
/// Gets or sets the expected query results.
/// </summary>
/// <value>The expected query results.</value>
public string ExpectedXpathResult { get; set; }
/// <summary>
/// Gets or sets the post.
/// </summary>
/// <value>The post.</value>
public string RequestContent { get; set; }
/// <summary>
/// Returns the HTML parsed into a standard <see cref="XmlDocument"/>.
/// Uses the <see cref="HtmlAgilityPack"/> library for "out of the web" (poorly formatted) html file support.
/// </summary> /// </summary>
/// <param name="html">The HTML</param> /// <param name="html">The HTML</param>
/// <returns>An <see cref="XmlDocument"/> from the HTML</returns> /// <returns>An XmlDocument from the HTML</returns>
private static XmlDocument getHtmlXml(string html) private static XmlDocument GetHtmlXml(string html)
{ {
var htmlDocument = new HtmlDocument(); var htmlDocument = new HtmlDocument();
htmlDocument.LoadHtml(html); htmlDocument.LoadHtml(html);
@@ -58,15 +37,34 @@ namespace Endpoint
} }
/// <summary> /// <summary>
/// Returns the HTML grabbed from the passed in URL parsed into a standard <see cref="XmlDocument"/>. /// Returns the HTML grabbed from the passed in URL parsed into a standard XmlDocument.
/// Uses the <see cref="HtmlAgilityPack"/> library for "out of the web" html file support. /// Uses the HtmlAgilityPack library for "out of the web" html file support.
/// </summary> /// </summary>
/// <param name="url">The URL.</param> /// <param name="url">The URL.</param>
/// <param name="requestContent">The post data.</param> /// <param name="requestContent">The post data.</param>
/// <returns>An <see cref="XmlDocument"/> from the HTML</returns> /// <returns>An XmlDocument from the HTML</returns>
private static XmlDocument getHtmlXml(Uri url, string requestContent) private static XmlDocument GetHtmlXml(Uri url, string requestContent)
{
return GetHtmlXml(GetUrlContent(url, "application/x-www-form-urlencoded", requestContent, null));
}
/// <summary>
/// Gets the HTTP endpoint configuration.
/// </summary>
/// <value>The HTTP endpoint configuration.</value>
public HtmlEndpointConfiguration HtmlEndpointConfiguration
{
get { return (HtmlEndpointConfiguration)_httpEndpointConfiguration; }
}
/// <summary>
/// Initializes a new instance of the <see cref="HttpEndpoint"/> class.
/// </summary>
/// <param name="config">The HttpEndpointConfiguration.</param>
public HtmlEndpoint(HtmlEndpointConfiguration config)
: base(config)
{ {
return getHtmlXml(GetUrlContent(url, "application/x-www-form-urlencoded", requestContent, null));
} }
/// <summary> /// <summary>
@@ -75,17 +73,17 @@ namespace Endpoint
/// <returns>Status</returns> /// <returns>Status</returns>
public override Status GetStatus() public override Status GetStatus()
{ {
var baseStatus = base.GetStatus(); Status baseStatus = base.GetStatus();
if (baseStatus != Status.Up) if (baseStatus != Status.Up)
return baseStatus; return baseStatus;
try try
{ {
var xml = getHtmlXml(Uri, RequestContent); XmlDocument xml = GetHtmlXml(HttpEndpointConfiguration.Uri, HtmlEndpointConfiguration.RequestContent);
// xml.Save(@"c:\test.xml"); // xml.Save(@"c:\test.xml");
var nodes = xml.SelectNodes(XpathQuery); XmlNodeList nodes = xml.SelectNodes(HtmlEndpointConfiguration.XpathQuery);
// verify html has expected value // verify html has expected value
if (nodes == null || nodes.Count == 0) if (nodes == null || nodes.Count == 0)
@@ -93,11 +91,11 @@ namespace Endpoint
StatusDescription = "Couldn't find expected value in html"; StatusDescription = "Couldn't find expected value in html";
return Status.Error; return Status.Error;
} }
var value = nodes[0].Value.Trim(); string value = nodes[0].Value.Trim();
if (value != ExpectedXpathResult) if (value != HtmlEndpointConfiguration.ExpectedXpathResult)
{ {
StatusDescription = String.Format("Result was: '{0}', was expecting '{1}'", value, StatusDescription = String.Format("Result was: '{0}', was expecting '{1}'", value,
ExpectedXpathResult); HtmlEndpointConfiguration.ExpectedXpathResult);
return Status.Error; return Status.Error;
} }
} }
+114
View File
@@ -0,0 +1,114 @@
using System;
using System.Configuration;
using System.Xml.Serialization;
namespace Endpoint
{
/// <summary>
/// Defines a configuration for an html webpage endpoint
/// </summary>
public class HtmlEndpointConfiguration : ConfigurationElement, IHttpEndpointConfiguration
{
/// <summary>
/// Gets or sets the name.
/// </summary>
/// <value>The name.</value>
[ConfigurationProperty("name", DefaultValue = "", IsKey = true, IsRequired = true)]
public string Name
{
get { return (string)base["name"]; }
set { base["name"] = value; }
}
/// <summary>
/// URI of the service
/// </summary>
[XmlIgnore]
public Uri Uri
{
get { return new Uri(UriString); }
}
/// <summary>
/// Gets or sets the URI string.
/// </summary>
/// <value>The URI string.</value>
[ConfigurationProperty("uri", DefaultValue = "", IsKey = false, IsRequired = true)]
public string UriString
{
get { return (string)base["uri"]; }
set { base["uri"] = value; }
}
/// <summary>
/// Gets or sets the xpath query for the html document
/// </summary>
/// <value>The xpath query.</value>
[ConfigurationProperty("xpathQuery", DefaultValue = "", IsKey = false, IsRequired = true)]
public string XpathQuery
{
get { return (string)base["xpathQuery"]; }
set { base["xpathQuery"] = value; }
}
/// <summary>
/// Gets or sets the expected query results.
/// </summary>
/// <value>The expected query results.</value>
[ConfigurationProperty("expectedXpathResult", DefaultValue = "", IsKey = false, IsRequired = true)]
public string ExpectedXpathResult
{
get { return (string)base["expectedXpathResult"]; }
set { base["expectedXpathResult"] = value; }
}
/// <summary>
/// Gets or sets the post.
/// </summary>
/// <value>The post.</value>
[ConfigurationProperty("requestContent", DefaultValue = "", IsKey = false, IsRequired = false)]
public string RequestContent
{
get { return (string)base["requestContent"]; }
set { base["requestContent"] = value; }
}
}
/// <summary>
///
/// </summary>
public class HtmlEndpointConfigurationCollection : ConfigurationElementCollection
{
/// <summary>
/// When overridden in a derived class, creates a new <see cref="T:System.Configuration.ConfigurationElement" />.
/// </summary>
/// <returns>
/// A new <see cref="T:System.Configuration.ConfigurationElement" />.
/// </returns>
protected override ConfigurationElement CreateNewElement()
{
return new HtmlEndpointConfiguration();
}
/// <summary>
/// Gets the element key for a specified configuration element when overridden in a derived class.
/// </summary>
/// <returns>
/// An <see cref="T:System.Object" /> that acts as the key for the specified <see cref="T:System.Configuration.ConfigurationElement" />.
/// </returns>
/// <param name="element">The <see cref="T:System.Configuration.ConfigurationElement" /> to return the key for. </param>
protected override object GetElementKey(ConfigurationElement element)
{
return ((HtmlEndpointConfiguration)element).Name;
}
}
/// <summary>
///
/// </summary>
public class HtmlEndpointConfigurationSection : ConfigurationSection
{
[ConfigurationProperty("endpoints")]
public HtmlEndpointConfigurationCollection Endpoints { get { return (HtmlEndpointConfigurationCollection)(base["endpoints"]); } }
}
}
+68 -44
View File
@@ -1,8 +1,8 @@
using System; using System;
using System.Collections.Generic;
using System.IO; using System.IO;
using System.Net; using System.Net;
using System.Text; using System.Text;
using System.Collections.Generic;
namespace Endpoint namespace Endpoint
{ {
@@ -10,66 +10,50 @@ namespace Endpoint
/// Http Endpoint - such as a webserver, a webservice, etc /// Http Endpoint - such as a webserver, a webservice, etc
/// </summary> /// </summary>
[Serializable] [Serializable]
public class HttpEndpoint : IEndpoint public class HttpEndpoint : IServiceEndpoint
{ {
/// <summary>
/// Gets or sets the name.
/// </summary>
/// <value>The name.</value>
public string Name { get; set; }
/// <summary>
/// URI of the service
/// </summary>
public Uri Uri { get; set; }
/// <summary>
/// Gets or sets the URI string.
/// </summary>
/// <value>The URI string.</value>
public string UriString
{
get { return Uri.ToString(); }
set { Uri = new Uri(value); }
}
/// <summary> /// <summary>
/// Returns the response string grabbed from the passed in URL. /// Returns the response string grabbed from the passed in URL.
/// </summary> /// </summary>
/// <param name="url">The URL.</param> /// <param name="url">The URL.</param>
/// <param name="contentType">The HTTP content type.</param> /// <param name="contentType">The HTTP contentType.</param>
/// <param name="requestContent">The request content.</param> /// <param name="requestContent">The request content.</param>
/// <param name="webHeaders">The web headers.</param> /// <param name="webHeaders">The web headers.</param>
/// <returns>A string containing response</returns> /// <returns>A string containing response</returns>
protected static string GetUrlContent(Uri url, string contentType, string requestContent, protected static string GetUrlContent(Uri url, string contentType, string requestContent, Dictionary<string,string> webHeaders)
Dictionary<string, string> webHeaders)
{ {
// POST request // POST request
if (!string.IsNullOrEmpty(contentType) && !string.IsNullOrEmpty(requestContent)) if (!string.IsNullOrEmpty(contentType) && !string.IsNullOrEmpty(requestContent))
{ {
var webRequest = (HttpWebRequest) WebRequest.Create(url); HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url);
// NOTE: need a proxy? Here's where it would go // NOTE: proxy?
// webRequest.Proxy = new WebProxy(); // webRequest.Proxy = new WebProxy();
// SOAP // SOAP
webRequest.ContentType = contentType; webRequest.ContentType = contentType;
if (webHeaders != null && webHeaders.Count > 0) if (webHeaders != null && webHeaders.Count > 0)
{ foreach (KeyValuePair<string, string> webHeader in webHeaders)
foreach (var webHeader in webHeaders)
webRequest.Headers.Add(webHeader.Key, webHeader.Value); webRequest.Headers.Add(webHeader.Key, webHeader.Value);
}
// NOTE: SOAPACtion
//webRequest.Headers.Add("SOAPAction", "\"urn:getPaymentKey\"");
// FORM
//webRequest.ContentType = "application/x-www-form-urlencoded";
webRequest.Method = "POST"; webRequest.Method = "POST";
// webRequest.Accept = "text/xml";
//We need to count how many bytes we're sending. Post'ed Faked Forms should be name=value& //We need to count how many bytes we're sending. Post'ed Faked Forms should be name=value&
var bytes = Encoding.ASCII.GetBytes(requestContent); byte[] bytes = Encoding.ASCII.GetBytes(requestContent);
webRequest.ContentLength = bytes.Length; webRequest.ContentLength = bytes.Length;
using (var requestStream = webRequest.GetRequestStream()) using (Stream requestStream = webRequest.GetRequestStream())
{ {
requestStream.Write(bytes, 0, bytes.Length); //write it to the stream requestStream.Write(bytes, 0, bytes.Length); //write it to the stream
} }
var webResponse = webRequest.GetResponse(); WebResponse webResponse = webRequest.GetResponse();
if (webResponse == null) if (webResponse == null)
return null; return null;
using (var streamReader = new StreamReader(webResponse.GetResponseStream())) using (var streamReader = new StreamReader(webResponse.GetResponseStream()))
@@ -80,18 +64,46 @@ namespace Endpoint
// GET Request // GET Request
var client = new WebClient(); var client = new WebClient();
using (var data = client.OpenRead(url)) using (Stream data = client.OpenRead(url))
using (var reader = new StreamReader(data)) using (var reader = new StreamReader(data))
{ {
return reader.ReadToEnd(); return reader.ReadToEnd();
} }
} }
protected readonly IHttpEndpointConfiguration _httpEndpointConfiguration;
/// <summary> /// <summary>
/// Returns a string explaining details on the current status /// Returns a string explaining details on the current status
/// </summary> /// </summary>
/// <returns>string with status message</returns> /// <returns>string with status message</returns>
public virtual string StatusDescription { get; protected set; } public virtual string StatusDescription
{
get; protected set;
}
public IServiceEndpointConfiguration ServiceEndpointConfiguration
{
get { return _httpEndpointConfiguration; }
}
/// <summary>
/// Gets the service name
/// </summary>
/// <value></value>
public string ServiceName
{
get { return _httpEndpointConfiguration.Name; }
}
/// <summary>
/// Gets the HTTP endpoint configuration.
/// </summary>
/// <value>The HTTP endpoint configuration.</value>
public IHttpEndpointConfiguration HttpEndpointConfiguration
{
get { return _httpEndpointConfiguration; }
}
/// <summary> /// <summary>
/// Gets the current status result of the endpoint /// Gets the current status result of the endpoint
@@ -101,24 +113,36 @@ namespace Endpoint
{ {
try try
{ {
var request = WebRequest.Create(Uri); WebRequest request = WebRequest.Create(HttpEndpointConfiguration.Uri);
using (var response = (HttpWebResponse) request.GetResponse()) using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
{ {
StatusDescription = response.StatusDescription; StatusDescription = response.StatusDescription;
return response.StatusCode == HttpStatusCode.OK if (response.StatusCode == HttpStatusCode.OK)
? Status.Up return Status.Up;
: Status.Unreachable; return Status.Unreachable;
} }
} }
catch (WebException ex) catch (WebException ex)
{ {
StatusDescription = ex.Message + " (" + ex.Status + ")"; StatusDescription = ex.Message + " (" + ex.Status + ")";
return ex.Status == WebExceptionStatus.Timeout // TODO: LOG
? Status.Timeout if (ex.Status == WebExceptionStatus.Timeout)
: Status.Unreachable; {
return Status.Timeout;
}
return Status.Unreachable;
} }
} }
/// <summary>
/// Initializes a new instance of the <see cref="HttpEndpoint"/> class.
/// </summary>
/// <param name="config">The HttpEndpointConfiguration.</param>
public HttpEndpoint(IHttpEndpointConfiguration config)
{
_httpEndpointConfiguration = config;
}
} }
} }
+128
View File
@@ -0,0 +1,128 @@
using System;
using System.Configuration;
using System.Xml.Serialization;
namespace Endpoint
{
/// <summary>
/// Defines a configuration for an http service endpoint
/// </summary>
public class HttpEndpointConfiguration : ConfigurationElement, IHttpEndpointConfiguration
{
/// <summary>
/// Gets or sets the name.
/// </summary>
/// <value>The name.</value>
[ConfigurationProperty("name", DefaultValue = "", IsKey = true, IsRequired = true)]
public string Name
{
get { return (string) base["name"]; }
set { base["name"] = value; }
}
/// <summary>
/// URI of the service
/// </summary>
[XmlIgnore]
public Uri Uri
{
get { return new Uri((string) base["uri"]); }
}
/// <summary>
/// Gets or sets the URI string.
/// </summary>
/// <value>The URI string.</value>
[ConfigurationProperty("uri", DefaultValue = "", IsKey = false, IsRequired = true)]
public string UriString
{
get { return (string)base["uri"]; }
set { base["uri"] = value; }
}
/// <summary>
/// Initializes a new instance of the <see cref="HttpEndpointConfiguration"/> class.
/// </summary>
/// <param name="serviceName">The name.</param>
/// <param name="uri">The uri.</param>
public HttpEndpointConfiguration(string serviceName, Uri uri)
{
Name = serviceName;
UriString = uri.OriginalString;
}
/// <summary>
/// Initializes a new instance of the <see cref="HttpEndpointConfiguration"/> class.
/// </summary>
internal protected HttpEndpointConfiguration()
{
}
/// <summary>
/// Determines whether the specified <see cref="T:System.Object"/> is equal to the current <see cref="T:System.Object"/>.
/// </summary>
/// <param name="obj">The <see cref="T:System.Object"/> to compare with the current <see cref="T:System.Object"/>.</param>
/// <returns>
/// true if the specified <see cref="T:System.Object"/> is equal to the current <see cref="T:System.Object"/>; otherwise, false.
/// </returns>
/// <exception cref="T:System.NullReferenceException">The <paramref name="obj"/> parameter is null.</exception>
public override bool Equals(object obj)
{
HttpEndpointConfiguration value = obj as HttpEndpointConfiguration;
if (value == null)
return false;
if (value.Uri != Uri)
return false;
return true;
}
/// <summary>
/// Serves as a hash function for a particular type.
/// </summary>
/// <returns>
/// A hash code for the current <see cref="T:System.Object"/>.
/// </returns>
public override int GetHashCode()
{
return Uri.GetHashCode();
}
}
/// <summary>
///
/// </summary>
public class HttpEndpointConfigurationCollection : ConfigurationElementCollection
{
/// <summary>
/// When overridden in a derived class, creates a new <see cref="T:System.Configuration.ConfigurationElement" />.
/// </summary>
/// <returns>
/// A new <see cref="T:System.Configuration.ConfigurationElement" />.
/// </returns>
protected override ConfigurationElement CreateNewElement()
{
return new HttpEndpointConfiguration();
}
/// <summary>
/// Gets the element key for a specified configuration element when overridden in a derived class.
/// </summary>
/// <returns>
/// An <see cref="T:System.Object" /> that acts as the key for the specified <see cref="T:System.Configuration.ConfigurationElement" />.
/// </returns>
/// <param name="element">The <see cref="T:System.Configuration.ConfigurationElement" /> to return the key for. </param>
protected override object GetElementKey(ConfigurationElement element)
{
return ((HttpEndpointConfiguration) element).Name;
}
}
/// <summary>
///
/// </summary>
public class HttpEndpointConfigurationSection : ConfigurationSection
{
[ConfigurationProperty("endpoints")]
public HttpEndpointConfigurationCollection Endpoints { get { return (HttpEndpointConfigurationCollection)(base["endpoints"]); } }
}
}
+18
View File
@@ -0,0 +1,18 @@
using System;
using System.Configuration;
using System.Xml.Serialization;
namespace Endpoint
{
public interface IHttpEndpointConfiguration : IServiceEndpointConfiguration
{
/// <summary>
/// URI of the service
/// </summary>
[XmlIgnore]
Uri Uri { get; }
[ConfigurationProperty("uri", DefaultValue = "", IsKey = false, IsRequired = false)]
string UriString { get; set; }
}
}
+31
View File
@@ -0,0 +1,31 @@
namespace Endpoint
{
/// <summary>
/// Describes a service endpoint, and the methods to find its current status
/// </summary>
public interface IServiceEndpoint
{
/// <summary>
/// Configuration of the endpoint
/// </summary>
IServiceEndpointConfiguration ServiceEndpointConfiguration { get; }
/// <summary>
/// Gets the service name
/// </summary>
string ServiceName { get; }
/// <summary>
/// Gets the current status result of the endpoint
/// </summary>
/// <returns>Status</returns>
Status GetStatus();
/// <summary>
/// Returns a string explaining details on the current status
/// </summary>
/// <returns>string with status message</returns>
string StatusDescription { get; }
}
}
+11
View File
@@ -0,0 +1,11 @@
namespace Endpoint
{
/// <summary>
/// Describes a service endpoint's configuration
/// </summary>
public interface IServiceEndpointConfiguration
{
string Name { get; set; }
}
}
+60
View File
@@ -0,0 +1,60 @@
using System;
using Oracle.DataAccess.Client;
namespace Endpoint
{
public class OracleEndpoint : IServiceEndpoint
{
private readonly OracleEndpointConfiguration _serviceEndpointConfiguration;
public IServiceEndpointConfiguration ServiceEndpointConfiguration
{
get { return _serviceEndpointConfiguration; }
}
public string ServiceName
{
get { return _serviceEndpointConfiguration.Name; }
}
public string StatusDescription { get; private set; }
public Status GetStatus()
{
using (OracleConnection oracleConnection = new OracleConnection(_serviceEndpointConfiguration.ConnectionString))
using (OracleCommand oracleCommand = new OracleCommand(_serviceEndpointConfiguration.ScalarQueryString, oracleConnection))
{
try
{
oracleConnection.Open();
object result = oracleCommand.ExecuteScalar();
string resultString = result.ToString();
if (resultString != _serviceEndpointConfiguration.ExpectedQueryResult)
{
StatusDescription = String.Format("Result was: '{0}', was expecting '{1}'", resultString,
_serviceEndpointConfiguration.ExpectedQueryResult);
return Status.Error;
}
}
catch(Exception ex)
{
StatusDescription = ex.Message;
return Status.Error;
}
}
StatusDescription = "OK";
return Status.Up;
}
/// <summary>
/// Initializes a new instance of the <see cref="OracleEndpoint"/> class.
/// </summary>
/// <param name="config">The config.</param>
public OracleEndpoint(OracleEndpointConfiguration config)
{
_serviceEndpointConfiguration = config;
StatusDescription = "";
}
}
}
+155
View File
@@ -0,0 +1,155 @@
using System;
using System.Configuration;
namespace Endpoint
{
/// <summary>
/// Defines a configuration for an oracle service endpoint
/// </summary>
public class OracleEndpointConfiguration : ConfigurationElement, IServiceEndpointConfiguration
{
/// <summary>
/// Gets or sets the name.
/// </summary>
/// <value>The name.</value>
[ConfigurationProperty("name", DefaultValue = "", IsKey = true, IsRequired = true)]
public string Name
{
get { return (string)base["name"]; }
set { base["name"] = value; }
}
/// <summary>
/// Gets or sets the connection string.
/// </summary>
/// <value>The connection string.</value>
[ConfigurationProperty("connectionString", DefaultValue = "", IsKey = false, IsRequired = true)]
public string ConnectionString
{
get { return (string)base["connectionString"]; }
set { base["connectionString"] = value; }
}
/// <summary>
/// Gets or sets the connection string.
/// </summary>
/// <value>The connection string.</value>
[ConfigurationProperty("scalarQueryString", DefaultValue = "", IsKey = false, IsRequired = true)]
public string ScalarQueryString
{
get { return (string)base["scalarQueryString"]; }
set { base["scalarQueryString"] = value; }
}
/// <summary>
/// Gets or sets the connection string.
/// </summary>
/// <value>The connection string.</value>
[ConfigurationProperty("expectedQueryResult", DefaultValue = "", IsKey = false, IsRequired = true)]
public string ExpectedQueryResult
{
get { return (string)base["expectedQueryResult"]; }
set { base["expectedQueryResult"] = value; }
}
/// <summary>
/// Initializes a new instance of the <see cref="OracleEndpointConfiguration"/> class.
/// </summary>
internal protected OracleEndpointConfiguration()
{}
/// <summary>
/// Initializes a new instance of the <see cref="OracleEndpointConfiguration"/> class.
/// </summary>
/// <param name="serviceName">Name of the service.</param>
/// <param name="connectionString">The connection string.</param>
/// <param name="scalarQueryString">The scalar query string.</param>
/// <param name="expectedQueryResult">The expected query result.</param>
public OracleEndpointConfiguration(string serviceName, string connectionString, string scalarQueryString, string expectedQueryResult)
{
if (serviceName == null)
throw new ArgumentNullException("serviceName");
if (connectionString == null)
throw new ArgumentNullException("connectionString");
if (scalarQueryString == null)
throw new ArgumentNullException("scalarQueryString");
if (expectedQueryResult == null)
throw new ArgumentNullException("expectedQueryResult");
ConnectionString = connectionString;
ScalarQueryString = scalarQueryString;
ExpectedQueryResult = expectedQueryResult;
}
/// <summary>
/// Determines whether the specified <see cref="T:System.Object"/> is equal to the current <see cref="T:System.Object"/>.
/// </summary>
/// <param name="obj">The <see cref="T:System.Object"/> to compare with the current <see cref="T:System.Object"/>.</param>
/// <returns>
/// true if the specified <see cref="T:System.Object"/> is equal to the current <see cref="T:System.Object"/>; otherwise, false.
/// </returns>
/// <exception cref="T:System.NullReferenceException">The <paramref name="obj"/> parameter is null.</exception>
public override bool Equals(object obj)
{
OracleEndpointConfiguration value = obj as OracleEndpointConfiguration;
if (value == null)
return false;
if (value.ConnectionString != ConnectionString || value.ScalarQueryString != ScalarQueryString)
return false;
return true;
}
/// <summary>
/// Serves as a hash function for a OracleEndpointConfiguration.
/// </summary>
/// <returns>
/// A hash code for the current <see cref="T:System.Object"/>.
/// </returns>
public override int GetHashCode()
{
return ConnectionString.GetHashCode() ^ ScalarQueryString.GetHashCode();
}
}
/// <summary>
///
/// </summary>
public class OracleEndpointConfigurationCollection : ConfigurationElementCollection
{
/// <summary>
/// When overridden in a derived class, creates a new <see cref="T:System.Configuration.ConfigurationElement" />.
/// </summary>
/// <returns>
/// A new <see cref="T:System.Configuration.ConfigurationElement" />.
/// </returns>
protected override ConfigurationElement CreateNewElement()
{
return new OracleEndpointConfiguration();
}
/// <summary>
/// Gets the element key for a specified configuration element when overridden in a derived class.
/// </summary>
/// <returns>
/// An <see cref="T:System.Object" /> that acts as the key for the specified <see cref="T:System.Configuration.ConfigurationElement" />.
/// </returns>
/// <param name="element">The <see cref="T:System.Configuration.ConfigurationElement" /> to return the key for. </param>
protected override object GetElementKey(ConfigurationElement element)
{
return ((OracleEndpointConfiguration)element).Name;
}
}
/// <summary>
///
/// </summary>
public class OracleEndpointConfigurationSection : ConfigurationSection
{
/// <summary>
/// Gets the endpoints.
/// </summary>
/// <value>The endpoints.</value>
[ConfigurationProperty("endpoints")]
public OracleEndpointConfigurationCollection Endpoints { get { return (OracleEndpointConfigurationCollection)(base["endpoints"]); } }
}
}
+31
View File
@@ -0,0 +1,31 @@
using System;
namespace Endpoint
{
/// <summary>
/// ServiceEndpointFactory
/// </summary>
public class ServiceEndpointFactory
{
/// <summary>
/// Creates the service endpoint based on the scheme
/// </summary>
/// <param name="config">The service endpoint configuration.</param>
/// <returns>The service endpoint.</returns>
public static IServiceEndpoint CreateServiceEndpoint(IServiceEndpointConfiguration config)
{
Type type = config.GetType();
if (type == typeof(HtmlEndpointConfiguration))
return new HtmlEndpoint((HtmlEndpointConfiguration)config);
if (type == typeof(HttpEndpointConfiguration))
return new HttpEndpoint((HttpEndpointConfiguration)config);
if (type == typeof(OracleEndpointConfiguration))
return new OracleEndpoint((OracleEndpointConfiguration)config);
throw new ArgumentException("Unknown type: " + type);
}
}
}
+27 -48
View File
@@ -4,92 +4,71 @@ using System.Xml;
namespace Endpoint namespace Endpoint
{ {
/// <summary>
/// A SOAP webservice endpoint.
/// </summary>
public class SoapEndpoint : HttpEndpoint public class SoapEndpoint : HttpEndpoint
{ {
private string _xpathNamespaces = string.Empty;
private Dictionary<string, string> _namespaceToUri; private Dictionary<string, string> _namespaceToUri;
/// <summary> /// <summary>
/// Gets or sets the xpath query for the html document /// Gets the SOAP endpoint configuration.
/// </summary> /// </summary>
/// <value>The xpath query.</value> /// <value>The SOAP endpoint configuration.</value>
public string XpathQuery { get; set; } public SoapEndpointConfiguration SoapEndpointConfiguration
{
get { return (SoapEndpointConfiguration)_httpEndpointConfiguration; }
}
/// <summary> /// <summary>
/// Gets or sets the namespaces used in the xpath query /// Initializes a new instance of the <see cref="HttpEndpoint"/> class.
/// </summary> /// </summary>
/// <value>The xpath namespaces.</value> /// <param name="config">The SoapEndpointConfiguration.</param>
public string XpathNamespaces public SoapEndpoint(SoapEndpointConfiguration config)
: base(config)
{ {
get { return _xpathNamespaces; } if (!string.IsNullOrEmpty(SoapEndpointConfiguration.XpathNamespaces))
set
{ {
_xpathNamespaces = value; string[] split = SoapEndpointConfiguration.XpathNamespaces.Split(',');
if (string.IsNullOrEmpty(_xpathNamespaces)) return;
var split = _xpathNamespaces.Split(',');
if (split.Length != 2) if (split.Length != 2)
throw new ArgumentException("Need a comma separated pair in XpathNamespaces."); throw new ArgumentException("Need a comma separated pair in XpathNamespaces.", "config");
_namespaceToUri = new Dictionary<string, string>(); _namespaceToUri = new Dictionary<string, string>();
_namespaceToUri.Add(split[0], split[1]); _namespaceToUri.Add(split[0], split[1]);
} }
} }
/// <summary>
/// Gets or sets the expected query results.
/// </summary>
/// <value>The expected query results.</value>
public string ExpectedXpathResult { get; set; }
/// <summary>
/// Gets or sets the SOAP action.
/// </summary>
/// <value>The post.</value>
public string SoapAction { get; set; }
/// <summary>
/// Gets or sets the SOAP request.
/// </summary>
/// <value>The post.</value>
public string SoapRequest { get; set; }
/// <summary> /// <summary>
/// Gets the current status result of the endpoint /// Gets the current status result of the endpoint
/// </summary> /// </summary>
/// <returns>Status</returns> /// <returns>Status</returns>
public override Status GetStatus() public override Status GetStatus()
{ {
var baseStatus = base.GetStatus(); Status baseStatus = base.GetStatus();
if (baseStatus != Status.Up) // if we can't even get to the webserver, no need to try and call a WS. if (baseStatus != Status.Up)
return baseStatus; return baseStatus;
try try
{ {
var headers = new Dictionary<string, string> {{"SOAPAction", SoapAction}}; Dictionary<string, string> headers = new Dictionary<string, string>
{{"SOAPAction", SoapEndpointConfiguration.SoapAction}};
var xml = new XmlDocument(); XmlDocument xml = new XmlDocument();
xml.LoadXml(GetUrlContent(Uri, "text/xml; charset=utf-8", SoapRequest, headers)); xml.LoadXml(GetUrlContent(SoapEndpointConfiguration.Uri, "text/xml; charset=utf-8", SoapEndpointConfiguration.SoapRequest, headers));
XmlNodeList nodes; XmlNodeList nodes;
if (_namespaceToUri != null) if (_namespaceToUri != null)
{ {
var nsMgr = new XmlNamespaceManager(xml.NameTable); XmlNamespaceManager nsMgr = new XmlNamespaceManager(xml.NameTable);
foreach (var namespaceToUri in _namespaceToUri) foreach (KeyValuePair<string, string> namespaceToUri in _namespaceToUri)
{ {
nsMgr.AddNamespace(namespaceToUri.Key, namespaceToUri.Value); nsMgr.AddNamespace(namespaceToUri.Key, namespaceToUri.Value);
} }
nodes = xml.SelectNodes(XpathQuery, nsMgr); nodes = xml.SelectNodes(SoapEndpointConfiguration.XpathQuery, nsMgr);
} }
else else
nodes = xml.SelectNodes(XpathQuery); nodes = xml.SelectNodes(SoapEndpointConfiguration.XpathQuery);
//xml.Save(@"c:\soap.xml"); // xml.Save(@"c:\soap.xml");
// verify response has expected value // verify response has expected value
if (nodes == null || nodes.Count == 0) if (nodes == null || nodes.Count == 0)
@@ -97,11 +76,11 @@ namespace Endpoint
StatusDescription = "Couldn't find expected value in SOAP response"; StatusDescription = "Couldn't find expected value in SOAP response";
return Status.Error; return Status.Error;
} }
var value = nodes[0].Value.Trim(); string value = nodes[0].Value.Trim();
if (value != ExpectedXpathResult) if (value != SoapEndpointConfiguration.ExpectedXpathResult)
{ {
StatusDescription = String.Format("Result was: '{0}', was expecting '{1}'", value, StatusDescription = String.Format("Result was: '{0}', was expecting '{1}'", value,
ExpectedXpathResult); SoapEndpointConfiguration.ExpectedXpathResult);
return Status.Error; return Status.Error;
} }
} }
+134
View File
@@ -0,0 +1,134 @@
using System;
using System.Configuration;
using System.Xml.Serialization;
namespace Endpoint
{
public class SoapEndpointConfiguration : ConfigurationElement, IHttpEndpointConfiguration
{
/// <summary>
/// Gets or sets the name.
/// </summary>
/// <value>The name.</value>
[ConfigurationProperty("name", DefaultValue = "", IsKey = true, IsRequired = true)]
public string Name
{
get { return (string)base["name"]; }
set { base["name"] = value; }
}
/// <summary>
/// URI of the service
/// </summary>
[XmlIgnore]
public Uri Uri
{
get { return new Uri(UriString); }
}
/// <summary>
/// Gets or sets the URI string.
/// </summary>
/// <value>The URI string.</value>
[ConfigurationProperty("uri", DefaultValue = "", IsKey = false, IsRequired = true)]
public string UriString
{
get { return (string)base["uri"]; }
set { base["uri"] = value; }
}
/// <summary>
/// Gets or sets the xpath query for the html document
/// </summary>
/// <value>The xpath query.</value>
[ConfigurationProperty("xpathQuery", DefaultValue = "", IsKey = false, IsRequired = true)]
public string XpathQuery
{
get { return (string)base["xpathQuery"]; }
set { base["xpathQuery"] = value; }
}
/// <summary>
/// Gets or sets the namespaces used in the xpath query
/// </summary>
/// <value>The xpath namespaces.</value>
[ConfigurationProperty("xpathNamespaces", DefaultValue = "", IsKey = false, IsRequired = false)]
public string XpathNamespaces
{
get { return (string)base["xpathNamespaces"]; }
set { base["xpathNamespaces"] = value; }
}
/// <summary>
/// Gets or sets the expected query results.
/// </summary>
/// <value>The expected query results.</value>
[ConfigurationProperty("expectedXpathResult", DefaultValue = "", IsKey = false, IsRequired = true)]
public string ExpectedXpathResult
{
get { return (string)base["expectedXpathResult"]; }
set { base["expectedXpathResult"] = value; }
}
/// <summary>
/// Gets or sets the SOAP action.
/// </summary>
/// <value>The post.</value>
[ConfigurationProperty("soapAction", DefaultValue = "", IsKey = false, IsRequired = true)]
public string SoapAction
{
get { return (string)base["soapAction"]; }
set { base["soapAction"] = value; }
}
/// <summary>
/// Gets or sets the SOAP request.
/// </summary>
/// <value>The post.</value>
[ConfigurationProperty("soapRequest", DefaultValue = "", IsKey = false, IsRequired = true)]
public string SoapRequest
{
get { return (string)base["soapRequest"]; }
set { base["soapRequest"] = value; }
}
}
/// <summary>
///
/// </summary>
public class SoapEndpointConfigurationCollection : ConfigurationElementCollection
{
/// <summary>
/// When overridden in a derived class, creates a new <see cref="T:System.Configuration.ConfigurationElement" />.
/// </summary>
/// <returns>
/// A new <see cref="T:System.Configuration.ConfigurationElement" />.
/// </returns>
protected override ConfigurationElement CreateNewElement()
{
return new SoapEndpointConfiguration();
}
/// <summary>
/// Gets the element key for a specified configuration element when overridden in a derived class.
/// </summary>
/// <returns>
/// An <see cref="T:System.Object" /> that acts as the key for the specified <see cref="T:System.Configuration.ConfigurationElement" />.
/// </returns>
/// <param name="element">The <see cref="T:System.Configuration.ConfigurationElement" /> to return the key for. </param>
protected override object GetElementKey(ConfigurationElement element)
{
return ((SoapEndpointConfiguration)element).Name;
}
}
/// <summary>
///
/// </summary>
public class SoapEndpointConfigurationSection : ConfigurationSection
{
[ConfigurationProperty("endpoints")]
public SoapEndpointConfigurationCollection Endpoints { get { return (SoapEndpointConfigurationCollection)(base["endpoints"]); } }
}
}
+2 -6
View File
@@ -3,13 +3,8 @@ namespace Endpoint
/// <summary> /// <summary>
/// Status of an endpoint /// Status of an endpoint
/// </summary> /// </summary>
/// <remarks>The <see cref="StatusComparer"/> expects these to be in order of best-to-worst descending.</remarks>
public enum Status public enum Status
{ {
/// <summary>
/// Service state is unknown - this will occur only before the first poll.
/// </summary>
Unknown,
/// <summary> /// <summary>
/// Service is working /// Service is working
/// </summary> /// </summary>
@@ -25,6 +20,7 @@ namespace Endpoint
/// <summary> /// <summary>
/// Service is available, but returns an error message /// Service is available, but returns an error message
/// </summary> /// </summary>
Error Error,
Unknown
} }
} }
+4 -46
View File
@@ -1,5 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="Current" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup> <PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -15,23 +14,9 @@
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> <ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<FileUpgradeFlags> <FileUpgradeFlags>
</FileUpgradeFlags> </FileUpgradeFlags>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<OldToolsVersion>3.5</OldToolsVersion> <OldToolsVersion>3.5</OldToolsVersion>
<UpgradeBackupLocation />
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
@@ -41,7 +26,6 @@
<DefineConstants>DEBUG;TRACE</DefineConstants> <DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
@@ -50,14 +34,13 @@
<DefineConstants>TRACE</DefineConstants> <DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="HtmlAgilityPack, Version=1.3.0.0, Culture=neutral, PublicKeyToken=bd319b19eaf3b43a, processorArchitecture=MSIL"> <Reference Include="HtmlAgilityPack, Version=1.3.0.0, Culture=neutral, PublicKeyToken=bd319b19eaf3b43a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\Endpoint\References\HtmlAgilityPack.dll</HintPath> <HintPath>..\Endpoint\References\HtmlAgilityPack.dll</HintPath>
</Reference> </Reference>
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" /> <Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
<Reference Include="Oracle.DataAccess, Version=2.102.2.20, Culture=neutral, PublicKeyToken=89b483f429c47342, processorArchitecture=x86"> <Reference Include="Oracle.DataAccess, Version=2.102.2.20, Culture=neutral, PublicKeyToken=89b483f429c47342, processorArchitecture=x86">
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\Endpoint\References\Oracle.DataAccess.dll</HintPath> <HintPath>..\Endpoint\References\Oracle.DataAccess.dll</HintPath>
@@ -71,12 +54,9 @@
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="SoapEndpointTest.cs" />
<Compile Include="HtmlEndpointTest.cs" /> <Compile Include="HtmlEndpointTest.cs" />
<Compile Include="HttpEndpointTest.cs" /> <Compile Include="HttpEndpointTest.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="WindowsServiceEndpointTest.cs" />
<Compile Include="WmiEndpointTest.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Endpoint\Endpoint.csproj"> <ProjectReference Include="..\Endpoint\Endpoint.csproj">
@@ -84,28 +64,6 @@
<Name>Endpoint</Name> <Name>Endpoint</Name>
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.0">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4 %28x86 and x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
<Visible>False</Visible>
<ProductName>Windows Installer 3.1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets. Other similar extension points exist, see Microsoft.Common.targets.
+24 -24
View File
@@ -1,17 +1,15 @@
using System; using System;
using Endpoint; using Endpoint;
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace EndpointTest namespace EndpointTest
{ {
/// <summary> /// <summary>
///This is a test class for HtmlEndpointTest and is intended ///This is a test class for HtmlEndpointTest and is intended
///to contain all HtmlEndpointTest Unit Tests ///to contain all HtmlEndpointTest Unit Tests
///</summary> ///</summary>
[TestClass] [TestClass()]
public class HtmlEndpointTest public class HtmlEndpointTest
{ {
// Random website for functional testing
private readonly Uri _goodUri = new Uri("http://www.seekwellness.com/sca/"); private readonly Uri _goodUri = new Uri("http://www.seekwellness.com/sca/");
/// <summary> /// <summary>
@@ -20,16 +18,16 @@ namespace EndpointTest
[TestMethod] [TestMethod]
public void HtmlEndpointConfigurationTest() public void HtmlEndpointConfigurationTest()
{ {
var target = new HtmlEndpoint HtmlEndpointConfiguration config =
{ new HtmlEndpointConfiguration {
UriString = _goodUri.OriginalString, UriString = _goodUri.OriginalString,
XpathQuery = "//td[contains(text(), 'Use this form')]/text()", XpathQuery = "//td[contains(text(), 'Use this form')]/text()",
ExpectedXpathResult = "Use this form to order your", ExpectedXpathResult = "Use this form to order your",
RequestContent = "redeem_coupon=true&f_coupon_code=stuff" RequestContent = "redeem_coupon=true&f_coupon_code=stuff"
}; };
HtmlEndpoint target = new HtmlEndpoint(config); // TODO: Initialize to an appropriate value
var status = target.GetStatus(); Status status = target.GetStatus();
Assert.AreEqual(Status.Up, status, target.StatusDescription);
} }
/// <summary> /// <summary>
@@ -38,15 +36,17 @@ namespace EndpointTest
[TestMethod] [TestMethod]
public void HtmlEndpointFormTest() public void HtmlEndpointFormTest()
{ {
var target = new HtmlEndpoint HtmlEndpointConfiguration config =
{ new HtmlEndpointConfiguration
UriString = _goodUri.OriginalString, {
XpathQuery = "//p[@class='errorMsg']/text()", UriString = _goodUri.OriginalString,
ExpectedXpathResult = "- Please enter a valid coupon code.", XpathQuery = "//p[@class='errorMsg']/text()",
RequestContent = "redeem_coupon=true&f_coupon_code=stuff" ExpectedXpathResult = "- Please enter a valid coupon code.",
}; RequestContent = "redeem_coupon=true&f_coupon_code=stuff"
};
HtmlEndpoint target = new HtmlEndpoint(config); // TODO: Initialize to an appropriate value
var status = target.GetStatus(); Status status = target.GetStatus();
Assert.AreEqual(Status.Up, status, target.StatusDescription); Assert.AreEqual(Status.Up, status, target.StatusDescription);
} }
} }
+28 -26
View File
@@ -1,40 +1,32 @@
using System; using System.Diagnostics;
using System.Net;
using Endpoint; using Endpoint;
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
namespace EndpointTest namespace EndpointTest
{ {
/// <summary> /// <summary>
///This is a test class for HttpEndpointTest and is intended ///This is a test class for HttpEndpointTest and is intended
///to contain all HttpEndpointTest Unit Tests ///to contain all HttpEndpointTest Unit Tests
///</summary> ///</summary>
[TestClass] [TestClass()]
public class HttpEndpointTest public class HttpEndpointTest
{ {
private readonly Uri _goodUri = new Uri("http://www.google.com"); private readonly Uri _goodUri = new Uri("http://www.google.com");
private readonly Uri _missingUri = new Uri("http://www.google.com/gasdfasdh598yqwejbiasalsdjfhaogle"); private readonly Uri _missingUri = new Uri("http://www.google.com/gasdfasdh598yqwejbiasalsdjfhaogle");
private readonly Uri _unreachableDomainUri = new Uri("http://gasdfasdh598yqwejbiasalsdjfhaogle"); private readonly Uri _unreachableDomainUri = new Uri("http://gasdfasdh598yqwejbiasalsdjfhaogle");
private readonly Uri _downUri = new Uri("http://192.168.0.153"); private readonly Uri _downUri = new Uri("http://192.168.0.153");
private readonly Uri _httpsUri = new Uri("https://sourceforge.net/"); private readonly Uri _httpsUri = new Uri("https://sourceforge.net/");
/// <summary> /// <summary>
///A test for HttpEndpoint Constructor ///A test for Url
///</summary> ///</summary>
[TestMethod] [TestMethod]
public void HttpEndpointConstructorTest() public void UrlTest()
{ {
HttpEndpoint endpoint = new HttpEndpoint {Uri = _goodUri}; HttpEndpoint endpoint = new HttpEndpoint(new HttpEndpointConfiguration("", _goodUri));
Assert.AreEqual(_goodUri, endpoint.Uri); Assert.AreEqual(_goodUri, endpoint.HttpEndpointConfiguration.Uri);
}
/// <summary>
///A test for UrlString
///</summary>
[TestMethod]
public void UrlStringTest()
{
HttpEndpoint endpoint = new HttpEndpoint {UriString = "http://uri/"};
Assert.AreEqual("http://uri/", endpoint.Uri.AbsoluteUri);
} }
/// <summary> /// <summary>
@@ -43,7 +35,7 @@ namespace EndpointTest
[TestMethod] [TestMethod]
public void GetStatusGoodTest() public void GetStatusGoodTest()
{ {
HttpEndpoint endpoint = new HttpEndpoint {Uri = _goodUri}; HttpEndpoint endpoint = new HttpEndpoint(new HttpEndpointConfiguration("", _goodUri));
Assert.AreEqual(Status.Up, endpoint.GetStatus()); Assert.AreEqual(Status.Up, endpoint.GetStatus());
} }
@@ -53,7 +45,7 @@ namespace EndpointTest
[TestMethod] [TestMethod]
public void GetStatusMissingTest() public void GetStatusMissingTest()
{ {
HttpEndpoint endpoint = new HttpEndpoint {Uri = _missingUri}; HttpEndpoint endpoint = new HttpEndpoint(new HttpEndpointConfiguration("", _missingUri));
Assert.AreEqual(Status.Unreachable, endpoint.GetStatus()); Assert.AreEqual(Status.Unreachable, endpoint.GetStatus());
} }
@@ -63,7 +55,7 @@ namespace EndpointTest
[TestMethod] [TestMethod]
public void GetStatusUnreachableTest() public void GetStatusUnreachableTest()
{ {
HttpEndpoint endpoint = new HttpEndpoint {Uri = _unreachableDomainUri}; HttpEndpoint endpoint = new HttpEndpoint(new HttpEndpointConfiguration("", _unreachableDomainUri));
Assert.AreEqual(Status.Unreachable, endpoint.GetStatus()); Assert.AreEqual(Status.Unreachable, endpoint.GetStatus());
} }
@@ -73,7 +65,7 @@ namespace EndpointTest
[TestMethod] [TestMethod]
public void GetStatusDownTest() public void GetStatusDownTest()
{ {
HttpEndpoint endpoint = new HttpEndpoint {Uri = _downUri}; HttpEndpoint endpoint = new HttpEndpoint(new HttpEndpointConfiguration("", _downUri));
Assert.AreEqual(Status.Unreachable, endpoint.GetStatus()); Assert.AreEqual(Status.Unreachable, endpoint.GetStatus());
} }
@@ -83,8 +75,18 @@ namespace EndpointTest
[TestMethod] [TestMethod]
public void GetHttpsTest() public void GetHttpsTest()
{ {
HttpEndpoint endpoint = new HttpEndpoint {Uri = _httpsUri}; HttpEndpoint endpoint = new HttpEndpoint(new HttpEndpointConfiguration("", _httpsUri));
Assert.AreEqual(Status.Up, endpoint.GetStatus()); Assert.AreEqual(Status.Up, endpoint.GetStatus());
} }
/// <summary>
///A test for HttpEndpoint Constructor
///</summary>
[TestMethod]
public void HttpEndpointConstructorTest()
{
HttpEndpoint endpoint = new HttpEndpoint(new HttpEndpointConfiguration("", _goodUri));
Assert.AreEqual(_goodUri, endpoint.HttpEndpointConfiguration.Uri);
}
} }
} }
+10 -5
View File
@@ -1,6 +1,8 @@
Microsoft Visual Studio Solution File, Format Version 11.00 Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2010 # Visual Studio Version 16
VisualStudioVersion = 16.0.35931.194
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{DA481DF1-5754-4499-AEA2-21F809256F35}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{DA481DF1-5754-4499-AEA2-21F809256F35}"
ProjectSection(SolutionItems) = preProject ProjectSection(SolutionItems) = preProject
LocalTestRun.testrunconfig = LocalTestRun.testrunconfig LocalTestRun.testrunconfig = LocalTestRun.testrunconfig
@@ -14,9 +16,6 @@ EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EndpointTest", "EndpointTest\EndpointTest.csproj", "{76D78812-B640-4EF0-957B-15D0E9000A84}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EndpointTest", "EndpointTest\EndpointTest.csproj", "{76D78812-B640-4EF0-957B-15D0E9000A84}"
EndProject EndProject
Global Global
GlobalSection(TestCaseManagementSettings) = postSolution
CategoryFile = ServiceDashBored.vsmdi
EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU Release|Any CPU = Release|Any CPU
@@ -38,4 +37,10 @@ Global
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
EndGlobalSection EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {93EF7101-5AA3-4AC7-B544-93735F7253F3}
EndGlobalSection
GlobalSection(TestCaseManagementSettings) = postSolution
CategoryFile = ServiceDashBored.vsmdi
EndGlobalSection
EndGlobal EndGlobal
+53 -79
View File
@@ -15,34 +15,47 @@ namespace ServiceDashBored
{ {
#region Private Members #region Private Members
private readonly IEndpoint _endpoint; private readonly IServiceEndpoint _serviceEndpoint;
private readonly Timer _lastUpdateTimer; private readonly Timer _timer;
private Status? _status = Endpoint.Status.Unknown;
private string _statusMessage = string.Empty;
private Icon _statusIcon;
private DateTime _lastUpdate; private DateTime _lastUpdate;
private readonly Logger _logger; private readonly Logger _logger;
private readonly TimeSpan _updatePeriod; private readonly TimeSpan _updatePeriod;
private static readonly object _propertyUpdateSyncObject = new Object(); private static readonly object _syncObject = 0;
private static readonly object _callbackSyncObject = new Object();
private bool _insideCallback;
#endregion #endregion
#region Properties #region Properties
/// <summary> /// <summary>
/// Gets the icon based on the status. /// Loads the icon based on the status.
/// </summary> /// </summary>
public Icon StatusIcon { get; private set; } public Icon StatusIcon
{
get
{
return _statusIcon;
}
}
/// <summary> /// <summary>
/// Gets service's current status. /// Gets the status.
/// </summary> /// </summary>
/// <value>The status.</value> /// <value>The status.</value>
public Status Status { get; private set; } public Status Status
{
get { return _status.Value; }
}
/// <summary> /// <summary>
/// Returns a string explaining details on the current status /// Returns a string explaining details on the current status
/// </summary> /// </summary>
public string StatusDescription { get; private set; } public string StatusDescription
{
get { return _statusMessage; }
}
/// <summary> /// <summary>
/// Gets the time since the last update /// Gets the time since the last update
@@ -52,41 +65,22 @@ namespace ServiceDashBored
{ {
get get
{ {
if (_lastUpdate == DateTime.MinValue) TimeSpan timeSpan = (DateTime.Now - _lastUpdate);
return "never";
if (_lastUpdate == DateTime.MaxValue)
return "updating";
var timeSpan = DateTime.Now - _lastUpdate;
if (timeSpan.Minutes > 0 ) if (timeSpan.Minutes > 0 )
return String.Format("{0}m {1}s", timeSpan.Minutes, timeSpan.Seconds); return String.Format("{0}m {1}s", timeSpan.Minutes, timeSpan.Seconds);
return return
timeSpan.Seconds + 1 + "s"; timeSpan.Seconds + "s";
} }
} }
/// <summary> /// <summary>
/// Gets the name of the service. ///
/// </summary> /// </summary>
/// <value>The name of the service.</value>
public string ServiceName public string ServiceName
{ {
get get
{ {
return _endpoint.Name; return _serviceEndpoint.ServiceName;
}
}
/// <summary>
/// Sets the last update time.
/// </summary>
/// <value>The last update time.</value>
private DateTime lastUpdate
{
set
{
_lastUpdate = value;
SignalPropertyChanged("TimeSinceLastUpdate");
} }
} }
@@ -95,33 +89,24 @@ namespace ServiceDashBored
#region Public Methods #region Public Methods
/// <summary> /// <summary>
/// Callback for the <c>threadpool</c> /// Callback for the threadpool
/// </summary> /// </summary>
/// <param name="threadContext">The thread context.</param> /// <param name="threadContext">The thread context.</param>
/// <param name="isTimeOut">The callback was triggered from a timeout</param> /// <param name="activated"></param>
public void ThreadPoolCallback(object threadContext, bool isTimeOut) public void ThreadPoolCallback(object threadContext, bool activated)
{ {
lock(_callbackSyncObject)
{
if (_insideCallback)
return;
_insideCallback = true;
}
try try
{ {
// turn off the timer while waiting for an update //Debug.WriteLine(DateTime.Now + " " + _serviceEndpoint.ServiceName + ": updateStatus");
_lastUpdateTimer.Change(Timeout.Infinite, Timeout.Infinite); //_logger.LogInfo(_serviceEndpoint.ServiceName + ": updateStatus");
updateStatus(); updateStatus();
_lastUpdate = DateTime.Now;
SignalPropertyChanged("TimeSinceLastUpdate");
} }
catch (Exception ex) catch (Exception ex)
{ {
// log exception // log exception
_logger.LogError(_endpoint.Name + ": " + ex); _logger.LogError(_serviceEndpoint.ServiceName + ": " + ex);
}
finally
{
_lastUpdateTimer.Change(_updatePeriod, _updatePeriod);
_insideCallback = false;
} }
} }
@@ -135,21 +120,18 @@ namespace ServiceDashBored
/// <returns>Status</returns> /// <returns>Status</returns>
private void updateStatus() private void updateStatus()
{ {
lastUpdate = DateTime.MaxValue; Status newStatus = _serviceEndpoint.GetStatus();
var newStatus = _endpoint.GetStatus(); if (_status != newStatus)
if (Status != newStatus)
{ {
Status = newStatus; _status = newStatus;
StatusDescription = _endpoint.StatusDescription; _statusMessage = _serviceEndpoint.StatusDescription;
StatusIcon = GetStatusIcon(Status); _statusIcon = GetStatusIcon(_status);
// NOTE: wait to signal the property changes until all of them have been updated
SignalPropertyChanged("Status"); SignalPropertyChanged("Status");
SignalPropertyChanged("StatusDescription");
SignalPropertyChanged("StatusIcon"); SignalPropertyChanged("StatusIcon");
SignalPropertyChanged("StatusDescription");
} }
lastUpdate = DateTime.Now; _lastUpdate = DateTime.Now;
} }
/// <summary> /// <summary>
/// Callback for the timer /// Callback for the timer
/// </summary> /// </summary>
@@ -168,12 +150,10 @@ namespace ServiceDashBored
/// </summary> /// </summary>
/// <param name="status">The status.</param> /// <param name="status">The status.</param>
/// <returns></returns> /// <returns></returns>
public static Icon GetStatusIcon(Status status) public static Icon GetStatusIcon(Status? status)
{ {
switch (status) switch (status)
{ {
case Status.Unknown:
return Resources.question;
case Status.Up: case Status.Up:
return Resources.up; return Resources.up;
case Status.Error: case Status.Error:
@@ -195,16 +175,13 @@ namespace ServiceDashBored
/// </summary> /// </summary>
/// <param name="endpoint">The endpoint.</param> /// <param name="endpoint">The endpoint.</param>
/// <param name="logger">The logger.</param> /// <param name="logger">The logger.</param>
public EndpointStatus(IEndpoint endpoint, Logger logger) public EndpointStatus(IServiceEndpoint endpoint, Logger logger)
{ {
_endpoint = endpoint; _serviceEndpoint = endpoint;
lastUpdate = DateTime.MinValue; _lastUpdate = DateTime.MinValue;
_logger = logger; _logger = logger;
_updatePeriod = new TimeSpan(0, 0, 0, 1); _updatePeriod = new TimeSpan(0, 0, 0, 1);
_lastUpdateTimer = new Timer(timerCallback, 0, _updatePeriod, _updatePeriod); _timer = new Timer(timerCallback, 0, _updatePeriod, _updatePeriod);
StatusIcon = GetStatusIcon(Status);
Status = Status.Unknown;
StatusDescription = string.Empty;
} }
#endregion #endregion
@@ -221,7 +198,7 @@ namespace ServiceDashBored
#region PropertyChanged methods #region PropertyChanged methods
/// <summary> /// <summary>
/// Checks if the property (<paramref name="propertyName"/>) has been updated or changed. /// Checks if the property (propertyName) has been updated or changed.
/// </summary> /// </summary>
/// <param name="propertyName">Name of the property.</param> /// <param name="propertyName">Name of the property.</param>
/// <param name="oldValue">The old value.</param> /// <param name="oldValue">The old value.</param>
@@ -234,7 +211,7 @@ namespace ServiceDashBored
return false; return false;
} }
if (oldValue == null || !oldValue.Equals(newValue)) if ((oldValue == null) || !oldValue.Equals(newValue))
{ {
oldValue = newValue; oldValue = newValue;
@@ -247,7 +224,7 @@ namespace ServiceDashBored
} }
/// <summary> /// <summary>
/// Checks if the property (<paramref name="propertyName"/>) has been updated or changed. /// Checks if the property (propertyName) has been updated or changed.
/// </summary> /// </summary>
/// <param name="propertyName">Name of the property.</param> /// <param name="propertyName">Name of the property.</param>
/// <param name="oldValue">The old value.</param> /// <param name="oldValue">The old value.</param>
@@ -277,14 +254,11 @@ namespace ServiceDashBored
return; return;
try try
{ {
lock (_propertyUpdateSyncObject) // send only one property changed event at once lock (_syncObject)
{ {
PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
} }
} }
catch (InvalidOperationException) // HACK: Ignore the "BindingSource cannot be its own data source."
{
}
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogWarning("SignalPropertyChanged: " + ex); _logger.LogWarning("SignalPropertyChanged: " + ex);
@@ -301,7 +275,7 @@ namespace ServiceDashBored
///<filterpriority>2</filterpriority> ///<filterpriority>2</filterpriority>
public void Dispose() public void Dispose()
{ {
_lastUpdateTimer.Dispose(); _timer.Dispose();
} }
#endregion #endregion
+91 -120
View File
@@ -37,41 +37,60 @@
{ {
this.components = new System.ComponentModel.Container(); this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Main)); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Main));
this.menuStrip = new System.Windows.Forms.MenuStrip();
this.helpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.aboutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.notifyIcon = new System.Windows.Forms.NotifyIcon(this.components); this.notifyIcon = new System.Windows.Forms.NotifyIcon(this.components);
this.trayContextMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components); this.contextMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components);
this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.dataGridView = new System.Windows.Forms.DataGridView(); this.dataGridView = new System.Windows.Forms.DataGridView();
this.statusIconDataGridViewImageColumn = new System.Windows.Forms.DataGridViewImageColumn();
this.ServiceName = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.TimeSinceLastUpdate = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.endpointBindingSource = new System.Windows.Forms.BindingSource(this.components);
this.cellTextBox = new System.Windows.Forms.TextBox(); this.cellTextBox = new System.Windows.Forms.TextBox();
this.statusTextBox = new System.Windows.Forms.RichTextBox(); this.endpointBindingSource = new System.Windows.Forms.BindingSource(this.components);
this.splitContainer = new System.Windows.Forms.SplitContainer(); this.ServiceName = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.dataGridContextMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components); this.statusIconDataGridViewImageColumn = new System.Windows.Forms.DataGridViewImageColumn();
this.updateNowToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.StatusDescription = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.trayContextMenuStrip.SuspendLayout(); this.TimeSinceLastUpdate = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.contextMenuStrip.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.endpointBindingSource)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.endpointBindingSource)).BeginInit();
this.splitContainer.Panel1.SuspendLayout();
this.splitContainer.Panel2.SuspendLayout();
this.splitContainer.SuspendLayout();
this.dataGridContextMenuStrip.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
// //
// menuStrip
//
this.menuStrip.Location = new System.Drawing.Point(0, 0);
this.menuStrip.Name = "menuStrip";
this.menuStrip.Size = new System.Drawing.Size(579, 24);
this.menuStrip.TabIndex = 0;
this.menuStrip.Text = "menuStrip1";
//
// helpToolStripMenuItem
//
this.helpToolStripMenuItem.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right;
this.helpToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.aboutToolStripMenuItem});
this.helpToolStripMenuItem.Name = "helpToolStripMenuItem";
this.helpToolStripMenuItem.Size = new System.Drawing.Size(40, 20);
this.helpToolStripMenuItem.Text = "Help";
//
// aboutToolStripMenuItem
//
this.aboutToolStripMenuItem.Name = "aboutToolStripMenuItem";
this.aboutToolStripMenuItem.Size = new System.Drawing.Size(114, 22);
this.aboutToolStripMenuItem.Text = "About";
//
// notifyIcon // notifyIcon
// //
this.notifyIcon.ContextMenuStrip = this.trayContextMenuStrip; this.notifyIcon.ContextMenuStrip = this.contextMenuStrip;
this.notifyIcon.Text = "Service DashBored"; this.notifyIcon.Text = "Service DashBored";
this.notifyIcon.Visible = true; this.notifyIcon.Visible = true;
this.notifyIcon.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.notifyIcon_MouseDoubleClick); this.notifyIcon.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.notifyIcon_MouseDoubleClick);
// //
// trayContextMenuStrip // contextMenuStrip
// //
this.trayContextMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.contextMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.exitToolStripMenuItem}); this.exitToolStripMenuItem});
this.trayContextMenuStrip.Name = "trayContextMenuStrip"; this.contextMenuStrip.Name = "contextMenuStrip";
this.trayContextMenuStrip.Size = new System.Drawing.Size(104, 26); this.contextMenuStrip.Size = new System.Drawing.Size(104, 26);
// //
// exitToolStripMenuItem // exitToolStripMenuItem
// //
@@ -90,33 +109,52 @@
| System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right))); | System.Windows.Forms.AnchorStyles.Right)));
this.dataGridView.AutoGenerateColumns = false; this.dataGridView.AutoGenerateColumns = false;
this.dataGridView.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
this.dataGridView.AutoSizeRowsMode = System.Windows.Forms.DataGridViewAutoSizeRowsMode.DisplayedCells;
this.dataGridView.BorderStyle = System.Windows.Forms.BorderStyle.None; this.dataGridView.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.dataGridView.CellBorderStyle = System.Windows.Forms.DataGridViewCellBorderStyle.None; this.dataGridView.CellBorderStyle = System.Windows.Forms.DataGridViewCellBorderStyle.None;
this.dataGridView.ClipboardCopyMode = System.Windows.Forms.DataGridViewClipboardCopyMode.EnableWithoutHeaderText; this.dataGridView.ClipboardCopyMode = System.Windows.Forms.DataGridViewClipboardCopyMode.EnableWithoutHeaderText;
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing; this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.statusIconDataGridViewImageColumn,
this.ServiceName, this.ServiceName,
this.statusIconDataGridViewImageColumn,
this.StatusDescription,
this.TimeSinceLastUpdate}); this.TimeSinceLastUpdate});
this.dataGridView.DataSource = this.endpointBindingSource; this.dataGridView.DataSource = this.endpointBindingSource;
this.dataGridView.EditMode = System.Windows.Forms.DataGridViewEditMode.EditProgrammatically; this.dataGridView.EditMode = System.Windows.Forms.DataGridViewEditMode.EditProgrammatically;
this.dataGridView.EnableHeadersVisualStyles = false; this.dataGridView.EnableHeadersVisualStyles = false;
this.dataGridView.Location = new System.Drawing.Point(12, 12); this.dataGridView.Location = new System.Drawing.Point(12, 27);
this.dataGridView.MultiSelect = false;
this.dataGridView.Name = "dataGridView"; this.dataGridView.Name = "dataGridView";
this.dataGridView.ReadOnly = true; this.dataGridView.ReadOnly = true;
this.dataGridView.RowHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.Single; this.dataGridView.RowHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.Single;
this.dataGridView.RowHeadersVisible = false; this.dataGridView.RowHeadersVisible = false;
this.dataGridView.RowHeadersWidthSizeMode = System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode.DisableResizing; this.dataGridView.RowHeadersWidthSizeMode = System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode.DisableResizing;
this.dataGridView.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; this.dataGridView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.CellSelect;
this.dataGridView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; this.dataGridView.Size = new System.Drawing.Size(555, 156);
this.dataGridView.Size = new System.Drawing.Size(368, 126);
this.dataGridView.TabIndex = 1; this.dataGridView.TabIndex = 1;
this.dataGridView.RowEnter += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_RowEnter); this.dataGridView.CellEnter += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_CellEnter);
this.dataGridView.MouseUp += new System.Windows.Forms.MouseEventHandler(this.dataGridView_MouseUp); //
this.dataGridView.DataError += new System.Windows.Forms.DataGridViewDataErrorEventHandler(this.dataGridView_DataError); // cellTextBox
//
this.cellTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.cellTextBox.Location = new System.Drawing.Point(12, 189);
this.cellTextBox.Name = "cellTextBox";
this.cellTextBox.ReadOnly = true;
this.cellTextBox.Size = new System.Drawing.Size(555, 20);
this.cellTextBox.TabIndex = 2;
//
// endpointBindingSource
//
this.endpointBindingSource.DataSource = typeof(ServiceDashBored.EndpointStatus);
//
// ServiceName
//
this.ServiceName.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.ColumnHeader;
this.ServiceName.DataPropertyName = "ServiceName";
this.ServiceName.HeaderText = "Service";
this.ServiceName.MinimumWidth = 100;
this.ServiceName.Name = "ServiceName";
this.ServiceName.ReadOnly = true;
this.ServiceName.Resizable = System.Windows.Forms.DataGridViewTriState.False;
// //
// statusIconDataGridViewImageColumn // statusIconDataGridViewImageColumn
// //
@@ -129,14 +167,13 @@
this.statusIconDataGridViewImageColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic; this.statusIconDataGridViewImageColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
this.statusIconDataGridViewImageColumn.Width = 30; this.statusIconDataGridViewImageColumn.Width = 30;
// //
// ServiceName // StatusDescription
// //
this.ServiceName.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; this.StatusDescription.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
this.ServiceName.DataPropertyName = "ServiceName"; this.StatusDescription.DataPropertyName = "StatusDescription";
this.ServiceName.HeaderText = "Service"; this.StatusDescription.HeaderText = "Status";
this.ServiceName.MinimumWidth = 100; this.StatusDescription.Name = "StatusDescription";
this.ServiceName.Name = "ServiceName"; this.StatusDescription.ReadOnly = true;
this.ServiceName.ReadOnly = true;
// //
// TimeSinceLastUpdate // TimeSinceLastUpdate
// //
@@ -145,112 +182,46 @@
this.TimeSinceLastUpdate.HeaderText = "Last Update"; this.TimeSinceLastUpdate.HeaderText = "Last Update";
this.TimeSinceLastUpdate.Name = "TimeSinceLastUpdate"; this.TimeSinceLastUpdate.Name = "TimeSinceLastUpdate";
this.TimeSinceLastUpdate.ReadOnly = true; this.TimeSinceLastUpdate.ReadOnly = true;
this.TimeSinceLastUpdate.Resizable = System.Windows.Forms.DataGridViewTriState.False;
this.TimeSinceLastUpdate.Width = 90; this.TimeSinceLastUpdate.Width = 90;
// //
// endpointBindingSource
//
this.endpointBindingSource.DataSource = typeof(ServiceDashBored.EndpointStatus);
//
// cellTextBox
//
this.cellTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.cellTextBox.Location = new System.Drawing.Point(12, 144);
this.cellTextBox.Name = "cellTextBox";
this.cellTextBox.ReadOnly = true;
this.cellTextBox.Size = new System.Drawing.Size(368, 20);
this.cellTextBox.TabIndex = 2;
//
// statusTextBox
//
this.statusTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.statusTextBox.BackColor = System.Drawing.SystemColors.Window;
this.statusTextBox.Location = new System.Drawing.Point(12, 3);
this.statusTextBox.Name = "statusTextBox";
this.statusTextBox.ReadOnly = true;
this.statusTextBox.Size = new System.Drawing.Size(368, 85);
this.statusTextBox.TabIndex = 3;
this.statusTextBox.Text = "";
//
// splitContainer
//
this.splitContainer.Dock = System.Windows.Forms.DockStyle.Fill;
this.splitContainer.Location = new System.Drawing.Point(0, 0);
this.splitContainer.Name = "splitContainer";
this.splitContainer.Orientation = System.Windows.Forms.Orientation.Horizontal;
//
// splitContainer.Panel1
//
this.splitContainer.Panel1.Controls.Add(this.cellTextBox);
this.splitContainer.Panel1.Controls.Add(this.dataGridView);
this.splitContainer.Panel1MinSize = 135;
//
// splitContainer.Panel2
//
this.splitContainer.Panel2.Controls.Add(this.statusTextBox);
this.splitContainer.Panel2MinSize = 100;
this.splitContainer.Size = new System.Drawing.Size(392, 270);
this.splitContainer.SplitterDistance = 166;
this.splitContainer.SplitterWidth = 3;
this.splitContainer.TabIndex = 4;
//
// dataGridContextMenuStrip
//
this.dataGridContextMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.updateNowToolStripMenuItem});
this.dataGridContextMenuStrip.Name = "dataGridContextMenuStrip";
this.dataGridContextMenuStrip.Size = new System.Drawing.Size(145, 26);
//
// updateNowToolStripMenuItem
//
this.updateNowToolStripMenuItem.Name = "updateNowToolStripMenuItem";
this.updateNowToolStripMenuItem.Size = new System.Drawing.Size(144, 22);
this.updateNowToolStripMenuItem.Text = "Update Now";
this.updateNowToolStripMenuItem.Click += new System.EventHandler(this.updateNowToolStripMenuItem_Click);
//
// Main // Main
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(392, 270); this.ClientSize = new System.Drawing.Size(579, 218);
this.Controls.Add(this.splitContainer); this.Controls.Add(this.cellTextBox);
this.Controls.Add(this.dataGridView);
this.Controls.Add(this.menuStrip);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MainMenuStrip = this.menuStrip;
this.MaximizeBox = false; this.MaximizeBox = false;
this.MinimumSize = new System.Drawing.Size(400, 300); this.MinimumSize = new System.Drawing.Size(587, 248);
this.Name = "Main"; this.Name = "Main";
this.Text = "Service DashBored"; this.Text = "Service DashBored";
this.Load += new System.EventHandler(this.main_Load); this.Load += new System.EventHandler(this.Main_Load);
this.Resize += new System.EventHandler(this.main_Resize); this.contextMenuStrip.ResumeLayout(false);
this.trayContextMenuStrip.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.endpointBindingSource)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.endpointBindingSource)).EndInit();
this.splitContainer.Panel1.ResumeLayout(false);
this.splitContainer.Panel1.PerformLayout();
this.splitContainer.Panel2.ResumeLayout(false);
this.splitContainer.ResumeLayout(false);
this.dataGridContextMenuStrip.ResumeLayout(false);
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout();
} }
#endregion #endregion
private System.Windows.Forms.MenuStrip menuStrip;
private System.Windows.Forms.ToolStripMenuItem helpToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem aboutToolStripMenuItem;
private System.Windows.Forms.NotifyIcon notifyIcon; private System.Windows.Forms.NotifyIcon notifyIcon;
private System.Windows.Forms.ContextMenuStrip trayContextMenuStrip; private System.Windows.Forms.ContextMenuStrip contextMenuStrip;
private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem;
private System.Windows.Forms.DataGridView dataGridView; private System.Windows.Forms.DataGridView dataGridView;
private System.Windows.Forms.BindingSource endpointBindingSource; private System.Windows.Forms.BindingSource endpointBindingSource;
private System.Windows.Forms.TextBox cellTextBox; private System.Windows.Forms.TextBox cellTextBox;
private System.Windows.Forms.DataGridViewImageColumn statusIconDataGridViewImageColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn TimeSinceLastUpdate;
private System.Windows.Forms.RichTextBox statusTextBox;
private System.Windows.Forms.SplitContainer splitContainer;
private System.Windows.Forms.DataGridViewTextBoxColumn ServiceName; private System.Windows.Forms.DataGridViewTextBoxColumn ServiceName;
private System.Windows.Forms.ContextMenuStrip dataGridContextMenuStrip; private System.Windows.Forms.DataGridViewImageColumn statusIconDataGridViewImageColumn;
private System.Windows.Forms.ToolStripMenuItem updateNowToolStripMenuItem; private System.Windows.Forms.DataGridViewTextBoxColumn StatusDescription;
private System.Windows.Forms.DataGridViewTextBoxColumn TimeSinceLastUpdate;
} }
} }
+173 -333
View File
@@ -1,7 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Drawing; using System.Configuration;
using System.Threading; using System.Threading;
using System.Windows.Forms; using System.Windows.Forms;
using BitFactory.Logging; using BitFactory.Logging;
@@ -9,100 +9,190 @@ using Endpoint;
namespace ServiceDashBored namespace ServiceDashBored
{ {
/// <summary>
/// DashBored's UI.
/// </summary>
public partial class Main : Form public partial class Main : Form
{ {
/// <summary> private Status _mainStatusIcon = Status.Timeout;
/// Number of seconds between trying to poll an endpoint for its status private BindingList<EndpointStatus> _endpointStatus;
/// </summary> private Dictionary<EndpointStatus, RegisteredWaitHandle> _endpointWaitHandle;
private const int ENDPOINT_POLL_TIME_INTERVAL = 30; private Logger _logger;
private const string LOG_FILENAME = "ServiceDashBored.log";
/// <summary>
/// Number of milliseconds to display status updates on the system tray notify balloon
/// </summary>
private const int NOTIFY_BALLOON_UPDATE_DELAY = 300;
/// <summary>
/// Win32 message for when the user ends their session.
/// </summary>
/// <remarks>http://msdn.microsoft.com/en-us/library/aa376890(VS.85).aspx</remarks>
private const int WM_QUERYENDSESSION = 0x11;
/// <summary>
/// The status to display in the system tray
/// </summary>
private Status _systemTrayStatusIcon = Status.Timeout;
private readonly BindingList<EndpointStatus> _endpoints;
private readonly Dictionary<EndpointStatus, Status> _endpointStatuses;
private readonly Dictionary<EndpointStatus, EventWaitHandle> _endpointEventWaitHandle;
/// <summary>
/// Default font for the Status Description text box
/// </summary>
private readonly Font _defaultFont = new Font("Microsoft Sans Serif", (float)8.25, FontStyle.Regular);
/// <summary>
/// Bold font for the Status Description text box
/// </summary>
private readonly Font _boldFont = new Font("Microsoft Sans Serif", (float)8.25, FontStyle.Bold);
/// <summary>
/// Different colors to use for each Status
/// </summary>
private readonly Dictionary<Status, Color> _statusColor
= new Dictionary<Status, Color>
{
{Status.Error, Color.DarkRed},
{Status.Timeout, Color.DarkOrange},
{Status.Unknown, Color.DarkOrange},
{Status.Unreachable, Color.DarkRed},
{Status.Up, Color.DarkGreen},
};
/// <summary>
/// Set to true when windows is closing the current session.
/// </summary>
private bool _endSessionPending;
/// <summary>
/// Logger instance.
/// </summary>
private readonly Logger _logger;
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Main"/> class. /// Initializes a new instance of the <see cref="Main"/> class.
/// </summary> /// </summary>
public Main(IEnumerable<IEndpoint> endpoints, Logger logger) public Main()
{ {
InitializeComponent(); InitializeComponent();
_logger = logger; Resize += Main_Resize;
}
_logger.LogInfo("Starting."); /// <summary>
/// Handles the Resize event of the Main control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
void Main_Resize(object sender, EventArgs e)
{
ShowInTaskbar = !(WindowState == FormWindowState.Minimized);
}
loadMainIcon(Status.Up); /// <summary>
/// Loads the icon based on the status.
/// </summary>
/// <param name="status">The status.</param>
private void LoadMainIcon(Status status)
{
if (_mainStatusIcon == status)
return;
_endpoints = new BindingList<EndpointStatus>(); notifyIcon.Icon = EndpointStatus.GetStatusIcon(status);
endpointBindingSource.DataSource = _endpoints;
_endpointStatuses = new Dictionary<EndpointStatus, Status>();
_endpointEventWaitHandle = new Dictionary<EndpointStatus, EventWaitHandle>();
foreach (var serviceEndpoint in endpoints) notifyIcon.BalloonTipIcon = (status == Status.Up) ? ToolTipIcon.Info : ToolTipIcon.Error;
_mainStatusIcon = status;
}
/// <summary>
/// Handles the Load event of the Main control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
private void Main_Load(object sender, EventArgs e)
{
_logger = new FileLogger(LOG_FILENAME);
LoadMainIcon(Status.Up);
notifyIcon.BalloonTipTitle = "Service DashBored";
notifyIcon.BalloonTipClicked += notifyIcon_BalloonTipClicked;
_endpointStatus = new BindingList<EndpointStatus>();
endpointBindingSource.DataSource = _endpointStatus;
_endpointWaitHandle = new Dictionary<EndpointStatus, RegisteredWaitHandle>();
HttpEndpointConfigurationSection httpEndpointConfigurationSection
= (HttpEndpointConfigurationSection) ConfigurationManager.GetSection("httpEndpointSection");
foreach (HttpEndpointConfiguration endpointConfig in httpEndpointConfigurationSection.Endpoints)
registerServiceEndpoint(new HttpEndpoint(endpointConfig));
HtmlEndpointConfigurationSection htmlEndpointConfigurationSection
= (HtmlEndpointConfigurationSection)ConfigurationManager.GetSection("htmlEndpointSection");
foreach (HtmlEndpointConfiguration endpointConfig in htmlEndpointConfigurationSection.Endpoints)
registerServiceEndpoint(new HtmlEndpoint(endpointConfig));
OracleEndpointConfigurationSection oracleEndpointConfigurationSection
= (OracleEndpointConfigurationSection)ConfigurationManager.GetSection("oracleEndpointSection");
foreach (OracleEndpointConfiguration endpointConfig in oracleEndpointConfigurationSection.Endpoints)
registerServiceEndpoint(new OracleEndpoint(endpointConfig));
SoapEndpointConfigurationSection soapEndpointConfigurationSection
= (SoapEndpointConfigurationSection)ConfigurationManager.GetSection("soapEndpointSection");
foreach (SoapEndpointConfiguration endpointConfig in soapEndpointConfigurationSection.Endpoints)
registerServiceEndpoint(new SoapEndpoint(endpointConfig));
}
/// <summary>
/// Registers the service endpoint.
/// </summary>
/// <param name="serviceEndpoint">The service endpoint.</param>
private void registerServiceEndpoint(IServiceEndpoint serviceEndpoint)
{
EndpointStatus endpointStatus = new EndpointStatus(serviceEndpoint, _logger);
_endpointStatus.Add(endpointStatus);
endpointStatus.PropertyChanged += Endpoint_PropertyChanged;
// Time Interval MasterThread will be executed
TimeSpan timeOut = TimeSpan.FromSeconds(30);
// Start timer thread
AutoResetEvent autoResetEvent = new AutoResetEvent(false);
RegisteredWaitHandle handle = ThreadPool.RegisterWaitForSingleObject(
autoResetEvent,
endpointStatus.ThreadPoolCallback,
"SomeState",
timeOut,
false
);
_endpointWaitHandle.Add(endpointStatus, handle);
autoResetEvent.Set();
}
/// <summary>
/// Handles the PropertyChanged event of an Endpoint.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="System.ComponentModel.PropertyChangedEventArgs"/> instance containing the event data.</param>
void Endpoint_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName != "Status") return;
EndpointStatus senderEndpointStatus = sender as EndpointStatus;
if (senderEndpointStatus == null)
throw new ArgumentException("sender is not EndpointStatus - it is: " + sender.GetType());
List<EndpointStatus> downEndpoints = new List<EndpointStatus>();
List<EndpointStatus> unreachableEndpoints = new List<EndpointStatus>();
if (senderEndpointStatus.Status != Status.Up)
{ {
registerServiceEndpoint(serviceEndpoint); foreach (EndpointStatus endpointStatus in _endpointStatus)
{
switch (endpointStatus.Status)
{
case Status.Timeout:
downEndpoints.Add(endpointStatus);
break;
case Status.Unreachable:
unreachableEndpoints.Add(endpointStatus);
break;
case Status.Error:
downEndpoints.Add(endpointStatus);
break;
}
}
}
string msg = string.Empty;
if (downEndpoints.Count > 0)
{
LoadMainIcon(Status.Timeout);
msg += "These services are timing out:" + Environment.NewLine + getEndpointString(downEndpoints);
}
if (unreachableEndpoints.Count > 0)
{
LoadMainIcon(Status.Unreachable);
msg += "These services are unreachable:" + Environment.NewLine + getEndpointString(unreachableEndpoints);
}
if (msg.Length > 0)
{
notifyIcon.BalloonTipText = msg;
notifyIcon.Text = "Service Problem";
notifyIcon.ShowBalloonTip(1500);
}
else if (downEndpoints.Count == 0 && unreachableEndpoints.Count == 0)
{
LoadMainIcon(Status.Up);
notifyIcon.Text = "All services are running.";
notifyIcon.BalloonTipText = notifyIcon.Text;
} }
} }
/// <summary> /// <summary>
/// Override to intercept WM_QUERYENDSESSION - so we know when the current OS session is ending. /// Concatenates each endpoint description into a single string
/// </summary> /// </summary>
/// <param name="m"></param> /// <param name="endpointStatuses">The endpoint statuses.</param>
/// <remarks>http://www.pixvillage.com/blogs/devblog/archive/2005/03/26/174.aspx</remarks> /// <returns></returns>
protected override void WndProc(ref Message m) private static string getEndpointString(List<EndpointStatus> endpointStatuses)
{ {
if (m.Msg == WM_QUERYENDSESSION) string result = string.Empty;
_endSessionPending = true; endpointStatuses.ForEach(delegate(EndpointStatus endpointStatus)
base.WndProc(ref m); {
result += endpointStatus.ServiceName + Environment.NewLine;
});
return result;
} }
/// <summary> /// <summary>
@@ -111,51 +201,14 @@ namespace ServiceDashBored
/// <param name="e"></param> /// <param name="e"></param>
protected override void OnClosing(CancelEventArgs e) protected override void OnClosing(CancelEventArgs e)
{ {
if (!_endSessionPending) if (!Environment.HasShutdownStarted)
{ {
e.Cancel = true; e.Cancel = true;
WindowState = FormWindowState.Minimized; // minimize instead of close WindowState = FormWindowState.Minimized;
} }
base.OnClosing(e); base.OnClosing(e);
} }
/// <summary>
/// Handles the Resize event of the Main control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
void main_Resize(object sender, EventArgs e)
{
ShowInTaskbar = WindowState != FormWindowState.Minimized;
}
/// <summary>
/// Handles the Load event of the Main control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
private void main_Load(object sender, EventArgs e)
{
notifyIcon.BalloonTipTitle = "Service DashBored";
notifyIcon.BalloonTipClicked += notifyIcon_BalloonTipClicked;
}
/// <summary>
/// Handles the PropertyChanged event of an Endpoint.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="System.ComponentModel.PropertyChangedEventArgs"/> instance containing the event data.</param>
void endpoint_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName != "Status") return;
var senderEndpointStatus = sender as EndpointStatus;
if (senderEndpointStatus == null)
throw new ArgumentException("sender is not EndpointStatus - it is: " + sender.GetType());
Invoke((MethodInvoker)(()=>updateStatus(senderEndpointStatus)));
}
/// <summary> /// <summary>
/// Handles the BalloonTipClicked event of the notifyIcon control. /// Handles the BalloonTipClicked event of the notifyIcon control.
/// </summary> /// </summary>
@@ -176,7 +229,6 @@ namespace ServiceDashBored
/// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
private void exitToolStripMenuItem_Click(object sender, EventArgs e) private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{ {
_logger.LogInfo("User Exiting.");
Application.Exit(); Application.Exit();
} }
@@ -200,228 +252,16 @@ namespace ServiceDashBored
} }
} }
private void dataGridView_RowEnter(object sender, DataGridViewCellEventArgs e) private void dataGridView_CellEnter(object sender, DataGridViewCellEventArgs e)
{ {
var endpointStatus = (EndpointStatus)dataGridView.Rows[e.RowIndex].DataBoundItem; DataGridViewColumn column = dataGridView.Columns[e.ColumnIndex];
cellTextBox.Text = string.Format("{0}. Status Description: {1}", if (column.ValueType == typeof(string))
endpointStatus.ServiceName, endpointStatus.StatusDescription);
}
private void dataGridView_DataError(object sender, DataGridViewDataErrorEventArgs e)
{
_logger.LogError(e.Exception);
}
/// <summary>
/// Registers the service endpoint.
/// </summary>
/// <param name="endpoint">The service endpoint.</param>
private void registerServiceEndpoint(IEndpoint endpoint)
{
var endpointStatus = new EndpointStatus(endpoint, _logger);
// Time Interval MasterThread will be executed
var timeOut = TimeSpan.FromSeconds(ENDPOINT_POLL_TIME_INTERVAL);
// Register a timed callback method in the threadpool.
var waitObject = new AutoResetEvent(false);
ThreadPool.RegisterWaitForSingleObject(
waitObject,
endpointStatus.ThreadPoolCallback,
null,
timeOut,
false
);
_endpoints.Add(endpointStatus);
_endpointStatuses.Add(endpointStatus, endpointStatus.Status);
_endpointEventWaitHandle.Add(endpointStatus, waitObject);
endpointStatus.PropertyChanged += endpoint_PropertyChanged;
waitObject.Set(); // signal an initial callback when done registying
}
/// <summary>
/// Loads the icon based on the status.
/// </summary>
/// <param name="status">The status.</param>
private void loadMainIcon(Status status)
{
if (_systemTrayStatusIcon == status)
return;
notifyIcon.Icon = EndpointStatus.GetStatusIcon(status);
notifyIcon.BalloonTipIcon = (status == Status.Up) ? ToolTipIcon.Info : ToolTipIcon.Error;
_systemTrayStatusIcon = status;
}
/// <summary>
/// Updates the status for the given endpoint.
/// </summary>
/// <remarks>Execute on UI thread</remarks>
/// <param name="endpointStatus">The endpoint status.</param>
private void updateStatus(EndpointStatus endpointStatus)
{
if (endpointStatus == null)
throw new ArgumentNullException("endpointStatus");
lock (_endpoints)
{ {
// if the status hasn't changed, don't do anything... cellTextBox.Text = (string)dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;
if (_endpointStatuses[endpointStatus] == endpointStatus.Status) return;
// if the status has changed...
var oldStatus = _endpointStatuses[endpointStatus];
_endpointStatuses[endpointStatus] = endpointStatus.Status;
// find the worst status of all
var statuses = new List<Status>(_endpointStatuses.Values);
statuses.Sort(new StatusComparer());
loadMainIcon(statuses[0]);
// update the system tray notify ballon info
notifyIcon.BalloonTipText = getShortServiceStatusMessage(endpointStatus);
notifyIcon.Text = endpointStatus.Status == Status.Up ? "Service Running" : "Service Problem";
// update the info in the status text box
updateStatusTextBox();
if (oldStatus != Status.Unknown || endpointStatus.Status != Status.Up)
{
notifyIcon.ShowBalloonTip(NOTIFY_BALLOON_UPDATE_DELAY);
_logger.LogInfo(string.Format("{0}. {1} : {2}", endpointStatus.ServiceName, endpointStatus.Status,
endpointStatus.StatusDescription));
}
} }
} else
/// <summary>
/// Updates the status text box - call this from the UI thread.
/// </summary>
private void updateStatusTextBox()
{
statusTextBox.Text = String.Empty;
var first = true;
foreach (var endpointStatus in _endpoints)
{ {
if (endpointStatus.Status == Status.Up || endpointStatus.Status == Status.Unknown) cellTextBox.Text = string.Empty;
continue;
if (!first)
{
statusTextBox.SelectedText = Environment.NewLine + Environment.NewLine;
}
else
{
first = false;
}
// Make the service description all pretty in the rich text box
statusTextBox.SelectionColor = _statusColor[endpointStatus.Status];
statusTextBox.SelectionFont = _defaultFont;
statusTextBox.SelectedText = endpointStatus.ServiceName;
statusTextBox.SelectionColor = Color.Black;
statusTextBox.SelectionFont = _defaultFont;
statusTextBox.SelectedText = ". ";
statusTextBox.SelectionColor = _statusColor[endpointStatus.Status];
statusTextBox.SelectionFont = _boldFont;
statusTextBox.SelectedText = endpointStatus.Status.ToString();
statusTextBox.SelectionColor = Color.Black;
statusTextBox.SelectionFont = _defaultFont;
statusTextBox.SelectedText = " : " + endpointStatus.StatusDescription;
}
}
/// <summary>
/// Gets the service status message.
/// </summary>
/// <param name="senderEndpointStatus">The sender endpoint status.</param>
/// <returns></returns>
private static string getShortServiceStatusMessage(EndpointStatus senderEndpointStatus)
{
var msg = string.Empty;
switch (senderEndpointStatus.Status)
{
case Status.Error:
msg = "Service Error: " + senderEndpointStatus.ServiceName;
break;
case Status.Timeout:
msg = "Service Timeout: " + senderEndpointStatus.ServiceName;
break;
case Status.Unknown:
msg = "Status Unknown: " + senderEndpointStatus.ServiceName;
break;
case Status.Unreachable:
msg = "Service Unreachable: " + senderEndpointStatus.ServiceName;
break;
case Status.Up:
msg = "Service Running: " + senderEndpointStatus.ServiceName;
break;
}
return msg;
}
private void dataGridView_MouseUp(object sender, MouseEventArgs e)
{
var hitTestInfo = dataGridView.HitTest(e.X, e.Y);
if (hitTestInfo.Type != DataGridViewHitTestType.Cell)
{
// deselect everything
var selectedEndpointStatus = getSelectedDataGridViewRow();
if (selectedEndpointStatus != null)
selectedEndpointStatus.Selected = false;
return;
}
if (e.Button == MouseButtons.Right && hitTestInfo.RowIndex >= 0)
{
// select row on right click as well
if (hitTestInfo.RowIndex >= 0)
{
var selectedEndpointStatus = getSelectedDataGridViewRow();
if (selectedEndpointStatus != null)
selectedEndpointStatus.Selected = false;
var clickedRow = dataGridView.Rows[hitTestInfo.RowIndex];
clickedRow.Selected = true;
}
// show the context menu
dataGridContextMenuStrip.Show(dataGridView, e.Location);
}
}
private DataGridViewRow getSelectedDataGridViewRow()
{
return dataGridView.SelectedRows.Count > 0
? dataGridView.Rows[dataGridView.SelectedRows[0].Index]
: null;
}
private EndpointStatus getSelectedEndpointStatus()
{
var dataGridViewRow = getSelectedDataGridViewRow();
return dataGridViewRow != null
? dataGridViewRow.DataBoundItem as EndpointStatus
: null;
}
private void updateNowToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
var endpointStatus = getSelectedEndpointStatus();
if (endpointStatus != null)
_endpointEventWaitHandle[endpointStatus].Set();
}
catch (Exception ex)
{
_logger.LogError(ex);
} }
} }
} }
+14 -8
View File
@@ -117,20 +117,26 @@
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<metadata name="notifyIcon.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <metadata name="menuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>160, 17</value>
</metadata>
<metadata name="trayContextMenuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value> <value>17, 17</value>
</metadata> </metadata>
<metadata name="notifyIcon.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>126, 10</value>
</metadata>
<metadata name="contextMenuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>227, 10</value>
</metadata>
<metadata name="ServiceName.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="StatusDescription.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="TimeSinceLastUpdate.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="TimeSinceLastUpdate.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value> <value>True</value>
</metadata> </metadata>
<metadata name="endpointBindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <metadata name="endpointBindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>245, 17</value> <value>349, 10</value>
</metadata>
<metadata name="dataGridContextMenuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>395, 17</value>
</metadata> </metadata>
<metadata name="$this.TrayLargeIcon" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="$this.TrayLargeIcon" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value> <value>True</value>
+3 -26
View File
@@ -1,9 +1,5 @@
using System; using System;
using System.Windows.Forms; using System.Windows.Forms;
using BitFactory.Logging;
using Castle.Core.Resource;
using Castle.Windsor;
using Castle.Windsor.Configuration.Interpreters;
namespace ServiceDashBored namespace ServiceDashBored
{ {
@@ -15,28 +11,9 @@ namespace ServiceDashBored
[STAThread] [STAThread]
static void Main() static void Main()
{ {
IWindsorContainer container = Application.EnableVisualStyles();
new WindsorContainer( Application.SetCompatibleTextRenderingDefault(false);
new XmlInterpreter(new ConfigResource("castle"))); Application.Run(new Main());
// Request the component to use it
var form = (Main)container[typeof(Main)];
try
{
// Use the component
Application.Run(form);
}
catch (Exception ex)
{
var logger = (Logger)container[typeof(Logger)];
logger.LogFatal(ex);
}
finally
{
// Release it
container.Release(form);
}
} }
} }
} }
+19 -4
View File
@@ -1,7 +1,7 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// This code was generated by a tool. // This code was generated by a tool.
// Runtime Version:4.0.30128.1 // Runtime Version:4.0.30319.42000
// //
// Changes to this file may cause incorrect behavior and will be lost if // Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated. // the code is regenerated.
@@ -19,7 +19,7 @@ namespace ServiceDashBored.Properties {
// class via a tool like ResGen or Visual Studio. // class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen // To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project. // with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources { internal class Resources {
@@ -60,6 +60,9 @@ namespace ServiceDashBored.Properties {
} }
} }
/// <summary>
/// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
/// </summary>
internal static System.Drawing.Icon accept { internal static System.Drawing.Icon accept {
get { get {
object obj = ResourceManager.GetObject("accept", resourceCulture); object obj = ResourceManager.GetObject("accept", resourceCulture);
@@ -67,13 +70,19 @@ namespace ServiceDashBored.Properties {
} }
} }
internal static System.Drawing.Icon question { /// <summary>
/// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
/// </summary>
internal static System.Drawing.Icon help {
get { get {
object obj = ResourceManager.GetObject("question", resourceCulture); object obj = ResourceManager.GetObject("help", resourceCulture);
return ((System.Drawing.Icon)(obj)); return ((System.Drawing.Icon)(obj));
} }
} }
/// <summary>
/// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
/// </summary>
internal static System.Drawing.Icon remove { internal static System.Drawing.Icon remove {
get { get {
object obj = ResourceManager.GetObject("remove", resourceCulture); object obj = ResourceManager.GetObject("remove", resourceCulture);
@@ -81,6 +90,9 @@ namespace ServiceDashBored.Properties {
} }
} }
/// <summary>
/// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
/// </summary>
internal static System.Drawing.Icon up { internal static System.Drawing.Icon up {
get { get {
object obj = ResourceManager.GetObject("up", resourceCulture); object obj = ResourceManager.GetObject("up", resourceCulture);
@@ -88,6 +100,9 @@ namespace ServiceDashBored.Properties {
} }
} }
/// <summary>
/// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
/// </summary>
internal static System.Drawing.Icon warning { internal static System.Drawing.Icon warning {
get { get {
object obj = ResourceManager.GetObject("warning", resourceCulture); object obj = ResourceManager.GetObject("warning", resourceCulture);
+2 -2
View File
@@ -121,8 +121,8 @@
<data name="accept" type="System.Resources.ResXFileRef, System.Windows.Forms"> <data name="accept" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\accept.ico;System.Drawing.Icon, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> <value>..\Resources\accept.ico;System.Drawing.Icon, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data> </data>
<data name="question" type="System.Resources.ResXFileRef, System.Windows.Forms"> <data name="help" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\question.ico;System.Drawing.Icon, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> <value>..\Resources\help.ico;System.Drawing.Icon, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data> </data>
<data name="remove" type="System.Resources.ResXFileRef, System.Windows.Forms"> <data name="remove" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\remove.ico;System.Drawing.Icon, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> <value>..\Resources\remove.ico;System.Drawing.Icon, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
+37
View File
@@ -0,0 +1,37 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace ServiceDashBored.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.10.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
public global::System.Collections.Hashtable EndpointUrls {
get {
return ((global::System.Collections.Hashtable)(this["EndpointUrls"]));
}
set {
this["EndpointUrls"] = value;
}
}
}
}
@@ -0,0 +1,9 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="ServiceDashBored.Properties" GeneratedClassName="Settings">
<Profiles />
<Settings>
<Setting Name="EndpointUrls" Type="System.Collections.Hashtable" Scope="User">
<Value Profile="(Default)" />
</Setting>
</Settings>
</SettingsFile>
Binary file not shown.

After

Width:  |  Height:  |  Size: 67 KiB

+14 -53
View File
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="Current" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup> <PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -14,23 +14,9 @@
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<FileUpgradeFlags> <FileUpgradeFlags>
</FileUpgradeFlags> </FileUpgradeFlags>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<OldToolsVersion>3.5</OldToolsVersion> <OldToolsVersion>3.5</OldToolsVersion>
<UpgradeBackupLocation />
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
@@ -40,7 +26,6 @@
<DefineConstants>DEBUG;TRACE</DefineConstants> <DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
@@ -49,29 +34,12 @@
<DefineConstants>TRACE</DefineConstants> <DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="BitFactory.Logging, Version=1.4.1.0, Culture=neutral, PublicKeyToken=de68848483a294a9, processorArchitecture=MSIL"> <Reference Include="BitFactory.Logging, Version=1.4.1.0, Culture=neutral, PublicKeyToken=de68848483a294a9, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>References\BitFactory.Logging.dll</HintPath> <HintPath>References\BitFactory.Logging.dll</HintPath>
</Reference> </Reference>
<Reference Include="Castle.Core, Version=1.0.3.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>References\Castle.Core.dll</HintPath>
</Reference>
<Reference Include="Castle.DynamicProxy2, Version=2.0.3.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>References\Castle.DynamicProxy2.dll</HintPath>
</Reference>
<Reference Include="Castle.MicroKernel, Version=1.0.3.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>References\Castle.MicroKernel.dll</HintPath>
</Reference>
<Reference Include="Castle.Windsor, Version=1.0.3.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>References\Castle.Windsor.dll</HintPath>
</Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.configuration" /> <Reference Include="System.configuration" />
<Reference Include="System.Data" /> <Reference Include="System.Data" />
@@ -108,11 +76,21 @@
</Compile> </Compile>
<None Include="app.config" /> <None Include="app.config" />
<None Include="Resources\up.ico" /> <None Include="Resources\up.ico" />
<None Include="Resources\question.ico" /> <None Include="Resources\help.ico" />
<None Include="Resources\remove.ico" /> <None Include="Resources\remove.ico" />
<None Include="Resources\accept.ico" /> <None Include="Resources\accept.ico" />
<None Include="Resources\warning.ico" /> <None Include="Resources\warning.ico" />
<None Include="Properties\DataSources\EndpointStatus.datasource" /> <None Include="Properties\DataSources\EndpointStatus.datasource" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<Compile Include="Settings.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Endpoint\Endpoint.csproj"> <ProjectReference Include="..\Endpoint\Endpoint.csproj">
@@ -120,23 +98,6 @@
<Name>Endpoint</Name> <Name>Endpoint</Name>
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<ItemGroup>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
<Visible>False</Visible>
<ProductName>Windows Installer 3.1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets. Other similar extension points exist, see Microsoft.Common.targets.
+28
View File
@@ -0,0 +1,28 @@
namespace ServiceDashBored.Properties {
// This class allows you to handle specific events on the settings class:
// The SettingChanging event is raised before a setting's value is changed.
// The PropertyChanged event is raised after a setting's value is changed.
// The SettingsLoaded event is raised after the setting values are loaded.
// The SettingsSaving event is raised before the setting values are saved.
internal sealed partial class Settings {
public Settings() {
// // To add event handlers for saving and changing settings, uncomment the lines below:
//
// this.SettingChanging += this.SettingChangingEventHandler;
//
// this.SettingsSaving += this.SettingsSavingEventHandler;
//
}
private void SettingChangingEventHandler(object sender, System.Configuration.SettingChangingEventArgs e) {
// Add code to handle the SettingChangingEvent event here.
}
private void SettingsSavingEventHandler(object sender, System.ComponentModel.CancelEventArgs e) {
// Add code to handle the SettingsSaving event here.
}
}
}
+27 -153
View File
@@ -1,157 +1,31 @@
<?xml version="1.0" encoding="utf-8" ?> <?xml version="1.0" encoding="utf-8" ?>
<configuration> <configuration>
<configSections> <configSections>
<section name="castle" type="Castle.Windsor.Configuration.AppDomain.CastleSectionHandler, Castle.Windsor" /> <section name="httpEndpointSection" type="Endpoint.HttpEndpointConfigurationSection, Endpoint"/>
</configSections> <section name="htmlEndpointSection" type="Endpoint.HtmlEndpointConfigurationSection, Endpoint"/>
<castle> <section name="oracleEndpointSection" type="Endpoint.OracleEndpointConfigurationSection, Endpoint"/>
<components> <section name="soapEndpointSection" type="Endpoint.SoapEndpointConfigurationSection, Endpoint"/>
<component id="form.component" type="ServiceDashBored.Main, ServiceDashBored"> </configSections>
<parameters> <httpEndpointSection>
<endpoints> <endpoints>
<array> <add name="kpcoql06 (paypal)" uri="http://kpcodl06:8080/paypal_server/PayPalService" />
<item>${google.endpoint}</item> <add name="google2" uri="http://www.google.com" />
<item>${10.21.63.6.endpoint}</item> </endpoints>
<item>${localhost.freespace.endpoint}</item> </httpEndpointSection>
</array> <htmlEndpointSection>
</endpoints> <endpoints>
</parameters> <!--<add name="kpapdl26 (payment)" uri="http://kpapdl26:8080/core_server/paymentservice" xpathQuery="//td[text()=&quot;PaymentService&quot;]/following-sibling::td/text()" expectedXpathResult="ACTIVE" />-->
</component> </endpoints>
</htmlEndpointSection>
<component id="logger.component" service="BitFactory.Logging.Logger, BitFactory.Logging" type="BitFactory.Logging.FileLogger, BitFactory.Logging"> <oracleEndpointSection>
<parameters> <endpoints>
<aFileName>ServiceDashBored.log</aFileName> <!--<add name="x5_int" connectionString="Data Source=x5_int01.jewelry.dev;User ID=webcontent;Password=acnwebcontent;"
</parameters> scalarQueryString="select 1 from dual" expectedQueryResult="1" />-->
</component> </endpoints>
</oracleEndpointSection>
<component id="kpcodl06.endpoint" service="Endpoint.IEndpoint, Endpoint" type="Endpoint.HttpEndpoint, Endpoint"> <soapEndpointSection>
<parameters> <endpoints>
<Name>kpcodl06:8080 (paypal)</Name> <add name="kpapdl26 (key)" uri="http://kpapdl26:8080/core_server/paymentservice" xpathQuery="//jtv:provider/text()" xpathNamespaces="jtv,http://jtv.com" expectedXpathResult="NoDecision" soapAction="&quot;urn:getPaymentKey&quot;" soapRequest="&lt;soapenv:Envelope xmlns:soapenv=&quot;http://schemas.xmlsoap.org/soap/envelope/&quot; xmlns:jtv=&quot;http://jtv.com&quot;&gt;&lt;soapenv:Header/&gt;&lt;soapenv:Body&gt;&lt;jtv:getPaymentKey&gt;&lt;jtv:context&gt;&lt;/jtv:context&gt;&lt;/jtv:getPaymentKey&gt;&lt;/soapenv:Body&gt;&lt;/soapenv:Envelope&gt;" />
<UriString>http://kpcodl06:8080/paypal_server/PayPalService</UriString> </endpoints>
</parameters> </soapEndpointSection>
</component>
<component id="kpapqlz03.endpoint" service="Endpoint.IEndpoint, Endpoint" type="Endpoint.HttpEndpoint, Endpoint">
<parameters>
<Name>kpapqlz03:8080 (paypal)</Name>
<UriString>http://kpapqlz03:8080/paypal_server/PayPalService</UriString>
</parameters>
</component>
<component id="kpcoql03.endpoint" service="Endpoint.IEndpoint, Endpoint" type="Endpoint.HttpEndpoint, Endpoint">
<parameters>
<Name>kpcoql03:8083 (OrderService)</Name>
<UriString>http://kpcoql03.jewelry.qa:8083/catalyst_server/OrderService</UriString>
</parameters>
</component>
<component id="10.21.63.6.endpoint" service="Endpoint.IEndpoint, Endpoint" type="Endpoint.HttpEndpoint, Endpoint">
<parameters>
<Name>10.21.63.6 (ws-virtual)</Name>
<UriString>http://10.21.63.6</UriString>
</parameters>
</component>
<component id="10.21.63.7.endpoint" service="Endpoint.IEndpoint, Endpoint" type="Endpoint.HttpEndpoint, Endpoint">
<parameters>
<Name>10.21.63.7 (ws-virtual)</Name>
<UriString>http://10.21.63.7</UriString>
</parameters>
</component>
<component id="10.21.63.8.endpoint" service="Endpoint.IEndpoint, Endpoint" type="Endpoint.HttpEndpoint, Endpoint">
<parameters>
<Name>10.21.63.8 (ws-virtual)</Name>
<UriString>http://10.21.63.8</UriString>
</parameters>
</component>
<component id="10.21.63.10.endpoint" service="Endpoint.IEndpoint, Endpoint" type="Endpoint.HttpEndpoint, Endpoint">
<parameters>
<Name>10.21.63.10 (ws-virtual)</Name>
<UriString>http://10.21.63.10</UriString>
</parameters>
</component>
<component id="10.21.63.11.endpoint" service="Endpoint.IEndpoint, Endpoint" type="Endpoint.HttpEndpoint, Endpoint">
<parameters>
<Name>10.21.63.11 (ws-physical)</Name>
<UriString>http://10.21.63.11</UriString>
</parameters>
</component>
<component id="10.21.63.12.endpoint" service="Endpoint.IEndpoint, Endpoint" type="Endpoint.HttpEndpoint, Endpoint">
<parameters>
<Name>10.21.63.12 (ws-physical)</Name>
<UriString>http://10.21.63.12</UriString>
</parameters>
</component>
<component id="images.jewelry.dmz.endpoint" service="Endpoint.IEndpoint, Endpoint" type="Endpoint.HttpEndpoint, Endpoint">
<parameters>
<Name>images.jewelry.dmz (ws-virtual)</Name>
<UriString>http://images.jewelry.dmz</UriString>
</parameters>
</component>
<component id="google.endpoint" service="Endpoint.IEndpoint, Endpoint" type="Endpoint.HttpEndpoint, Endpoint">
<parameters>
<Name>Google</Name>
<UriString>http://www.google.com</UriString>
</parameters>
</component>
<component id="localhost.freespace.endpoint" service="Endpoint.IEndpoint, Endpoint" type="Endpoint.WmiEndpoint, Endpoint">
<parameters>
<Name>localhost D: Freespace</Name>
<MachineName>\\localhost</MachineName>
<ObjectQueryString>select FreeSpace from Win32_LogicalDisk where DeviceID='D:'</ObjectQueryString>
<ResultPropertyName>FreeSpace</ResultPropertyName>
<MinimumThreshold>50e6</MinimumThreshold>
</parameters>
</component>
<component id="kpapdl26.endpoint" service="Endpoint.IEndpoint, Endpoint" type="Endpoint.SoapEndpoint, Endpoint">
<parameters>
<Name>kpapdl26:8080 (payment)</Name>
<UriString>http://kpapdl26:8080/core_server/paymentservice</UriString>
<XpathQuery>//jtv:provider/text()</XpathQuery>
<XpathNamespaces>jtv,http://jtv.com</XpathNamespaces>
<ExpectedXpathResult>NoDecision</ExpectedXpathResult>
<SoapAction>"urn:getPaymentKey"</SoapAction>
<SoapRequest>
<![CDATA[<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:jtv="http://jtv.com"><soapenv:Header/><soapenv:Body><jtv:getPaymentKey><jtv:context></jtv:context></jtv:getPaymentKey></soapenv:Body></soapenv:Envelope>]]>
</SoapRequest>
</parameters>
</component>
<component id="pscoql03.endpoint" service="Endpoint.IEndpoint, Endpoint" type="Endpoint.SoapEndpoint, Endpoint">
<parameters>
<Name>pscoql03:8080 (payment)</Name>
<UriString>http://pscoql03:8080/core_server/paymentservice</UriString>
<XpathQuery>//jtv:provider/text()</XpathQuery>
<XpathNamespaces>jtv,http://jtv.com</XpathNamespaces>
<ExpectedXpathResult>NoDecision</ExpectedXpathResult>
<SoapAction>"urn:getPaymentKey"</SoapAction>
<SoapRequest>
<![CDATA[<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:jtv="http://jtv.com"><soapenv:Header/><soapenv:Body><jtv:getPaymentKey><jtv:context></jtv:context></jtv:getPaymentKey></soapenv:Body></soapenv:Envelope>]]>
</SoapRequest>
</parameters>
</component>
<component id="10.20.7.26.endpoint" service="Endpoint.IEndpoint, Endpoint" type="Endpoint.SoapEndpoint, Endpoint">
<parameters>
<Name>10.20.7.26:8080 (payment)</Name>
<UriString>http://10.20.7.26:8080/core_server/paymentservice</UriString>
<XpathQuery>//jtv:provider/text()</XpathQuery>
<XpathNamespaces>jtv,http://jtv.com</XpathNamespaces>
<ExpectedXpathResult>NoDecision</ExpectedXpathResult>
<SoapAction>"urn:getPaymentKey"</SoapAction>
<SoapRequest>
<![CDATA[<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:jtv="http://jtv.com"><soapenv:Header/><soapenv:Body><jtv:getPaymentKey><jtv:context></jtv:context></jtv:getPaymentKey></soapenv:Body></soapenv:Envelope>]]>
</SoapRequest>
</parameters>
</component>
</components>
</castle>
</configuration> </configuration>