Exemple #1
0
        private static bool TrySetRESTContextForScreenServicesActions(HttpActionContext actionContext, ref RESTExposeContext restExposeContext)
        {
            RESTScreenServicesActionPropertiesAttribute props = actionContext.ActionDescriptor.GetCustomAttributes <RESTScreenServicesActionPropertiesAttribute>().SingleOrDefault();

            if (props != null)
            {
                restExposeContext.LogTo = LogTo.ScreenServices;

                restExposeContext.TraceAll    = RuntimePlatformSettings.ScreenServices.TraceAll.GetValue();
                restExposeContext.TraceErrors = RuntimePlatformSettings.ScreenServices.TraceErrors.GetValue();
                restExposeContext.ActionName  = props.Name;
                restExposeContext.ScreenName  = props.Screen;

                return(true);
            }
            return(false);
        }
Exemple #2
0
        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;
        }