|
//*****************************************************************************
// Description.....Routing Manager
//
// Author..........Roman Kiss, rkiss@pathcom.com
// Copyright © 2005 ATZ Consulting Inc.
//
// Date Created: 03/03/10
//
// Date Modified By Description
//-----------------------------------------------------------------------------
// 03/03/10 Roman Kiss Initial Revision
//
//*****************************************************************************
//
#region Namespaces
using System;
using System.Diagnostics;
using System.ServiceModel;
using System.ServiceModel.Description;
#endregion
namespace LocalRepository
{
[ServiceContract(Namespace = "urn:rkiss/2010/09/ms/core/routing", SessionMode = SessionMode.Allowed)]
public interface IRoutingManager
{
[OperationContract(IsOneWay = true)]
void Refresh(string machineName, string applicationName);
[OperationContract]
void Set(string machineName, string applicationName, RoutingMetadata metadata);
[OperationContract]
void Reset(string machineName, string applicationName);
[OperationContract]
string GetStatus(string machineName, string applicationName);
}
public class Proxy
{
public static void Refresh(string address, string machineName, string applicationName)
{
ChannelFactory<IRoutingManager> factory = null;
try
{
ServiceEndpoint se = new ServiceEndpoint(ContractDescription.GetContract(typeof(IRoutingManager)), new BasicHttpBinding(BasicHttpSecurityMode.None), new EndpointAddress(address));
factory = new ChannelFactory<IRoutingManager>(se);
IRoutingManager channel = factory.CreateChannel();
channel.Refresh(machineName, applicationName);
((IClientChannel)channel).Close();
factory.Close();
}
catch (Exception ex)
{
Trace.WriteLine(string.Format("[{0}] Refresh failed to delivery, error = {1}", applicationName, ex.Message));
if (factory != null)
{
if (factory.State == CommunicationState.Faulted)
factory.Abort();
else
factory.Close();
factory = null;
}
throw ex;
}
}
public static void Set(string address, string machineName, string applicationName, RoutingMetadata metadata)
{
ChannelFactory<IRoutingManager> factory = null;
try
{
ServiceEndpoint se = new ServiceEndpoint(ContractDescription.GetContract(typeof(IRoutingManager)), new BasicHttpBinding(BasicHttpSecurityMode.None), new EndpointAddress(address));
factory = new ChannelFactory<IRoutingManager>(se);
IRoutingManager channel = factory.CreateChannel();
channel.Set(machineName, applicationName, metadata);
((IClientChannel)channel).Close();
factory.Close();
}
catch (Exception ex)
{
Trace.WriteLine(string.Format("[{0}] Set failed to delivery, error = {1}", applicationName, ex.Message));
if (factory != null)
{
if (factory.State == CommunicationState.Faulted)
factory.Abort();
else
factory.Close();
factory = null;
}
throw ex;
}
}
public static string GetStatus(string address, string machineName, string applicationName)
{
ChannelFactory<IRoutingManager> factory = null;
try
{
ServiceEndpoint se = new ServiceEndpoint(ContractDescription.GetContract(typeof(IRoutingManager)), new BasicHttpBinding(BasicHttpSecurityMode.None), new EndpointAddress(address));
factory = new ChannelFactory<IRoutingManager>(se);
IRoutingManager channel = factory.CreateChannel();
string retVal = channel.GetStatus(machineName, applicationName);
((IClientChannel)channel).Close();
factory.Close();
return retVal;
}
catch (Exception ex)
{
Trace.WriteLine(string.Format("[{0}] GetStatus failed to delivery, error = {1}", applicationName, ex.Message));
if (factory != null)
{
if (factory.State == CommunicationState.Faulted)
factory.Abort();
else
factory.Close();
factory = null;
}
throw ex;
}
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.