Ejemplo n.º 1
0
        /// <summary>
        /// Validate authentication cloud key in request.
        /// </summary>
        /// <param name="request">Instance of <see cref="HttpRequest"/> current request.</param>
        /// <returns>Message text if key wrong or empty string.</returns>
        public virtual string ValidateAuthKey(HttpRequest request)
        {
            AuthenticationResult result = BpmonlineCloudEngine.Authenticate(request, UserConnection);

            if (result.Success)
            {
                return(string.Empty);
            }
            return(result.Message);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Checks the API key.
        /// </summary>
        /// <param name="userConnection">The user connection.</param>
        /// <returns><c>true</c> if api key is set, otherwise - <c>false</c>.</returns>
        public static bool CheckApiKey(UserConnection userConnection)
        {
            var apiKey = BpmonlineCloudEngine.GetAPIKey(userConnection);

            if (apiKey.IsNullOrEmpty())
            {
                _log.Warn("\tService API key is empty. Check 'CloudServicesAPIKey' system settings value");
                return(false);
            }
            return(true);
        }
Ejemplo n.º 3
0
 private void GetRequiredParameters(out string serviceUrl, out string apiKey)
 {
     serviceUrl = SysSettings.GetValue(UserConnection, "AccountEnrichmentServiceUrl", string.Empty);
     if (serviceUrl.IsNullOrEmpty())
     {
         throw new HttpException((int)HttpStatusCode.InternalServerError,
                                 "Enrichment account service url not set");
     }
     apiKey = BpmonlineCloudEngine.GetAPIKey(UserConnection);
     if (apiKey.IsNullOrEmpty())
     {
         throw new HttpException((int)HttpStatusCode.InternalServerError, "Cloud service api key not set");
     }
 }
Ejemplo n.º 4
0
        private List <ClassificationResult> QueryPrediction(Dictionary <string, object> classifyData)
        {
            var                         apiKey                = BpmonlineCloudEngine.GetAPIKey(_userConnection);
            var                         serviceUrlArg         = new ConstructorArgument("serviceUrl", ServiceUrl);
            var                         apiKeyArg             = new ConstructorArgument("apiKey", apiKey);
            IMLServiceProxy             proxy                 = ClassFactory.Get <IMLServiceProxy>(serviceUrlArg, apiKeyArg);
            List <ClassificationResult> classificationResults = null;

            try {
                classificationResults = proxy.Classify(ModelInstanceUId, classifyData);
            } catch (Exception e) {
                _log.ErrorFormat("Classification failed with error: {0}", e, e.Message);
            }
            return(classificationResults);
        }
 private void CheckRequiredParameters(out string serviceUrl, out string apiKey)
 {
     serviceUrl = SysSettings.GetValue(_userConnection,
                                       EmailMiningConsts.TextParsingServiceSysSetting, string.Empty);
     if (serviceUrl.IsNullOrEmpty())
     {
         _metricReporter.Gauge(EmailMiningUnreachableMetricName, 1);
         throw new IncorrectConfigurationException(EmailMiningConsts.TextParsingServiceSysSetting);
     }
     apiKey = BpmonlineCloudEngine.GetAPIKey(_userConnection);
     if (apiKey.IsNullOrEmpty())
     {
         _metricReporter.Gauge(EmailMiningUnreachableMetricName, 1);
         throw new IncorrectConfigurationException(CloudServicesAPIKey);
     }
 }
Ejemplo n.º 6
0
        private List <double> Predict(MLModelConfig model,
                                      IList <Dictionary <string, object> > dataForPrediction)
        {
            var             apiKey        = BpmonlineCloudEngine.GetAPIKey(_userConnection);
            var             serviceUrlArg = new ConstructorArgument("serviceUrl", model.ServiceUrl);
            var             apiKeyArg     = new ConstructorArgument("apiKey", apiKey);
            IMLServiceProxy proxy;

            try {
                proxy = ClassFactory.Get <IMLServiceProxy>(serviceUrlArg, apiKeyArg);
            } catch (IncorrectConfigurationException ex) {
                _log.WarnFormat($"Can't predict value for model {model.Id}", ex);
                throw;
            }
            var predictionResults = Predict(model, dataForPrediction, proxy);

            return(predictionResults);
        }