private void BindTask() { DateTime lastLogDate = DateTime.MinValue; if (ViewState["lastLogDate"] != null) { lastLogDate = (DateTime)ViewState["lastLogDate"]; } BackgroundTask task = ES.Services.Tasks.GetTaskWithLogRecords(PanelRequest.TaskID, lastLogDate); if (task == null) { RedirectToBrowsePage(); } // bind task details litTitle.Text = String.Format("{0} "{1}"", GetAuditLogTaskName(task.Source, task.TaskName), task.ItemName); litStep.Text = LocalizeActivityText(task.GetLogs().Count > 0 ? task.GetLogs()[0].Text : String.Empty); litStartTime.Text = task.StartDate.ToString(); // progress int percent = 0; if (task.IndicatorMaximum > 0) { percent = task.IndicatorCurrent * 100 / task.IndicatorMaximum; } pnlProgressBar.Width = Unit.Percentage(percent); // duration litDuration.Text = GetDurationText(task.StartDate, DateTime.Now); // execution log StringBuilder log = new StringBuilder(); if (task.GetLogs().Count > 0) { ViewState["lastLogDate"] = task.GetLogs()[0].Date.AddTicks(1); } foreach (BackgroundTaskLogRecord logRecord in task.GetLogs()) { log.Append("[").Append(GetDurationText(task.StartDate, logRecord.Date)).Append("] "); log.Append(GetLogLineIdent(logRecord.TextIdent)); log.Append(LocalizeActivityText(logRecord.Text)); log.Append("<br>"); } litLog.Text = log.ToString();//+ litLog.Text; if (task.Completed) { btnStop.Visible = false; } }
protected void repRecords_ItemDataBound(object sender, RepeaterItemEventArgs e) { BackgroundTaskLogRecord record = (BackgroundTaskLogRecord)e.Item.DataItem; Literal litRecord = (Literal)e.Item.FindControl("litRecord"); Gauge gauge = (Gauge)e.Item.FindControl("gauge"); if (litRecord != null) { string text = record.Text; // localize text string locText = GetSharedLocalizedString("TaskActivity." + text); if (locText != null) { text = locText; } // format parameters if (record.TextParameters != null && record.TextParameters.Length > 0 && record.Severity == 0) { text = String.Format(text, record.TextParameters); } litRecord.Text = text; // gauge gauge.Visible = false; if (e.Item.ItemIndex == task.GetLogs().Count - 1) { if (task.IndicatorCurrent == -1) { litRecord.Text += "..."; } else { gauge.Visible = true; gauge.Total = task.IndicatorMaximum; gauge.Progress = task.IndicatorCurrent; } } } }
private void BindTask(VirtualMachine vm) { task = ES.Services.Tasks.GetTaskWithLogRecords(vm.CurrentTaskId, DateTime.MinValue); if (task == null) { return; } // bind task details litTaskName.Text = String.Format("{0} "{1}"", GetAuditLogTaskName(task.Source, task.TaskName), task.ItemName); // time litStarted.Text = task.StartDate.ToString("T"); TimeSpan d = (TimeSpan)(DateTime.Now - task.StartDate); litElapsed.Text = new TimeSpan(d.Hours, d.Minutes, d.Seconds).ToString(); // bind records repRecords.DataSource = task.GetLogs(); repRecords.DataBind(); }