示例#1
0
        public ActionResult SetupSubmit(string indexOption, string faceApi, string faceApiEndpoint, string computerVisionApi, string computerVisionApiEndpoint)
        {
            if (!IsSitecoreUser())
            {
                return(LoginPage());
            }

            IImageAnalysis analysis = SetupService.SaveKeysAndAnalyze(faceApi, faceApiEndpoint, computerVisionApi, computerVisionApiEndpoint);
            var            items    = new List <string>();

            if (analysis == null || analysis.FacialAnalysis?.Length < 1)
            {
                items.Add("Face API");
            }
            if (analysis?.TextAnalysis?.Regions == null || analysis?.VisionAnalysis?.Description == null)
            {
                items.Add("Computer Vision API");
            }

            string err = SetupService.SetFieldsFolderTemplate();

            if (!string.IsNullOrEmpty(err))
            {
                items.Add(err);
            }

            SetupService.PublishContent();

            if (!indexOption.Equals("Skip"))
            {
                SetupService.ConfigureIndexes(indexOption);
            }

            return(Json(new
            {
                Failed = (analysis == null || items.Count > 0),
                Items = string.Join(",", items)
            }));
        }