private static GitStatusState GetEnvState(EnvironmentStatus env) { switch (env) { case EnvironmentStatus.Undefined: case EnvironmentStatus.NotStarted: return(GitStatusState.NotSet); case EnvironmentStatus.Scheduled: case EnvironmentStatus.Queued: case EnvironmentStatus.InProgress: return(GitStatusState.Pending); case EnvironmentStatus.PartiallySucceeded: case EnvironmentStatus.Succeeded: return(GitStatusState.Succeeded); case EnvironmentStatus.Canceled: case EnvironmentStatus.Rejected: return(GitStatusState.Failed); default: return(GitStatusState.Error); } }
private SolutionDeploy.Core.DeploymentStatus DoGetReleaseEnvironmentStatus(int releaseId, int environmentId) { Release release = this.releaseClient.GetRelease(releaseId, this.accessToken); if (release == null) { return(SolutionDeploy.Core.DeploymentStatus.Unknown); } ReleaseEnvironment releaseEnvironment = release.Environments.FirstOrDefault(e => e.Id == environmentId); if (releaseEnvironment == null) { return(SolutionDeploy.Core.DeploymentStatus.Unknown); } EnvironmentStatus environmentStatus = releaseEnvironment.Status; if (environmentStatus == EnvironmentStatus.InProgress) { return(this.CheckForPendingApprovals(releaseId)); } return(GetDeploymentStatus(environmentStatus)); }
private ReleaseEnvironment GetTestEnvironment(EnvironmentStatus status) { ReleaseEnvironment releaseEnvironment = new ReleaseEnvironment { Status = status }; return(releaseEnvironment); }
/// <summary> /// Game has ended. /// </summary> private void Finished() { Receive <string>(msg => msg == "new", msg => { using (Logger.Log(CONTEXT, "Switching to `Ready`")) { Status = EnvironmentStatus.Ready; Become(Ready); } }); BaseOperations(); }
private Release GetTestRelease(EnvironmentStatus status) { Release release = new Release { Environments = new List <ReleaseEnvironment> { new ReleaseEnvironment { Id = 123, Name = "Environment1", Status = status } } }; return(release); }
/// <summary> /// Currently registering players. /// </summary> private void Registering() { Receive <string>(msg => msg == "begin", msg => { using (Logger.Log(CONTEXT, "Switching to `Active`")) { Status = EnvironmentStatus.Active; foreach (var dragon in DragonActors) { dragon.Value.Tell("begin"); } ServiceController.PushStatus(); Become(Active); } }); BaseOperations(); }
/// <summary> /// Game is currently in progress. /// </summary> private void Active() { Receive <HeroAttackMessage>(msg => { using (Logger.Log(CONTEXT, "Player attacks the dragon")) { HeroActors[msg.Hero].Forward(msg); } }); Receive <HeroDefendMessage>(msg => { using (Logger.Log(CONTEXT, "Player defending")) { HeroActors[msg.Hero].Forward(msg); } }); Receive <DragonAttackMessage>(msg => { using (Logger.Log(CONTEXT, "Dragon attacks")) { var keys = HeroActors.Keys.ToList(); var random = new Random(); var randomHero = keys[random.Next(keys.Count)]; var hero = HeroActors[randomHero]; hero.Tell(msg); ServiceController.PushMessage(MessageTypes.Dragon, Sender.Path.Name, $"`{Sender.Path.Name}` the dragon attacks `@{hero.Path.Name}`"); } }); Receive <string>(msg => msg == "weak", msg => { using (Logger.Log(CONTEXT, $"`{Sender.Path.Name}` the dragon looks pretty weak right now")) { ServiceController.PushMessage(MessageTypes.System, Sender.Path.Name, $"`{Sender.Path.Name}` the dragon looks weak now..."); } }); Receive <string>(msg => msg == "died", msg => { using (Logger.Log(CONTEXT, $"`{Sender.Path.Name}` the dragon had died")) { var results = DragonActors.Select(dragonActor => dragonActor.Value.Ask <bool>("alive").Result).ToList(); if (results.TrueForAll(alive => alive == false)) { ServiceController.PushMessage(MessageTypes.System, Sender.Path.Name, $"The dragons have been defeated!"); Self.Tell("finish"); } } }); Receive <string>(msg => msg == "finish", msg => { using (Logger.Log(CONTEXT, "Switching to `Finished`")) { Status = EnvironmentStatus.Finished; ServiceController.PushStatus(); Become(Finished); } }); BaseOperations(); }
/// <summary> /// The pre-start event hook. /// </summary> protected override void PreStart() { Status = EnvironmentStatus.Ready; DragonActors = new Dictionary <string, IActorRef> { { "bahamut", Context.ActorOf(Props.Create(() => new Dragon(Logger)), "bahamut") }, { "enywas", Context.ActorOf(Props.Create(() => new Dragon(Logger)), "enywas") } }; HeroActors = new Dictionary <string, IActorRef>(); // Add event subscription for the dragons foreach (var dragon in DragonActors.Values) { Context.System.EventStream.Subscribe(dragon, typeof(ResetMessage)); } }
/// <summary> /// Base actor operations. /// </summary> private void BaseOperations() { Receive <HeroRegisterMessage>(msg => { using (Logger.Log(CONTEXT, "WARN: Player registration outside of `Ready` state")) { Sender.Tell(false); } }); Receive <string>(msg => msg == "status", msg => { using (Logger.Log(CONTEXT, "Reporting the environment status")) { Sender.Tell(Tuple.Create(Status, HeroActors.Keys.ToArray(), DragonActors.Keys.ToArray())); } }); Receive <string>(msg => msg == "reset", msg => { using (Logger.Log(CONTEXT, "Switching to `Ready`")) { Status = EnvironmentStatus.Ready; Context.System.EventStream.Publish(new ResetMessage()); Become(Ready); } }); }
internal void GetReleaseEnvironmentStatus_GetsEnvironment_ReturnsStatus( EnvironmentStatus envStatus, SolutionDeploy.Core.DeploymentStatus deployStatus) { IVstsReleaseClient releaseClient = Substitute.For <IVstsReleaseClient>(); IAuthenticator authenticator = Substitute.For <IAuthenticator>(); VstsConfig vstsConfig = new VstsConfig(); authenticator.Authenticate().Returns(new AuthenticationResult { Success = true }); releaseClient.GetRelease(Arg.Any <int>(), Arg.Any <string>()) .Returns(this.GetTestRelease(envStatus)); this.sut = new VstsReleaseRepository(releaseClient, authenticator, vstsConfig); SolutionDeploy.Core.DeploymentStatus result = this.sut.GetReleaseEnvironmentStatus("123", "123"); Assert.Equal(deployStatus, result); }
/// <summary> /// Environment is initialised / reset and is ready. /// </summary> private void Ready() { Receive <HeroRegisterMessage>(msg => { using (Logger.Log(CONTEXT, "Registering player")) { if (HeroActors.ContainsKey(msg.Slug)) { Sender.Tell(false); } else { HeroActors.Add(msg.Slug, Context.ActorOf(Props.Create(() => new Hero(Logger)), msg.Slug)); Sender.Tell(true); } } }); Receive <HeroDeregisterMessage>(msg => { using (Logger.Log(CONTEXT, "Deregistering player")) { if (HeroActors.ContainsKey(msg.Hero)) { HeroActors[msg.Hero].Tell(PoisonPill.Instance); HeroActors.Remove(msg.Hero); Sender.Tell(true); } else { Sender.Tell(false); } } }); Receive <string>(msg => msg == "start", msg => { using (Logger.Log(CONTEXT, "Switching to `Registering`")) { Context.System.Scheduler.ScheduleTellOnce( TimeSpan.FromSeconds(10), Self, "begin", Self); Status = EnvironmentStatus.Registering; Become(Registering); } }); BaseOperations(); }
private static SolutionDeploy.Core.DeploymentStatus GetDeploymentStatus(EnvironmentStatus status) { switch (status) { case EnvironmentStatus.Canceled: return(SolutionDeploy.Core.DeploymentStatus.Cancelled); case EnvironmentStatus.NotStarted: return(SolutionDeploy.Core.DeploymentStatus.NotStarted); case EnvironmentStatus.PartiallySucceeded: return(SolutionDeploy.Core.DeploymentStatus.Failed); case EnvironmentStatus.Queued: return(SolutionDeploy.Core.DeploymentStatus.Queued); case EnvironmentStatus.Rejected: return(SolutionDeploy.Core.DeploymentStatus.Failed); case EnvironmentStatus.Scheduled: return(SolutionDeploy.Core.DeploymentStatus.Queued); case EnvironmentStatus.Succeeded: return(SolutionDeploy.Core.DeploymentStatus.Succeeded); case EnvironmentStatus.Undefined: return(SolutionDeploy.Core.DeploymentStatus.Unknown); default: return(SolutionDeploy.Core.DeploymentStatus.Unknown); } }
protected override int OnExecute(CommandLineApplication app) { base.OnExecute(app); EnvironmentStatus filterStatus = EnvironmentStatus.Undefined; if (this.EnvironmentStatusFilter != null) { Enum.TryParse( value: string.Join(',', this.EnvironmentStatusFilter), ignoreCase: true, out filterStatus); } var releaseListRequest = new ReleaseListRequest(this.ExpandPropterties) { ReleaseDefinitionId = this.ReleaseDefinitionId, DefinitionEnvironmentId = this.DefinitionEnvironmentId, Top = this.Top, EnvironmentStatusFilter = filterStatus, }; IEnumerable <Release> releases = this.DevOpsClient.Release.GetAllAsync(this.ProjectName, releaseListRequest).GetAwaiter().GetResult(); if (this.IncludeAllProperties) { this.PrintOrExport(releases.OrderByDescending(r => r.Id)); } else { this.PrintOrExport(releases.Select(r => new { r.Id, r.Name }) .OrderByDescending(r => r.Id)); } return(ExitCodes.Ok); }
/// <summary> /// Wraps sending messages to the connected descriptor /// </summary> /// <param name="strings">the output</param> /// <returns>success status</returns> public bool SendOutput(IEnumerable <string> strings) { //TODO: Stop hardcoding this but we have literally no sense of injury/self status yet SelfStatus self = new SelfStatus { Body = new BodyStatus { Health = _currentPlayer.CurrentHealth == 0 ? 100 : 100 / (2M * _currentPlayer.CurrentHealth), Stamina = _currentPlayer.CurrentStamina, Overall = OverallStatus.Excellent, Anatomy = new AnatomicalPart[] { new AnatomicalPart { Name = "Arm", Overall = OverallStatus.Good, Wounds = new string[] { "Light scrape" } }, new AnatomicalPart { Name = "Leg", Overall = OverallStatus.Excellent, Wounds = new string[] { } } } }, CurrentActivity = _currentPlayer.CurrentAction, Balance = _currentPlayer.Balance.ToString(), CurrentArt = _currentPlayer.LastAttack?.Name ?? "", CurrentCombo = _currentPlayer.LastCombo?.Name ?? "", CurrentTarget = _currentPlayer.GetTarget() == null ? "" : _currentPlayer.GetTarget() == _currentPlayer ? "Your shadow" : _currentPlayer.GetTarget().GetDescribableName(_currentPlayer), CurrentTargetHealth = _currentPlayer.GetTarget() == null || _currentPlayer.GetTarget() == _currentPlayer ? double.PositiveInfinity : _currentPlayer.GetTarget().CurrentHealth == 0 ? 100 : 100 / (2 * _currentPlayer.CurrentHealth), Position = _currentPlayer.StancePosition.ToString(), Stance = _currentPlayer.Stance, Stagger = _currentPlayer.Stagger.ToString(), Qualities = string.Join("", _currentPlayer.Qualities.Where(quality => quality.Visible).Select(quality => string.Format("<div class='qualityRow'><span>{0}</span><span>{1}</span></div>", quality.Name, quality.Value))), CurrentTargetQualities = _currentPlayer.GetTarget() == null || _currentPlayer.GetTarget() == _currentPlayer ? "" : string.Join("", _currentPlayer.GetTarget().Qualities.Where(quality => quality.Visible).Select(quality => string.Format("<div class='qualityRow'><span>{0}</span><span>{1}</span></div>", quality.Name, quality.Value))), Mind = new MindStatus { Overall = OverallStatus.Excellent, States = new string[] { "Fearful" } } }; IGlobalPosition currentLocation = _currentPlayer.CurrentLocation; IContains currentContainer = currentLocation.CurrentLocation(); IZone currentZone = currentContainer.CurrentLocation.CurrentZone; ILocale currentLocale = currentLocation.CurrentLocale; IRoom currentRoom = currentLocation.CurrentRoom; IGaia currentWorld = currentZone.GetWorld(); IEnumerable <string> pathways = Enumerable.Empty <string>(); IEnumerable <string> inventory = Enumerable.Empty <string>(); IEnumerable <string> populace = Enumerable.Empty <string>(); string locationDescription = string.Empty; LexicalContext lexicalContext = new LexicalContext(_currentPlayer) { Language = _currentPlayer.Template <IPlayerTemplate>().Account.Config.UILanguage, Perspective = NarrativePerspective.SecondPerson, Position = LexicalPosition.Near }; Message toCluster = new Message(currentContainer.RenderToVisible(_currentPlayer)); if (currentContainer != null) { pathways = ((ILocation)currentContainer).GetPathways().Select(data => data.GetDescribableName(_currentPlayer)); inventory = currentContainer.GetContents <IInanimate>().Select(data => data.GetDescribableName(_currentPlayer)); populace = currentContainer.GetContents <IMobile>().Where(player => !player.Equals(_currentPlayer)).Select(data => data.GetDescribableName(_currentPlayer)); locationDescription = toCluster.Unpack(TargetEntity.Actor, lexicalContext); } LocalStatus local = new LocalStatus { ZoneName = currentZone?.TemplateName, LocaleName = currentLocale?.TemplateName, RoomName = currentRoom?.TemplateName, Inventory = inventory.ToArray(), Populace = populace.ToArray(), Exits = pathways.ToArray(), LocationDescriptive = locationDescription }; //The next two are mostly hard coded, TODO, also fix how we get the map as that's an admin thing ExtendedStatus extended = new ExtendedStatus { Horizon = new string[] { "A hillside", "A dense forest" }, VisibleMap = currentLocation.CurrentRoom == null ? string.Empty : currentLocation.CurrentRoom.RenderCenteredMap(3, true) }; string timeOfDayString = string.Format("The hour of {0} in the day of {1} in {2} in the year of {3}", currentWorld.CurrentTimeOfDay.Hour , currentWorld.CurrentTimeOfDay.Day , currentWorld.CurrentTimeOfDay.MonthName() , currentWorld.CurrentTimeOfDay.Year); string sun = "0"; string moon = "0"; string visibilityString = "5"; Tuple <string, string, string[]> weatherTuple = new Tuple <string, string, string[]>("", "", new string[] { }); if (currentZone != null) { Tuple <PrecipitationAmount, PrecipitationType, HashSet <WeatherType> > forecast = currentZone.CurrentForecast(); weatherTuple = new Tuple <string, string, string[]>(forecast.Item1.ToString(), forecast.Item2.ToString(), forecast.Item3.Select(wt => wt.ToString()).ToArray()); visibilityString = currentZone.GetCurrentLuminosity().ToString(); if (currentWorld != null) { IEnumerable <ICelestial> bodies = currentZone.GetVisibileCelestials(_currentPlayer); ICelestial theSun = bodies.FirstOrDefault(cest => cest.Name.Equals("sun", StringComparison.InvariantCultureIgnoreCase)); ICelestial theMoon = bodies.FirstOrDefault(cest => cest.Name.Equals("moon", StringComparison.InvariantCultureIgnoreCase)); if (theSun != null) { ICelestialPosition celestialPosition = currentWorld.CelestialPositions.FirstOrDefault(celest => celest.CelestialObject == theSun); sun = AstronomicalUtilities.GetCelestialLuminosityModifier(celestialPosition.CelestialObject, celestialPosition.Position, currentWorld.PlanetaryRotation , currentWorld.OrbitalPosition, currentZone.Template <IZoneTemplate>().Hemisphere, currentWorld.Template <IGaiaTemplate>().RotationalAngle).ToString(); } if (theMoon != null) { ICelestialPosition celestialPosition = currentWorld.CelestialPositions.FirstOrDefault(celest => celest.CelestialObject == theMoon); moon = AstronomicalUtilities.GetCelestialLuminosityModifier(celestialPosition.CelestialObject, celestialPosition.Position, currentWorld.PlanetaryRotation , currentWorld.OrbitalPosition, currentZone.Template <IZoneTemplate>().Hemisphere, currentWorld.Template <IGaiaTemplate>().RotationalAngle).ToString(); } } } EnvironmentStatus environment = new EnvironmentStatus { Sun = sun, Moon = moon, Visibility = visibilityString, Weather = weatherTuple, Temperature = currentZone.EffectiveTemperature().ToString(), Humidity = currentZone.EffectiveHumidity().ToString(), TimeOfDay = timeOfDayString }; OutputStatus outputFormat = new OutputStatus { Occurrence = EncapsulateOutput(strings), Self = self, Local = local, Extended = extended, Environment = environment }; Send(Utility.SerializationUtility.Serialize(outputFormat)); return(true); }
/// <summary> /// Base actor operations. /// </summary> private void BaseOperations() { Receive<HeroRegisterMessage>(msg => { using (Logger.Log(CONTEXT, "WARN: Player registration outside of `Ready` state")) { Sender.Tell(false); }}); Receive<string>(msg => msg == "status", msg => { using (Logger.Log(CONTEXT, "Reporting the environment status")) { Sender.Tell(Tuple.Create(Status, HeroActors.Keys.ToArray(), DragonActors.Keys.ToArray())); }}); Receive<string>(msg => msg == "reset", msg => { using (Logger.Log(CONTEXT, "Switching to `Ready`")) { Status = EnvironmentStatus.Ready; Context.System.EventStream.Publish(new ResetMessage()); Become(Ready); }}); }
/// <summary> /// Game is currently in progress. /// </summary> private void Active() { Receive<HeroAttackMessage>(msg => { using (Logger.Log(CONTEXT, "Player attacks the dragon")) { HeroActors[msg.Hero].Forward(msg); }}); Receive<HeroDefendMessage>(msg => { using (Logger.Log(CONTEXT, "Player defending")) { HeroActors[msg.Hero].Forward(msg); }}); Receive<DragonAttackMessage>(msg => { using (Logger.Log(CONTEXT, "Dragon attacks")) { var keys = HeroActors.Keys.ToList(); var random = new Random(); var randomHero = keys[random.Next(keys.Count)]; var hero = HeroActors[randomHero]; hero.Tell(msg); ServiceController.PushMessage(MessageTypes.Dragon, Sender.Path.Name, $"`{Sender.Path.Name}` the dragon attacks `@{hero.Path.Name}`"); }}); Receive<string>(msg => msg == "weak", msg => { using (Logger.Log(CONTEXT, $"`{Sender.Path.Name}` the dragon looks pretty weak right now")) { ServiceController.PushMessage(MessageTypes.System, Sender.Path.Name, $"`{Sender.Path.Name}` the dragon looks weak now..."); }}); Receive<string>(msg => msg == "died", msg => { using (Logger.Log(CONTEXT, $"`{Sender.Path.Name}` the dragon had died")) { var results = DragonActors.Select(dragonActor => dragonActor.Value.Ask<bool>("alive").Result).ToList(); if (results.TrueForAll(alive => alive == false)) { ServiceController.PushMessage(MessageTypes.System, Sender.Path.Name, $"The dragons have been defeated!"); Self.Tell("finish"); } }}); Receive<string>(msg => msg == "finish", msg => { using (Logger.Log(CONTEXT, "Switching to `Finished`")) { Status = EnvironmentStatus.Finished; ServiceController.PushStatus(); Become(Finished); }}); BaseOperations(); }
/// <summary> /// Currently registering players. /// </summary> private void Registering() { Receive<string>(msg => msg == "begin", msg => { using (Logger.Log(CONTEXT, "Switching to `Active`")) { Status = EnvironmentStatus.Active; foreach (var dragon in DragonActors) { dragon.Value.Tell("begin"); } ServiceController.PushStatus(); Become(Active); }}); BaseOperations(); }
/// <summary> /// The pre-start event hook. /// </summary> protected override void PreStart() { Status = EnvironmentStatus.Ready; DragonActors = new Dictionary<string, IActorRef> { { "bahamut", Context.ActorOf(Props.Create(() => new Dragon(Logger)), "bahamut") }, { "enywas", Context.ActorOf(Props.Create(() => new Dragon(Logger)), "enywas") } }; HeroActors = new Dictionary<string, IActorRef>(); // Add event subscription for the dragons foreach (var dragon in DragonActors.Values) { Context.System.EventStream.Subscribe(dragon, typeof(ResetMessage)); } }
private void ZvtEnvironmentOnStatusReceived(IntermediateStatus status) { EnvironmentStatus?.Invoke(status); }
public async Task <string> UpdateEnvironmentAsync(string projectName, int releaseId, int environmentId, EnvironmentStatus status, string comments) { var parameters = new Dictionary <string, object>(); FluentDictionary.For(parameters) .Add("api-version", "5.0-preview.6"); var endPointUrl = new Uri($"{projectName}/{EndPoint}/{releaseId}/environments/{environmentId}", UriKind.Relative); var body = new UpdateEnvironmentRequest { Status = status, Comments = comments, }; var response = await this.Connection .Patch <string>(endPointUrl, body, parameters, null) .ConfigureAwait(false); return(response.Body); }
/// <summary> /// Environment is initialised / reset and is ready. /// </summary> private void Ready() { Receive<HeroRegisterMessage>(msg => { using (Logger.Log(CONTEXT, "Registering player")) { if (HeroActors.ContainsKey(msg.Slug)) { Sender.Tell(false); } else { HeroActors.Add(msg.Slug, Context.ActorOf(Props.Create(() => new Hero(Logger)), msg.Slug)); Sender.Tell(true); } }}); Receive<HeroDeregisterMessage>(msg => { using (Logger.Log(CONTEXT, "Deregistering player")) { if (HeroActors.ContainsKey(msg.Hero)) { HeroActors[msg.Hero].Tell(PoisonPill.Instance); HeroActors.Remove(msg.Hero); Sender.Tell(true); } else { Sender.Tell(false); } }}); Receive<string>(msg => msg == "start", msg => { using (Logger.Log(CONTEXT, "Switching to `Registering`")) { Context.System.Scheduler.ScheduleTellOnce( TimeSpan.FromSeconds(10), Self, "begin", Self); Status = EnvironmentStatus.Registering; Become(Registering); }}); BaseOperations(); }
public void SetEnvironmentStatus(EnvironmentStatus status) { try { using (ES1AutomationEntities context = new ES1AutomationEntities()) { TestEnvironment environment = context.TestEnvironments.Find(this.EnvironmentId); if (environment.EnvironmentStatus != EnvironmentStatus.Discard || status == EnvironmentStatus.Disposing)//We could not modify the environment status if it's discard, except to change it to disposing { ATFEnvironment.Log.logger.Debug(string.Format("Change Status for Env: {0}, {1} -> {2}", this.Name, this.EnvironmentStatus, status)); environment.Status = (int)status; environment.ModifyDate = DateTime.UtcNow; this.Status = (int)status; this.ModifyDate = environment.ModifyDate; context.Entry(environment).Property(p => p.Status).IsModified = true; context.Entry(environment).Property(p => p.ModifyDate).IsModified = true; context.SaveChanges(); } } } catch (Exception ex) { ATFEnvironment.Log.logger.Error(ex); } }
public static IList<TestEnvironment> GetEnvironmentByStatus(EnvironmentStatus status) { using (ES1AutomationEntities context = new ES1AutomationEntities()) { return context.TestEnvironments.Where(e => e.Status == (int)status).ToList<TestEnvironment>(); } }
/// <summary> /// Game has ended. /// </summary> private void Finished() { Receive<string>(msg => msg == "new", msg => { using (Logger.Log(CONTEXT, "Switching to `Ready`")) { Status = EnvironmentStatus.Ready; Become(Ready); }}); BaseOperations(); }