private async Task WaitUntilJobCompletedAsync(string jobId, int maxWaitInMilliseconds = 5000)
        {
            IMonitoringApi monitoringApi = JobStorage.Current.GetMonitoringApi();

            var           sw         = Stopwatch.StartNew();
            JobDetailsDto jobDetails = null;

            while ((jobDetails == null || jobDetails.History.All(s => s.StateName != "Succeeded")) && (sw.Elapsed.TotalMilliseconds < maxWaitInMilliseconds || Debugger.IsAttached))
            {
                await Task.Delay(25);

                jobDetails = monitoringApi.JobDetails(jobId);
                if (monitoringApi.FailedCount() > 0)
                {
                    break;
                }
            }

            FailedJobDto failedJob = monitoringApi
                                     .FailedJobs(0, int.MaxValue)
                                     .Select(j => j.Value)
                                     .FirstOrDefault();

            if (failedJob != null)
            {
                throw new InvalidOperationException($"Job failed: {failedJob.ExceptionDetails}.");
            }

            _client.Delete(jobId);
        }
Exemple #2
0
        public void JobDetails_ShouldReturnHistory()
        {
            const string jobStateName = "Scheduled";
            const string stateData    = "{\"EnqueueAt\":\"2016-02-21T11:56:05.0561988Z\", \"ScheduledAt\":\"2016-02-21T11:55:50.0561988Z\"}";

            JobDetailsDto result = null;

            _storage.UseConnection(connection =>
            {
                var jobId =
                    connection.ExecuteScalar <string>(
                        "insert into Job (CreatedAt,InvocationData,Arguments,ExpireAt) " +
                        "values (@createdAt, @invocationData, @arguments,@expireAt);" +
                        "set @jobId = last_insert_id(); " +
                        "insert into State (JobId, Name, CreatedAt, Data) " +
                        "values (@jobId, @jobStateName, @createdAt, @stateData);" +
                        "select @jobId;",

                        new
                {
                    createdAt      = _createdAt,
                    invocationData = _invocationData,
                    arguments      = _arguments,
                    expireAt       = _expireAt,
                    jobStateName,
                    stateData
                });

                result = _sut.JobDetails(jobId);
            });

            Assert.Equal(1, result.History.Count);
        }
Exemple #3
0
        /// <summary>
        ///     The mock monitor api with exception.
        /// </summary>
        private void MockMonitorApiWithException()
        {
            var sh = new StateHistoryDto
            {
                Data =
                    new Dictionary <string, string>
                {
                    {
                        "ExceptionMessage",
                        "string message"
                    },
                    {
                        "ExceptionDetails",
                        "string details"
                    }
                },
                CreatedAt = DateTime.Now,
                Reason    = "A reason",
                StateName = "BadState"
            };

            var jd = new JobDetailsDto {
                CreatedAt = DateTime.Now, History = new List <StateHistoryDto> {
                    sh
                }
            };

            this.StateHistoryWithException = jd;
            this.MonitorApiMock.Setup(m => m.JobDetails(It.IsAny <string>())).Returns(jd);
        }
Exemple #4
0
        public async Task <object> RetryParticipationSyncImmediately(
            CrmData data,
            Configurations requestWideSettings,
            bool requestConsumerId = false)
        {
            var jobId = await Task.Run(() => BackgroundJob.Enqueue <ICrmConsumerProvider>(
                                           iCrmProvider =>
                                           iCrmProvider.CreateParticipationAsync(
                                               data,
                                               requestWideSettings,
                                               requestConsumerId)));

            var             result        = new object();
            IMonitoringApi  monitoringApi = JobStorage.Current.GetMonitoringApi();
            JobDetailsDto   jobDetails    = monitoringApi.JobDetails(jobId);
            SucceededJobDto jobDto        = monitoringApi.SucceededJobs(0, int.MaxValue)
                                            .First()
                                            //.FirstOrDefault(job => job.Key == "Key")
                                            .Value;

            if (jobDto != null)
            {
                result = jobDto.Result;
                return(JsonConvert.DeserializeObject <CrmResponse>(result.ToString()));
            }

            return(null);
        }
        public void JobDetails_ShouldReturnHistory()
        {
            const string jobStateName = "Scheduled";
            const string stateData    =
                "{\"EnqueueAt\":\"2016-02-21T11:56:05.0561988Z\", \"ScheduledAt\":\"2016-02-21T11:55:50.0561988Z\"}";

            JobDetailsDto result = null;

            _storage.UseStatelessSession(connection =>
            {
                var newJob = new _Job
                {
                    CreatedAt      = _createdAt,
                    InvocationData = _invocationData,
                    Arguments      = _arguments,
                    ExpireAt       = _expireAt
                };
                connection.Insert(newJob);
                connection.Insert(new _JobState
                {
                    Job       = newJob,
                    CreatedAt = _createdAt,
                    Name      = jobStateName,
                    Data      = stateData
                });
                //does nothing
                var jobId = newJob.Id;

                result = _sut.JobDetails(jobId.ToString());
            });

            Assert.Equal(1, result.History.Count);
        }
Exemple #6
0
        public void JobDetails_ShouldReturnProperties()
        {
            var properties = new Dictionary <string, string>();

            properties["CurrentUICulture"] = "en-US";
            properties["CurrentCulture"]   = "lt-LT";

            JobDetailsDto result = null;

            _storage.UseConnection(connection =>
            {
                var jobId =
                    connection.ExecuteScalar <string>(
                        "insert into Job (CreatedAt,InvocationData,Arguments,ExpireAt) " +
                        "values (@createdAt, @invocationData, @arguments,@expireAt);" +
                        "set @jobId = last_insert_id(); " +
                        "insert into JobParameter (JobId, Name, Value) " +
                        "values (@jobId, 'CurrentUICulture', 'en-US')," +
                        "       (@jobId, 'CurrentCulture', 'lt-LT');" +
                        "select @jobId;",

                        new { createdAt = _createdAt, invocationData = _invocationData, arguments = _arguments, expireAt = _expireAt });

                result = _sut.JobDetails(jobId);
            });

            Assert.Equal(properties, result.Properties);
        }
Exemple #7
0
        public JobDetailsDto JobDetails(string jobId)
        {
            return(UsingDatabase <JobDetailsDto>(db =>
            {
                var job = db.GetTable <Entities.Job>().SingleById(jobId);

                var histories = db.GetTable <Entities.JobState>().Where(js => js.JobId == job.Id).Select(jobState => new StateHistoryDto()
                {
                    CreatedAt = jobState.CreatedAt,
                    Reason = jobState.Reason,
                    StateName = jobState.Name,
                    Data = JsonConvert.DeserializeObject <Dictionary <string, string> >(jobState.Data)
                }).ToList();


                var jobDetailsDto = new JobDetailsDto()
                {
                    CreatedAt = job.CreatedAt,
                    ExpireAt = job.ExpireAt,
                    Properties = db.GetTable <Entities.JobParameter>().Where(jp => jp.JobId == job.Id).ToDictionary(jp => jp.Name, jp => jp.Value),
                    History = histories
                };

                return jobDetailsDto;
            }));
        }
Exemple #8
0
        public void JobDetails_ShouldReturnHistory()
        {
            const string jobStateName = "Scheduled";
            const string stateData    = "{\"EnqueueAt\":\"2016-02-21T11:56:05.0561988Z\", \"ScheduledAt\":\"2016-02-21T11:55:50.0561988Z\"}";

            JobDetailsDto result = null;

            _storage.UseConnection(connection =>
            {
                var param = new DynamicParameters();
                param.Add("createdAt", _createdAt, direction: System.Data.ParameterDirection.Input);
                param.Add("invocationData", _invocationData, direction: System.Data.ParameterDirection.Input);
                param.Add("arguments", _arguments, direction: System.Data.ParameterDirection.Input);
                param.Add("expireAt", _expireAt, direction: System.Data.ParameterDirection.Input);
                param.Add("jobStateName", jobStateName, direction: System.Data.ParameterDirection.Input);
                param.Add("stateData", stateData, direction: System.Data.ParameterDirection.Input);
                param.Add(name: "jobid", dbType: System.Data.DbType.Int32, direction: System.Data.ParameterDirection.Output);

                connection.Execute(@"
declare
    jobid number(11);
begin
    insert into HANGFIRE_JOB (CreatedAt,InvocationData,Arguments,ExpireAt) values (:createdAt, :invocationData, :arguments, :expireAt) returning ID into jobid;
    insert into HANGFIRE_STATE (JobId, Name, CreatedAt, Data) values (jobId, :jobStateName, :createdAt, :stateData);
    :jobId := jobid;
end;", param);

                var jobId = param.Get <int>("jobid");

                result = _sut.JobDetails(jobId.ToString());
            });

            Assert.Equal(1, result.History.Count);
        }
Exemple #9
0
        public void JobDetails_ShouldReturnProperties()
        {
            var properties = new Dictionary <string, string>();

            properties["CurrentUICulture"] = "en-US";
            properties["CurrentCulture"]   = "lt-LT";

            JobDetailsDto result = null;

            _storage.UseConnection(connection =>
            {
                var param = new DynamicParameters();
                param.Add(name: "createdAt", value: _createdAt, direction: System.Data.ParameterDirection.Input);
                param.Add(name: "invocationData", value: _invocationData, direction: System.Data.ParameterDirection.Input);
                param.Add(name: "arguments", value: _arguments, direction: System.Data.ParameterDirection.Input);
                param.Add(name: "expireAt", value: _expireAt, direction: System.Data.ParameterDirection.Input);
                param.Add(name: "jobid", dbType: System.Data.DbType.Int32, direction: System.Data.ParameterDirection.Output);

                connection.Execute(@"
declare 
  jobid number(11);
begin
  insert into HANGFIRE_JOB (CreatedAt,InvocationData,Arguments,ExpireAt) values (:createdAt, :invocationData, :arguments, :expireAt) returning ID into jobid; 
  insert into HANGFIRE_JOBParameter (JobId, Name, Value) values (jobId, 'CurrentUICulture', 'en-US');
  insert into HANGFIRE_JOBParameter (JobId, Name, Value) values (jobId, 'CurrentCulture', 'lt-LT');
  :jobid := jobid;
end;", param);
                var jobId = param.Get <int>("jobid");
                result    = _sut.JobDetails(jobId.ToString());
            });

            Assert.Equal(properties, result.Properties);
        }
Exemple #10
0
        public void JobDetails_ShouldReturnCreatedAtAndExpireAt()
        {
            JobDetailsDto result = null;

            _storage.UseConnection(connection =>
            {
                var param = new DynamicParameters();
                param.Add(name: "createdAt", value: _createdAt, direction: System.Data.ParameterDirection.Input);
                param.Add(name: "invocationData", value: _invocationData, direction: System.Data.ParameterDirection.Input);
                param.Add(name: "arguments", value: _arguments, direction: System.Data.ParameterDirection.Input);
                param.Add(name: "expireAt", value: _expireAt, direction: System.Data.ParameterDirection.Input);
                param.Add(name: "jobid", dbType: System.Data.DbType.Int32, direction: System.Data.ParameterDirection.Output);

                connection.Execute(@"
declare
    jobid number(11);
begin
  insert into HANGFIRE_JOB (CreatedAt,InvocationData,Arguments,ExpireAt) values (:createdAt, :invocationData, :arguments, :expireAt) returning ID into jobid;
  :jobid := jobid;
end;", param);
                var jobId = param.Get <int>("jobid");
                result    = _sut.JobDetails(jobId.ToString());
            });

            Assert.Equal(_createdAt.ToString("yyyy-MM-dd hh:mm:ss"), result.CreatedAt.Value.ToString("yyyy-MM-dd hh:mm:ss"));
            Assert.Equal(_expireAt.ToString("yyyy-MM-dd hh:mm:ss"), result.ExpireAt.Value.ToString("yyyy-MM-dd hh:mm:ss"));
        }
        public void JobDetails_ShouldReturnCreatedAtAndExpireAt()
        {
            JobDetailsDto result = null;

            _storage.UseStatelessSession(connection =>
            {
                var newJob = new _Job
                {
                    CreatedAt      = _createdAt,
                    InvocationData = _invocationData,
                    Arguments      = _arguments,
                    ExpireAt       = _expireAt
                };
                connection.Insert(newJob);
                //does nothing
                var jobId = newJob.Id;

                result = _sut.JobDetails(jobId.ToString());
            });

            Assert.Equal(_createdAt.ToString("yyyy-MM-dd hh:mm:ss"),
                         result.CreatedAt.Value.ToString("yyyy-MM-dd hh:mm:ss"));
            Assert.Equal(_expireAt.ToString("yyyy-MM-dd hh:mm:ss"),
                         result.ExpireAt.Value.ToString("yyyy-MM-dd hh:mm:ss"));
        }
Exemple #12
0
        /// <summary>
        ///     The mock monitor api without history.
        /// </summary>
        private void MockMonitorApiWithoutHistory()
        {
            var jd = new JobDetailsDto {
                CreatedAt = DateTime.Now, History = new List <StateHistoryDto>()
            };

            this.StateHistoryNotFound = jd;
            this.MonitorApiMock.Setup(m => m.JobDetails(It.IsAny <string>())).Returns(jd);
        }
Exemple #13
0
        private JobDto CreateJobDto(string id, JobDetailsDto jobDetails)
        {
            var status = jobDetails.History.FirstOrDefault();

            var jobDto = new JobDto
            {
                Id             = id,
                CreatedAt      = jobDetails.CreatedAt ?? DateTime.MinValue,
                StateChangedAt = status?.CreatedAt,
                Status         = status?.StateName,
                Reason         = status?.Reason
            };

            return(jobDto);
        }
Exemple #14
0
        public void JobDetails_ShouldReturnJob()
        {
            JobDetailsDto result = null;

            _storage.UseConnection(connection =>
            {
                var jobId =
                    connection.ExecuteScalar <string>(
                        "insert into Job (CreatedAt,InvocationData,Arguments,ExpireAt) " +
                        "values (@createdAt, @invocationData, @arguments,@expireAt);" +
                        "select last_insert_id(); ",

                        new { createdAt = _createdAt, invocationData = _invocationData, arguments = _arguments, expireAt = _expireAt });

                result = _sut.JobDetails(jobId);
            });

            Assert.NotNull(result.Job);
        }
Exemple #15
0
        public void JobDetails_ShouldReturnCreatedAtAndExpireAt()
        {
            JobDetailsDto result = null;

            _storage.UseConnection(connection =>
            {
                var jobId =
                    connection.ExecuteScalar <string>(
                        "insert into Job (CreatedAt,InvocationData,Arguments,ExpireAt) " +
                        "values (@createdAt, @invocationData, @arguments,@expireAt);" +
                        "select last_insert_id(); ",
                        new { createdAt = _createdAt, invocationData = _invocationData, arguments = _arguments, expireAt = _expireAt });

                result = _sut.JobDetails(jobId);
            });

            Assert.Equal(_createdAt.ToString("yyyy-MM-dd hh:mm:ss"), result.CreatedAt.Value.ToString("yyyy-MM-dd hh:mm:ss"));
            Assert.Equal(_expireAt.ToString("yyyy-MM-dd hh:mm:ss"), result.ExpireAt.Value.ToString("yyyy-MM-dd hh:mm:ss"));
        }
Exemple #16
0
        public JobDetailsDto Update(JobDetailsDto jobDetails)
        {
            if (sqlUnSafe(jobDetails.AppliedBy) || sqlUnSafe(jobDetails.Id.ToString()))
            {
                throw new Exception("Error occured while updating record. Please contact your supervisor");
            }

            try
            {
                using var conn = new MySqlConnection(connString);
                conn.Open();
                using var command   = conn.CreateCommand();
                command.CommandText = $"UPDATE autoapply_uipath.jobsdetailed SET AppliedBy ='{jobDetails.AppliedBy}', AppliedDate=now()  WHERE JobId = {jobDetails.Id}";
                var a = command.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                throw new Exception("Error occured while updating record. Please contact your supervisor", ex);
            }
            return(jobDetails);
        }
Exemple #17
0
        public HttpResponseMessage Get(Guid id)
        {
            //2 design options-- query the queue or query the side effect of the action.

            IMonitoringApi monitor = JobStorage.Current.GetMonitoringApi();

            JobDetailsDto dto = monitor.JobDetails(QueueMap[id]);

            //if (QueueResults.ContainsKey(id) && QueueResults[id]!=null && QueueResults[id].Url!="")
            if (dto.History.Any(x => x.StateName == "Succeeded"))
            {
                HttpResponseMessage message = new HttpResponseMessage(HttpStatusCode.SeeOther);
                message.Headers.Location = new Uri(QueueResults[id].Url);
                return(message);
            }
            else
            {
                HttpResponseMessage message = new HttpResponseMessage(HttpStatusCode.OK);
                message.Content = new StringContent("Not ready yet, try again in a few seconds.");
                return(message);
            }
        }
        public void JobDetails_ShouldReturnJob()
        {
            JobDetailsDto result = null;

            _storage.UseStatelessSession(connection =>
            {
                var newJob = new _Job
                {
                    CreatedAt      = _createdAt,
                    InvocationData = _invocationData,
                    Arguments      = _arguments,
                    ExpireAt       = _expireAt
                };
                connection.Insert(newJob);
                //does nothing
                var jobId = newJob.Id;


                result = _sut.JobDetails(jobId.ToString());
            });

            Assert.NotNull(result.Job);
        }
        public void JobDetails_ShouldReturnProperties()
        {
            var properties = new Dictionary <string, string>
            {
                ["CurrentUICulture"] = "en-US",
                ["CurrentCulture"]   = "lt-LT"
            };

            JobDetailsDto result = null;

            _storage.UseStatelessSession(connection =>
            {
                var newJob = new _Job
                {
                    CreatedAt      = _createdAt,
                    InvocationData = _invocationData,
                    Arguments      = _arguments,
                    ExpireAt       = _expireAt
                };
                connection.Insert(newJob);

                foreach (var x in properties)
                {
                    connection.Insert(new _JobParameter {
                        Job = newJob, Name = x.Key, Value = x.Value
                    });
                }

                //does nothing
                var jobId = newJob.Id;

                result = _sut.JobDetails(jobId.ToString());
            });

            Assert.Equal(properties, result.Properties);
        }
Exemple #20
0
        public List <JobDetailsDto> GetByPageNum(int first, int last, JobDetailsDto filter)
        {
            //pageNum = (pageNum - 1) * 100;
            var jd = new List <JobDetailsDto>();

            try
            {
                using var conn = new MySqlConnection(connString);
                conn.Open();
                using var command   = conn.CreateCommand();
                command.CommandText = "SELECT JobId, JobTitle, JobUrl, PostedBy, PostedDate, AppliedBy, AppliedDate" +
                                      " FROM autoapply_uipath.jobsdetailed WHERE 1=1 ";
                if (filter.Id != 0 && !sqlUnSafe(filter.Id.ToString()))
                {
                    command.CommandText += $" && JobId LIKE '%{filter.Id}%'";
                }
                if (!string.IsNullOrEmpty(filter.JobTitle) && !sqlUnSafe(filter.JobTitle))
                {
                    command.CommandText += $" && JobTitle  LIKE '%{filter.JobTitle}%'";
                }
                if (!string.IsNullOrEmpty(filter.JobUrl) && !sqlUnSafe(filter.JobUrl))
                {
                    command.CommandText += $" && JobUrl  LIKE '%{filter.JobUrl}%'";
                }
                if (!string.IsNullOrEmpty(filter.PostedBy) && !sqlUnSafe(filter.PostedBy))
                {
                    command.CommandText += $" && PostedBy  LIKE '%{filter.PostedBy}%'";
                }
                if (!string.IsNullOrEmpty(filter.AppliedBy) && !sqlUnSafe(filter.AppliedBy))
                {
                    command.CommandText += $" && AppliedBy  LIKE '%{filter.AppliedBy}%'";
                }


                command.CommandText += $" ORDER BY PostedDate desc, JobId desc, AppliedBy asc LIMIT @last OFFSET @first;";
                command.Parameters.AddWithValue("@last", last);
                command.Parameters.AddWithValue("@first", first);
                var rdr = command.ExecuteReader();
                while (rdr.Read())
                {
                    try
                    {
                        var job = new JobDetailsDto();
                        job.Id          = rdr.GetInt32(0);
                        job.JobTitle    = rdr.IsDBNull("jobtitle") ? "https://www.google.com" : rdr.GetString(1);;
                        job.JobUrl      = rdr.IsDBNull("joburl") ? "" : rdr.GetString(2);
                        job.PostedBy    = rdr.IsDBNull("postedby") ? "" : rdr.GetString(3);
                        job.PostedDate  = rdr.IsDBNull("posteddate") ? (DateTime?)null : rdr.GetDateTime(4);
                        job.AppliedBy   = rdr.IsDBNull("appliedby") ? "" : rdr.GetString(5);
                        job.AppliedDate = rdr.IsDBNull("applieddate") ? (DateTime?)null : rdr.GetDateTime(6);
                        jd.Add(job);
                    }
                    catch (Exception ex)
                    {
                        throw new Exception("Error occured while processing your request. Please contact your supervisor", ex);
                    }
                }
                ;
            }
            catch (Exception ex)
            {
                var a = ex;
            }
            return(jd);
        }
Exemple #21
0
 public JobDetailsModel(string id, JobDetailsDto job)
 {
     Id   = id;
     Name = $"{job.Job.Type.Name}.{job.Job.Method.Name}";
     Job  = BuildJob(id, job.Job);
 }
 public IActionResult GetByPageNum([FromQuery] JobDetailsDto filters, int first = 0, int last = 100)
 {
     return(Ok(_jobDetailsManager.GetByPageNum(first, last, filters)));
 }
 public IActionResult Update([FromBody] JobDetailsDto jobDetails)
 {
     return(Ok(_jobDetailsManager.Update(jobDetails)));
 }
        public override void Execute()
        {
            WriteLiteral("\n");



            #line 11 "..\..\Pages\JobDetailsPage.cshtml"

            var           monitor = JobStorage.Current.GetMonitoringApi();
            JobDetailsDto job     = monitor.JobDetails(JobId.ToString());

            string title = null;

            if (job != null)
            {
                title = job.Job != null?String.Format("{0}.{1}", job.Job.Type.Name, job.Job.Method.Name) : null;
            }

            title = title ?? "Job";

            Layout = new LayoutPage {
                Title = title
            };



            #line default
            #line hidden
            WriteLiteral("\n");



            #line 27 "..\..\Pages\JobDetailsPage.cshtml"
            if (job == null)
            {
            #line default
            #line hidden
                WriteLiteral("    ");

                WriteLiteral(" The job with id \'");



            #line 29 "..\..\Pages\JobDetailsPage.cshtml"
                Write(JobId);


            #line default
            #line hidden
                WriteLiteral("\' was expired or was not existed on the server.\n");



            #line 30 "..\..\Pages\JobDetailsPage.cshtml"
            }
            else
            {
            #line default
            #line hidden
                WriteLiteral("    <div class=\"job-snippet-header\">\n        <span class=\"job-snippet-tab\">\n     " +
                             "       Job ID: <span class=\"job-snippet-id\">");



            #line 35 "..\..\Pages\JobDetailsPage.cshtml"
                Write(HtmlHelper.JobId(JobId.ToString(), false));


            #line default
            #line hidden
                WriteLiteral("</span>\n        </span>\n\n        <span class=\"job-snippet-buttons pull-right\">\n  " +
                             "          <button class=\"btn btn-xs btn-default\" data-ajax=\"");



            #line 39 "..\..\Pages\JobDetailsPage.cshtml"
                Write(Request.LinkTo("/actions/requeue/" + JobId));


            #line default
            #line hidden
                WriteLiteral("\" data-loading-text=\"Enqueueing...\">Requeue</button>\n            <button class=\"b" +
                             "tn btn-xs btn-death\" data-ajax=\"");



            #line 40 "..\..\Pages\JobDetailsPage.cshtml"
                Write(Request.LinkTo("/actions/delete/" + JobId));


            #line default
            #line hidden
                WriteLiteral("\" data-loading-text=\"Deleting...\" data-confirm=\"Do you really want to delete this" +
                             " job?\">Delete</button>\n        </span>\n\n        <div class=\"clearfix\"></div>\n   " +
                             " </div>\n");



                WriteLiteral("    <div class=\"job-snippet\">\n        <div class=\"job-snippet-code\">\n");



            #line 47 "..\..\Pages\JobDetailsPage.cshtml"
                if (job.CreatedAt.HasValue)
                {
            #line default
            #line hidden
                    WriteLiteral("                <div class=\"pull-right job-creation-date\">\n                    Cr" +
                                 "eated\n                    <span data-moment=\"");



            #line 51 "..\..\Pages\JobDetailsPage.cshtml"
                    Write(JobHelper.ToStringTimestamp(job.CreatedAt.Value));


            #line default
            #line hidden
                    WriteLiteral("\"></span>\n                </div>\n");



            #line 53 "..\..\Pages\JobDetailsPage.cshtml"
                }


            #line default
            #line hidden


            #line 54 "..\..\Pages\JobDetailsPage.cshtml"
                if (job != null)
                {
            #line default
            #line hidden
                    WriteLiteral("                <pre><code>");



            #line 56 "..\..\Pages\JobDetailsPage.cshtml"
                    Write(JobMethodCallRenderer.Render(job.Job));


            #line default
            #line hidden
                    WriteLiteral("</code></pre>\n");



            #line 57 "..\..\Pages\JobDetailsPage.cshtml"
                }


            #line default
            #line hidden
                WriteLiteral("            <div class=\"clearfix\"></div>\n        </div>\n\n");



            #line 61 "..\..\Pages\JobDetailsPage.cshtml"
                if (job.Properties.Count > 0)
                {
            #line default
            #line hidden
                    WriteLiteral("            <div class=\"job-snippet-properties\">\n                <dl>\n");



            #line 65 "..\..\Pages\JobDetailsPage.cshtml"
                    foreach (var property in job.Properties)
                    {
            #line default
            #line hidden
                        WriteLiteral("                        <dt>");



            #line 67 "..\..\Pages\JobDetailsPage.cshtml"
                        Write(property.Key);


            #line default
            #line hidden
                        WriteLiteral("</dt>\n");



                        WriteLiteral("                        <dd>\n                            <pre>");



            #line 69 "..\..\Pages\JobDetailsPage.cshtml"
                        Write(property.Value);


            #line default
            #line hidden
                        WriteLiteral("</pre>\n                        </dd>\n");



            #line 71 "..\..\Pages\JobDetailsPage.cshtml"
                    }


            #line default
            #line hidden
                    WriteLiteral("                </dl>\n            </div>\n");



            #line 74 "..\..\Pages\JobDetailsPage.cshtml"
                }


            #line default
            #line hidden
                WriteLiteral("    </div>\n");



            #line 76 "..\..\Pages\JobDetailsPage.cshtml"

                if (job.History.Count > 0)
                {
            #line default
            #line hidden
                    WriteLiteral("        <h3>History</h3>\n");



            #line 80 "..\..\Pages\JobDetailsPage.cshtml"
                    var index = 0;

                    DateTime[] entriesCreationTime = job.History.Select(x => x.CreatedAt).ToArray();
                    var        nextEntry           = 1;

                    foreach (var entry in job.History)
                    {
                        var background = JobHistoryRenderer.BackgroundStateColors.ContainsKey(entry.StateName)
               ? JobHistoryRenderer.BackgroundStateColors[entry.StateName]
               : null;

                        if (index == 0)
                        {
                            background = JobHistoryRenderer.ForegroundStateColors.ContainsKey(entry.StateName)
                    ? JobHistoryRenderer.ForegroundStateColors[entry.StateName]
                    : null;
                        }



            #line default
            #line hidden
                        WriteLiteral("            <div class=\"job-history ");



            #line 98 "..\..\Pages\JobDetailsPage.cshtml"
                        Write(index == 0 ? "job-history-current" : null);


            #line default
            #line hidden
                        WriteLiteral("\">\n                <div class=\"job-history-heading\" style=\"");



            #line 99 "..\..\Pages\JobDetailsPage.cshtml"
                        Write(background != null ? String.Format("background-color: {0};", background) : null);


            #line default
            #line hidden
                        WriteLiteral("\">\n                    <span class=\"pull-right\" data-moment-title=\"");



            #line 100 "..\..\Pages\JobDetailsPage.cshtml"
                        Write(JobHelper.ToStringTimestamp(entry.CreatedAt));


            #line default
            #line hidden
                        WriteLiteral("\">\n                        ");



            #line 101 "..\..\Pages\JobDetailsPage.cshtml"
                        Write(HtmlHelper.ToHumanDuration(entry.CreatedAt - (nextEntry < entriesCreationTime.Length ? entriesCreationTime[nextEntry] : job.CreatedAt)));


            #line default
            #line hidden
                        WriteLiteral("\n");



            #line 102 "..\..\Pages\JobDetailsPage.cshtml"
                        nextEntry++;


            #line default
            #line hidden
                        WriteLiteral("                    </span>\n                    <h4 class=\"job-history-title\">\n  " +
                                     "                      ");



            #line 105 "..\..\Pages\JobDetailsPage.cshtml"
                        Write(entry.StateName);


            #line default
            #line hidden
                        WriteLiteral("\n\n");



            #line 107 "..\..\Pages\JobDetailsPage.cshtml"
                        if (!String.IsNullOrWhiteSpace(entry.Reason))
                        {
            #line default
            #line hidden
                            WriteLiteral("                            <small>");



            #line 109 "..\..\Pages\JobDetailsPage.cshtml"
                            Write(entry.Reason);


            #line default
            #line hidden
                            WriteLiteral("</small>\n");



            #line 110 "..\..\Pages\JobDetailsPage.cshtml"
                        }


            #line default
            #line hidden
                        WriteLiteral("                    </h4>\n                </div>\n\n");



            #line 114 "..\..\Pages\JobDetailsPage.cshtml"
                        if (JobHistoryRenderer.Exists(entry.StateName))
                        {
                            var rendered = JobHistoryRenderer.Render(entry.StateName, entry.Data);
                            if (rendered != null)
                            {
            #line default
            #line hidden
                                WriteLiteral("                        <div class=\"job-history-body\">\n                          " +
                                             "  ");



            #line 120 "..\..\Pages\JobDetailsPage.cshtml"
                                Write(rendered);


            #line default
            #line hidden
                                WriteLiteral("\n                        </div>\n");



            #line 122 "..\..\Pages\JobDetailsPage.cshtml"
                            }
                        }
                        else
                        {
            #line default
            #line hidden
                            WriteLiteral("                    <div class=\"job-history-body\">\n                        <dl cl" +
                                         "ass=\"dl-horizontal\">\n");



            #line 128 "..\..\Pages\JobDetailsPage.cshtml"
                            foreach (var item in entry.Data)
                            {
            #line default
            #line hidden
                                WriteLiteral("                                <dt>");



            #line 130 "..\..\Pages\JobDetailsPage.cshtml"
                                Write(item.Key);


            #line default
            #line hidden
                                WriteLiteral(":</dt>\n");



                                WriteLiteral("                                <dd>");



            #line 131 "..\..\Pages\JobDetailsPage.cshtml"
                                Write(item.Value);


            #line default
            #line hidden
                                WriteLiteral("</dd>\n");



            #line 132 "..\..\Pages\JobDetailsPage.cshtml"
                            }


            #line default
            #line hidden
                            WriteLiteral("                        </dl>\n                    </div>\n");



            #line 135 "..\..\Pages\JobDetailsPage.cshtml"
                        }


            #line default
            #line hidden
                        WriteLiteral("            </div>\n");



            #line 137 "..\..\Pages\JobDetailsPage.cshtml"

                        index++;
                    }
                }
            }

            #line default
            #line hidden
        }