private void RemoveSettings_Bing(SPFeatureReceiverProperties properties)
 {
     if (webApp != null)
     {
         BingSettings settings = new BingSettings();
         foreach (SPSite site in webApp.Sites)
         {
             settings.Remove(site);
         }
     }
 }
 private void RemoveSettings_Bing(SPFeatureReceiverProperties properties)
 {
     if (webApp != null)
     {
         BingSettings settings = new BingSettings();
         foreach (SPSite site in webApp.Sites)
         {
             try
             {
                 settings.Remove(site);
             }
             catch (Exception ex)
             {
                 SPDiagnosticsService.Local.WriteTrace(0, new SPDiagnosticsCategory(ex.Source, TraceSeverity.High, EventSeverity.Error), TraceSeverity.High, ex.Message, ex.Data);
                 //ex.ToString();
             }
         }
     }
 }
        public async Task <IEnumerable <Snippet> > GetSnippetsFromParserAsync(string searchQuery, int count)
        {
            var searchEngine = new Engine(); // обьект поискового движка

            #region Settings for services
            var yandexSettings = new YandexSettings();
            var googleSettings = new GoogleSettings();
            var bingSettings   = new BingSettings();
            #endregion

            #region Helpers
            var yandexHelper = new YandexServiceHelper();
            var googleHelper = new GoogleServiceHelper();
            var bingHelper   = new BingServiceHelper();
            #endregion

            #region Services
            var yandex = new Yandex(yandexSettings, yandexHelper);
            var google = new Google(googleSettings, googleHelper);
            var bing   = new Bing(bingSettings, bingHelper);
            #endregion

            var services = new List <ISearchService>()
            {
                google, yandex, bing
            };

            searchEngine.AddRangeSearchServices(services);

            var snippets = searchEngine.Start(searchQuery, count);

            if (snippets != null)
            {
                await _snippetRepository.AddRangeAsync(snippets);
            }

            return(snippets);
        }
Exemplo n.º 4
0
        public void ConfigureServices(IServiceCollection services)
        {
            ConfigureSession(services);

            services.AddMvc();
            ILuisSettings luisSettings = new LuisSettings(Configuration.GetSection("Luis"));

            services.AddSingleton(luisSettings);

            IBingSettings bingSettings = new BingSettings(Configuration.GetSection("Bing"));

            services.AddSingleton(bingSettings);

            IShareSettings shareSettings = new ShareSettings(Configuration.GetSection("Share"));

            services.AddSingleton(shareSettings);

            IKeyVaultSettings keyVaultSettings = new KeyVaultSettings(Configuration.GetSection("KeyVault"));

            services.AddSingleton(keyVaultSettings);

            IAdminSettings adminSettings = new AdminSettings(Configuration.GetSection("Admin"));

            services.AddSingleton(adminSettings);

            IOnboardingInfoSettings onboardingInfoSettings = new OnboardingInfoSettings(Configuration.GetSection("EmailService"), Configuration.GetSection("KeyVault"));

            services.AddSingleton(onboardingInfoSettings);
            IQnAMakerSettings qnAMakerSettings = new QnAMakerSettings(Configuration.GetSection("QnAMaker"));

            services.AddSingleton(qnAMakerSettings);

            services.AddSingleton <ILuisProxy, LuisProxy>();
            services.AddSingleton <ILuisBusinessLogic, LuisBusinessLogic>();
            services.AddSingleton <ITopicsResourcesBusinessLogic, TopicsResourcesBusinessLogic>();
            services.AddSingleton <IWebSearchBusinessLogic, WebSearchBusinessLogic>();
            services.AddSingleton <ICuratedExperienceConvertor, A2JAuthorBusinessLogic>();
            services.AddSingleton <ICuratedExperienceBusinessLogic, CuratedExperienceBuisnessLogic>();
            services.AddTransient <IHttpClientService, HttpClientService>();
            services.AddSingleton <IUserProfileBusinessLogic, UserProfileBusinessLogic>();
            services.AddSingleton <IPersonalizedPlanBusinessLogic, PersonalizedPlanBusinessLogic>();
            services.AddSingleton <IStaticResourceBusinessLogic, StaticResourceBusinessLogic>();
            services.AddSingleton <IShareBusinessLogic, ShareBusinessLogic>();
            services.AddSingleton <ICuratedExperienceConvertor, A2JAuthorBusinessLogic>();
            services.AddSingleton <IPersonalizedPlanEngine, PersonalizedPlanEngine>();
            services.AddSingleton <IA2JAuthorLogicParser, LogicParser>();
            services.AddSingleton <IA2JAuthorLogicInterpreter, LogicInterpreter>();
            services.AddSingleton <IPersonalizedPlanViewModelMapper, PersonalizedPlanViewModelMapper>();
            services.AddSingleton <IUserRoleBusinessLogic, UserRoleBusinessLogic>();
            services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>();
            services.AddSingleton <ISessionManager, SessionManager>();
            services.AddSingleton <IAdminBusinessLogic, AdminBusinessLogic>();
            services.AddSingleton <IStateProvinceBusinessLogic, StateProvinceBusinessLogic>();
            services.AddSingleton <IOnboardingInfoBusinessLogic, OnboardingInfoBusinessLogic>();
            services.AddSingleton <IQnABotBusinessLogic, QnABotBusinessLogic>();

            services.AddAuthentication(sharedOptions =>
            {
                sharedOptions.DefaultScheme = JwtBearerDefaults.AuthenticationScheme;
            }).AddAzureAdBearer(options => Configuration.Bind("AzureAd", options));

            services.AddAuthorization(options =>
            {
                options.DefaultPolicy = new AuthorizationPolicyBuilder(JwtBearerDefaults.AuthenticationScheme)
                                        .RequireAuthenticatedUser()
                                        .Build();
            });
            ConfigureCosmosDb(services);

            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new Info {
                    Title = "Access2Justice API", Version = "1.0.0", Description = "List of all APIs for Access2Justice", TermsOfService = "None"
                });
                c.TagActionsBy(api => api.GroupName);
                c.DescribeAllEnumsAsStrings();
                c.OrderActionsBy((apiDesc) => $"{apiDesc.RelativePath}_{apiDesc.HttpMethod}");
                c.OperationFilter <FileUploadOperation>(); //Register File Upload Operation Filter
                c.OperationFilter <FileUploadOperationResource>();
                c.CustomSchemaIds(x => x.FullName);
                var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
                var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
                c.IncludeXmlComments(xmlPath);
            });
        }