Skip to content

Instantly share code, notes, and snippets.

@sitefinitySDK
Last active November 30, 2022 15:02

Revisions

  1. @ivaneftimov ivaneftimov revised this gist Oct 21, 2015. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions SitefinityStatusHelper.cs
    Original file line number Diff line number Diff line change
    @@ -22,10 +22,10 @@ public static void WaitForSitefinityToStart(string testingInstanceUrl, double to
    DateTime startTime = DateTime.UtcNow;
    TimeSpan elapsedTime = new TimeSpan();
    HttpResponseMessage response;
    HttpClient client = new HttpClient();

    do
    {
    HttpClient client = new HttpClient();
    {
    response = client.Get(testingInstanceUrl + "/appstatus");
    Thread.Sleep(1000);
    elapsedTime = DateTime.UtcNow.Subtract(startTime);
  2. Sitefinity SDK revised this gist Oct 16, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion SitefinityStatusHelper.cs
    Original file line number Diff line number Diff line change
    @@ -6,7 +6,7 @@
    using System.Threading;
    using System.Web;

    namespace Utilities
    namespace CiUtilities
    {
    public static class SitefinityStatusHelper
    {
  3. Sitefinity SDK revised this gist Oct 16, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion SitefinityStatusHelper.cs
    Original file line number Diff line number Diff line change
    @@ -6,7 +6,7 @@
    using System.Threading;
    using System.Web;

    namespace SitefinityWebApp
    namespace Utilities
    {
    public static class SitefinityStatusHelper
    {
  4. Sitefinity SDK created this gist Oct 16, 2015.
    41 changes: 41 additions & 0 deletions SitefinityStatusHelper.cs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,41 @@
    using Microsoft.Http;
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Net;
    using System.Threading;
    using System.Web;

    namespace SitefinityWebApp
    {
    public static class SitefinityStatusHelper
    {
    /// <summary>
    /// Waits for sitefintiy to start.
    /// </summary>
    /// <param name="testingInstanceUrl">The testing Sitefinity instance url.</param>
    /// <param name="totalWaitSeconds">the maximum wait time in seconds.</param>
    public static void WaitForSitefinityToStart(string testingInstanceUrl, double totalWaitSeconds)
    {
    // While /appstatus service is responding, Sitefinity is either in Initialize or Upgrade state.
    // Since Sitefinity Bootstrap is running on a different than main thread, getting of the tests is postoned until Sitefinity is up and running
    DateTime startTime = DateTime.UtcNow;
    TimeSpan elapsedTime = new TimeSpan();
    HttpResponseMessage response;

    do
    {
    HttpClient client = new HttpClient();
    response = client.Get(testingInstanceUrl + "/appstatus");
    Thread.Sleep(1000);
    elapsedTime = DateTime.UtcNow.Subtract(startTime);

    } while (response.StatusCode == HttpStatusCode.OK && elapsedTime.TotalSeconds < totalWaitSeconds);

    if (elapsedTime.TotalSeconds > totalWaitSeconds)
    {
    throw new Exception("Sitefinity did not start in less than " + totalWaitSeconds / 60 + " minultes.");
    }
    }
    }
    }