Example #1
0
        internal InvocationLogViewModel(FunctionInstanceSnapshot snapshot, bool?heartbeatIsValid)
        {
            Id                   = snapshot.Id;
            FunctionName         = snapshot.FunctionShortName;
            FunctionId           = snapshot.FunctionId;
            FunctionFullName     = snapshot.FunctionFullName;
            FunctionDisplayTitle = snapshot.DisplayTitle;
            HostInstanceId       = snapshot.HostInstanceId;
            InstanceQueueName    = snapshot.InstanceQueueName;
            if (snapshot.WebSiteName != null &&
                snapshot.WebSiteName == Environment.GetEnvironmentVariable(WebSitesKnownKeyNames.WebSiteNameKey))
            {
                ExecutingJobRunId = new WebJobRunIdentifierViewModel((WebJobTypes)Enum.Parse(typeof(WebJobTypes),
                                                                                             snapshot.WebJobType), snapshot.WebJobName, snapshot.WebJobRunId);
            }
            if (heartbeatIsValid.HasValue)
            {
                Status = snapshot.GetStatusWithHeartbeat(heartbeatIsValid.Value);
            }
            else
            {
                Status = snapshot.GetStatusWithoutHeartbeat();
            }
            switch (Status)
            {
            case FunctionInstanceStatus.Running:
                WhenUtc  = snapshot.StartTime.Value.UtcDateTime;
                Duration = DateTimeOffset.UtcNow - snapshot.StartTime;
                break;

            case FunctionInstanceStatus.CompletedSuccess:
                WhenUtc  = snapshot.EndTime.Value.UtcDateTime;
                Duration = snapshot.GetFinalDuration();
                break;

            case FunctionInstanceStatus.CompletedFailed:
                WhenUtc          = snapshot.EndTime.Value.UtcDateTime;
                Duration         = snapshot.GetFinalDuration();
                ExceptionType    = snapshot.ExceptionType;
                ExceptionMessage = snapshot.ExceptionMessage;
                break;

            case FunctionInstanceStatus.NeverFinished:
                WhenUtc  = snapshot.StartTime.Value.UtcDateTime;
                Duration = null;
                break;
            }
        }
 internal InvocationLogViewModel(FunctionInstanceSnapshot snapshot, bool? heartbeatIsValid)
 {
     Id = snapshot.Id;
     FunctionName = snapshot.FunctionShortName;
     FunctionId = snapshot.FunctionId;
     FunctionFullName = snapshot.FunctionFullName;
     FunctionDisplayTitle = snapshot.DisplayTitle;
     HostInstanceId = snapshot.HostInstanceId;
     InstanceQueueName = snapshot.InstanceQueueName;
     if (snapshot.WebSiteName != null
         && snapshot.WebSiteName == Environment.GetEnvironmentVariable(WebSitesKnownKeyNames.WebSiteNameKey))
     {
         ExecutingJobRunId = new WebJobRunIdentifierViewModel((WebJobType)Enum.Parse(typeof(WebJobType),
             snapshot.WebJobType), snapshot.WebJobName, snapshot.WebJobRunId);
     }
     if (heartbeatIsValid.HasValue)
     {
         Status = snapshot.GetStatusWithHeartbeat(heartbeatIsValid.Value);
     }
     else
     {
         Status = snapshot.GetStatusWithoutHeartbeat();
     }
     switch (Status)
     {
         case FunctionInstanceStatus.Running:
             WhenUtc = snapshot.StartTime.Value.UtcDateTime;
             Duration = DateTimeOffset.UtcNow - snapshot.StartTime;
             break;
         case FunctionInstanceStatus.CompletedSuccess:
             WhenUtc = snapshot.EndTime.Value.UtcDateTime;
             Duration = snapshot.GetFinalDuration();
             break;
         case FunctionInstanceStatus.CompletedFailed:
             WhenUtc = snapshot.EndTime.Value.UtcDateTime;
             Duration = snapshot.GetFinalDuration();
             ExceptionType = snapshot.ExceptionType;
             ExceptionMessage = snapshot.ExceptionMessage;
             break;
         case FunctionInstanceStatus.NeverFinished:
             WhenUtc = snapshot.StartTime.Value.UtcDateTime;
             Duration = null;
             break;
     }
 }