当前位置: 首页>>代码示例>>C#>>正文


C# IServiceResponse类代码示例

本文整理汇总了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);
            }
        }
开发者ID:adambird,项目名称:eaep,代码行数:32,代码来源:SearchService.cs

示例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";
 }
开发者ID:adambird,项目名称:eaep,代码行数:7,代码来源:EventService.cs

示例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);
     }
 }
开发者ID:adambird,项目名称:eaep,代码行数:8,代码来源:HtmlPage.cs

示例4: ApiServiceResponse

        public ApiServiceResponse(IServiceResponse source)
        {
            if (source == null) throw new ArgumentNullException("source");

            ErrorMessage = source.ErrorMessage;
            Success = source.Success;
            Exception = source.Exception;
        }
开发者ID:LordZoltan,项目名称:WebAPIDemos,代码行数:8,代码来源:ApiServiceResponse.cs

示例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);
        }
开发者ID:yuriik83,项目名称:UA-.NET,代码行数:13,代码来源:Opc.Ua.Messages.cs

示例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";
     }
 }
开发者ID:adambird,项目名称:eaep,代码行数:14,代码来源:HttpService.cs

示例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));
            }
        }
开发者ID:adambird,项目名称:eaep,代码行数:17,代码来源:CountService.cs

示例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);
            }
        }
开发者ID:adambird,项目名称:eaep,代码行数:17,代码来源:DistinctService.cs

示例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:
            }
        }
开发者ID:netcasewqs,项目名称:nlite,代码行数:25,代码来源:ControllerListener.cs

示例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);
        }
开发者ID:adambird,项目名称:eaep,代码行数:40,代码来源:SearchPage.cs

示例11: Send

 public void Send(IServiceResponse response)
 {
     _sendingQueue.Enqueue(response);
 }
开发者ID:smeshlink,项目名称:Misty.NET,代码行数:4,代码来源:TcpChannel.cs

示例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);
 }
开发者ID:smeshlink,项目名称:Misty.NET,代码行数:10,代码来源:TcpChannel.cs

示例13: OnResponseSent

 /// <summary>
 /// Called when a response sent via the endpoint.
 /// </summary>
 /// <param name="response">The response.</param>
 protected virtual void OnResponseSent(IServiceResponse response)
 {
 }
开发者ID:OPCFoundation,项目名称:UA-.NETStandardLibrary,代码行数:7,代码来源:EndpointBase.cs

示例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;
                }
            }
        }
开发者ID:OPCFoundation,项目名称:Misc-Tools,代码行数:60,代码来源:TcpServerChannel.cs

示例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;
 }
开发者ID:netcasewqs,项目名称:nlite,代码行数:13,代码来源:Api.cs


注:本文中的IServiceResponse类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。