private void AddPostedFiles(Player player) { if (Request.Files.Count == 0) { return; } // assume only 1 file posted HttpPostedFileBase hpf = Request.Files[0] as HttpPostedFileBase; if (hpf.ContentLength == 0) { return; } string extension = Path.GetExtension(hpf.FileName); string newFileName = Guid.NewGuid().ToString() + extension; var blob = this.blobAgent.GetContainer().GetBlobReference(newFileName); blob.Properties.ContentType = BlobAgent.GetContentTypeFromExtension(extension); blob.UploadFromStream(hpf.InputStream); player.PhotoUri = blob.Uri.AbsolutePath; //string serverFileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "roster-images", newFileName); //hpf.SaveAs(serverFileName); //player.PhotoUri = "/roster-images/" + newFileName; }
public void SetBlobList(List <Transform> blobs) { allBlobs = blobs; foreach (Transform blob in allBlobs) { BlobAgent blobAgent = blob.GetComponent <BlobAgent>(); blobAgent.blobSaved += BlobSaved; blobAgent.blobDied += BlobDied; } totalBlobCounter = allBlobs.Count; }
public void BlobSaved(BlobAgent blobAgent) { blobSavedCounter++; blobAgent.state = BlobAgent.BlobState.InGoal; CheckGameOver(); }
public void BlobDied(BlobAgent blobAgent) { blobDiedCounter++; blobAgent.state = BlobAgent.BlobState.Dead; CheckGameOver(); }
public static void Run([TimerTrigger("0 */2 * * * *")] TimerInfo myTimer, ILogger log) { log.LogInformation($"Function executed at: {DateTime.Now}"); // Meraki dashboard parameters var apiKey = Environment.GetEnvironmentVariable("MerakiApiKey"); var networkId = Environment.GetEnvironmentVariable("MerakiNetworkId"); var targetIp = Environment.GetEnvironmentVariable("MerakiTargetIp"); var timespan = Environment.GetEnvironmentVariable("MerakiProbeTimespan"); // UDR parameters AadCredential cred = new AadCredential() { TenantId = Environment.GetEnvironmentVariable("AadTenantId"), ClientId = Environment.GetEnvironmentVariable("AadClientId"), ClientSecret = Environment.GetEnvironmentVariable("AadClientSecret") }; var subscription = Environment.GetEnvironmentVariable("AzSubscriptionId"); // route table parameters var udrrg = Environment.GetEnvironmentVariable("AzRouteTableResourceGroup"); var routeTableName = Environment.GetEnvironmentVariable("AzRouteTableName"); var routeNames = JsonConvert.DeserializeObject <List <object> >(Environment.GetEnvironmentVariable("AzRouteNames")); // Blob Storage Parameters var blobCnString = Environment.GetEnvironmentVariable("BlobCnString"); var container = Environment.GetEnvironmentVariable("BlobContainerName"); var blobname = Environment.GetEnvironmentVariable("BlobName"); // Log Analytics parameters var workspaceId = Environment.GetEnvironmentVariable("LogAnalyticsWorkspaceId"); var workspaceKey = Environment.GetEnvironmentVariable("LogAnalyticsWorkspaceKey"); // max loss percent var maxLossPercent = Environment.GetEnvironmentVariable("MaxLossPercent"); // create all dependency injection objects IGetLossLatency probe = new ProbeAgent(apiKey, targetIp); IDefineRoute router = new RouteAgent(cred, subscription); IPersistFailover blob = new BlobAgent(blobCnString, container, blobname); ILog logger = new AzMonLogger(workspaceId, workspaceKey); // constructor List <RouteInfo> routes = new List <RouteInfo>(); foreach (var routeName in routeNames) { routes.Add(new RouteInfo() { ResourceGroup = udrrg, RouteTableName = routeTableName, RouteName = routeName.ToString() }); } MerakiHaAgent agent = new MerakiHaAgent(probe, router, blob, logger, routes); // Probe and failover if needed var activeProbe = agent.CanProbeActive(int.Parse(maxLossPercent)); var standbyProbe = agent.CanProbeStandby(int.Parse(maxLossPercent)); // Don't failover if both nodes are unreachable if (!activeProbe && standbyProbe) { var result = agent.Failover(int.Parse(maxLossPercent)); log.LogInformation("Loss={0}, Failover={1}, Message={2}", result.lossPercent, result.Failover, result.Message ?? "OK"); } // Both nodes are down, don't failover but alert if (!activeProbe && !standbyProbe) { log.LogCritical("Loss={0}, Failover={1}, Message={2}", "100", "false", "Both nodes unreachable, will not failover."); } }