/// <summary>
        /// Generates the error report.
        /// </summary>
        /// <param name="id">The identifier.</param>
        /// <returns>
        /// the error report
        /// </returns>
        public string GenerateErrorReport(string id)
        {
            using (new LanguageSwitcher(Language.Parse("en")))
            {
                using (new DatabaseSwitcher(Factory.GetDatabase("master")))
                {
                    using (new SecurityDisabler())
                    {
                        var component = Sitecore.Context.Database.GetItem(new ID(id));

                        var componentHealth = new ComponentHealth(component);

                        StringBuilder sb = new StringBuilder();

                        sb.AppendLine("Created,Reason,Exception");

                        foreach (var error in componentHealth.ErrorList.Entries.OrderByDescending(t => t.Created))
                        {
                            sb.AppendLine(string.Format("{0},{1},{2}",
                                                        EscapeSpecialCharacters(error.Created.ToString()),
                                                        EscapeSpecialCharacters(error.Reason),
                                                        EscapeSpecialCharacters(error.Exception != null ? error.Exception.ToString() : string.Empty)));
                        }

                        return(sb.ToString());
                    }
                }
            }
        }
        private static Mock <IGetComponentHealth> BuildCommand(ComponentHealth result)
        {
            var mock = new Mock <IGetComponentHealth>();

            mock
            .Setup(instance => instance.Execute(Unit.Default))
            .Returns(Observable.Return(result));

            return(mock);
        }
예제 #3
0
 public void TakeComponentDamage(ComponentHealth ch)
 {
     currentHealth -= 1;
     components.Remove(ch);
     Damage();
     if (currentHealth <= 0)
     {
         Die();
     }
 }
예제 #4
0
    // Use this for initialization
    void Start()
    {
        // Use 1x1 pixels to draw the health bars
        m_Background = new Texture2D(1, 1);
        m_Background.SetPixel(0, 0, Color.red);
        m_Background.Apply();
        m_Foreground = new Texture2D(1, 1);
        m_Foreground.SetPixel(0, 0, Color.green);
        m_Foreground.Apply();

        m_Health = GetComponent <ComponentHealth>();
    }
        /// <summary>Creates the table row.</summary>
        /// <param name="componentHealth">The component health.</param>
        private void CreateTableRow(ComponentHealth componentHealth)
        {
            // Add report table row
            var message  = componentHealth.ErrorCount > 0 && componentHealth.Status != Customization.HealthcheckStatus.Healthy ? componentHealth.ErrorList.Entries[0].Reason : componentHealth.HealthyMessage;
            var rowStyle = GetRowStyle(componentHealth.Status.ToString());

            mailBodyBuilder.AppendLine($"<tr style=\"{rowStyle}\">");

            mailBodyBuilder.Append($"<td style=\"{Styles.td}\">{componentHealth.Name}</td>");
            mailBodyBuilder.Append($"<td style=\"{Styles.td}\">{componentHealth.LastCheckTime}</td>");
            mailBodyBuilder.Append($"<td style=\"{Styles.td}\">{componentHealth.Status}</td>");
            mailBodyBuilder.Append($"<td style=\"{Styles.td}\">{message}</td>");

            mailBodyBuilder.AppendLine("</tr>");
        }
예제 #6
0
        private void PowerUp(ComponentHealth h, ComponentAmmo a, ComponentPickUp up, ComponentAlive alive)
        {
            h.Health += up.Pick_health;
            a.Ammo   += up.Pick_ammo;


            if (up.Pick_health == h.Health)
            {
                Delete(alive);
            }
            if (up.Pick_ammo == a.Ammo)
            {
                Delete(alive);
            }
        }
예제 #7
0
 /// <summary>Determines whether the componentHealth is valid for reporting.</summary>
 /// <param name="componentHealth">The component health.</param>
 /// <returns>
 ///   <c>true</c> if [is valid for reporting] [the specified component health]; otherwise, <c>false</c>.
 /// </returns>
 public static bool IsValidForReporting(this ComponentHealth componentHealth, SettingsModel settingsModel)
 {
     if (componentHealth.Status == Customization.HealthcheckStatus.Error && settingsModel.ErrorLevel == Customization.HealthcheckStatus.Error)
     {
         return(true);
     }
     else if ((componentHealth.Status == Customization.HealthcheckStatus.Warning || componentHealth.Status == Customization.HealthcheckStatus.Error) && settingsModel.ErrorLevel == Customization.HealthcheckStatus.Error)
     {
         return(true);
     }
     else if (settingsModel.ErrorLevel == Customization.HealthcheckStatus.Healthy)
     {
         return(true);
     }
     return(false);
 }
예제 #8
0
    // Use this for initialization
    public void init(GameController gContr, float x, float y, float quadR, float quadG, float quadB)
    {
        controller = gContr;
        healthBar = gameObject.transform.parent.FindChild("Health").GetComponent<ComponentHealth> ();
        captain = GameObject.Find ("Crew").GetComponent<MoveCaptain> ();
        healthBar = gameObject.transform.parent.FindChild ("Health").GetComponent<ComponentHealth> ();
        controller.MakeSprite (gameObject, "Button", transform.parent, 0, 0, 1, 1, 300);
        gameObject.name = "Button";
        gameObject.GetComponent<SpriteRenderer> ().sortingLayerName = "BottomRhsUI";
        gameObject.transform.localPosition = new Vector3 (x, y, 0);
        gameObject.AddComponent<BoxCollider2D> ();

        sprite = GetComponent<SpriteRenderer> ();
        darkenSprite = (.7f);
        upColor = new Color (quadR, quadG, quadB);
        downColor = new Color (quadR*darkenSprite, quadG*darkenSprite, quadB*darkenSprite);
        sprite.color = upColor;
    }
        /// <summary>
        /// Clears all errors entries but last
        /// </summary>
        /// <returns>true if the entries have been cleared, false otherwise</returns>
        private bool ClearButLastErrorEntry(ComponentHealth componentHealth)
        {
            // get last error entry
            var indexOfLastEntry = componentHealth.ErrorList.Entries.Count - 1;

            if (indexOfLastEntry > -1)
            {
                var lastErrorEntry = componentHealth.ErrorList.Entries[indexOfLastEntry];

                // clear the error list and add the last entry
                componentHealth.ErrorList.Entries.Clear();
                componentHealth.ErrorList.Entries.Add(lastErrorEntry);
                componentHealth.ErrorCount = componentHealth.ErrorList.Entries.Count;

                return(true);
            }

            return(false);
        }
예제 #10
0
파일: Ship.cs 프로젝트: jackson-laskey/JERF
	public void init (GameController gContr) {
		controller = gContr;
		gameObject.AddComponent<Rigidbody2D> ().isKinematic = true;
		gameObject.AddComponent<BoxCollider2D> ().isTrigger = true;
		transform.localPosition = new Vector3 (-3.2f, -4, 0);
		gameObject.name = "Ship";
		tag = "PlayerController";

		laserLevel = GameObject.Find("Lasers").GetComponentInChildren<LaserHealth>();
		shieldLevel = GameObject.Find("Shields").GetComponentInChildren<ComponentHealth>();
		engineLevel = GameObject.Find("Engines").GetComponentInChildren<ComponentHealth>();
<<<<<<< HEAD
		animator = this.GetComponent<Animator> ();
		animator.SetInteger ("Direction", 0);
		jets = Jet.GetComponent<Animator> ();
		jets.SetInteger ("Direction", 0);
		jets.SetInteger ("Power", 3);
=======
		JET = GameObject.Find ("Jets");
		direction = this.gameObject.GetComponent<Animator> ();
//		jets = JET.GetComponent<Animator> ();

<<<<<<< HEAD
>>>>>>> PrefabsToCode


		direction.SetInteger ("Direction", 0);
		jets.SetInteger ("Power", 3);
=======
//		direction.SetInteger ("Direction", 0);
//		jets.SetInteger ("Power", 3);
>>>>>>> origin/PrefabsToCode
		// loads template for laser prefab instantiation


		// clock tracks time passed, ship fires when clock passes threshold. clock then resets.
		clock = 0;
		fireInterval = 32f;

		initd = true;
	}
예제 #11
0
        public Player()
        {
            LastLevel = 0;

            AddComponent(new ComponentMove());
            var health = new ComponentHealth(3)
            {
                ShowHealthBar = false, NaturalRegeneration = true
            };

            health.Killed += Health_Killed;
            AddComponent(health);

            AddComponent(new ComponentLightSource {
                IsOn = true, Color = Color.White * 0.50f, Power = 64
            });
            AddComponent(new RendererCreature(Resources.Sprites["entity/player"], Resources.Sprites["entity/player_lifting"]));
            AddComponent(new ComponentFlammable());
            AddComponent(new ComponentItemHolder());

            AddComponent(new ComponentAttack());
            AddComponent(new ComponentCollider(new Rectangle(-2, -2, 4, 4)));
            AddComponent(new ComponentEnergy());
            AddComponent(new ComponentInteract());
            AddComponent(new ComponentInventory(64)
            {
                AlowPickUp = true
            });
            AddComponent(new ComponentMove());
            AddComponent(new ComponentPickup());
            AddComponent(new ComponentPushable());
            AddComponent(new ComponentRevealMap());
            AddComponent(new ComponentCastShadow());
            AddComponent(new ComponentSwim());
            AddComponent(new ComponentPlayerBody());
            AddComponent(new CircleMenu());
            AddComponent(new ComponentExperience());
        }
        /// <summary>
        /// Saves the healthcheck related component's fields.
        /// </summary>
        /// <param name="componentHealth">Holds data that needs to be saved</param>
        public void SaveComponent(ComponentHealth componentHealth)
        {
            Item item;

            using (new DatabaseSwitcher(Factory.GetDatabase(Healthcheck.Service.Core.Constants.MasterDatabaseName)))
            {
                item = Context.Database.GetItem(new ID(componentHealth.Id));
            }

            if (item != null)
            {
                using (new SecurityDisabler())
                {
                    using (new EditContext(item))
                    {
                        item["Status"]          = componentHealth.Status == HealthcheckStatus.UnKnown ? string.Empty : componentHealth.Status.ToString();
                        item["Error Messages"]  = JsonUtil.GetErrorMessagesJson(componentHealth.ErrorList);
                        item["Healthy Message"] = componentHealth.HealthyMessage;
                        item["Last Check Time"] = DateUtil.FormatDateTime(componentHealth.LastCheckTime, "yyyyMMddTHHmmss", CultureInfo.InvariantCulture);
                    }
                }
            }
        }
예제 #13
0
        public void Execute_ResultHasRightDuration_WhenCommandFailed()
        {
            ComponentHealth actual = _failInstance.Execute(Unit.Default).Wait();

            actual.Duration.ShouldNotBeNullOrEmpty();
        }
예제 #14
0
        public void Execute_ResultHasRightPassed_WhenCommandFailed()
        {
            ComponentHealth actual = _failInstance.Execute(Unit.Default).Wait();

            actual.Passed.ShouldBeFalse();
        }
예제 #15
0
        public void Execute_ResultHasRightPassed_WhenCommandSucceeded()
        {
            ComponentHealth actual = _instance.Execute(Unit.Default).Wait();

            actual.Passed.ShouldBeTrue();
        }
예제 #16
0
        public void Execute_ResultHasRightMessage_WhenCommandFailed()
        {
            ComponentHealth actual = _failInstance.Execute(Unit.Default).Wait();

            actual.Message.ShouldStartWith(FailMessage);
        }
예제 #17
0
        public void Execute_ResultHasRightMessage_WhenCommandSucceeded()
        {
            ComponentHealth actual = _instance.Execute(Unit.Default).Wait();

            actual.Message.ShouldBe(SuccessMessage);
        }
예제 #18
0
        public void Execute_ResultHasRightName_WhenCommandFailed()
        {
            ComponentHealth actual = _failInstance.Execute(Unit.Default).Wait();

            actual.Name.ShouldBe(Name);
        }
        /// <summary>
        /// Limits the error entries.
        /// </summary>
        /// <param name="component">The component.</param>
        /// <returns>
        /// Filtered component
        /// </returns>
        private ComponentHealth LimitErrorEntries(ComponentHealth component)
        {
            component.ErrorList.Entries = component.ErrorList.Entries.OrderByDescending(t => t.Created).Take(100).ToList();

            return(component);
        }