Configuration branch
This commit is contained in:
+16
-42
@@ -1,5 +1,5 @@
|
||||
<?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>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
@@ -14,23 +14,9 @@
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<FileUpgradeFlags>
|
||||
</FileUpgradeFlags>
|
||||
<UpgradeBackupLocation>
|
||||
</UpgradeBackupLocation>
|
||||
<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 Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
@@ -40,7 +26,6 @@
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
@@ -49,51 +34,40 @@
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="HtmlAgilityPack, Version=1.3.0.0, Culture=neutral, PublicKeyToken=bd319b19eaf3b43a, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>References\HtmlAgilityPack.dll</HintPath>
|
||||
</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.configuration" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Management" />
|
||||
<Reference Include="System.ServiceProcess" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<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="IServiceEndpoint.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="ServiceEndpointFactory.cs" />
|
||||
<Compile Include="SoapEndpointConfiguration.cs" />
|
||||
<Compile Include="SoapEndpoint.cs" />
|
||||
<Compile Include="Status.cs" />
|
||||
<Compile Include="StatusComparer.cs" />
|
||||
<Compile Include="WindowsServiceEndpoint.cs" />
|
||||
<Compile Include="WmiEndpoint.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</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" />
|
||||
<!-- 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.
|
||||
|
||||
+34
-36
@@ -6,36 +6,15 @@ using HtmlAgilityPack;
|
||||
|
||||
namespace Endpoint
|
||||
{
|
||||
/// <summary>
|
||||
/// A website endpoint
|
||||
/// </summary>
|
||||
public class HtmlEndpoint : HttpEndpoint
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the xpath query for the html document
|
||||
/// </summary>
|
||||
/// <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.
|
||||
/// Returns the HTML parsed into a standard XmlDocument.
|
||||
/// Uses the HtmlAgilityPack library for "out of the web" (poorly formatted) html file support.
|
||||
/// </summary>
|
||||
/// <param name="html">The HTML</param>
|
||||
/// <returns>An <see cref="XmlDocument"/> from the HTML</returns>
|
||||
private static XmlDocument getHtmlXml(string html)
|
||||
/// <returns>An XmlDocument from the HTML</returns>
|
||||
private static XmlDocument GetHtmlXml(string html)
|
||||
{
|
||||
var htmlDocument = new HtmlDocument();
|
||||
htmlDocument.LoadHtml(html);
|
||||
@@ -58,15 +37,34 @@ namespace Endpoint
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the HTML grabbed from the passed in URL parsed into a standard <see cref="XmlDocument"/>.
|
||||
/// Uses the <see cref="HtmlAgilityPack"/> library for "out of the web" html file support.
|
||||
/// Returns the HTML grabbed from the passed in URL parsed into a standard XmlDocument.
|
||||
/// Uses the HtmlAgilityPack library for "out of the web" html file support.
|
||||
/// </summary>
|
||||
/// <param name="url">The URL.</param>
|
||||
/// <param name="requestContent">The post data.</param>
|
||||
/// <returns>An <see cref="XmlDocument"/> from the HTML</returns>
|
||||
private static XmlDocument getHtmlXml(Uri url, string requestContent)
|
||||
/// <returns>An XmlDocument from the HTML</returns>
|
||||
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>
|
||||
@@ -75,17 +73,17 @@ namespace Endpoint
|
||||
/// <returns>Status</returns>
|
||||
public override Status GetStatus()
|
||||
{
|
||||
var baseStatus = base.GetStatus();
|
||||
Status baseStatus = base.GetStatus();
|
||||
if (baseStatus != Status.Up)
|
||||
return baseStatus;
|
||||
|
||||
try
|
||||
{
|
||||
var xml = getHtmlXml(Uri, RequestContent);
|
||||
XmlDocument xml = GetHtmlXml(HttpEndpointConfiguration.Uri, HtmlEndpointConfiguration.RequestContent);
|
||||
|
||||
// xml.Save(@"c:\test.xml");
|
||||
|
||||
var nodes = xml.SelectNodes(XpathQuery);
|
||||
XmlNodeList nodes = xml.SelectNodes(HtmlEndpointConfiguration.XpathQuery);
|
||||
|
||||
// verify html has expected value
|
||||
if (nodes == null || nodes.Count == 0)
|
||||
@@ -93,11 +91,11 @@ namespace Endpoint
|
||||
StatusDescription = "Couldn't find expected value in html";
|
||||
return Status.Error;
|
||||
}
|
||||
var value = nodes[0].Value.Trim();
|
||||
if (value != ExpectedXpathResult)
|
||||
string value = nodes[0].Value.Trim();
|
||||
if (value != HtmlEndpointConfiguration.ExpectedXpathResult)
|
||||
{
|
||||
StatusDescription = String.Format("Result was: '{0}', was expecting '{1}'", value,
|
||||
ExpectedXpathResult);
|
||||
HtmlEndpointConfiguration.ExpectedXpathResult);
|
||||
return Status.Error;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
@@ -1,8 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Endpoint
|
||||
{
|
||||
@@ -10,66 +10,50 @@ namespace Endpoint
|
||||
/// Http Endpoint - such as a webserver, a webservice, etc
|
||||
/// </summary>
|
||||
[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>
|
||||
/// Returns the response string grabbed from the passed in URL.
|
||||
/// </summary>
|
||||
/// <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="webHeaders">The web headers.</param>
|
||||
/// <returns>A string containing response</returns>
|
||||
protected static string GetUrlContent(Uri url, string contentType, string requestContent,
|
||||
Dictionary<string, string> webHeaders)
|
||||
protected static string GetUrlContent(Uri url, string contentType, string requestContent, Dictionary<string,string> webHeaders)
|
||||
{
|
||||
// POST request
|
||||
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();
|
||||
|
||||
// SOAP
|
||||
webRequest.ContentType = contentType;
|
||||
if (webHeaders != null && webHeaders.Count > 0)
|
||||
{
|
||||
foreach (var webHeader in webHeaders)
|
||||
foreach (KeyValuePair<string, string> webHeader in webHeaders)
|
||||
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.Accept = "text/xml";
|
||||
|
||||
//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;
|
||||
using (var requestStream = webRequest.GetRequestStream())
|
||||
using (Stream requestStream = webRequest.GetRequestStream())
|
||||
{
|
||||
requestStream.Write(bytes, 0, bytes.Length); //write it to the stream
|
||||
}
|
||||
var webResponse = webRequest.GetResponse();
|
||||
WebResponse webResponse = webRequest.GetResponse();
|
||||
if (webResponse == null)
|
||||
return null;
|
||||
using (var streamReader = new StreamReader(webResponse.GetResponseStream()))
|
||||
@@ -80,18 +64,46 @@ namespace Endpoint
|
||||
|
||||
// GET Request
|
||||
var client = new WebClient();
|
||||
using (var data = client.OpenRead(url))
|
||||
using (Stream data = client.OpenRead(url))
|
||||
using (var reader = new StreamReader(data))
|
||||
{
|
||||
return reader.ReadToEnd();
|
||||
}
|
||||
}
|
||||
|
||||
protected readonly IHttpEndpointConfiguration _httpEndpointConfiguration;
|
||||
|
||||
/// <summary>
|
||||
/// Returns a string explaining details on the current status
|
||||
/// </summary>
|
||||
/// <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>
|
||||
/// Gets the current status result of the endpoint
|
||||
@@ -101,24 +113,36 @@ namespace Endpoint
|
||||
{
|
||||
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;
|
||||
return response.StatusCode == HttpStatusCode.OK
|
||||
? Status.Up
|
||||
: Status.Unreachable;
|
||||
if (response.StatusCode == HttpStatusCode.OK)
|
||||
return Status.Up;
|
||||
return Status.Unreachable;
|
||||
}
|
||||
}
|
||||
catch (WebException ex)
|
||||
{
|
||||
StatusDescription = ex.Message + " (" + ex.Status + ")";
|
||||
|
||||
return ex.Status == WebExceptionStatus.Timeout
|
||||
? Status.Timeout
|
||||
: Status.Unreachable;
|
||||
// TODO: LOG
|
||||
if (ex.Status == WebExceptionStatus.Timeout)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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"]); } }
|
||||
}
|
||||
}
|
||||
@@ -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; }
|
||||
}
|
||||
}
|
||||
@@ -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; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
|
||||
namespace Endpoint
|
||||
{
|
||||
/// <summary>
|
||||
/// Describes a service endpoint's configuration
|
||||
/// </summary>
|
||||
public interface IServiceEndpointConfiguration
|
||||
{
|
||||
string Name { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -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 = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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"]); } }
|
||||
}
|
||||
}
|
||||
@@ -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
@@ -4,92 +4,71 @@ using System.Xml;
|
||||
|
||||
namespace Endpoint
|
||||
{
|
||||
/// <summary>
|
||||
/// A SOAP webservice endpoint.
|
||||
/// </summary>
|
||||
public class SoapEndpoint : HttpEndpoint
|
||||
{
|
||||
private string _xpathNamespaces = string.Empty;
|
||||
private Dictionary<string, string> _namespaceToUri;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the xpath query for the html document
|
||||
/// Gets the SOAP endpoint configuration.
|
||||
/// </summary>
|
||||
/// <value>The xpath query.</value>
|
||||
public string XpathQuery { get; set; }
|
||||
/// <value>The SOAP endpoint configuration.</value>
|
||||
public SoapEndpointConfiguration SoapEndpointConfiguration
|
||||
{
|
||||
get { return (SoapEndpointConfiguration)_httpEndpointConfiguration; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the namespaces used in the xpath query
|
||||
/// Initializes a new instance of the <see cref="HttpEndpoint"/> class.
|
||||
/// </summary>
|
||||
/// <value>The xpath namespaces.</value>
|
||||
public string XpathNamespaces
|
||||
/// <param name="config">The SoapEndpointConfiguration.</param>
|
||||
public SoapEndpoint(SoapEndpointConfiguration config)
|
||||
: base(config)
|
||||
{
|
||||
get { return _xpathNamespaces; }
|
||||
set
|
||||
if (!string.IsNullOrEmpty(SoapEndpointConfiguration.XpathNamespaces))
|
||||
{
|
||||
_xpathNamespaces = value;
|
||||
if (string.IsNullOrEmpty(_xpathNamespaces)) return;
|
||||
|
||||
var split = _xpathNamespaces.Split(',');
|
||||
string[] split = SoapEndpointConfiguration.XpathNamespaces.Split(',');
|
||||
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.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>
|
||||
/// Gets the current status result of the endpoint
|
||||
/// </summary>
|
||||
/// <returns>Status</returns>
|
||||
public override Status GetStatus()
|
||||
{
|
||||
var baseStatus = base.GetStatus();
|
||||
if (baseStatus != Status.Up) // if we can't even get to the webserver, no need to try and call a WS.
|
||||
Status baseStatus = base.GetStatus();
|
||||
if (baseStatus != Status.Up)
|
||||
return baseStatus;
|
||||
|
||||
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;
|
||||
if (_namespaceToUri != null)
|
||||
{
|
||||
var nsMgr = new XmlNamespaceManager(xml.NameTable);
|
||||
foreach (var namespaceToUri in _namespaceToUri)
|
||||
XmlNamespaceManager nsMgr = new XmlNamespaceManager(xml.NameTable);
|
||||
foreach (KeyValuePair<string, string> namespaceToUri in _namespaceToUri)
|
||||
{
|
||||
nsMgr.AddNamespace(namespaceToUri.Key, namespaceToUri.Value);
|
||||
}
|
||||
|
||||
nodes = xml.SelectNodes(XpathQuery, nsMgr);
|
||||
nodes = xml.SelectNodes(SoapEndpointConfiguration.XpathQuery, nsMgr);
|
||||
}
|
||||
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
|
||||
if (nodes == null || nodes.Count == 0)
|
||||
@@ -97,11 +76,11 @@ namespace Endpoint
|
||||
StatusDescription = "Couldn't find expected value in SOAP response";
|
||||
return Status.Error;
|
||||
}
|
||||
var value = nodes[0].Value.Trim();
|
||||
if (value != ExpectedXpathResult)
|
||||
string value = nodes[0].Value.Trim();
|
||||
if (value != SoapEndpointConfiguration.ExpectedXpathResult)
|
||||
{
|
||||
StatusDescription = String.Format("Result was: '{0}', was expecting '{1}'", value,
|
||||
ExpectedXpathResult);
|
||||
SoapEndpointConfiguration.ExpectedXpathResult);
|
||||
return Status.Error;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
@@ -3,13 +3,8 @@ namespace Endpoint
|
||||
/// <summary>
|
||||
/// Status of an endpoint
|
||||
/// </summary>
|
||||
/// <remarks>The <see cref="StatusComparer"/> expects these to be in order of best-to-worst descending.</remarks>
|
||||
public enum Status
|
||||
{
|
||||
/// <summary>
|
||||
/// Service state is unknown - this will occur only before the first poll.
|
||||
/// </summary>
|
||||
Unknown,
|
||||
/// <summary>
|
||||
/// Service is working
|
||||
/// </summary>
|
||||
@@ -25,6 +20,7 @@ namespace Endpoint
|
||||
/// <summary>
|
||||
/// Service is available, but returns an error message
|
||||
/// </summary>
|
||||
Error
|
||||
Error,
|
||||
Unknown
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
<?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>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
@@ -15,23 +14,9 @@
|
||||
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<FileUpgradeFlags>
|
||||
</FileUpgradeFlags>
|
||||
<UpgradeBackupLocation>
|
||||
</UpgradeBackupLocation>
|
||||
<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 Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
@@ -41,7 +26,6 @@
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
@@ -50,14 +34,13 @@
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="HtmlAgilityPack, Version=1.3.0.0, Culture=neutral, PublicKeyToken=bd319b19eaf3b43a, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\Endpoint\References\HtmlAgilityPack.dll</HintPath>
|
||||
</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">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\Endpoint\References\Oracle.DataAccess.dll</HintPath>
|
||||
@@ -71,12 +54,9 @@
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="SoapEndpointTest.cs" />
|
||||
<Compile Include="HtmlEndpointTest.cs" />
|
||||
<Compile Include="HttpEndpointTest.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="WindowsServiceEndpointTest.cs" />
|
||||
<Compile Include="WmiEndpointTest.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Endpoint\Endpoint.csproj">
|
||||
@@ -84,28 +64,6 @@
|
||||
<Name>Endpoint</Name>
|
||||
</ProjectReference>
|
||||
</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" />
|
||||
<!-- 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.
|
||||
|
||||
@@ -1,17 +1,15 @@
|
||||
using System;
|
||||
using Endpoint;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
namespace EndpointTest
|
||||
{
|
||||
/// <summary>
|
||||
///This is a test class for HtmlEndpointTest and is intended
|
||||
///to contain all HtmlEndpointTest Unit Tests
|
||||
///</summary>
|
||||
[TestClass]
|
||||
/// <summary>
|
||||
///This is a test class for HtmlEndpointTest and is intended
|
||||
///to contain all HtmlEndpointTest Unit Tests
|
||||
///</summary>
|
||||
[TestClass()]
|
||||
public class HtmlEndpointTest
|
||||
{
|
||||
// Random website for functional testing
|
||||
private readonly Uri _goodUri = new Uri("http://www.seekwellness.com/sca/");
|
||||
|
||||
/// <summary>
|
||||
@@ -20,16 +18,16 @@ namespace EndpointTest
|
||||
[TestMethod]
|
||||
public void HtmlEndpointConfigurationTest()
|
||||
{
|
||||
var target = new HtmlEndpoint
|
||||
{
|
||||
UriString = _goodUri.OriginalString,
|
||||
XpathQuery = "//td[contains(text(), 'Use this form')]/text()",
|
||||
ExpectedXpathResult = "Use this form to order your",
|
||||
RequestContent = "redeem_coupon=true&f_coupon_code=stuff"
|
||||
};
|
||||
HtmlEndpointConfiguration config =
|
||||
new HtmlEndpointConfiguration {
|
||||
UriString = _goodUri.OriginalString,
|
||||
XpathQuery = "//td[contains(text(), 'Use this form')]/text()",
|
||||
ExpectedXpathResult = "Use this form to order your",
|
||||
RequestContent = "redeem_coupon=true&f_coupon_code=stuff"
|
||||
};
|
||||
HtmlEndpoint target = new HtmlEndpoint(config); // TODO: Initialize to an appropriate value
|
||||
|
||||
var status = target.GetStatus();
|
||||
Assert.AreEqual(Status.Up, status, target.StatusDescription);
|
||||
Status status = target.GetStatus();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -38,15 +36,17 @@ namespace EndpointTest
|
||||
[TestMethod]
|
||||
public void HtmlEndpointFormTest()
|
||||
{
|
||||
var target = new HtmlEndpoint
|
||||
{
|
||||
UriString = _goodUri.OriginalString,
|
||||
XpathQuery = "//p[@class='errorMsg']/text()",
|
||||
ExpectedXpathResult = "- Please enter a valid coupon code.",
|
||||
RequestContent = "redeem_coupon=true&f_coupon_code=stuff"
|
||||
};
|
||||
HtmlEndpointConfiguration config =
|
||||
new HtmlEndpointConfiguration
|
||||
{
|
||||
UriString = _goodUri.OriginalString,
|
||||
XpathQuery = "//p[@class='errorMsg']/text()",
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,40 +1,32 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Net;
|
||||
using Endpoint;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System;
|
||||
|
||||
namespace EndpointTest
|
||||
{
|
||||
/// <summary>
|
||||
///This is a test class for HttpEndpointTest and is intended
|
||||
///to contain all HttpEndpointTest Unit Tests
|
||||
///</summary>
|
||||
[TestClass]
|
||||
/// <summary>
|
||||
///This is a test class for HttpEndpointTest and is intended
|
||||
///to contain all HttpEndpointTest Unit Tests
|
||||
///</summary>
|
||||
[TestClass()]
|
||||
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 _unreachableDomainUri = new Uri("http://gasdfasdh598yqwejbiasalsdjfhaogle");
|
||||
private readonly Uri _downUri = new Uri("http://192.168.0.153");
|
||||
private readonly Uri _httpsUri = new Uri("https://sourceforge.net/");
|
||||
|
||||
/// <summary>
|
||||
///A test for HttpEndpoint Constructor
|
||||
///A test for Url
|
||||
///</summary>
|
||||
[TestMethod]
|
||||
public void HttpEndpointConstructorTest()
|
||||
public void UrlTest()
|
||||
{
|
||||
HttpEndpoint endpoint = new HttpEndpoint {Uri = _goodUri};
|
||||
Assert.AreEqual(_goodUri, endpoint.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);
|
||||
HttpEndpoint endpoint = new HttpEndpoint(new HttpEndpointConfiguration("", _goodUri));
|
||||
Assert.AreEqual(_goodUri, endpoint.HttpEndpointConfiguration.Uri);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -43,7 +35,7 @@ namespace EndpointTest
|
||||
[TestMethod]
|
||||
public void GetStatusGoodTest()
|
||||
{
|
||||
HttpEndpoint endpoint = new HttpEndpoint {Uri = _goodUri};
|
||||
HttpEndpoint endpoint = new HttpEndpoint(new HttpEndpointConfiguration("", _goodUri));
|
||||
Assert.AreEqual(Status.Up, endpoint.GetStatus());
|
||||
}
|
||||
|
||||
@@ -53,7 +45,7 @@ namespace EndpointTest
|
||||
[TestMethod]
|
||||
public void GetStatusMissingTest()
|
||||
{
|
||||
HttpEndpoint endpoint = new HttpEndpoint {Uri = _missingUri};
|
||||
HttpEndpoint endpoint = new HttpEndpoint(new HttpEndpointConfiguration("", _missingUri));
|
||||
Assert.AreEqual(Status.Unreachable, endpoint.GetStatus());
|
||||
}
|
||||
|
||||
@@ -63,7 +55,7 @@ namespace EndpointTest
|
||||
[TestMethod]
|
||||
public void GetStatusUnreachableTest()
|
||||
{
|
||||
HttpEndpoint endpoint = new HttpEndpoint {Uri = _unreachableDomainUri};
|
||||
HttpEndpoint endpoint = new HttpEndpoint(new HttpEndpointConfiguration("", _unreachableDomainUri));
|
||||
Assert.AreEqual(Status.Unreachable, endpoint.GetStatus());
|
||||
}
|
||||
|
||||
@@ -73,7 +65,7 @@ namespace EndpointTest
|
||||
[TestMethod]
|
||||
public void GetStatusDownTest()
|
||||
{
|
||||
HttpEndpoint endpoint = new HttpEndpoint {Uri = _downUri};
|
||||
HttpEndpoint endpoint = new HttpEndpoint(new HttpEndpointConfiguration("", _downUri));
|
||||
Assert.AreEqual(Status.Unreachable, endpoint.GetStatus());
|
||||
}
|
||||
|
||||
@@ -83,8 +75,18 @@ namespace EndpointTest
|
||||
[TestMethod]
|
||||
public void GetHttpsTest()
|
||||
{
|
||||
HttpEndpoint endpoint = new HttpEndpoint {Uri = _httpsUri};
|
||||
HttpEndpoint endpoint = new HttpEndpoint(new HttpEndpointConfiguration("", _httpsUri));
|
||||
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
@@ -1,6 +1,8 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 11.00
|
||||
# Visual Studio 2010
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# 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}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
LocalTestRun.testrunconfig = LocalTestRun.testrunconfig
|
||||
@@ -14,9 +16,6 @@ EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EndpointTest", "EndpointTest\EndpointTest.csproj", "{76D78812-B640-4EF0-957B-15D0E9000A84}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(TestCaseManagementSettings) = postSolution
|
||||
CategoryFile = ServiceDashBored.vsmdi
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
@@ -38,4 +37,10 @@ Global
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {93EF7101-5AA3-4AC7-B544-93735F7253F3}
|
||||
EndGlobalSection
|
||||
GlobalSection(TestCaseManagementSettings) = postSolution
|
||||
CategoryFile = ServiceDashBored.vsmdi
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
||||
@@ -15,34 +15,47 @@ namespace ServiceDashBored
|
||||
{
|
||||
#region Private Members
|
||||
|
||||
private readonly IEndpoint _endpoint;
|
||||
private readonly Timer _lastUpdateTimer;
|
||||
private readonly IServiceEndpoint _serviceEndpoint;
|
||||
private readonly Timer _timer;
|
||||
private Status? _status = Endpoint.Status.Unknown;
|
||||
private string _statusMessage = string.Empty;
|
||||
private Icon _statusIcon;
|
||||
private DateTime _lastUpdate;
|
||||
private readonly Logger _logger;
|
||||
private readonly TimeSpan _updatePeriod;
|
||||
private static readonly object _propertyUpdateSyncObject = new Object();
|
||||
private static readonly object _callbackSyncObject = new Object();
|
||||
private bool _insideCallback;
|
||||
private static readonly object _syncObject = 0;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// Gets the icon based on the status.
|
||||
/// Loads the icon based on the status.
|
||||
/// </summary>
|
||||
public Icon StatusIcon { get; private set; }
|
||||
public Icon StatusIcon
|
||||
{
|
||||
get
|
||||
{
|
||||
return _statusIcon;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets service's current status.
|
||||
/// Gets the status.
|
||||
/// </summary>
|
||||
/// <value>The status.</value>
|
||||
public Status Status { get; private set; }
|
||||
public Status Status
|
||||
{
|
||||
get { return _status.Value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a string explaining details on the current status
|
||||
/// </summary>
|
||||
public string StatusDescription { get; private set; }
|
||||
public string StatusDescription
|
||||
{
|
||||
get { return _statusMessage; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the time since the last update
|
||||
@@ -52,41 +65,22 @@ namespace ServiceDashBored
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_lastUpdate == DateTime.MinValue)
|
||||
return "never";
|
||||
if (_lastUpdate == DateTime.MaxValue)
|
||||
return "updating";
|
||||
|
||||
var timeSpan = DateTime.Now - _lastUpdate;
|
||||
TimeSpan timeSpan = (DateTime.Now - _lastUpdate);
|
||||
if (timeSpan.Minutes > 0 )
|
||||
return String.Format("{0}m {1}s", timeSpan.Minutes, timeSpan.Seconds);
|
||||
return
|
||||
timeSpan.Seconds + 1 + "s";
|
||||
timeSpan.Seconds + "s";
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the service.
|
||||
///
|
||||
/// </summary>
|
||||
/// <value>The name of the service.</value>
|
||||
public string ServiceName
|
||||
{
|
||||
get
|
||||
{
|
||||
return _endpoint.Name;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the last update time.
|
||||
/// </summary>
|
||||
/// <value>The last update time.</value>
|
||||
private DateTime lastUpdate
|
||||
{
|
||||
set
|
||||
{
|
||||
_lastUpdate = value;
|
||||
SignalPropertyChanged("TimeSinceLastUpdate");
|
||||
return _serviceEndpoint.ServiceName;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,33 +89,24 @@ namespace ServiceDashBored
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Callback for the <c>threadpool</c>
|
||||
/// Callback for the threadpool
|
||||
/// </summary>
|
||||
/// <param name="threadContext">The thread context.</param>
|
||||
/// <param name="isTimeOut">The callback was triggered from a timeout</param>
|
||||
public void ThreadPoolCallback(object threadContext, bool isTimeOut)
|
||||
/// <param name="activated"></param>
|
||||
public void ThreadPoolCallback(object threadContext, bool activated)
|
||||
{
|
||||
lock(_callbackSyncObject)
|
||||
{
|
||||
if (_insideCallback)
|
||||
return;
|
||||
_insideCallback = true;
|
||||
}
|
||||
try
|
||||
{
|
||||
// turn off the timer while waiting for an update
|
||||
_lastUpdateTimer.Change(Timeout.Infinite, Timeout.Infinite);
|
||||
//Debug.WriteLine(DateTime.Now + " " + _serviceEndpoint.ServiceName + ": updateStatus");
|
||||
//_logger.LogInfo(_serviceEndpoint.ServiceName + ": updateStatus");
|
||||
updateStatus();
|
||||
_lastUpdate = DateTime.Now;
|
||||
SignalPropertyChanged("TimeSinceLastUpdate");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// log exception
|
||||
_logger.LogError(_endpoint.Name + ": " + ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
_lastUpdateTimer.Change(_updatePeriod, _updatePeriod);
|
||||
_insideCallback = false;
|
||||
_logger.LogError(_serviceEndpoint.ServiceName + ": " + ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,21 +120,18 @@ namespace ServiceDashBored
|
||||
/// <returns>Status</returns>
|
||||
private void updateStatus()
|
||||
{
|
||||
lastUpdate = DateTime.MaxValue;
|
||||
var newStatus = _endpoint.GetStatus();
|
||||
if (Status != newStatus)
|
||||
Status newStatus = _serviceEndpoint.GetStatus();
|
||||
if (_status != newStatus)
|
||||
{
|
||||
Status = newStatus;
|
||||
StatusDescription = _endpoint.StatusDescription;
|
||||
StatusIcon = GetStatusIcon(Status);
|
||||
// NOTE: wait to signal the property changes until all of them have been updated
|
||||
_status = newStatus;
|
||||
_statusMessage = _serviceEndpoint.StatusDescription;
|
||||
_statusIcon = GetStatusIcon(_status);
|
||||
SignalPropertyChanged("Status");
|
||||
SignalPropertyChanged("StatusDescription");
|
||||
SignalPropertyChanged("StatusIcon");
|
||||
SignalPropertyChanged("StatusDescription");
|
||||
}
|
||||
lastUpdate = DateTime.Now;
|
||||
_lastUpdate = DateTime.Now;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Callback for the timer
|
||||
/// </summary>
|
||||
@@ -168,12 +150,10 @@ namespace ServiceDashBored
|
||||
/// </summary>
|
||||
/// <param name="status">The status.</param>
|
||||
/// <returns></returns>
|
||||
public static Icon GetStatusIcon(Status status)
|
||||
public static Icon GetStatusIcon(Status? status)
|
||||
{
|
||||
switch (status)
|
||||
{
|
||||
case Status.Unknown:
|
||||
return Resources.question;
|
||||
case Status.Up:
|
||||
return Resources.up;
|
||||
case Status.Error:
|
||||
@@ -195,16 +175,13 @@ namespace ServiceDashBored
|
||||
/// </summary>
|
||||
/// <param name="endpoint">The endpoint.</param>
|
||||
/// <param name="logger">The logger.</param>
|
||||
public EndpointStatus(IEndpoint endpoint, Logger logger)
|
||||
public EndpointStatus(IServiceEndpoint endpoint, Logger logger)
|
||||
{
|
||||
_endpoint = endpoint;
|
||||
lastUpdate = DateTime.MinValue;
|
||||
_serviceEndpoint = endpoint;
|
||||
_lastUpdate = DateTime.MinValue;
|
||||
_logger = logger;
|
||||
_updatePeriod = new TimeSpan(0, 0, 0, 1);
|
||||
_lastUpdateTimer = new Timer(timerCallback, 0, _updatePeriod, _updatePeriod);
|
||||
StatusIcon = GetStatusIcon(Status);
|
||||
Status = Status.Unknown;
|
||||
StatusDescription = string.Empty;
|
||||
_timer = new Timer(timerCallback, 0, _updatePeriod, _updatePeriod);
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -221,7 +198,7 @@ namespace ServiceDashBored
|
||||
#region PropertyChanged methods
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the property (<paramref name="propertyName"/>) has been updated or changed.
|
||||
/// Checks if the property (propertyName) has been updated or changed.
|
||||
/// </summary>
|
||||
/// <param name="propertyName">Name of the property.</param>
|
||||
/// <param name="oldValue">The old value.</param>
|
||||
@@ -234,7 +211,7 @@ namespace ServiceDashBored
|
||||
return false;
|
||||
}
|
||||
|
||||
if (oldValue == null || !oldValue.Equals(newValue))
|
||||
if ((oldValue == null) || !oldValue.Equals(newValue))
|
||||
{
|
||||
oldValue = newValue;
|
||||
|
||||
@@ -247,7 +224,7 @@ namespace ServiceDashBored
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the property (<paramref name="propertyName"/>) has been updated or changed.
|
||||
/// Checks if the property (propertyName) has been updated or changed.
|
||||
/// </summary>
|
||||
/// <param name="propertyName">Name of the property.</param>
|
||||
/// <param name="oldValue">The old value.</param>
|
||||
@@ -277,14 +254,11 @@ namespace ServiceDashBored
|
||||
return;
|
||||
try
|
||||
{
|
||||
lock (_propertyUpdateSyncObject) // send only one property changed event at once
|
||||
lock (_syncObject)
|
||||
{
|
||||
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
catch (InvalidOperationException) // HACK: Ignore the "BindingSource cannot be its own data source."
|
||||
{
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogWarning("SignalPropertyChanged: " + ex);
|
||||
@@ -301,7 +275,7 @@ namespace ServiceDashBored
|
||||
///<filterpriority>2</filterpriority>
|
||||
public void Dispose()
|
||||
{
|
||||
_lastUpdateTimer.Dispose();
|
||||
_timer.Dispose();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
Generated
+91
-120
@@ -37,41 +37,60 @@
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
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.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.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.statusTextBox = new System.Windows.Forms.RichTextBox();
|
||||
this.splitContainer = new System.Windows.Forms.SplitContainer();
|
||||
this.dataGridContextMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components);
|
||||
this.updateNowToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.trayContextMenuStrip.SuspendLayout();
|
||||
this.endpointBindingSource = new System.Windows.Forms.BindingSource(this.components);
|
||||
this.ServiceName = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.statusIconDataGridViewImageColumn = new System.Windows.Forms.DataGridViewImageColumn();
|
||||
this.StatusDescription = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.TimeSinceLastUpdate = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.contextMenuStrip.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.endpointBindingSource)).BeginInit();
|
||||
this.splitContainer.Panel1.SuspendLayout();
|
||||
this.splitContainer.Panel2.SuspendLayout();
|
||||
this.splitContainer.SuspendLayout();
|
||||
this.dataGridContextMenuStrip.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
|
||||
//
|
||||
this.notifyIcon.ContextMenuStrip = this.trayContextMenuStrip;
|
||||
this.notifyIcon.ContextMenuStrip = this.contextMenuStrip;
|
||||
this.notifyIcon.Text = "Service DashBored";
|
||||
this.notifyIcon.Visible = true;
|
||||
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.trayContextMenuStrip.Name = "trayContextMenuStrip";
|
||||
this.trayContextMenuStrip.Size = new System.Drawing.Size(104, 26);
|
||||
this.contextMenuStrip.Name = "contextMenuStrip";
|
||||
this.contextMenuStrip.Size = new System.Drawing.Size(104, 26);
|
||||
//
|
||||
// exitToolStripMenuItem
|
||||
//
|
||||
@@ -90,33 +109,52 @@
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
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.CellBorderStyle = System.Windows.Forms.DataGridViewCellBorderStyle.None;
|
||||
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.statusIconDataGridViewImageColumn,
|
||||
this.ServiceName,
|
||||
this.statusIconDataGridViewImageColumn,
|
||||
this.StatusDescription,
|
||||
this.TimeSinceLastUpdate});
|
||||
this.dataGridView.DataSource = this.endpointBindingSource;
|
||||
this.dataGridView.EditMode = System.Windows.Forms.DataGridViewEditMode.EditProgrammatically;
|
||||
this.dataGridView.EnableHeadersVisualStyles = false;
|
||||
this.dataGridView.Location = new System.Drawing.Point(12, 12);
|
||||
this.dataGridView.MultiSelect = false;
|
||||
this.dataGridView.Location = new System.Drawing.Point(12, 27);
|
||||
this.dataGridView.Name = "dataGridView";
|
||||
this.dataGridView.ReadOnly = true;
|
||||
this.dataGridView.RowHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.Single;
|
||||
this.dataGridView.RowHeadersVisible = false;
|
||||
this.dataGridView.RowHeadersWidthSizeMode = System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode.DisableResizing;
|
||||
this.dataGridView.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
|
||||
this.dataGridView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
|
||||
this.dataGridView.Size = new System.Drawing.Size(368, 126);
|
||||
this.dataGridView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.CellSelect;
|
||||
this.dataGridView.Size = new System.Drawing.Size(555, 156);
|
||||
this.dataGridView.TabIndex = 1;
|
||||
this.dataGridView.RowEnter += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_RowEnter);
|
||||
this.dataGridView.MouseUp += new System.Windows.Forms.MouseEventHandler(this.dataGridView_MouseUp);
|
||||
this.dataGridView.DataError += new System.Windows.Forms.DataGridViewDataErrorEventHandler(this.dataGridView_DataError);
|
||||
this.dataGridView.CellEnter += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_CellEnter);
|
||||
//
|
||||
// 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
|
||||
//
|
||||
@@ -129,14 +167,13 @@
|
||||
this.statusIconDataGridViewImageColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
|
||||
this.statusIconDataGridViewImageColumn.Width = 30;
|
||||
//
|
||||
// ServiceName
|
||||
// StatusDescription
|
||||
//
|
||||
this.ServiceName.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
|
||||
this.ServiceName.DataPropertyName = "ServiceName";
|
||||
this.ServiceName.HeaderText = "Service";
|
||||
this.ServiceName.MinimumWidth = 100;
|
||||
this.ServiceName.Name = "ServiceName";
|
||||
this.ServiceName.ReadOnly = true;
|
||||
this.StatusDescription.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
|
||||
this.StatusDescription.DataPropertyName = "StatusDescription";
|
||||
this.StatusDescription.HeaderText = "Status";
|
||||
this.StatusDescription.Name = "StatusDescription";
|
||||
this.StatusDescription.ReadOnly = true;
|
||||
//
|
||||
// TimeSinceLastUpdate
|
||||
//
|
||||
@@ -145,112 +182,46 @@
|
||||
this.TimeSinceLastUpdate.HeaderText = "Last Update";
|
||||
this.TimeSinceLastUpdate.Name = "TimeSinceLastUpdate";
|
||||
this.TimeSinceLastUpdate.ReadOnly = true;
|
||||
this.TimeSinceLastUpdate.Resizable = System.Windows.Forms.DataGridViewTriState.False;
|
||||
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
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(392, 270);
|
||||
this.Controls.Add(this.splitContainer);
|
||||
this.ClientSize = new System.Drawing.Size(579, 218);
|
||||
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.MainMenuStrip = this.menuStrip;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimumSize = new System.Drawing.Size(400, 300);
|
||||
this.MinimumSize = new System.Drawing.Size(587, 248);
|
||||
this.Name = "Main";
|
||||
this.Text = "Service DashBored";
|
||||
this.Load += new System.EventHandler(this.main_Load);
|
||||
this.Resize += new System.EventHandler(this.main_Resize);
|
||||
this.trayContextMenuStrip.ResumeLayout(false);
|
||||
this.Load += new System.EventHandler(this.Main_Load);
|
||||
this.contextMenuStrip.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).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.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#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.ContextMenuStrip trayContextMenuStrip;
|
||||
private System.Windows.Forms.ContextMenuStrip contextMenuStrip;
|
||||
private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem;
|
||||
private System.Windows.Forms.DataGridView dataGridView;
|
||||
private System.Windows.Forms.BindingSource endpointBindingSource;
|
||||
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.ContextMenuStrip dataGridContextMenuStrip;
|
||||
private System.Windows.Forms.ToolStripMenuItem updateNowToolStripMenuItem;
|
||||
private System.Windows.Forms.DataGridViewImageColumn statusIconDataGridViewImageColumn;
|
||||
private System.Windows.Forms.DataGridViewTextBoxColumn StatusDescription;
|
||||
private System.Windows.Forms.DataGridViewTextBoxColumn TimeSinceLastUpdate;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+173
-333
@@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Configuration;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
using BitFactory.Logging;
|
||||
@@ -9,100 +9,190 @@ using Endpoint;
|
||||
|
||||
namespace ServiceDashBored
|
||||
{
|
||||
/// <summary>
|
||||
/// DashBored's UI.
|
||||
/// </summary>
|
||||
public partial class Main : Form
|
||||
{
|
||||
/// <summary>
|
||||
/// Number of seconds between trying to poll an endpoint for its status
|
||||
/// </summary>
|
||||
private const int ENDPOINT_POLL_TIME_INTERVAL = 30;
|
||||
|
||||
/// <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;
|
||||
private Status _mainStatusIcon = Status.Timeout;
|
||||
private BindingList<EndpointStatus> _endpointStatus;
|
||||
private Dictionary<EndpointStatus, RegisteredWaitHandle> _endpointWaitHandle;
|
||||
private Logger _logger;
|
||||
private const string LOG_FILENAME = "ServiceDashBored.log";
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Main"/> class.
|
||||
/// </summary>
|
||||
public Main(IEnumerable<IEndpoint> endpoints, Logger logger)
|
||||
public Main()
|
||||
{
|
||||
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>();
|
||||
endpointBindingSource.DataSource = _endpoints;
|
||||
_endpointStatuses = new Dictionary<EndpointStatus, Status>();
|
||||
_endpointEventWaitHandle = new Dictionary<EndpointStatus, EventWaitHandle>();
|
||||
notifyIcon.Icon = EndpointStatus.GetStatusIcon(status);
|
||||
|
||||
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>
|
||||
/// Override to intercept WM_QUERYENDSESSION - so we know when the current OS session is ending.
|
||||
/// Concatenates each endpoint description into a single string
|
||||
/// </summary>
|
||||
/// <param name="m"></param>
|
||||
/// <remarks>http://www.pixvillage.com/blogs/devblog/archive/2005/03/26/174.aspx</remarks>
|
||||
protected override void WndProc(ref Message m)
|
||||
/// <param name="endpointStatuses">The endpoint statuses.</param>
|
||||
/// <returns></returns>
|
||||
private static string getEndpointString(List<EndpointStatus> endpointStatuses)
|
||||
{
|
||||
if (m.Msg == WM_QUERYENDSESSION)
|
||||
_endSessionPending = true;
|
||||
base.WndProc(ref m);
|
||||
string result = string.Empty;
|
||||
endpointStatuses.ForEach(delegate(EndpointStatus endpointStatus)
|
||||
{
|
||||
result += endpointStatus.ServiceName + Environment.NewLine;
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -111,51 +201,14 @@ namespace ServiceDashBored
|
||||
/// <param name="e"></param>
|
||||
protected override void OnClosing(CancelEventArgs e)
|
||||
{
|
||||
if (!_endSessionPending)
|
||||
if (!Environment.HasShutdownStarted)
|
||||
{
|
||||
e.Cancel = true;
|
||||
WindowState = FormWindowState.Minimized; // minimize instead of close
|
||||
WindowState = FormWindowState.Minimized;
|
||||
}
|
||||
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>
|
||||
/// Handles the BalloonTipClicked event of the notifyIcon control.
|
||||
/// </summary>
|
||||
@@ -176,7 +229,6 @@ namespace ServiceDashBored
|
||||
/// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
|
||||
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
_logger.LogInfo("User Exiting.");
|
||||
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;
|
||||
cellTextBox.Text = string.Format("{0}. Status Description: {1}",
|
||||
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)
|
||||
DataGridViewColumn column = dataGridView.Columns[e.ColumnIndex];
|
||||
if (column.ValueType == typeof(string))
|
||||
{
|
||||
// if the status hasn't changed, don't do anything...
|
||||
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));
|
||||
}
|
||||
cellTextBox.Text = (string)dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <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)
|
||||
else
|
||||
{
|
||||
if (endpointStatus.Status == Status.Up || endpointStatus.Status == Status.Unknown)
|
||||
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);
|
||||
cellTextBox.Text = string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,20 +117,26 @@
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="notifyIcon.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">
|
||||
<metadata name="menuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</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">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="endpointBindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>245, 17</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>
|
||||
<value>349, 10</value>
|
||||
</metadata>
|
||||
<metadata name="$this.TrayLargeIcon" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using BitFactory.Logging;
|
||||
using Castle.Core.Resource;
|
||||
using Castle.Windsor;
|
||||
using Castle.Windsor.Configuration.Interpreters;
|
||||
|
||||
namespace ServiceDashBored
|
||||
{
|
||||
@@ -15,28 +11,9 @@ namespace ServiceDashBored
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
IWindsorContainer container =
|
||||
new WindsorContainer(
|
||||
new XmlInterpreter(new ConfigResource("castle")));
|
||||
|
||||
// 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);
|
||||
}
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
Application.Run(new Main());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+19
-4
@@ -1,7 +1,7 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 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
|
||||
// the code is regenerated.
|
||||
@@ -19,7 +19,7 @@ namespace ServiceDashBored.Properties {
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// 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.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
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 {
|
||||
get {
|
||||
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 {
|
||||
object obj = ResourceManager.GetObject("question", resourceCulture);
|
||||
object obj = ResourceManager.GetObject("help", resourceCulture);
|
||||
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 {
|
||||
get {
|
||||
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 {
|
||||
get {
|
||||
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 {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("warning", resourceCulture);
|
||||
|
||||
@@ -121,8 +121,8 @@
|
||||
<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>
|
||||
</data>
|
||||
<data name="question" 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>
|
||||
<data name="help" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\help.ico;System.Drawing.Icon, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<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>
|
||||
|
||||
+37
@@ -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 |
@@ -1,5 +1,5 @@
|
||||
<?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>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
@@ -14,23 +14,9 @@
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<FileUpgradeFlags>
|
||||
</FileUpgradeFlags>
|
||||
<UpgradeBackupLocation>
|
||||
</UpgradeBackupLocation>
|
||||
<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 Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
@@ -40,7 +26,6 @@
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
@@ -49,29 +34,12 @@
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="BitFactory.Logging, Version=1.4.1.0, Culture=neutral, PublicKeyToken=de68848483a294a9, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>References\BitFactory.Logging.dll</HintPath>
|
||||
</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.configuration" />
|
||||
<Reference Include="System.Data" />
|
||||
@@ -108,11 +76,21 @@
|
||||
</Compile>
|
||||
<None Include="app.config" />
|
||||
<None Include="Resources\up.ico" />
|
||||
<None Include="Resources\question.ico" />
|
||||
<None Include="Resources\help.ico" />
|
||||
<None Include="Resources\remove.ico" />
|
||||
<None Include="Resources\accept.ico" />
|
||||
<None Include="Resources\warning.ico" />
|
||||
<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>
|
||||
<ProjectReference Include="..\Endpoint\Endpoint.csproj">
|
||||
@@ -120,23 +98,6 @@
|
||||
<Name>Endpoint</Name>
|
||||
</ProjectReference>
|
||||
</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" />
|
||||
<!-- 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.
|
||||
|
||||
@@ -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
@@ -1,157 +1,31 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<configSections>
|
||||
<section name="castle" type="Castle.Windsor.Configuration.AppDomain.CastleSectionHandler, Castle.Windsor" />
|
||||
</configSections>
|
||||
<castle>
|
||||
<components>
|
||||
<component id="form.component" type="ServiceDashBored.Main, ServiceDashBored">
|
||||
<parameters>
|
||||
<endpoints>
|
||||
<array>
|
||||
<item>${google.endpoint}</item>
|
||||
<item>${10.21.63.6.endpoint}</item>
|
||||
<item>${localhost.freespace.endpoint}</item>
|
||||
</array>
|
||||
</endpoints>
|
||||
</parameters>
|
||||
</component>
|
||||
|
||||
<component id="logger.component" service="BitFactory.Logging.Logger, BitFactory.Logging" type="BitFactory.Logging.FileLogger, BitFactory.Logging">
|
||||
<parameters>
|
||||
<aFileName>ServiceDashBored.log</aFileName>
|
||||
</parameters>
|
||||
</component>
|
||||
|
||||
<component id="kpcodl06.endpoint" service="Endpoint.IEndpoint, Endpoint" type="Endpoint.HttpEndpoint, Endpoint">
|
||||
<parameters>
|
||||
<Name>kpcodl06:8080 (paypal)</Name>
|
||||
<UriString>http://kpcodl06:8080/paypal_server/PayPalService</UriString>
|
||||
</parameters>
|
||||
</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>
|
||||
<section name="httpEndpointSection" type="Endpoint.HttpEndpointConfigurationSection, Endpoint"/>
|
||||
<section name="htmlEndpointSection" type="Endpoint.HtmlEndpointConfigurationSection, Endpoint"/>
|
||||
<section name="oracleEndpointSection" type="Endpoint.OracleEndpointConfigurationSection, Endpoint"/>
|
||||
<section name="soapEndpointSection" type="Endpoint.SoapEndpointConfigurationSection, Endpoint"/>
|
||||
</configSections>
|
||||
<httpEndpointSection>
|
||||
<endpoints>
|
||||
<add name="kpcoql06 (paypal)" uri="http://kpcodl06:8080/paypal_server/PayPalService" />
|
||||
<add name="google2" uri="http://www.google.com" />
|
||||
</endpoints>
|
||||
</httpEndpointSection>
|
||||
<htmlEndpointSection>
|
||||
<endpoints>
|
||||
<!--<add name="kpapdl26 (payment)" uri="http://kpapdl26:8080/core_server/paymentservice" xpathQuery="//td[text()="PaymentService"]/following-sibling::td/text()" expectedXpathResult="ACTIVE" />-->
|
||||
</endpoints>
|
||||
</htmlEndpointSection>
|
||||
<oracleEndpointSection>
|
||||
<endpoints>
|
||||
<!--<add name="x5_int" connectionString="Data Source=x5_int01.jewelry.dev;User ID=webcontent;Password=acnwebcontent;"
|
||||
scalarQueryString="select 1 from dual" expectedQueryResult="1" />-->
|
||||
</endpoints>
|
||||
</oracleEndpointSection>
|
||||
<soapEndpointSection>
|
||||
<endpoints>
|
||||
<add name="kpapdl26 (key)" uri="http://kpapdl26:8080/core_server/paymentservice" xpathQuery="//jtv:provider/text()" xpathNamespaces="jtv,http://jtv.com" expectedXpathResult="NoDecision" soapAction=""urn:getPaymentKey"" soapRequest="<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>" />
|
||||
</endpoints>
|
||||
</soapEndpointSection>
|
||||
</configuration>
|
||||
Reference in New Issue
Block a user