private static bool TrySetRESTContextForRESTExposeActions(HttpActionContext actionContext, string ssKey, ref RESTExposeContext restExposeContext) { RESTExposeActionPropertiesAttribute props = actionContext.ActionDescriptor.GetCustomAttributes <RESTExposeActionPropertiesAttribute>().SingleOrDefault(); if (props != null) { restExposeContext.LogTo = LogTo.RESTExpose; var moduleKey = AppInfo.GetAppInfo().eSpaceUID; restExposeContext.TraceAll = RESTSettings.GetTraceAllSetting(moduleKey, ssKey).GetValue(); restExposeContext.TraceErrors = RESTSettings.GetTraceErrorsSetting(moduleKey, ssKey).GetValue(); restExposeContext.ActionName = props.Name; restExposeContext.IsRequestBinary = props.IsRequestBinary; restExposeContext.IsResponseBinary = props.IsResponseBinary; return(true); } return(false); }
public static void SetupLoggingContext(HttpActionContext actionContext, string serviceName, string ssKey) { bool restExposeAction = actionContext.ActionDescriptor.GetCustomAttributes <RESTExposeActionPropertiesAttribute>().Any(); bool restScreenServicesAction = actionContext.ActionDescriptor.GetCustomAttributes <RESTScreenServicesActionPropertiesAttribute>().Any(); if (!restExposeAction && !restScreenServicesAction) { return; } RESTExposeContext restExposeContext = new RESTExposeContext(); restExposeContext.StartTime = DateTime.Now; restExposeContext.ServiceName = serviceName; if (restExposeAction) // For REST expose actions { var configuration = RESTServiceConfiguration.GetCustomClientConfiguration(ssKey, AppInfo.GetAppInfo().eSpaceId); restExposeContext.TraceAll = configuration.TraceAll; restExposeContext.TraceErrors = configuration.TraceErrors; RESTExposeActionPropertiesAttribute propertiesAttribute = actionContext.ActionDescriptor.GetCustomAttributes <RESTExposeActionPropertiesAttribute>().Single(); restExposeContext.ActionName = propertiesAttribute.Name; restExposeContext.IsRequestBinary = propertiesAttribute.IsRequestBinary; restExposeContext.IsResponseBinary = propertiesAttribute.IsResponseBinary; } else // For Screen Services actions { var configuration = RESTServiceConfiguration.GetMobileLoggingLevelConfiguration(AppInfo.GetAppInfo().eSpaceId); restExposeContext.TraceAll = configuration.TraceAll; restExposeContext.TraceErrors = configuration.TraceErrors; RESTScreenServicesActionPropertiesAttribute propertiesAttribute = actionContext.ActionDescriptor.GetCustomAttributes <RESTScreenServicesActionPropertiesAttribute>().Single(); restExposeContext.ActionName = propertiesAttribute.Name; restExposeContext.ScreenName = propertiesAttribute.Screen; restExposeContext.IsScreenService = true; } HttpContext.Current.Items[RESTContextVariableName] = restExposeContext; }