public void Configure(IApplicationBuilder app, IServiceProvider serviceProvider, IHostingEnvironment env) { FileProcessor fp = new FileProcessor(env); try { var havokcontext = fp.LoadJsonFromAppFolder("\\", "havok.json"); } catch { Havok havok = new Havok(); havok.Id = 1; havok.Name = "Item1"; string json = JsonConvert.SerializeObject(havok); fp.SaveJsonToAppFolder("\\", "havok.json", json); } Func <HttpContext, bool> isApiRequest = (HttpContext context) => context.Request.Path.ToString().StartsWith("/api/"); app.UseWhen(context => !isApiRequest(context), appbuilder => { appbuilder.UseHavokMiddleware(min: TimeSpan.FromMilliseconds(30000), max: TimeSpan.FromMilliseconds(40000)); }); // Configure Session. app.UseSession(); // Add static files to the request pipeline app.UseStaticFiles(); // Allow static files within the .well-known directory to allow for automatic SSL renewal app.UseStaticFiles(new StaticFileOptions() { ServeUnknownFileTypes = true, // this was needed as IIS would not serve extensionless URLs from the directory without it FileProvider = new PhysicalFileProvider( Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", @".well-known")), RequestPath = new PathString("/.well-known") }); // Add cookie-based authentication to the request pipeline app.UseAuthentication(); AppBuilderLoginProviderExtensions.AddLoginProviders(service, new ConfigurationLoginProviders(Configuration.GetSection("Authentication"))); // Add login providers (Microsoft/AzureAD/Google/etc). This must be done after `app.UseIdentity()` //app.AddLoginProviders( new ConfigurationLoginProviders(Configuration.GetSection("Authentication"))); // Add MVC to the request pipeline app.UseMvc(routes => { routes.MapRoute( name: "areaRoute", template: "{area:exists}/{controller}/{action}", defaults: new { action = "Index" }); routes.MapRoute( name: "default", template: "{controller}/{action}/{id?}", defaults: new { controller = "Home", action = "Index" }); routes.MapRoute( name: "api", template: "{controller}/{id?}"); }); }
public override async Task <Task> ProcessInScope(IServiceProvider serviceProvider) { Console.WriteLine("Processing starts here"); _context = serviceProvider.GetService <HavokContext>(); Havok item = _context.Havoks.First(); if (item.resourceGroupName != null) { AzureAppService apps = await GetAzureAppService(); if (apps.properties.numberOfWorkers > 1) { item.isScaledOut = true; } else { item.isScaledOut = false; } _context.Entry(item).State = EntityState.Modified; _context.SaveChanges(); } return(Task.CompletedTask); }
public ActionResult <Havok> GetHavok() { FileProcessor fp = new FileProcessor(_env); Havok item = JsonConvert.DeserializeObject <Havok> (fp.LoadJsonFromAppFolder("\\", "havok.json")); return(item); }
public override async Task <Task> ProcessInScope(IServiceProvider serviceProvider) { Console.WriteLine("Processing starts here"); _env = serviceProvider.GetService <IHostingEnvironment>(); FileProcessor fp = new FileProcessor(_env); Havok item = JsonConvert.DeserializeObject <Havok>(fp.LoadJsonFromAppFolder("\\", "havok.json")); if (item.resourceGroupName != null) { AzureAppService apps = await GetAzureAppService(); if (apps.properties.numberOfWorkers > 1) { item.isScaledOut = true; } else { item.isScaledOut = false; } string json = JsonConvert.SerializeObject(item); fp.SaveJsonToAppFolder("\\", "havok.json", json); } return(Task.CompletedTask); }
public virtual void Sync(EnginePtr exeeng, Direct3D exed3d, OpenGL exeogl, Havok exehvk, GuiFactory exegui, Forms exefms, DirectIpt exedip, WinIpt exewip, FFmpeg exeffm, CryptoPP execpp, ID3Lib exeid3, WinAudio exewad, XAudio2 exexa2, WinMidi exemid, WinSock exewsk, AsyncWorkers exeaws, SQLite exesql, HaruPdf exepdf, RayTracer exertr, Pbrt exepbrt, PythonScriptEngine exepse, Console execle) { IronSightEnginePINVOKE.IDirect3D_Sync(swigCPtr, EnginePtr.getCPtr(exeeng), Direct3D.getCPtr(exed3d), OpenGL.getCPtr(exeogl), Havok.getCPtr(exehvk), GuiFactory.getCPtr(exegui), Forms.getCPtr(exefms), DirectIpt.getCPtr(exedip), WinIpt.getCPtr(exewip), FFmpeg.getCPtr(exeffm), CryptoPP.getCPtr(execpp), ID3Lib.getCPtr(exeid3), WinAudio.getCPtr(exewad), XAudio2.getCPtr(exexa2), WinMidi.getCPtr(exemid), WinSock.getCPtr(exewsk), AsyncWorkers.getCPtr(exeaws), SQLite.getCPtr(exesql), HaruPdf.getCPtr(exepdf), RayTracer.getCPtr(exertr), Pbrt.getCPtr(exepbrt), PythonScriptEngine.getCPtr(exepse), Console.getCPtr(execle)); if (IronSightEnginePINVOKE.SWIGPendingException.Pending) { throw IronSightEnginePINVOKE.SWIGPendingException.Retrieve(); } }
public async Task <IActionResult> PutHavokItem(long id, Havok item) { if (id != item.Id) { return(BadRequest()); } _context.Entry(item).State = EntityState.Modified; await _context.SaveChangesAsync(); return(NoContent()); }
public async Task <IActionResult> PutHavokItem(long id, Havok item) { if (id != item.Id) { return(BadRequest()); } FileProcessor fp = new FileProcessor(_env); string json = JsonConvert.SerializeObject(item); await fp.SaveAwaitableJsonToAppFolder("\\", "havok.json", json); return(NoContent()); }
public async Task Invoke(HttpContext httpContext, IHostingEnvironment env) { int delayInMs = _random.Value.Next(_minDelayInMs, _maxDelayInMs); FileProcessor fp = new FileProcessor(env); Havok myEnt = JsonConvert.DeserializeObject <Havok>(fp.LoadJsonFromAppFolder("\\", "havok.json")); if (myEnt.HavokEnabled == true && myEnt.isScaledOut == false) { await Task.Delay(delayInMs); } await _next(httpContext); }
private async Task <AzureAppService> GetAzureAppService() { Havok item = _context.Havoks.First(); string tenantId = item.TenantId; string clientId = item.ClientId; string clientSecret = item.ClientSecret; string token = await AuthenticationHelpers.AcquireTokenBySPN(tenantId, clientId, clientSecret); string path = String.Format("https://management.azure.com/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Web/serverfarms/{2}?api-version=2016-09-01", item.SubscriptionId, item.resourceGroupName, item.AppServiceName); using (var client = new HttpClient()) { client.DefaultRequestHeaders.Add("Authorization", "Bearer " + token); client.BaseAddress = new Uri("https://management.azure.com/"); HttpResponseMessage response = await client.GetAsync(path); AzureAppService appService; return(appService = JsonConvert.DeserializeObject <AzureAppService>(await response.Content.ReadAsStringAsync())); } //client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", "Your Oauth token"); }
void RigidBody_ContactPointCallback(ref Havok.HkContactPointEvent A_0) { m_lastContactWithGround = DateTime.UtcNow; }
private void AabbPhantom_CollidableRemoved(ref Havok.HkpCollidableRemovedEvent eventData) { var rb = eventData.RigidBody; if (rb == null) // ignore phantoms return; var grid = rb.UserObject as MyGridPhysics; var character = rb.UserObject as MyPhysicsBody; if (IsDynamicGrid(rb, grid) || IsCharacter(rb, character)) { using (m_nearbyEntitiesLock.AcquireExclusiveUsing()) { if (character != null) { MyTrace.Send(TraceWindow.Analytics, string.Format("{0} Removed character", character.Entity.EntityId)); } IMyEntity entity = grid == null ? character.Entity : grid.Entity; Debug.Assert(m_nearbyEntities.Contains(entity), "Removing entity which was not added"); m_nearbyEntities.Remove(entity); } } }
private void AabbPhantom_CollidableAdded(ref Havok.HkpCollidableAddedEvent eventData) { var rb = eventData.RigidBody; if (rb == null) // ignore phantoms return; var grid = rb.UserObject as MyGridPhysics; var character = rb.UserObject as MyPhysicsBody; // I get both rigid bodies reported but they don't match, I will only track RB 1 if (IsDynamicGrid(rb, grid) || IsCharacter(rb, character)) { using (m_nearbyEntitiesLock.AcquireExclusiveUsing()) { IMyEntity entity = grid == null ? character.Entity : grid.Entity; Debug.Assert(!m_nearbyEntities.Contains(entity), "Entity added twice"); m_nearbyEntities.Add(entity); } } }
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Havok obj) { return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr); }
private void AabbPhantom_CollidableRemoved(ref Havok.HkpCollidableRemovedEvent eventData) { var rb = eventData.RigidBody; if (rb == null) // ignore phantoms return; var entities = rb.GetAllEntities(); foreach (var entity in entities) { var grid = entity.Physics as MyGridPhysics; var character = entity.Physics as MyPhysicsBody; if (IsDynamicGrid(rb, grid) || IsCharacter(rb, character)) { using (m_nearbyEntitiesLock.AcquireExclusiveUsing()) { if (character != null) { MyTrace.Send(TraceWindow.Analytics, string.Format("{0} Removed character", character.Entity.EntityId)); } //unreliable //Debug.Assert(m_nearbyEntities.Contains(entity), "Removing entity which was not added"); m_nearbyEntities.Remove(entity); } } } entities.Clear(); }
private void AabbPhantom_CollidableAdded(ref Havok.HkpCollidableAddedEvent eventData) { var rb = eventData.RigidBody; if (rb == null) // ignore phantoms return; var entities = rb.GetAllEntities(); foreach (var entity in entities) { var grid = entity.Physics as MyGridPhysics; var character = entity.Physics as MyPhysicsBody; // I get both rigid bodies reported but they don't match, I will only track RB 1 if (IsDynamicGrid(rb, grid) || IsCharacter(rb, character)) { using (m_nearbyEntitiesLock.AcquireExclusiveUsing()) { //unreliable //Debug.Assert(!m_nearbyEntities.Contains(entity), "Entity added twice"); m_nearbyEntities.Add(entity); } } } entities.Clear(); }