/*      public void ResponseFilter(IRequest req, IResponse res, object responseDto)
        {
            //TODO avoid memory leaks
            var hub = GlobalHost.ConnectionManager.GetHubContext<IdentifyStateHub>();
            if (hub != null)
            {

                if ((responseDto==null) || (responseDto.GetType()==typeof(Worker)))
                {
                    var myrepository = HostContext.Container.Resolve<WorkersRepository>();
                    hub.Clients.All.updateModels(myrepository.GetModelNames());
                }
                else if (responseDto.GetType()==typeof(IdentifyDTO)) hub.Clients.All.updateIdentifyProcess(responseDto);
            }
        }*/
        public void ResponseFilter(IRequest req, IResponse res, object response)
        {
            //TODO avoid memory leaks
            var hub = GlobalHost.ConnectionManager.GetHubContext<dynamic>();
            if (hub != null)
            {

                if ((response == null) || (response.GetType() == typeof(Worker)))
                {
                    var myrepository = HostContext.Container.Resolve<WorkersRepository>();
                    hub.Clients.All.updateModels(myrepository.GetModelNames());
                }
                else if (response.GetType() == typeof(IdentifyDTO)) hub.Clients.All.updateIdentifyProcess(response);
            }
        }
Beispiel #2
0
        public override object OnServiceException(ServiceStack.Web.IRequest httpReq, object request, Exception ex)
        {
            if (ex != null)
            {
                string errorMessage = ex.Message;
                string rawUrl       = "";
                if (httpReq != null)
                {
                    rawUrl = httpReq.RawUrl;
                }

                if (ex is WebServiceException)
                {
                    WebServiceException webServiceException = ex as WebServiceException;
                    errorMessage = webServiceException.ErrorMessage;
                }
                if (request != null)
                {
                    errorMessage = string.Format("Post 出错{0}, requestType: {1}, request: {2}, rawUrl: {3}",
                                                 errorMessage,
                                                 request.GetType().Name,
                                                 JsonConvert.SerializeObject(request),
                                                 rawUrl);
                }

                if (ex is ValidateException)
                {
                    EIMLog.Logger.Info(errorMessage, ex);
                }
                else
                {
                    EIMLog.Logger.Error(errorMessage, ex);
                }
            }
            else
            {
                EIMLog.Logger.Error(request);
            }

            return(base.OnServiceException(httpReq, request, ex));
        }