本文整理汇总了C#中IServiceResponse类的典型用法代码示例。如果您正苦于以下问题:C# IServiceResponse类的具体用法?C# IServiceResponse怎么用?C# IServiceResponse使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IServiceResponse类属于命名空间,在下文中一共展示了IServiceResponse类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessRequest
public override void ProcessRequest(IServiceRequest request, IServiceResponse response, IResourceRepository resourceRepository)
{
response.ContentType = Constants.CONTENT_TYPE_JSON;
EAEPMessages messages = null;
if (request.GetParameter(Constants.QUERY_STRING_FROM) != null)
{
DateTime from = DateTime.ParseExact(request.GetParameter(Constants.QUERY_STRING_FROM), Constants.FORMAT_DATETIME, CultureInfo.InvariantCulture);
if (request.GetParameter(Constants.QUERY_STRING_TO) != null)
{
messages = monitor.GetMessages(
from,
DateTime.ParseExact(request.GetParameter(Constants.QUERY_STRING_TO), Constants.FORMAT_DATETIME, CultureInfo.InvariantCulture),
request.Query
);
}
else
{
messages = monitor.GetMessages(from, request.Query);
}
}
else
{
messages = monitor.GetMessages(request.Query);
}
using (StreamWriter writer = new StreamWriter(response.ContentStream))
{
string json = JsonConvert.SerializeObject(messages);
writer.Write(json);
}
}
示例2: ProcessRequest
public override void ProcessRequest(IServiceRequest request, IServiceResponse response, IResourceRepository resourceRepository)
{
EAEPMessages messages = new EAEPMessages(request.Body);
monitorStore.PushMessages(messages);
response.StatusCode = Constants.HTTP_200_OK;
response.StatusDescription = "OK";
}
示例3: WriteContent
protected void WriteContent(IServiceRequest request, IServiceResponse response, IResourceRepository resourceRepository)
{
response.ContentType = "text/html";
using (StreamWriter targetWriter = new StreamWriter(response.ContentStream))
{
InternalWriteContent(targetWriter, request, response, resourceRepository);
}
}
示例4: ApiServiceResponse
public ApiServiceResponse(IServiceResponse source)
{
if (source == null) throw new ArgumentNullException("source");
ErrorMessage = source.ErrorMessage;
Success = source.Success;
Exception = source.Exception;
}
示例5: CreateResponse
/// <summary cref="IServiceMessage.CreateResponse" />
public object CreateResponse(IServiceResponse response)
{
FindServersResponse body = response as FindServersResponse;
if (body == null)
{
body = new FindServersResponse();
body.ResponseHeader = ((ServiceFault)response).ResponseHeader;
}
return new FindServersResponseMessage(body);
}
示例6: Handle
public void Handle(IServiceRequest request, IServiceResponse response, IResourceRepository resourceRepository)
{
try
{
ProcessRequest(request, response, resourceRepository);
response.StatusCode = Constants.HTTP_200_OK;
response.StatusDescription = "OK";
}
catch (Exception)
{
response.StatusCode = Constants.HTTP_500_SERVER_ERROR;
response.StatusDescription = "Error, review logs";
}
}
示例7: ProcessRequest
public override void ProcessRequest(IServiceRequest request, IServiceResponse response, IResourceRepository resourceRepository)
{
CountResult[] result = store.Count(
DateTime.ParseExact(request.GetParameter(Constants.QUERY_STRING_FROM), Constants.FORMAT_DATETIME, CultureInfo.InvariantCulture),
DateTime.ParseExact(request.GetParameter(Constants.QUERY_STRING_TO), Constants.FORMAT_DATETIME, CultureInfo.InvariantCulture),
int.Parse(request.GetParameter(Constants.QUERY_STRING_TIMESLICES)),
request.GetParameter(Constants.QUERY_STRING_GROUPBY),
request.Query
);
response.ContentType = Constants.CONTENT_TYPE_JSON;
using (StreamWriter writer = new StreamWriter(response.ContentStream))
{
writer.Write((string) JsonConvert.SerializeObject(result));
}
}
示例8: ProcessRequest
public override void ProcessRequest(IServiceRequest request, IServiceResponse response, IResourceRepository resourceRepository)
{
string[] values = store.Distinct(
request.GetParameter(Constants.QUERY_STRING_FIELD),
DateTime.ParseExact(request.GetParameter(Constants.QUERY_STRING_FROM), Constants.FORMAT_DATETIME, CultureInfo.InvariantCulture),
DateTime.ParseExact(request.GetParameter(Constants.QUERY_STRING_TO), Constants.FORMAT_DATETIME, CultureInfo.InvariantCulture),
request.Query
);
response.ContentType = Constants.CONTENT_TYPE_JSON;
using (StreamWriter writer = new StreamWriter(response.ContentStream))
{
string json = JsonConvert.SerializeObject(values);
writer.Write(json);
}
}
示例9: OnExceptionFired
/// <summary>
/// 监听异常
/// </summary>
/// <param name="req"></param>
/// <param name="resp"></param>
/// <param name="operationDesc"></param>
public override void OnExceptionFired(IServiceRequest req, IServiceResponse resp, IOperationDescriptor operationDesc)
{
IRedirectToErrorResult errorNav = null;
if (operationDesc != null)
{
if (operationDesc.Extensions.ContainsKey(ControllerListener.ErrorNavigation))
errorNav = operationDesc.Extensions[ControllerListener.ErrorNavigation] as IRedirectToErrorResult;
else if (operationDesc.ServiceDescriptor.Extensions.ContainsKey(ControllerListener.ErrorNavigation))
errorNav = operationDesc.ServiceDescriptor.Extensions[ControllerListener.ErrorNavigation] as IRedirectToErrorResult;
}
//执行失败后, 设置mvc的 controller serviceDispatcherName 和 ActionName
if (errorNav != null)
{
req.Context[ControllerListener.NavigationResult] = errorNav;
if (errorNav.IsSaveModelState)
resp.Result = req.Arguments.FirstOrDefault();//TODO:
}
}
示例10: InternalWriteContent
protected override void InternalWriteContent(StreamWriter writer, IServiceRequest request, IServiceResponse response, IResourceRepository resourceRepository)
{
resourceRepository.WriteResource("header.htm", writer);
bool activeSearch = (request.Query != null);
try
{
EAEPMessages messages = new EAEPMessages();
string searchResultText = string.Empty;
if (activeSearch)
{
messages = monitor.GetMessages(request.Query);
searchResultText = string.Format("{0} message(s) found", messages.Count);
}
WriteSearchResultHeader(writer, request, resourceRepository, searchResultText);
int maxItems = 100;
if (maxItems > messages.Count) { maxItems = messages.Count; }
string messageTemplate = resourceRepository.GetResourceAsString("eaepmsg.htm");
for (int i = 0; i < maxItems; i++)
{
WriteResultItem(writer, messageTemplate, messages[i]);
}
}
catch (Exception ex)
{
writer.WriteLine(ReplaceCRLFwithHTMLLineBreaks(ex.ToString()));
}
resourceRepository.WriteResource("searchresultfooter.htm", writer);
resourceRepository.WriteResource("footer.htm", writer);
}
示例11: Send
public void Send(IServiceResponse response)
{
_sendingQueue.Enqueue(response);
}
示例12: ProcessResponse
private void ProcessResponse(IServiceResponse response)
{
if (response.Token != null)
{
WaitFuture<IServiceRequest, IServiceResponse> f;
if (_waitingRequests.TryRemove(response.Token, out f))
f.Response = response;
}
//_channel.FireResponseReceived(response);
}
示例13: OnResponseSent
/// <summary>
/// Called when a response sent via the endpoint.
/// </summary>
/// <param name="response">The response.</param>
protected virtual void OnResponseSent(IServiceResponse response)
{
}
示例14: SendResponse
/// <summary>
/// Sends the response for the specified request.
/// </summary>
public void SendResponse(uint requestId, IServiceResponse response)
{
if (response == null) throw new ArgumentNullException("response");
lock (DataLock)
{
// must queue the response if the channel is in the faulted state.
if (State == TcpChannelState.Faulted)
{
m_queuedResponses[requestId] = response;
return;
}
// Utils.Trace("Channel {0}: SendResponse {1}", ChannelId, requestId);
BufferCollection buffers = null;
try
{
// note that the server does nothing if the message limits are exceeded.
bool limitsExceeded = false;
buffers = WriteSymmetricMessage(
TcpMessageType.Message,
requestId,
CurrentToken,
response,
false,
out limitsExceeded);
}
catch (Exception e)
{
SendServiceFault(
CurrentToken,
requestId,
ServiceResult.Create(e, StatusCodes.BadEncodingError, "Could not encode outgoing message."));
return;
}
try
{
BeginWriteMessage(buffers, Int32.MaxValue, null);
buffers = null;
}
catch (Exception)
{
if (buffers != null)
{
buffers.Release(BufferManager, "SendResponse");
}
m_queuedResponses[requestId] = response;
return;
}
}
}
示例15: Resolve
/// <summary>
/// 解析服务响应结果
/// </summary>
/// <param name="httpContext"></param>
/// <param name="serviceResponse"></param>
/// <returns></returns>
public object Resolve(IHttpContext httpContext, IServiceResponse serviceResponse)
{
var jsonResponse = httpContext.Request["_cs_"] != null ?
new DotNetSuccessResponse(serviceResponse.Result)
: new SuccessResponse(serviceResponse.Result);
return jsonResponse;
}