// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { //services.AddControllers(); services.AddScoped <IUserRepository, UserRepository>(); string conn = Configuration.GetConnectionString("CONN"); services.AddDbContext <AuthDbContext>(opt => { opt.UseSqlServer(conn); }); services.Configure <UrlSettings>(Configuration.GetSection("UrlSettings")); #region COMMON_SWAGGER_JWT _apiStartup = new ApiStartup(services, Configuration); _apiStartup.AddSwaggerGen(); _apiStartup.ConfigureJwtAuthentication(); #endregion #region CORSCONFIG //** will be used //var corsConfig = Configuration.GetSection("CorsConfiguration").Get<CorsConfiguration>(); services.AddCors(options => { options.AddPolicy(name: "AuthCorsConfig", builder => builder .AllowAnyOrigin() .AllowAnyHeader() .AllowAnyMethod()); //builder => //{ // builder.WithOrigins(corsConfig?.AcceptedUrls?.ToArray()); //}); }); services.AddMvc(options => options.EnableEndpointRouting = false); #endregion #region SENDGRID services.Configure <SendGridEmailSettings>(Configuration.GetSection("SendGridEmailProperties")); services.Configure <SendGridEmailVariables>(Configuration.GetSection("CompanyProperties")); services.AddScoped <IEmailSender, EmailSender>(); #endregion #region MEDIATR services.AddMediatR(typeof(Startup)); #endregion }
public void Configuration(IAppBuilder app) { //app.UseWelcomePage("/"); var config = new HttpConfiguration(); // Web API ApiStartup.Register(config); app.UseWebApi(config); // JSON payload by default. var appXmlType = config.Formatters.XmlFormatter.SupportedMediaTypes.FirstOrDefault(t => t.MediaType == "application/xml"); config.Formatters.XmlFormatter.SupportedMediaTypes.Remove(appXmlType); app.MapSignalR(); // File Server (Use public folder from SPA project.) app.UseFileServer(new FileServerOptions { RequestPath = new PathString(string.Empty), FileSystem = new PhysicalFileSystem("../../../../../../ngOwinSpa/public") }); app.UseStageMarker(PipelineStage.MapHandler); }
// This method gets called by the runtime. Use this method to add services to the container. // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 public void ConfigureServices(IServiceCollection services) { // We want to run the API and MVC UI app on a single ASP.NET Core host but we cannot get along with a single DI container currently // as endpoint routing is bugged regarding pipeline branches (https://github.com/dotnet/aspnetcore/issues/19330), // so we need two application branches with isolated MVC-related and shared common services (like service layer services). // Unfortunately, the built-in DI is insufficient for this setup, we need some more advanced solution like Autofac. // As a matter of fact, Autofac could handle this situation out-of-the-box (https://autofaccn.readthedocs.io/en/latest/integration/aspnetcore.html#multitenant-support) // but this approach also has issues currently (https://github.com/autofac/Autofac.AspNetCore.Multitenant/issues/27) // The services defined here go into the root DI container and are accessible to the nested (tenant) containers. // 1. register shared services and obtain options necessary for DI configuration using (var optionsProvider = ApiStartup.BuildImmediateOptionsProvider(ConfigureImmediateOptions)) { ApiStartup.ConfigureBaseServices(services, optionsProvider); UIOptions = optionsProvider.GetRequiredService <IOptions <UIOptions> >().Value; } ConfigureOptions(services); ConfigureServicesPartial(services); // 2. register the tenants services.AddSingleton(new Tenants( new ApiTenant(ApiTenantId, this, typeof(Api.Startup).Assembly), new UITenant(UITenantId, this, typeof(Startup).Assembly))); // 3. finally register a startup filter which ensures that the main branch is set up before any other middleware added services.Insert(0, ServiceDescriptor.Transient <IStartupFilter, MainBranchSetupFilter>()); }
public Startup(IConfiguration configuration, IHostingEnvironment env) { Configuration = configuration; if (env.IsDevelopment()) { this.developmentEnvironment = true; } identityStartup = new IdentityStartup(configuration, this.developmentEnvironment); dataStartup = new DataStartup(); apiStartup = new ApiStartup(); servicesStartup = new ServicesStartup(); }
public void Init(IConfiguration configuration, IWebHostEnvironment env) { this.Configuration = configuration; this.CurrentEnvironment = env; if (env.IsDevelopment()) { this.developmentEnvironment = true; } identityStartup = new IdentityStartup(configuration, this.developmentEnvironment); dataStartup = new DataStartup(); apiStartup = new ApiStartup(); servicesStartup = new ServicesStartup(); }
public void Configuration(IAppBuilder app) { var config = new HttpConfiguration(); // Web API app.UseWebApi(config); ApiStartup.Register(config); // JSON payload by default. var appXmlType = config.Formatters.XmlFormatter.SupportedMediaTypes.FirstOrDefault(t => t.MediaType == "application/xml"); config.Formatters.XmlFormatter.SupportedMediaTypes.Remove(appXmlType); app.UseFileServer(new FileServerOptions { RequestPath = new PathString(string.Empty), FileSystem = new PhysicalFileSystem("./public") }); app.UseStageMarker(PipelineStage.MapHandler); }
public static int MeasureTeam(ApiStartup p1, List <FeedbackContainer> f1) { int totalfeedback = 0; int teamMeasurement = 0; foreach (FeedbackContainer fbc1 in f1) { totalfeedback += fbc1.Fields.TeamStrength; } if (f1.Count == 0) { return(p1.Team); } int avg = totalfeedback / f1.Count; int newAvg = (avg + p1.Team) / 2; if (newAvg >= 5) { teamMeasurement = 4; } else if (newAvg == 4) { teamMeasurement = 3; } else if (newAvg == 3) { teamMeasurement = 2; } else if (newAvg == 2) { teamMeasurement = 1; } else if (newAvg == 1) { teamMeasurement = 0; } return(teamMeasurement); }
public static List <KeyValuePair <string, double> > FindSimilar(string desc, List <string> themes, List <string> techAreas, StartupListRootObject startupList, SLPADDBContext context) { List <string> keywords = GetKeywords(desc); List <StartupContainer> containers = startupList.Records; List <Models.Startup> dbStartups = context.Startup.ToList(); Dictionary <string, double> scoreDictionary = new Dictionary <string, double>(); foreach (StartupContainer sc in containers) { if (desc == sc.Fields.CompanySummary) { continue; } ApiStartup startup = sc.Fields; double score = GetScore(keywords, techAreas, themes, GetKeywords(startup.CompanySummary), startup.TechAreas, startup.Theme); scoreDictionary.Add(startup.CompanyName, score); } foreach (Models.Startup s in dbStartups) { try { double score = GetScore(keywords, techAreas, themes, GetKeywords(s.Summary), s.TechArea, s.Theme); scoreDictionary.Add(s.Name, score); } catch { } } List <KeyValuePair <string, double> > topScores = new List <KeyValuePair <string, double> >(); List <KeyValuePair <string, double> > returnValue = new List <KeyValuePair <string, double> >(); topScores = scoreDictionary.ToList().OrderByDescending(x => x.Value).ToList(); for (int i = 0; i < Math.Min(3, topScores.Count); i++) { returnValue.Add(topScores[i]); } return(returnValue); }
public async Task <List <PredictedApiStartup> > CompareSuccess(int id) { //List<string> techAreasStrings = new List<string>(); Models.Startup startupToEdit = _context.Startup.Find(id); // List<ApiStartup> newList = new List<ApiStartup>(); //var newList = startupToEdit; string[] techAreaStrings = startupToEdit.TechArea.Replace(" ", "").Split(','); StartupListRootObject startupList = (await Utilities.GetApiResponse <StartupListRootObject>("v0/appFo187B73tuYhyg", "Master List", "https://api.airtable.com", "api_key", ApiKey)).FirstOrDefault(); StartupListRootObject filteredStartupList = new StartupListRootObject(); filteredStartupList.Records = new List <StartupContainer>(); foreach (string ta in techAreaStrings) { foreach (var record in startupList.Records) { if (record.Fields.TechAreas != null) { string apiTechAreas = record.Fields.TechAreas.Replace(" ", "").ToLower(); string thisTechArea = ta.Replace(" ", "").ToLower(); if (apiTechAreas.Contains(thisTechArea)) { filteredStartupList.Records.Add(record); } } } } FeedbackListRootObject feedbackList = (await Utilities.GetApiResponse <FeedbackListRootObject>("v0/appFo187B73tuYhyg", "Feedback", "https://api.airtable.com", "api_key", ApiKey)).FirstOrDefault(); List <PredictedApiStartup> ratedFilteredApiStartups = new List <PredictedApiStartup>(); for (int i = 0; i < filteredStartupList.Records.Count; i++) { ApiStartup singleStartup = (ApiStartup)filteredStartupList.Records[i].Fields; //PredictedApiStartup thisone = singleStartup as PredictedApiStartup; if (singleStartup != null) { PredictedApiStartup pas = new PredictedApiStartup(); pas.CompanyName = singleStartup.CompanyName; pas.CompanySummary = singleStartup.CompanySummary; pas.PredictedRating = SuccessPredictor.PredictSuccess(filteredStartupList.Records[i].Fields, feedbackList.Records); ratedFilteredApiStartups.Add(pas); } } ratedFilteredApiStartups = ratedFilteredApiStartups.OrderBy(x => x.PredictedRating).Reverse().ToList(); List <PredictedApiStartup> topResults = new List <PredictedApiStartup>(); for (int i = 0; i < 3; i++) //change i<# to change number of results { try { topResults.Add(ratedFilteredApiStartups[i]); } catch { break; } } return(topResults); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { //services.AddControllers(); services.AddScoped <IUserRepository, UserRepository>(); services.AddScoped <IRoleRepository, RoleRepository>(); services.AddScoped <IAccountRepository, AccountRepository>(); services.AddScoped <IAccountTypeRepository, AccountTypeRepository>(); services.AddScoped <IAccountAdminRepository, AccountAdminRepository>(); services.AddScoped <IAccountUserRepository, AccountUserRepository>(); services.AddScoped <IUserGateRepository, UserGateRepository>(); services.AddScoped <IGateRepository, GateRepository>(); services.AddScoped <IGateTypeRepository, GateTypeRepository>(); services.AddScoped <ILogService, LogService>(); string conn = Configuration.GetConnectionString("CONN"); services.AddDbContext <GPDbContext>(opt => { opt.UseSqlServer(conn); }); #region COMMON_SWAGGER_JWTAUTH _apiStartup = new ApiStartup(services, Configuration); _apiStartup.AddSwaggerGen(true); _apiStartup.ConfigureJwtAuthentication(OnUserAuthenticated, true); #endregion #region CORSCONFIG //** will be used //var corsConfig = Configuration.GetSection("CorsConfiguration").Get<CorsConfiguration>(); services.AddCors(options => { options.AddPolicy(name: "GateCorsConfig", builder => builder .AllowAnyOrigin() .AllowAnyHeader() .AllowAnyMethod()); //builder => //{ // builder.WithOrigins(corsConfig?.AcceptedUrls?.ToArray()); //}); }); services.AddMvc(options => options.EnableEndpointRouting = false); #endregion #region MEDIATR services.AddMediatR(typeof(Startup)); #endregion #region IGNORE_REFERENCELOOPING services.AddControllers().AddNewtonsoftJson(options => options.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore); #endregion }
public static int PredictSuccess(ApiStartup s1, List <FeedbackContainer> fc1) { int success = MeasureTeam(s1, fc1) + MeasureInterest(fc1); return(success); }