예제 #1
0
        private async Task <IDictionary <string, bool> > LoadFeaturesAsync()
        {
            var features = (await _featuresRepository.GetFeaturesAsync())
                           .ToDictionary(f => f.Name, f => f.Enabled);

            var isWorkflowEnabled = (_licenseHelper.GetValidBlueprintLicenseFeatures() & FeatureTypes.Workflow) != 0;

            features[ServiceConstants.WorkflowFeatureKey] = isWorkflowEnabled;

            return(features);
        }
예제 #2
0
        public override void OnActionExecuting(HttpActionContext actionContext)
        {
            var licenses = _featureLicenseHelper.GetValidBlueprintLicenseFeatures();

            if ((licenses & _requiredFeatureTypes) != _requiredFeatureTypes)
            {
                // required license not found
                var errorMessage = "License is not available";
                var errorCode    = ErrorCodes.LicenseUnavailable;
                if (_requiredFeatureTypes == FeatureTypes.Workflow)
                {
                    errorMessage = "Workflow license is not available";
                    errorCode    = ErrorCodes.WorkflowLicenseUnavailable;
                }
                var error = new HttpError(errorMessage)
                {
                    [ServiceConstants.ErrorCodeName] = errorCode
                };
                actionContext.Response = actionContext.Request.CreateErrorResponse(HttpStatusCode.Forbidden, error);
            }
        }