本文整理汇总了C#中System.ServiceModel.OperationContextScope类的典型用法代码示例。如果您正苦于以下问题:C# OperationContextScope类的具体用法?C# OperationContextScope怎么用?C# OperationContextScope使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
OperationContextScope类属于System.ServiceModel命名空间,在下文中一共展示了OperationContextScope类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: InvokeWithSameProxy
static void InvokeWithSameProxy()
{
ChannelFactory<IAdd> factory=new ChannelFactory<IAdd>("AddService");
IAdd proxy = factory.CreateChannel();
if (null != proxy as ICommunicationObject)
{
(proxy as ICommunicationObject).Open();
}
var datatime = DateTime.Now;
Console.WriteLine(datatime);
int num = 100;
for (int i = 0; i < num; i++)
{
ThreadPool.QueueUserWorkItem(delegate
{
int clientId = Interlocked.Increment(ref index);
using (
OperationContextScope contextScope =
new OperationContextScope(proxy as IContextChannel))
{
Console.WriteLine(i);
MessageHeader<int> header = new MessageHeader<int>(clientId);
System.ServiceModel.Channels.MessageHeader messageHeader =
header.GetUntypedHeader(MessageWrapper.headerClientId,
MessageWrapper.headerNamespace);
OperationContext.Current.OutgoingMessageHeaders.Add(messageHeader);
proxy.Add(1, 2);
if (i == num-1) {
Console.WriteLine((DateTime.Now - datatime).Seconds);
}
}
});
}
}
开发者ID:tengwei,项目名称:TwApplication,代码行数:35,代码来源:Program.cs
示例2: Main
static void Main(string[] args)
{
try
{
var aqAquisitionServiceClient = new AQAcquisitionServiceClient("BasicHttpBinding_IAQAcquisitionService", "http://sooke/AQUARIUS/AqAcquisitionService.svc/Basic");
//var aqAquisitionServiceClient = new AQAcquisitionServiceClient("WSHttpBinding_IAQAcquisitionService", "http://sooke/AQUARIUS/AqAcquisitionService.svc");
var authToken = aqAquisitionServiceClient.GetAuthToken("admin", "admin");
Console.WriteLine("Token: " + authToken);
using (var contextScope = new OperationContextScope(aqAquisitionServiceClient.InnerChannel))
{
var runtimeHeader = MessageHeader.CreateHeader("AQAuthToken", "", authToken, false);
OperationContext.Current.OutgoingMessageHeaders.Add(runtimeHeader);
var allLocations = aqAquisitionServiceClient.GetAllLocations();
Console.WriteLine("There are " + allLocations.Length + " Locations:");
foreach (var location in allLocations)
{
Console.WriteLine("\t" + location.Identifier);
}
}
}
catch(Exception ex)
{
Console.WriteLine("Error occurred: " + ex.ToString());
}
Console.WriteLine("Enter to quit...");
Console.ReadLine();
}
开发者ID:AlanLiu-AI,项目名称:AqDemos,代码行数:28,代码来源:Program.cs
示例3: GetOSVersionsProcess
public OperatingSystemList GetOSVersionsProcess(out Operation operation)
{
Func<string, OperatingSystemList> func = null;
OperatingSystemList operatingSystemList = null;
operation = null;
using (OperationContextScope operationContextScope = new OperationContextScope((IContextChannel)base.Channel))
{
try
{
GetAzureOSVersionCommand getAzureOSVersionCommand = this;
if (func == null)
{
func = (string s) => base.Channel.ListOperatingSystems(s);
}
operatingSystemList = ((CmdletBase<IServiceManagement>)getAzureOSVersionCommand).RetryCall<OperatingSystemList>(func);
operation = base.WaitForOperation(base.CommandRuntime.ToString());
}
catch (CommunicationException communicationException1)
{
CommunicationException communicationException = communicationException1;
this.WriteErrorDetails(communicationException);
}
}
return operatingSystemList;
}
开发者ID:nickchal,项目名称:pash,代码行数:25,代码来源:GetAzureOSVersionCommand.cs
示例4: OperationContextScope
public OperationContextScope(IContextChannel channel)
{
this.originalContext = OperationContext.Current;
this.originalScope = currentScope;
this.thread = Thread.CurrentThread;
this.PushContext(new OperationContext(channel));
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:7,代码来源:OperationContextScope.cs
示例5: AddCertificateProcess
internal void AddCertificateProcess()
{
Action<string> action = null;
this.ValidateParameters();
byte[] certificateData = this.GetCertificateData();
CertificateFile certificateFile = new CertificateFile();
certificateFile.Data = Convert.ToBase64String(certificateData);
certificateFile.Password = this.Password;
certificateFile.CertificateFormat = "pfx";
CertificateFile certificateFile1 = certificateFile;
using (OperationContextScope operationContextScope = new OperationContextScope((IContextChannel)base.Channel))
{
try
{
AddAzureCertificateCommand addAzureCertificateCommand = this;
if (action == null)
{
action = (string s) => base.Channel.AddCertificates(s, this.ServiceName, certificateFile1);
}
((CmdletBase<IServiceManagement>)addAzureCertificateCommand).RetryCall(action);
Operation operation = base.WaitForOperation(base.CommandRuntime.ToString());
ManagementOperationContext managementOperationContext = new ManagementOperationContext();
managementOperationContext.set_OperationDescription(base.CommandRuntime.ToString());
managementOperationContext.set_OperationId(operation.OperationTrackingId);
managementOperationContext.set_OperationStatus(operation.Status);
ManagementOperationContext managementOperationContext1 = managementOperationContext;
base.WriteObject(managementOperationContext1, true);
}
catch (CommunicationException communicationException1)
{
CommunicationException communicationException = communicationException1;
this.WriteErrorDetails(communicationException);
}
}
}
开发者ID:nickchal,项目名称:pash,代码行数:35,代码来源:AddAzureCertificateCommand.cs
示例6: ResampleImageVolume
/// <summary>
/// one-way call to resample an image volume
/// </summary>
/// <param name="seriesInstanceUID"></param>
public void ResampleImageVolume(ImageVolumeResampleRequest request)
{
_responseContext =
OperationContext.Current.IncomingMessageHeaders.GetHeader<ResponseContext>(
"ResponseContext", "ServiceModelEx");
_responseAddress =
new EndpointAddress(_responseContext.ResponseAddress);
ResampleEngineClient re = new ResampleEngineClient();
ImageVolumeResampleResponse response = re.ResampleImageVolume(request);
System.Diagnostics.Trace.Assert(response.ResampledImageVolumeGuid.CompareTo(Guid.Empty) != 0);
MessageHeader<ResponseContext> responseHeader = new MessageHeader<ResponseContext>(_responseContext);
NetMsmqBinding binding = new NetMsmqBinding("NoMsmqSecurity");
ResampleResponseProxy proxy = new ResampleResponseProxy(binding, _responseAddress);
using (OperationContextScope scope = new OperationContextScope(proxy.InnerChannel))
{
OperationContext.Current.OutgoingMessageHeaders.Add(
responseHeader.GetUntypedHeader("ResponseContext", "ServiceModelEx"));
proxy.OnResampleDone(response);
}
proxy.Close();
}
开发者ID:dg1an3,项目名称:PheonixRt.Mvvm,代码行数:31,代码来源:ResampleManager.cs
示例7: Main
static void Main(string[] args)
{
var factory = new ChannelFactory<IFantasyService>("*");
factory.Credentials.UserName.UserName = "scott";
factory.Credentials.UserName.Password = "sas0927";
factory.Endpoint.Behaviors.Add(new CustomHeaderEndpointBehavior());
var proxy = factory.CreateChannel();
MessageHeader header = MessageHeader.CreateHeader("userId", "http://www.identitystream.com", "Custom Header");
using (OperationContextScope scope = new OperationContextScope((IContextChannel)proxy))
{
OperationContext.Current.OutgoingMessageHeaders.Add(header);
//HttpRequestMessageProperty httpRequestProperty = new HttpRequestMessageProperty();
//httpRequestProperty.Headers.Add("myCustomHeader", "Custom Happy Value.");
//httpRequestProperty.Headers.Add(HttpRequestHeader.UserAgent, "my user agent");
//OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] = httpRequestProperty;
}
IList<string> leagueNames = proxy.GetLeagueNames();
Console.WriteLine(string.Format("{0} league names returned.", leagueNames.Count));
int teamWins = proxy.GetTeamWins(1);
Console.WriteLine(string.Format("{0} team wins for team 1.", teamWins));
Console.ReadLine();
}
开发者ID:ssickles,项目名称:archive,代码行数:25,代码来源:Program.cs
示例8: SetAffinityGroupProcess
public void SetAffinityGroupProcess()
{
this.ValidateParameters();
using (OperationContextScope operationContextScope = new OperationContextScope((IContextChannel)base.Channel))
{
try
{
UpdateAffinityGroupInput updateAffinityGroupInput = new UpdateAffinityGroupInput();
updateAffinityGroupInput.Label = ServiceManagementHelper.EncodeToBase64String(this.Label);
UpdateAffinityGroupInput description = updateAffinityGroupInput;
if (this.Description != null)
{
description.Description = this.Description;
}
CmdletExtensions.WriteVerboseOutputForObject(this, description);
base.RetryCall((string s) => base.Channel.UpdateAffinityGroup(s, this.Name, description));
Operation operation = base.WaitForOperation(base.CommandRuntime.ToString());
ManagementOperationContext managementOperationContext = new ManagementOperationContext();
managementOperationContext.set_OperationDescription(base.CommandRuntime.ToString());
managementOperationContext.set_OperationId(operation.OperationTrackingId);
managementOperationContext.set_OperationStatus(operation.Status);
ManagementOperationContext managementOperationContext1 = managementOperationContext;
base.WriteObject(managementOperationContext1, true);
}
catch (CommunicationException communicationException1)
{
CommunicationException communicationException = communicationException1;
this.WriteErrorDetails(communicationException);
}
}
}
开发者ID:nickchal,项目名称:pash,代码行数:31,代码来源:SetAzureAffinityGroupCommand.cs
示例9: ReConnection
/// <summary>
/// 重新连接wcf服务
/// </summary>
/// <param name="mainfrm"></param>
public static void ReConnection()
{
try
{
NetTcpBinding binding = new NetTcpBinding("NetTcpBinding_WCFHandlerService");
//binding.OpenTimeout = TimeSpan.FromSeconds(10);
//binding.TransferMode = TransferMode.Buffered;
DuplexChannelFactory<IWCFHandlerService> mChannelFactory = new DuplexChannelFactory<IWCFHandlerService>(AppGlobal.cache.GetData("ClientService") as IClientService, binding, System.Configuration.ConfigurationSettings.AppSettings["WCF_endpoint"]);
IWCFHandlerService wcfHandlerService = mChannelFactory.CreateChannel();
using (var scope = new OperationContextScope(wcfHandlerService as IContextChannel))
{
var router = System.ServiceModel.Channels.MessageHeader.CreateHeader("routerID", myNamespace, AppGlobal.cache.GetData("routerID").ToString());
OperationContext.Current.OutgoingMessageHeaders.Add(router);
wcfHandlerService.Heartbeat(AppGlobal.cache.GetData("WCFClientID").ToString());
}
if (AppGlobal.cache.Contains("WCFService")) AppGlobal.cache.Remove("WCFService");
AppGlobal.cache.Add("WCFService", wcfHandlerService);
}
catch (Exception err)
{
throw new Exception(err.Message);
}
}
开发者ID:keep01,项目名称:efwplus_winformframe,代码行数:29,代码来源:WcfClientManage.cs
示例10: ProcessRequest
public void ProcessRequest(HttpContext context)
{
try
{
// Local Variables.
string uRequestID = String.Empty;
string uStatus = String.Empty;
String SOAPEndPoint = context.Session["SOAPEndPoint"].ToString();
String internalOauthToken = context.Session["internalOauthToken"].ToString();
String id = context.Request.QueryString["id"].ToString().Trim();
String status = context.Request.QueryString["status"].ToString().Trim();
// Create the SOAP binding for call.
BasicHttpBinding binding = new BasicHttpBinding();
binding.Name = "UserNameSoapBinding";
binding.Security.Mode = BasicHttpSecurityMode.TransportWithMessageCredential;
binding.MaxReceivedMessageSize = 2147483647;
var client = new SoapClient(binding, new EndpointAddress(new Uri(SOAPEndPoint)));
client.ClientCredentials.UserName.UserName = "*";
client.ClientCredentials.UserName.Password = "*";
using (var scope = new OperationContextScope(client.InnerChannel))
{
// Add oAuth token to SOAP header.
XNamespace ns = "http://exacttarget.com";
var oauthElement = new XElement(ns + "oAuthToken", internalOauthToken);
var xmlHeader = MessageHeader.CreateHeader("oAuth", "http://exacttarget.com", oauthElement);
OperationContext.Current.OutgoingMessageHeaders.Add(xmlHeader);
// Setup Subscriber Object to pass fields for updating.
Subscriber sub = new Subscriber();
sub.ID = int.Parse(id);
sub.IDSpecified = true;
if (status.ToLower() == "unsubscribed")
sub.Status = SubscriberStatus.Unsubscribed;
else
sub.Status = SubscriberStatus.Active;
sub.StatusSpecified = true;
// Call the Update method on the Subscriber object.
UpdateResult[] uResults = client.Update(new UpdateOptions(), new APIObject[] { sub }, out uRequestID, out uStatus);
if (uResults != null && uStatus.ToLower().Equals("ok"))
{
String strResults = string.Empty;
strResults += uResults;
// Return the update results from handler.
context.Response.Write(strResults);
}
else
{
context.Response.Write("Not OK!");
}
}
}
catch (Exception ex)
{
context.Response.Write(ex);
}
}
开发者ID:haithemaraissia,项目名称:SubscriberSearch-net,代码行数:60,代码来源:SubscriberUpdate.ashx.cs
示例11: Main
static void Main(string[] args)
{
using (ChannelFactory<IMessage> channelFactory = new ChannelFactory<IMessage>("messageservice"))
{
IMessage proxy = channelFactory.CreateChannel();
using (OperationContextScope contextScope = new OperationContextScope(proxy as IContextChannel))
{
MessageHeader<CultureInfo> header = new MessageHeader<CultureInfo>(Thread.CurrentThread.CurrentUICulture);
OperationContext.Current.OutgoingMessageHeaders.Add(header.GetUntypedHeader(CultureInfoHeadLocalName, CultureInfoHeaderNamespace));
Console.WriteLine("The UI culture of current thread is {0}", Thread.CurrentThread.CurrentUICulture);
Console.WriteLine(proxy.GetMessage());
}
Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US");
using (OperationContextScope contextScope = new OperationContextScope(proxy as IContextChannel))
{
MessageHeader<CultureInfo> header = new MessageHeader<CultureInfo>(Thread.CurrentThread.CurrentUICulture);
OperationContext.Current.OutgoingMessageHeaders.Add(header.GetUntypedHeader(CultureInfoHeadLocalName, CultureInfoHeaderNamespace));
Console.WriteLine("The UI culture of current thread is {0}", Thread.CurrentThread.CurrentUICulture);
Console.WriteLine(proxy.GetMessage());
}
}
Console.Read();
}
开发者ID:Kelvin-Lei,项目名称:WCFService_Demo,代码行数:25,代码来源:Program.cs
示例12: MainPageLoaded
void MainPageLoaded(object sender, RoutedEventArgs e)
{
// Simple Version
var basicHttpBinding = new BasicHttpBinding();
var endpointAddress = new EndpointAddress("http://localhost:50738/UserGroupEvent.svc");
var userGroupEventService = new ChannelFactory<IAsyncUserGroupEventService>(basicHttpBinding, endpointAddress).CreateChannel();
AsyncCallback asyncCallBack = delegate(IAsyncResult result)
{
var response = ((IAsyncUserGroupEventService)result.AsyncState).EndGetUserGroupEvent(result);
Dispatcher.BeginInvoke(() => SetUserGroupEventData(response));
};
userGroupEventService.BeginGetUserGroupEvent("123", asyncCallBack, userGroupEventService);
// Deluxe Variante mit eigenem Proxy
var channel = new UserGroupEventServiceProxy("BasicHttpBinding_IAsyncUserGroupEventService").Channel;
channel.BeginGetUserGroupEvent("123", ProcessResult, channel);
// Variante mit Faulthandler
using (var scope = new OperationContextScope((IContextChannel)channel))
{
var messageHeadersElement = OperationContext.Current.OutgoingMessageHeaders;
messageHeadersElement.Add(MessageHeader.CreateHeader("DoesNotHandleFault", "", true));
channel.BeginGetUserGroupEventWithFault("123", ProcessResultWithFault, channel);
}
}
开发者ID:sven-s,项目名称:SilverlightErfahrungsbericht,代码行数:26,代码来源:MainPage.xaml.cs
示例13: GetResponse
private void GetResponse(ICollection<IPointToLaceProvider> response)
{
var webService = new ConfigureIvidTitleHolder();
using (var scope = new OperationContextScope(webService.Client.InnerChannel))
{
OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] =
webService.RequestMessageProperty;
var request =
HandleRequest.GetTitleholderQueryRequest(response,_dataProvider.GetRequest<IAmIvidTitleholderRequest>());
_logCommand.LogConfiguration(new {request}, null);
_logCommand.LogRequest(new ConnectionTypeIdentifier(webService.Client.Endpoint.Address.ToString()).ForWebApiType(), new { request }, _dataProvider.BillablleState.NoRecordState);
_response = webService
.Client
.TitleholderQuery(request);
webService.Close();
_logCommand.LogResponse(_response == null ? DataProviderResponseState.NoRecords : DataProviderResponseState.Successful,
new ConnectionTypeIdentifier(webService.Client.Endpoint.Address.ToString())
.ForWebApiType(), _response ?? new TitleholderQueryResponse(), _dataProvider.BillablleState.NoRecordState);
if (_response == null)
_logCommand.LogFault(new {_dataProvider}, new {NoRequestReceived = "No response received from Ivid Title Holder Data Provider"});
}
}
开发者ID:rjonker1,项目名称:lightstone-data-platform,代码行数:29,代码来源:CallIvidTitleHolderDataProvider.cs
示例14: RemoveDeploymentProcess
public void RemoveDeploymentProcess()
{
Action<string> action = null;
using (OperationContextScope operationContextScope = new OperationContextScope((IContextChannel)base.Channel))
{
try
{
RemoveAzureDeploymentCommand removeAzureDeploymentCommand = this;
if (action == null)
{
action = (string s) => base.Channel.DeleteDeploymentBySlot(s, this.ServiceName, this.Slot);
}
((CmdletBase<IServiceManagement>)removeAzureDeploymentCommand).RetryCall(action);
Operation operation = base.WaitForOperation(base.CommandRuntime.ToString());
ManagementOperationContext managementOperationContext = new ManagementOperationContext();
managementOperationContext.set_OperationDescription(base.CommandRuntime.ToString());
managementOperationContext.set_OperationId(operation.OperationTrackingId);
managementOperationContext.set_OperationStatus(operation.Status);
ManagementOperationContext managementOperationContext1 = managementOperationContext;
base.WriteObject(managementOperationContext1, true);
}
catch (CommunicationException communicationException1)
{
CommunicationException communicationException = communicationException1;
this.WriteErrorDetails(communicationException);
}
}
}
开发者ID:nickchal,项目名称:pash,代码行数:28,代码来源:RemoveAzureDeploymentCommand.cs
示例15: Main
static void Main(string[] args)
{
Order order1 = new Order(Guid.NewGuid(), DateTime.Today.AddDays(5), Guid.NewGuid(), "Supplier A");
Order order2 = new Order(Guid.NewGuid(), DateTime.Today.AddDays(-5), Guid.NewGuid(), "Supplier A");
string path = ConfigurationManager.AppSettings["msmqPath"];
var address = new Uri(path);
OrderResponseContext context = new OrderResponseContext();
context.ResponseAddress = address;
var channelFactory = new ChannelFactory<IOrderProcesser>("defaultEndpoint");
var orderProcessor = channelFactory.CreateChannel();
using (var contextScope = new OperationContextScope(orderProcessor as IContextChannel)) {
Console.WriteLine("Submit the order of order No.: {0}", order1.OrderNo);
OrderResponseContext.Current = context;
orderProcessor.Submit(order1);
}
using (OperationContextScope contextScope = new OperationContextScope(orderProcessor as IContextChannel)) {
Console.WriteLine("Submit the order of order No.: {0}", order2.OrderNo);
OrderResponseContext.Current = context;
orderProcessor.Submit(order2);
}
Console.Read();
}
开发者ID:0811112150,项目名称:HappyDayHistory,代码行数:26,代码来源:Program.cs
示例16: Submit
public void Submit(Order order)
{
Console.WriteLine("Begin to process the order of the order No.: {0}", order.OrderNo);
FaultException exception = null;
if (order.OrderDate < DateTime.Now) {
exception = new FaultException(new FaultReason("The order has expried"), new FaultCode("sender"));
Console.WriteLine("It's fail to process the order.\n\tOrder No.: {0}\n\tReason:{1}", order.OrderNo, "The order has expried");
} else {
Console.WriteLine("It's successful to process the order.\n\tOrder No.: {0}", order.OrderNo);
}
NetMsmqBinding binding = new NetMsmqBinding();
binding.ExactlyOnce = false;
binding.Security.Transport.MsmqAuthenticationMode = MsmqAuthenticationMode.None;
binding.Security.Transport.MsmqProtectionLevel = ProtectionLevel.None;
ChannelFactory<IOrderRessponse> channelFactory = new ChannelFactory<IOrderRessponse>(binding);
OrderResponseContext responseContext = OrderResponseContext.Current;
IOrderRessponse channel = channelFactory.CreateChannel(new EndpointAddress(responseContext.ResponseAddress));
using (OperationContextScope contextScope = new OperationContextScope(channel as IContextChannel)) {
channel.SubmitOrderResponse(order.OrderNo, exception);
}
Console.Read();
}
开发者ID:0811112150,项目名称:HappyDayHistory,代码行数:25,代码来源:OrderProcessorService.cs
示例17: CallSimpleCustomHeaderService
private static void CallSimpleCustomHeaderService()
{
using (var client = new SimpleCustomHeaderServiceClient())
{
using (var scope = new OperationContextScope(client.InnerChannel))
{
//Log the user who's web session resulted in this service call
var webUser = new MessageHeader<string>("joe.bloggs");
var webUserHeader = webUser.GetUntypedHeader("web-user", "ns");
//Log which webnode we were on behind the load balancer
var webNodeId = new MessageHeader<int>(1234);
var webNodeIdHeader = webNodeId.GetUntypedHeader("web-node-id", "ns");
//Log a unique session id
var webSessionId = new MessageHeader<Guid>(Guid.NewGuid());
var webSessionIdHeader = webSessionId.GetUntypedHeader("web-session-id", "ns");
OperationContext.Current.OutgoingMessageHeaders.Add(webUserHeader);
OperationContext.Current.OutgoingMessageHeaders.Add(webNodeIdHeader);
OperationContext.Current.OutgoingMessageHeaders.Add(webSessionIdHeader);
System.Console.WriteLine(client.DoWork());
}
}
}
开发者ID:eoincampbell,项目名称:wcf-custom-headers-demo,代码行数:26,代码来源:Program.cs
示例18: MonitorForm_Load
//其他成员
private void MonitorForm_Load(object sender, EventArgs e)
{
string header = string.Format("{0, -13}{1, -22}{2}", "Client", "Time", "Event");
this.listBoxExecutionProgress.Items.Add(header);
_syncContext = SynchronizationContext.Current;
_callbackInstance = new InstanceContext(new CalculatorCallbackService());
_channelFactory = new DuplexChannelFactory<ICalculator>(_callbackInstance, "calculatorservice");
EventMonitor.MonitoringNotificationSended += ReceiveMonitoringNotification;
this.Disposed += delegate
{
EventMonitor.MonitoringNotificationSended -= ReceiveMonitoringNotification;
_channelFactory.Close();
};
for (int i = 0; i < 2; i++)
{
ThreadPool.QueueUserWorkItem(state =>
{
int clientId = Interlocked.Increment(ref _clientId);
EventMonitor.Send(clientId, EventType.StartCall);
ICalculator proxy = _channelFactory.CreateChannel();
using (OperationContextScope contextScope = new OperationContextScope(proxy as IContextChannel))
{
MessageHeader<int> messageHeader = new MessageHeader<int>(clientId);
OperationContext.Current.OutgoingMessageHeaders.Add(messageHeader.GetUntypedHeader(EventMonitor.CientIdHeaderLocalName, EventMonitor.CientIdHeaderNamespace));
proxy.Add(1, 2);
}
EventMonitor.Send(clientId, EventType.EndCall);
}, null);
}
}
开发者ID:huoxudong125,项目名称:WCF-Demo,代码行数:33,代码来源:MonitorForm.cs
示例19: DeliverMessage
public void DeliverMessage(ExternalDataEventArgs eventArgs, IComparable queueName, object message, object workItem, IPendingWork workHandler)
{
if (eventArgs == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("eventArgs");
}
if (queueName == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("queueName");
}
using (ExternalDataExchangeClient desClient = new ExternalDataExchangeClient(WorkflowRuntimeEndpoint.netNamedPipeContextBinding,
new EndpointAddress(this.baseUri)))
{
using (OperationContextScope scope = new OperationContextScope((IContextChannel)desClient.InnerChannel))
{
IContextManager contextManager = desClient.InnerChannel.GetProperty<IContextManager>();
Fx.Assert(contextManager != null, "IContextManager must not be null.");
if (contextManager != null)
{
IDictionary<string, string> context = new Dictionary<string, string>();
context["instanceId"] = eventArgs.InstanceId.ToString();
contextManager.SetContext(context);
}
desClient.RaiseEvent(eventArgs, queueName, message);
}
}
}
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:30,代码来源:WorkflowClientDeliverMessageWrapper.cs
示例20: SetVirtualNetworkGatewayCommandProcess
public GatewayManagementOperationContext SetVirtualNetworkGatewayCommandProcess()
{
using (OperationContextScope operationContextScope = new OperationContextScope((IContextChannel)base.Channel))
{
try
{
UpdateConnection updateConnection = new UpdateConnection();
SwitchParameter connect = this.Connect;
if (!connect.IsPresent)
{
updateConnection.Operation = UpdateConnectionOperation.Disconnect;
}
else
{
updateConnection.Operation = UpdateConnectionOperation.Connect;
}
base.RetryCall<GatewayOperationAsyncResponse>((string s) => base.Channel.UpdateVirtualNetworkGatewayConnection(s, this.VNetName, this.LocalNetworkSiteName, updateConnection));
Operation operation = base.WaitForGatewayOperation(base.CommandRuntime.ToString());
ManagementOperationContext managementOperationContext = new ManagementOperationContext();
managementOperationContext.set_OperationDescription(base.CommandRuntime.ToString());
managementOperationContext.set_OperationId(operation.OperationTrackingId);
managementOperationContext.set_OperationStatus(operation.Status);
ManagementOperationContext managementOperationContext1 = managementOperationContext;
base.WriteObject(managementOperationContext1, true);
}
catch (CommunicationException communicationException1)
{
CommunicationException communicationException = communicationException1;
this.WriteErrorDetails(communicationException);
}
}
return null;
}
开发者ID:nickchal,项目名称:pash,代码行数:33,代码来源:SetAzureVNetGatewayCommand.cs
注:本文中的System.ServiceModel.OperationContextScope类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论