public object AfterReceiveRequest(ref Message request, IClientChannel channel, InstanceContext instanceContext) { // www-form try { ContentTransform(ref request); } catch (Exception ex) { LogHelper.Info(ex.Message + ex.StackTrace); } if (DEBUG) { QZ.RealTimeRequestLogService.RequestLog log = LogInccomingRequest(request); return(log); } var res = Util.Get_RemoteIp().ToMaybe().Do(ip => counter.AddRec(ip)) .Select <VisitorCounter.IpInfo, string>( ip => counter.GetIpInfo(ip, false).ToMaybe(), (ip, info) => { if (counter.IsMechineIpInfo(info)) { counter.AddRecCount(ip, 0x1000); } if (!counter.IsIpAuthorized(ip)) { if (VisitorCounter.GetReqPath().ToLower() == "orgcompany/branch/select/page") { throw new WebFaultException <string>(string.Format("{0} Unauthorized!", ip), System.Net.HttpStatusCode.Unauthorized); } } return(string.Empty); } ); return(null); }
public void BeforeSendReply(ref Message reply, object correlationState) { if (DEBUG && correlationState != null) { QZ.RealTimeRequestLogService.RequestLog rt = (QZ.RealTimeRequestLogService.RequestLog)correlationState; TimeSpan ts = DateTime.Now - rt.Time; rt.TotalSpend = ts.Milliseconds; if (reply != null) { MessageProperties mp = reply.Properties; object obj; if (mp.TryGetValue("httpResponse", out obj)) { System.ServiceModel.Channels.HttpResponseMessageProperty wh = (System.ServiceModel.Channels.HttpResponseMessageProperty)obj; rt.ResponseHeader = wh.Headers.ToString(); rt.ResponseContentType = wh.Headers[System.Net.HttpResponseHeader.ContentType]; rt.ResponseStatusCode = (int)wh.StatusCode; rt.ResponseStatusStr = wh.StatusCode.ToString(); } if (rt.ResponseStatusCode == 200) { rt.Response = GetReponseBody(reply); } else { rt.Response = string.Empty; } } else { rt.ResponseStatusStr = "no reply message captured, unable to read the response infomation."; } QZ.RealTimeRequestLogService.RealTimeRequestLog.AppendLog(rt); } }